UNPKG

ai-form-designer

Version:

vue3+adv的设计器,可视化开发页面表单

103 lines (102 loc) 13.2 kB
"use strict";const d=require("./_commonjsHelpers-DwTZ_eVU.cjs"),h=require("./index-l4ZjSaVt.cjs"),be=require("./_vue_commonjs-external-CccDNqHl.cjs"),A=require("./index-BHY6EyIp.cjs");function ve(r,s){for(var n=0;n<s.length;n++){const i=s[n];if(typeof i!="string"&&!Array.isArray(i)){for(const o in i)if(o!=="default"&&!(o in r)){const u=Object.getOwnPropertyDescriptor(i,o);u&&Object.defineProperty(r,o,u.get?u:{enumerable:!0,get:()=>i[o]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}var U={},I={},X={},N={},D={};Object.defineProperty(D,"__esModule",{value:!0});D.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=d.commonjsGlobal&&d.commonjsGlobal.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(N,"__esModule",{value:!0});const ge=h.require$$0,pe=h.common,_e=me(D),we={name:"Switch",common:pe.commonDark,self(r){const{primaryColorSuppl:s,opacityDisabled:n,borderRadius:i,primaryColor:o,textColor2:u,baseColor:p}=r;return Object.assign(Object.assign({},_e.default),{iconColor:p,textColor:u,loadingColor:s,opacityDisabled:n,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,ge.changeColor)(o,{alpha:.3})}`})}};N.default=we;var T={},ye=d.commonjsGlobal&&d.commonjsGlobal.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(T,"__esModule",{value:!0});const xe=h.require$$0,Se=h.common,ke=ye(D);function Ce(r){const{primaryColor:s,opacityDisabled:n,borderRadius:i,textColor3:o}=r;return Object.assign(Object.assign({},ke.default),{iconColor:o,textColor:"white",loadingColor:s,opacityDisabled:n,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,xe.changeColor)(s,{alpha:.2})}`})}const $e={name:"Switch",common:Se.commonLight,self:Ce};T.default=$e;(function(r){var s=d.commonjsGlobal&&d.commonjsGlobal.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(r,"__esModule",{value:!0}),r.switchLight=r.switchDark=void 0;var n=N;Object.defineProperty(r,"switchDark",{enumerable:!0,get:function(){return s(n).default}});var i=T;Object.defineProperty(r,"switchLight",{enumerable:!0,get:function(){return s(i).default}})})(X);var H={};Object.defineProperty(H,"__esModule",{value:!0});const q=A.iconSwitch_cssr,t=h.cssr;H.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,q.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,q.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=d.commonjsGlobal&&d.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.switchProps=void 0;const n=h.require$$0,i=h.require$$1,o=be.require$$2,u=A._internal,p=h._mixins,l=h._utils,Y=X,J=s(H);r.switchProps=Object.assign(Object.assign({},p.useTheme.props),{size:{type:String,default:"medium"},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},onChange:[Function,Array]});let S;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.")}),S===void 0&&(typeof CSS<"u"?typeof CSS.supports<"u"?S=CSS.supports("width","max(1px)"):S=!1:S=!0);const{mergedClsPrefixRef:j,inlineThemeDisabled:k}=(0,p.useConfig)(e),F=(0,p.useTheme)("Switch","-switch",J.default,Y.switchLight,e,j),f=(0,p.useFormItem)(e),{mergedSizeRef:R,mergedDisabledRef:_}=f,C=(0,o.ref)(e.defaultValue),M=(0,o.toRef)(e,"value"),w=(0,i.useMergedState)(M,C),$=(0,o.computed)(()=>w.value===e.checkedValue),y=(0,o.ref)(!1),c=(0,o.ref)(!1),b=(0,o.computed)(()=>{const{railStyle:a}=e;if(a)return a({focused:c.value,checked:$.value})});function v(a){const{"onUpdate:value":E,onChange:O,onUpdateValue:P}=e,{nTriggerFormInput:V,nTriggerFormChange:W}=f;E&&(0,l.call)(E,a),P&&(0,l.call)(P,a),O&&(0,l.call)(O,a),C.value=a,V(),W()}function Q(){const{nTriggerFormFocus:a}=f;a()}function Z(){const{nTriggerFormBlur:a}=f;a()}function ee(){e.loading||_.value||(w.value!==e.checkedValue?v(e.checkedValue):v(e.uncheckedValue))}function te(){c.value=!0,Q()}function oe(){c.value=!1,Z(),y.value=!1}function re(a){e.loading||_.value||a.key===" "&&(w.value!==e.checkedValue?v(e.checkedValue):v(e.uncheckedValue),y.value=!1)}function ie(a){e.loading||_.value||a.key===" "&&(a.preventDefault(),y.value=!0)}const G=(0,o.computed)(()=>{const{value:a}=R,{self:{opacityDisabled:E,railColor:O,railColorActive:P,buttonBoxShadow:V,buttonColor:W,boxShadowFocus:ne,loadingColor:ae,textColor:le,iconColor:ce,[(0,l.createKey)("buttonHeight",a)]:m,[(0,l.createKey)("buttonWidth",a)]:se,[(0,l.createKey)("buttonWidthPressed",a)]:de,[(0,l.createKey)("railHeight",a)]:g,[(0,l.createKey)("railWidth",a)]:B,[(0,l.createKey)("railBorderRadius",a)]:ue,[(0,l.createKey)("buttonBorderRadius",a)]:he},common:{cubicBezierEaseInOut:fe}}=F.value;let z,L,K;return S?(z=`calc((${g} - ${m}) / 2)`,L=`max(${g}, ${m})`,K=`max(${B}, calc(${B} + ${m} - ${g}))`):(z=(0,n.pxfy)(((0,n.depx)(g)-(0,n.depx)(m))/2),L=(0,n.pxfy)(Math.max((0,n.depx)(g),(0,n.depx)(m))),K=(0,n.depx)(g)>(0,n.depx)(m)?B:(0,n.pxfy)((0,n.depx)(B)+(0,n.depx)(m)-(0,n.depx)(g))),{"--n-bezier":fe,"--n-button-border-radius":he,"--n-button-box-shadow":V,"--n-button-color":W,"--n-button-width":se,"--n-button-width-pressed":de,"--n-button-height":m,"--n-height":L,"--n-offset":z,"--n-opacity-disabled":E,"--n-rail-border-radius":ue,"--n-rail-color":O,"--n-rail-color-active":P,"--n-rail-height":g,"--n-rail-width":B,"--n-width":K,"--n-box-shadow-focus":ne,"--n-loading-color":ae,"--n-text-color":le,"--n-icon-color":ce}}),x=k?(0,p.useThemeClass)("switch",(0,o.computed)(()=>R.value[0]),G,e):void 0;return{handleClick:ee,handleBlur:oe,handleFocus:te,handleKeyup:re,handleKeydown:ie,mergedRailStyle:b,pressed:y,mergedClsPrefix:j,mergedValue:w,checked:$,mergedDisabled:_,cssVars:k?void 0:G,themeClass:x==null?void 0:x.themeClass,onRender:x==null?void 0:x.onRender}},render(){const{mergedClsPrefix:e,mergedDisabled:j,checked:k,mergedRailStyle:F,onRender:f,$slots:R}=this;f==null||f();const{checked:_,unchecked:C,icon:M,"checked-icon":w,"unchecked-icon":$}=R,y=!((0,l.isSlotEmpty)(M)&&(0,l.isSlotEmpty)(w)&&(0,l.isSlotEmpty)($));return(0,o.h)("div",{role:"switch","aria-checked":k,class:[`${e}-switch`,this.themeClass,y&&`${e}-switch--icon`,k&&`${e}-switch--active`,j&&`${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:F},(0,l.resolveWrappedSlot)(_,c=>(0,l.resolveWrappedSlot)(C,b=>c||b?(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`}),b)):null)),(0,o.h)("div",{class:`${e}-switch__button`},(0,l.resolveWrappedSlot)(M,c=>(0,l.resolveWrappedSlot)(w,b=>(0,l.resolveWrappedSlot)($,v=>(0,o.h)(u.NIconSwitchTransition,null,{default:()=>this.loading?(0,o.h)(u.NBaseLoading,{key:"loading",clsPrefix:e,strokeWidth:20}):this.checked&&(b||c)?(0,o.h)("div",{class:`${e}-switch__button-icon`,key:b?"checked-icon":"icon"},b||c):!this.checked&&(v||c)?(0,o.h)("div",{class:`${e}-switch__button-icon`,key:v?"unchecked-icon":"icon"},v||c):null})))),(0,l.resolveWrappedSlot)(_,c=>c&&(0,o.h)("div",{key:"checked",class:`${e}-switch__checked`},c)),(0,l.resolveWrappedSlot)(C,c=>c&&(0,o.h)("div",{key:"unchecked",class:`${e}-switch__unchecked`},c)))))}})})(I);(function(r){var s=d.commonjsGlobal&&d.commonjsGlobal.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(r,"__esModule",{value:!0}),r.switchProps=r.NSwitch=void 0;var n=I;Object.defineProperty(r,"NSwitch",{enumerable:!0,get:function(){return s(n).default}}),Object.defineProperty(r,"switchProps",{enumerable:!0,get:function(){return n.switchProps}})})(U);const Be=ve({__proto__:null},[U]);exports.index=Be;