@vunk/form 2.19.10 → 2.19.11
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),y=require("@vunk/form/components/form-item"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),y=require("@vunk/form/components/form-item"),N=require("@vunk/form/composables"),n=require("element-plus"),s=require("@vunk/core"),q=require("@vunk/form/components/templates-default"),w=require("@vunk/form/components/template-instances-provider"),T=require("@vunk/form/components/fieldset"),I=require("@vunk/form/components/form-item-renderer"),E=require("@vunk/form/components/renderer-data"),A=require("@vunk/form/composables/element-plus"),v=require("@vunk/shared/function"),F=require("../index-DSyxYMB0.js"),f=require("../cloneDeep-DaYwfXwD.js"),b={...y._VkfFormItemCtx.props,columns:{type:Array,default:()=>[]},modelValue:{type:Array,default:()=>[]},readonly:{type:Boolean,default:void 0},splicable:{type:Boolean,default:!0},slots:{type:Object,default:()=>({})},labelActions:{type:Boolean,default:!1},defaultItemValue:{type:[Object,Function],default:()=>({})},keepLast:{type:Boolean,default:!1},topSplicable:{type:Boolean,default:!0},cardProps:{type:Object,default:()=>({})},fieldsetProps:{type:Object,default:()=>({})}},P={"update:modelValue":null},j={key:0,class:"vkf-card-input-collection-options"},O={class:"vkf-card-input-collection-card__footer"},$=e.defineComponent({inheritAttrs:!1,__name:"core",props:b,emits:P,setup(c,{emit:m}){const l=c,u=m,g=y._VkfFormItemCtx.createBindProps(l),d=N.useComputedReadonly(l),{tr:p}=A.useLocale(),i=e.computed(()=>{if(!l.prop||l.prop.length===0)return l.modelValue;const t={};return s.ensetData(t,{k:l.prop,v:l.modelValue}),t});function V(t){const o=f.cloneDeep(l.modelValue),a=v.isCallable(l.defaultItemValue)?l.defaultItemValue():l.defaultItemValue;o.splice(t+1,0,f.cloneDeep(a)),u("update:modelValue",o)}function h(t){const o=f.cloneDeep(l.modelValue);o.splice(t,1),u("update:modelValue",o)}const D=t=>{const o=f.cloneDeep(i.value);s.ensetData(o,t),u("update:modelValue",s.getValue(o,l.prop))};function S(t){return l.columns.map(o=>{var C;const a=[l.prop??[],t].flat(),k=[a,o.prop].flat(),r={readonly:d.value,...o,prop:k};Reflect.deleteProperty(r,"createTemplateProps"),v.isCallable(o.templateProps)&&(r.templateProps=()=>o.templateProps(s.getValue(i.value,a)));const _=((C=o.createTemplateProps)==null?void 0:C.call(o,{$index:t,row:s.getValue(i.value,a)},r))??{};return Object.assign(r,_),r})}return(t,o)=>(e.openBlock(),e.createBlock(e.unref(w.VkfTemplateInstancesProvider),null,{placeholder:e.withCtx(()=>[e.createVNode(e.unref(q.VkfTemplatesDefault))]),default:e.withCtx(()=>[e.createVNode(e.unref(y.VkfFormItem),e.mergeProps({class:"vkf-card-input-collection"},{...e.unref(g),...t.$attrs}),e.createSlots({default:e.withCtx(()=>{var a;return[!e.unref(d)&&t.splicable&&!t.labelActions&&t.topSplicable?(e.openBlock(),e.createElementBlock("div",j,[e.createVNode(e.unref(n.ElButton),{type:"primary",onClick:o[1]||(o[1]=k=>V(-1))},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(p)("vkf.common.add","添加")),1)]),_:1})])):e.createCommentVNode("",!0),(a=t.modelValue)!=null&&a.length?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(e.unref(n.ElEmpty),{key:1,class:"vkf-card-input-collection-empty"},{image:e.withCtx(()=>[...o[2]||(o[2]=[e.createTextVNode(e.toDisplayString(""),-1)])]),_:1})),e.createVNode(e.unref(E.VkfRendererData),{data:i.value,onSetData:D},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.modelValue,(k,r)=>(e.openBlock(),e.createBlock(e.unref(n.ElCard),e.mergeProps({key:r,class:"vkf-card-input-collection-card"},{ref_for:!0},t.cardProps),e.createSlots({default:e.withCtx(()=>[e.createVNode(e.unref(T.VkfFieldset),e.mergeProps({ref_for:!0},t.fieldsetProps),{default:e.withCtx(()=>[e.createVNode(e.unref(I.VkfFormItemRenderer),{source:S(r)},null,8,["source"])]),_:2},1040)]),_:2},[!e.unref(d)&&t.splicable?{name:"footer",fn:e.withCtx(()=>[e.createElementVNode("div",O,[e.renderSlot(t.$slots,"footerActions"),e.createVNode(e.unref(n.ElButton),{type:"primary",onClick:()=>V(r)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(p)("vkf.common.add","添加")),1)]),_:1},8,["onClick"]),e.createVNode(e.unref(n.ElButton),{type:"danger",disabled:t.modelValue.length<=1&&l.keepLast,onClick:()=>h(r)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(p)("vkf.common.delete","删除")),1)]),_:1},8,["disabled","onClick"])])]),key:"0"}:void 0]),1040))),128))]),_:3},8,["data"])]}),_:2},[t.labelActions?{name:"labelActions",fn:e.withCtx(()=>[e.renderSlot(t.$slots,"labelActions"),!e.unref(d)&&t.splicable&&t.topSplicable?(e.openBlock(),e.createBlock(e.unref(n.ElButton),{key:0,size:"small",icon:e.unref(F.plus_default),onClick:o[0]||(o[0]=a=>V(-1))},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(p)("vkf.common.add","添加")),1)]),_:1},8,["icon"])):e.createCommentVNode("",!0)]),key:"0"}:void 0]),1040)]),_:3}))}}),B=e.defineComponent({name:"VkfCardInputCollection",props:b,emits:P,setup(c,{slots:m,emit:l}){return()=>e.h($,{...c,"onUpdate:modelValue":u=>l("update:modelValue",u)},{...c.slots,...m})}}),x=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));exports.VkfCardInputCollection=B;exports.__VkfCardInputCollection=x;exports.default=B;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { _VkfFormItemCtx as
|
|
1
|
+
import { defineComponent as I, computed as z, openBlock as s, createBlock as y, unref as o, withCtx as a, createVNode as p, mergeProps as _, createSlots as A, createElementBlock as h, createTextVNode as u, toDisplayString as c, createCommentVNode as g, Fragment as M, renderList as U, createElementVNode as q, renderSlot as D, h as G } from "vue";
|
|
2
|
+
import { _VkfFormItemCtx as O, VkfFormItem as H } from "@vunk/form/components/form-item";
|
|
3
3
|
import { useComputedReadonly as J } from "@vunk/form/composables";
|
|
4
4
|
import { ElButton as V, ElEmpty as K, ElCard as Q } from "element-plus";
|
|
5
|
-
import { ensetData as
|
|
5
|
+
import { ensetData as F, getValue as B } from "@vunk/core";
|
|
6
6
|
import { VkfTemplatesDefault as W } from "@vunk/form/components/templates-default";
|
|
7
7
|
import { VkfTemplateInstancesProvider as X } from "@vunk/form/components/template-instances-provider";
|
|
8
8
|
import { VkfFieldset as Y } from "@vunk/form/components/fieldset";
|
|
9
9
|
import { VkfFormItemRenderer as Z } from "@vunk/form/components/form-item-renderer";
|
|
10
10
|
import { VkfRendererData as x } from "@vunk/form/components/renderer-data";
|
|
11
11
|
import { useLocale as ee } from "@vunk/form/composables/element-plus";
|
|
12
|
-
import { isCallable as
|
|
12
|
+
import { isCallable as j } from "@vunk/shared/function";
|
|
13
13
|
import { p as te } from "../index-BCZuzyeO.mjs";
|
|
14
14
|
import { c as v } from "../cloneDeep-DE0l40hv.mjs";
|
|
15
|
-
const
|
|
16
|
-
...
|
|
15
|
+
const T = {
|
|
16
|
+
...O.props,
|
|
17
17
|
columns: {
|
|
18
18
|
type: Array,
|
|
19
19
|
default: () => []
|
|
@@ -77,43 +77,43 @@ const O = {
|
|
|
77
77
|
type: Object,
|
|
78
78
|
default: () => ({})
|
|
79
79
|
}
|
|
80
|
-
},
|
|
80
|
+
}, $ = {
|
|
81
81
|
"update:modelValue": null
|
|
82
82
|
}, oe = {
|
|
83
83
|
key: 0,
|
|
84
84
|
class: "vkf-card-input-collection-options"
|
|
85
|
-
}, le = { class: "vkf-card-input-collection-card__footer" }, ae = /* @__PURE__ */
|
|
85
|
+
}, le = { class: "vkf-card-input-collection-card__footer" }, ae = /* @__PURE__ */ I({
|
|
86
86
|
inheritAttrs: !1,
|
|
87
87
|
__name: "core",
|
|
88
|
-
props:
|
|
89
|
-
emits:
|
|
88
|
+
props: T,
|
|
89
|
+
emits: $,
|
|
90
90
|
setup(i, { emit: b }) {
|
|
91
|
-
const l = i, d = b, E =
|
|
91
|
+
const l = i, d = b, E = O.createBindProps(l), m = J(l), { tr: f } = ee(), k = z(() => {
|
|
92
92
|
if (!l.prop || l.prop.length === 0)
|
|
93
93
|
return l.modelValue;
|
|
94
94
|
const e = {};
|
|
95
|
-
return
|
|
95
|
+
return F(e, {
|
|
96
96
|
k: l.prop,
|
|
97
97
|
v: l.modelValue
|
|
98
98
|
}), e;
|
|
99
99
|
});
|
|
100
100
|
function C(e) {
|
|
101
|
-
const t = v(l.modelValue), n =
|
|
101
|
+
const t = v(l.modelValue), n = j(l.defaultItemValue) ? l.defaultItemValue() : l.defaultItemValue;
|
|
102
102
|
t.splice(
|
|
103
103
|
e + 1,
|
|
104
104
|
0,
|
|
105
105
|
v(n)
|
|
106
106
|
), d("update:modelValue", t);
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function L(e) {
|
|
109
109
|
const t = v(l.modelValue);
|
|
110
110
|
t.splice(e, 1), d("update:modelValue", t);
|
|
111
111
|
}
|
|
112
|
-
const
|
|
112
|
+
const N = (e) => {
|
|
113
113
|
const t = v(k.value);
|
|
114
|
-
|
|
114
|
+
F(t, e), d("update:modelValue", B(t, l.prop));
|
|
115
115
|
};
|
|
116
|
-
function
|
|
116
|
+
function R(e) {
|
|
117
117
|
return l.columns.map((t) => {
|
|
118
118
|
var S;
|
|
119
119
|
const n = [
|
|
@@ -124,10 +124,10 @@ const O = {
|
|
|
124
124
|
...t,
|
|
125
125
|
prop: P
|
|
126
126
|
};
|
|
127
|
-
Reflect.deleteProperty(r, "createTemplateProps"),
|
|
127
|
+
Reflect.deleteProperty(r, "createTemplateProps"), j(t.templateProps) && (r.templateProps = () => t.templateProps(
|
|
128
128
|
B(k.value, n)
|
|
129
129
|
));
|
|
130
|
-
const
|
|
130
|
+
const w = ((S = t.createTemplateProps) == null ? void 0 : S.call(
|
|
131
131
|
t,
|
|
132
132
|
{
|
|
133
133
|
$index: e,
|
|
@@ -135,7 +135,7 @@ const O = {
|
|
|
135
135
|
},
|
|
136
136
|
r
|
|
137
137
|
)) ?? {};
|
|
138
|
-
return Object.assign(r,
|
|
138
|
+
return Object.assign(r, w), r;
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
141
|
return (e, t) => (s(), y(o(X), null, {
|
|
@@ -146,11 +146,11 @@ const O = {
|
|
|
146
146
|
p(o(H), _({ class: "vkf-card-input-collection" }, {
|
|
147
147
|
...o(E),
|
|
148
148
|
...e.$attrs
|
|
149
|
-
}),
|
|
149
|
+
}), A({
|
|
150
150
|
default: a(() => {
|
|
151
151
|
var n;
|
|
152
152
|
return [
|
|
153
|
-
!o(m) && e.splicable && !e.labelActions && e.topSplicable ? (s(),
|
|
153
|
+
!o(m) && e.splicable && !e.labelActions && e.topSplicable ? (s(), h("div", oe, [
|
|
154
154
|
p(o(V), {
|
|
155
155
|
type: "primary",
|
|
156
156
|
onClick: t[1] || (t[1] = (P) => C(-1))
|
|
@@ -172,18 +172,18 @@ const O = {
|
|
|
172
172
|
})),
|
|
173
173
|
p(o(x), {
|
|
174
174
|
data: k.value,
|
|
175
|
-
onSetData:
|
|
175
|
+
onSetData: N
|
|
176
176
|
}, {
|
|
177
177
|
default: a(() => [
|
|
178
|
-
(s(!0),
|
|
178
|
+
(s(!0), h(M, null, U(e.modelValue, (P, r) => (s(), y(o(Q), _({
|
|
179
179
|
key: r,
|
|
180
180
|
class: "vkf-card-input-collection-card"
|
|
181
|
-
}, { ref_for: !0 }, e.cardProps),
|
|
181
|
+
}, { ref_for: !0 }, e.cardProps), A({
|
|
182
182
|
default: a(() => [
|
|
183
183
|
p(o(Y), _({ ref_for: !0 }, e.fieldsetProps), {
|
|
184
184
|
default: a(() => [
|
|
185
185
|
p(o(Z), {
|
|
186
|
-
source:
|
|
186
|
+
source: R(r)
|
|
187
187
|
}, null, 8, ["source"])
|
|
188
188
|
]),
|
|
189
189
|
_: 2
|
|
@@ -194,7 +194,8 @@ const O = {
|
|
|
194
194
|
!o(m) && e.splicable ? {
|
|
195
195
|
name: "footer",
|
|
196
196
|
fn: a(() => [
|
|
197
|
-
|
|
197
|
+
q("div", le, [
|
|
198
|
+
D(e.$slots, "footerActions"),
|
|
198
199
|
p(o(V), {
|
|
199
200
|
type: "primary",
|
|
200
201
|
onClick: () => C(r)
|
|
@@ -207,7 +208,7 @@ const O = {
|
|
|
207
208
|
p(o(V), {
|
|
208
209
|
type: "danger",
|
|
209
210
|
disabled: e.modelValue.length <= 1 && l.keepLast,
|
|
210
|
-
onClick: () =>
|
|
211
|
+
onClick: () => L(r)
|
|
211
212
|
}, {
|
|
212
213
|
default: a(() => [
|
|
213
214
|
u(c(o(f)("vkf.common.delete", "删除")), 1)
|
|
@@ -220,7 +221,7 @@ const O = {
|
|
|
220
221
|
} : void 0
|
|
221
222
|
]), 1040))), 128))
|
|
222
223
|
]),
|
|
223
|
-
_:
|
|
224
|
+
_: 3
|
|
224
225
|
}, 8, ["data"])
|
|
225
226
|
];
|
|
226
227
|
}),
|
|
@@ -229,7 +230,7 @@ const O = {
|
|
|
229
230
|
e.labelActions ? {
|
|
230
231
|
name: "labelActions",
|
|
231
232
|
fn: a(() => [
|
|
232
|
-
|
|
233
|
+
D(e.$slots, "labelActions"),
|
|
233
234
|
!o(m) && e.splicable && e.topSplicable ? (s(), y(o(V), {
|
|
234
235
|
key: 0,
|
|
235
236
|
size: "small",
|
|
@@ -249,10 +250,10 @@ const O = {
|
|
|
249
250
|
_: 3
|
|
250
251
|
}));
|
|
251
252
|
}
|
|
252
|
-
}), be =
|
|
253
|
+
}), be = I({
|
|
253
254
|
name: "VkfCardInputCollection",
|
|
254
|
-
props:
|
|
255
|
-
emits:
|
|
255
|
+
props: T,
|
|
256
|
+
emits: $,
|
|
256
257
|
setup(i, { slots: b, emit: l }) {
|
|
257
258
|
return () => G(ae, {
|
|
258
259
|
...i,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { NormalObject } from '@vunk/shared';
|
|
2
2
|
import { VkfFieldset } from '@vunk/form/components/fieldset';
|
|
3
|
-
declare var __VLS_21: {};
|
|
3
|
+
declare var __VLS_21: {}, __VLS_72: {};
|
|
4
4
|
type __VLS_Slots = {} & {
|
|
5
5
|
labelActions?: (props: typeof __VLS_21) => any;
|
|
6
|
+
} & {
|
|
7
|
+
footerActions?: (props: typeof __VLS_72) => any;
|
|
6
8
|
};
|
|
7
9
|
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
8
10
|
columns: {
|