@farris/ui-vue
Version:
Farris Vue, a Farris Design based Vue3 component library.
2 lines (1 loc) • 37 kB
JavaScript
(function(V,I){typeof exports=="object"&&typeof module<"u"?I(exports,require("../../components/common/index.umd.js"),require("../../components/dynamic-resolver/index.umd.js"),require("../../components/button-edit/index.umd.js"),require("vue"),require("../../components/locale/index.umd.js"),require("../../components/property-panel/index.umd.js"),require("../../components/button/index.umd.js"),require("../../components/field-selector/index.umd.js"),require("../../components/collection-property-editor/index.umd.js/src/use-button-items.designer"),require("../../components/designer-canvas/index.umd.js")):typeof define=="function"&&define.amd?define(["exports","../../components/common/index.umd.js","../../components/dynamic-resolver/index.umd.js","../../components/button-edit/index.umd.js","vue","../../components/locale/index.umd.js","../../components/property-panel/index.umd.js","../../components/button/index.umd.js","../../components/field-selector/index.umd.js","../../components/collection-property-editor/index.umd.js/src/use-button-items.designer","../../components/designer-canvas/index.umd.js"],I):(V=typeof globalThis<"u"?globalThis:V||self,I(V["button-edit"]={},V.common,V.dynamicResolver,V.FButtonEdit,V.Vue,V.locale,null,null,null,null,V.designerCanvas))})(this,function(V,I,A,se,e,J,ut,ct,dt,ft,he){"use strict";var it=Object.defineProperty;var rt=(V,I,A)=>I in V?it(V,I,{enumerable:!0,configurable:!0,writable:!0,value:A}):V[I]=A;var G=(V,I,A)=>rt(V,typeof I!="symbol"?I+"":I,A);const ve={id:{type:String,default:""},buttonContent:{type:String,default:'<i class="f-icon f-icon-lookup"></i>'},buttonBehavior:{type:String,default:"Popup"},autoComplete:{type:Boolean,default:!1},customClass:{type:String,default:""},disable:{type:Boolean,default:!1},editable:{type:Boolean,default:!0},enableClear:{type:Boolean,default:!1},modelValue:{type:String,default:""},readonly:{type:Boolean,default:!1},showButtonWhenDisabled:{type:Boolean,default:!1},showAppendButton:{type:Boolean,default:!0},enableTitle:{type:Boolean,default:!1},inputType:{type:String,default:"text"},forcePlaceholder:{type:Boolean,default:!1},placeholder:{type:String,default:""},minLength:Number,maxLength:{type:Number},tabIndex:Number,popupHost:{type:Object},popupRightBoundary:{type:Object},popupOffsetX:{type:Object,default:0},popupOffsetY:{type:Object,default:0},popupOnInput:{type:Boolean,default:!1},popupOnFocus:{type:Boolean,default:!1},popupOnClick:{type:Boolean,default:!1},popupClass:{type:String,default:""},popupMinWidth:{type:Number,default:160},modalOptions:{type:Object,default:{}},wrapText:{type:Boolean,default:!1},multiSelect:{type:Boolean,default:!1},separator:{type:String,default:","},textAlign:{type:String,default:"left"},beforeClickButton:{type:Function,default:null},focusOnCreated:{type:Boolean,default:!1},selectOnCreated:{type:Boolean,default:!1},beforeOpen:{type:Function,default:null},updateOn:{type:String,default:"change"},keepWidthWithReference:{type:Boolean,default:!0},placement:{type:String,default:"bottom-left"},limitContentBySpace:{type:Boolean,default:!1},beforeClosePopup:{type:Function,default:null},expandable:{type:Boolean,default:!1},expandMode:{type:String,default:"text"},expandContent:{type:String,default:""},expandDisabled:{type:Boolean,default:!1}},ye={popupContentPosition:{type:Object,default:{left:0,top:0}},host:{type:Object},backgroundColor:{type:String,default:""}};function ge(){const t=e.ref(!1);return e.onMounted(()=>{t.value=!0}),t}const be=e.defineComponent({name:"FOverlay",props:ye,emits:["click"],setup(t,n){const a=e.ref(t.popupContentPosition),o=e.ref(t.host),d=ge(),i=e.computed(()=>({backgroundColor:t.backgroundColor||"",pointerEvents:"auto"}));function p(u){n.emit("click"),u.preventDefault(),u.stopPropagation()}e.computed(()=>{const u=o.value;if(u){const h=u.getBoundingClientRect(),{left:x,top:y,height:k}=h;return{left:x,top:y+k}}return a.value});const f=e.computed(()=>({}));return()=>d.value?e.createVNode(e.Teleport,{to:"body"},{default:()=>{var u,h;return[e.createVNode("div",{class:"overlay-container",onClick:x=>p(x),style:i.value},[e.createVNode("div",{style:f.value},[(h=(u=n.slots).default)==null?void 0:h.call(u)])])]}}):null}});function we(t){if(t.content&&t.content.render)return t.content.render;if(t.render&&typeof t.render=="function")return t.render}function Ce(t){const n=document.createElement("div");n.style.display="contents";let a;const o=t.onClickCallback||(()=>{}),d=()=>{o(),a&&a.unmount()};return a=e.createApp({setup(){e.onUnmounted(()=>{document.body.removeChild(n)});const i=we(t);return()=>e.createVNode(be,{"popup-content-position":t.popupPosition,host:t.host,onClick:d,backgroundColor:t.backgroundColor},{default:()=>[i&&i()]})}}),document.body.appendChild(n),a.mount(n),a}class xe{static show(n){return Ce(n)}}const Me={allowClickMaskToClose:{type:Boolean,default:!1},beforeClose:{type:Function,default:()=>!0},class:{type:String,default:""},maskClass:{type:String,default:""},title:{type:String,default:""},width:{type:Number,default:500},height:{type:Number,default:320},buttons:{type:Array,default:[]},modelValue:{type:Boolean,default:!1},mask:{type:Boolean,default:!0},showHeader:{type:Boolean,default:!0},showButtons:{type:Boolean,default:!0},fitContent:{type:Boolean,default:!0},showCloseButton:{type:Boolean,default:!0},showFloatingClose:{type:Boolean,default:!1},showMaxButton:{type:Boolean,default:!1},minHeight:{type:Number},maxHeight:{type:Number},minWidth:{type:Number},maxWidth:{type:Number},containment:{type:Object,default:null},resizeable:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},dragHandle:{type:Object,default:null},closedCallback:{type:Function,default:null},openedCallback:{type:Function,default:null},resizeHandle:{type:Function,default:null},render:{type:Function,default:null},acceptCallback:{type:Function,default:null},rejectCallback:{type:Function,default:null},enableEsc:{type:Boolean,default:!0},enableEnter:{type:Boolean,default:!1},dialogType:{type:String,default:""},src:{type:String,default:""},footerHeight:{type:Number,default:60},position:{type:String,default:"center"},host:{type:Object,default:"body"},isMessager:{type:Boolean,default:!1},fullscreen:{type:Boolean,default:!1},maximized:{type:Boolean,default:!1},useTransform:{type:Boolean,default:!0}};class N{constructor(n,a){this.x=n,this.y=a}static getTransformInfo(n){const o=window.getComputedStyle(n).getPropertyValue("transform").replace(/[^-\d,]/g,"").split(",");if(o.length>=6){const d=parseInt(o[4],10),i=parseInt(o[5],10);return{x:d,y:i}}return{x:0,y:0}}static fromEvent(n,a=null){if(this.isMouseEvent(n))return new N(n.clientX,n.clientY);if(a===null||n.changedTouches.length===1)return new N(n.changedTouches[0].clientX,n.changedTouches[0].clientY);for(let o=0;o<n.changedTouches.length;o++)if(n.changedTouches[o].target===a)return new N(n.changedTouches[o].clientX,n.changedTouches[o].clientY)}static isMouseEvent(n){return Object.prototype.toString.apply(n).indexOf("MouseEvent")===8}static isIPosition(n){return!!n&&"x"in n&&"y"in n}static getCurrent(n){const a=new N(0,0);if(window){const o=window.getComputedStyle(n);if(o){const d=parseInt(o.getPropertyValue("left"),10),i=parseInt(o.getPropertyValue("top"),10);a.x=isNaN(d)?0:d,a.y=isNaN(i)?0:i}return a}return null}static copy(n){return new N(0,0).set(n)}get value(){return{x:this.x,y:this.y}}add(n){return this.x+=n.x,this.y+=n.y,this}subtract(n){return this.x-=n.x,this.y-=n.y,this}multiply(n){this.x*=n,this.y*=n}divide(n){this.x/=n,this.y/=n}reset(){return this.x=0,this.y=0,this}set(n){return this.x=n.x,this.y=n.y,this}}class ${constructor(n,a){this.width=n,this.height=a}static getCurrent(n){const a=new $(0,0);if(window){const o=window.getComputedStyle(n);return o&&(a.width=parseInt(o.getPropertyValue("width"),10),a.height=parseInt(o.getPropertyValue("height"),10)),a}return null}static copy(n){return new $(0,0).set(n)}set(n){return this.width=n.width,this.height=n.height,this}}function Be(t,n){const a=e.ref(),o=e.ref(),d=e.ref(),i=e.ref(),p=e.ref(),f=e.ref(),u=e.ref(),h=e.ref(),x=e.ref(),y=e.ref(),k=e.ref(),w=e.ref(t.resizeable),M=e.ref(),B=e.ref(t.draggable),j=e.ref(!1);function P(){const r=o.value||document.body,c=window.getComputedStyle(r);if(!c||!a.value)return;const C=N.getTransformInfo(a.value),b={};u.value&&(b.deltaL=a.value.offsetLeft-u.value.x,b.deltaT=a.value.offsetTop-u.value.y);const T=c.getPropertyValue("position");b.width=r.clientWidth,b.height=r.clientHeight,b.pr=parseInt(c.getPropertyValue("padding-right"),10),b.pb=parseInt(c.getPropertyValue("padding-bottom"),10),b.position=c.getPropertyValue("position"),T==="static"&&(r.style.position="relative"),b.translateX=C.x,b.translateY=C.y,y.value=b}function E(r){if(a.value){i.value=$.getCurrent(a.value),p.value=N.getCurrent(a.value),f.value=i.value?$.copy(i.value):null,u.value=p.value?N.copy(p.value):null,P();const c=r.target.getAttribute("type")||"";h.value={n:!!c.match(/n/),s:!!c.match(/s/),w:!!c.match(/w/),e:!!c.match(/e/)}}}function S(){var r,c,C,b;if(a.value){const T=a.value;h.value&&((h.value.n||h.value.s)&&((r=f.value)!=null&&r.height)&&(T.style.height=f.value.height+"px"),(h.value.w||h.value.e)&&((c=f.value)!=null&&c.width)&&(T.style.width=f.value.width+"px"),u.value&&((C=u.value)!=null&&C.x&&(T.style.left=u.value.x+"px"),(b=u.value)!=null&&b.y&&(T.style.top=u.value.y+"px")))}}function H(){const r=t.minHeight?t.minHeight:1,c=t.minWidth?t.minWidth:1;f.value&&u.value&&h.value&&i.value&&(f.value.height<r&&(f.value.height=r,h.value.n&&p.value&&(u.value.y=p.value.y+(i.value.height-r))),f.value.width<c&&(f.value.width=c,h.value.w&&p.value&&(u.value.x=p.value.x+(i.value.width-c))),t.maxHeight&&f.value.height>t.maxHeight&&(f.value.height=t.maxHeight,p.value&&h.value.n&&(u.value.y=p.value.y+(i.value.height-t.maxHeight))),t.maxWidth&&f.value.width>t.maxWidth&&(f.value.width=t.maxWidth,h.value.w&&p.value&&(u.value.x=p.value.x+(i.value.width-t.maxWidth))))}function q(){if(o.value){const r=y.value;if(u.value&&f.value&&h.value&&i.value){const c=r.width-r.pr-r.deltaL-r.translateX-u.value.x,C=r.height-r.pb-r.deltaT-r.translateY-u.value.y;h.value.n&&u.value.y+r.translateY<0&&p.value&&(u.value.y=-r.translateY,f.value.height=i.value.height+p.value.y+r.translateY),h.value.w&&u.value.x+r.translateX<0&&p.value&&(u.value.x=-r.translateX,f.value.width=i.value.width+p.value.x+r.translateX),f.value.width>c&&(f.value.width=c),f.value.height>C&&(f.value.height=C)}}}function F(r){if(!d.value||!i.value||!p.value||!h.value)return;r.subtract(d.value);const c=r.x,C=r.y;h.value.n?(u.value.y=p.value.y+C,f.value.height=i.value.height-C):h.value.s&&(f.value.height=i.value.height+C),h.value.e?f.value.width=i.value.width+c:h.value.w&&(f.value.width=i.value.width-c,u.value.x=p.value.x+c),q(),H(),S()}function m(r){if(!x.value)return;const c=N.fromEvent(r);c&&F(c)}function s(){if(a.value){const{width:r,height:c,x:C,y:b}=a.value.getBoundingClientRect(),T=N.getTransformInfo(a.value);return{size:{width:r,height:c},position:{x:C-T.x,y:b-T.y}}}return null}function g(r){if(a.value){const c=s();k.value=c}d.value=void 0,i.value=null,p.value=null,f.value=null,u.value=null,h.value=null,x.value=null,document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",g)}function R(){document.addEventListener("mousemove",m),document.addEventListener("mouseup",g)}function L(r){r instanceof MouseEvent&&r.button===2||B.value&&(document.body.click(),r.stopPropagation(),r.preventDefault(),d.value=N.fromEvent(r),x.value=r.target,E(r),R())}function D(r){return a.value=r,w.value&&e.createVNode(e.Fragment,null,[e.createVNode("div",{class:"fv-resizable-handle fv-resizable-n",type:"n",onMousedown:c=>L(c)},null),e.createVNode("div",{class:"fv-resizable-handle fv-resizable-e",type:"e",onMousedown:c=>L(c)},null),e.createVNode("div",{class:"fv-resizable-handle fv-resizable-s",type:"s",onMousedown:c=>L(c)},null),e.createVNode("div",{class:"fv-resizable-handle fv-resizable-w",type:"w",onMousedown:c=>L(c)},null),e.createVNode("div",{class:"fv-resizable-handle fv-resizable-ne",type:"ne",onMousedown:c=>L(c)},null),e.createVNode("div",{class:"fv-resizable-handle fv-resizable-se fv-resizable-diagonal",type:"se",onMousedown:c=>L(c)},null),e.createVNode("div",{class:"fv-resizable-handle fv-resizable-sw",type:"sw",onMousedown:c=>L(c)},null),e.createVNode("div",{class:"fv-resizable-handle fv-resizable-nw",type:"nw",onMousedown:c=>L(c)},null)])}function W(r=!0){document.body.click();const c=o.value||document.body,C=$.getCurrent(c),b=a.value;r&&b&&(M.value=s(),M.value.transform=b.style.transform),C&&b&&(f.value=C,f.value.height-=14,f.value.width-=14,b.style.height=f.value.height+"px",b.style.width=f.value.width+"px",b.style.left="7px",b.style.top="7px",b.style.transform="",k.value={size:f.value,position:{x:0,y:0}},B.value=!1,j.value=!0)}function te(){var r,c;if(document.body.click(),M.value){const C={width:M.value.size.width||0,height:M.value.size.height||0},b={x:(window.innerWidth-C.width)/2,y:(window.innerHeight-C.height)/2};(r=f.value)==null||r.set(C),(c=u.value)==null||c.set(b);const T=a.value;T.style.height=C.height+"px",T.style.width=C.width+"px",T.style.left=`${b.x}px`,T.style.top=`${b.y}px`,T.style.transform="",k.value={size:C,position:b},B.value=t.draggable,j.value=!1}}function Z(){if(a.value){const r=$.getCurrent(a.value);if(r){const{width:c,height:C}=r;a.value.style.left=`${(window.innerWidth-c)/2}px`,a.value.style.top=`${(window.innerHeight-C)/2}px`,a.value.style.transform=""}}}function ne(){const r=()=>{j.value?W(!1):Z(),document.body.click()};return window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r)}}const U=ne();return{renderResizeBar:D,boundingElement:o,resizedEventParam:k,maximize:W,restore:te,allowDrag:B,isMaximized:j,unWindowResizeHandle:U,moveToCenter:Z}}function ke(t,n,a){const o=e.ref(),d=e.ref(t.draggable),i=e.ref(t.lockAxis),p=e.ref(),f=e.ref(),u=e.ref(!1),h=e.ref(new N(0,0)),x=e.ref(new N(0,0)),y=e.ref(new N(0,0)),k=e.ref(new N(0,0));e.watch(()=>a.value,m=>{p.value.style.cursor=m?"move":"default"});function w(m,s){if(s.tagName==="BUTTON")return!1;if(s===m)return!0;for(const g in s.children)if(Object.prototype.hasOwnProperty.call(s.children,g)&&w(m,s.children[g]))return!0;return!1}function M(){var R,L;let m=y.value.x+x.value.x,s=y.value.y+x.value.y;i.value==="x"?(m=((R=h.value)==null?void 0:R.x)||0,y.value.x=0):i.value==="y"&&(s=((L=h.value)==null?void 0:L.y)||0,y.value.y=0);const g=`translate3d(${Math.round(m)}px, ${Math.round(s)}px, 0px)`;o.value&&(o.value.style.transform=g),k.value.x=m,k.value.y=s}function B(){if(!f.value||!o.value)return null;const m=f.value.getBoundingClientRect(),s=o.value.getBoundingClientRect(),g={top:m.top<s.top,right:m.right>s.right,bottom:m.bottom>s.bottom,left:m.left<s.left};return g.top||(y.value.y-=s.top-m.top),g.bottom||(y.value.y-=s.bottom-m.bottom),g.right||(y.value.x-=s.right-m.right),g.left||(y.value.x-=s.left-m.left),M(),g}function j(m){m&&(h.value&&m.subtract(h.value),y.value.set(m),M(),B())}function P(m){u.value&&d.value&&(m.stopPropagation(),m.preventDefault(),j(N.fromEvent(m,p.value)))}function E(){var m;if(u.value){if(u.value=!1,x.value.add(y.value),y.value.reset(),(m=o.value)==null||m.classList.remove("ng-dragging"),!t.useTransform&&o.value){const{left:s,top:g}=o.value.getBoundingClientRect();o.value.style.left=Math.ceil(s)+"px",o.value.style.top=Math.ceil(g)+"px",o.value.style.transform="none"}n.emit("stopMove"),document.removeEventListener("mousemove",P),document.removeEventListener("mouseup",E)}}function S(){!u.value&&p.value&&(u.value=!0,p.value.classList.add("ng-dragging"),document.addEventListener("mousemove",P),document.addEventListener("mouseup",E))}function H(){if(o.value){const m=N.getTransformInfo(o.value);x.value.set(m);return}x.value.reset()}function q(m){if(!a.value||m instanceof MouseEvent&&m.button===2)return;const s=m.target||m.srcElement;p.value!==void 0&&s&&!w(s,p.value)||d.value!==!1&&(document.body.click(),m.stopPropagation(),m.preventDefault(),h.value=N.fromEvent(m,o.value),H(),S())}function F(m,s,g){if(d.value&&s){if(m)p.value=m;else if(t.dragHandle){if(t.dragHandle instanceof HTMLElement)p.value=t.dragHandle;else if(typeof t.dragHandle=="string"){const R=s.querySelector(t.dragHandle);R&&(p.value=R)}}o.value=s,f.value=g,p.value?(p.value.classList.add("ng-draggable"),p.value.addEventListener("mousedown",q)):d.value=!1}}return{registerDraggle:F,resetTranslate:H}}function ie(t,n){if(t){const a=o=>{o.key.toLowerCase()===t.toLowerCase()&&n({event:o,key:t})};return document.addEventListener("keydown",a),()=>{document.removeEventListener("keydown",a)}}}function Ee(t,n){const a=e.ref(t.enableEsc);let o=null;return a.value?(o=ie("Escape",d=>{n.emit("esc",{event:d.event,type:"esc"})}),{remove:o}):null}function Oe(t,n){const a=e.ref(t.enableEnter);let o=null;return a.value?(o=ie("Enter",d=>{n.emit("enter",{event:d.event,type:"enter"})}),{remove:o}):null}const K=e.defineComponent({name:"FModal",props:Me,emits:["update:modelValue","accept","cancel","closed","resize","esc","enter","stopMove","buttonClick"],setup(t,n){const a=e.ref(t.width||300),o=e.ref(t.height||200),d=e.ref(t.modelValue),i=e.ref(""),p=e.ref(t.class),f=e.ref(t.fitContent),u=e.ref(t.showHeader),h=e.ref(""),x=e.ref(t.showCloseButton),y=e.ref(t.showMaxButton),k=e.ref(!1),w=e.ref(t.dialogType),M=e.ref(t.src),B=e.ref(""),j=e.ref(t.showButtons),P=e.ref(t.title),E=e.ref(t.containment||null),S=e.ref();P.value==="错误提示"&&(P.value=J.LocaleService.getLocaleValue("messageBox.errorTitle"));const H=e.ref(!1);function q(){const l=document.querySelectorAll(".farris-modal").length;(!l||l-1<=0)&&S.value===document.querySelectorAll(".farris-modal")[0]&&document.body.classList.remove("modal-open"),S.value&&S.value.classList.remove("show")}function F(l,v){const O=v?"accept":"cancel";Promise.resolve().then(()=>{var z;return(z=t.beforeClose)==null?void 0:z.call(t,{closeType:O})}).then(z=>{z&&(d.value=!1,n.emit("update:modelValue",!1),v!=null&&n.emit(v?"accept":"cancel"),n.emit("closed",l),q())})}const m=[{name:"cancel",text:J.LocaleService.getLocaleValue("messageBox.cancel")||"取消",class:"btn btn-secondary",handle:l=>{F(l,!1)}},{name:"accept",text:J.LocaleService.getLocaleValue("messageBox.ok")||"确定",class:"btn btn-primary",handle:l=>{F(l,!0)}}],s=e.ref(t.buttons&&t.buttons.length?t.buttons:m),g=e.computed(()=>!!h.value),R=e.computed(()=>!!j.value&&!!s.value),L=e.ref(),D=e.ref(),W=e.ref(t.maximized||!1),{renderResizeBar:te,maximize:Z,restore:ne,boundingElement:U,resizedEventParam:r,allowDrag:c,unWindowResizeHandle:C,moveToCenter:b}=Be(t),{registerDraggle:T}=ke(t,n,c);function de(){return!!document.querySelectorAll(".farris-modal").length&&document.body.classList.contains("modal-open")}e.watch(()=>t.title,(l,v)=>{l!==v&&(P.value=l)}),e.watch(()=>t.modelValue,(l,v)=>{l!==v&&(d.value=l,d.value&&t.draggable&&e.nextTick(()=>{D.value&&!E.value&&(E.value=D.value.parentElement,U.value=E.value,T(L.value,D.value,U.value),b())}),l||(E.value&&(E.value=null),q())),d.value?H.value=de():(W.value=!1,c.value=t.draggable)}),e.watch(()=>t.showHeader,(l,v)=>{l!==v&&(u.value=l)}),e.watch(()=>t.showButtons,(l,v)=>{l!==v&&(j.value=l)}),e.watch(()=>r.value,(l,v)=>{const O=l||{},z=v||{};JSON.stringify(O)!==JSON.stringify(z)&&n.emit("resize",{newSize:l,oldSize:v,isMaximized:W.value})}),e.watch([()=>t.width,()=>t.height],(l,v)=>{(l[0]!==v[0]||l[1]!==v[1])&&(a.value=l[0]||500,o.value=l[1]||600)}),e.watch(()=>t.class,(l,v)=>{p.value=l});const Q=e.computed(()=>(d.value&&document.body.classList.add("modal-open"),d.value)),Le=e.computed(()=>{var O;const l={modal:!0,"farris-modal":!0,fade:!0,"fe-cmp-page-modal":!!t.showFloatingClose};l["f-modal-fitContent"]=!!f.value,l.show=!!Q.value;const v=(O=t.maskClass)==null?void 0:O.split(" ");return v==null||v.reduce((z,Y)=>(z[Y]=!0,z),l),l}),Fe=e.computed(()=>{var O;const l={"modal-dialog":!0},v=(O=p.value)==null?void 0:O.split(" ");return v==null||v.reduce((z,Y)=>(z[Y]=!0,z),l),l}),We=()=>I.isMobilePhone()&&!t.isMessager||!!t.fullscreen,De=e.computed(()=>{const l=document.documentElement.clientWidth,v=document.documentElement.clientHeight;if(W.value)return{position:"fixed",top:"0px",left:"0px",width:"100vw",height:"100vh",margin:"0"};const O=Math.min(a.value,l),z=t.position==="right"?"100%":f.value?"auto":`${Math.min(o.value,v-10)}px`,Y=`${(window.innerHeight-(z==="100%"||z==="auto"?0:parseInt(z)))/2}px`,st=t.position==="right"?`${window.innerWidth-O}px`:`${(window.innerWidth-O)/2}px`,me={position:"absolute",top:Y,left:st,width:I.isMobilePhone()?"auto":`${O}px`,height:z};return t.mask||(me.pointerEvents="auto"),me}),fe=e.ref(I.getMaxZIndex()||1050),Ae=e.computed(()=>{const l={display:"block",overflow:"hidden"};return t.mask||(l.pointerEvents="none",l.backgroundColor="transparent"),H.value&&(l.backgroundColor="transparent"),l.zIndex=fe.value,l}),$e=e.computed(()=>({"modal-content":!0,"modal-content-has-header":u.value,"is-mobile":We()})),qe=e.computed(()=>{const l={display:u.value?"":"none"};return l["pointer-events"]=c.value?"auto":"none",l}),Ye=e.computed(()=>({"f-icon":!0,modal_maximize:!0,modalrevert:W.value})),Xe=e.computed(()=>({"modal-body":!0,"f-utils-flex-column":w.value==="iframe","f-utils-fill":!0}));function Ue(){return{height:`${t.footerHeight||60}px`}}const Ge=e.computed(()=>{const l={textAlgin:B.value},v=Ue();return Object.assign(l,v)});function le(l){if(l==null||l.stopPropagation(),W.value){W.value=!1,ne();return}Z(),W.value=!0}async function Ke(l,v){l.handle?await l.handle(v,l)&&n.emit("closed",v):n.emit("buttonClick",{button:l,$event:v})}function _e(l){l.width&&(a.value=l.width),l.height&&(o.value=l.height),l.buttons&&(s.value=l.buttons),l.title&&(P.value=l.title)}let ae=null,oe=null;e.onBeforeMount(()=>{H.value=de()}),e.onMounted(()=>{D.value&&!E.value&&(E.value=D.value.parentElement,U.value=E.value,T(L.value,D.value,U.value)),Q.value&&document.body.classList.add("modal-open"),ae=Ee(t,n),oe=Oe(t,n)}),e.onUnmounted(()=>{C&&C(),ae&&ae.remove(),oe&&oe.remove()}),n.expose({modalElementRef:D,updateModalOptions:_e,close:F,maxDialog:le,isMaximized:W,disableButtons:(l,v=!0)=>{s.value.forEach(O=>{O.name&&l.includes(O.name)&&(O.disabled=v)})}});function Je(){return e.createVNode("div",{class:"action-wrapper",onClick:l=>F(l,!1)},[e.createVNode("span",{class:"close-icon"},[e.createVNode("i",{class:"f-icon f-icon-close"},null)])])}function Ze(){return e.createVNode("ul",null,[k.value&&e.createVNode("li",{class:"f-btn-icon f-bare"},[e.createVNode("span",{class:"f-icon modal_minimize"},null)]),y.value&&e.createVNode("li",{onClick:le,class:"f-btn-icon f-bare",style:"pointer-events: auto;"},[e.createVNode("span",{class:Ye.value},null)]),x.value&&e.createVNode("li",{class:"f-btn-icon f-bare",onClick:l=>F(l,!1),style:"pointer-events: auto;"},[e.createVNode("span",{class:"f-icon modal_close"},null)])])}const Qe=l=>{l.preventDefault();const v=l.currentTarget,O=l.deltaY*.5;v.scrollLeft+=O};function et(){return e.createVNode("div",{class:"modal-footer",style:Ge.value},[s.value&&e.createVNode("div",{class:"buttons",onWheel:Qe},[s.value.map(l=>{var z;const v=e.ref(l.disabled),O=l.class||((z=l.appearance)==null?void 0:z.class);return e.createVNode("button",{name:l.name,style:l.styles,type:"button",disabled:v.value,class:O+(l.iconClass?" btn-icontext":"")+(l.visible===!1?"d-none":""),onClick:Y=>{Ke(l,Y)}},[!!l.iconClass&&e.createVNode("i",{class:l.iconClass},null),l.text])})])])}function pe(l){y.value&&le()}function tt(){return e.createVNode(e.Fragment,null,[W.value&&e.createVNode("div",{class:"modal-header",style:"position: absolute;background: transparent;height: 45px;width: 100%;",onDblclick:l=>pe()},null),e.createVNode("div",{ref:L,class:"modal-header",style:qe.value,onDblclick:l=>pe()},[n.slots.headerTemplate?n.slots.headerTemplate():e.createVNode("div",{class:"modal-title"},[g.value&&e.createVNode("span",{class:h.value,style:"margin-right: 8px"},null),e.createVNode("span",{class:"modal-title-label"},[P.value])]),e.createVNode("div",{class:"actions"},[Ze()])])])}function nt(){return n.slots.footerTemplate?n.slots.footerTemplate():R.value&&et()}function lt(l){if(l.stopPropagation(),t.allowClickMaskToClose){if(l.target!==S.value)return;F(l,!1)}}function at(){var l,v;return e.createVNode("div",{id:i.value,class:Fe.value,style:De.value,ref:D},[t.showFloatingClose&&Je(),e.createVNode("div",{class:$e.value},[u.value&&tt(),e.createVNode("div",{class:Xe.value},[(v=(l=n.slots).default)==null?void 0:v.call(l),w.value==="iframe"&&e.createVNode("iframe",{title:i.value,class:"f-utils-fill",width:"100%",frameborder:"0",src:M.value},null)]),nt()]),!f.value&&D.value&&!W.value&&te(D.value)])}function ot(l){return l||"body"}return e.watchEffect(()=>{Q.value&&(fe.value=I.getMaxZIndex()||1050)}),()=>e.createVNode(e.Teleport,{to:ot(t.host)},{default:()=>[Q.value&&e.createVNode(e.Transition,{name:"fade",appear:!0},{default:()=>[e.createVNode("div",{ref:S,class:Le.value,style:Ae.value,onClick:lt},[at()])]})]})}});function re(t){if(t.content&&t.content.render)return t.content.render;if(t.render&&typeof t.render=="function")return t.render}function Ve(t){const n=document.createElement("div");n.style.display="contents";const a=e.createApp({setup(o,d){e.onUnmounted(()=>{document.body.removeChild(n)});const i=e.ref(),p=e.ref(t.class||""),f=e.ref(!!t.showButtons),u=e.ref(!!t.showHeader),h=e.ref(t.showCloseButton==null?!0:t.showCloseButton),x=e.ref(!!t.showFloatingClose),y=e.ref(!0),k=e.ref(t.title||""),w=t.acceptCallback||(()=>{}),M=t.rejectCallback||(()=>{}),B=t.closedCallback||(H=>{}),j=t.resizeHandle||(H=>{}),P=t.stopMoveHandle||(H=>{}),E=re(t),S=H=>{y.value=!1,a.unmount(),B(H)};return e.onMounted(()=>{}),d.expose({modalRef:i}),()=>e.createVNode(K,{ref:i,class:p.value,modelValue:y.value,"onUpdate:modelValue":H=>y.value=H,title:k.value,width:t.width,height:t.height,buttons:t.buttons,"show-header":u.value,"show-buttons":f.value,"show-close-button":h.value,"show-max-button":!1,showFloatingClose:x.value,onAccept:w,onCancel:M,fitContent:t.fitContent==null?!0:t.fitContent,onClosed:S,onResize:j,onStopMove:P},{default:()=>[E&&E(a)]})}});return document.body.appendChild(n),a.use(J.LocaleService.i18n),a.mount(n),a}class ze{constructor(n){G(this,"appContext",null);G(this,"modalRef",e.ref());G(this,"activeModalIndex",e.ref(0));G(this,"modalRefs",{});G(this,"isUseEscCloseModal",e.ref(!1));this.app=n,this.appContext=n?n._context:null}getCurrentModal(){return this.modalRefs[this.activeModalIndex.value]}adaptToWindow(n,a){const{width:o,height:d}={width:window.innerWidth,height:window.innerHeight};return o<n&&(n=o-14),d<a&&(a=d-14),{width:n,height:a}}static show(n){const a=Object.assign({title:"",showButtons:!0,showHeader:!0},n);return Ve(a)}close(n){var a,o;n?(o=n.value)==null||o.close():(a=this.getCurrentModal())==null||a.close()}open(n){const a=document.createDocumentFragment();n.showMaxButton&&n.fitContent&&(n.showMaxButton=!1);const o=e.shallowRef(Object.assign({title:"",showButtons:!0,showHeader:!0,maximized:!1},n)),d=e.ref(!0),i=o.value.acceptCallback||(()=>{}),p=o.value.rejectCallback||(()=>{}),f=o.value.closedCallback||((s,g)=>{}),u=o.value.openedCallback||(s=>{}),h=o.value.resizeHandle||(s=>{}),x=n.stopMoveHandle||(s=>{});let y;const k=re(o.value),w=s=>{var R;d.value=!1;const g=(R=s==null?void 0:s.target)==null?void 0:R.classList.contains("modal_close");f(s,this.isUseEscCloseModal.value?"esc":g?"icon":"button")},M=s=>{w(s),y&&e.nextTick(()=>{if(this.modalRefs[this.activeModalIndex.value]&&delete this.modalRefs[this.activeModalIndex.value],e.render(null,a),y=null,this.modalRef.value=null,this.modalRefs){const g=Object.keys(this.modalRefs).map(R=>Number(R));g.length>0?this.activeModalIndex.value=Math.max(...g):this.activeModalIndex.value=0,this.modalRefs[this.activeModalIndex.value]&&(this.modalRef.value=this.modalRefs[this.activeModalIndex.value])}this.isUseEscCloseModal.value=!1})},B=s=>{var g;this.isUseEscCloseModal.value=!0,(g=this.getCurrentModal())==null||g.close(s==null?void 0:s.event)},{width:j,height:P}=o.value,E=this.adaptToWindow(j||500,P||320);Object.assign(o.value,E);const S=e.ref(),H=()=>e.createVNode(K,e.mergeProps({ref:S,modelValue:d.value,"onUpdate:modelValue":s=>d.value=s},o.value,{isMessager:o.value.class&&o.value.class.indexOf("modal-message")>-1,onAccept:i,onCancel:p,onClosed:M,onResize:h,onEsc:B,onStopMove:x,maximized:o.value.maximized}),{default:()=>[k&&k(this.app)]});y=(s=>{const g=e.h(H,s);return g.appContext=this.appContext,e.render(g,a),g})({...o.value}),this.activeModalIndex.value++;const F=this.activeModalIndex.value;this.modalRefs[F]=S.value;const m=s=>{o.value={...o.value,...s},y&&e.render(e.cloneVNode(y,{...o}),a)};return e.nextTick(()=>{this.modalRefs[F]=S.value,this.modalRef.value=S.value,u(new Event("opened"))}),{update:m,destroy:M,modalRef:S,close:()=>{var s;(s=S.value)==null||s.close()},disableButtons:(s,g=!0)=>{var R;(R=S.value)==null||R.disableButtons(s,g)}}}}const ue=Symbol("FModalService");K.install=t=>{t.component(K.name,K);const n=new ze(t);t.provide(ue,n),t.provide("FModalService",n)};function ce(t,n){function a(){const o=t.beforeOpen||t.beforeClickButton||null;let d=Promise.resolve(!0);if(o){const i=o(n.value);if(typeof i>"u")return d;typeof i=="boolean"?d=Promise.resolve(i):d=i}return d}return{judgeCanOpen:a}}function Ne(t,n,a,o,d){const i=e.ref(t.buttonBehavior),p=e.ref(t.popupOnInput),f=e.computed(()=>({"input-group-append":!0,"append-force-show":t.showButtonWhenDisabled&&(t.readonly||t.disable)})),{judgeCanOpen:u}=ce(t,d),h=e.computed(()=>t.showButtonWhenDisabled||(!t.editable||!t.readonly)&&!t.disable),x=e.inject(ue,null),y=e.ref();async function k(B){if(await u()&&h.value){const j=!!n.slots.default;if(i.value==="Modal"){const P=t.modalOptions,E=x==null?void 0:x.open({...P,render:()=>n.slots.default&&n.slots.default()});y.value=E==null?void 0:E.modalRef}i.value==="Overlay"&&xe.show({host:document.body,backgroundColor:"rgba(0,0,0,.15)",render:()=>n.slots.default&&n.slots.default()}),j&&i.value==="Popup"&&o.togglePopup(!0),j&&p.value&&o.hidePopup(),n.emit("clickButton",{origin:B,value:t.modelValue})}}function w(B){n.emit("mouseEnterIcon",B)}function M(B){n.emit("mouseLeaveIcon",B)}return{buttonGroupClass:f,onClickButton:k,onMouseEnterButton:w,onMouseLeaveButton:M,modalRef:y}}const X="FarrisVue_PopoverInstancesKey";function Se(t,n,a,o){const d=e.ref(),i=e.ref(!1),{judgeCanOpen:p}=ce(t,o);e.watch(()=>d.value,(w,M)=>{window[X]=window[X]||new WeakMap,w?window[X].set(a.value,w):window[X].delete(a.value)});function f(){if(window[X]){const w=window[X];document.querySelectorAll(".f-button-edit,.v-popover").forEach(M=>{const B=w.get(M);B&&M!==a.value&&!a.value.closest(".popover-fitcontent")&&B.hide()})}}function u(){const w=d.value;w&&(w.show?w.show(a.value):w.open&&w.open(a.value))}async function h(w=!1){if(!!n.slots.default){if(!w&&!i.value&&!await p())return;i.value=!i.value,i.value&&(await e.nextTick(),u())}}async function x(w=!1){if(!!n.slots.default){if(!w&&!await p())return;i.value=!0,await e.nextTick(),u()}}function y(){i.value=!1}function k(){i.value=!0,e.nextTick(()=>{u()})}return{hidePopup:y,showPopup:k,popup:x,shouldPopupContent:i,togglePopup:h,popoverRef:d,closeAllPopover:f}}function je(t,n,a){const{buttonGroupClass:o}=a,d=e.ref(),i=e.computed(()=>({"input-group-append input-append-wrapper":!0,"input-append-button":t.expandMode==="button","input-append-text":t.expandMode==="text"}));return{renderButtonGroup:()=>e.createVNode("div",{id:t.id?`${t.id}-button-group`:void 0,class:o.value},[n.slots.buttonContent?e.createVNode("span",{class:"input-group-text input-group-append-button"},[n.slots.buttonContent()]):t.buttonContent?e.createVNode("span",{class:"input-group-text input-group-append-button",innerHTML:t.buttonContent,ref:d},null):null,t.expandable&&t.expandContent&&e.createVNode("div",{class:i.value},[e.createVNode("div",{class:"input-group-text",innerHTML:t.expandContent},null)])]),buttonHandleElement:d}}const _=e.defineComponent({name:"FButtonEdit",props:ve,emits:["updateExtendInfo","clear","change","click","clickButton","blur","focus","mouseEnterIcon","mouseLeaveIcon","keyup","keydown","inputClick","input","update:modelValue"],setup(t,n){const a=e.ref(),o=e.inject("design-item-context"),d=he.useDesignerComponent(a,o),i=e.ref(t.customClass),p=e.ref(t.modelValue),f=Se(t,n,a,p),u=Ne(t,n,a,f,p),h=e.ref(),x=e.computed(()=>({"f-cmp-inputgroup":!0,"input-group":!0,"f-state-disabled":!0,"f-state-editable":!1,"f-state-readonly":!0}));e.onMounted(()=>{a.value.componentInstance=d}),n.expose(d.value);const y=e.computed(()=>{const M={"f-button-edit":!0,"f-cmp-inputgroup":!0,"f-button-edit-nowrap":!t.wrapText};return i.value&&i.value.split(" ").reduce((B,j)=>(B[j]=!0,B),M),M}),k=e.computed(()=>({"text-left":t.textAlign==="left","text-center":t.textAlign==="center","text-right":t.textAlign==="right","form-control":!0,"f-utils-fill":!0})),{renderButtonGroup:w}=je(t,n,u);return()=>e.createVNode("div",e.mergeProps(n.attrs,{ref:a,class:y.value,id:t.id?t.id:void 0,style:"pointer-events: none;"}),[e.createVNode("div",{class:x.value},[e.createVNode("input",{ref:h,class:k.value,readonly:!0,placeholder:t.placeholder},null),w()])])}}),Te=new Map([["appearance",A.resolveAppearance]]);function Ie(t,n,a){return n}const He={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://farris-design.gitee.io/button-edit.schema.json",title:"button-edit",description:"A Farris Input Component",type:"object",properties:{id:{description:"The unique identifier for a Input Group",type:"string"},type:{description:"The type string of Input Group component",type:"string",default:"button-edit"},appearance:{description:"",type:"object",properties:{class:{type:"string"},style:{type:"string"}},default:{}},binding:{description:"",type:"object",default:{}},disable:{type:"string",default:!1},editable:{description:"",type:"boolean",default:!0},enableLinkLabel:{description:"",type:"boolean",default:!1},label:{description:"",type:"string",default:""},lableWidth:{description:"",type:"number"},placeholder:{description:"",type:"string",default:""},forcePlaceholder:{description:"",type:"boolean",default:!1},readonly:{description:"",type:"boolean",default:!1},require:{description:"",type:"boolean",default:!1},tabindex:{description:"",type:"number",default:-1},textAlign:{description:"",type:"string",enum:["left","middle","right"],default:"left"},visible:{description:"",type:"boolean",default:!0},onBlur:{description:"",type:"string",default:""},onClickLinkLabel:{description:"",type:"string",default:""},autoComplete:{description:"",type:"boolean",default:!1},buttonContent:{description:"",type:"string",default:""},enableClear:{description:"",type:"boolean",default:!0},inputType:{description:"",type:"string",enum:["text","tag"],default:"text"},multiSelect:{description:"",type:"boolean",default:!1},popup:{description:"",type:"object",properties:{footerButtons:{type:"array",default:[]},height:{type:"number",default:600},dataMapping:{type:"object"},contents:{type:"array",default:[]},showMaxButton:{type:"boolean",default:!0},showCloseButton:{type:"boolean",default:!0},showFooter:{type:"boolean",default:!0},title:{type:"string",default:""},width:{type:"number",default:800}}},popupClass:{description:"",type:"string",default:""},separator:{type:"string",default:","},showButtonWhenDisabled:{description:"",type:"boolean",default:!1},showAppendButton:{description:"",type:"boolean",default:!0},wrapText:{type:"boolean",default:!1},onClear:{description:"",type:"string",default:""},onClickButton:{description:"",type:"string",default:""},modelValue:{description:"",type:"string",default:""}},required:["id","type"]},Re={title:"buttonEdit",description:"A Farris Component",type:"object",categories:{basic:{description:"Basic Infomation",title:"基本信息",properties:{id:{description:"组件标识",title:"标识",type:"string",readonly:!0},type:{description:"组件类型",title:"控件类型",type:"select",editor:{type:"waiting for modification",enum:[]}}}},behavior:{description:"Basic Infomation",title:"行为",properties:{editable:{description:"",title:"允许编辑",type:"boolean"},readonly:{description:"",title:"只读",type:"string"},required:{description:"",title:"必填",type:"boolean"},visible:{description:"",title:"可见",type:"boolean"},placeholder:{description:"",title:"提示文本",type:"string"},tabindex:{description:"",title:"tab索引",type:"number"},textAlign:{description:"",title:"对齐方式",type:"enum",editor:{type:"combo-list",textField:"name",valueField:"value",data:[{value:"left",name:"左对齐"},{value:"center",name:"居中"},{value:"right",name:"右对齐"}]}}}}}},ee=A.createPropsResolver(se.buttonEditProps,He,Te,Ie,Re);_.register=(t,n,a,o)=>{t["button-edit"]=se,n["button-edit"]=ee},_.registerDesigner=(t,n,a)=>{t["button-edit"]=_,n["button-edit"]=ee};const Pe=I.withInstall(_);V.FButtonEditDesign=_,V.default=Pe,V.propsResolver=ee,Object.defineProperties(V,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});