@gopowerteam/form-render 0.0.11 → 0.0.13
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 +2 -1
- package/dist/cjs/form-render/index.d.ts +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/utils/is-promise.d.ts +1 -0
- package/dist/es/form-items/select/index.d.ts +2 -1
- package/dist/es/form-render/index.d.ts +1 -1
- package/dist/es/index.mjs +257 -229
- package/dist/es/utils/is-promise.d.ts +1 -0
- package/package.json +1 -1
|
@@ -4,9 +4,10 @@ export type SelectOptions = Map<string | number, string>;
|
|
|
4
4
|
export interface RenderSelectItemOptions {
|
|
5
5
|
placeholder?: string;
|
|
6
6
|
clearable?: boolean;
|
|
7
|
-
options: SelectOptions | Promise<SelectOptions> | (() => Promise<SelectOptions>);
|
|
7
|
+
options: SelectOptions | (() => SelectOptions) | Promise<SelectOptions> | (() => Promise<SelectOptions>);
|
|
8
8
|
multiple?: boolean;
|
|
9
9
|
maxTagCount?: number;
|
|
10
10
|
default?: string | number | boolean;
|
|
11
11
|
autoSumbit?: boolean;
|
|
12
|
+
cache?: boolean;
|
|
12
13
|
}
|
|
@@ -359,8 +359,8 @@ export declare const FormRender: import("vue").DefineComponent<{
|
|
|
359
359
|
onCancel?: ((...args: any[]) => any) | undefined;
|
|
360
360
|
"onUpdate:model-value"?: ((...args: any[]) => any) | undefined;
|
|
361
361
|
}, {
|
|
362
|
-
footer: boolean;
|
|
363
362
|
name: string;
|
|
363
|
+
footer: boolean;
|
|
364
364
|
layout: "horizontal" | "vertical";
|
|
365
365
|
minWidth: number;
|
|
366
366
|
submitable: boolean;
|
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"),d=require("@arco-design/web-vue"),V=require("dayjs"),w=require("./resolver.cjs");const I=Symbol("ArcoConfigProvider"),_="arco",j="$arco",C=e=>{var t,r,a;const u=l.getCurrentInstance(),c=l.inject(I,void 0),n=(a=(r=c==null?void 0:c.prefixCls)!=null?r:(t=u==null?void 0:u.appContext.config.globalProperties[j])==null?void 0:t.classPrefix)!=null?a:_;return e?`${n}-${e}`:n},D=Object.prototype.toString;function $(e){return D.call(e)==="[object Number]"&&e===e}var F=(e,t)=>{for(const[r,a]of t)e[r]=a;return e};const z=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:t}){const r=C("icon"),a=l.computed(()=>[r,`${r}-down`,{[`${r}-spin`]:e.spin}]),u=l.computed(()=>{const n={};return e.size&&(n.fontSize=$(e.size)?`${e.size}px`:e.size),e.rotate&&(n.transform=`rotate(${e.rotate}deg)`),n});return{cls:a,innerStyle:u,onClick:n=>{t("click",n)}}}}),P=["stroke-width","stroke-linecap","stroke-linejoin"],B=l.createElementVNode("path",{d:"M39.6 17.443 24.043 33 8.487 17.443"},null,-1),O=[B];function q(e,t,r,a,u,c){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:t[0]||(t[0]=(...n)=>e.onClick&&e.onClick(...n))},O,14,P)}var b=F(z,[["render",q]]);const L=Object.assign(b,{install:(e,t)=>{var r;const a=(r=t==null?void 0:t.iconPrefix)!=null?r:"";e.component(a+b.name,b)}}),M=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:t}){const r=C("icon"),a=l.computed(()=>[r,`${r}-up`,{[`${r}-spin`]:e.spin}]),u=l.computed(()=>{const n={};return e.size&&(n.fontSize=$(e.size)?`${e.size}px`:e.size),e.rotate&&(n.transform=`rotate(${e.rotate}deg)`),n});return{cls:a,innerStyle:u,onClick:n=>{t("click",n)}}}}),R=["stroke-width","stroke-linecap","stroke-linejoin"],U=l.createElementVNode("path",{d:"M39.6 30.557 24.043 15 8.487 30.557"},null,-1),T=[U];function E(e,t,r,a,u,c){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:t[0]||(t[0]=(...n)=>e.onClick&&e.onClick(...n))},T,14,R)}var v=F(M,[["render",E]]);const A=Object.assign(v,{install:(e,t)=>{var r;const a=(r=t==null?void 0:t.iconPrefix)!=null?r:"";e.component(a+v.name,v)}}),S={id:Symbol("ID"),source:Symbol("Source")};function Y(e,t){const r=l.ref({});return e==null||e.forEach(u=>{let c=null;u.default&&(c=(typeof u.default=="function"?u.default():u.default)||null),t&&t[u.key]&&(c=t[u.key]),r.value[u.key]=c}),[r,u=>{r.value=u}]}function W(e){function t(r,a){return e!=null&&e.disabledDate?e.disabledDate(r,a):!1}return(r,a)=>{switch(e==null?void 0:e.type){case"week":return l.createVNode(d.WeekPicker,{modelValue:r[a.key],"onUpdate:modelValue":u=>r[a.key]=u,"disabled-date":t,format:e==null?void 0:e.labelFormat,"value-format":e==null?void 0:e.valueFormat},null);case"month":return l.createVNode(d.MonthPicker,{modelValue:r[a.key],"onUpdate:modelValue":u=>r[a.key]=u,"disabled-date":t,format:e==null?void 0:e.labelFormat,"value-format":e==null?void 0:e.valueFormat},null);case"quarter":return l.createVNode(d.QuarterPicker,{modelValue:r[a.key],"onUpdate:modelValue":u=>r[a.key]=u,"disabled-date":t,format:e==null?void 0:e.labelFormat,"value-format":e==null?void 0:e.valueFormat},null);case"year":return l.createVNode(d.YearPicker,{modelValue:r[a.key],"onUpdate:modelValue":u=>r[a.key]=u,"disabled-date":t,format:e==null?void 0:e.labelFormat,"value-format":e==null?void 0:e.valueFormat},null);case"date":default:return l.createVNode(d.DatePicker,{modelValue:r[a.key],"onUpdate:modelValue":u=>r[a.key]=u,"disabled-date":t,format:e==null?void 0:e.labelFormat,"value-format":e==null?void 0:e.valueFormat},null)}}}function G(e){return(t,r)=>{switch(e==null?void 0:e.type){case"number":return l.createVNode(d.InputNumber,{modelValue:t[r.key],"onUpdate:modelValue":a=>t[r.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(d.Input,{modelValue:t[r.key],"onUpdate:modelValue":a=>t[r.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 typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!l.isVNode(e)}function Q(e){let t=!1;const r=l.ref(new Map);e.options instanceof Function?e.options().then(u=>r.value=u):e.options instanceof Promise?e.options.then(u=>r.value=u):r.value=e.options;function a(){e.autoSumbit}return(u,c)=>{let n;return e.default&&!t&&(u[c.key]=e.default,t=!0),l.createVNode(d.Select,{multiple:e.multiple,modelValue:u[c.key],"onUpdate:modelValue":o=>u[c.key]=o,placeholder:e.placeholder,allowClear:e.clearable,maxTagCount:e.maxTagCount??5,onChange:a},K(n=Array.from(r.value.entries()).map(([o,i])=>l.createVNode(d.Option,{key:o,value:o,label:i},null)))?n:{default:()=>[n]})}}function X(e){function t(){e!=null&&e.autoSumbit}return(r,a)=>(e!=null&&e.default&&(r[a.key]=e.default),l.createVNode(d.Switch,{modelValue:r[a.key],"onUpdate:modelValue":u=>r[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:t},null))}function H(e){return(t,r)=>{let a=[];function u(o){a=o}function c(o){if(o&&o.length===2){const[i,h]=o.sort(),s=V(i).startOf("days"),y=V(h).endOf("days");t[r.key]=[s.format((e==null?void 0:e.valueFormat)||"YYYY-MM-DD"),y.format((e==null?void 0:e.valueFormat)||"YYYY-MM-DD")]}}function n(o){return e!=null&&e.disabledDate?e.disabledDate(a,o):!1}return l.createVNode("div",null,[l.createVNode(d.RangePicker,{style:{width:"300px"},modelValue:t[r.key],"onUpdate:modelValue":o=>t[r.key]=o,onSelect:u,onChange:c,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 J(e){return(t,r)=>l.createVNode(d.Textarea,{modelValue:t[r.key],"onUpdate:modelValue":a=>t[r.key]=a,placeholder:e==null?void 0:e.placeholder,autoSize:e==null?void 0:e.autosize,maxLength:e==null?void 0:e.maxLength},null)}function Z(e){return t=>e(t)}function p(){return{input:G,textarea:J,select:Q,date:W,switch:X,dateRange:H,render:Z}}function ee(e,t){t.render||(t.render=a=>a.input());const r=t.render({...p()});return{default:()=>r(e,t)}}function re(e,t){return l.h(d.FormItem,{field:t.key,label:t.title},ee(e,t))}function g(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!l.isVNode(e)}const N=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:350},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 t=Math.random().toString(32).slice(2).toUpperCase(),r=l.ref(),[a,u]=Y(e.form,e.modelValue||e.value),c=l.ref(e.columns||0),n=l.ref(!0),o=()=>n.value=!n.value;l.provide(S.id,t),l.provide(S.source,a);const i=l.computed(()=>{if(!c.value)return 1;const f=e.form.reduce((m,k)=>m+((k==null?void 0:k.span)||1),0);return c.value-f%c.value}),h=l.computed(()=>e.form.reduce((f,m)=>(m.rule&&(f[m.key]=m.rule),f),{}));function s(){var f;if(c.value===0){const m=(f=r.value)==null?void 0:f.$el;c.value=Math.floor(m.offsetWidth/e.minWidth)}}l.onMounted(()=>{s()});function y(f,m){a.value[f]=m,u({...a})}function x(){var f;(f=r.value)==null||f.resetFields()}return window.addEventListener("resize",s),{formId:t,formSource:a,formInstance:r,formColumns:c,formRules:h,formCollspased:n,formActiosSpan:i,toggleFormCollapsed:o,updateFormField:y,updateFormSource:u,reset:x}},render(){const e=()=>{this.$emit("submit",this.formSource),this.$emit("update:model-value",this.formSource)},t=()=>{const r=[],a=this.footer?{span:this.formColumns}:{span:this.formActiosSpan};if(this.searchable&&(r.push(l.createVNode(d.Button,{type:"primary",htmlType:"submit"},{default:()=>[l.createTextVNode("搜索")]})),r.push(l.createVNode(d.Button,{type:"secondary",onClick:()=>{var u;return(u=this.formInstance)==null?void 0:u.resetFields()}},{default:()=>[l.createTextVNode("重置")]}))),this.submitable&&(r.push(l.createVNode(d.Button,{type:"primary",htmlType:"submit"},{default:()=>[l.createTextVNode("提交")]})),r.push(l.createVNode(d.Button,{type:"secondary",onClick:()=>this.$emit("cancel")},{default:()=>[l.createTextVNode("取消")]}))),this.form.some(u=>!!u.collapsed)&&r.push(l.createVNode(d.Button,{onClick:this.toggleFormCollapsed},{default:()=>this.formCollspased?"展开":"收起",icon:()=>this.formCollspased?l.createVNode(L,null,null):l.createVNode(A,null,null)})),this.$slots.actions&&r.push(...this.$slots.actions()),r.length)return l.createVNode(d.GridItem,a,{default:()=>[l.createVNode(d.FormItem,{hideLabel:!0,contentClass:this.footer?"form-footer":""},{default:()=>[l.createVNode(d.Space,null,g(r)?r:{default:()=>[r]})]})]})};return l.createVNode(d.Form,l.mergeProps({layout:this.$props.layout,rules:this.formRules,onSubmitSuccess:e},{name:this.name},{"auto-label-width":!0,ref:r=>this.formInstance=r,model:this.formSource}),{default:()=>[l.createVNode(d.Grid,{cols:this.formColumns,"col-gap":10,"rol-gap":10},{default:()=>[this.form.filter(r=>this.formCollspased?!r.collapsed:!0).map(r=>{let a;return l.createVNode(d.GridItem,{span:r.span},g(a=re(this.formSource,r))?a:{default:()=>[a]})}),t()]})]})}});function te(e){return e}function le(e){const t=l.getCurrentInstance(),r=l.ref();function a(){var c,n;const u=(n=(c=t==null?void 0:t.proxy)==null?void 0:c.$refs)==null?void 0:n[e];u&&(r.value=u)}return l.onMounted(a),l.onUpdated(a),r}const ae={install(e,t){e.component("FormRender",N)}};exports.FormRenderResolver=w.FormRenderResolver;exports.FormRender=N;exports.default=ae;exports.defineForm=te;exports.useForm=le;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("vue"),d=require("@arco-design/web-vue"),S=require("dayjs"),_=require("./resolver.cjs");const D=Symbol("ArcoConfigProvider"),j="arco",z="$arco",F=e=>{var r,t,a;const u=l.getCurrentInstance(),c=l.inject(D,void 0),n=(a=(t=c==null?void 0:c.prefixCls)!=null?t:(r=u==null?void 0:u.appContext.config.globalProperties[z])==null?void 0:r.classPrefix)!=null?a:j;return e?`${n}-${e}`:n},O=Object.prototype.toString;function N(e){return O.call(e)==="[object Number]"&&e===e}var x=(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=N(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)}}}}),M=["stroke-width","stroke-linecap","stroke-linejoin"],B=l.createElementVNode("path",{d:"M39.6 17.443 24.043 33 8.487 17.443"},null,-1),R=[B];function q(e,r,t,a,u,c){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,M)}var b=x(P,[["render",q]]);const L=Object.assign(b,{install:(e,r)=>{var t;const a=(t=r==null?void 0:r.iconPrefix)!=null?t:"";e.component(a+b.name,b)}}),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=N(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"],E=l.createElementVNode("path",{d:"M39.6 30.557 24.043 15 8.487 30.557"},null,-1),A=[E];function W(e,r,t,a,u,c){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,T)}var v=x(U,[["render",W]]);const Y=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)}}),g={id:Symbol("ID"),source:Symbol("Source")};function G(e,r){const t=l.ref({});return e==null||e.forEach(u=>{let c=null;u.default&&(c=(typeof u.default=="function"?u.default():u.default)||null),r&&r[u.key]&&(c=r[u.key]),t.value[u.key]=c}),[t,u=>{t.value=u}]}function K(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(d.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(d.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(d.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(d.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(d.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 Q(e){return(r,t)=>{switch(e==null?void 0:e.type){case"number":return l.createVNode(d.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(d.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 $(e){return!!e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function X(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!l.isVNode(e)}const V=new WeakMap;function H(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();$(n)?n.then(u):u(n);break}case $(e.options):{e.options.then(n=>a.value=n);break}default:a.value=e.options}function c(){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,f)=>{let m;return e.default&&!t&&(n[f.key]=e.default,t=!0),l.createVNode(d.Select,{ref:i=>r=i,multiple:e.multiple,modelValue:n[f.key],"onUpdate:modelValue":i=>n[f.key]=i,placeholder:e.placeholder,allowClear:e.clearable,maxTagCount:e.maxTagCount??5,onChange:c},X(m=Array.from(a.value.entries()).map(([i,h])=>l.createVNode(d.Option,{key:i,value:i,label:h},null)))?m:{default:()=>[m]})}}function J(e){function r(){e!=null&&e.autoSumbit}return(t,a)=>(e!=null&&e.default&&(t[a.key]=e.default),l.createVNode(d.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 Z(e){return(r,t)=>{let a=[];function u(f){a=f}function c(f){if(f&&f.length===2){const[m,i]=f.sort(),h=S(m).startOf("days"),y=S(i).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(f){return e!=null&&e.disabledDate?e.disabledDate(a,f):!1}return l.createVNode("div",null,[l.createVNode(d.RangePicker,{style:{width:"300px"},modelValue:r[t.key],"onUpdate:modelValue":f=>r[t.key]=f,onSelect:u,onChange:c,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 p(e){return(r,t)=>l.createVNode(d.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)}function ee(e){return r=>e(r)}function te(){return{input:Q,textarea:p,select:H,date:K,switch:J,dateRange:Z,render:ee}}function re(e,r){r.render||(r.render=a=>a.input());const t=r.render({...te()});return{default:()=>t(e,r)}}function le(e,r){return l.h(d.FormItem,{field:r.key,label:r.title},re(e,r))}function C(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!l.isVNode(e)}const w=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:350},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]=G(e.form,e.modelValue||e.value),c=l.ref(e.columns||0),n=l.ref(!0),f=()=>n.value=!n.value;l.provide(g.id,r),l.provide(g.source,a);const m=l.computed(()=>{if(!c.value)return 1;const o=e.form.reduce((s,k)=>s+((k==null?void 0:k.span)||1),0);return c.value-o%c.value}),i=l.computed(()=>e.form.reduce((o,s)=>(s.rule&&(o[s.key]=s.rule),o),{}));function h(){var o;if(c.value===0){const s=(o=t.value)==null?void 0:o.$el;c.value=Math.floor(s.offsetWidth/e.minWidth)}}l.onMounted(()=>{h()});function y(o,s){a.value[o]=s,u({...a})}function I(){var o;(o=t.value)==null||o.resetFields()}return window.addEventListener("resize",h),{formId:r,formSource:a,formInstance:t,formColumns:c,formRules:i,formCollspased:n,formActiosSpan:m,toggleFormCollapsed:f,updateFormField:y,updateFormSource:u,reset:I}},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(d.Button,{type:"primary",htmlType:"submit"},{default:()=>[l.createTextVNode("搜索")]})),t.push(l.createVNode(d.Button,{type:"secondary",onClick:()=>{var u;return(u=this.formInstance)==null?void 0:u.resetFields()}},{default:()=>[l.createTextVNode("重置")]}))),this.submitable&&(t.push(l.createVNode(d.Button,{type:"primary",htmlType:"submit"},{default:()=>[l.createTextVNode("提交")]})),t.push(l.createVNode(d.Button,{type:"secondary",onClick:()=>this.$emit("cancel")},{default:()=>[l.createTextVNode("取消")]}))),this.form.some(u=>!!u.collapsed)&&t.push(l.createVNode(d.Button,{onClick:this.toggleFormCollapsed},{default:()=>this.formCollspased?"展开":"收起",icon:()=>this.formCollspased?l.createVNode(L,null,null):l.createVNode(Y,null,null)})),this.$slots.actions&&t.push(...this.$slots.actions()),t.length)return l.createVNode(d.GridItem,a,{default:()=>[l.createVNode(d.FormItem,{hideLabel:!0,contentClass:this.footer?"form-footer":""},{default:()=>[l.createVNode(d.Space,null,C(t)?t:{default:()=>[t]})]})]})};return l.createVNode(d.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(d.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(d.GridItem,{span:t.span},C(a=le(this.formSource,t))?a:{default:()=>[a]})}),r()]})]})}});function ae(e){return e}function ne(e){const r=l.getCurrentInstance(),t=l.ref();function a(){var c,n;const u=(n=(c=r==null?void 0:r.proxy)==null?void 0:c.$refs)==null?void 0:n[e];u&&(t.value=u)}return l.onMounted(a),l.onUpdated(a),t}const ue={install(e,r){e.component("FormRender",w)}};exports.FormRenderResolver=_.FormRenderResolver;exports.FormRender=w;exports.default=ue;exports.defineForm=ae;exports.useForm=ne;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isPromise(obj: any): boolean;
|
|
@@ -4,9 +4,10 @@ export type SelectOptions = Map<string | number, string>;
|
|
|
4
4
|
export interface RenderSelectItemOptions {
|
|
5
5
|
placeholder?: string;
|
|
6
6
|
clearable?: boolean;
|
|
7
|
-
options: SelectOptions | Promise<SelectOptions> | (() => Promise<SelectOptions>);
|
|
7
|
+
options: SelectOptions | (() => SelectOptions) | Promise<SelectOptions> | (() => Promise<SelectOptions>);
|
|
8
8
|
multiple?: boolean;
|
|
9
9
|
maxTagCount?: number;
|
|
10
10
|
default?: string | number | boolean;
|
|
11
11
|
autoSumbit?: boolean;
|
|
12
|
+
cache?: boolean;
|
|
12
13
|
}
|
|
@@ -359,8 +359,8 @@ export declare const FormRender: import("vue").DefineComponent<{
|
|
|
359
359
|
onCancel?: ((...args: any[]) => any) | undefined;
|
|
360
360
|
"onUpdate:model-value"?: ((...args: any[]) => any) | undefined;
|
|
361
361
|
}, {
|
|
362
|
-
footer: boolean;
|
|
363
362
|
name: string;
|
|
363
|
+
footer: boolean;
|
|
364
364
|
layout: "horizontal" | "vertical";
|
|
365
365
|
minWidth: number;
|
|
366
366
|
submitable: boolean;
|
package/dist/es/index.mjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { getCurrentInstance as
|
|
2
|
-
import { DatePicker as
|
|
3
|
-
import
|
|
1
|
+
import { getCurrentInstance as j, inject as A, defineComponent as x, computed as y, openBlock as O, createElementBlock as P, normalizeClass as z, normalizeStyle as L, createElementVNode as N, ref as h, createVNode as u, isVNode as M, h as W, provide as F, onMounted as U, mergeProps as Y, createTextVNode as b, onUpdated as G } from "vue";
|
|
2
|
+
import { DatePicker as K, YearPicker as Q, QuarterPicker as X, MonthPicker as H, WeekPicker as J, Input as Z, InputNumber as p, Select as ee, Option as re, Switch as te, RangePicker as le, Textarea as ae, FormItem as R, Form as ne, Grid as ue, GridItem as w, Button as k, Space as ce } from "@arco-design/web-vue";
|
|
3
|
+
import V from "dayjs";
|
|
4
4
|
import { FormRenderResolver as Ye } from "./resolver.mjs";
|
|
5
|
-
const
|
|
6
|
-
var
|
|
7
|
-
const
|
|
8
|
-
return e ? `${
|
|
9
|
-
},
|
|
10
|
-
function
|
|
11
|
-
return
|
|
5
|
+
const de = Symbol("ArcoConfigProvider"), fe = "arco", ie = "$arco", q = (e) => {
|
|
6
|
+
var t, r, l;
|
|
7
|
+
const n = j(), c = A(de, void 0), a = (l = (r = c == null ? void 0 : c.prefixCls) != null ? r : (t = n == null ? void 0 : n.appContext.config.globalProperties[ie]) == null ? void 0 : t.classPrefix) != null ? l : fe;
|
|
8
|
+
return e ? `${a}-${e}` : a;
|
|
9
|
+
}, me = Object.prototype.toString;
|
|
10
|
+
function B(e) {
|
|
11
|
+
return me.call(e) === "[object Number]" && e === e;
|
|
12
12
|
}
|
|
13
|
-
var
|
|
14
|
-
for (const [r,
|
|
15
|
-
e[r] =
|
|
13
|
+
var E = (e, t) => {
|
|
14
|
+
for (const [r, l] of t)
|
|
15
|
+
e[r] = l;
|
|
16
16
|
return e;
|
|
17
17
|
};
|
|
18
|
-
const
|
|
18
|
+
const se = x({
|
|
19
19
|
name: "IconDown",
|
|
20
20
|
props: {
|
|
21
21
|
size: {
|
|
@@ -42,47 +42,47 @@ const me = C({
|
|
|
42
42
|
click: (e) => !0
|
|
43
43
|
},
|
|
44
44
|
setup(e, {
|
|
45
|
-
emit:
|
|
45
|
+
emit: t
|
|
46
46
|
}) {
|
|
47
|
-
const r =
|
|
47
|
+
const r = q("icon"), l = y(() => [r, `${r}-down`, {
|
|
48
48
|
[`${r}-spin`]: e.spin
|
|
49
|
-
}]),
|
|
50
|
-
const
|
|
51
|
-
return e.size && (
|
|
49
|
+
}]), n = y(() => {
|
|
50
|
+
const a = {};
|
|
51
|
+
return e.size && (a.fontSize = B(e.size) ? `${e.size}px` : e.size), e.rotate && (a.transform = `rotate(${e.rotate}deg)`), a;
|
|
52
52
|
});
|
|
53
53
|
return {
|
|
54
|
-
cls:
|
|
55
|
-
innerStyle:
|
|
56
|
-
onClick: (
|
|
57
|
-
|
|
54
|
+
cls: l,
|
|
55
|
+
innerStyle: n,
|
|
56
|
+
onClick: (a) => {
|
|
57
|
+
t("click", a);
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
-
}),
|
|
61
|
+
}), oe = ["stroke-width", "stroke-linecap", "stroke-linejoin"], he = /* @__PURE__ */ N("path", {
|
|
62
62
|
d: "M39.6 17.443 24.043 33 8.487 17.443"
|
|
63
|
-
}, null, -1),
|
|
64
|
-
function
|
|
65
|
-
return
|
|
63
|
+
}, null, -1), ye = [he];
|
|
64
|
+
function ke(e, t, r, l, n, c) {
|
|
65
|
+
return O(), P("svg", {
|
|
66
66
|
viewBox: "0 0 48 48",
|
|
67
67
|
fill: "none",
|
|
68
68
|
xmlns: "http://www.w3.org/2000/svg",
|
|
69
69
|
stroke: "currentColor",
|
|
70
|
-
class:
|
|
71
|
-
style:
|
|
70
|
+
class: z(e.cls),
|
|
71
|
+
style: L(e.innerStyle),
|
|
72
72
|
"stroke-width": e.strokeWidth,
|
|
73
73
|
"stroke-linecap": e.strokeLinecap,
|
|
74
74
|
"stroke-linejoin": e.strokeLinejoin,
|
|
75
|
-
onClick:
|
|
76
|
-
},
|
|
75
|
+
onClick: t[0] || (t[0] = (...a) => e.onClick && e.onClick(...a))
|
|
76
|
+
}, ye, 14, oe);
|
|
77
77
|
}
|
|
78
|
-
var
|
|
79
|
-
const
|
|
80
|
-
install: (e,
|
|
78
|
+
var $ = /* @__PURE__ */ E(se, [["render", ke]]);
|
|
79
|
+
const be = Object.assign($, {
|
|
80
|
+
install: (e, t) => {
|
|
81
81
|
var r;
|
|
82
|
-
const
|
|
83
|
-
e.component(
|
|
82
|
+
const l = (r = t == null ? void 0 : t.iconPrefix) != null ? r : "";
|
|
83
|
+
e.component(l + $.name, $);
|
|
84
84
|
}
|
|
85
|
-
}),
|
|
85
|
+
}), ve = x({
|
|
86
86
|
name: "IconUp",
|
|
87
87
|
props: {
|
|
88
88
|
size: {
|
|
@@ -109,116 +109,116 @@ const ye = Object.assign(g, {
|
|
|
109
109
|
click: (e) => !0
|
|
110
110
|
},
|
|
111
111
|
setup(e, {
|
|
112
|
-
emit:
|
|
112
|
+
emit: t
|
|
113
113
|
}) {
|
|
114
|
-
const r =
|
|
114
|
+
const r = q("icon"), l = y(() => [r, `${r}-up`, {
|
|
115
115
|
[`${r}-spin`]: e.spin
|
|
116
|
-
}]),
|
|
117
|
-
const
|
|
118
|
-
return e.size && (
|
|
116
|
+
}]), n = y(() => {
|
|
117
|
+
const a = {};
|
|
118
|
+
return e.size && (a.fontSize = B(e.size) ? `${e.size}px` : e.size), e.rotate && (a.transform = `rotate(${e.rotate}deg)`), a;
|
|
119
119
|
});
|
|
120
120
|
return {
|
|
121
|
-
cls:
|
|
122
|
-
innerStyle:
|
|
123
|
-
onClick: (
|
|
124
|
-
|
|
121
|
+
cls: l,
|
|
122
|
+
innerStyle: n,
|
|
123
|
+
onClick: (a) => {
|
|
124
|
+
t("click", a);
|
|
125
125
|
}
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
|
-
}),
|
|
128
|
+
}), Se = ["stroke-width", "stroke-linecap", "stroke-linejoin"], $e = /* @__PURE__ */ N("path", {
|
|
129
129
|
d: "M39.6 30.557 24.043 15 8.487 30.557"
|
|
130
|
-
}, null, -1),
|
|
131
|
-
function
|
|
132
|
-
return
|
|
130
|
+
}, null, -1), ge = [$e];
|
|
131
|
+
function Ce(e, t, r, l, n, c) {
|
|
132
|
+
return O(), P("svg", {
|
|
133
133
|
viewBox: "0 0 48 48",
|
|
134
134
|
fill: "none",
|
|
135
135
|
xmlns: "http://www.w3.org/2000/svg",
|
|
136
136
|
stroke: "currentColor",
|
|
137
|
-
class:
|
|
138
|
-
style:
|
|
137
|
+
class: z(e.cls),
|
|
138
|
+
style: L(e.innerStyle),
|
|
139
139
|
"stroke-width": e.strokeWidth,
|
|
140
140
|
"stroke-linecap": e.strokeLinecap,
|
|
141
141
|
"stroke-linejoin": e.strokeLinejoin,
|
|
142
|
-
onClick:
|
|
143
|
-
},
|
|
142
|
+
onClick: t[0] || (t[0] = (...a) => e.onClick && e.onClick(...a))
|
|
143
|
+
}, ge, 14, Se);
|
|
144
144
|
}
|
|
145
|
-
var
|
|
146
|
-
const
|
|
147
|
-
install: (e,
|
|
145
|
+
var g = /* @__PURE__ */ E(ve, [["render", Ce]]);
|
|
146
|
+
const xe = Object.assign(g, {
|
|
147
|
+
install: (e, t) => {
|
|
148
148
|
var r;
|
|
149
|
-
const
|
|
150
|
-
e.component(
|
|
149
|
+
const l = (r = t == null ? void 0 : t.iconPrefix) != null ? r : "";
|
|
150
|
+
e.component(l + g.name, g);
|
|
151
151
|
}
|
|
152
|
-
}),
|
|
152
|
+
}), I = {
|
|
153
153
|
id: Symbol("ID"),
|
|
154
154
|
source: Symbol("Source")
|
|
155
155
|
};
|
|
156
|
-
function
|
|
157
|
-
const r =
|
|
158
|
-
return e == null || e.forEach((
|
|
159
|
-
let
|
|
160
|
-
|
|
161
|
-
}), [r, (
|
|
162
|
-
r.value =
|
|
156
|
+
function Fe(e, t) {
|
|
157
|
+
const r = h({});
|
|
158
|
+
return e == null || e.forEach((n) => {
|
|
159
|
+
let c = null;
|
|
160
|
+
n.default && (c = (typeof n.default == "function" ? n.default() : n.default) || null), t && t[n.key] && (c = t[n.key]), r.value[n.key] = c;
|
|
161
|
+
}), [r, (n) => {
|
|
162
|
+
r.value = n;
|
|
163
163
|
}];
|
|
164
164
|
}
|
|
165
|
-
function
|
|
166
|
-
function
|
|
167
|
-
return e != null && e.disabledDate ? e.disabledDate(r,
|
|
165
|
+
function we(e) {
|
|
166
|
+
function t(r, l) {
|
|
167
|
+
return e != null && e.disabledDate ? e.disabledDate(r, l) : !1;
|
|
168
168
|
}
|
|
169
|
-
return (r,
|
|
169
|
+
return (r, l) => {
|
|
170
170
|
switch (e == null ? void 0 : e.type) {
|
|
171
171
|
case "week":
|
|
172
|
-
return
|
|
173
|
-
modelValue: r[
|
|
174
|
-
"onUpdate:modelValue": (
|
|
175
|
-
"disabled-date":
|
|
172
|
+
return u(J, {
|
|
173
|
+
modelValue: r[l.key],
|
|
174
|
+
"onUpdate:modelValue": (n) => r[l.key] = n,
|
|
175
|
+
"disabled-date": t,
|
|
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: r[
|
|
182
|
-
"onUpdate:modelValue": (
|
|
183
|
-
"disabled-date":
|
|
180
|
+
return u(H, {
|
|
181
|
+
modelValue: r[l.key],
|
|
182
|
+
"onUpdate:modelValue": (n) => r[l.key] = n,
|
|
183
|
+
"disabled-date": t,
|
|
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: r[
|
|
190
|
-
"onUpdate:modelValue": (
|
|
191
|
-
"disabled-date":
|
|
188
|
+
return u(X, {
|
|
189
|
+
modelValue: r[l.key],
|
|
190
|
+
"onUpdate:modelValue": (n) => r[l.key] = n,
|
|
191
|
+
"disabled-date": t,
|
|
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: r[
|
|
198
|
-
"onUpdate:modelValue": (
|
|
199
|
-
"disabled-date":
|
|
196
|
+
return u(Q, {
|
|
197
|
+
modelValue: r[l.key],
|
|
198
|
+
"onUpdate:modelValue": (n) => r[l.key] = n,
|
|
199
|
+
"disabled-date": t,
|
|
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: r[
|
|
207
|
-
"onUpdate:modelValue": (
|
|
208
|
-
"disabled-date":
|
|
205
|
+
return u(K, {
|
|
206
|
+
modelValue: r[l.key],
|
|
207
|
+
"onUpdate:modelValue": (n) => r[l.key] = n,
|
|
208
|
+
"disabled-date": t,
|
|
209
209
|
format: e == null ? void 0 : e.labelFormat,
|
|
210
210
|
"value-format": e == null ? void 0 : e.valueFormat
|
|
211
211
|
}, null);
|
|
212
212
|
}
|
|
213
213
|
};
|
|
214
214
|
}
|
|
215
|
-
function
|
|
216
|
-
return (
|
|
215
|
+
function Ve(e) {
|
|
216
|
+
return (t, r) => {
|
|
217
217
|
switch (e == null ? void 0 : e.type) {
|
|
218
218
|
case "number":
|
|
219
|
-
return
|
|
220
|
-
modelValue:
|
|
221
|
-
"onUpdate:modelValue": (
|
|
219
|
+
return u(p, {
|
|
220
|
+
modelValue: t[r.key],
|
|
221
|
+
"onUpdate:modelValue": (l) => t[r.key] = l,
|
|
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 Fe(e) {
|
|
|
226
226
|
}, null);
|
|
227
227
|
case "string":
|
|
228
228
|
default:
|
|
229
|
-
return
|
|
230
|
-
modelValue:
|
|
231
|
-
"onUpdate:modelValue": (
|
|
229
|
+
return u(Z, {
|
|
230
|
+
modelValue: t[r.key],
|
|
231
|
+
"onUpdate:modelValue": (l) => t[r.key] = l,
|
|
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
|
|
@@ -236,122 +236,150 @@ function Fe(e) {
|
|
|
236
236
|
}
|
|
237
237
|
};
|
|
238
238
|
}
|
|
239
|
-
function
|
|
240
|
-
return typeof e == "
|
|
239
|
+
function _(e) {
|
|
240
|
+
return !!e && (typeof e == "object" || typeof e == "function") && typeof e.then == "function";
|
|
241
241
|
}
|
|
242
|
-
function
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
242
|
+
function Ie(e) {
|
|
243
|
+
return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !M(e);
|
|
244
|
+
}
|
|
245
|
+
const C = /* @__PURE__ */ new WeakMap();
|
|
246
|
+
function _e(e) {
|
|
247
|
+
let t, r = !1;
|
|
248
|
+
const l = h(/* @__PURE__ */ new Map()), n = (a) => {
|
|
249
|
+
l.value = a, e.cache !== !1 && C.set(e.options, a);
|
|
250
|
+
};
|
|
251
|
+
switch (!0) {
|
|
252
|
+
case e.options instanceof Function: {
|
|
253
|
+
if (C.has(e.options)) {
|
|
254
|
+
l.value = C.get(e.options);
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
const a = e.options();
|
|
258
|
+
_(a) ? a.then(n) : n(a);
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
case _(e.options): {
|
|
262
|
+
e.options.then((a) => l.value = a);
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
default:
|
|
266
|
+
l.value = e.options;
|
|
267
|
+
}
|
|
268
|
+
function c() {
|
|
269
|
+
if (!e.autoSumbit || !t)
|
|
270
|
+
return;
|
|
271
|
+
let a = t;
|
|
272
|
+
for (; a && a.$el.tagName !== "FORM"; )
|
|
273
|
+
a = a.$parent;
|
|
274
|
+
a && a.$el && a.$el.dispatchEvent(new Event("submit"));
|
|
248
275
|
}
|
|
249
|
-
return (a,
|
|
250
|
-
let
|
|
251
|
-
return e.default && !
|
|
276
|
+
return (a, d) => {
|
|
277
|
+
let s;
|
|
278
|
+
return e.default && !r && (a[d.key] = e.default, r = !0), u(ee, {
|
|
279
|
+
ref: (i) => t = i,
|
|
252
280
|
multiple: e.multiple,
|
|
253
|
-
modelValue: a[
|
|
254
|
-
"onUpdate:modelValue": (
|
|
281
|
+
modelValue: a[d.key],
|
|
282
|
+
"onUpdate:modelValue": (i) => a[d.key] = i,
|
|
255
283
|
placeholder: e.placeholder,
|
|
256
284
|
allowClear: e.clearable,
|
|
257
285
|
maxTagCount: e.maxTagCount ?? 5,
|
|
258
|
-
onChange:
|
|
259
|
-
},
|
|
260
|
-
key:
|
|
261
|
-
value:
|
|
286
|
+
onChange: c
|
|
287
|
+
}, Ie(s = Array.from(l.value.entries()).map(([i, o]) => u(re, {
|
|
288
|
+
key: i,
|
|
289
|
+
value: i,
|
|
262
290
|
label: o
|
|
263
|
-
}, null))) ?
|
|
264
|
-
default: () => [
|
|
291
|
+
}, null))) ? s : {
|
|
292
|
+
default: () => [s]
|
|
265
293
|
});
|
|
266
294
|
};
|
|
267
295
|
}
|
|
268
|
-
function
|
|
269
|
-
function
|
|
296
|
+
function De(e) {
|
|
297
|
+
function t() {
|
|
270
298
|
e != null && e.autoSumbit;
|
|
271
299
|
}
|
|
272
|
-
return (r,
|
|
273
|
-
modelValue: r[
|
|
274
|
-
"onUpdate:modelValue": (
|
|
300
|
+
return (r, l) => (e != null && e.default && (r[l.key] = e.default), u(te, {
|
|
301
|
+
modelValue: r[l.key],
|
|
302
|
+
"onUpdate:modelValue": (n) => r[l.key] = n,
|
|
275
303
|
checkedText: (e == null ? void 0 : e.openLabel) ?? "是",
|
|
276
304
|
uncheckedText: (e == null ? void 0 : e.closeLabel) ?? "否",
|
|
277
305
|
checkedValue: (e == null ? void 0 : e.openValue) ?? !0,
|
|
278
306
|
uncheckedValue: (e == null ? void 0 : e.closeValue) ?? !1,
|
|
279
|
-
onChange:
|
|
307
|
+
onChange: t
|
|
280
308
|
}, null));
|
|
281
309
|
}
|
|
282
|
-
function
|
|
283
|
-
return (
|
|
284
|
-
let
|
|
285
|
-
function a(d) {
|
|
286
|
-
t = d;
|
|
287
|
-
}
|
|
310
|
+
function je(e) {
|
|
311
|
+
return (t, r) => {
|
|
312
|
+
let l = [];
|
|
288
313
|
function n(d) {
|
|
314
|
+
l = d;
|
|
315
|
+
}
|
|
316
|
+
function c(d) {
|
|
289
317
|
if (d && d.length === 2) {
|
|
290
|
-
const [
|
|
291
|
-
|
|
318
|
+
const [s, i] = d.sort(), o = V(s).startOf("days"), v = V(i).endOf("days");
|
|
319
|
+
t[r.key] = [o.format((e == null ? void 0 : e.valueFormat) || "YYYY-MM-DD"), v.format((e == null ? void 0 : e.valueFormat) || "YYYY-MM-DD")];
|
|
292
320
|
}
|
|
293
321
|
}
|
|
294
|
-
function
|
|
295
|
-
return e != null && e.disabledDate ? e.disabledDate(
|
|
322
|
+
function a(d) {
|
|
323
|
+
return e != null && e.disabledDate ? e.disabledDate(l, d) : !1;
|
|
296
324
|
}
|
|
297
|
-
return
|
|
325
|
+
return u("div", null, [u(le, {
|
|
298
326
|
style: {
|
|
299
327
|
width: "300px"
|
|
300
328
|
},
|
|
301
|
-
modelValue:
|
|
302
|
-
"onUpdate:modelValue": (d) =>
|
|
303
|
-
onSelect:
|
|
304
|
-
onChange:
|
|
329
|
+
modelValue: t[r.key],
|
|
330
|
+
"onUpdate:modelValue": (d) => t[r.key] = d,
|
|
331
|
+
onSelect: n,
|
|
332
|
+
onChange: c,
|
|
305
333
|
mode: e == null ? void 0 : e.type,
|
|
306
334
|
allowClear: e == null ? void 0 : e.clearable,
|
|
307
|
-
"disabled-date":
|
|
335
|
+
"disabled-date": a,
|
|
308
336
|
format: e == null ? void 0 : e.labelFormat,
|
|
309
337
|
"value-format": e == null ? void 0 : e.valueFormat
|
|
310
338
|
}, null)]);
|
|
311
339
|
};
|
|
312
340
|
}
|
|
313
|
-
function
|
|
314
|
-
return (
|
|
315
|
-
modelValue:
|
|
316
|
-
"onUpdate:modelValue": (
|
|
341
|
+
function Oe(e) {
|
|
342
|
+
return (t, r) => u(ae, {
|
|
343
|
+
modelValue: t[r.key],
|
|
344
|
+
"onUpdate:modelValue": (l) => t[r.key] = l,
|
|
317
345
|
placeholder: e == null ? void 0 : e.placeholder,
|
|
318
346
|
autoSize: e == null ? void 0 : e.autosize,
|
|
319
347
|
maxLength: e == null ? void 0 : e.maxLength
|
|
320
348
|
}, null);
|
|
321
349
|
}
|
|
322
|
-
function
|
|
323
|
-
return (
|
|
350
|
+
function Pe(e) {
|
|
351
|
+
return (t) => e(t);
|
|
324
352
|
}
|
|
325
|
-
function
|
|
353
|
+
function ze() {
|
|
326
354
|
return {
|
|
327
|
-
input:
|
|
328
|
-
textarea:
|
|
329
|
-
select:
|
|
330
|
-
date:
|
|
331
|
-
switch:
|
|
332
|
-
dateRange:
|
|
333
|
-
render:
|
|
355
|
+
input: Ve,
|
|
356
|
+
textarea: Oe,
|
|
357
|
+
select: _e,
|
|
358
|
+
date: we,
|
|
359
|
+
switch: De,
|
|
360
|
+
dateRange: je,
|
|
361
|
+
render: Pe
|
|
334
362
|
};
|
|
335
363
|
}
|
|
336
|
-
function
|
|
337
|
-
|
|
338
|
-
const r =
|
|
339
|
-
...
|
|
364
|
+
function Le(e, t) {
|
|
365
|
+
t.render || (t.render = (l) => l.input());
|
|
366
|
+
const r = t.render({
|
|
367
|
+
...ze()
|
|
340
368
|
});
|
|
341
369
|
return {
|
|
342
|
-
default: () => r(e,
|
|
370
|
+
default: () => r(e, t)
|
|
343
371
|
};
|
|
344
372
|
}
|
|
345
|
-
function
|
|
346
|
-
return
|
|
347
|
-
field:
|
|
348
|
-
label:
|
|
349
|
-
},
|
|
373
|
+
function Ne(e, t) {
|
|
374
|
+
return W(R, {
|
|
375
|
+
field: t.key,
|
|
376
|
+
label: t.title
|
|
377
|
+
}, Le(e, t));
|
|
350
378
|
}
|
|
351
|
-
function
|
|
352
|
-
return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !
|
|
379
|
+
function D(e) {
|
|
380
|
+
return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !M(e);
|
|
353
381
|
}
|
|
354
|
-
const
|
|
382
|
+
const Me = /* @__PURE__ */ x({
|
|
355
383
|
props: {
|
|
356
384
|
form: {
|
|
357
385
|
type: Object,
|
|
@@ -403,97 +431,97 @@ const Oe = /* @__PURE__ */ C({
|
|
|
403
431
|
emits: ["submit", "cancel", "update:model-value"],
|
|
404
432
|
expose: ["formSource", "updateFormField", "updateFormSource", "reset"],
|
|
405
433
|
setup(e) {
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
const
|
|
409
|
-
if (!
|
|
434
|
+
const t = Math.random().toString(32).slice(2).toUpperCase(), r = h(), [l, n] = Fe(e.form, e.modelValue || e.value), c = h(e.columns || 0), a = h(!0), d = () => a.value = !a.value;
|
|
435
|
+
F(I.id, t), F(I.source, l);
|
|
436
|
+
const s = y(() => {
|
|
437
|
+
if (!c.value)
|
|
410
438
|
return 1;
|
|
411
439
|
const f = e.form.reduce((m, S) => m + ((S == null ? void 0 : S.span) || 1), 0);
|
|
412
|
-
return
|
|
413
|
-
}),
|
|
414
|
-
function
|
|
440
|
+
return c.value - f % c.value;
|
|
441
|
+
}), i = y(() => e.form.reduce((f, m) => (m.rule && (f[m.key] = m.rule), f), {}));
|
|
442
|
+
function o() {
|
|
415
443
|
var f;
|
|
416
|
-
if (
|
|
444
|
+
if (c.value === 0) {
|
|
417
445
|
const m = (f = r.value) == null ? void 0 : f.$el;
|
|
418
|
-
|
|
446
|
+
c.value = Math.floor(m.offsetWidth / e.minWidth);
|
|
419
447
|
}
|
|
420
448
|
}
|
|
421
|
-
|
|
422
|
-
|
|
449
|
+
U(() => {
|
|
450
|
+
o();
|
|
423
451
|
});
|
|
424
452
|
function v(f, m) {
|
|
425
|
-
|
|
426
|
-
...
|
|
453
|
+
l.value[f] = m, n({
|
|
454
|
+
...l
|
|
427
455
|
});
|
|
428
456
|
}
|
|
429
|
-
function
|
|
457
|
+
function T() {
|
|
430
458
|
var f;
|
|
431
459
|
(f = r.value) == null || f.resetFields();
|
|
432
460
|
}
|
|
433
|
-
return window.addEventListener("resize",
|
|
434
|
-
formId:
|
|
435
|
-
formSource:
|
|
461
|
+
return window.addEventListener("resize", o), {
|
|
462
|
+
formId: t,
|
|
463
|
+
formSource: l,
|
|
436
464
|
formInstance: r,
|
|
437
|
-
formColumns:
|
|
438
|
-
formRules:
|
|
439
|
-
formCollspased:
|
|
440
|
-
formActiosSpan:
|
|
465
|
+
formColumns: c,
|
|
466
|
+
formRules: i,
|
|
467
|
+
formCollspased: a,
|
|
468
|
+
formActiosSpan: s,
|
|
441
469
|
toggleFormCollapsed: d,
|
|
442
470
|
updateFormField: v,
|
|
443
|
-
updateFormSource:
|
|
444
|
-
reset:
|
|
471
|
+
updateFormSource: n,
|
|
472
|
+
reset: T
|
|
445
473
|
};
|
|
446
474
|
},
|
|
447
475
|
render() {
|
|
448
476
|
const e = () => {
|
|
449
477
|
this.$emit("submit", this.formSource), this.$emit("update:model-value", this.formSource);
|
|
450
|
-
},
|
|
451
|
-
const r = [],
|
|
478
|
+
}, t = () => {
|
|
479
|
+
const r = [], l = this.footer ? {
|
|
452
480
|
span: this.formColumns
|
|
453
481
|
} : {
|
|
454
482
|
span: this.formActiosSpan
|
|
455
483
|
};
|
|
456
|
-
if (this.searchable && (r.push(
|
|
484
|
+
if (this.searchable && (r.push(u(k, {
|
|
457
485
|
type: "primary",
|
|
458
486
|
htmlType: "submit"
|
|
459
487
|
}, {
|
|
460
|
-
default: () => [
|
|
461
|
-
})), r.push(
|
|
488
|
+
default: () => [b("搜索")]
|
|
489
|
+
})), r.push(u(k, {
|
|
462
490
|
type: "secondary",
|
|
463
491
|
onClick: () => {
|
|
464
|
-
var
|
|
465
|
-
return (
|
|
492
|
+
var n;
|
|
493
|
+
return (n = this.formInstance) == null ? void 0 : n.resetFields();
|
|
466
494
|
}
|
|
467
495
|
}, {
|
|
468
|
-
default: () => [
|
|
469
|
-
}))), this.submitable && (r.push(
|
|
496
|
+
default: () => [b("重置")]
|
|
497
|
+
}))), this.submitable && (r.push(u(k, {
|
|
470
498
|
type: "primary",
|
|
471
499
|
htmlType: "submit"
|
|
472
500
|
}, {
|
|
473
|
-
default: () => [
|
|
474
|
-
})), r.push(
|
|
501
|
+
default: () => [b("提交")]
|
|
502
|
+
})), r.push(u(k, {
|
|
475
503
|
type: "secondary",
|
|
476
504
|
onClick: () => this.$emit("cancel")
|
|
477
505
|
}, {
|
|
478
|
-
default: () => [
|
|
479
|
-
}))), this.form.some((
|
|
506
|
+
default: () => [b("取消")]
|
|
507
|
+
}))), this.form.some((n) => !!n.collapsed) && r.push(u(k, {
|
|
480
508
|
onClick: this.toggleFormCollapsed
|
|
481
509
|
}, {
|
|
482
510
|
default: () => this.formCollspased ? "展开" : "收起",
|
|
483
|
-
icon: () => this.formCollspased ?
|
|
511
|
+
icon: () => this.formCollspased ? u(be, null, null) : u(xe, null, null)
|
|
484
512
|
})), this.$slots.actions && r.push(...this.$slots.actions()), r.length)
|
|
485
|
-
return
|
|
486
|
-
default: () => [
|
|
513
|
+
return u(w, l, {
|
|
514
|
+
default: () => [u(R, {
|
|
487
515
|
hideLabel: !0,
|
|
488
516
|
contentClass: this.footer ? "form-footer" : ""
|
|
489
517
|
}, {
|
|
490
|
-
default: () => [
|
|
518
|
+
default: () => [u(ce, null, D(r) ? r : {
|
|
491
519
|
default: () => [r]
|
|
492
520
|
})]
|
|
493
521
|
})]
|
|
494
522
|
});
|
|
495
523
|
};
|
|
496
|
-
return
|
|
524
|
+
return u(ne, Y({
|
|
497
525
|
layout: this.$props.layout,
|
|
498
526
|
rules: this.formRules,
|
|
499
527
|
onSubmitSuccess: e
|
|
@@ -504,44 +532,44 @@ const Oe = /* @__PURE__ */ C({
|
|
|
504
532
|
ref: (r) => this.formInstance = r,
|
|
505
533
|
model: this.formSource
|
|
506
534
|
}), {
|
|
507
|
-
default: () => [
|
|
535
|
+
default: () => [u(ue, {
|
|
508
536
|
cols: this.formColumns,
|
|
509
537
|
"col-gap": 10,
|
|
510
538
|
"rol-gap": 10
|
|
511
539
|
}, {
|
|
512
540
|
default: () => [this.form.filter((r) => this.formCollspased ? !r.collapsed : !0).map((r) => {
|
|
513
|
-
let
|
|
514
|
-
return
|
|
541
|
+
let l;
|
|
542
|
+
return u(w, {
|
|
515
543
|
span: r.span
|
|
516
|
-
},
|
|
517
|
-
default: () => [
|
|
544
|
+
}, D(l = Ne(this.formSource, r)) ? l : {
|
|
545
|
+
default: () => [l]
|
|
518
546
|
});
|
|
519
|
-
}),
|
|
547
|
+
}), t()]
|
|
520
548
|
})]
|
|
521
549
|
});
|
|
522
550
|
}
|
|
523
551
|
});
|
|
524
|
-
function
|
|
552
|
+
function Be(e) {
|
|
525
553
|
return e;
|
|
526
554
|
}
|
|
527
|
-
function
|
|
528
|
-
const
|
|
529
|
-
function
|
|
530
|
-
var
|
|
531
|
-
const
|
|
532
|
-
|
|
555
|
+
function Ee(e) {
|
|
556
|
+
const t = j(), r = h();
|
|
557
|
+
function l() {
|
|
558
|
+
var c, a;
|
|
559
|
+
const n = (a = (c = t == null ? void 0 : t.proxy) == null ? void 0 : c.$refs) == null ? void 0 : a[e];
|
|
560
|
+
n && (r.value = n);
|
|
533
561
|
}
|
|
534
|
-
return
|
|
562
|
+
return U(l), G(l), r;
|
|
535
563
|
}
|
|
536
|
-
const
|
|
537
|
-
install(e,
|
|
538
|
-
e.component("FormRender",
|
|
564
|
+
const Te = {
|
|
565
|
+
install(e, t) {
|
|
566
|
+
e.component("FormRender", Me);
|
|
539
567
|
}
|
|
540
568
|
};
|
|
541
569
|
export {
|
|
542
|
-
|
|
570
|
+
Me as FormRender,
|
|
543
571
|
Ye as FormRenderResolver,
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
572
|
+
Te as default,
|
|
573
|
+
Be as defineForm,
|
|
574
|
+
Ee as useForm
|
|
547
575
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isPromise(obj: any): boolean;
|