@vunk/form 2.5.7 → 2.5.9
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/components/input-collection/index.cjs +41 -26
- package/components/input-collection/index.css +3 -3
- package/components/input-collection/index.mjs +41 -26
- package/components/input-collection/src/ctx.d.ts +7 -0
- package/components/input-collection/src/index.vue.d.ts +12 -3
- package/components/input-collection/src/types.d.ts +10 -7
- package/index.css +3 -3
- package/package.json +1 -1
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var vue = require('vue');
|
|
6
|
+
var index = require('../index2.cjs');
|
|
7
|
+
var core = require('@vunk/core');
|
|
8
|
+
var fieldset = require('@vunk/form/components/fieldset');
|
|
6
9
|
var formItem = require('@vunk/form/components/form-item');
|
|
7
|
-
var tableColumns = require('@vunk/plus/components/table-columns');
|
|
8
|
-
var elementPlus = require('element-plus');
|
|
9
|
-
var composables = require('@vunk/form/composables');
|
|
10
|
-
var templatesDefault = require('@vunk/form/components/templates-default');
|
|
11
|
-
var templateInstancesProvider = require('@vunk/form/components/template-instances-provider');
|
|
12
10
|
var formItemRenderer = require('@vunk/form/components/form-item-renderer');
|
|
13
|
-
var core = require('@vunk/core');
|
|
14
|
-
var index = require('../index2.cjs');
|
|
15
11
|
var rendererData = require('@vunk/form/components/renderer-data');
|
|
16
|
-
var
|
|
12
|
+
var templateInstancesProvider = require('@vunk/form/components/template-instances-provider');
|
|
13
|
+
var templatesDefault = require('@vunk/form/components/templates-default');
|
|
14
|
+
var composables = require('@vunk/form/composables');
|
|
15
|
+
var tableColumns = require('@vunk/plus/components/table-columns');
|
|
16
|
+
var elementPlus = require('element-plus');
|
|
17
17
|
var cloneDeep = require('../cloneDeep.cjs');
|
|
18
18
|
var _pluginVue_exportHelper = require('../_plugin-vue_export-helper.cjs');
|
|
19
19
|
require('../isObject.cjs');
|
|
@@ -61,6 +61,13 @@ const props = {
|
|
|
61
61
|
defaultExpandAll: {
|
|
62
62
|
type: Boolean,
|
|
63
63
|
default: false
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* @description 添加记录时的默认值
|
|
67
|
+
*/
|
|
68
|
+
defaultItemValue: {
|
|
69
|
+
type: Object,
|
|
70
|
+
default: () => ({})
|
|
64
71
|
}
|
|
65
72
|
};
|
|
66
73
|
const emits = {
|
|
@@ -100,15 +107,21 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
100
107
|
return props2.columns.map(column => {
|
|
101
108
|
return {
|
|
102
109
|
...column,
|
|
103
|
-
slots: e =>
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
110
|
+
slots: e => {
|
|
111
|
+
const prop = [props2.prop ?? [], e.$index, column.prop].flat();
|
|
112
|
+
const formItemProps = {
|
|
113
|
+
prop,
|
|
107
114
|
readonly: readonly.value,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
115
|
+
templateType: column.templateType,
|
|
116
|
+
templateProps: column.templateProps
|
|
117
|
+
};
|
|
118
|
+
return vue.createVNode(formItemRenderer.VkfFormItemRenderer, {
|
|
119
|
+
"source": [{
|
|
120
|
+
...formItemProps,
|
|
121
|
+
...column.createTemplateProps?.(e, formItemProps)
|
|
122
|
+
}]
|
|
123
|
+
}, null);
|
|
124
|
+
}
|
|
112
125
|
};
|
|
113
126
|
});
|
|
114
127
|
});
|
|
@@ -117,14 +130,16 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
117
130
|
type: "expand",
|
|
118
131
|
slots: e => {
|
|
119
132
|
const source = expandFormItemRaws.value.map(column => {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
templateType: column.templateType,
|
|
133
|
+
const prop = [props2.prop ?? [], e.$index, column.prop].flat();
|
|
134
|
+
const formItemProps = {
|
|
135
|
+
prop,
|
|
124
136
|
readonly: readonly.value,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
137
|
+
templateType: column.templateType,
|
|
138
|
+
templateProps: column.templateProps
|
|
139
|
+
};
|
|
140
|
+
return {
|
|
141
|
+
...formItemProps,
|
|
142
|
+
...column.createTemplateProps?.(e, formItemProps)
|
|
128
143
|
};
|
|
129
144
|
});
|
|
130
145
|
return vue.createVNode(fieldset.VkfFieldset, {
|
|
@@ -167,7 +182,7 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
167
182
|
});
|
|
168
183
|
function handlePlus(index) {
|
|
169
184
|
const data = cloneDeep.cloneDeep(props2.modelValue);
|
|
170
|
-
data.splice(index + 1, 0,
|
|
185
|
+
data.splice(index + 1, 0, cloneDeep.cloneDeep(props2.defaultItemValue));
|
|
171
186
|
emit("update:modelValue", data);
|
|
172
187
|
setExpandRowKeys([]);
|
|
173
188
|
}
|
|
@@ -178,7 +193,7 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
178
193
|
setExpandRowKeys([]);
|
|
179
194
|
}
|
|
180
195
|
const addToFirst = () => {
|
|
181
|
-
emit("update:modelValue", [
|
|
196
|
+
emit("update:modelValue", [cloneDeep.cloneDeep(props2.defaultItemValue), ...(props2.modelValue ?? [])]);
|
|
182
197
|
setExpandRowKeys([]);
|
|
183
198
|
};
|
|
184
199
|
const handleFormSetData = e => {
|
|
@@ -191,7 +206,7 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
191
206
|
return props2.modelValue?.map((e, index) => {
|
|
192
207
|
return {
|
|
193
208
|
...e,
|
|
194
|
-
[ROW_KEY]: index
|
|
209
|
+
[ROW_KEY]: `${index}`
|
|
195
210
|
};
|
|
196
211
|
});
|
|
197
212
|
});
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
.vkf-input-collection-table .vkf-form-item {
|
|
10
10
|
margin-bottom: 0;
|
|
11
11
|
}
|
|
12
|
-
.vkf-input-collection-table .vk-input-collection__expand-form-item {
|
|
13
|
-
margin-bottom: 18px;
|
|
14
|
-
}
|
|
15
12
|
.vk-input-collection__expand-fieldset{
|
|
16
13
|
padding: 8px;
|
|
17
14
|
}
|
|
15
|
+
.vk-input-collection__expand-fieldset .vkf-form-item{
|
|
16
|
+
margin-bottom: 18px;
|
|
17
|
+
}
|
|
18
18
|
.vk-input-collection__buttons .cell{
|
|
19
19
|
padding: 0;
|
|
20
20
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { defineComponent, computed, createVNode, Fragment, ref, resolveComponent, openBlock, createBlock, withCtx, normalizeProps, guardReactiveProps, createSlots, createElementBlock, createTextVNode, createCommentVNode, renderSlot } from 'vue';
|
|
2
|
+
import { p as plus_default, b as minus_default } from '../index2.mjs';
|
|
3
|
+
import { ensetData, getValue } from '@vunk/core';
|
|
4
|
+
import { VkfFieldset } from '@vunk/form/components/fieldset';
|
|
2
5
|
import { _VkfFormItemCtx, VkfFormItem } from '@vunk/form/components/form-item';
|
|
3
|
-
import { VkTableColumns } from '@vunk/plus/components/table-columns';
|
|
4
|
-
import { ElTable, ElButton } from 'element-plus';
|
|
5
|
-
import { useComputedReadonly } from '@vunk/form/composables';
|
|
6
|
-
import { VkfTemplatesDefault } from '@vunk/form/components/templates-default';
|
|
7
|
-
import { VkfTemplateInstancesProvider } from '@vunk/form/components/template-instances-provider';
|
|
8
6
|
import { VkfFormItemRenderer } from '@vunk/form/components/form-item-renderer';
|
|
9
|
-
import { ensetData, getValue } from '@vunk/core';
|
|
10
|
-
import { p as plus_default, b as minus_default } from '../index2.mjs';
|
|
11
7
|
import { VkfRendererData } from '@vunk/form/components/renderer-data';
|
|
12
|
-
import {
|
|
8
|
+
import { VkfTemplateInstancesProvider } from '@vunk/form/components/template-instances-provider';
|
|
9
|
+
import { VkfTemplatesDefault } from '@vunk/form/components/templates-default';
|
|
10
|
+
import { useComputedReadonly } from '@vunk/form/composables';
|
|
11
|
+
import { VkTableColumns } from '@vunk/plus/components/table-columns';
|
|
12
|
+
import { ElTable, ElButton } from 'element-plus';
|
|
13
13
|
import { c as cloneDeep } from '../cloneDeep.mjs';
|
|
14
14
|
import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
|
|
15
15
|
import '../isObject.mjs';
|
|
@@ -57,6 +57,13 @@ const props = {
|
|
|
57
57
|
defaultExpandAll: {
|
|
58
58
|
type: Boolean,
|
|
59
59
|
default: false
|
|
60
|
+
},
|
|
61
|
+
/**
|
|
62
|
+
* @description 添加记录时的默认值
|
|
63
|
+
*/
|
|
64
|
+
defaultItemValue: {
|
|
65
|
+
type: Object,
|
|
66
|
+
default: () => ({})
|
|
60
67
|
}
|
|
61
68
|
};
|
|
62
69
|
const emits = {
|
|
@@ -96,15 +103,21 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
96
103
|
return props2.columns.map(column => {
|
|
97
104
|
return {
|
|
98
105
|
...column,
|
|
99
|
-
slots: e =>
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
106
|
+
slots: e => {
|
|
107
|
+
const prop = [props2.prop ?? [], e.$index, column.prop].flat();
|
|
108
|
+
const formItemProps = {
|
|
109
|
+
prop,
|
|
103
110
|
readonly: readonly.value,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
111
|
+
templateType: column.templateType,
|
|
112
|
+
templateProps: column.templateProps
|
|
113
|
+
};
|
|
114
|
+
return createVNode(VkfFormItemRenderer, {
|
|
115
|
+
"source": [{
|
|
116
|
+
...formItemProps,
|
|
117
|
+
...column.createTemplateProps?.(e, formItemProps)
|
|
118
|
+
}]
|
|
119
|
+
}, null);
|
|
120
|
+
}
|
|
108
121
|
};
|
|
109
122
|
});
|
|
110
123
|
});
|
|
@@ -113,14 +126,16 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
113
126
|
type: "expand",
|
|
114
127
|
slots: e => {
|
|
115
128
|
const source = expandFormItemRaws.value.map(column => {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
templateType: column.templateType,
|
|
129
|
+
const prop = [props2.prop ?? [], e.$index, column.prop].flat();
|
|
130
|
+
const formItemProps = {
|
|
131
|
+
prop,
|
|
120
132
|
readonly: readonly.value,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
133
|
+
templateType: column.templateType,
|
|
134
|
+
templateProps: column.templateProps
|
|
135
|
+
};
|
|
136
|
+
return {
|
|
137
|
+
...formItemProps,
|
|
138
|
+
...column.createTemplateProps?.(e, formItemProps)
|
|
124
139
|
};
|
|
125
140
|
});
|
|
126
141
|
return createVNode(VkfFieldset, {
|
|
@@ -163,7 +178,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
163
178
|
});
|
|
164
179
|
function handlePlus(index) {
|
|
165
180
|
const data = cloneDeep(props2.modelValue);
|
|
166
|
-
data.splice(index + 1, 0,
|
|
181
|
+
data.splice(index + 1, 0, cloneDeep(props2.defaultItemValue));
|
|
167
182
|
emit("update:modelValue", data);
|
|
168
183
|
setExpandRowKeys([]);
|
|
169
184
|
}
|
|
@@ -174,7 +189,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
174
189
|
setExpandRowKeys([]);
|
|
175
190
|
}
|
|
176
191
|
const addToFirst = () => {
|
|
177
|
-
emit("update:modelValue", [
|
|
192
|
+
emit("update:modelValue", [cloneDeep(props2.defaultItemValue), ...(props2.modelValue ?? [])]);
|
|
178
193
|
setExpandRowKeys([]);
|
|
179
194
|
};
|
|
180
195
|
const handleFormSetData = e => {
|
|
@@ -187,7 +202,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
187
202
|
return props2.modelValue?.map((e, index) => {
|
|
188
203
|
return {
|
|
189
204
|
...e,
|
|
190
|
-
[ROW_KEY]: index
|
|
205
|
+
[ROW_KEY]: `${index}`
|
|
191
206
|
};
|
|
192
207
|
});
|
|
193
208
|
});
|
|
@@ -41,6 +41,13 @@ export declare const props: {
|
|
|
41
41
|
type: BooleanConstructor;
|
|
42
42
|
default: boolean;
|
|
43
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* @description 添加记录时的默认值
|
|
46
|
+
*/
|
|
47
|
+
defaultItemValue: {
|
|
48
|
+
type: PropType<NormalObject>;
|
|
49
|
+
default: () => {};
|
|
50
|
+
};
|
|
44
51
|
required: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, undefined, boolean>;
|
|
45
52
|
formItemSize: {
|
|
46
53
|
type: PropType<"default" | "small" | "large">;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { NormalObject } from '@vunk/shared';
|
|
1
|
+
import type { SetDataEvent } from '@vunk/core';
|
|
2
|
+
import type { __VkTableColumns } from '@vunk/plus/components/table-columns';
|
|
3
|
+
import type { NormalObject } from '@vunk/shared';
|
|
4
4
|
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
5
5
|
columns: {
|
|
6
6
|
type: import("vue").PropType<any[]>;
|
|
@@ -30,6 +30,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
30
30
|
type: BooleanConstructor;
|
|
31
31
|
default: boolean;
|
|
32
32
|
};
|
|
33
|
+
defaultItemValue: {
|
|
34
|
+
type: import("vue").PropType<NormalObject>;
|
|
35
|
+
default: () => {};
|
|
36
|
+
};
|
|
33
37
|
required: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, undefined, boolean>;
|
|
34
38
|
formItemSize: {
|
|
35
39
|
type: import("vue").PropType<"default" | "small" | "large">;
|
|
@@ -130,6 +134,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
130
134
|
type: BooleanConstructor;
|
|
131
135
|
default: boolean;
|
|
132
136
|
};
|
|
137
|
+
defaultItemValue: {
|
|
138
|
+
type: import("vue").PropType<NormalObject>;
|
|
139
|
+
default: () => {};
|
|
140
|
+
};
|
|
133
141
|
required: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, undefined, boolean>;
|
|
134
142
|
formItemSize: {
|
|
135
143
|
type: import("vue").PropType<"default" | "small" | "large">;
|
|
@@ -207,6 +215,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
207
215
|
splicable: boolean;
|
|
208
216
|
labelActions: boolean;
|
|
209
217
|
summaryLabel: (data: NormalObject) => string;
|
|
218
|
+
defaultItemValue: NormalObject;
|
|
210
219
|
}, {}, {
|
|
211
220
|
ElTable: import("element-plus/es/utils").SFCWithInstall<import("vue").DefineComponent<{
|
|
212
221
|
data: {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import type { __VkfTemplatesDefault } from '@vunk/form/components/templates-default';
|
|
2
|
+
import type { BasicSource } from '@vunk/form/shared';
|
|
3
|
+
import type { __VkTableColumns } from '@vunk/plus/components/table-columns';
|
|
4
|
+
import type { Keyof, NormalObject, VueComponentPropsType } from '@vunk/shared';
|
|
5
|
+
import type { TableColumnCtx } from 'element-plus';
|
|
6
|
+
import type Core from './index.vue';
|
|
7
7
|
export interface Source<P extends string = string> extends VueComponentPropsType<typeof Core>, BasicSource {
|
|
8
8
|
prop?: P | P[];
|
|
9
9
|
templateType: 'VkfInputCollection';
|
|
@@ -12,9 +12,12 @@ export type Column<R extends NormalObject = NormalObject, SourceType extends Nor
|
|
|
12
12
|
templateType: SourceType['templateType'];
|
|
13
13
|
templateProps?: Partial<SourceType>;
|
|
14
14
|
expandVisible?: boolean;
|
|
15
|
-
createTemplateProps?: (
|
|
15
|
+
createTemplateProps?: (columnSlotEvent: {
|
|
16
16
|
row: R;
|
|
17
17
|
column: TableColumnCtx<R>;
|
|
18
18
|
$index: number;
|
|
19
|
+
}, formItemProps: {
|
|
20
|
+
prop: Array<string | number>;
|
|
21
|
+
readonly: boolean;
|
|
19
22
|
}) => Partial<SourceType>;
|
|
20
23
|
};
|
package/index.css
CHANGED
|
@@ -252,12 +252,12 @@
|
|
|
252
252
|
.vkf-input-collection-table .vkf-form-item {
|
|
253
253
|
margin-bottom: 0;
|
|
254
254
|
}
|
|
255
|
-
.vkf-input-collection-table .vk-input-collection__expand-form-item {
|
|
256
|
-
margin-bottom: 18px;
|
|
257
|
-
}
|
|
258
255
|
.vk-input-collection__expand-fieldset{
|
|
259
256
|
padding: 8px;
|
|
260
257
|
}
|
|
258
|
+
.vk-input-collection__expand-fieldset .vkf-form-item{
|
|
259
|
+
margin-bottom: 18px;
|
|
260
|
+
}
|
|
261
261
|
.vk-input-collection__buttons .cell{
|
|
262
262
|
padding: 0;
|
|
263
263
|
}
|