dynamicformdjx 0.3.2 → 0.3.4
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/README.md +90 -0
- package/dist/elementPlus/index.cjs +1 -1
- package/dist/elementPlus/index.mjs +1 -1
- package/dist/hooks/useDyForm.d.ts +4 -1
- package/dist/index-CA3F2Lxo.cjs +1 -0
- package/dist/index-MF72-iEr.js +34 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +63 -60
- package/dist/naiveUi/hooks/decorateForm.d.ts +8 -0
- package/dist/naiveUi/hooks/renderForm.d.ts +1 -1
- package/dist/naiveUi/index.cjs +1 -1
- package/dist/naiveUi/index.d.ts +1 -0
- package/dist/naiveUi/index.mjs +324 -298
- package/dist/utils/tools.d.ts +3 -1
- package/package.json +1 -1
- package/dist/index-BWQjnQQF.cjs +0 -1
- package/dist/index-BqKRE4oH.js +0 -29
package/README.md
CHANGED
|
@@ -262,7 +262,97 @@ const validatorData = () => {
|
|
|
262
262
|
}
|
|
263
263
|
</style>
|
|
264
264
|
```
|
|
265
|
+
#### 3.装饰表单
|
|
266
|
+
> (可省略render2函数)
|
|
267
|
+
```vue
|
|
268
|
+
<script setup lang="ts">
|
|
269
|
+
import { ref} from "vue";
|
|
270
|
+
import {NButton} from "naive-ui";
|
|
271
|
+
import {useDyForm} from "dynamicformdjx";
|
|
272
|
+
import {
|
|
273
|
+
type naiDynamicFormRef,
|
|
274
|
+
NaiDynamicForm,
|
|
275
|
+
useDecorateForm,
|
|
276
|
+
renderDatePicker
|
|
277
|
+
} from "dynamicformdjx/naiveUi";
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
type FormRow = {
|
|
281
|
+
password: string
|
|
282
|
+
job: number
|
|
283
|
+
birthday: number
|
|
284
|
+
}
|
|
285
|
+
const naiDynamicFormRef = ref<naiDynamicFormRef | null>(null)
|
|
286
|
+
const formItems = useDecorateForm<FormRow>([
|
|
287
|
+
{
|
|
288
|
+
key: "password",
|
|
289
|
+
label: "密码",
|
|
290
|
+
value: null,
|
|
291
|
+
clearable: true,
|
|
292
|
+
placeholder: '请输入密码',
|
|
293
|
+
required: true,
|
|
294
|
+
type:'password',
|
|
295
|
+
renderType: 'renderInput',
|
|
296
|
+
renderProps:{
|
|
297
|
+
showPasswordOn:'click'
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
key: "job",
|
|
302
|
+
label: "职位",
|
|
303
|
+
value: null,
|
|
304
|
+
clearable: true,
|
|
305
|
+
options: ['前端', '后端'].map((label, value) => ({label, value})),
|
|
306
|
+
renderType: 'renderSelect',
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
key: "birthday",
|
|
310
|
+
label: "生日",
|
|
311
|
+
value: null,
|
|
312
|
+
render2: f => renderDatePicker(f.value, {type: 'datetime'}, f),
|
|
313
|
+
},
|
|
314
|
+
])
|
|
315
|
+
const useForm = useDyForm<FormRow>(formItems)
|
|
316
|
+
const getData = () => {
|
|
317
|
+
const res = naiDynamicFormRef.value?.getResult?.()
|
|
318
|
+
console.log(res)
|
|
319
|
+
}
|
|
320
|
+
const resetData = () => {
|
|
321
|
+
naiDynamicFormRef.value?.reset?.()
|
|
322
|
+
}
|
|
323
|
+
const setData = () => {
|
|
324
|
+
useForm.setValues({
|
|
325
|
+
password: 'naive-ui',
|
|
326
|
+
job: 0,
|
|
327
|
+
birthday: Date.now(),
|
|
328
|
+
})
|
|
329
|
+
}
|
|
330
|
+
const validatorData = () => {
|
|
331
|
+
naiDynamicFormRef.value?.validator().then(data => {
|
|
332
|
+
console.log(data)
|
|
333
|
+
}).catch(err => {
|
|
334
|
+
console.log(err)
|
|
335
|
+
})
|
|
336
|
+
}
|
|
337
|
+
</script>
|
|
338
|
+
|
|
339
|
+
<template>
|
|
340
|
+
<NaiDynamicForm :items="formItems" ref="naiDynamicFormRef"/>
|
|
341
|
+
<div class="control">
|
|
342
|
+
<n-button @click="getData" type="success" size="small">get Data</n-button>
|
|
343
|
+
<n-button @click="setData" type="warning" size="small">set Data</n-button>
|
|
344
|
+
<n-button @click="validatorData" type="default" size="small">validate Data</n-button>
|
|
345
|
+
<n-button @click="resetData" type="error" size="small">reset Data</n-button>
|
|
346
|
+
</div>
|
|
347
|
+
</template>
|
|
265
348
|
|
|
349
|
+
<style scoped>
|
|
350
|
+
.control {
|
|
351
|
+
display: flex;
|
|
352
|
+
gap: 5px;
|
|
353
|
+
}
|
|
354
|
+
</style>
|
|
355
|
+
```
|
|
266
356
|
### 动态录入
|
|
267
357
|
|
|
268
358
|
#### 1.单组件
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),f=require("../index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),f=require("../index-CA3F2Lxo.cjs"),u=require("element-plus"),k=e.defineComponent({name:"EleDynamicInput",props:{size:{type:String},isController:{type:Boolean},dyCls:{type:String},randomFun:{type:Function,default:t=>`${Date.now()}_${t??0}`},btnConfigs:{type:Object},configs:{type:Object},dyListConfigs:{type:Object},modelValue:{type:Object,required:!0}},emits:{"update:modelValue":t=>!0,onReset:()=>!0,onMerge:(t,s)=>!0},setup(t,{emit:s,expose:C}){const N={resetTxt:"重置",newTxt:"添加项",mergeTxt:"合并",...t.btnConfigs},i={hideReset:!1,maxHeight:"300px",autoScroll:!0,allowFilter:!0,...t.configs},c={arraySplitSymbol:",",...t.dyListConfigs},m=t.size,o=e.ref(f.tranArr(t.modelValue,t.randomFun,c.arraySplitSymbol)),V=e.ref(null);return e.watch(o,l=>{if(!t.isController)return;const v=f.resetObj(l,c.arraySplitSymbol);s("update:modelValue",v),s("onMerge",v,e.toRaw(o.value))},{deep:!0}),C({onSet:l=>{o.value=f.tranArr(l??t.modelValue,t.randomFun,c.arraySplitSymbol)},getResult:(l="res")=>l==="ori"?e.toRaw(o.value):f.resetObj(o.value,c.arraySplitSymbol)}),()=>e.createVNode("div",{class:t.dyCls??`dynamicForm ${m}`,style:{maxHeight:i.maxHeight}},[e.createVNode("div",{class:"dyFormList",ref:V},[o.value.map((l,v,n)=>e.createVNode("div",{class:"dItem",key:l.rId},[e.createVNode("div",{class:"input"},[e.createVNode(u.ElInput,{size:m,modelValue:l.key,class:"key",onInput:r=>{l.key=r}},null),e.createTextVNode(":"),e.createVNode(u.ElInput,{size:m,modelValue:l.value,class:"value",onInput:r=>{i.allowFilter&&l.isNumber?l.value=f.formatNumberInput(r,l.isArray,c.arraySplitSymbol):l.value=r}},{prefix:()=>e.createVNode(e.Fragment,null,[e.createVNode(u.ElButton,{class:"typeBtn",type:l.isArray?"success":"default",size:"small",onClick:()=>{l.isArray=!l.isArray}},{default:()=>[e.createTextVNode("Array")]}),e.createTextVNode(" "),e.createVNode(u.ElButton,{class:"typeBtn",type:l.isNumber?"success":"default",size:"small",onClick:()=>{l.isNumber=!l.isNumber}},{default:()=>[e.createTextVNode("Number")]})])})]),e.createVNode("div",{class:"btn"},[e.createVNode(u.ElButton,{type:"success",size:m,disabled:v!==n.length-1,onClick:()=>{o.value.push({rId:t.randomFun(),key:"",value:""}),i.autoScroll&&e.nextTick(()=>{const r=V.value;r?.scrollTo({top:r.scrollHeight,behavior:"smooth"})})}},{default:()=>[e.createTextVNode("+")]}),e.createVNode(u.ElButton,{size:m,type:"danger",onClick:()=>{o.value=o.value.filter(r=>r.rId!==l.rId)}},{default:()=>[e.createTextVNode("-")]})])]))]),e.createVNode("div",{class:"control"},[!o.value.length&&e.createVNode(u.ElButton,{size:m,type:"success",onClick:()=>{o.value.push({rId:t.randomFun(),key:"",value:""})}},{default:()=>[N.newTxt]}),!t.isController&&e.createVNode(e.Fragment,null,[!i.hideReset&&e.createVNode(u.ElButton,{size:m,type:"default",onClick:()=>{o.value=f.tranArr(t.modelValue,t.randomFun,c.arraySplitSymbol),s("onReset")}},{default:()=>[N.resetTxt]}),e.createVNode(u.ElButton,{size:m,type:"info",onClick:()=>{o.value.sort((v,n)=>+v.rId-+n.rId);const l=f.resetObj(o.value,c.arraySplitSymbol);s("update:modelValue",l),s("onMerge",l,e.toRaw(o.value)),o.value=f.tranArr(l,t.randomFun,c.arraySplitSymbol)}},{default:()=>[N.mergeTxt]})])])])}});function I(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!e.isVNode(t)}const A=e.defineComponent({name:"EleDynamicCascadeInput",props:{modelValue:{type:Object,required:!0},isController:{type:Boolean},dyCls:{type:String},randomFun:{type:Function,default:t=>`${Date.now()}_${t??0}`},depth:{type:Number,default:3},btnConfigs:{type:Object},configs:{type:Object},dyListConfigs:{type:Object},newChildTxt:{type:Function,default:t=>`添加 '${t.key}' 子项`}},emits:{"update:modelValue":t=>!0,onReset:()=>!0,onMerge:(t,s)=>!0},setup(t,{emit:s,expose:C}){const N={resetTxt:"重置",newTxt:"添加项",mergeTxt:"合并",...t.btnConfigs},i={hideReset:!1,maxHeight:"600px",allowFilter:!0,showBorder:!0,showPad:!0,retractLen:0,borderColors:[],...t.configs},c={arraySplitSymbol:",",...t.dyListConfigs},m=n=>["string","number"].includes(n),o=n=>Object.keys(n).map((r,d)=>{let a=n[r];const b=Array.isArray(a),x=b?a.every(p=>typeof p=="number"):typeof a=="number",g=a===null;return m(typeof a)&&(a=n[r]),g&&(a=""),{rId:t.randomFun(d),key:r,value:Object.prototype.toString.call(a)==="[object Object]"?o(n[r]):b?a.join(c.arraySplitSymbol):a,isArray:b||void 0,isNumber:x||void 0}}),V=n=>n.reduce((r,d)=>{const a=d.value;return d.key.trim().length&&(r[d.key]=Array.isArray(a)?V(a):f.parseValue(d.value,d.isArray,d.isNumber,c.arraySplitSymbol)),r},{}),l=e.ref(o(t.modelValue)),v=(n,r=1,d)=>e.createVNode("div",{class:[`depth-${r}`,i.showBorder?"":"no-border",i.showPad?"":"no-pad"],style:{"--depth":r,["--c"+[r]]:f.saferRepairColor(i.borderColors,r)}},[n.map((a,b,x)=>{const g=Array.isArray(a.value),p=m(typeof a.value);return e.createVNode("div",{class:"dItem",key:a.rId,style:{marginLeft:r>1?`${r*i.retractLen}px`:"0"}},[e.createVNode("div",{class:"input"},[!g&&e.createVNode(e.Fragment,null,[e.createVNode(u.ElInput,{modelValue:a.key,class:"key",onInput:y=>a.key=y},null),e.createTextVNode(":")]),e.createVNode(u.ElInput,{class:`value ${g?"isKey":""}`,modelValue:p?a.value:a.key,onInput:y=>{if(g){a.key=y;return}i.allowFilter&&a.isNumber?a.value=f.formatNumberInput(y,a.isArray,c.arraySplitSymbol):a.value=y}},{prefix:Array.isArray(a.value)?void 0:()=>e.createVNode(e.Fragment,null,[e.createVNode(u.ElButton,{type:a.isArray?"success":"default",size:"small",onClick:()=>{a.isArray=!a.isArray}},{default:()=>[e.createTextVNode("Array")]}),e.createTextVNode(" "),e.createVNode(u.ElButton,{type:a.isNumber?"success":"default",size:"small",onClick:()=>{a.isNumber=!a.isNumber}},{default:()=>[e.createTextVNode("Number")]})]),suffix:()=>{let y;return r<t.depth?!g&&e.createVNode(u.ElButton,{type:"success",size:"small",onClick:()=>{p&&(a.value=[],a.isArray=void 0),a.value.push({rId:t.randomFun(),key:"",value:""})}},I(y=t.newChildTxt(a))?y:{default:()=>[y]}):null}})]),e.createVNode("div",{class:"btn"},[e.createVNode(u.ElButton,{type:"success",disabled:b!==x.length-1,onClick:()=>{n.push({rId:t.randomFun(),key:"",value:""})}},{default:()=>[e.createTextVNode("+")]}),e.createVNode(u.ElButton,{type:"danger",onClick:()=>{if(n.splice(b,1),n.length<1){if(d===void 0)return V([]);const y=l.value.findIndex(S=>S.rId===d?.rId);r<1?l.value.splice(y,1,{...d,value:""}):d.value=""}}},{default:()=>[e.createTextVNode("-")]})]),Array.isArray(a.value)&&v(a.value,r+1,a)])})]);return e.watch(l,n=>{if(!t.isController)return;const r=V(n);s("update:modelValue",r),s("onMerge",r,e.toRaw(l.value))},{deep:!0}),C({onSet:n=>{l.value=o(n??t.modelValue)},getResult:(n="res")=>n==="ori"?e.toRaw(l.value):V(l.value)}),()=>e.createVNode("div",{class:t.dyCls??"dynamicCascadeForm"},[e.createVNode("div",{class:"dyFormList",style:{maxHeight:i.maxHeight}},[v(l.value)]),e.createVNode("div",{class:"control"},[!l.value.length&&e.createVNode(u.ElButton,{type:"success",onClick:()=>{l.value.push({rId:t.randomFun(),key:"",value:""})}},{default:()=>[N.newTxt]}),!t.isController&&e.createVNode(e.Fragment,null,[!i.hideReset&&e.createVNode(u.ElButton,{type:"default",onClick:()=>{l.value=o(t.modelValue),s("onReset")}},{default:()=>[N.resetTxt]}),e.createVNode(u.ElButton,{type:"info",onClick:()=>{const n=V(l.value);s("update:modelValue",n),s("onMerge",n,e.toRaw(l.value)),l.value=o(n)}},{default:()=>[N.mergeTxt]})])])])}});exports.EleDynamicCascadeInput=A;exports.EleDynamicInput=k;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent as N, ref as w, watch as T, toRaw as k, createVNode as a, createTextVNode as m, Fragment as S, nextTick as O, isVNode as R } from "vue";
|
|
2
|
-
import { t as I, r as V, f as j, p as L, s as M } from "../index-
|
|
2
|
+
import { t as I, r as V, f as j, p as L, s as M } from "../index-MF72-iEr.js";
|
|
3
3
|
import { ElInput as h, ElButton as r } from "element-plus";
|
|
4
4
|
const E = /* @__PURE__ */ N({
|
|
5
5
|
name: "EleDynamicInput",
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { Ref } from 'vue';
|
|
2
2
|
import { DyFormItem } from '../types/form';
|
|
3
3
|
type KeyOf<T> = Extract<keyof T, string>;
|
|
4
|
-
export
|
|
4
|
+
export type DyFormItemLike<Row extends Record<string, any>, RuleT = any> = Omit<DyFormItem<Row, RuleT>, "value"> & {
|
|
5
|
+
value: DyFormItem<Row, RuleT>["value"] | any | null;
|
|
6
|
+
};
|
|
7
|
+
export declare function useReactiveForm<T extends Record<string, any>, U = any>(items: DyFormItemLike<T, U>[], isReactive?: boolean): DyFormItem<T, U>[];
|
|
5
8
|
export declare function useDyForm<Row extends Record<string, any>>(items: DyFormItem<Row>[] | Ref<DyFormItem<Row>[]>): {
|
|
6
9
|
setDisabled: (disabled: boolean, keys?: KeyOf<Row>[]) => void;
|
|
7
10
|
setHidden: (hidden: boolean, keys?: KeyOf<Row>[]) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require('./index.css');const a=require("vue"),l=(e,s,n)=>Object.keys(e).map((t,r)=>{const i=e[t],o=Array.isArray(i),c=o?i.every(f=>typeof f=="number"):typeof i=="number";return{rId:s(r),key:t,value:o?i.join(n):i,isArray:o||void 0,isNumber:c||void 0}}),p=(e,s)=>e.reduce((n,t)=>(t.key.trim()&&(n[t.key]=u(t.value,t.isArray,t.isNumber,s)),n),{}),u=(e,s,n,t=",")=>{let r;return s?n?r=String(e).split(t).map(Number).filter(i=>!Number.isNaN(i)):r=String(e).split(t):n?r=parseFloat(e):r=e.toString(),r},m=(e,s,n=",")=>{const t=r=>{r=r.replace(/[^\d.-]/g,"");let i=!1;r.startsWith("-")&&(i=!0),r=r.replace(/-/g,"");const o=r.indexOf(".");return o!==-1&&(r=r.slice(0,o+1)+r.slice(o+1).replace(/\./g,"")),(i?"-":"")+r};return s?e.split(n).map(r=>t(r)).join(n):t(e)},g=e=>`hsl(${e*35%360}, 60%, 65%)`,y=(e,s)=>e[s-1]??g(s);function b(e){return a.isRef(e)?e:a.ref(e??null)}exports.ensureRef=b;exports.formatNumberInput=m;exports.parseValue=u;exports.resetObj=p;exports.saferRepairColor=y;exports.tranArr=l;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ref as c, isRef as f } from "vue";
|
|
2
|
+
import './index.css';const g = (e, s, n) => Object.keys(e).map((t, r) => {
|
|
3
|
+
const i = e[t], o = Array.isArray(i), a = o ? i.every((u) => typeof u == "number") : typeof i == "number";
|
|
4
|
+
return {
|
|
5
|
+
rId: s(r),
|
|
6
|
+
key: t,
|
|
7
|
+
value: o ? i.join(n) : i,
|
|
8
|
+
isArray: o || void 0,
|
|
9
|
+
isNumber: a || void 0
|
|
10
|
+
};
|
|
11
|
+
}), y = (e, s) => e.reduce((n, t) => (t.key.trim() && (n[t.key] = l(t.value, t.isArray, t.isNumber, s)), n), {}), l = (e, s, n, t = ",") => {
|
|
12
|
+
let r;
|
|
13
|
+
return s ? n ? r = String(e).split(t).map(Number).filter((i) => !Number.isNaN(i)) : r = String(e).split(t) : n ? r = parseFloat(e) : r = e.toString(), r;
|
|
14
|
+
}, b = (e, s, n = ",") => {
|
|
15
|
+
const t = (r) => {
|
|
16
|
+
r = r.replace(/[^\d.-]/g, "");
|
|
17
|
+
let i = !1;
|
|
18
|
+
r.startsWith("-") && (i = !0), r = r.replace(/-/g, "");
|
|
19
|
+
const o = r.indexOf(".");
|
|
20
|
+
return o !== -1 && (r = r.slice(0, o + 1) + r.slice(o + 1).replace(/\./g, "")), (i ? "-" : "") + r;
|
|
21
|
+
};
|
|
22
|
+
return s ? e.split(n).map((r) => t(r)).join(n) : t(e);
|
|
23
|
+
}, p = (e) => `hsl(${e * 35 % 360}, 60%, 65%)`, d = (e, s) => e[s - 1] ?? p(s);
|
|
24
|
+
function h(e) {
|
|
25
|
+
return f(e) ? e : c(e ?? null);
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
h as e,
|
|
29
|
+
b as f,
|
|
30
|
+
l as p,
|
|
31
|
+
y as r,
|
|
32
|
+
d as s,
|
|
33
|
+
g as t
|
|
34
|
+
};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),m=require("./index-CA3F2Lxo.cjs"),I=e.defineComponent({name:"DynamicInput",props:{size:{type:String},isController:{type:Boolean},dyCls:{type:String},randomFun:{type:Function,default:a=>`${Date.now()}_${a??0}`},btnConfigs:{type:Object},configs:{type:Object},dyListConfigs:{type:Object},modelValue:{type:Object,required:!0}},emits:{"update:modelValue":a=>!0,onReset:()=>!0,onMerge:(a,u)=>!0},setup(a,{emit:u,expose:f}){const d={resetTxt:"重置",newTxt:"添加项",mergeTxt:"合并",...a.btnConfigs},i={hideReset:!1,maxHeight:"300px",autoScroll:!0,allowFilter:!0,...a.configs},y={arraySplitSymbol:",",...a.dyListConfigs},v=a.size,s=e.ref(m.tranArr(a.modelValue,a.randomFun,y.arraySplitSymbol)),b=e.ref(null);return e.watch(s,t=>{if(!a.isController)return;const o=m.resetObj(t,y.arraySplitSymbol);u("update:modelValue",o),u("onMerge",o,e.toRaw(s.value))},{deep:!0}),f({onSet:t=>{s.value=m.tranArr(t??a.modelValue,a.randomFun,y.arraySplitSymbol)},getResult:(t="res")=>t==="ori"?e.toRaw(s.value):m.resetObj(s.value,y.arraySplitSymbol)}),()=>e.createVNode("div",{class:a.dyCls??`dynamicForm ${v}`},[e.createVNode("div",{class:"dyFormList",ref:b,style:{maxHeight:i.maxHeight}},[s.value.map((t,o,l)=>e.createVNode("div",{class:"dItem",key:t.rId},[e.createVNode("div",{class:"input"},[e.createVNode("input",{size:v,value:t.key,class:"key nativeInput",onInput:r=>{t.key=r.target.value}},null),e.createTextVNode(":"),e.createVNode("div",{class:"vInput"},[e.createVNode("div",{class:"slot"},[e.createVNode("button",{class:[t.isArray?"success":"default","small","bt"],onClick:()=>{t.isArray=!t.isArray}},[e.createTextVNode("Array")]),e.createTextVNode(" "),e.createVNode("button",{class:[t.isNumber?"success":"default","small","bt"],onClick:()=>{t.isNumber=!t.isNumber}},[e.createTextVNode("Number")])]),e.createVNode("input",{size:v,value:t.value,class:"value nativeV",onInput:r=>{const c=r.target.value;i.allowFilter&&t.isNumber?t.value=m.formatNumberInput(c,t.isArray,y.arraySplitSymbol):t.value=c}},null)])]),e.createVNode("div",{class:"btn"},[e.createVNode("button",{class:[v,"success","bt"],disabled:o!==l.length-1,onClick:()=>{s.value.push({rId:a.randomFun(),key:"",value:""}),i.autoScroll&&e.nextTick(()=>{const r=b.value;r?.scrollTo({top:r.scrollHeight,behavior:"smooth"})})}},[e.createTextVNode("+")]),e.createVNode("button",{class:["danger",v,"bt"],onClick:()=>{s.value=s.value.filter(r=>r.rId!==t.rId)}},[e.createTextVNode("-")])])]))]),e.createVNode("div",{class:"control"},[!s.value.length&&e.createVNode("button",{class:["success",v,"bt"],onClick:()=>{s.value.push({rId:a.randomFun(),key:"",value:""})}},[d.newTxt]),!a.isController&&e.createVNode(e.Fragment,null,[!i.hideReset&&e.createVNode("button",{class:["default",v,"bt"],onClick:()=>{s.value=m.tranArr(a.modelValue,a.randomFun,y.arraySplitSymbol),u("onReset")}},[d.resetTxt]),e.createVNode("button",{class:["info",v,"bt"],onClick:()=>{s.value.sort((o,l)=>+o.rId-+l.rId);const t=m.resetObj(s.value,y.arraySplitSymbol);u("update:modelValue",t),u("onMerge",t,e.toRaw(s.value)),s.value=m.tranArr(t,a.randomFun,y.arraySplitSymbol)}},[d.mergeTxt])])])])}}),S=e.defineComponent({name:"DynamicCascadeInput",props:{modelValue:{type:Object,required:!0},isController:{type:Boolean},dyCls:{type:String},randomFun:{type:Function,default:a=>`${Date.now()}_${a??0}`},depth:{type:Number,default:3},btnConfigs:{type:Object},configs:{type:Object},dyListConfigs:{type:Object},newChildTxt:{type:Function,default:a=>`添加 '${a.key}' 子项`}},emits:{"update:modelValue":a=>!0,onReset:()=>!0,onMerge:(a,u)=>!0},setup(a,{emit:u,expose:f}){const d={resetTxt:"重置",newTxt:"添加项",mergeTxt:"合并",...a.btnConfigs},i={hideReset:!1,maxHeight:"600px",allowFilter:!0,showBorder:!0,showPad:!0,retractLen:0,borderColors:[],...a.configs},y={arraySplitSymbol:",",...a.dyListConfigs},v=l=>["string","number"].includes(l),s=l=>Object.keys(l).map((r,c)=>{let n=l[r];const V=Array.isArray(n),x=V?n.every(k=>typeof k=="number"):typeof n=="number",N=n===null;return v(typeof n)&&(n=l[r]),N&&(n=""),{rId:a.randomFun(c),key:r,value:Object.prototype.toString.call(n)==="[object Object]"?s(l[r]):V?n.join(y.arraySplitSymbol):n,isArray:V||void 0,isNumber:x||void 0}}),b=l=>l.reduce((r,c)=>{const n=c.value;return c.key.trim().length&&(r[c.key]=Array.isArray(n)?b(n):m.parseValue(c.value,c.isArray,c.isNumber,y.arraySplitSymbol)),r},{}),t=e.ref(s(a.modelValue)),o=(l,r=1,c)=>e.createVNode("div",{class:[`depth-${r}`,i.showBorder?"":"no-border",i.showPad?"":"no-pad"],style:{"--depth":r,["--c"+[r]]:m.saferRepairColor(i.borderColors,r)}},[l.map((n,V,x)=>{const N=Array.isArray(n.value),k=v(typeof n.value);return e.createVNode("div",{class:"dItem",key:n.rId,style:{marginLeft:r>1?`${r*i.retractLen}px`:"0"}},[e.createVNode("div",{class:"input"},[!N&&e.createVNode(e.Fragment,null,[e.createVNode("input",{value:n.key,class:"key nativeInput",onInput:C=>n.key=C.target.value},null),e.createTextVNode(":")]),e.createVNode("div",{class:"vInput"},[e.createVNode("div",{class:"slot"},[Array.isArray(n.value)?void 0:e.createVNode(e.Fragment,null,[e.createVNode("button",{class:[n.isArray?"success":"default","small","bt"],onClick:()=>{n.isArray=!n.isArray}},[e.createTextVNode("Array")]),e.createTextVNode(" "),e.createVNode("button",{class:[n.isNumber?"success":"default","small","bt"],onClick:()=>{n.isNumber=!n.isNumber}},[e.createTextVNode("Number")])])]),e.createVNode("input",{class:`value nativeV ${N?"isKey":""}`,value:k?n.value:n.key,onInput:C=>{const g=C.target.value;if(N){n.key=g;return}i.allowFilter&&n.isNumber?n.value=m.formatNumberInput(g,n.isArray,y.arraySplitSymbol):n.value=g}},null),e.createVNode("div",{class:"surSlot"},[r<a.depth?!N&&e.createVNode("button",{class:["success","bt"],onClick:()=>{k&&(n.value=[],n.isArray=void 0),n.value.push({rId:a.randomFun(),key:"",value:""})}},[a.newChildTxt(n)]):null])])]),e.createVNode("div",{class:"btn"},[e.createVNode("button",{class:["success","bt"],disabled:V!==x.length-1,onClick:()=>{l.push({rId:a.randomFun(),key:"",value:""})}},[e.createTextVNode("+")]),e.createVNode("button",{class:["danger","bt"],onClick:()=>{if(l.splice(V,1),l.length<1){if(c===void 0)return b([]);const C=t.value.findIndex(g=>g.rId===c?.rId);r<1?t.value.splice(C,1,{...c,value:""}):c.value=""}}},[e.createTextVNode("-")])]),Array.isArray(n.value)&&o(n.value,r+1,n)])})]);return e.watch(t,l=>{if(!a.isController)return;const r=b(l);u("update:modelValue",r),u("onMerge",r,e.toRaw(t.value))},{deep:!0}),f({onSet:l=>{t.value=s(l??a.modelValue)},getResult:(l="res")=>l==="ori"?e.toRaw(t.value):b(t.value)}),()=>e.createVNode("div",{class:a.dyCls??"dynamicCascadeForm"},[e.createVNode("div",{class:"dyFormList",style:{maxHeight:i.maxHeight}},[o(t.value)]),e.createVNode("div",{class:"control"},[!t.value.length&&e.createVNode("button",{class:["success","bt"],onClick:()=>{t.value.push({rId:a.randomFun(),key:"",value:""})}},[d.newTxt]),!a.isController&&e.createVNode(e.Fragment,null,[!i.hideReset&&e.createVNode("button",{class:["default","bt"],onClick:()=>{t.value=s(a.modelValue),u("onReset")}},[d.resetTxt]),e.createVNode("button",{class:["info","bt"],onClick:()=>{const l=b(t.value);u("update:modelValue",l),u("onMerge",l,e.toRaw(t.value)),t.value=s(l)}},[d.mergeTxt])])])])}});function h(a,u=!0){return a.map(f=>{const d=f;return d.value=m.ensureRef(f.value),u?e.shallowReactive(d):d})}function p(a){const u=()=>e.unref(a),f=(t,o)=>{u().forEach(l=>{const r=l.key;(!o||o.includes(r))&&(l.disabled=t)})},d=(t,o)=>{u().forEach(l=>{const r=l.key;(!o||o.includes(r))&&(l.hidden=t)})},i=(t,o)=>{const l=u().find(r=>r.key===t);l&&(e.isRef(l.value)?l.value.value=o:l.value=o)};return{setDisabled:f,setHidden:d,setValue:i,setValues:t=>{Object.entries(t).forEach(([o,l])=>{i(o,l)})},getValue:t=>u().find(o=>o.key===t),getValues:t=>{const o=t&&t.length?new Set(t):null;return u().reduce((l,r)=>{const c=r.key;if(!o||o.has(c)){const n=e.isRef(r.value)?r.value.value:r.value;l[c]=n}return l},{})},onReset:(t=null)=>{u().forEach(o=>{e.isRef(o.value)?o.value.value=t:o.value=t})}}}const F={install(a){a.component("DynamicInput",I),a.component("DynamicCascadeInput",S)}};exports.DynamicCascadeInput=S;exports.DynamicInput=I;exports.DynamicInputPlugin=F;exports.useDyForm=p;exports.useReactiveForm=h;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { t as p, r as V, f as T, p as L, s as M } from "./index-
|
|
3
|
-
const
|
|
1
|
+
import { defineComponent as R, ref as w, watch as N, toRaw as h, createVNode as n, createTextVNode as m, nextTick as j, Fragment as x, shallowReactive as O, unref as D, isRef as F } from "vue";
|
|
2
|
+
import { t as p, r as V, f as T, p as L, s as M, e as $ } from "./index-MF72-iEr.js";
|
|
3
|
+
const H = /* @__PURE__ */ R({
|
|
4
4
|
name: "DynamicInput",
|
|
5
5
|
props: {
|
|
6
6
|
size: {
|
|
@@ -39,7 +39,7 @@ const $ = /* @__PURE__ */ N({
|
|
|
39
39
|
emit: r,
|
|
40
40
|
expose: f
|
|
41
41
|
}) {
|
|
42
|
-
const
|
|
42
|
+
const d = {
|
|
43
43
|
resetTxt: "重置",
|
|
44
44
|
newTxt: "添加项",
|
|
45
45
|
mergeTxt: "合并",
|
|
@@ -50,23 +50,23 @@ const $ = /* @__PURE__ */ N({
|
|
|
50
50
|
autoScroll: !0,
|
|
51
51
|
allowFilter: !0,
|
|
52
52
|
...t.configs
|
|
53
|
-
},
|
|
53
|
+
}, y = {
|
|
54
54
|
arraySplitSymbol: ",",
|
|
55
55
|
...t.dyListConfigs
|
|
56
|
-
},
|
|
57
|
-
return
|
|
56
|
+
}, v = t.size, o = w(p(t.modelValue, t.randomFun, y.arraySplitSymbol)), b = w(null);
|
|
57
|
+
return N(o, (e) => {
|
|
58
58
|
if (!t.isController) return;
|
|
59
|
-
const u = V(e,
|
|
59
|
+
const u = V(e, y.arraySplitSymbol);
|
|
60
60
|
r("update:modelValue", u), r("onMerge", u, h(o.value));
|
|
61
61
|
}, {
|
|
62
62
|
deep: !0
|
|
63
63
|
}), f({
|
|
64
64
|
onSet: (e) => {
|
|
65
|
-
o.value = p(e ?? t.modelValue, t.randomFun,
|
|
65
|
+
o.value = p(e ?? t.modelValue, t.randomFun, y.arraySplitSymbol);
|
|
66
66
|
},
|
|
67
|
-
getResult: (e = "res") => e === "ori" ? h(o.value) : V(o.value,
|
|
67
|
+
getResult: (e = "res") => e === "ori" ? h(o.value) : V(o.value, y.arraySplitSymbol)
|
|
68
68
|
}), () => n("div", {
|
|
69
|
-
class: t.dyCls ?? `dynamicForm ${
|
|
69
|
+
class: t.dyCls ?? `dynamicForm ${v}`
|
|
70
70
|
}, [n("div", {
|
|
71
71
|
class: "dyFormList",
|
|
72
72
|
ref: b,
|
|
@@ -79,13 +79,13 @@ const $ = /* @__PURE__ */ N({
|
|
|
79
79
|
}, [n("div", {
|
|
80
80
|
class: "input"
|
|
81
81
|
}, [n("input", {
|
|
82
|
-
size:
|
|
82
|
+
size: v,
|
|
83
83
|
value: e.key,
|
|
84
84
|
class: "key nativeInput",
|
|
85
85
|
onInput: (s) => {
|
|
86
86
|
e.key = s.target.value;
|
|
87
87
|
}
|
|
88
|
-
}, null),
|
|
88
|
+
}, null), m(":"), n("div", {
|
|
89
89
|
class: "vInput"
|
|
90
90
|
}, [n("div", {
|
|
91
91
|
class: "slot"
|
|
@@ -94,23 +94,23 @@ const $ = /* @__PURE__ */ N({
|
|
|
94
94
|
onClick: () => {
|
|
95
95
|
e.isArray = !e.isArray;
|
|
96
96
|
}
|
|
97
|
-
}, [
|
|
97
|
+
}, [m("Array")]), m(" "), n("button", {
|
|
98
98
|
class: [e.isNumber ? "success" : "default", "small", "bt"],
|
|
99
99
|
onClick: () => {
|
|
100
100
|
e.isNumber = !e.isNumber;
|
|
101
101
|
}
|
|
102
|
-
}, [
|
|
103
|
-
size:
|
|
102
|
+
}, [m("Number")])]), n("input", {
|
|
103
|
+
size: v,
|
|
104
104
|
value: e.value,
|
|
105
105
|
class: "value nativeV",
|
|
106
106
|
onInput: (s) => {
|
|
107
107
|
const i = s.target.value;
|
|
108
|
-
c.allowFilter && e.isNumber ? e.value = T(i, e.isArray,
|
|
108
|
+
c.allowFilter && e.isNumber ? e.value = T(i, e.isArray, y.arraySplitSymbol) : e.value = i;
|
|
109
109
|
}
|
|
110
110
|
}, null)])]), n("div", {
|
|
111
111
|
class: "btn"
|
|
112
112
|
}, [n("button", {
|
|
113
|
-
class: [
|
|
113
|
+
class: [v, "success", "bt"],
|
|
114
114
|
disabled: u !== l.length - 1,
|
|
115
115
|
onClick: () => {
|
|
116
116
|
o.value.push({
|
|
@@ -125,15 +125,15 @@ const $ = /* @__PURE__ */ N({
|
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
-
}, [
|
|
129
|
-
class: ["danger",
|
|
128
|
+
}, [m("+")]), n("button", {
|
|
129
|
+
class: ["danger", v, "bt"],
|
|
130
130
|
onClick: () => {
|
|
131
131
|
o.value = o.value.filter((s) => s.rId !== e.rId);
|
|
132
132
|
}
|
|
133
|
-
}, [
|
|
133
|
+
}, [m("-")])])]))]), n("div", {
|
|
134
134
|
class: "control"
|
|
135
135
|
}, [!o.value.length && n("button", {
|
|
136
|
-
class: ["success",
|
|
136
|
+
class: ["success", v, "bt"],
|
|
137
137
|
onClick: () => {
|
|
138
138
|
o.value.push({
|
|
139
139
|
rId: t.randomFun(),
|
|
@@ -141,21 +141,21 @@ const $ = /* @__PURE__ */ N({
|
|
|
141
141
|
value: ""
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
|
-
}, [
|
|
145
|
-
class: ["default",
|
|
144
|
+
}, [d.newTxt]), !t.isController && n(x, null, [!c.hideReset && n("button", {
|
|
145
|
+
class: ["default", v, "bt"],
|
|
146
146
|
onClick: () => {
|
|
147
|
-
o.value = p(t.modelValue, t.randomFun,
|
|
147
|
+
o.value = p(t.modelValue, t.randomFun, y.arraySplitSymbol), r("onReset");
|
|
148
148
|
}
|
|
149
|
-
}, [
|
|
150
|
-
class: ["info",
|
|
149
|
+
}, [d.resetTxt]), n("button", {
|
|
150
|
+
class: ["info", v, "bt"],
|
|
151
151
|
onClick: () => {
|
|
152
152
|
o.value.sort((u, l) => +u.rId - +l.rId);
|
|
153
|
-
const e = V(o.value,
|
|
154
|
-
r("update:modelValue", e), r("onMerge", e, h(o.value)), o.value = p(e, t.randomFun,
|
|
153
|
+
const e = V(o.value, y.arraySplitSymbol);
|
|
154
|
+
r("update:modelValue", e), r("onMerge", e, h(o.value)), o.value = p(e, t.randomFun, y.arraySplitSymbol);
|
|
155
155
|
}
|
|
156
|
-
}, [
|
|
156
|
+
}, [d.mergeTxt])])])]);
|
|
157
157
|
}
|
|
158
|
-
}),
|
|
158
|
+
}), z = /* @__PURE__ */ R({
|
|
159
159
|
name: "DynamicCascadeInput",
|
|
160
160
|
props: {
|
|
161
161
|
modelValue: {
|
|
@@ -200,7 +200,7 @@ const $ = /* @__PURE__ */ N({
|
|
|
200
200
|
emit: r,
|
|
201
201
|
expose: f
|
|
202
202
|
}) {
|
|
203
|
-
const
|
|
203
|
+
const d = {
|
|
204
204
|
resetTxt: "重置",
|
|
205
205
|
newTxt: "添加项",
|
|
206
206
|
mergeTxt: "合并",
|
|
@@ -214,22 +214,22 @@ const $ = /* @__PURE__ */ N({
|
|
|
214
214
|
retractLen: 0,
|
|
215
215
|
borderColors: [],
|
|
216
216
|
...t.configs
|
|
217
|
-
},
|
|
217
|
+
}, y = {
|
|
218
218
|
arraySplitSymbol: ",",
|
|
219
219
|
...t.dyListConfigs
|
|
220
|
-
},
|
|
220
|
+
}, v = (l) => ["string", "number"].includes(l), o = (l) => Object.keys(l).map((s, i) => {
|
|
221
221
|
let a = l[s];
|
|
222
222
|
const g = Array.isArray(a), A = g ? a.every((S) => typeof S == "number") : typeof a == "number", C = a === null;
|
|
223
|
-
return
|
|
223
|
+
return v(typeof a) && (a = l[s]), C && (a = ""), {
|
|
224
224
|
rId: t.randomFun(i),
|
|
225
225
|
key: s,
|
|
226
|
-
value: Object.prototype.toString.call(a) === "[object Object]" ? o(l[s]) : g ? a.join(
|
|
226
|
+
value: Object.prototype.toString.call(a) === "[object Object]" ? o(l[s]) : g ? a.join(y.arraySplitSymbol) : a,
|
|
227
227
|
isArray: g || void 0,
|
|
228
228
|
isNumber: A || void 0
|
|
229
229
|
};
|
|
230
230
|
}), b = (l) => l.reduce((s, i) => {
|
|
231
231
|
const a = i.value;
|
|
232
|
-
return i.key.trim().length && (s[i.key] = Array.isArray(a) ? b(a) : L(i.value, i.isArray, i.isNumber,
|
|
232
|
+
return i.key.trim().length && (s[i.key] = Array.isArray(a) ? b(a) : L(i.value, i.isArray, i.isNumber, y.arraySplitSymbol)), s;
|
|
233
233
|
}, {}), e = w(o(t.modelValue)), u = (l, s = 1, i) => n("div", {
|
|
234
234
|
class: [`depth-${s}`, c.showBorder ? "" : "no-border", c.showPad ? "" : "no-pad"],
|
|
235
235
|
style: {
|
|
@@ -237,7 +237,7 @@ const $ = /* @__PURE__ */ N({
|
|
|
237
237
|
["--c" + [s]]: M(c.borderColors, s)
|
|
238
238
|
}
|
|
239
239
|
}, [l.map((a, g, A) => {
|
|
240
|
-
const C = Array.isArray(a.value), S =
|
|
240
|
+
const C = Array.isArray(a.value), S = v(typeof a.value);
|
|
241
241
|
return n("div", {
|
|
242
242
|
class: "dItem",
|
|
243
243
|
key: a.rId,
|
|
@@ -250,7 +250,7 @@ const $ = /* @__PURE__ */ N({
|
|
|
250
250
|
value: a.key,
|
|
251
251
|
class: "key nativeInput",
|
|
252
252
|
onInput: (I) => a.key = I.target.value
|
|
253
|
-
}, null),
|
|
253
|
+
}, null), m(":")]), n("div", {
|
|
254
254
|
class: "vInput"
|
|
255
255
|
}, [n("div", {
|
|
256
256
|
class: "slot"
|
|
@@ -259,12 +259,12 @@ const $ = /* @__PURE__ */ N({
|
|
|
259
259
|
onClick: () => {
|
|
260
260
|
a.isArray = !a.isArray;
|
|
261
261
|
}
|
|
262
|
-
}, [
|
|
262
|
+
}, [m("Array")]), m(" "), n("button", {
|
|
263
263
|
class: [a.isNumber ? "success" : "default", "small", "bt"],
|
|
264
264
|
onClick: () => {
|
|
265
265
|
a.isNumber = !a.isNumber;
|
|
266
266
|
}
|
|
267
|
-
}, [
|
|
267
|
+
}, [m("Number")])])]), n("input", {
|
|
268
268
|
class: `value nativeV ${C ? "isKey" : ""}`,
|
|
269
269
|
value: S ? a.value : a.key,
|
|
270
270
|
onInput: (I) => {
|
|
@@ -273,7 +273,7 @@ const $ = /* @__PURE__ */ N({
|
|
|
273
273
|
a.key = k;
|
|
274
274
|
return;
|
|
275
275
|
}
|
|
276
|
-
c.allowFilter && a.isNumber ? a.value = T(k, a.isArray,
|
|
276
|
+
c.allowFilter && a.isNumber ? a.value = T(k, a.isArray, y.arraySplitSymbol) : a.value = k;
|
|
277
277
|
}
|
|
278
278
|
}, null), n("div", {
|
|
279
279
|
class: "surSlot"
|
|
@@ -298,7 +298,7 @@ const $ = /* @__PURE__ */ N({
|
|
|
298
298
|
value: ""
|
|
299
299
|
});
|
|
300
300
|
}
|
|
301
|
-
}, [
|
|
301
|
+
}, [m("+")]), n("button", {
|
|
302
302
|
class: ["danger", "bt"],
|
|
303
303
|
onClick: () => {
|
|
304
304
|
if (l.splice(g, 1), l.length < 1) {
|
|
@@ -310,9 +310,9 @@ const $ = /* @__PURE__ */ N({
|
|
|
310
310
|
}) : i.value = "";
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
|
-
}, [
|
|
313
|
+
}, [m("-")])]), Array.isArray(a.value) && u(a.value, s + 1, a)]);
|
|
314
314
|
})]);
|
|
315
|
-
return
|
|
315
|
+
return N(e, (l) => {
|
|
316
316
|
if (!t.isController) return;
|
|
317
317
|
const s = b(l);
|
|
318
318
|
r("update:modelValue", s), r("onMerge", s, h(e.value));
|
|
@@ -341,30 +341,33 @@ const $ = /* @__PURE__ */ N({
|
|
|
341
341
|
value: ""
|
|
342
342
|
});
|
|
343
343
|
}
|
|
344
|
-
}, [
|
|
344
|
+
}, [d.newTxt]), !t.isController && n(x, null, [!c.hideReset && n("button", {
|
|
345
345
|
class: ["default", "bt"],
|
|
346
346
|
onClick: () => {
|
|
347
347
|
e.value = o(t.modelValue), r("onReset");
|
|
348
348
|
}
|
|
349
|
-
}, [
|
|
349
|
+
}, [d.resetTxt]), n("button", {
|
|
350
350
|
class: ["info", "bt"],
|
|
351
351
|
onClick: () => {
|
|
352
352
|
const l = b(e.value);
|
|
353
353
|
r("update:modelValue", l), r("onMerge", l, h(e.value)), e.value = o(l);
|
|
354
354
|
}
|
|
355
|
-
}, [
|
|
355
|
+
}, [d.mergeTxt])])])]);
|
|
356
356
|
}
|
|
357
357
|
});
|
|
358
|
-
function
|
|
359
|
-
return
|
|
358
|
+
function P(t, r = !0) {
|
|
359
|
+
return t.map((f) => {
|
|
360
|
+
const d = f;
|
|
361
|
+
return d.value = $(f.value), r ? O(d) : d;
|
|
362
|
+
});
|
|
360
363
|
}
|
|
361
|
-
function
|
|
364
|
+
function q(t) {
|
|
362
365
|
const r = () => D(t), f = (e, u) => {
|
|
363
366
|
r().forEach((l) => {
|
|
364
367
|
const s = l.key;
|
|
365
368
|
(!u || u.includes(s)) && (l.disabled = e);
|
|
366
369
|
});
|
|
367
|
-
},
|
|
370
|
+
}, d = (e, u) => {
|
|
368
371
|
r().forEach((l) => {
|
|
369
372
|
const s = l.key;
|
|
370
373
|
(!u || u.includes(s)) && (l.hidden = e);
|
|
@@ -373,7 +376,7 @@ function P(t) {
|
|
|
373
376
|
const l = r().find((s) => s.key === e);
|
|
374
377
|
l && (F(l.value) ? l.value.value = u : l.value = u);
|
|
375
378
|
};
|
|
376
|
-
return { setDisabled: f, setHidden:
|
|
379
|
+
return { setDisabled: f, setHidden: d, setValue: c, setValues: (e) => {
|
|
377
380
|
Object.entries(e).forEach(([u, l]) => {
|
|
378
381
|
c(u, l);
|
|
379
382
|
});
|
|
@@ -393,15 +396,15 @@ function P(t) {
|
|
|
393
396
|
});
|
|
394
397
|
} };
|
|
395
398
|
}
|
|
396
|
-
const
|
|
399
|
+
const _ = {
|
|
397
400
|
install(t) {
|
|
398
|
-
t.component("DynamicInput",
|
|
401
|
+
t.component("DynamicInput", H), t.component("DynamicCascadeInput", z);
|
|
399
402
|
}
|
|
400
403
|
};
|
|
401
404
|
export {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
405
|
+
z as DynamicCascadeInput,
|
|
406
|
+
H as DynamicInput,
|
|
407
|
+
_ as DynamicInputPlugin,
|
|
408
|
+
q as useDyForm,
|
|
409
|
+
P as useReactiveForm
|
|
407
410
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DyFormItem } from '../../types/form';
|
|
2
|
+
export type RenderType = "renderInput" | "renderSelect" | "renderPopSelect" | "renderTreeSelect" | "renderRadioGroup" | "renderRadioButtonGroup" | "renderCheckboxGroup" | "renderSwitch" | "renderDatePicker" | "renderTimePicker";
|
|
3
|
+
export type DecorateDyFormItem<Row extends Record<string, any>, RuleT = any> = Omit<DyFormItem<Row, RuleT>, "value"> & {
|
|
4
|
+
value: DyFormItem<Row, RuleT>["value"] | any | null;
|
|
5
|
+
renderType?: RenderType;
|
|
6
|
+
renderProps?: Record<string, any>;
|
|
7
|
+
};
|
|
8
|
+
export declare function useDecorateForm<Row extends Record<string, any>, RuleT = any>(items: DecorateDyFormItem<Row, RuleT>[], isReactive?: boolean): DyFormItem<Row, RuleT>[];
|
|
@@ -3,7 +3,7 @@ import { Value as DatePickerValue } from 'naive-ui/lib/date-picker/src/interface
|
|
|
3
3
|
import { SelectGroupOption, Value as SelectValue } from 'naive-ui/lib/select/src/interface';
|
|
4
4
|
import { TreeSelectOption, Value } from 'naive-ui/lib/tree-select/src/interface';
|
|
5
5
|
import { AllowedComponentProps, Ref, VNode } from 'vue';
|
|
6
|
-
import { DyFormItem } from '../../types/form
|
|
6
|
+
import { DyFormItem } from '../../types/form';
|
|
7
7
|
export declare function renderInput(model: Ref<string>, optionProps?: InputProps | AllowedComponentProps, rf?: DyFormItem): VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
8
8
|
[key: string]: any;
|
|
9
9
|
}>;
|