UNPKG

epic-designer-gold

Version:

基于vue3的设计器,可视化开发页面表单

10 lines (9 loc) 16.6 kB
"use strict";const j=require("./_commonjsHelpers-DwTZ_eVU.cjs"),Ze=require("./_vue_commonjs-external-BbihI59z.cjs"),O=require("./index-4PPmJYKt.cjs"),p=require("./index-jx5A2kt8.cjs"),et=require("./utils-zEcOzoWV.cjs"),tt=require("./fade-in-scale-up.cssr-C_UMnGtI.cjs");function nt(u,g){for(var l=0;l<g.length;l++){const c=g[l];if(typeof c!="string"&&!Array.isArray(c)){for(const S in c)if(S!=="default"&&!(S in u)){const v=Object.getOwnPropertyDescriptor(c,S);v&&Object.defineProperty(u,S,v.get?v:{enumerable:!0,get:()=>c[S]})}}}return Object.freeze(Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}))}var _e={},ye={},Oe={},Y={},x={};Object.defineProperty(x,"__esModule",{value:!0});x.self=Se;const lt=p.styles,it=p.styles$1,rt=O.common,at=O._mixins;function Se(u){const{boxShadow2:g}=u;return{menuBoxShadow:g}}const ot=(0,at.createTheme)({name:"Select",common:rt.commonLight,peers:{InternalSelection:lt.internalSelectionLight,InternalSelectMenu:it.internalSelectMenuLight},self:Se});x.default=ot;Object.defineProperty(Y,"__esModule",{value:!0});const st=p.styles,ut=p.styles$1,ct=O.common,dt=x,ft={name:"Select",common:ct.commonDark,peers:{InternalSelection:st.internalSelectionDark,InternalSelectMenu:ut.internalSelectMenuDark},self:dt.self};Y.default=ft;var K={};Object.defineProperty(K,"__esModule",{value:!0});K.selectRtl=void 0;const ht=p.styles$1,vt=p.styles,mt=p.styles$2,gt=p.styles$3,pt=O.cssr;K.selectRtl={name:"Select",style:(0,pt.c)([]),peers:[vt.internalSelectionRtl,ht.internalSelectMenuRtl,gt.tagRtl,mt.scrollbarRtl]};(function(u){var g=j.commonjsGlobal&&j.commonjsGlobal.__importDefault||function(v){return v&&v.__esModule?v:{default:v}};Object.defineProperty(u,"__esModule",{value:!0}),u.selectRtl=u.selectLight=u.selectDark=void 0;var l=Y;Object.defineProperty(u,"selectDark",{enumerable:!0,get:function(){return g(l).default}});var c=x;Object.defineProperty(u,"selectLight",{enumerable:!0,get:function(){return g(c).default}});var S=K;Object.defineProperty(u,"selectRtl",{enumerable:!0,get:function(){return S.selectRtl}})})(Oe);var Z={};Object.defineProperty(Z,"__esModule",{value:!0});const X=O.cssr,bt=tt.fadeInScaleUp_cssr;Z.default=(0,X.c)([(0,X.cB)("select",` z-index: auto; outline: none; width: 100%; position: relative; `),(0,X.cB)("select-menu",` margin: 4px 0; box-shadow: var(--n-menu-box-shadow); `,[(0,bt.fadeInScaleUpTransition)({originalTransition:"background-color .3s var(--n-bezier), box-shadow .3s var(--n-bezier)"})])]);(function(u){var g=j.commonjsGlobal&&j.commonjsGlobal.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(u,"__esModule",{value:!0}),u.selectProps=void 0;const l=Ze.require$$0,c=O.require$$1,S=p.require$$1,v=O.require$$1$1,z=O.require$$2,ee=p.require$$2,P=O._mixins,f=O._utils,te=p._internal,Me=Oe,R=et.utils,we=g(Z);u.selectProps=Object.assign(Object.assign({},P.useTheme.props),{to:f.useAdjustedTo.propTo,bordered:{type:Boolean,default:void 0},clearable:Boolean,clearFilterAfterSelect:{type:Boolean,default:!0},options:{type:Array,default:()=>[]},defaultValue:{type:[String,Number,Array],default:null},keyboard:{type:Boolean,default:!0},value:[String,Number,Array],placeholder:String,menuProps:Object,multiple:Boolean,size:String,menuSize:{type:String},filterable:Boolean,disabled:{type:Boolean,default:void 0},remote:Boolean,loading:Boolean,filter:Function,placement:{type:String,default:"bottom-start"},widthMode:{type:String,default:"trigger"},tag:Boolean,onCreate:Function,fallbackOption:{type:[Function,Boolean],default:void 0},show:{type:Boolean,default:void 0},showArrow:{type:Boolean,default:!0},maxTagCount:[Number,String],ellipsisTagPopoverProps:Object,consistentMenuWidth:{type:Boolean,default:!0},virtualScroll:{type:Boolean,default:!0},labelField:{type:String,default:"label"},valueField:{type:String,default:"value"},childrenField:{type:String,default:"children"},renderLabel:Function,renderOption:Function,renderTag:Function,"onUpdate:value":[Function,Array],inputProps:Object,nodeProps:Function,ignoreComposition:{type:Boolean,default:!0},showOnFocus:Boolean,onUpdateValue:[Function,Array],onBlur:[Function,Array],onClear:[Function,Array],onFocus:[Function,Array],onScroll:[Function,Array],onSearch:[Function,Array],onUpdateShow:[Function,Array],"onUpdate:show":[Function,Array],displayDirective:{type:String,default:"show"},resetMenuOnOptionsChange:{type:Boolean,default:!0},status:String,showCheckmark:{type:Boolean,default:!0},onChange:[Function,Array],items:Array}),u.default=(0,l.defineComponent)({name:"Select",props:u.selectProps,setup(t){process.env.NODE_ENV!=="production"&&(0,l.watchEffect)(()=>{t.items!==void 0&&(0,f.warnOnce)("select","`items` is deprecated, please use `options` instead."),t.onChange!==void 0&&(0,f.warnOnce)("select","`on-change` is deprecated, please use `on-update:value` instead.")});const{mergedClsPrefixRef:b,mergedBorderedRef:k,namespaceRef:_,inlineThemeDisabled:h}=(0,P.useConfig)(t),ne=(0,P.useTheme)("Select","-select",we.default,Me.selectLight,t,b),H=(0,l.ref)(t.defaultValue),Fe=(0,l.toRef)(t,"value"),A=(0,z.useMergedState)(Fe,H),I=(0,l.ref)(!1),C=(0,l.ref)(""),J=(0,z.useCompitable)(t,["items","options"]),M=(0,l.ref)([]),F=(0,l.ref)([]),le=(0,l.computed)(()=>F.value.concat(M.value).concat(J.value)),Te=(0,l.computed)(()=>{const{filter:e}=t;if(e)return e;const{labelField:n,valueField:i}=t;return(s,a)=>{if(!a)return!1;const r=a[n];if(typeof r=="string")return(0,R.patternMatched)(s,r);const o=a[i];return typeof o=="string"?(0,R.patternMatched)(s,o):typeof o=="number"?(0,R.patternMatched)(s,String(o)):!1}}),Pe=(0,l.computed)(()=>{if(t.remote)return J.value;{const{value:e}=le,{value:n}=C;return!n.length||!t.filterable?e:(0,R.filterOptions)(e,Te.value,n,t.childrenField)}}),Re=(0,l.computed)(()=>{const{valueField:e,childrenField:n}=t,i=(0,R.createTmOptions)(e,n);return(0,S.createTreeMate)(Pe.value,i)}),ie=(0,l.computed)(()=>(0,R.createValOptMap)(le.value,t.valueField,t.childrenField)),L=(0,l.ref)(!1),y=(0,z.useMergedState)((0,l.toRef)(t,"show"),L),m=(0,l.ref)(null),re=(0,l.ref)(null),D=(0,l.ref)(null),{localeRef:Ce}=(0,P.useLocale)("Select"),Be=(0,l.computed)(()=>{var e;return(e=t.placeholder)!==null&&e!==void 0?e:Ce.value.placeholder}),$=[],U=(0,l.ref)(new Map),ae=(0,l.computed)(()=>{const{fallbackOption:e}=t;if(e===void 0){const{labelField:n,valueField:i}=t;return s=>({[n]:String(s),[i]:s})}return e===!1?!1:n=>Object.assign(e(n),{value:n})});function Q(e){const n=t.remote,{value:i}=U,{value:s}=ie,{value:a}=ae,r=[];return e.forEach(o=>{if(s.has(o))r.push(s.get(o));else if(n&&i.has(o))r.push(i.get(o));else if(a){const d=a(o);d&&r.push(d)}}),r}const oe=(0,l.computed)(()=>{if(t.multiple){const{value:e}=A;return Array.isArray(e)?Q(e):[]}return null}),se=(0,l.computed)(()=>{const{value:e}=A;return!t.multiple&&!Array.isArray(e)?e===null?null:Q([e])[0]||null:null}),N=(0,P.useFormItem)(t),{mergedSizeRef:je,mergedDisabledRef:q,mergedStatusRef:ke}=N;function E(e,n){const{onChange:i,"onUpdate:value":s,onUpdateValue:a}=t,{nTriggerFormChange:r,nTriggerFormInput:o}=N;i&&(0,f.call)(i,e,n),a&&(0,f.call)(a,e,n),s&&(0,f.call)(s,e,n),H.value=e,r(),o()}function ue(e){const{onBlur:n}=t,{nTriggerFormBlur:i}=N;n&&(0,f.call)(n,e),i()}function Ae(){const{onClear:e}=t;e&&(0,f.call)(e)}function Ie(e){const{onFocus:n,showOnFocus:i}=t,{nTriggerFormFocus:s}=N;n&&(0,f.call)(n,e),s(),i&&V()}function De(e){const{onSearch:n}=t;n&&(0,f.call)(n,e)}function $e(e){const{onScroll:n}=t;n&&(0,f.call)(n,e)}function ce(){var e;const{remote:n,multiple:i}=t;if(n){const{value:s}=U;if(i){const{valueField:a}=t;(e=oe.value)===null||e===void 0||e.forEach(r=>{s.set(r[a],r)})}else{const a=se.value;a&&s.set(a[t.valueField],a)}}}function de(e){const{onUpdateShow:n,"onUpdate:show":i}=t;n&&(0,f.call)(n,e),i&&(0,f.call)(i,e),L.value=e}function V(){q.value||(de(!0),L.value=!0,t.filterable&&pe())}function w(){de(!1)}function fe(){C.value="",F.value=$}const W=(0,l.ref)(!1);function Ve(){t.filterable&&(W.value=!0)}function xe(){t.filterable&&(W.value=!1,y.value||fe())}function ze(){q.value||(y.value?t.filterable?pe():w():V())}function Le(e){var n,i;!((i=(n=D.value)===null||n===void 0?void 0:n.selfRef)===null||i===void 0)&&i.contains(e.relatedTarget)||(I.value=!1,ue(e),w())}function Ue(e){Ie(e),I.value=!0}function Ne(){I.value=!0}function qe(e){var n;!((n=m.value)===null||n===void 0)&&n.$el.contains(e.relatedTarget)||(I.value=!1,ue(e),w())}function Ee(){var e;(e=m.value)===null||e===void 0||e.focus(),w()}function We(e){var n;y.value&&(!((n=m.value)===null||n===void 0)&&n.$el.contains((0,c.getPreciseEventTarget)(e))||w())}function Ge(e){if(!Array.isArray(e))return[];if(ae.value)return Array.from(e);{const{remote:n}=t,{value:i}=ie;if(n){const{value:s}=U;return e.filter(a=>i.has(a)||s.has(a))}else return e.filter(s=>i.has(s))}}function he(e){G(e.rawNode)}function G(e){if(q.value)return;const{tag:n,remote:i,clearFilterAfterSelect:s,valueField:a}=t;if(n&&!i){const{value:r}=F,o=r[0]||null;if(o){const d=M.value;d.length?d.push(o):M.value=[o],F.value=$}}if(i&&U.value.set(e[a],e),t.multiple){const r=Ge(A.value),o=r.findIndex(d=>d===e[a]);if(~o){if(r.splice(o,1),n&&!i){const d=ve(e[a]);~d&&(M.value.splice(d,1),s&&(C.value=""))}}else r.push(e[a]),s&&(C.value="");E(r,Q(r))}else{if(n&&!i){const r=ve(e[a]);~r?M.value=[M.value[r]]:M.value=$}ge(),w(),E(e[a],e)}}function ve(e){return M.value.findIndex(i=>i[t.valueField]===e)}function Ke(e){y.value||V();const{value:n}=e.target;C.value=n;const{tag:i,remote:s}=t;if(De(n),i&&!s){if(!n){F.value=$;return}const{onCreate:a}=t,r=a?a(n):{[t.labelField]:n,[t.valueField]:n},{valueField:o,labelField:d}=t;J.value.some(T=>T[o]===r[o]||T[d]===r[d])||M.value.some(T=>T[o]===r[o]||T[d]===r[d])?F.value=$:F.value=[r]}}function He(e){e.stopPropagation();const{multiple:n}=t;!n&&t.filterable&&w(),Ae(),n?E([],[]):E(null,null)}function Je(e){!(0,c.happensIn)(e,"action")&&!(0,c.happensIn)(e,"empty")&&!(0,c.happensIn)(e,"header")&&e.preventDefault()}function Qe(e){$e(e)}function me(e){var n,i,s,a,r;if(!t.keyboard){e.preventDefault();return}switch(e.key){case" ":if(t.filterable)break;e.preventDefault();case"Enter":if(!(!((n=m.value)===null||n===void 0)&&n.isComposing)){if(y.value){const o=(i=D.value)===null||i===void 0?void 0:i.getPendingTmNode();o?he(o):t.filterable||(w(),ge())}else if(V(),t.tag&&W.value){const o=F.value[0];if(o){const d=o[t.valueField],{value:T}=A;t.multiple&&Array.isArray(T)&&T.includes(d)||G(o)}}}e.preventDefault();break;case"ArrowUp":if(e.preventDefault(),t.loading)return;y.value&&((s=D.value)===null||s===void 0||s.prev());break;case"ArrowDown":if(e.preventDefault(),t.loading)return;y.value?(a=D.value)===null||a===void 0||a.next():V();break;case"Escape":y.value&&((0,f.markEventEffectPerformed)(e),w()),(r=m.value)===null||r===void 0||r.focus();break}}function ge(){var e;(e=m.value)===null||e===void 0||e.focus()}function pe(){var e;(e=m.value)===null||e===void 0||e.focusInput()}function Xe(){var e;y.value&&((e=re.value)===null||e===void 0||e.syncPosition())}ce(),(0,l.watch)((0,l.toRef)(t,"options"),ce);const Ye={focus:()=>{var e;(e=m.value)===null||e===void 0||e.focus()},focusInput:()=>{var e;(e=m.value)===null||e===void 0||e.focusInput()},blur:()=>{var e;(e=m.value)===null||e===void 0||e.blur()},blurInput:()=>{var e;(e=m.value)===null||e===void 0||e.blurInput()}},be=(0,l.computed)(()=>{const{self:{menuBoxShadow:e}}=ne.value;return{"--n-menu-box-shadow":e}}),B=h?(0,P.useThemeClass)("select",void 0,be,t):void 0;return Object.assign(Object.assign({},Ye),{mergedStatus:ke,mergedClsPrefix:b,mergedBordered:k,namespace:_,treeMate:Re,isMounted:(0,z.useIsMounted)(),triggerRef:m,menuRef:D,pattern:C,uncontrolledShow:L,mergedShow:y,adjustedTo:(0,f.useAdjustedTo)(t),uncontrolledValue:H,mergedValue:A,followerRef:re,localizedPlaceholder:Be,selectedOption:se,selectedOptions:oe,mergedSize:je,mergedDisabled:q,focused:I,activeWithoutMenuOpen:W,inlineThemeDisabled:h,onTriggerInputFocus:Ve,onTriggerInputBlur:xe,handleTriggerOrMenuResize:Xe,handleMenuFocus:Ne,handleMenuBlur:qe,handleMenuTabOut:Ee,handleTriggerClick:ze,handleToggle:he,handleDeleteOption:G,handlePatternInput:Ke,handleClear:He,handleTriggerBlur:Le,handleTriggerFocus:Ue,handleKeydown:me,handleMenuAfterLeave:fe,handleMenuClickOutside:We,handleMenuScroll:Qe,handleMenuKeydown:me,handleMenuMousedown:Je,mergedTheme:ne,cssVars:h?void 0:be,themeClass:B==null?void 0:B.themeClass,onRender:B==null?void 0:B.onRender})},render(){return(0,l.h)("div",{class:`${this.mergedClsPrefix}-select`},(0,l.h)(v.VBinder,null,{default:()=>[(0,l.h)(v.VTarget,null,{default:()=>(0,l.h)(te.NInternalSelection,{ref:"triggerRef",inlineThemeDisabled:this.inlineThemeDisabled,status:this.mergedStatus,inputProps:this.inputProps,clsPrefix:this.mergedClsPrefix,showArrow:this.showArrow,maxTagCount:this.maxTagCount,ellipsisTagPopoverProps:this.ellipsisTagPopoverProps,bordered:this.mergedBordered,active:this.activeWithoutMenuOpen||this.mergedShow,pattern:this.pattern,placeholder:this.localizedPlaceholder,selectedOption:this.selectedOption,selectedOptions:this.selectedOptions,multiple:this.multiple,renderTag:this.renderTag,renderLabel:this.renderLabel,filterable:this.filterable,clearable:this.clearable,disabled:this.mergedDisabled,size:this.mergedSize,theme:this.mergedTheme.peers.InternalSelection,labelField:this.labelField,valueField:this.valueField,themeOverrides:this.mergedTheme.peerOverrides.InternalSelection,loading:this.loading,focused:this.focused,onClick:this.handleTriggerClick,onDeleteOption:this.handleDeleteOption,onPatternInput:this.handlePatternInput,onClear:this.handleClear,onBlur:this.handleTriggerBlur,onFocus:this.handleTriggerFocus,onKeydown:this.handleKeydown,onPatternBlur:this.onTriggerInputBlur,onPatternFocus:this.onTriggerInputFocus,onResize:this.handleTriggerOrMenuResize,ignoreComposition:this.ignoreComposition},{arrow:()=>{var t,b;return[(b=(t=this.$slots).arrow)===null||b===void 0?void 0:b.call(t)]}})}),(0,l.h)(v.VFollower,{ref:"followerRef",show:this.mergedShow,to:this.adjustedTo,teleportDisabled:this.adjustedTo===f.useAdjustedTo.tdkey,containerClass:this.namespace,width:this.consistentMenuWidth?"target":void 0,minWidth:"target",placement:this.placement},{default:()=>(0,l.h)(l.Transition,{name:"fade-in-scale-up-transition",appear:this.isMounted,onAfterLeave:this.handleMenuAfterLeave},{default:()=>{var t,b,k;return this.mergedShow||this.displayDirective==="show"?((t=this.onRender)===null||t===void 0||t.call(this),(0,l.withDirectives)((0,l.h)(te.NInternalSelectMenu,Object.assign({},this.menuProps,{ref:"menuRef",onResize:this.handleTriggerOrMenuResize,inlineThemeDisabled:this.inlineThemeDisabled,virtualScroll:this.consistentMenuWidth&&this.virtualScroll,class:[`${this.mergedClsPrefix}-select-menu`,this.themeClass,(b=this.menuProps)===null||b===void 0?void 0:b.class],clsPrefix:this.mergedClsPrefix,focusable:!0,labelField:this.labelField,valueField:this.valueField,autoPending:!0,nodeProps:this.nodeProps,theme:this.mergedTheme.peers.InternalSelectMenu,themeOverrides:this.mergedTheme.peerOverrides.InternalSelectMenu,treeMate:this.treeMate,multiple:this.multiple,size:this.menuSize,renderOption:this.renderOption,renderLabel:this.renderLabel,value:this.mergedValue,style:[(k=this.menuProps)===null||k===void 0?void 0:k.style,this.cssVars],onToggle:this.handleToggle,onScroll:this.handleMenuScroll,onFocus:this.handleMenuFocus,onBlur:this.handleMenuBlur,onKeydown:this.handleMenuKeydown,onTabOut:this.handleMenuTabOut,onMousedown:this.handleMenuMousedown,show:this.mergedShow,showCheckmark:this.showCheckmark,resetMenuOnOptionsChange:this.resetMenuOnOptionsChange}),{empty:()=>{var _,h;return[(h=(_=this.$slots).empty)===null||h===void 0?void 0:h.call(_)]},header:()=>{var _,h;return[(h=(_=this.$slots).header)===null||h===void 0?void 0:h.call(_)]},action:()=>{var _,h;return[(h=(_=this.$slots).action)===null||h===void 0?void 0:h.call(_)]}}),this.displayDirective==="show"?[[l.vShow,this.mergedShow],[ee.clickoutside,this.handleMenuClickOutside,void 0,{capture:!0}]]:[[ee.clickoutside,this.handleMenuClickOutside,void 0,{capture:!0}]])):null}})})]}))}})})(ye);(function(u){var g=j.commonjsGlobal&&j.commonjsGlobal.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(u,"__esModule",{value:!0}),u.selectProps=u.NSelect=void 0;var l=ye;Object.defineProperty(u,"NSelect",{enumerable:!0,get:function(){return g(l).default}}),Object.defineProperty(u,"selectProps",{enumerable:!0,get:function(){return l.selectProps}})})(_e);const _t=nt({__proto__:null},[_e]);exports.index=_t;