@qin-ui/element-plus-pro 1.0.0
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 +77 -0
- package/es/component-provider/index.js +220 -0
- package/es/core/index-VQxpXgLX.js +362 -0
- package/es/element-plus-pro.css +66 -0
- package/es/form/index-BvqMIOZ8.js +470 -0
- package/es/form/index.js +20 -0
- package/es/index.d.ts +924 -0
- package/es/index.js +51 -0
- package/es/table/index.js +880 -0
- package/es/vendor/utils/lodash-es-p6jau26B.js +1120 -0
- package/package.json +49 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
[class*='-form-item'] [class*='-form-item'][data-v-f9126ed0] {
|
|
2
|
+
margin-bottom: 18px;
|
|
3
|
+
}
|
|
4
|
+
.pro-table_search-form[data-v-f615ff61] [class*='-form-item'] {
|
|
5
|
+
margin: 0;
|
|
6
|
+
}
|
|
7
|
+
.pro-table_search-form_expand-toggle-button[data-v-f615ff61] {
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
padding: 0;
|
|
11
|
+
padding-left: 4px;
|
|
12
|
+
}
|
|
13
|
+
.pro-table_search-form .transition[data-v-f615ff61] {
|
|
14
|
+
transition: all 0.25s;
|
|
15
|
+
}
|
|
16
|
+
.pro-table_search-form-container[data-v-45e627f4] {
|
|
17
|
+
margin-bottom: 24px;
|
|
18
|
+
padding: 24px;
|
|
19
|
+
background-color: var(--el-bg-color, #fff);
|
|
20
|
+
border-radius: 4px;
|
|
21
|
+
}
|
|
22
|
+
.pro-table_table-container[data-v-55d01897] {
|
|
23
|
+
flex: 1;
|
|
24
|
+
padding: 24px 24px 0;
|
|
25
|
+
background-color: var(--el-bg-color, #fff);
|
|
26
|
+
border-radius: 4px;
|
|
27
|
+
}
|
|
28
|
+
.pro-table_size-control_button[data-v-7af52d04] {
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
padding-right: 12px;
|
|
32
|
+
padding-left: 12px;
|
|
33
|
+
}
|
|
34
|
+
.pro-table_size-control_button[data-v-7af52d04] svg {
|
|
35
|
+
transform: scale(1.3);
|
|
36
|
+
}
|
|
37
|
+
.pro-table_column-control_button[data-v-e45d2d29] {
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
padding-right: 12px;
|
|
41
|
+
padding-left: 12px;
|
|
42
|
+
}
|
|
43
|
+
.pro-table_column-control_button[data-v-e45d2d29] svg {
|
|
44
|
+
transform: scale(1.2, 1.4);
|
|
45
|
+
}
|
|
46
|
+
.pro-table_header[data-v-c5989f58] {
|
|
47
|
+
display: flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
justify-content: flex-end;
|
|
50
|
+
}
|
|
51
|
+
.pro-table_header[data-v-c5989f58]:empty {
|
|
52
|
+
display: none;
|
|
53
|
+
}
|
|
54
|
+
.pro-table_header + .pro-table_header_content[data-v-c5989f58] {
|
|
55
|
+
margin-top: 16px;
|
|
56
|
+
}
|
|
57
|
+
.pro-table_header_button-bar[data-v-c5989f58] {
|
|
58
|
+
flex: 1;
|
|
59
|
+
}
|
|
60
|
+
.pro-table_header_toolbar[data-v-c5989f58] {
|
|
61
|
+
margin-left: 12px;
|
|
62
|
+
}
|
|
63
|
+
.pro-table_pagination[data-v-c5989f58] {
|
|
64
|
+
justify-content: flex-end;
|
|
65
|
+
padding: 16px 0;
|
|
66
|
+
}
|
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import { inject, computed, provide, toValue, defineComponent, useAttrs, useSlots, watchEffect, createBlock, openBlock, unref, mergeProps, withModifiers, withCtx, createVNode, renderSlot, normalizeProps, guardReactiveProps, resolveComponent, createElementBlock, Fragment, renderList, createSlots, ref, createCommentVNode, resolveDynamicComponent, isVNode, createTextVNode, toDisplayString } from "vue";
|
|
2
|
+
import { ElFormItem, ElCol, ElTable, ElPagination, useFormDisabled, ElForm, ElTransfer, ElTreeSelect, ElSlider, ElSwitch, ElRadioGroup, ElCheckboxGroup, ElTimeSelect, ElTimePicker, ElDatePicker, ElCascader, ElSelect, ElAutocomplete, ElInputNumber, ElInput, ElRow } from "element-plus";
|
|
3
|
+
import { INJECT_CONFIG, getInjectConfig, INJECT_COMPONENTS } from "../component-provider/index.js";
|
|
4
|
+
import { I as InjectionFormKey, c as camelizeProperties, a as InjectionPathKey, g as getObject, u as useForm$1, b as useFields$1, d as useFormRef$1 } from "../core/index-VQxpXgLX.js";
|
|
5
|
+
import { i as isPlainObject, t as toPath, o as omit, c as cloneDeep } from "../vendor/utils/lodash-es-p6jau26B.js";
|
|
6
|
+
const tableProps = () => ElTable.props || {};
|
|
7
|
+
const paginationProps = () => ElPagination.props || {};
|
|
8
|
+
const gridItemProps = () => ElCol.props || {};
|
|
9
|
+
const formItemProps = () => ElFormItem.props || {};
|
|
10
|
+
const DisabledContextKey = Symbol("pro-form-disabled-context");
|
|
11
|
+
const useDisabledContext = () => {
|
|
12
|
+
const formDisabled = useFormDisabled();
|
|
13
|
+
return inject(DisabledContextKey, computed(() => !!formDisabled.value));
|
|
14
|
+
};
|
|
15
|
+
const useDisabledContextProvider = (disabled) => {
|
|
16
|
+
provide(DisabledContextKey, computed(() => !!toValue(disabled)));
|
|
17
|
+
};
|
|
18
|
+
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
19
|
+
...{ name: "ProForm", inheritAttrs: false },
|
|
20
|
+
__name: "index",
|
|
21
|
+
props: {
|
|
22
|
+
grid: { type: [Boolean, Object], default: false },
|
|
23
|
+
form: { default: () => ({}) }
|
|
24
|
+
},
|
|
25
|
+
setup(__props) {
|
|
26
|
+
provide(InjectionFormKey, __props.form);
|
|
27
|
+
const { formData, fields, setFormRef } = __props.form;
|
|
28
|
+
const _fields = computed(() => fields.value);
|
|
29
|
+
const config = INJECT_CONFIG["pro-form"];
|
|
30
|
+
const attrs = useAttrs();
|
|
31
|
+
const { grid: _injectGrid, ...injectAttrs } = inject(
|
|
32
|
+
config.injectionKey,
|
|
33
|
+
config.default
|
|
34
|
+
);
|
|
35
|
+
const slots = useSlots();
|
|
36
|
+
watchEffect(() => {
|
|
37
|
+
Object.keys(slots).forEach((name) => {
|
|
38
|
+
if (name === "default") return;
|
|
39
|
+
provide(`${TeleportComponentNamePrefix}${name}`, slots[name]);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
return (_ctx, _cache) => {
|
|
43
|
+
return openBlock(), createBlock(unref(ElForm), mergeProps({
|
|
44
|
+
ref: (el) => {
|
|
45
|
+
var _a;
|
|
46
|
+
return (_a = unref(setFormRef)) == null ? void 0 : _a(el);
|
|
47
|
+
},
|
|
48
|
+
model: unref(formData)
|
|
49
|
+
}, mergeProps(injectAttrs, unref(camelizeProperties)(unref(attrs))), {
|
|
50
|
+
class: "pro-form",
|
|
51
|
+
onSubmit: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
52
|
+
}, ["prevent"]))
|
|
53
|
+
}), {
|
|
54
|
+
default: withCtx(() => [
|
|
55
|
+
createVNode(unref(BaseFormItem), {
|
|
56
|
+
fields: _fields.value,
|
|
57
|
+
grid: __props.grid
|
|
58
|
+
}, null, 8, ["fields", "grid"]),
|
|
59
|
+
renderSlot(_ctx.$slots, "default")
|
|
60
|
+
]),
|
|
61
|
+
_: 3
|
|
62
|
+
}, 16, ["model"]);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
const FORM_ITEM_SLOT_KEYS = ["label", "error"];
|
|
67
|
+
const componentMap = {
|
|
68
|
+
"input": ElInput,
|
|
69
|
+
"input-number": ElInputNumber,
|
|
70
|
+
"autocomplete": ElAutocomplete,
|
|
71
|
+
"select": ElSelect,
|
|
72
|
+
"cascader": ElCascader,
|
|
73
|
+
"date-picker": ElDatePicker,
|
|
74
|
+
"time-picker": ElTimePicker,
|
|
75
|
+
"time-select": ElTimeSelect,
|
|
76
|
+
"checkbox-group": ElCheckboxGroup,
|
|
77
|
+
"radio-group": ElRadioGroup,
|
|
78
|
+
"switch": ElSwitch,
|
|
79
|
+
"slider": ElSlider,
|
|
80
|
+
"tree-select": ElTreeSelect,
|
|
81
|
+
"transfer": ElTransfer
|
|
82
|
+
};
|
|
83
|
+
const TeleportComponentNamePrefix = "TeleportComponent_";
|
|
84
|
+
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
85
|
+
__name: "index",
|
|
86
|
+
props: {
|
|
87
|
+
path: {}
|
|
88
|
+
},
|
|
89
|
+
setup(__props) {
|
|
90
|
+
const props = __props;
|
|
91
|
+
const namePath = computed(() => {
|
|
92
|
+
return Array.isArray(props.path) ? props.path.join(".") : props.path;
|
|
93
|
+
});
|
|
94
|
+
provide(InjectionPathKey, namePath);
|
|
95
|
+
return (_ctx, _cache) => {
|
|
96
|
+
return renderSlot(_ctx.$slots, "default", { path: namePath.value });
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
101
|
+
__name: "index",
|
|
102
|
+
props: {
|
|
103
|
+
field: {}
|
|
104
|
+
},
|
|
105
|
+
setup(__props) {
|
|
106
|
+
const formItemPropKeys = Object.keys(formItemProps());
|
|
107
|
+
const gridItemPropKeys = Object.keys(gridItemProps());
|
|
108
|
+
const props = __props;
|
|
109
|
+
const config = INJECT_CONFIG["pro-form-item"];
|
|
110
|
+
const injectFormItemProps = inject(config.injectionKey, config.default);
|
|
111
|
+
const groupedAttributes = computed(() => {
|
|
112
|
+
let gridItemProps2 = {};
|
|
113
|
+
let formItemProps2 = {};
|
|
114
|
+
const componentProps = { slots: {} };
|
|
115
|
+
const formItemSlots = {};
|
|
116
|
+
if (isPlainObject(props.field)) {
|
|
117
|
+
const { path, name, fields, formItemClass, formItemStyle, formItemContainer, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, ...rest } = props.field;
|
|
118
|
+
const {
|
|
119
|
+
class: injectClassName,
|
|
120
|
+
style: injectStyle,
|
|
121
|
+
span: injectSpan,
|
|
122
|
+
formItemContainer: injectFormItemContainer,
|
|
123
|
+
xs,
|
|
124
|
+
sm,
|
|
125
|
+
md,
|
|
126
|
+
lg,
|
|
127
|
+
xl,
|
|
128
|
+
...injectRest
|
|
129
|
+
} = injectFormItemProps;
|
|
130
|
+
const initGridItemProps = span || span === 0 ? { span } : { xs, sm, md, lg, xl, span: injectSpan };
|
|
131
|
+
gridItemProps2 = fields ? { span: span ?? 24 } : initGridItemProps;
|
|
132
|
+
formItemProps2 = mergeProps(
|
|
133
|
+
injectRest,
|
|
134
|
+
{ class: injectClassName, style: injectStyle },
|
|
135
|
+
{ class: toValue(formItemClass), style: toValue(formItemStyle) },
|
|
136
|
+
formItemDataAttrs
|
|
137
|
+
);
|
|
138
|
+
formItemProps2.container = formItemContainer ?? injectFormItemContainer;
|
|
139
|
+
Object.keys(rest).forEach((k) => {
|
|
140
|
+
if (gridItemPropKeys.includes(k)) {
|
|
141
|
+
gridItemProps2[k] = rest[k];
|
|
142
|
+
} else if (formItemPropKeys.includes(k)) {
|
|
143
|
+
formItemProps2[k] = rest[k];
|
|
144
|
+
} else {
|
|
145
|
+
componentProps[k] = rest[k];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
Object.assign(componentProps, componentDataAttrs);
|
|
149
|
+
Object.keys(slots).forEach((k) => {
|
|
150
|
+
if (FORM_ITEM_SLOT_KEYS.includes(k)) {
|
|
151
|
+
formItemSlots[k] = slots[k];
|
|
152
|
+
} else {
|
|
153
|
+
componentProps["slots"][k] = slots[k];
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
return { gridItemProps: gridItemProps2, formItemProps: formItemProps2, componentProps, formItemSlots };
|
|
158
|
+
});
|
|
159
|
+
return (_ctx, _cache) => {
|
|
160
|
+
return renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(groupedAttributes.value)));
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
165
|
+
...{ name: "BaseFormItem", inheritAttrs: false },
|
|
166
|
+
__name: "index",
|
|
167
|
+
props: {
|
|
168
|
+
grid: { type: [Boolean, Object], default: () => void 0 },
|
|
169
|
+
fields: { default: () => [] },
|
|
170
|
+
disabled: { type: Boolean, default: () => void 0 }
|
|
171
|
+
},
|
|
172
|
+
setup(__props) {
|
|
173
|
+
const validFields = computed(() => {
|
|
174
|
+
var _a, _b;
|
|
175
|
+
return (_b = (_a = __props.fields).filter) == null ? void 0 : _b.call(_a, (field) => !field.hidden);
|
|
176
|
+
});
|
|
177
|
+
useDisabledContextProvider(computed(() => __props.disabled));
|
|
178
|
+
const config = INJECT_CONFIG["pro-form"];
|
|
179
|
+
const { grid: injectGrid } = inject(config.injectionKey, config.default);
|
|
180
|
+
const enableGrid = computed(() => {
|
|
181
|
+
if (__props.grid !== void 0) return !!__props.grid;
|
|
182
|
+
return !!injectGrid;
|
|
183
|
+
});
|
|
184
|
+
const computedGridProps = computed(() => {
|
|
185
|
+
return enableGrid.value ? { ...getObject(injectGrid), ...getObject(__props.grid) } : {};
|
|
186
|
+
});
|
|
187
|
+
const formItemRefs = [];
|
|
188
|
+
const componentRefs = [];
|
|
189
|
+
const onFormItemMounted = (index, formItemProps2) => {
|
|
190
|
+
const field = validFields.value[index];
|
|
191
|
+
Object.assign(field, {
|
|
192
|
+
getFormItemRef: () => formItemRefs[index],
|
|
193
|
+
getFormItemComputedProps: () => formItemProps2
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
const onComponentMounted = (index) => {
|
|
197
|
+
const field = validFields.value[index];
|
|
198
|
+
Object.assign(field, {
|
|
199
|
+
getComponentRef: () => {
|
|
200
|
+
var _a;
|
|
201
|
+
return (_a = componentRefs[index]) == null ? void 0 : _a.getComponentRef();
|
|
202
|
+
},
|
|
203
|
+
getComponentComputedProps: () => {
|
|
204
|
+
var _a;
|
|
205
|
+
return (_a = componentRefs[index]) == null ? void 0 : _a.getComponentComputedProps();
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
return (_ctx, _cache) => {
|
|
210
|
+
const _component_BaseFormItem = resolveComponent("BaseFormItem");
|
|
211
|
+
return openBlock(), createBlock(unref(_sfc_main$1), mergeProps({
|
|
212
|
+
component: enableGrid.value ? unref(ElRow) : void 0
|
|
213
|
+
}, computedGridProps.value, { style: { "width": "100%" } }), {
|
|
214
|
+
default: withCtx(() => [
|
|
215
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(validFields.value, ({ path: _path, ...field }, index) => {
|
|
216
|
+
return openBlock(), createBlock(_sfc_main$5, mergeProps({
|
|
217
|
+
key: unref(toPath)(toValue(_path ?? index)).join(".") || index
|
|
218
|
+
}, { ref_for: true }, { path: _path }), {
|
|
219
|
+
default: withCtx(({ path }) => [
|
|
220
|
+
createVNode(_sfc_main$4, { field }, {
|
|
221
|
+
default: withCtx(({
|
|
222
|
+
gridItemProps: gridItemProps2,
|
|
223
|
+
formItemProps: { container, ...formItemProps2 },
|
|
224
|
+
componentProps,
|
|
225
|
+
formItemSlots
|
|
226
|
+
}) => [
|
|
227
|
+
createVNode(unref(_sfc_main$1), mergeProps({
|
|
228
|
+
component: enableGrid.value ? unref(ElCol) : void 0
|
|
229
|
+
}, { ref_for: true }, gridItemProps2), {
|
|
230
|
+
default: withCtx(() => [
|
|
231
|
+
createVNode(unref(_sfc_main$1), {
|
|
232
|
+
component: container,
|
|
233
|
+
path
|
|
234
|
+
}, {
|
|
235
|
+
default: withCtx(() => [
|
|
236
|
+
createVNode(unref(ElFormItem), mergeProps({ ref_for: true }, formItemProps2, {
|
|
237
|
+
ref_for: true,
|
|
238
|
+
ref: (el) => formItemRefs[index] = el,
|
|
239
|
+
prop: unref(toPath)(path).join("."),
|
|
240
|
+
path,
|
|
241
|
+
onVnodeMounted: ($event) => onFormItemMounted(index, formItemProps2)
|
|
242
|
+
}), createSlots({
|
|
243
|
+
default: withCtx(() => [
|
|
244
|
+
field.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
|
|
245
|
+
key: 0,
|
|
246
|
+
grid: field.grid ?? __props.grid,
|
|
247
|
+
fields: field.fields,
|
|
248
|
+
disabled: toValue(field.disabled)
|
|
249
|
+
}, null, 8, ["grid", "fields", "disabled"])) : (openBlock(), createBlock(unref(_sfc_main$2), mergeProps({
|
|
250
|
+
key: 1,
|
|
251
|
+
ref_for: true,
|
|
252
|
+
ref: (el) => componentRefs[index] = el
|
|
253
|
+
}, { ref_for: true }, componentProps, {
|
|
254
|
+
path,
|
|
255
|
+
onVnodeMounted: ($event) => onComponentMounted(index)
|
|
256
|
+
}), null, 16, ["path", "onVnodeMounted"]))
|
|
257
|
+
]),
|
|
258
|
+
_: 2
|
|
259
|
+
}, [
|
|
260
|
+
renderList(formItemSlots, (slot, name) => {
|
|
261
|
+
return {
|
|
262
|
+
name,
|
|
263
|
+
fn: withCtx((scoped) => [
|
|
264
|
+
createVNode(unref(_sfc_main), mergeProps({
|
|
265
|
+
path,
|
|
266
|
+
component: slot
|
|
267
|
+
}, { ref_for: true }, scoped), null, 16, ["path", "component"])
|
|
268
|
+
])
|
|
269
|
+
};
|
|
270
|
+
})
|
|
271
|
+
]), 1040, ["prop", "path", "onVnodeMounted"])
|
|
272
|
+
]),
|
|
273
|
+
_: 2
|
|
274
|
+
}, 1032, ["component", "path"])
|
|
275
|
+
]),
|
|
276
|
+
_: 2
|
|
277
|
+
}, 1040, ["component"])
|
|
278
|
+
]),
|
|
279
|
+
_: 2
|
|
280
|
+
}, 1032, ["field"])
|
|
281
|
+
]),
|
|
282
|
+
_: 2
|
|
283
|
+
}, 1040);
|
|
284
|
+
}), 128))
|
|
285
|
+
]),
|
|
286
|
+
_: 1
|
|
287
|
+
}, 16, ["component"]);
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
const _export_sfc = (sfc, props) => {
|
|
292
|
+
const target = sfc.__vccOpts || sfc;
|
|
293
|
+
for (const [key, val] of props) {
|
|
294
|
+
target[key] = val;
|
|
295
|
+
}
|
|
296
|
+
return target;
|
|
297
|
+
};
|
|
298
|
+
const BaseFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-f9126ed0"]]);
|
|
299
|
+
const useForm = useForm$1;
|
|
300
|
+
const getInitProps = (field) => {
|
|
301
|
+
const { component, type } = field;
|
|
302
|
+
if (typeof component === "string") {
|
|
303
|
+
const k = [component, type].filter(Boolean).join(".");
|
|
304
|
+
const config = getInjectConfig(k);
|
|
305
|
+
if (!config) return {};
|
|
306
|
+
const injectProps = inject(config.injectionKey, config.default);
|
|
307
|
+
return injectProps;
|
|
308
|
+
}
|
|
309
|
+
return {};
|
|
310
|
+
};
|
|
311
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
312
|
+
...{ name: "BaseField", inheritAttrs: false },
|
|
313
|
+
__name: "index",
|
|
314
|
+
props: {
|
|
315
|
+
component: { default: () => void 0 },
|
|
316
|
+
path: { default: "" }
|
|
317
|
+
},
|
|
318
|
+
setup(__props, { expose: __expose }) {
|
|
319
|
+
const form = useForm(false);
|
|
320
|
+
const { getFormData, setFormData } = form;
|
|
321
|
+
const componentRef = ref();
|
|
322
|
+
const attrs = useAttrs();
|
|
323
|
+
function getOldValue() {
|
|
324
|
+
return cloneDeep(getFormData == null ? void 0 : getFormData(__props.path));
|
|
325
|
+
}
|
|
326
|
+
const value = computed({
|
|
327
|
+
get() {
|
|
328
|
+
let val = getFormData == null ? void 0 : getFormData(__props.path);
|
|
329
|
+
const { valueFormatter } = groupedAttrs.value;
|
|
330
|
+
if (typeof valueFormatter === "object" && typeof valueFormatter.get === "function") {
|
|
331
|
+
val = valueFormatter.get(val);
|
|
332
|
+
}
|
|
333
|
+
return val;
|
|
334
|
+
},
|
|
335
|
+
set(val) {
|
|
336
|
+
let newVal = val;
|
|
337
|
+
const { valueFormatter } = groupedAttrs.value;
|
|
338
|
+
if (valueFormatter) {
|
|
339
|
+
if (typeof valueFormatter === "function") {
|
|
340
|
+
newVal = valueFormatter(val, getOldValue());
|
|
341
|
+
} else if (typeof valueFormatter.set === "function") {
|
|
342
|
+
newVal = valueFormatter.set(val, getOldValue());
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
setFormData == null ? void 0 : setFormData(__props.path, newVal);
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
const parentDisabled = useDisabledContext();
|
|
349
|
+
const groupedAttrs = computed(() => {
|
|
350
|
+
const initProps = getInitProps({
|
|
351
|
+
component: __props.component,
|
|
352
|
+
type: attrs.type
|
|
353
|
+
});
|
|
354
|
+
const modelPropName = attrs.modelProp ?? initProps.modelProp ?? "modelValue";
|
|
355
|
+
const mergedProps = mergeProps(
|
|
356
|
+
initProps,
|
|
357
|
+
attrs,
|
|
358
|
+
{ class: attrs.componentClass, style: attrs.componentStyle },
|
|
359
|
+
{ class: initProps.componentClass, style: initProps.componentStyle },
|
|
360
|
+
{ disabled: attrs.disabled ?? parentDisabled.value ?? initProps.disabled },
|
|
361
|
+
{ modelProp: modelPropName }
|
|
362
|
+
);
|
|
363
|
+
const { valueFormatter, modelProp, slots, componentClass, componentStyle, componentContainer, ...rest } = mergedProps;
|
|
364
|
+
const modelBindingProp = modelProp ?? "modelValue";
|
|
365
|
+
const bindAttrs = omit(rest, [
|
|
366
|
+
modelBindingProp,
|
|
367
|
+
`onUpdate:${modelBindingProp}`
|
|
368
|
+
]);
|
|
369
|
+
return {
|
|
370
|
+
attrs: bindAttrs,
|
|
371
|
+
slots,
|
|
372
|
+
componentContainer,
|
|
373
|
+
modelProp: modelBindingProp,
|
|
374
|
+
valueFormatter
|
|
375
|
+
};
|
|
376
|
+
});
|
|
377
|
+
const teleportComponent = inject(
|
|
378
|
+
`${TeleportComponentNamePrefix}${__props.path}`,
|
|
379
|
+
void 0
|
|
380
|
+
);
|
|
381
|
+
const customComponents = inject(INJECT_COMPONENTS, {});
|
|
382
|
+
const is = computed(() => {
|
|
383
|
+
if (teleportComponent) return teleportComponent;
|
|
384
|
+
if (typeof __props.component === "string") {
|
|
385
|
+
return customComponents[__props.component] || componentMap[__props.component] || __props.component;
|
|
386
|
+
}
|
|
387
|
+
return __props.component;
|
|
388
|
+
});
|
|
389
|
+
__expose({
|
|
390
|
+
getComponentRef: () => componentRef.value,
|
|
391
|
+
getComponentComputedProps: () => groupedAttrs.value.attrs
|
|
392
|
+
});
|
|
393
|
+
return (_ctx, _cache) => {
|
|
394
|
+
return openBlock(), createBlock(unref(_sfc_main$1), {
|
|
395
|
+
component: groupedAttrs.value.componentContainer,
|
|
396
|
+
path: __props.path
|
|
397
|
+
}, {
|
|
398
|
+
default: withCtx(() => [
|
|
399
|
+
is.value ? (openBlock(), createBlock(resolveDynamicComponent(is.value), mergeProps({ key: 0 }, groupedAttrs.value.attrs, {
|
|
400
|
+
ref_key: "componentRef",
|
|
401
|
+
ref: componentRef,
|
|
402
|
+
[`${groupedAttrs.value.modelProp}`]: value.value,
|
|
403
|
+
[`onUpdate:${groupedAttrs.value.modelProp}`]: _cache[0] || (_cache[0] = ($event) => value.value = $event),
|
|
404
|
+
path: __props.path
|
|
405
|
+
}), createSlots({ _: 2 }, [
|
|
406
|
+
renderList(groupedAttrs.value.slots, (slot, name) => {
|
|
407
|
+
return {
|
|
408
|
+
name,
|
|
409
|
+
fn: withCtx((scoped) => [
|
|
410
|
+
createVNode(unref(_sfc_main), mergeProps({ path: __props.path }, scoped, { component: slot }), null, 16, ["path", "component"])
|
|
411
|
+
])
|
|
412
|
+
};
|
|
413
|
+
})
|
|
414
|
+
]), 1040, ["path"])) : createCommentVNode("", true)
|
|
415
|
+
]),
|
|
416
|
+
_: 1
|
|
417
|
+
}, 8, ["component", "path"]);
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
422
|
+
...{ name: "ContainerFragment", inheritAttrs: false },
|
|
423
|
+
__name: "index",
|
|
424
|
+
props: {
|
|
425
|
+
component: { type: [Object, Function] }
|
|
426
|
+
},
|
|
427
|
+
setup(__props) {
|
|
428
|
+
return (_ctx, _cache) => {
|
|
429
|
+
return __props.component ? (openBlock(), createBlock(resolveDynamicComponent(__props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), {
|
|
430
|
+
default: withCtx(() => [
|
|
431
|
+
renderSlot(_ctx.$slots, "default")
|
|
432
|
+
]),
|
|
433
|
+
_: 3
|
|
434
|
+
}, 16)) : renderSlot(_ctx.$slots, "default", { key: 1 });
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
439
|
+
...{ name: "SlotComponent", inheritAttrs: false },
|
|
440
|
+
__name: "index",
|
|
441
|
+
props: {
|
|
442
|
+
component: { type: [Object, Function, String, Number, Boolean, null] }
|
|
443
|
+
},
|
|
444
|
+
setup(__props) {
|
|
445
|
+
return (_ctx, _cache) => {
|
|
446
|
+
return isVNode(__props.component) || typeof __props.component === "function" ? (openBlock(), createBlock(resolveDynamicComponent(__props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), null, 16)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
447
|
+
createTextVNode(toDisplayString(__props.component), 1)
|
|
448
|
+
], 64));
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
const useFields = useFields$1;
|
|
453
|
+
const useFormRef = useFormRef$1;
|
|
454
|
+
export {
|
|
455
|
+
BaseFormItem as B,
|
|
456
|
+
FORM_ITEM_SLOT_KEYS as F,
|
|
457
|
+
TeleportComponentNamePrefix as T,
|
|
458
|
+
_export_sfc as _,
|
|
459
|
+
_sfc_main$6 as a,
|
|
460
|
+
_sfc_main$1 as b,
|
|
461
|
+
_sfc_main$2 as c,
|
|
462
|
+
_sfc_main as d,
|
|
463
|
+
componentMap as e,
|
|
464
|
+
useFields as f,
|
|
465
|
+
useFormRef as g,
|
|
466
|
+
getInitProps as h,
|
|
467
|
+
paginationProps as p,
|
|
468
|
+
tableProps as t,
|
|
469
|
+
useForm as u
|
|
470
|
+
};
|
package/es/form/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { c, a, B, b, F, d, T, e, a as a2, h, f, u, g } from "./index-BvqMIOZ8.js";
|
|
2
|
+
import { I, a as a3, e as e2 } from "../core/index-VQxpXgLX.js";
|
|
3
|
+
export {
|
|
4
|
+
c as BaseField,
|
|
5
|
+
a as BaseForm,
|
|
6
|
+
B as BaseFormItem,
|
|
7
|
+
b as ContainerFragment,
|
|
8
|
+
F as FORM_ITEM_SLOT_KEYS,
|
|
9
|
+
I as InjectionFormKey,
|
|
10
|
+
a3 as InjectionPathKey,
|
|
11
|
+
d as SlotComponent,
|
|
12
|
+
T as TeleportComponentNamePrefix,
|
|
13
|
+
e as componentMap,
|
|
14
|
+
a2 as default,
|
|
15
|
+
h as getInitProps,
|
|
16
|
+
f as useFields,
|
|
17
|
+
u as useForm,
|
|
18
|
+
e2 as useFormData,
|
|
19
|
+
g as useFormRef
|
|
20
|
+
};
|