UNPKG

epic-designer-gold

Version:

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

103 lines (102 loc) 13.5 kB
"use strict";const u=require("./_commonjsHelpers-DwTZ_eVU.cjs"),f=require("./index-CFee6cT1.cjs"),ve=require("./_vue_commonjs-external-CccDNqHl.cjs"),U=require("./index-DQpYVvll.cjs");function ge(r,s){for(var a=0;a<s.length;a++){const i=s[a];if(typeof i!="string"&&!Array.isArray(i)){for(const o in i)if(o!=="default"&&!(o in r)){const h=Object.getOwnPropertyDescriptor(i,o);h&&Object.defineProperty(r,o,h.get?h:{enumerable:!0,get:()=>i[o]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}var I={},X={},Y={},H={},V={};Object.defineProperty(V,"__esModule",{value:!0});V.default={buttonHeightSmall:"14px",buttonHeightMedium:"18px",buttonHeightLarge:"22px",buttonWidthSmall:"14px",buttonWidthMedium:"18px",buttonWidthLarge:"22px",buttonWidthPressedSmall:"20px",buttonWidthPressedMedium:"24px",buttonWidthPressedLarge:"28px",railHeightSmall:"18px",railHeightMedium:"22px",railHeightLarge:"26px",railWidthSmall:"32px",railWidthMedium:"40px",railWidthLarge:"48px"};var me=u.commonjsGlobal&&u.commonjsGlobal.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(H,"__esModule",{value:!0});const pe=f.require$$0,_e=f.common,we=me(V),ye={name:"Switch",common:_e.commonDark,self(r){const{primaryColorSuppl:s,opacityDisabled:a,borderRadius:i,primaryColor:o,textColor2:h,baseColor:p}=r;return Object.assign(Object.assign({},we.default),{iconColor:p,textColor:h,loadingColor:s,opacityDisabled:a,railColor:"rgba(255, 255, 255, .20)",railColorActive:s,buttonBoxShadow:"0px 2px 4px 0 rgba(0, 0, 0, 0.4)",buttonColor:"#FFF",railBorderRadiusSmall:i,railBorderRadiusMedium:i,railBorderRadiusLarge:i,buttonBorderRadiusSmall:i,buttonBorderRadiusMedium:i,buttonBorderRadiusLarge:i,boxShadowFocus:`0 0 8px 0 ${(0,pe.changeColor)(o,{alpha:.3})}`})}};H.default=ye;var N={},xe=u.commonjsGlobal&&u.commonjsGlobal.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(N,"__esModule",{value:!0});const Se=f.require$$0,ke=f.common,Ce=xe(V);function je(r){const{primaryColor:s,opacityDisabled:a,borderRadius:i,textColor3:o}=r;return Object.assign(Object.assign({},Ce.default),{iconColor:o,textColor:"white",loadingColor:s,opacityDisabled:a,railColor:"rgba(0, 0, 0, .14)",railColorActive:s,buttonBoxShadow:"0 1px 4px 0 rgba(0, 0, 0, 0.3), inset 0 0 1px 0 rgba(0, 0, 0, 0.05)",buttonColor:"#FFF",railBorderRadiusSmall:i,railBorderRadiusMedium:i,railBorderRadiusLarge:i,buttonBorderRadiusSmall:i,buttonBorderRadiusMedium:i,buttonBorderRadiusLarge:i,boxShadowFocus:`0 0 0 2px ${(0,Se.changeColor)(s,{alpha:.2})}`})}const Be={name:"Switch",common:ke.commonLight,self:je};N.default=Be;(function(r){var s=u.commonjsGlobal&&u.commonjsGlobal.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(r,"__esModule",{value:!0}),r.switchLight=r.switchDark=void 0;var a=H;Object.defineProperty(r,"switchDark",{enumerable:!0,get:function(){return s(a).default}});var i=N;Object.defineProperty(r,"switchLight",{enumerable:!0,get:function(){return s(i).default}})})(Y);var G={};Object.defineProperty(G,"__esModule",{value:!0});const A=U.iconSwitch_cssr,t=f.cssr;G.default=(0,t.cB)("switch",` height: var(--n-height); min-width: var(--n-width); vertical-align: middle; user-select: none; -webkit-user-select: none; display: inline-flex; outline: none; justify-content: center; align-items: center; `,[(0,t.cE)("children-placeholder",` height: var(--n-rail-height); display: flex; flex-direction: column; overflow: hidden; pointer-events: none; visibility: hidden; `),(0,t.cE)("rail-placeholder",` display: flex; flex-wrap: none; `),(0,t.cE)("button-placeholder",` width: calc(1.75 * var(--n-rail-height)); height: var(--n-rail-height); `),(0,t.cB)("base-loading",` position: absolute; top: 50%; left: 50%; transform: translateX(-50%) translateY(-50%); font-size: calc(var(--n-button-width) - 4px); color: var(--n-loading-color); transition: color .3s var(--n-bezier); `,[(0,A.iconSwitchTransition)({left:"50%",top:"50%",originalTransform:"translateX(-50%) translateY(-50%)"})]),(0,t.cE)("checked, unchecked",` transition: color .3s var(--n-bezier); color: var(--n-text-color); box-sizing: border-box; position: absolute; white-space: nowrap; top: 0; bottom: 0; display: flex; align-items: center; line-height: 1; `),(0,t.cE)("checked",` right: 0; padding-right: calc(1.25 * var(--n-rail-height) - var(--n-offset)); `),(0,t.cE)("unchecked",` left: 0; justify-content: flex-end; padding-left: calc(1.25 * var(--n-rail-height) - var(--n-offset)); `),(0,t.c)("&:focus",[(0,t.cE)("rail",` box-shadow: var(--n-box-shadow-focus); `)]),(0,t.cM)("round",[(0,t.cE)("rail","border-radius: calc(var(--n-rail-height) / 2);",[(0,t.cE)("button","border-radius: calc(var(--n-button-height) / 2);")])]),(0,t.cNotM)("disabled",[(0,t.cNotM)("icon",[(0,t.cM)("rubber-band",[(0,t.cM)("pressed",[(0,t.cE)("rail",[(0,t.cE)("button","max-width: var(--n-button-width-pressed);")])]),(0,t.cE)("rail",[(0,t.c)("&:active",[(0,t.cE)("button","max-width: var(--n-button-width-pressed);")])]),(0,t.cM)("active",[(0,t.cM)("pressed",[(0,t.cE)("rail",[(0,t.cE)("button","left: calc(100% - var(--n-offset) - var(--n-button-width-pressed));")])]),(0,t.cE)("rail",[(0,t.c)("&:active",[(0,t.cE)("button","left: calc(100% - var(--n-offset) - var(--n-button-width-pressed));")])])])])])]),(0,t.cM)("active",[(0,t.cE)("rail",[(0,t.cE)("button","left: calc(100% - var(--n-button-width) - var(--n-offset))")])]),(0,t.cE)("rail",` overflow: hidden; height: var(--n-rail-height); min-width: var(--n-rail-width); border-radius: var(--n-rail-border-radius); cursor: pointer; position: relative; transition: opacity .3s var(--n-bezier), background .3s var(--n-bezier), box-shadow .3s var(--n-bezier); background-color: var(--n-rail-color); `,[(0,t.cE)("button-icon",` color: var(--n-icon-color); transition: color .3s var(--n-bezier); font-size: calc(var(--n-button-height) - 4px); position: absolute; left: 0; right: 0; top: 0; bottom: 0; display: flex; justify-content: center; align-items: center; line-height: 1; `,[(0,A.iconSwitchTransition)()]),(0,t.cE)("button",` align-items: center; top: var(--n-offset); left: var(--n-offset); height: var(--n-button-height); width: var(--n-button-width-pressed); max-width: var(--n-button-width); border-radius: var(--n-button-border-radius); background-color: var(--n-button-color); box-shadow: var(--n-button-box-shadow); box-sizing: border-box; cursor: inherit; content: ""; position: absolute; transition: background-color .3s var(--n-bezier), left .3s var(--n-bezier), opacity .3s var(--n-bezier), max-width .3s var(--n-bezier), box-shadow .3s var(--n-bezier); `)]),(0,t.cM)("active",[(0,t.cE)("rail","background-color: var(--n-rail-color-active);")]),(0,t.cM)("loading",[(0,t.cE)("rail",` cursor: wait; `)]),(0,t.cM)("disabled",[(0,t.cE)("rail",` cursor: not-allowed; opacity: .5; `)])]);(function(r){var s=u.commonjsGlobal&&u.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.switchProps=void 0;const a=f.require$$0,i=f.require$$1,o=ve.require$$2,h=U._internal,p=f._mixins,l=f._utils,J=Y,Q=s(G);r.switchProps=Object.assign(Object.assign({},p.useTheme.props),{size:String,value:{type:[String,Number,Boolean],default:void 0},loading:Boolean,defaultValue:{type:[String,Number,Boolean],default:!1},disabled:{type:Boolean,default:void 0},round:{type:Boolean,default:!0},"onUpdate:value":[Function,Array],onUpdateValue:[Function,Array],checkedValue:{type:[String,Number,Boolean],default:!0},uncheckedValue:{type:[String,Number,Boolean],default:!1},railStyle:Function,rubberBand:{type:Boolean,default:!0},spinProps:Object,onChange:[Function,Array]});let k;r.default=(0,o.defineComponent)({name:"Switch",props:r.switchProps,slots:Object,setup(e){process.env.NODE_ENV!=="production"&&(0,o.watchEffect)(()=>{e.onChange&&(0,l.warnOnce)("switch","`on-change` is deprecated, please use `on-update:value` instead.")}),k===void 0&&(typeof CSS<"u"?typeof CSS.supports<"u"?k=CSS.supports("width","max(1px)"):k=!1:k=!0);const{mergedClsPrefixRef:O,inlineThemeDisabled:C,mergedComponentPropsRef:j}=(0,p.useConfig)(e),B=(0,p.useTheme)("Switch","-switch",Q.default,J.switchLight,e,O),x=(0,p.useFormItem)(e,{mergedSize(n){var b,v;if(e.size!==void 0)return e.size;if(n)return n.mergedSize.value;const y=(v=(b=j==null?void 0:j.value)===null||b===void 0?void 0:b.Switch)===null||v===void 0?void 0:v.size;return y||"medium"}}),{mergedSizeRef:R,mergedDisabledRef:_}=x,M=(0,o.ref)(e.defaultValue),P=(0,o.toRef)(e,"value"),w=(0,i.useMergedState)(P,M),z=(0,o.computed)(()=>w.value===e.checkedValue),c=(0,o.ref)(!1),d=(0,o.ref)(!1),$=(0,o.computed)(()=>{const{railStyle:n}=e;if(n)return n({focused:d.value,checked:z.value})});function D(n){const{"onUpdate:value":b,onChange:v,onUpdateValue:y}=e,{nTriggerFormInput:W,nTriggerFormChange:F}=x;b&&(0,l.call)(b,n),y&&(0,l.call)(y,n),v&&(0,l.call)(v,n),M.value=n,W(),F()}function Z(){const{nTriggerFormFocus:n}=x;n()}function ee(){const{nTriggerFormBlur:n}=x;n()}function te(){e.loading||_.value||(w.value!==e.checkedValue?D(e.checkedValue):D(e.uncheckedValue))}function oe(){d.value=!0,Z()}function re(){d.value=!1,ee(),c.value=!1}function ie(n){e.loading||_.value||n.key===" "&&(w.value!==e.checkedValue?D(e.checkedValue):D(e.uncheckedValue),c.value=!1)}function ne(n){e.loading||_.value||n.key===" "&&(n.preventDefault(),c.value=!0)}const q=(0,o.computed)(()=>{const{value:n}=R,{self:{opacityDisabled:b,railColor:v,railColorActive:y,buttonBoxShadow:W,buttonColor:F,boxShadowFocus:ae,loadingColor:le,textColor:ce,iconColor:se,[(0,l.createKey)("buttonHeight",n)]:g,[(0,l.createKey)("buttonWidth",n)]:de,[(0,l.createKey)("buttonWidthPressed",n)]:ue,[(0,l.createKey)("railHeight",n)]:m,[(0,l.createKey)("railWidth",n)]:E,[(0,l.createKey)("railBorderRadius",n)]:he,[(0,l.createKey)("buttonBorderRadius",n)]:fe},common:{cubicBezierEaseInOut:be}}=B.value;let L,K,T;return k?(L=`calc((${m} - ${g}) / 2)`,K=`max(${m}, ${g})`,T=`max(${E}, calc(${E} + ${g} - ${m}))`):(L=(0,a.pxfy)(((0,a.depx)(m)-(0,a.depx)(g))/2),K=(0,a.pxfy)(Math.max((0,a.depx)(m),(0,a.depx)(g))),T=(0,a.depx)(m)>(0,a.depx)(g)?E:(0,a.pxfy)((0,a.depx)(E)+(0,a.depx)(g)-(0,a.depx)(m))),{"--n-bezier":be,"--n-button-border-radius":fe,"--n-button-box-shadow":W,"--n-button-color":F,"--n-button-width":de,"--n-button-width-pressed":ue,"--n-button-height":g,"--n-height":K,"--n-offset":L,"--n-opacity-disabled":b,"--n-rail-border-radius":he,"--n-rail-color":v,"--n-rail-color-active":y,"--n-rail-height":m,"--n-rail-width":E,"--n-width":T,"--n-box-shadow-focus":ae,"--n-loading-color":le,"--n-text-color":ce,"--n-icon-color":se}}),S=C?(0,p.useThemeClass)("switch",(0,o.computed)(()=>R.value[0]),q,e):void 0;return{handleClick:te,handleBlur:re,handleFocus:oe,handleKeyup:ie,handleKeydown:ne,mergedRailStyle:$,pressed:c,mergedClsPrefix:O,mergedValue:w,checked:z,mergedDisabled:_,cssVars:C?void 0:q,themeClass:S==null?void 0:S.themeClass,onRender:S==null?void 0:S.onRender}},render(){const{mergedClsPrefix:e,mergedDisabled:O,checked:C,mergedRailStyle:j,onRender:B,$slots:x}=this;B==null||B();const{checked:R,unchecked:_,icon:M,"checked-icon":P,"unchecked-icon":w}=x,z=!((0,l.isSlotEmpty)(M)&&(0,l.isSlotEmpty)(P)&&(0,l.isSlotEmpty)(w));return(0,o.h)("div",{role:"switch","aria-checked":C,class:[`${e}-switch`,this.themeClass,z&&`${e}-switch--icon`,C&&`${e}-switch--active`,O&&`${e}-switch--disabled`,this.round&&`${e}-switch--round`,this.loading&&`${e}-switch--loading`,this.pressed&&`${e}-switch--pressed`,this.rubberBand&&`${e}-switch--rubber-band`],tabindex:this.mergedDisabled?void 0:0,style:this.cssVars,onClick:this.handleClick,onFocus:this.handleFocus,onBlur:this.handleBlur,onKeyup:this.handleKeyup,onKeydown:this.handleKeydown},(0,o.h)("div",{class:`${e}-switch__rail`,"aria-hidden":"true",style:j},(0,l.resolveWrappedSlot)(R,c=>(0,l.resolveWrappedSlot)(_,d=>c||d?(0,o.h)("div",{"aria-hidden":!0,class:`${e}-switch__children-placeholder`},(0,o.h)("div",{class:`${e}-switch__rail-placeholder`},(0,o.h)("div",{class:`${e}-switch__button-placeholder`}),c),(0,o.h)("div",{class:`${e}-switch__rail-placeholder`},(0,o.h)("div",{class:`${e}-switch__button-placeholder`}),d)):null)),(0,o.h)("div",{class:`${e}-switch__button`},(0,l.resolveWrappedSlot)(M,c=>(0,l.resolveWrappedSlot)(P,d=>(0,l.resolveWrappedSlot)(w,$=>(0,o.h)(h.NIconSwitchTransition,null,{default:()=>this.loading?(0,o.h)(h.NBaseLoading,Object.assign({key:"loading",clsPrefix:e,strokeWidth:20},this.spinProps)):this.checked&&(d||c)?(0,o.h)("div",{class:`${e}-switch__button-icon`,key:d?"checked-icon":"icon"},d||c):!this.checked&&($||c)?(0,o.h)("div",{class:`${e}-switch__button-icon`,key:$?"unchecked-icon":"icon"},$||c):null})))),(0,l.resolveWrappedSlot)(R,c=>c&&(0,o.h)("div",{key:"checked",class:`${e}-switch__checked`},c)),(0,l.resolveWrappedSlot)(_,c=>c&&(0,o.h)("div",{key:"unchecked",class:`${e}-switch__unchecked`},c)))))}})})(X);(function(r){var s=u.commonjsGlobal&&u.commonjsGlobal.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(r,"__esModule",{value:!0}),r.switchProps=r.NSwitch=void 0;var a=X;Object.defineProperty(r,"NSwitch",{enumerable:!0,get:function(){return s(a).default}}),Object.defineProperty(r,"switchProps",{enumerable:!0,get:function(){return a.switchProps}})})(I);const Re=ge({__proto__:null},[I]);exports.index=Re;