@gopowerteam/form-render 0.0.19 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/form-items/select/index.d.ts +1 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/interfaces/form-item-options.d.ts +1 -1
- package/dist/es/form-items/select/index.d.ts +1 -0
- package/dist/es/index.mjs +192 -182
- package/dist/es/interfaces/form-item-options.d.ts +1 -1
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ export type SelectOptions = Map<string | number, string>;
|
|
|
4
4
|
export interface RenderSelectItemOptions {
|
|
5
5
|
placeholder?: string;
|
|
6
6
|
clearable?: boolean;
|
|
7
|
+
searchable?: boolean;
|
|
7
8
|
options: SelectOptions | (() => SelectOptions) | Promise<SelectOptions> | (() => Promise<SelectOptions>);
|
|
8
9
|
multiple?: boolean;
|
|
9
10
|
maxTagCount?: number;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("vue"),f=require("@arco-design/web-vue"),$=require("dayjs"),D=require("./resolver.cjs");const O=Symbol("ArcoConfigProvider"),j="arco",M="$arco",F=e=>{var r,t,a;const u=l.getCurrentInstance(),d=l.inject(O,void 0),n=(a=(t=d==null?void 0:d.prefixCls)!=null?t:(r=u==null?void 0:u.appContext.config.globalProperties[M])==null?void 0:r.classPrefix)!=null?a:j;return e?`${n}-${e}`:n},z=Object.prototype.toString;function x(e){return z.call(e)==="[object Number]"&&e===e}var w=(e,r)=>{for(const[t,a]of r)e[t]=a;return e};const P=l.defineComponent({name:"IconDown",props:{size:{type:[Number,String]},strokeWidth:{type:Number,default:4},strokeLinecap:{type:String,default:"butt",validator:e=>["butt","round","square"].includes(e)},strokeLinejoin:{type:String,default:"miter",validator:e=>["arcs","bevel","miter","miter-clip","round"].includes(e)},rotate:Number,spin:Boolean},emits:{click:e=>!0},setup(e,{emit:r}){const t=F("icon"),a=l.computed(()=>[t,`${t}-down`,{[`${t}-spin`]:e.spin}]),u=l.computed(()=>{const n={};return e.size&&(n.fontSize=x(e.size)?`${e.size}px`:e.size),e.rotate&&(n.transform=`rotate(${e.rotate}deg)`),n});return{cls:a,innerStyle:u,onClick:n=>{r("click",n)}}}}),T=["stroke-width","stroke-linecap","stroke-linejoin"],L=l.createElementVNode("path",{d:"M39.6 17.443 24.043 33 8.487 17.443"},null,-1),R=[L];function B(e,r,t,a,u,d){return l.openBlock(),l.createElementBlock("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",class:l.normalizeClass(e.cls),style:l.normalizeStyle(e.innerStyle),"stroke-width":e.strokeWidth,"stroke-linecap":e.strokeLinecap,"stroke-linejoin":e.strokeLinejoin,onClick:r[0]||(r[0]=(...n)=>e.onClick&&e.onClick(...n))},R,14,T)}var v=w(P,[["render",B]]);const q=Object.assign(v,{install:(e,r)=>{var t;const a=(t=r==null?void 0:r.iconPrefix)!=null?t:"";e.component(a+v.name,v)}}),U=l.defineComponent({name:"IconUp",props:{size:{type:[Number,String]},strokeWidth:{type:Number,default:4},strokeLinecap:{type:String,default:"butt",validator:e=>["butt","round","square"].includes(e)},strokeLinejoin:{type:String,default:"miter",validator:e=>["arcs","bevel","miter","miter-clip","round"].includes(e)},rotate:Number,spin:Boolean},emits:{click:e=>!0},setup(e,{emit:r}){const t=F("icon"),a=l.computed(()=>[t,`${t}-up`,{[`${t}-spin`]:e.spin}]),u=l.computed(()=>{const n={};return e.size&&(n.fontSize=x(e.size)?`${e.size}px`:e.size),e.rotate&&(n.transform=`rotate(${e.rotate}deg)`),n});return{cls:a,innerStyle:u,onClick:n=>{r("click",n)}}}}),E=["stroke-width","stroke-linecap","stroke-linejoin"],W=l.createElementVNode("path",{d:"M39.6 30.557 24.043 15 8.487 30.557"},null,-1),A=[W];function Y(e,r,t,a,u,d){return l.openBlock(),l.createElementBlock("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",class:l.normalizeClass(e.cls),style:l.normalizeStyle(e.innerStyle),"stroke-width":e.strokeWidth,"stroke-linecap":e.strokeLinecap,"stroke-linejoin":e.strokeLinejoin,onClick:r[0]||(r[0]=(...n)=>e.onClick&&e.onClick(...n))},A,14,E)}var S=w(U,[["render",Y]]);const G=Object.assign(S,{install:(e,r)=>{var t;const a=(t=r==null?void 0:r.iconPrefix)!=null?t:"";e.component(a+S.name,S)}}),C={id:Symbol("ID"),source:Symbol("Source")};function K(e,r){const t=l.ref({});return e==null||e.forEach(u=>{let d=null;u.default&&(d=(typeof u.default=="function"?u.default():u.default)||null),r&&r[u.key]!==void 0&&(d=r[u.key]),t.value[u.key]=d}),[t,u=>{t.value=u}]}function Q(e){function r(t,a){return e!=null&&e.disabledDate?e.disabledDate(t,a):!1}return(t,a)=>{switch(e==null?void 0:e.type){case"week":return l.createVNode(f.WeekPicker,{modelValue:t[a.key],"onUpdate:modelValue":u=>t[a.key]=u,"disabled-date":r,format:e==null?void 0:e.labelFormat,"value-format":e==null?void 0:e.valueFormat},null);case"month":return l.createVNode(f.MonthPicker,{modelValue:t[a.key],"onUpdate:modelValue":u=>t[a.key]=u,"disabled-date":r,format:e==null?void 0:e.labelFormat,"value-format":e==null?void 0:e.valueFormat},null);case"quarter":return l.createVNode(f.QuarterPicker,{modelValue:t[a.key],"onUpdate:modelValue":u=>t[a.key]=u,"disabled-date":r,format:e==null?void 0:e.labelFormat,"value-format":e==null?void 0:e.valueFormat},null);case"year":return l.createVNode(f.YearPicker,{modelValue:t[a.key],"onUpdate:modelValue":u=>t[a.key]=u,"disabled-date":r,format:e==null?void 0:e.labelFormat,"value-format":e==null?void 0:e.valueFormat},null);case"date":default:return l.createVNode(f.DatePicker,{modelValue:t[a.key],"onUpdate:modelValue":u=>t[a.key]=u,"disabled-date":r,format:e==null?void 0:e.labelFormat,"value-format":e==null?void 0:e.valueFormat},null)}}}function X(e){return(r,t)=>{switch(e==null?void 0:e.type){case"number":return l.createVNode(f.InputNumber,{modelValue:r[t.key],"onUpdate:modelValue":a=>r[t.key]=a,hideButton:!0,"read-only":e==null?void 0:e.readonly,placeholder:e==null?void 0:e.placeholder,allowClear:e==null?void 0:e.clearable},null);case"string":default:return l.createVNode(f.Input,{modelValue:r[t.key],"onUpdate:modelValue":a=>r[t.key]=a,placeholder:e==null?void 0:e.placeholder,readonly:e==null?void 0:e.readonly,allowClear:e==null?void 0:e.clearable},null)}}}function k(e){return!!e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function H(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!l.isVNode(e)}const V=new WeakMap;function J(e){let r,t=!1;const a=l.ref(new Map),u=n=>{a.value=n,e.cache!==!1&&V.set(e.options,n)};switch(!0){case e.options instanceof Function:{if(V.has(e.options)){a.value=V.get(e.options);break}const n=e.options();k(n)?n.then(u):u(n);break}case k(e.options):{e.options.then(n=>a.value=n);break}default:a.value=e.options}function d(){if(!e.autoSumbit||!r)return;let n=r;for(;n&&n.$el.tagName!=="FORM";)n=n.$parent;n&&n.$el&&n.$el.dispatchEvent(new Event("submit"))}return(n,c)=>{let s;return e.default&&!t&&(n[c.key]=e.default,t=!0),l.createVNode(f.Select,{ref:o=>r=o,multiple:e.multiple,modelValue:n[c.key],"onUpdate:modelValue":o=>n[c.key]=o,placeholder:e.placeholder,allowClear:e.clearable,maxTagCount:e.maxTagCount??2,onChange:d},H(s=Array.from(a.value.entries()).map(([o,h])=>l.createVNode(f.Option,{key:o,value:o,label:h},null)))?s:{default:()=>[s]})}}function Z(e){function r(){e!=null&&e.autoSumbit}return(t,a)=>(e!=null&&e.default&&(t[a.key]=e.default),l.createVNode(f.Switch,{modelValue:t[a.key],"onUpdate:modelValue":u=>t[a.key]=u,checkedText:(e==null?void 0:e.openLabel)??"是",uncheckedText:(e==null?void 0:e.closeLabel)??"否",checkedValue:(e==null?void 0:e.openValue)??!0,uncheckedValue:(e==null?void 0:e.closeValue)??!1,onChange:r},null))}function p(e){return(r,t)=>{let a=[];function u(c){a=c}function d(c){if(c&&c.length===2){const[s,o]=c.sort(),h=$(s).startOf("days"),y=$(o).endOf("days");r[t.key]=[h.format((e==null?void 0:e.valueFormat)||"YYYY-MM-DD"),y.format((e==null?void 0:e.valueFormat)||"YYYY-MM-DD")]}}function n(c){return e!=null&&e.disabledDate?e.disabledDate(a,c):!1}return l.createVNode("div",null,[l.createVNode(f.RangePicker,{style:{width:"300px"},modelValue:r[t.key],"onUpdate:modelValue":c=>r[t.key]=c,onSelect:u,onChange:d,mode:e==null?void 0:e.type,allowClear:e==null?void 0:e.clearable,"disabled-date":n,format:e==null?void 0:e.labelFormat,"value-format":e==null?void 0:e.valueFormat},null)])}}function ee(e){return(r,t)=>l.createVNode(f.Textarea,{modelValue:r[t.key],"onUpdate:modelValue":a=>r[t.key]=a,placeholder:e==null?void 0:e.placeholder,autoSize:e==null?void 0:e.autosize,maxLength:e==null?void 0:e.maxLength},null)}const g=new WeakMap;function te(e){let r,t=!1;const a=l.ref([]),u=c=>{a.value=c,e.cache!==!1&&g.set(e.options,c)};switch(!0){case e.options instanceof Function:{if(g.has(e.options)){a.value=g.get(e.options);break}const c=e.options();k(c)?c.then(u):u(c);break}case k(e.options):{e.options.then(c=>a.value=c);break}default:a.value=e.options}function d(){if(!e.autoSumbit||!r)return;let c=r;for(;c&&c.$el.tagName!=="FORM";)c=c.$parent;c&&c.$el&&c.$el.dispatchEvent(new Event("submit"))}function n(c,s){var y;const o=((y=e.fieldNames)==null?void 0:y.title)||"title",h=s[o];return h?h.toLowerCase().includes(c.toLowerCase()):!1}return(c,s)=>(e.default&&!t&&(c[s.key]=e.default,t=!0),l.createVNode(f.TreeSelect,{ref:o=>r=o,multiple:e.multiple,modelValue:c[s.key],"onUpdate:modelValue":o=>c[s.key]=o,placeholder:e.placeholder,allowClear:e.clearable,allowSearch:e.searchable,maxTagCount:e.maxTagCount??2,onChange:d,filterTreeNode:n,data:a.value,fieldNames:e.fieldNames},null))}function re(e){return r=>e(r)}function le(){return{input:X,textarea:ee,select:J,treeSelect:te,date:Q,switch:Z,dateRange:p,render:re}}function ae(e,r){r.render||(r.render=a=>a.input());const t=r.render({...le()});return{default:()=>t(e,r)}}function ne(e,r){return l.h(f.FormItem,{field:r.key,label:r.title},ae(e,r))}function N(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!l.isVNode(e)}const I=l.defineComponent({props:{form:{type:Object,required:!0},value:{type:Object,required:!1},layout:{type:String,required:!1,default:"horizontal"},columns:{type:Number,required:!1},modelValue:{type:Object,required:!1},minWidth:{type:Number,required:!1,default:320},name:{type:String,required:!1,default:"form"},submitable:{type:Boolean,required:!1,default:!1},searchable:{type:Boolean,required:!1,default:!1},footer:{type:Boolean,required:!1,default:!1}},emits:["submit","cancel","update:model-value"],expose:["formSource","updateFormField","updateFormSource","reset"],setup(e){const r=Math.random().toString(32).slice(2).toUpperCase(),t=l.ref(),[a,u]=K(e.form,e.modelValue||e.value),d=l.ref(e.columns||0),n=l.ref(!0),c=()=>n.value=!n.value;l.provide(C.id,r),l.provide(C.source,a);const s=l.computed(()=>{if(!d.value)return 1;const i=e.form.reduce((m,b)=>m+((b==null?void 0:b.span)||1),0);return d.value-i%d.value}),o=l.computed(()=>e.form.reduce((i,m)=>(m.rule&&(i[m.key]=m.rule),i),{}));function h(){var m;const i=(m=t.value)==null?void 0:m.$el;i&&(d.value=Math.floor(i.offsetWidth/e.minWidth))}l.onMounted(()=>{h()});function y(i,m){a.value[i]=m,u({...a})}function _(){var i;(i=t.value)==null||i.resetFields()}return window.addEventListener("resize",h),{formId:r,formSource:a,formInstance:t,formColumns:d,formRules:o,formCollspased:n,formActiosSpan:s,toggleFormCollapsed:c,updateFormField:y,updateFormSource:u,reset:_}},render(){const e=()=>{this.$emit("submit",this.formSource),this.$emit("update:model-value",this.formSource)},r=()=>{const t=[],a=this.footer?{span:this.formColumns}:{span:this.formActiosSpan};if(this.searchable&&(t.push(l.createVNode(f.Button,{type:"primary",htmlType:"submit"},{default:()=>[l.createTextVNode("搜索")]})),t.push(l.createVNode(f.Button,{type:"secondary",onClick:()=>{var u;return(u=this.formInstance)==null?void 0:u.resetFields()}},{default:()=>[l.createTextVNode("重置")]}))),this.submitable&&(t.push(l.createVNode(f.Button,{type:"primary",htmlType:"submit"},{default:()=>[l.createTextVNode("提交")]})),t.push(l.createVNode(f.Button,{type:"secondary",onClick:()=>this.$emit("cancel")},{default:()=>[l.createTextVNode("取消")]}))),this.form.some(u=>!!u.collapsed)&&t.push(l.createVNode(f.Button,{onClick:this.toggleFormCollapsed},{default:()=>this.formCollspased?"展开":"收起",icon:()=>this.formCollspased?l.createVNode(q,null,null):l.createVNode(G,null,null)})),this.$slots.actions&&t.push(...this.$slots.actions()),t.length)return l.createVNode(f.GridItem,a,{default:()=>[l.createVNode(f.FormItem,{hideLabel:!0,contentClass:this.footer?"form-footer":""},{default:()=>[l.createVNode(f.Space,null,N(t)?t:{default:()=>[t]})]})]})};return l.createVNode("div",{class:"form-render"},[l.createVNode(f.Form,l.mergeProps({layout:this.$props.layout,rules:this.formRules,onSubmitSuccess:e},{name:this.name},{"auto-label-width":!0,ref:t=>this.formInstance=t,model:this.formSource}),{default:()=>[l.createVNode(f.Grid,{cols:this.formColumns,"col-gap":10,"rol-gap":10},{default:()=>[this.form.filter(t=>this.formCollspased?!t.collapsed:!0).map(t=>{let a;return l.createVNode(f.GridItem,{span:t.span},N(a=ne(this.formSource,t))?a:{default:()=>[a]})}),r()]})]})])}});function ue(e){return e}function ce(e){const r=l.getCurrentInstance(),t=l.ref();function a(){var d,n;const u=(n=(d=r==null?void 0:r.proxy)==null?void 0:d.$refs)==null?void 0:n[e];u&&(t.value=u)}return l.onMounted(a),l.onUpdated(a),t}const de={install(e,r){e.component("FormRender",I)}};exports.FormRenderResolver=D.FormRenderResolver;exports.FormRender=I;exports.default=de;exports.defineForm=ue;exports.useForm=ce;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),f=require("@arco-design/web-vue"),$=require("dayjs"),D=require("./resolver.cjs");const O=Symbol("ArcoConfigProvider"),j="arco",M="$arco",F=e=>{var r,l,t;const n=a.getCurrentInstance(),d=a.inject(O,void 0),u=(t=(l=d==null?void 0:d.prefixCls)!=null?l:(r=n==null?void 0:n.appContext.config.globalProperties[M])==null?void 0:r.classPrefix)!=null?t:j;return e?`${u}-${e}`:u},z=Object.prototype.toString;function w(e){return z.call(e)==="[object Number]"&&e===e}var x=(e,r)=>{for(const[l,t]of r)e[l]=t;return e};const P=a.defineComponent({name:"IconDown",props:{size:{type:[Number,String]},strokeWidth:{type:Number,default:4},strokeLinecap:{type:String,default:"butt",validator:e=>["butt","round","square"].includes(e)},strokeLinejoin:{type:String,default:"miter",validator:e=>["arcs","bevel","miter","miter-clip","round"].includes(e)},rotate:Number,spin:Boolean},emits:{click:e=>!0},setup(e,{emit:r}){const l=F("icon"),t=a.computed(()=>[l,`${l}-down`,{[`${l}-spin`]:e.spin}]),n=a.computed(()=>{const u={};return e.size&&(u.fontSize=w(e.size)?`${e.size}px`:e.size),e.rotate&&(u.transform=`rotate(${e.rotate}deg)`),u});return{cls:t,innerStyle:n,onClick:u=>{r("click",u)}}}}),T=["stroke-width","stroke-linecap","stroke-linejoin"],L=a.createElementVNode("path",{d:"M39.6 17.443 24.043 33 8.487 17.443"},null,-1),R=[L];function B(e,r,l,t,n,d){return a.openBlock(),a.createElementBlock("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",class:a.normalizeClass(e.cls),style:a.normalizeStyle(e.innerStyle),"stroke-width":e.strokeWidth,"stroke-linecap":e.strokeLinecap,"stroke-linejoin":e.strokeLinejoin,onClick:r[0]||(r[0]=(...u)=>e.onClick&&e.onClick(...u))},R,14,T)}var v=x(P,[["render",B]]);const q=Object.assign(v,{install:(e,r)=>{var l;const t=(l=r==null?void 0:r.iconPrefix)!=null?l:"";e.component(t+v.name,v)}}),U=a.defineComponent({name:"IconUp",props:{size:{type:[Number,String]},strokeWidth:{type:Number,default:4},strokeLinecap:{type:String,default:"butt",validator:e=>["butt","round","square"].includes(e)},strokeLinejoin:{type:String,default:"miter",validator:e=>["arcs","bevel","miter","miter-clip","round"].includes(e)},rotate:Number,spin:Boolean},emits:{click:e=>!0},setup(e,{emit:r}){const l=F("icon"),t=a.computed(()=>[l,`${l}-up`,{[`${l}-spin`]:e.spin}]),n=a.computed(()=>{const u={};return e.size&&(u.fontSize=w(e.size)?`${e.size}px`:e.size),e.rotate&&(u.transform=`rotate(${e.rotate}deg)`),u});return{cls:t,innerStyle:n,onClick:u=>{r("click",u)}}}}),E=["stroke-width","stroke-linecap","stroke-linejoin"],W=a.createElementVNode("path",{d:"M39.6 30.557 24.043 15 8.487 30.557"},null,-1),A=[W];function Y(e,r,l,t,n,d){return a.openBlock(),a.createElementBlock("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",class:a.normalizeClass(e.cls),style:a.normalizeStyle(e.innerStyle),"stroke-width":e.strokeWidth,"stroke-linecap":e.strokeLinecap,"stroke-linejoin":e.strokeLinejoin,onClick:r[0]||(r[0]=(...u)=>e.onClick&&e.onClick(...u))},A,14,E)}var S=x(U,[["render",Y]]);const G=Object.assign(S,{install:(e,r)=>{var l;const t=(l=r==null?void 0:r.iconPrefix)!=null?l:"";e.component(t+S.name,S)}}),C={id:Symbol("ID"),source:Symbol("Source")};function K(e,r){const l=a.ref({});return e==null||e.forEach(n=>{let d=null;n.default&&(d=(typeof n.default=="function"?n.default():n.default)||null),r&&r[n.key]!==void 0&&(d=r[n.key]),l.value[n.key]=d}),[l,n=>{l.value=n}]}function Q(e){function r(l,t){return e!=null&&e.disabledDate?e.disabledDate(l,t):!1}return(l,t)=>{switch(e==null?void 0:e.type){case"week":return a.createVNode(f.WeekPicker,{modelValue:l[t.key],"onUpdate:modelValue":n=>l[t.key]=n,"disabled-date":r,format:e==null?void 0:e.labelFormat,"value-format":e==null?void 0:e.valueFormat},null);case"month":return a.createVNode(f.MonthPicker,{modelValue:l[t.key],"onUpdate:modelValue":n=>l[t.key]=n,"disabled-date":r,format:e==null?void 0:e.labelFormat,"value-format":e==null?void 0:e.valueFormat},null);case"quarter":return a.createVNode(f.QuarterPicker,{modelValue:l[t.key],"onUpdate:modelValue":n=>l[t.key]=n,"disabled-date":r,format:e==null?void 0:e.labelFormat,"value-format":e==null?void 0:e.valueFormat},null);case"year":return a.createVNode(f.YearPicker,{modelValue:l[t.key],"onUpdate:modelValue":n=>l[t.key]=n,"disabled-date":r,format:e==null?void 0:e.labelFormat,"value-format":e==null?void 0:e.valueFormat},null);case"date":default:return a.createVNode(f.DatePicker,{modelValue:l[t.key],"onUpdate:modelValue":n=>l[t.key]=n,"disabled-date":r,format:e==null?void 0:e.labelFormat,"value-format":e==null?void 0:e.valueFormat},null)}}}function X(e){return(r,l)=>{switch(e==null?void 0:e.type){case"number":return a.createVNode(f.InputNumber,{modelValue:r[l.key],"onUpdate:modelValue":t=>r[l.key]=t,hideButton:!0,"read-only":e==null?void 0:e.readonly,placeholder:e==null?void 0:e.placeholder,allowClear:e==null?void 0:e.clearable},null);case"string":default:return a.createVNode(f.Input,{modelValue:r[l.key],"onUpdate:modelValue":t=>r[l.key]=t,placeholder:e==null?void 0:e.placeholder,readonly:e==null?void 0:e.readonly,allowClear:e==null?void 0:e.clearable},null)}}}function k(e){return!!e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function H(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!a.isVNode(e)}const V=new WeakMap;function J(e){let r,l=!1;const t=a.ref(new Map),n=u=>{t.value=u,e.cache!==!1&&V.set(e.options,u)};switch(!0){case e.options instanceof Function:{if(V.has(e.options)){t.value=V.get(e.options);break}const u=e.options();k(u)?u.then(n):n(u);break}case k(e.options):{e.options.then(u=>t.value=u);break}default:t.value=e.options}function d(){if(!e.autoSumbit||!r)return;let u=r;for(;u&&u.$el.tagName!=="FORM";)u=u.$parent;u&&u.$el&&u.$el.dispatchEvent(new Event("submit"))}return(u,c)=>{let o;return e.default&&!l&&(u[c.key]=e.default,l=!0),a.createVNode(f.Select,{ref:s=>r=s,multiple:e.multiple,modelValue:u[c.key],"onUpdate:modelValue":s=>u[c.key]=s,placeholder:e.placeholder,allowClear:e.clearable,allowSearch:e.searchable,maxTagCount:e.maxTagCount??2,onChange:d},H(o=Array.from(t.value.entries()).map(([s,h])=>a.createVNode(f.Option,{key:s,value:s,label:h},null)))?o:{default:()=>[o]})}}function Z(e){function r(){e!=null&&e.autoSumbit}return(l,t)=>(e!=null&&e.default&&(l[t.key]=e.default),a.createVNode(f.Switch,{modelValue:l[t.key],"onUpdate:modelValue":n=>l[t.key]=n,checkedText:(e==null?void 0:e.openLabel)??"是",uncheckedText:(e==null?void 0:e.closeLabel)??"否",checkedValue:(e==null?void 0:e.openValue)??!0,uncheckedValue:(e==null?void 0:e.closeValue)??!1,onChange:r},null))}function p(e){return(r,l)=>{let t=[];function n(c){t=c}function d(c){if(c&&c.length===2){const[o,s]=c.sort(),h=$(o).startOf("days"),y=$(s).endOf("days");r[l.key]=[h.format((e==null?void 0:e.valueFormat)||"YYYY-MM-DD"),y.format((e==null?void 0:e.valueFormat)||"YYYY-MM-DD")]}}function u(c){return e!=null&&e.disabledDate?e.disabledDate(t,c):!1}return a.createVNode("div",null,[a.createVNode(f.RangePicker,{style:{width:"300px"},modelValue:r[l.key],"onUpdate:modelValue":c=>r[l.key]=c,onSelect:n,onChange:d,mode:e==null?void 0:e.type,allowClear:e==null?void 0:e.clearable,"disabled-date":u,format:e==null?void 0:e.labelFormat,"value-format":e==null?void 0:e.valueFormat},null)])}}function ee(e){return(r,l)=>a.createVNode(f.Textarea,{modelValue:r[l.key],"onUpdate:modelValue":t=>r[l.key]=t,placeholder:e==null?void 0:e.placeholder,autoSize:e==null?void 0:e.autosize,maxLength:e==null?void 0:e.maxLength},null)}const g=new WeakMap;function te(e){let r,l=!1;const t=a.ref([]),n=c=>{t.value=c,e.cache!==!1&&g.set(e.options,c)};switch(!0){case e.options instanceof Function:{if(g.has(e.options)){t.value=g.get(e.options);break}const c=e.options();k(c)?c.then(n):n(c);break}case k(e.options):{e.options.then(c=>t.value=c);break}default:t.value=e.options}function d(){if(!e.autoSumbit||!r)return;let c=r;for(;c&&c.$el.tagName!=="FORM";)c=c.$parent;c&&c.$el&&c.$el.dispatchEvent(new Event("submit"))}function u(c,o){var y;const s=((y=e.fieldNames)==null?void 0:y.title)||"title",h=o[s];return h?h.toLowerCase().includes(c.toLowerCase()):!1}return(c,o)=>(e.default&&!l&&(c[o.key]=e.default,l=!0),a.createVNode(f.TreeSelect,{ref:s=>r=s,multiple:e.multiple,modelValue:c[o.key],"onUpdate:modelValue":s=>c[o.key]=s,placeholder:e.placeholder,allowClear:e.clearable,allowSearch:e.searchable,maxTagCount:e.maxTagCount??2,onChange:d,filterTreeNode:u,data:t.value,fieldNames:e.fieldNames},null))}function re(e){return r=>e(r)}function le(){return{input:X,textarea:ee,select:J,treeSelect:te,date:Q,switch:Z,dateRange:p,render:re}}function ae(e,r){r.render||(r.render=t=>t.input());const l=r.render({...le()});return{default:()=>l(e,r)}}function ne(e,r){return a.h(f.FormItem,{field:r.key,label:r.title},ae(e,r))}function N(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!a.isVNode(e)}const I=a.defineComponent({props:{form:{type:Object,required:!0},value:{type:Object,required:!1},layout:{type:String,required:!1,default:"horizontal"},columns:{type:Number,required:!1},modelValue:{type:Object,required:!1},minWidth:{type:Number,required:!1,default:320},name:{type:String,required:!1,default:"form"},submitable:{type:Boolean,required:!1,default:!1},searchable:{type:Boolean,required:!1,default:!1},footer:{type:Boolean,required:!1,default:!1}},emits:["submit","cancel","update:model-value"],expose:["formSource","updateFormField","updateFormSource","reset"],setup(e){const r=Math.random().toString(32).slice(2).toUpperCase(),l=a.ref(),[t,n]=K(e.form,e.modelValue||e.value),d=a.ref(e.columns||0),u=a.ref(!0),c=()=>u.value=!u.value;a.provide(C.id,r),a.provide(C.source,t);const o=a.computed(()=>{if(!d.value)return 1;const i=e.form.reduce((m,b)=>m+((b==null?void 0:b.span)||1),0);return d.value-i%d.value}),s=a.computed(()=>e.form.reduce((i,m)=>(m.rule&&(i[m.key]=m.rule),i),{}));function h(){var m;const i=(m=l.value)==null?void 0:m.$el;i&&(d.value=Math.floor(i.offsetWidth/e.minWidth))}a.onMounted(()=>{h()});function y(i,m){t.value[i]=m,n({...t})}function _(){var i;(i=l.value)==null||i.resetFields()}return window.addEventListener("resize",h),{formId:r,formSource:t,formInstance:l,formColumns:d,formRules:s,formCollspased:u,formActiosSpan:o,toggleFormCollapsed:c,updateFormField:y,updateFormSource:n,reset:_}},render(){const e=()=>{this.$emit("submit",this.formSource),this.$emit("update:model-value",this.formSource)},r=()=>{const t=[],n=this.footer?{span:this.formColumns}:{span:this.formActiosSpan};if(this.searchable&&(t.push(a.createVNode(f.Button,{type:"primary",htmlType:"submit"},{default:()=>[a.createTextVNode("搜索")]})),t.push(a.createVNode(f.Button,{type:"secondary",onClick:()=>{var d;return(d=this.formInstance)==null?void 0:d.resetFields()}},{default:()=>[a.createTextVNode("重置")]}))),this.submitable&&(t.push(a.createVNode(f.Button,{type:"primary",htmlType:"submit"},{default:()=>[a.createTextVNode("提交")]})),t.push(a.createVNode(f.Button,{type:"secondary",onClick:()=>this.$emit("cancel")},{default:()=>[a.createTextVNode("取消")]}))),this.form.some(d=>!!d.collapsed)&&t.push(a.createVNode(f.Button,{onClick:this.toggleFormCollapsed},{default:()=>this.formCollspased?"展开":"收起",icon:()=>this.formCollspased?a.createVNode(q,null,null):a.createVNode(G,null,null)})),this.$slots.actions&&t.push(...this.$slots.actions()),t.length)return a.createVNode(f.GridItem,n,{default:()=>[a.createVNode(f.FormItem,{hideLabel:!0,contentClass:this.footer?"form-footer":""},{default:()=>[a.createVNode(f.Space,null,N(t)?t:{default:()=>[t]})]})]})},l=this.form.filter(t=>this.formCollspased?!t.collapsed:!0).filter(t=>{switch(!0){case typeof t.visiable=="boolean":return t.visiable;case typeof t.visiable=="function":return t.visiable(this.formSource);default:return!0}});return a.createVNode("div",{class:"form-render"},[a.createVNode(f.Form,a.mergeProps({layout:this.$props.layout,rules:this.formRules,onSubmitSuccess:e},{name:this.name},{"auto-label-width":!0,ref:t=>this.formInstance=t,model:this.formSource}),{default:()=>[a.createVNode(f.Grid,{cols:this.formColumns,"col-gap":10,"rol-gap":10},{default:()=>[l.map(t=>{let n;return a.createVNode(f.GridItem,{span:t.span},N(n=ne(this.formSource,t))?n:{default:()=>[n]})}),r()]})]})])}});function ue(e){return e}function ce(e){const r=a.getCurrentInstance(),l=a.ref();function t(){var d,u;const n=(u=(d=r==null?void 0:r.proxy)==null?void 0:d.$refs)==null?void 0:u[e];n&&(l.value=n)}return a.onMounted(t),a.onUpdated(t),l}const de={install(e,r){e.component("FormRender",I)}};exports.FormRenderResolver=D.FormRenderResolver;exports.FormRender=I;exports.default=de;exports.defineForm=ue;exports.useForm=ce;
|
|
@@ -8,7 +8,7 @@ export interface FormItemOptions<T = Record<string, any>> {
|
|
|
8
8
|
title: string;
|
|
9
9
|
default?: any | (() => any) | (() => Promise<any>);
|
|
10
10
|
collapsed?: boolean;
|
|
11
|
-
visiable?: (record: T) => boolean;
|
|
11
|
+
visiable?: boolean | ((record: T) => boolean);
|
|
12
12
|
span?: number;
|
|
13
13
|
rule?: FieldRule | FieldRule[];
|
|
14
14
|
render?: FormItemRender<T>;
|
|
@@ -4,6 +4,7 @@ export type SelectOptions = Map<string | number, string>;
|
|
|
4
4
|
export interface RenderSelectItemOptions {
|
|
5
5
|
placeholder?: string;
|
|
6
6
|
clearable?: boolean;
|
|
7
|
+
searchable?: boolean;
|
|
7
8
|
options: SelectOptions | (() => SelectOptions) | Promise<SelectOptions> | (() => Promise<SelectOptions>);
|
|
8
9
|
multiple?: boolean;
|
|
9
10
|
maxTagCount?: number;
|
package/dist/es/index.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { getCurrentInstance as O, inject as A, defineComponent as F, computed as k, openBlock as j, createElementBlock as L, normalizeClass as P, normalizeStyle as z, createElementVNode as M, ref as h, createVNode as
|
|
1
|
+
import { getCurrentInstance as O, inject as A, defineComponent as F, computed as k, openBlock as j, createElementBlock as L, normalizeClass as P, normalizeStyle as z, createElementVNode as M, ref as h, createVNode as d, isVNode as U, h as Y, provide as V, onMounted as R, mergeProps as G, createTextVNode as v, onUpdated as K } from "vue";
|
|
2
2
|
import { DatePicker as Q, YearPicker as X, QuarterPicker as H, MonthPicker as J, WeekPicker as Z, Input as p, InputNumber as ee, Select as te, Option as le, Switch as re, RangePicker as ae, Textarea as ne, TreeSelect as ue, FormItem as T, Form as ce, Grid as de, GridItem as I, Button as b, Space as fe } from "@arco-design/web-vue";
|
|
3
3
|
import _ from "dayjs";
|
|
4
4
|
import { FormRenderResolver as Qe } from "./resolver.mjs";
|
|
5
|
-
const
|
|
6
|
-
var l,
|
|
7
|
-
const
|
|
8
|
-
return e ? `${
|
|
5
|
+
const se = Symbol("ArcoConfigProvider"), ie = "arco", me = "$arco", q = (e) => {
|
|
6
|
+
var l, r, t;
|
|
7
|
+
const a = O(), c = A(se, void 0), n = (t = (r = c == null ? void 0 : c.prefixCls) != null ? r : (l = a == null ? void 0 : a.appContext.config.globalProperties[me]) == null ? void 0 : l.classPrefix) != null ? t : ie;
|
|
8
|
+
return e ? `${n}-${e}` : n;
|
|
9
9
|
}, oe = Object.prototype.toString;
|
|
10
10
|
function B(e) {
|
|
11
11
|
return oe.call(e) === "[object Number]" && e === e;
|
|
12
12
|
}
|
|
13
13
|
var E = (e, l) => {
|
|
14
|
-
for (const [
|
|
15
|
-
e[
|
|
14
|
+
for (const [r, t] of l)
|
|
15
|
+
e[r] = t;
|
|
16
16
|
return e;
|
|
17
17
|
};
|
|
18
18
|
const he = F({
|
|
@@ -44,24 +44,24 @@ const he = F({
|
|
|
44
44
|
setup(e, {
|
|
45
45
|
emit: l
|
|
46
46
|
}) {
|
|
47
|
-
const
|
|
48
|
-
[`${
|
|
49
|
-
}]),
|
|
50
|
-
const
|
|
51
|
-
return e.size && (
|
|
47
|
+
const r = q("icon"), t = k(() => [r, `${r}-down`, {
|
|
48
|
+
[`${r}-spin`]: e.spin
|
|
49
|
+
}]), a = k(() => {
|
|
50
|
+
const n = {};
|
|
51
|
+
return e.size && (n.fontSize = B(e.size) ? `${e.size}px` : e.size), e.rotate && (n.transform = `rotate(${e.rotate}deg)`), n;
|
|
52
52
|
});
|
|
53
53
|
return {
|
|
54
|
-
cls:
|
|
55
|
-
innerStyle:
|
|
56
|
-
onClick: (
|
|
57
|
-
l("click",
|
|
54
|
+
cls: t,
|
|
55
|
+
innerStyle: a,
|
|
56
|
+
onClick: (n) => {
|
|
57
|
+
l("click", n);
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
}), ye = ["stroke-width", "stroke-linecap", "stroke-linejoin"], ke = /* @__PURE__ */ M("path", {
|
|
62
62
|
d: "M39.6 17.443 24.043 33 8.487 17.443"
|
|
63
63
|
}, null, -1), be = [ke];
|
|
64
|
-
function ve(e, l,
|
|
64
|
+
function ve(e, l, r, t, a, c) {
|
|
65
65
|
return j(), L("svg", {
|
|
66
66
|
viewBox: "0 0 48 48",
|
|
67
67
|
fill: "none",
|
|
@@ -72,15 +72,15 @@ function ve(e, l, t, r, n, d) {
|
|
|
72
72
|
"stroke-width": e.strokeWidth,
|
|
73
73
|
"stroke-linecap": e.strokeLinecap,
|
|
74
74
|
"stroke-linejoin": e.strokeLinejoin,
|
|
75
|
-
onClick: l[0] || (l[0] = (...
|
|
75
|
+
onClick: l[0] || (l[0] = (...n) => e.onClick && e.onClick(...n))
|
|
76
76
|
}, be, 14, ye);
|
|
77
77
|
}
|
|
78
78
|
var g = /* @__PURE__ */ E(he, [["render", ve]]);
|
|
79
79
|
const Se = Object.assign(g, {
|
|
80
80
|
install: (e, l) => {
|
|
81
|
-
var
|
|
82
|
-
const
|
|
83
|
-
e.component(
|
|
81
|
+
var r;
|
|
82
|
+
const t = (r = l == null ? void 0 : l.iconPrefix) != null ? r : "";
|
|
83
|
+
e.component(t + g.name, g);
|
|
84
84
|
}
|
|
85
85
|
}), $e = F({
|
|
86
86
|
name: "IconUp",
|
|
@@ -111,24 +111,24 @@ const Se = Object.assign(g, {
|
|
|
111
111
|
setup(e, {
|
|
112
112
|
emit: l
|
|
113
113
|
}) {
|
|
114
|
-
const
|
|
115
|
-
[`${
|
|
116
|
-
}]),
|
|
117
|
-
const
|
|
118
|
-
return e.size && (
|
|
114
|
+
const r = q("icon"), t = k(() => [r, `${r}-up`, {
|
|
115
|
+
[`${r}-spin`]: e.spin
|
|
116
|
+
}]), a = k(() => {
|
|
117
|
+
const n = {};
|
|
118
|
+
return e.size && (n.fontSize = B(e.size) ? `${e.size}px` : e.size), e.rotate && (n.transform = `rotate(${e.rotate}deg)`), n;
|
|
119
119
|
});
|
|
120
120
|
return {
|
|
121
|
-
cls:
|
|
122
|
-
innerStyle:
|
|
123
|
-
onClick: (
|
|
124
|
-
l("click",
|
|
121
|
+
cls: t,
|
|
122
|
+
innerStyle: a,
|
|
123
|
+
onClick: (n) => {
|
|
124
|
+
l("click", n);
|
|
125
125
|
}
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
128
|
}), ge = ["stroke-width", "stroke-linecap", "stroke-linejoin"], Ce = /* @__PURE__ */ M("path", {
|
|
129
129
|
d: "M39.6 30.557 24.043 15 8.487 30.557"
|
|
130
|
-
}, null, -1),
|
|
131
|
-
function
|
|
130
|
+
}, null, -1), we = [Ce];
|
|
131
|
+
function xe(e, l, r, t, a, c) {
|
|
132
132
|
return j(), L("svg", {
|
|
133
133
|
viewBox: "0 0 48 48",
|
|
134
134
|
fill: "none",
|
|
@@ -139,72 +139,72 @@ function we(e, l, t, r, n, d) {
|
|
|
139
139
|
"stroke-width": e.strokeWidth,
|
|
140
140
|
"stroke-linecap": e.strokeLinecap,
|
|
141
141
|
"stroke-linejoin": e.strokeLinejoin,
|
|
142
|
-
onClick: l[0] || (l[0] = (...
|
|
143
|
-
},
|
|
142
|
+
onClick: l[0] || (l[0] = (...n) => e.onClick && e.onClick(...n))
|
|
143
|
+
}, we, 14, ge);
|
|
144
144
|
}
|
|
145
|
-
var C = /* @__PURE__ */ E($e, [["render",
|
|
145
|
+
var C = /* @__PURE__ */ E($e, [["render", xe]]);
|
|
146
146
|
const Fe = Object.assign(C, {
|
|
147
147
|
install: (e, l) => {
|
|
148
|
-
var
|
|
149
|
-
const
|
|
150
|
-
e.component(
|
|
148
|
+
var r;
|
|
149
|
+
const t = (r = l == null ? void 0 : l.iconPrefix) != null ? r : "";
|
|
150
|
+
e.component(t + C.name, C);
|
|
151
151
|
}
|
|
152
152
|
}), D = {
|
|
153
153
|
id: Symbol("ID"),
|
|
154
154
|
source: Symbol("Source")
|
|
155
155
|
};
|
|
156
156
|
function Ve(e, l) {
|
|
157
|
-
const
|
|
158
|
-
return e == null || e.forEach((
|
|
159
|
-
let
|
|
160
|
-
|
|
161
|
-
}), [
|
|
162
|
-
|
|
157
|
+
const r = h({});
|
|
158
|
+
return e == null || e.forEach((a) => {
|
|
159
|
+
let c = null;
|
|
160
|
+
a.default && (c = (typeof a.default == "function" ? a.default() : a.default) || null), l && l[a.key] !== void 0 && (c = l[a.key]), r.value[a.key] = c;
|
|
161
|
+
}), [r, (a) => {
|
|
162
|
+
r.value = a;
|
|
163
163
|
}];
|
|
164
164
|
}
|
|
165
165
|
function Ie(e) {
|
|
166
|
-
function l(
|
|
167
|
-
return e != null && e.disabledDate ? e.disabledDate(
|
|
166
|
+
function l(r, t) {
|
|
167
|
+
return e != null && e.disabledDate ? e.disabledDate(r, t) : !1;
|
|
168
168
|
}
|
|
169
|
-
return (
|
|
169
|
+
return (r, t) => {
|
|
170
170
|
switch (e == null ? void 0 : e.type) {
|
|
171
171
|
case "week":
|
|
172
|
-
return
|
|
173
|
-
modelValue: t
|
|
174
|
-
"onUpdate:modelValue": (
|
|
172
|
+
return d(Z, {
|
|
173
|
+
modelValue: r[t.key],
|
|
174
|
+
"onUpdate:modelValue": (a) => r[t.key] = a,
|
|
175
175
|
"disabled-date": l,
|
|
176
176
|
format: e == null ? void 0 : e.labelFormat,
|
|
177
177
|
"value-format": e == null ? void 0 : e.valueFormat
|
|
178
178
|
}, null);
|
|
179
179
|
case "month":
|
|
180
|
-
return
|
|
181
|
-
modelValue: t
|
|
182
|
-
"onUpdate:modelValue": (
|
|
180
|
+
return d(J, {
|
|
181
|
+
modelValue: r[t.key],
|
|
182
|
+
"onUpdate:modelValue": (a) => r[t.key] = a,
|
|
183
183
|
"disabled-date": l,
|
|
184
184
|
format: e == null ? void 0 : e.labelFormat,
|
|
185
185
|
"value-format": e == null ? void 0 : e.valueFormat
|
|
186
186
|
}, null);
|
|
187
187
|
case "quarter":
|
|
188
|
-
return
|
|
189
|
-
modelValue: t
|
|
190
|
-
"onUpdate:modelValue": (
|
|
188
|
+
return d(H, {
|
|
189
|
+
modelValue: r[t.key],
|
|
190
|
+
"onUpdate:modelValue": (a) => r[t.key] = a,
|
|
191
191
|
"disabled-date": l,
|
|
192
192
|
format: e == null ? void 0 : e.labelFormat,
|
|
193
193
|
"value-format": e == null ? void 0 : e.valueFormat
|
|
194
194
|
}, null);
|
|
195
195
|
case "year":
|
|
196
|
-
return
|
|
197
|
-
modelValue: t
|
|
198
|
-
"onUpdate:modelValue": (
|
|
196
|
+
return d(X, {
|
|
197
|
+
modelValue: r[t.key],
|
|
198
|
+
"onUpdate:modelValue": (a) => r[t.key] = a,
|
|
199
199
|
"disabled-date": l,
|
|
200
200
|
format: e == null ? void 0 : e.labelFormat,
|
|
201
201
|
"value-format": e == null ? void 0 : e.valueFormat
|
|
202
202
|
}, null);
|
|
203
203
|
case "date":
|
|
204
204
|
default:
|
|
205
|
-
return
|
|
206
|
-
modelValue: t
|
|
207
|
-
"onUpdate:modelValue": (
|
|
205
|
+
return d(Q, {
|
|
206
|
+
modelValue: r[t.key],
|
|
207
|
+
"onUpdate:modelValue": (a) => r[t.key] = a,
|
|
208
208
|
"disabled-date": l,
|
|
209
209
|
format: e == null ? void 0 : e.labelFormat,
|
|
210
210
|
"value-format": e == null ? void 0 : e.valueFormat
|
|
@@ -213,12 +213,12 @@ function Ie(e) {
|
|
|
213
213
|
};
|
|
214
214
|
}
|
|
215
215
|
function _e(e) {
|
|
216
|
-
return (l,
|
|
216
|
+
return (l, r) => {
|
|
217
217
|
switch (e == null ? void 0 : e.type) {
|
|
218
218
|
case "number":
|
|
219
|
-
return
|
|
220
|
-
modelValue: l[
|
|
221
|
-
"onUpdate:modelValue": (
|
|
219
|
+
return d(ee, {
|
|
220
|
+
modelValue: l[r.key],
|
|
221
|
+
"onUpdate:modelValue": (t) => l[r.key] = t,
|
|
222
222
|
hideButton: !0,
|
|
223
223
|
"read-only": e == null ? void 0 : e.readonly,
|
|
224
224
|
placeholder: e == null ? void 0 : e.placeholder,
|
|
@@ -226,9 +226,9 @@ function _e(e) {
|
|
|
226
226
|
}, null);
|
|
227
227
|
case "string":
|
|
228
228
|
default:
|
|
229
|
-
return
|
|
230
|
-
modelValue: l[
|
|
231
|
-
"onUpdate:modelValue": (
|
|
229
|
+
return d(p, {
|
|
230
|
+
modelValue: l[r.key],
|
|
231
|
+
"onUpdate:modelValue": (t) => l[r.key] = t,
|
|
232
232
|
placeholder: e == null ? void 0 : e.placeholder,
|
|
233
233
|
readonly: e == null ? void 0 : e.readonly,
|
|
234
234
|
allowClear: e == null ? void 0 : e.clearable
|
|
@@ -242,54 +242,55 @@ function S(e) {
|
|
|
242
242
|
function De(e) {
|
|
243
243
|
return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !U(e);
|
|
244
244
|
}
|
|
245
|
-
const
|
|
245
|
+
const w = /* @__PURE__ */ new WeakMap();
|
|
246
246
|
function Ne(e) {
|
|
247
|
-
let l,
|
|
248
|
-
const
|
|
249
|
-
|
|
247
|
+
let l, r = !1;
|
|
248
|
+
const t = h(/* @__PURE__ */ new Map()), a = (n) => {
|
|
249
|
+
t.value = n, e.cache !== !1 && w.set(e.options, n);
|
|
250
250
|
};
|
|
251
251
|
switch (!0) {
|
|
252
252
|
case e.options instanceof Function: {
|
|
253
|
-
if (
|
|
254
|
-
|
|
253
|
+
if (w.has(e.options)) {
|
|
254
|
+
t.value = w.get(e.options);
|
|
255
255
|
break;
|
|
256
256
|
}
|
|
257
|
-
const
|
|
258
|
-
S(
|
|
257
|
+
const n = e.options();
|
|
258
|
+
S(n) ? n.then(a) : a(n);
|
|
259
259
|
break;
|
|
260
260
|
}
|
|
261
261
|
case S(e.options): {
|
|
262
|
-
e.options.then((
|
|
262
|
+
e.options.then((n) => t.value = n);
|
|
263
263
|
break;
|
|
264
264
|
}
|
|
265
265
|
default:
|
|
266
|
-
|
|
266
|
+
t.value = e.options;
|
|
267
267
|
}
|
|
268
|
-
function
|
|
268
|
+
function c() {
|
|
269
269
|
if (!e.autoSumbit || !l)
|
|
270
270
|
return;
|
|
271
|
-
let
|
|
272
|
-
for (;
|
|
273
|
-
|
|
274
|
-
|
|
271
|
+
let n = l;
|
|
272
|
+
for (; n && n.$el.tagName !== "FORM"; )
|
|
273
|
+
n = n.$parent;
|
|
274
|
+
n && n.$el && n.$el.dispatchEvent(new Event("submit"));
|
|
275
275
|
}
|
|
276
|
-
return (
|
|
277
|
-
let
|
|
278
|
-
return e.default && !
|
|
276
|
+
return (n, u) => {
|
|
277
|
+
let s;
|
|
278
|
+
return e.default && !r && (n[u.key] = e.default, r = !0), d(te, {
|
|
279
279
|
ref: (f) => l = f,
|
|
280
280
|
multiple: e.multiple,
|
|
281
|
-
modelValue:
|
|
282
|
-
"onUpdate:modelValue": (f) =>
|
|
281
|
+
modelValue: n[u.key],
|
|
282
|
+
"onUpdate:modelValue": (f) => n[u.key] = f,
|
|
283
283
|
placeholder: e.placeholder,
|
|
284
284
|
allowClear: e.clearable,
|
|
285
|
+
allowSearch: e.searchable,
|
|
285
286
|
maxTagCount: e.maxTagCount ?? 2,
|
|
286
|
-
onChange:
|
|
287
|
-
}, De(
|
|
287
|
+
onChange: c
|
|
288
|
+
}, De(s = Array.from(t.value.entries()).map(([f, o]) => d(le, {
|
|
288
289
|
key: f,
|
|
289
290
|
value: f,
|
|
290
291
|
label: o
|
|
291
|
-
}, null))) ?
|
|
292
|
-
default: () => [
|
|
292
|
+
}, null))) ? s : {
|
|
293
|
+
default: () => [s]
|
|
293
294
|
});
|
|
294
295
|
};
|
|
295
296
|
}
|
|
@@ -297,9 +298,9 @@ function Oe(e) {
|
|
|
297
298
|
function l() {
|
|
298
299
|
e != null && e.autoSumbit;
|
|
299
300
|
}
|
|
300
|
-
return (
|
|
301
|
-
modelValue: t
|
|
302
|
-
"onUpdate:modelValue": (
|
|
301
|
+
return (r, t) => (e != null && e.default && (r[t.key] = e.default), d(re, {
|
|
302
|
+
modelValue: r[t.key],
|
|
303
|
+
"onUpdate:modelValue": (a) => r[t.key] = a,
|
|
303
304
|
checkedText: (e == null ? void 0 : e.openLabel) ?? "是",
|
|
304
305
|
uncheckedText: (e == null ? void 0 : e.closeLabel) ?? "否",
|
|
305
306
|
checkedValue: (e == null ? void 0 : e.openValue) ?? !0,
|
|
@@ -308,69 +309,69 @@ function Oe(e) {
|
|
|
308
309
|
}, null));
|
|
309
310
|
}
|
|
310
311
|
function je(e) {
|
|
311
|
-
return (l,
|
|
312
|
-
let
|
|
313
|
-
function
|
|
314
|
-
|
|
312
|
+
return (l, r) => {
|
|
313
|
+
let t = [];
|
|
314
|
+
function a(u) {
|
|
315
|
+
t = u;
|
|
315
316
|
}
|
|
316
|
-
function
|
|
317
|
+
function c(u) {
|
|
317
318
|
if (u && u.length === 2) {
|
|
318
|
-
const [
|
|
319
|
-
l[
|
|
319
|
+
const [s, f] = u.sort(), o = _(s).startOf("days"), y = _(f).endOf("days");
|
|
320
|
+
l[r.key] = [o.format((e == null ? void 0 : e.valueFormat) || "YYYY-MM-DD"), y.format((e == null ? void 0 : e.valueFormat) || "YYYY-MM-DD")];
|
|
320
321
|
}
|
|
321
322
|
}
|
|
322
|
-
function
|
|
323
|
-
return e != null && e.disabledDate ? e.disabledDate(
|
|
323
|
+
function n(u) {
|
|
324
|
+
return e != null && e.disabledDate ? e.disabledDate(t, u) : !1;
|
|
324
325
|
}
|
|
325
|
-
return
|
|
326
|
+
return d("div", null, [d(ae, {
|
|
326
327
|
style: {
|
|
327
328
|
width: "300px"
|
|
328
329
|
},
|
|
329
|
-
modelValue: l[
|
|
330
|
-
"onUpdate:modelValue": (u) => l[
|
|
331
|
-
onSelect:
|
|
332
|
-
onChange:
|
|
330
|
+
modelValue: l[r.key],
|
|
331
|
+
"onUpdate:modelValue": (u) => l[r.key] = u,
|
|
332
|
+
onSelect: a,
|
|
333
|
+
onChange: c,
|
|
333
334
|
mode: e == null ? void 0 : e.type,
|
|
334
335
|
allowClear: e == null ? void 0 : e.clearable,
|
|
335
|
-
"disabled-date":
|
|
336
|
+
"disabled-date": n,
|
|
336
337
|
format: e == null ? void 0 : e.labelFormat,
|
|
337
338
|
"value-format": e == null ? void 0 : e.valueFormat
|
|
338
339
|
}, null)]);
|
|
339
340
|
};
|
|
340
341
|
}
|
|
341
342
|
function Le(e) {
|
|
342
|
-
return (l,
|
|
343
|
-
modelValue: l[
|
|
344
|
-
"onUpdate:modelValue": (
|
|
343
|
+
return (l, r) => d(ne, {
|
|
344
|
+
modelValue: l[r.key],
|
|
345
|
+
"onUpdate:modelValue": (t) => l[r.key] = t,
|
|
345
346
|
placeholder: e == null ? void 0 : e.placeholder,
|
|
346
347
|
autoSize: e == null ? void 0 : e.autosize,
|
|
347
348
|
maxLength: e == null ? void 0 : e.maxLength
|
|
348
349
|
}, null);
|
|
349
350
|
}
|
|
350
|
-
const
|
|
351
|
+
const x = /* @__PURE__ */ new WeakMap();
|
|
351
352
|
function Pe(e) {
|
|
352
|
-
let l,
|
|
353
|
-
const
|
|
354
|
-
|
|
353
|
+
let l, r = !1;
|
|
354
|
+
const t = h([]), a = (u) => {
|
|
355
|
+
t.value = u, e.cache !== !1 && x.set(e.options, u);
|
|
355
356
|
};
|
|
356
357
|
switch (!0) {
|
|
357
358
|
case e.options instanceof Function: {
|
|
358
|
-
if (
|
|
359
|
-
|
|
359
|
+
if (x.has(e.options)) {
|
|
360
|
+
t.value = x.get(e.options);
|
|
360
361
|
break;
|
|
361
362
|
}
|
|
362
363
|
const u = e.options();
|
|
363
|
-
S(u) ? u.then(
|
|
364
|
+
S(u) ? u.then(a) : a(u);
|
|
364
365
|
break;
|
|
365
366
|
}
|
|
366
367
|
case S(e.options): {
|
|
367
|
-
e.options.then((u) =>
|
|
368
|
+
e.options.then((u) => t.value = u);
|
|
368
369
|
break;
|
|
369
370
|
}
|
|
370
371
|
default:
|
|
371
|
-
|
|
372
|
+
t.value = e.options;
|
|
372
373
|
}
|
|
373
|
-
function
|
|
374
|
+
function c() {
|
|
374
375
|
if (!e.autoSumbit || !l)
|
|
375
376
|
return;
|
|
376
377
|
let u = l;
|
|
@@ -378,23 +379,23 @@ function Pe(e) {
|
|
|
378
379
|
u = u.$parent;
|
|
379
380
|
u && u.$el && u.$el.dispatchEvent(new Event("submit"));
|
|
380
381
|
}
|
|
381
|
-
function
|
|
382
|
+
function n(u, s) {
|
|
382
383
|
var y;
|
|
383
|
-
const f = ((y = e.fieldNames) == null ? void 0 : y.title) || "title", o =
|
|
384
|
+
const f = ((y = e.fieldNames) == null ? void 0 : y.title) || "title", o = s[f];
|
|
384
385
|
return o ? o.toLowerCase().includes(u.toLowerCase()) : !1;
|
|
385
386
|
}
|
|
386
|
-
return (u,
|
|
387
|
+
return (u, s) => (e.default && !r && (u[s.key] = e.default, r = !0), d(ue, {
|
|
387
388
|
ref: (f) => l = f,
|
|
388
389
|
multiple: e.multiple,
|
|
389
|
-
modelValue: u[
|
|
390
|
-
"onUpdate:modelValue": (f) => u[
|
|
390
|
+
modelValue: u[s.key],
|
|
391
|
+
"onUpdate:modelValue": (f) => u[s.key] = f,
|
|
391
392
|
placeholder: e.placeholder,
|
|
392
393
|
allowClear: e.clearable,
|
|
393
394
|
allowSearch: e.searchable,
|
|
394
395
|
maxTagCount: e.maxTagCount ?? 2,
|
|
395
|
-
onChange:
|
|
396
|
-
filterTreeNode:
|
|
397
|
-
data:
|
|
396
|
+
onChange: c,
|
|
397
|
+
filterTreeNode: n,
|
|
398
|
+
data: t.value,
|
|
398
399
|
fieldNames: e.fieldNames
|
|
399
400
|
}, null));
|
|
400
401
|
}
|
|
@@ -414,12 +415,12 @@ function Me() {
|
|
|
414
415
|
};
|
|
415
416
|
}
|
|
416
417
|
function Ue(e, l) {
|
|
417
|
-
l.render || (l.render = (
|
|
418
|
-
const
|
|
418
|
+
l.render || (l.render = (t) => t.input());
|
|
419
|
+
const r = l.render({
|
|
419
420
|
...Me()
|
|
420
421
|
});
|
|
421
422
|
return {
|
|
422
|
-
default: () =>
|
|
423
|
+
default: () => r(e, l)
|
|
423
424
|
};
|
|
424
425
|
}
|
|
425
426
|
function Re(e, l) {
|
|
@@ -483,42 +484,42 @@ const Te = /* @__PURE__ */ F({
|
|
|
483
484
|
emits: ["submit", "cancel", "update:model-value"],
|
|
484
485
|
expose: ["formSource", "updateFormField", "updateFormSource", "reset"],
|
|
485
486
|
setup(e) {
|
|
486
|
-
const l = Math.random().toString(32).slice(2).toUpperCase(),
|
|
487
|
-
V(D.id, l), V(D.source,
|
|
488
|
-
const
|
|
489
|
-
if (!
|
|
487
|
+
const l = Math.random().toString(32).slice(2).toUpperCase(), r = h(), [t, a] = Ve(e.form, e.modelValue || e.value), c = h(e.columns || 0), n = h(!0), u = () => n.value = !n.value;
|
|
488
|
+
V(D.id, l), V(D.source, t);
|
|
489
|
+
const s = k(() => {
|
|
490
|
+
if (!c.value)
|
|
490
491
|
return 1;
|
|
491
|
-
const
|
|
492
|
-
return
|
|
493
|
-
}), f = k(() => e.form.reduce((
|
|
492
|
+
const i = e.form.reduce((m, $) => m + (($ == null ? void 0 : $.span) || 1), 0);
|
|
493
|
+
return c.value - i % c.value;
|
|
494
|
+
}), f = k(() => e.form.reduce((i, m) => (m.rule && (i[m.key] = m.rule), i), {}));
|
|
494
495
|
function o() {
|
|
495
496
|
var m;
|
|
496
|
-
const
|
|
497
|
-
|
|
497
|
+
const i = (m = r.value) == null ? void 0 : m.$el;
|
|
498
|
+
i && (c.value = Math.floor(i.offsetWidth / e.minWidth));
|
|
498
499
|
}
|
|
499
500
|
R(() => {
|
|
500
501
|
o();
|
|
501
502
|
});
|
|
502
|
-
function y(
|
|
503
|
-
|
|
504
|
-
...
|
|
503
|
+
function y(i, m) {
|
|
504
|
+
t.value[i] = m, a({
|
|
505
|
+
...t
|
|
505
506
|
});
|
|
506
507
|
}
|
|
507
508
|
function W() {
|
|
508
|
-
var
|
|
509
|
-
(
|
|
509
|
+
var i;
|
|
510
|
+
(i = r.value) == null || i.resetFields();
|
|
510
511
|
}
|
|
511
512
|
return window.addEventListener("resize", o), {
|
|
512
513
|
formId: l,
|
|
513
|
-
formSource:
|
|
514
|
-
formInstance:
|
|
515
|
-
formColumns:
|
|
514
|
+
formSource: t,
|
|
515
|
+
formInstance: r,
|
|
516
|
+
formColumns: c,
|
|
516
517
|
formRules: f,
|
|
517
|
-
formCollspased:
|
|
518
|
-
formActiosSpan:
|
|
518
|
+
formCollspased: n,
|
|
519
|
+
formActiosSpan: s,
|
|
519
520
|
toggleFormCollapsed: u,
|
|
520
521
|
updateFormField: y,
|
|
521
|
-
updateFormSource:
|
|
522
|
+
updateFormSource: a,
|
|
522
523
|
reset: W
|
|
523
524
|
};
|
|
524
525
|
},
|
|
@@ -526,54 +527,63 @@ const Te = /* @__PURE__ */ F({
|
|
|
526
527
|
const e = () => {
|
|
527
528
|
this.$emit("submit", this.formSource), this.$emit("update:model-value", this.formSource);
|
|
528
529
|
}, l = () => {
|
|
529
|
-
const t = [],
|
|
530
|
+
const t = [], a = this.footer ? {
|
|
530
531
|
span: this.formColumns
|
|
531
532
|
} : {
|
|
532
533
|
span: this.formActiosSpan
|
|
533
534
|
};
|
|
534
|
-
if (this.searchable && (t.push(
|
|
535
|
+
if (this.searchable && (t.push(d(b, {
|
|
535
536
|
type: "primary",
|
|
536
537
|
htmlType: "submit"
|
|
537
538
|
}, {
|
|
538
539
|
default: () => [v("搜索")]
|
|
539
|
-
})), t.push(
|
|
540
|
+
})), t.push(d(b, {
|
|
540
541
|
type: "secondary",
|
|
541
542
|
onClick: () => {
|
|
542
|
-
var
|
|
543
|
-
return (
|
|
543
|
+
var c;
|
|
544
|
+
return (c = this.formInstance) == null ? void 0 : c.resetFields();
|
|
544
545
|
}
|
|
545
546
|
}, {
|
|
546
547
|
default: () => [v("重置")]
|
|
547
|
-
}))), this.submitable && (t.push(
|
|
548
|
+
}))), this.submitable && (t.push(d(b, {
|
|
548
549
|
type: "primary",
|
|
549
550
|
htmlType: "submit"
|
|
550
551
|
}, {
|
|
551
552
|
default: () => [v("提交")]
|
|
552
|
-
})), t.push(
|
|
553
|
+
})), t.push(d(b, {
|
|
553
554
|
type: "secondary",
|
|
554
555
|
onClick: () => this.$emit("cancel")
|
|
555
556
|
}, {
|
|
556
557
|
default: () => [v("取消")]
|
|
557
|
-
}))), this.form.some((
|
|
558
|
+
}))), this.form.some((c) => !!c.collapsed) && t.push(d(b, {
|
|
558
559
|
onClick: this.toggleFormCollapsed
|
|
559
560
|
}, {
|
|
560
561
|
default: () => this.formCollspased ? "展开" : "收起",
|
|
561
|
-
icon: () => this.formCollspased ?
|
|
562
|
+
icon: () => this.formCollspased ? d(Se, null, null) : d(Fe, null, null)
|
|
562
563
|
})), this.$slots.actions && t.push(...this.$slots.actions()), t.length)
|
|
563
|
-
return
|
|
564
|
-
default: () => [
|
|
564
|
+
return d(I, a, {
|
|
565
|
+
default: () => [d(T, {
|
|
565
566
|
hideLabel: !0,
|
|
566
567
|
contentClass: this.footer ? "form-footer" : ""
|
|
567
568
|
}, {
|
|
568
|
-
default: () => [
|
|
569
|
+
default: () => [d(fe, null, N(t) ? t : {
|
|
569
570
|
default: () => [t]
|
|
570
571
|
})]
|
|
571
572
|
})]
|
|
572
573
|
});
|
|
573
|
-
}
|
|
574
|
-
|
|
574
|
+
}, r = this.form.filter((t) => this.formCollspased ? !t.collapsed : !0).filter((t) => {
|
|
575
|
+
switch (!0) {
|
|
576
|
+
case typeof t.visiable == "boolean":
|
|
577
|
+
return t.visiable;
|
|
578
|
+
case typeof t.visiable == "function":
|
|
579
|
+
return t.visiable(this.formSource);
|
|
580
|
+
default:
|
|
581
|
+
return !0;
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
return d("div", {
|
|
575
585
|
class: "form-render"
|
|
576
|
-
}, [
|
|
586
|
+
}, [d(ce, G({
|
|
577
587
|
layout: this.$props.layout,
|
|
578
588
|
rules: this.formRules,
|
|
579
589
|
onSubmitSuccess: e
|
|
@@ -584,17 +594,17 @@ const Te = /* @__PURE__ */ F({
|
|
|
584
594
|
ref: (t) => this.formInstance = t,
|
|
585
595
|
model: this.formSource
|
|
586
596
|
}), {
|
|
587
|
-
default: () => [
|
|
597
|
+
default: () => [d(de, {
|
|
588
598
|
cols: this.formColumns,
|
|
589
599
|
"col-gap": 10,
|
|
590
600
|
"rol-gap": 10
|
|
591
601
|
}, {
|
|
592
|
-
default: () => [
|
|
593
|
-
let
|
|
594
|
-
return
|
|
602
|
+
default: () => [r.map((t) => {
|
|
603
|
+
let a;
|
|
604
|
+
return d(I, {
|
|
595
605
|
span: t.span
|
|
596
|
-
}, N(
|
|
597
|
-
default: () => [
|
|
606
|
+
}, N(a = Re(this.formSource, t)) ? a : {
|
|
607
|
+
default: () => [a]
|
|
598
608
|
});
|
|
599
609
|
}), l()]
|
|
600
610
|
})]
|
|
@@ -605,13 +615,13 @@ function We(e) {
|
|
|
605
615
|
return e;
|
|
606
616
|
}
|
|
607
617
|
function Ae(e) {
|
|
608
|
-
const l = O(),
|
|
609
|
-
function
|
|
610
|
-
var
|
|
611
|
-
const
|
|
612
|
-
|
|
618
|
+
const l = O(), r = h();
|
|
619
|
+
function t() {
|
|
620
|
+
var c, n;
|
|
621
|
+
const a = (n = (c = l == null ? void 0 : l.proxy) == null ? void 0 : c.$refs) == null ? void 0 : n[e];
|
|
622
|
+
a && (r.value = a);
|
|
613
623
|
}
|
|
614
|
-
return R(
|
|
624
|
+
return R(t), K(t), r;
|
|
615
625
|
}
|
|
616
626
|
const Ye = {
|
|
617
627
|
install(e, l) {
|
|
@@ -8,7 +8,7 @@ export interface FormItemOptions<T = Record<string, any>> {
|
|
|
8
8
|
title: string;
|
|
9
9
|
default?: any | (() => any) | (() => Promise<any>);
|
|
10
10
|
collapsed?: boolean;
|
|
11
|
-
visiable?: (record: T) => boolean;
|
|
11
|
+
visiable?: boolean | ((record: T) => boolean);
|
|
12
12
|
span?: number;
|
|
13
13
|
rule?: FieldRule | FieldRule[];
|
|
14
14
|
render?: FormItemRender<T>;
|