@qin-ui/element-plus-pro 1.3.4 → 1.4.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/AI-CONTEXT.md +26 -2
- package/README.md +41 -30
- package/api.json +69 -38
- package/es/components/component-provider/components/index.vue.d.ts +10 -3
- package/es/components/component-provider/components/index.vue.d.ts.map +1 -1
- package/es/components/component-provider/constants/index.d.ts +22 -4
- package/es/components/component-provider/constants/index.d.ts.map +1 -1
- package/es/components/component-provider/types/index.d.ts +17 -3
- package/es/components/component-provider/types/index.d.ts.map +1 -1
- package/es/components/form/components/BaseField/index.vue.d.ts.map +1 -1
- package/es/components/form/components/BaseField/utils/index.d.ts +15 -0
- package/es/components/form/components/BaseField/utils/index.d.ts.map +1 -1
- package/es/components/form/components/BaseFormItem/index.vue.d.ts +3 -1
- package/es/components/form/components/BaseFormItem/index.vue.d.ts.map +1 -1
- package/es/components/form/components/ContainerFragment/index.vue.d.ts.map +1 -1
- package/es/components/form/components/ProForm/index.vue.d.ts.map +1 -1
- package/es/components/form/components/SlotComponent/index.vue.d.ts.map +1 -1
- package/es/components/form/components/index.d.ts +4 -0
- package/es/components/form/components/index.d.ts.map +1 -1
- package/es/components/form/constants/index.d.ts +8 -2
- package/es/components/form/constants/index.d.ts.map +1 -1
- package/es/components/form/hooks/useFields.d.ts.map +1 -1
- package/es/components/form/hooks/useForm.d.ts.map +1 -1
- package/es/components/form/hooks/useGroupFieldAttrs.d.ts +9 -0
- package/es/components/form/hooks/useGroupFieldAttrs.d.ts.map +1 -1
- package/es/components/form/index.d.ts +2 -2
- package/es/components/form/index.d.ts.map +1 -1
- package/es/components/form/types/index.d.ts +65 -50
- package/es/components/form/types/index.d.ts.map +1 -1
- package/es/components/form/utils/fieldKey.d.ts +13 -0
- package/es/components/form/utils/fieldKey.d.ts.map +1 -0
- package/es/components/table/components/ColumnControl.vue.d.ts +1 -1
- package/es/components/table/components/ColumnControl.vue.d.ts.map +1 -1
- package/es/components/table/components/ProTable.vue.d.ts +15 -1
- package/es/components/table/components/ProTable.vue.d.ts.map +1 -1
- package/es/components/table/components/SearchForm.vue.d.ts +14 -2
- package/es/components/table/components/SearchForm.vue.d.ts.map +1 -1
- package/es/components/table/components/SizeControl.vue.d.ts +7 -2
- package/es/components/table/components/SizeControl.vue.d.ts.map +1 -1
- package/es/components/table/components/TableColumnRenderer.vue.d.ts +14 -14
- package/es/components/table/components/TableColumnRenderer.vue.d.ts.map +1 -1
- package/es/components/table/hooks/index.d.ts +2 -0
- package/es/components/table/hooks/index.d.ts.map +1 -0
- package/es/components/table/{useTable.d.ts → hooks/useTable.d.ts} +3 -3
- package/es/components/table/hooks/useTable.d.ts.map +1 -0
- package/es/components/table/index.d.ts +6 -2
- package/es/components/table/index.d.ts.map +1 -1
- package/es/components/table/types/index.d.ts +16 -12
- package/es/components/table/types/index.d.ts.map +1 -1
- package/es/element-plus-pro.css +14 -14
- package/es/index.d.ts +9 -6
- package/es/index.d.ts.map +1 -1
- package/es/index.js +577 -432
- package/es/index.js.map +1 -1
- package/es/locale/index.d.ts +2 -1
- package/es/locale/index.d.ts.map +1 -1
- package/es/shared/core/index.d.ts +1 -1
- package/es/shared/core/index.d.ts.map +1 -1
- package/es/shared/ui/index.d.ts +20 -2
- package/es/shared/ui/index.d.ts.map +1 -1
- package/package.json +8 -5
- package/src/components/component-provider/components/index.vue +48 -21
- package/src/components/component-provider/constants/index.ts +34 -6
- package/src/components/component-provider/types/index.ts +21 -7
- package/src/components/form/components/BaseField/index.vue +32 -15
- package/src/components/form/components/BaseField/utils/index.ts +16 -1
- package/src/components/form/components/BaseFormItem/index.vue +61 -15
- package/src/components/form/components/ContainerFragment/index.vue +3 -1
- package/src/components/form/components/ProForm/index.vue +54 -27
- package/src/components/form/components/SlotComponent/index.vue +4 -2
- package/src/components/form/components/index.ts +8 -1
- package/src/components/form/constants/index.ts +9 -2
- package/src/components/form/hooks/useFields.ts +5 -2
- package/src/components/form/hooks/useForm.ts +8 -1
- package/src/components/form/hooks/useGroupFieldAttrs.ts +29 -30
- package/src/components/form/index.ts +1 -3
- package/src/components/form/types/index.ts +71 -52
- package/src/components/form/utils/fieldKey.ts +27 -0
- package/src/components/table/components/ColumnControl.vue +20 -8
- package/src/components/table/components/ProTable.vue +194 -96
- package/src/components/table/components/SearchForm.vue +62 -23
- package/src/components/table/components/SizeControl.vue +23 -1
- package/src/components/table/components/TableColumnRenderer.vue +93 -61
- package/src/components/table/hooks/index.ts +1 -0
- package/src/components/table/{useTable.ts → hooks/useTable.ts} +6 -4
- package/src/components/table/index.ts +11 -2
- package/src/components/table/types/index.ts +17 -13
- package/src/index.ts +13 -7
- package/src/locale/index.ts +4 -2
- package/src/shared/core/index.ts +11 -0
- package/src/shared/ui/index.ts +29 -5
- package/tsconfig.json +22 -0
- package/es/components/table/useTable.d.ts.map +0 -1
package/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./element-plus-pro.css";
|
|
2
|
-
import { inject, computed, toValue,
|
|
3
|
-
import { ElTable, ElPagination, ElCol, ElFormItem, useFormDisabled, ElTransfer, ElTreeSelect, ElSlider, ElSwitch, ElRadioGroup, ElCheckboxGroup, ElTimeSelect, ElTimePicker, ElDatePicker, ElCascader, ElSelect, ElAutocomplete, ElInputNumber, ElInput,
|
|
4
|
-
import {
|
|
2
|
+
import { inject, computed, toValue, provide, defineComponent, createBlock, renderSlot, openBlock, resolveDynamicComponent, normalizeProps, mergeProps, withCtx, createElementBlock, Fragment, createTextVNode, toDisplayString, ref, createCommentVNode, createSlots, renderList, createVNode, toRaw, resolveComponent, unref, useSlots, shallowRef, onUpdated, triggerRef, withModifiers, createElementVNode, normalizeStyle, nextTick, mergeModels, useModel, watch, h, onMounted, resolveDirective, normalizeClass, withDirectives, guardReactiveProps, effect, stop, Comment, Text } from "vue";
|
|
3
|
+
import { ElTable, ElPagination, ElCol, ElFormItem, useFormDisabled, ElTransfer, ElTreeSelect, ElSlider, ElSwitch, ElRadioGroup, ElCheckboxGroup, ElTimeSelect, ElTimePicker, ElDatePicker, ElCascader, ElSelect, ElAutocomplete, ElInputNumber, ElInput, localeContextKey, useLocale as useLocale$1, ElRow, ElForm, ElSpace, ElButton, useSize, ElDropdown, ElDropdownMenu, ElDropdownItem, ElCheckbox, ElTableColumn, ElLoading } from "element-plus";
|
|
4
|
+
import { useForm as useForm$1, zhCN as zhCN$1, zhTW as zhTW$1, enUS as enUS$1, resolveLocaleName, format, useReactiveAttrs, cloneDeep, getObject, InjectionFormSlotsKey, isPlainObject, resolveFieldIdentity, isObjectItem, normalizePathKey, createFormProxy, InjectionFormKey, omitBy, camelizeProperties, useFields as useFields$1, useFormRef as useFormRef$1, useSearchFormExpand, get, pick, isPromise, useTable as useTable$1, omit } from "@qin-ui/pro-components-core";
|
|
5
5
|
import { useFormData } from "@qin-ui/pro-components-core";
|
|
6
6
|
const _tableProps = ElTable.props || {};
|
|
7
7
|
const _paginationProps = ElPagination.props || {};
|
|
@@ -14,17 +14,30 @@ const formItemProps = () => _formItemProps;
|
|
|
14
14
|
const DisabledContextKey = Symbol.for("pro-form-disabled-context");
|
|
15
15
|
const useDisabledContext = () => {
|
|
16
16
|
const formDisabled = useFormDisabled();
|
|
17
|
-
const customDisabled = inject(
|
|
17
|
+
const customDisabled = inject(
|
|
18
|
+
DisabledContextKey,
|
|
19
|
+
void 0
|
|
20
|
+
);
|
|
18
21
|
return computed(() => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
+
const custom = toValue(customDisabled);
|
|
23
|
+
if (custom !== void 0) return Boolean(custom);
|
|
22
24
|
return Boolean(formDisabled.value);
|
|
23
25
|
});
|
|
24
26
|
};
|
|
27
|
+
const useDisabledContextProvider = (disabled) => {
|
|
28
|
+
const parentDisabled = useDisabledContext();
|
|
29
|
+
provide(
|
|
30
|
+
DisabledContextKey,
|
|
31
|
+
computed(() => toValue(disabled) ?? parentDisabled.value)
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
const useProviderDisabled = useDisabledContextProvider;
|
|
35
|
+
const INJECT_COMPONENT_VARS = Symbol("COMPONENT_VARS");
|
|
25
36
|
const INJECT_CONFIG = {
|
|
26
37
|
"pro-table": {
|
|
27
38
|
injectionKey: Symbol(""),
|
|
39
|
+
// 数据取自 `:table` 实例或显式 `:data`;列与加载态非类型面成员,同样在注入层忽略
|
|
40
|
+
ignoreProps: ["loading", "columns", "data"],
|
|
28
41
|
default: {
|
|
29
42
|
pagination: {
|
|
30
43
|
layout: "total, sizes, prev, pager, next, jumper",
|
|
@@ -41,6 +54,8 @@ const INJECT_CONFIG = {
|
|
|
41
54
|
},
|
|
42
55
|
"pro-form": {
|
|
43
56
|
injectionKey: Symbol(""),
|
|
57
|
+
// 表单实例由 `:form` 显式传入
|
|
58
|
+
ignoreProps: ["form"],
|
|
44
59
|
default: { grid: { gutter: 24 } }
|
|
45
60
|
},
|
|
46
61
|
"pro-form-item": {
|
|
@@ -201,6 +216,38 @@ const ensureInjectConfig = (key) => {
|
|
|
201
216
|
DYNAMIC_INJECT_CONFIG[key] = created;
|
|
202
217
|
return created;
|
|
203
218
|
};
|
|
219
|
+
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
220
|
+
...{ name: "ContainerFragment", inheritAttrs: false },
|
|
221
|
+
__name: "index",
|
|
222
|
+
props: {
|
|
223
|
+
component: { type: [Object, Function] }
|
|
224
|
+
},
|
|
225
|
+
setup(__props) {
|
|
226
|
+
return (_ctx, _cache) => {
|
|
227
|
+
return __props.component ? (openBlock(), createBlock(resolveDynamicComponent(__props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), {
|
|
228
|
+
default: withCtx(() => [
|
|
229
|
+
renderSlot(_ctx.$slots, "default")
|
|
230
|
+
]),
|
|
231
|
+
_: 3
|
|
232
|
+
}, 16)) : renderSlot(_ctx.$slots, "default", { key: 1 });
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
237
|
+
...{ name: "SlotComponent", inheritAttrs: false },
|
|
238
|
+
__name: "index",
|
|
239
|
+
props: {
|
|
240
|
+
component: { type: [Object, Function, String, Number, Boolean, null] }
|
|
241
|
+
},
|
|
242
|
+
setup(__props) {
|
|
243
|
+
const isRenderable = (c) => c !== null && c !== void 0 && (typeof c === "function" || typeof c === "object");
|
|
244
|
+
return (_ctx, _cache) => {
|
|
245
|
+
return isRenderable(__props.component) ? (openBlock(), createBlock(resolveDynamicComponent(__props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), null, 16)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
246
|
+
createTextVNode(toDisplayString(__props.component), 1)
|
|
247
|
+
], 64));
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
});
|
|
204
251
|
const FORM_ITEM_SLOT_KEYS = ["label", "error"];
|
|
205
252
|
const componentMap = {
|
|
206
253
|
"input": ElInput,
|
|
@@ -218,222 +265,14 @@ const componentMap = {
|
|
|
218
265
|
"tree-select": ElTreeSelect,
|
|
219
266
|
"transfer": ElTransfer
|
|
220
267
|
};
|
|
221
|
-
const
|
|
222
|
-
(k) => k !== "disabled"
|
|
223
|
-
);
|
|
224
|
-
const gridItemPropKeys = Object.keys(gridItemProps());
|
|
225
|
-
const gridItemPropKeySet = new Set(gridItemPropKeys);
|
|
226
|
-
const formItemPropKeySet = new Set(formItemPropKeys);
|
|
227
|
-
const formItemSlotKeySet = new Set(FORM_ITEM_SLOT_KEYS);
|
|
228
|
-
function useGroupFieldAttrs(validFields) {
|
|
229
|
-
const config = INJECT_CONFIG["pro-form-item"];
|
|
230
|
-
const injectFormItemProps = inject(config.injectionKey, config.default);
|
|
231
|
-
return computed(() => {
|
|
232
|
-
const rawInjectProps = toValue(injectFormItemProps) || {};
|
|
233
|
-
return validFields.value.map((field) => {
|
|
234
|
-
let gridItemProps2 = {};
|
|
235
|
-
let formItemProps2 = {};
|
|
236
|
-
const componentProps = { slots: {} };
|
|
237
|
-
const formItemSlots = {};
|
|
238
|
-
if (isPlainObject(field)) {
|
|
239
|
-
const { path, name, fields, formItemClass, formItemStyle, formItemContainer, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, ...rest } = field;
|
|
240
|
-
const {
|
|
241
|
-
class: injectClassName,
|
|
242
|
-
style: injectStyle,
|
|
243
|
-
span: injectSpan,
|
|
244
|
-
formItemContainer: injectFormItemContainer,
|
|
245
|
-
xs,
|
|
246
|
-
sm,
|
|
247
|
-
md,
|
|
248
|
-
lg,
|
|
249
|
-
xl,
|
|
250
|
-
...injectRest
|
|
251
|
-
} = rawInjectProps;
|
|
252
|
-
const initGridItemProps = span || span === 0 ? { span } : { xs, sm, md, lg, xl, span: injectSpan };
|
|
253
|
-
gridItemProps2 = fields ? { span: span ?? 24 } : initGridItemProps;
|
|
254
|
-
formItemProps2 = mergeProps(
|
|
255
|
-
injectRest,
|
|
256
|
-
{ class: injectClassName, style: injectStyle },
|
|
257
|
-
{ class: toValue(formItemClass), style: toValue(formItemStyle) },
|
|
258
|
-
formItemDataAttrs
|
|
259
|
-
);
|
|
260
|
-
const container = formItemContainer ?? injectFormItemContainer;
|
|
261
|
-
Object.keys(rest).forEach((k) => {
|
|
262
|
-
if (gridItemPropKeySet.has(k)) {
|
|
263
|
-
gridItemProps2[k] = rest[k];
|
|
264
|
-
} else if (formItemPropKeySet.has(k)) {
|
|
265
|
-
formItemProps2[k] = rest[k];
|
|
266
|
-
} else {
|
|
267
|
-
componentProps[k] = rest[k];
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
Object.assign(componentProps, componentDataAttrs);
|
|
271
|
-
Object.keys(slots).forEach((k) => {
|
|
272
|
-
if (formItemSlotKeySet.has(k)) {
|
|
273
|
-
formItemSlots[k] = slots[k];
|
|
274
|
-
} else {
|
|
275
|
-
componentProps.slots[k] = slots[k];
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
const raw2 = toValue(name) ?? toValue(path);
|
|
279
|
-
return {
|
|
280
|
-
path: Array.isArray(raw2) ? raw2.join(".") : raw2 || "",
|
|
281
|
-
gridItemProps: gridItemProps2,
|
|
282
|
-
formItemProps: formItemProps2,
|
|
283
|
-
formItemSlots,
|
|
284
|
-
componentProps,
|
|
285
|
-
container,
|
|
286
|
-
rawField: field
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
const raw = toValue(field == null ? void 0 : field.name) ?? toValue(field == null ? void 0 : field.path);
|
|
290
|
-
return {
|
|
291
|
-
path: Array.isArray(raw) ? raw.join(".") : raw || "",
|
|
292
|
-
gridItemProps: gridItemProps2,
|
|
293
|
-
formItemProps: formItemProps2,
|
|
294
|
-
formItemSlots,
|
|
295
|
-
componentProps,
|
|
296
|
-
rawField: field
|
|
297
|
-
};
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
302
|
-
...{ name: "BaseFormItem", inheritAttrs: false },
|
|
303
|
-
__name: "index",
|
|
304
|
-
props: {
|
|
305
|
-
grid: { type: [Boolean, Object], default: void 0 },
|
|
306
|
-
fields: { default: () => [] }
|
|
307
|
-
},
|
|
308
|
-
setup(__props) {
|
|
309
|
-
const props = __props;
|
|
310
|
-
const validFields = computed(
|
|
311
|
-
() => (
|
|
312
|
-
// hidden 支持 Ref/ComputedRef/getter 等响应式形态(统一使用 toValue 取值)
|
|
313
|
-
(props.fields ?? []).filter((field) => !toValue(field.hidden))
|
|
314
|
-
)
|
|
315
|
-
);
|
|
316
|
-
const config = INJECT_CONFIG["pro-form"];
|
|
317
|
-
const injectFormConfig = inject(config.injectionKey, config.default);
|
|
318
|
-
const injectGrid = computed(() => {
|
|
319
|
-
var _a;
|
|
320
|
-
return (_a = toValue(injectFormConfig)) == null ? void 0 : _a.grid;
|
|
321
|
-
});
|
|
322
|
-
const enableGrid = computed(() => {
|
|
323
|
-
if (props.grid !== void 0) return !!props.grid;
|
|
324
|
-
return !!injectGrid.value;
|
|
325
|
-
});
|
|
326
|
-
const computedGridProps = computed(() => {
|
|
327
|
-
return enableGrid.value ? { ...getObject(injectGrid.value), ...getObject(props.grid) } : {};
|
|
328
|
-
});
|
|
329
|
-
const formItemInstanceMap = /* @__PURE__ */ new WeakMap();
|
|
330
|
-
const componentInstanceMap = /* @__PURE__ */ new WeakMap();
|
|
331
|
-
const setFormItemRef = (field, el, formItemProps2) => {
|
|
332
|
-
if (!field || typeof field !== "object") return;
|
|
333
|
-
const raw = toRaw(field);
|
|
334
|
-
if (el) {
|
|
335
|
-
formItemInstanceMap.set(raw, el);
|
|
336
|
-
raw.getFormItemRef = () => formItemInstanceMap.get(raw);
|
|
337
|
-
raw.getFormItemComputedProps = () => formItemProps2;
|
|
338
|
-
} else {
|
|
339
|
-
formItemInstanceMap.delete(raw);
|
|
340
|
-
delete raw.getFormItemRef;
|
|
341
|
-
delete raw.getFormItemComputedProps;
|
|
342
|
-
}
|
|
343
|
-
};
|
|
344
|
-
const setComponentRef = (field, el) => {
|
|
345
|
-
if (!field || typeof field !== "object") return;
|
|
346
|
-
const raw = toRaw(field);
|
|
347
|
-
if (el) {
|
|
348
|
-
componentInstanceMap.set(raw, el);
|
|
349
|
-
raw.getComponentRef = () => {
|
|
350
|
-
var _a;
|
|
351
|
-
return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentRef();
|
|
352
|
-
};
|
|
353
|
-
raw.getComponentComputedProps = () => {
|
|
354
|
-
var _a;
|
|
355
|
-
return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentComputedProps();
|
|
356
|
-
};
|
|
357
|
-
} else {
|
|
358
|
-
componentInstanceMap.delete(raw);
|
|
359
|
-
delete raw.getComponentRef;
|
|
360
|
-
delete raw.getComponentComputedProps;
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
const groupedFields = useGroupFieldAttrs(validFields);
|
|
364
|
-
return (_ctx, _cache) => {
|
|
365
|
-
const _component_BaseFormItem = resolveComponent("BaseFormItem");
|
|
366
|
-
return openBlock(), createBlock(unref(_sfc_main$d), mergeProps({
|
|
367
|
-
component: enableGrid.value ? unref(ElRow) : void 0
|
|
368
|
-
}, computedGridProps.value, { style: { "width": "100%" } }), {
|
|
369
|
-
default: withCtx(() => [
|
|
370
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(groupedFields), (item, index2) => {
|
|
371
|
-
return openBlock(), createBlock(unref(_sfc_main$d), mergeProps({
|
|
372
|
-
key: item.path || index2,
|
|
373
|
-
component: enableGrid.value ? unref(ElCol) : void 0
|
|
374
|
-
}, { ref_for: true }, item.gridItemProps), {
|
|
375
|
-
default: withCtx(() => [
|
|
376
|
-
createVNode(unref(_sfc_main$d), {
|
|
377
|
-
component: item.container,
|
|
378
|
-
path: item.path
|
|
379
|
-
}, {
|
|
380
|
-
default: withCtx(() => [
|
|
381
|
-
createVNode(unref(ElFormItem), mergeProps({ ref_for: true }, item.formItemProps, {
|
|
382
|
-
ref_for: true,
|
|
383
|
-
ref: (el) => setFormItemRef(item.rawField, el, item.formItemProps),
|
|
384
|
-
prop: unref(normalizePathKey)(item.path),
|
|
385
|
-
path: item.path
|
|
386
|
-
}), createSlots({
|
|
387
|
-
default: withCtx(() => [
|
|
388
|
-
item.rawField.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
|
|
389
|
-
key: 0,
|
|
390
|
-
grid: item.rawField.grid ?? props.grid,
|
|
391
|
-
fields: item.rawField.fields
|
|
392
|
-
}, null, 8, ["grid", "fields"])) : (openBlock(), createBlock(unref(_sfc_main$e), mergeProps({
|
|
393
|
-
key: 1,
|
|
394
|
-
ref_for: true,
|
|
395
|
-
ref: (el) => setComponentRef(item.rawField, el)
|
|
396
|
-
}, { ref_for: true }, item.componentProps, {
|
|
397
|
-
path: item.path
|
|
398
|
-
}), null, 16, ["path"]))
|
|
399
|
-
]),
|
|
400
|
-
_: 2
|
|
401
|
-
}, [
|
|
402
|
-
renderList(item.formItemSlots, (slot, name) => {
|
|
403
|
-
return {
|
|
404
|
-
name,
|
|
405
|
-
fn: withCtx((scoped) => [
|
|
406
|
-
createVNode(unref(_sfc_main$c), mergeProps({
|
|
407
|
-
path: item.path,
|
|
408
|
-
component: slot
|
|
409
|
-
}, { ref_for: true }, scoped), null, 16, ["path", "component"])
|
|
410
|
-
])
|
|
411
|
-
};
|
|
412
|
-
})
|
|
413
|
-
]), 1040, ["prop", "path"])
|
|
414
|
-
]),
|
|
415
|
-
_: 2
|
|
416
|
-
}, 1032, ["component", "path"])
|
|
417
|
-
]),
|
|
418
|
-
_: 2
|
|
419
|
-
}, 1040, ["component"]);
|
|
420
|
-
}), 128))
|
|
421
|
-
]),
|
|
422
|
-
_: 1
|
|
423
|
-
}, 16, ["component"]);
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
|
-
const _export_sfc = (sfc, props) => {
|
|
428
|
-
const target = sfc.__vccOpts || sfc;
|
|
429
|
-
for (const [key, val] of props) {
|
|
430
|
-
target[key] = val;
|
|
431
|
-
}
|
|
432
|
-
return target;
|
|
433
|
-
};
|
|
434
|
-
const BaseFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-42bb0876"]]);
|
|
268
|
+
const ELEMENT_FIELD_IDENTITY_KEYS = ["prop", "path"];
|
|
435
269
|
function useForm(...args) {
|
|
436
|
-
|
|
270
|
+
if (args.length === 1 && typeof args[0] === "boolean") {
|
|
271
|
+
return useForm$1(args[0]);
|
|
272
|
+
}
|
|
273
|
+
return useForm$1(args[0], args[1], args[2], {
|
|
274
|
+
fieldIdentityKeys: ELEMENT_FIELD_IDENTITY_KEYS
|
|
275
|
+
});
|
|
437
276
|
}
|
|
438
277
|
const PLACEHOLDER_KEYS = {
|
|
439
278
|
input: "input.placeholder",
|
|
@@ -537,7 +376,7 @@ const useLocale = () => {
|
|
|
537
376
|
const { lang: elLang } = useLocale$1();
|
|
538
377
|
const override = inject(LOCALE_INJECT_KEY, void 0);
|
|
539
378
|
const lang = computed(() => {
|
|
540
|
-
if (
|
|
379
|
+
if (toValue(elLocaleContext) == null) return "zh-CN";
|
|
541
380
|
return resolveLocaleName(elLang.value);
|
|
542
381
|
});
|
|
543
382
|
const pack = computed(
|
|
@@ -550,7 +389,7 @@ const useLocale = () => {
|
|
|
550
389
|
};
|
|
551
390
|
return { t, lang };
|
|
552
391
|
};
|
|
553
|
-
const _sfc_main$
|
|
392
|
+
const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
554
393
|
...{ name: "BaseField", inheritAttrs: false },
|
|
555
394
|
__name: "index",
|
|
556
395
|
props: {
|
|
@@ -558,15 +397,20 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
558
397
|
path: { default: "" }
|
|
559
398
|
},
|
|
560
399
|
setup(__props, { expose: __expose }) {
|
|
400
|
+
const cloneDeepIfObject = (val) => (
|
|
401
|
+
// 原始值直接传递,引用值克隆快照
|
|
402
|
+
typeof val === "object" && val !== null ? cloneDeep(val) : val
|
|
403
|
+
);
|
|
561
404
|
const props = __props;
|
|
562
405
|
const { t } = useLocale();
|
|
563
406
|
const form = useForm(false);
|
|
564
407
|
const componentRef = ref();
|
|
565
|
-
const attrs =
|
|
408
|
+
const attrs = useReactiveAttrs();
|
|
566
409
|
const typeVal = attrs.type;
|
|
567
410
|
const injectConfigKey = typeof props.component === "string" ? [props.component, typeVal].filter(Boolean).join(".") : "";
|
|
568
411
|
const componentInjectConfig = injectConfigKey ? getInjectConfig(injectConfigKey) : void 0;
|
|
569
412
|
const rawInjectComponentProps = componentInjectConfig ? inject(componentInjectConfig.injectionKey, componentInjectConfig.default) : void 0;
|
|
413
|
+
const componentVars = inject(INJECT_COMPONENT_VARS, void 0);
|
|
570
414
|
const value = computed({
|
|
571
415
|
get() {
|
|
572
416
|
var _a;
|
|
@@ -583,7 +427,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
583
427
|
const { valueFormatter } = groupedAttrs.value;
|
|
584
428
|
const setFormatter = typeof valueFormatter === "function" ? valueFormatter : typeof valueFormatter === "object" && typeof (valueFormatter == null ? void 0 : valueFormatter.set) === "function" ? valueFormatter.set : void 0;
|
|
585
429
|
if (setFormatter) {
|
|
586
|
-
const oldVal = setFormatter.length > 1 ?
|
|
430
|
+
const oldVal = setFormatter.length > 1 ? cloneDeepIfObject((_a = form.getFormData) == null ? void 0 : _a.call(form, props.path)) : void 0;
|
|
587
431
|
newVal = setFormatter(val, oldVal);
|
|
588
432
|
}
|
|
589
433
|
(_b = form.setFormData) == null ? void 0 : _b.call(form, props.path, newVal);
|
|
@@ -597,7 +441,11 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
597
441
|
});
|
|
598
442
|
const parentDisabled = useDisabledContext();
|
|
599
443
|
const groupedAttrs = computed(() => {
|
|
600
|
-
|
|
444
|
+
var _a;
|
|
445
|
+
const currentInjectProps = {
|
|
446
|
+
...toValue(rawInjectComponentProps) || {},
|
|
447
|
+
...getObject((_a = toValue(componentVars)) == null ? void 0 : _a[injectConfigKey])
|
|
448
|
+
};
|
|
601
449
|
const initProps = getInitProps(
|
|
602
450
|
{
|
|
603
451
|
component: props.component,
|
|
@@ -607,7 +455,8 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
607
455
|
t
|
|
608
456
|
);
|
|
609
457
|
const modelPropName = attrs.modelProp ?? initProps.modelProp ?? "modelValue";
|
|
610
|
-
const
|
|
458
|
+
const normalizeDisabled = (value2) => value2 === "" || value2 === "disabled" ? true : Boolean(value2);
|
|
459
|
+
const effectiveDisabled = attrs.disabled !== void 0 && attrs.disabled !== null ? normalizeDisabled(attrs.disabled) : normalizeDisabled(parentDisabled.value) || normalizeDisabled(initProps.disabled);
|
|
611
460
|
const mergedProps = mergeProps(
|
|
612
461
|
initProps,
|
|
613
462
|
attrs,
|
|
@@ -625,14 +474,14 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
625
474
|
onUpdateValue
|
|
626
475
|
};
|
|
627
476
|
});
|
|
628
|
-
const
|
|
477
|
+
const injectedFormSlots = inject(InjectionFormSlotsKey, void 0);
|
|
629
478
|
const customComponents = inject(INJECT_COMPONENTS, {});
|
|
630
479
|
const is = computed(() => {
|
|
631
|
-
var _a;
|
|
632
|
-
const teleportSlot = props.path && (
|
|
480
|
+
var _a, _b;
|
|
481
|
+
const teleportSlot = props.path && ((_a = injectedFormSlots == null ? void 0 : injectedFormSlots.value) == null ? void 0 : _a[props.path]);
|
|
633
482
|
if (teleportSlot) return teleportSlot;
|
|
634
483
|
if (typeof props.component === "string") {
|
|
635
|
-
const resolved = ((
|
|
484
|
+
const resolved = ((_b = toValue(customComponents)) == null ? void 0 : _b[props.component]) || componentMap[props.component];
|
|
636
485
|
if (resolved) return resolved;
|
|
637
486
|
warnUnknownComponent(props.component);
|
|
638
487
|
return props.component;
|
|
@@ -644,7 +493,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
644
493
|
getComponentComputedProps: () => groupedAttrs.value.attrs
|
|
645
494
|
});
|
|
646
495
|
return (_ctx, _cache) => {
|
|
647
|
-
return openBlock(), createBlock(
|
|
496
|
+
return openBlock(), createBlock(_sfc_main$f, {
|
|
648
497
|
component: groupedAttrs.value.componentContainer,
|
|
649
498
|
path: props.path
|
|
650
499
|
}, {
|
|
@@ -660,7 +509,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
660
509
|
return {
|
|
661
510
|
name,
|
|
662
511
|
fn: withCtx((scoped) => [
|
|
663
|
-
createVNode(
|
|
512
|
+
createVNode(_sfc_main$e, mergeProps({
|
|
664
513
|
path: props.path
|
|
665
514
|
}, scoped, { component: slot }), null, 16, ["path", "component"])
|
|
666
515
|
])
|
|
@@ -673,51 +522,260 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
673
522
|
};
|
|
674
523
|
}
|
|
675
524
|
});
|
|
676
|
-
const
|
|
677
|
-
|
|
525
|
+
const fieldKeyMap = /* @__PURE__ */ new WeakMap();
|
|
526
|
+
let fieldKeySeed = 0;
|
|
527
|
+
const getFieldKey = (field) => {
|
|
528
|
+
if (field === null || typeof field !== "object")
|
|
529
|
+
return `raw_${String(field)}`;
|
|
530
|
+
const raw = toRaw(field);
|
|
531
|
+
let key = fieldKeyMap.get(raw);
|
|
532
|
+
if (key === void 0) {
|
|
533
|
+
key = ++fieldKeySeed;
|
|
534
|
+
fieldKeyMap.set(raw, key);
|
|
535
|
+
}
|
|
536
|
+
return key;
|
|
537
|
+
};
|
|
538
|
+
const formItemPropKeys = Object.keys(formItemProps());
|
|
539
|
+
const gridItemPropKeys = Object.keys(gridItemProps());
|
|
540
|
+
const gridItemPropKeySet = new Set(gridItemPropKeys);
|
|
541
|
+
const formItemPropKeySet = new Set(formItemPropKeys);
|
|
542
|
+
const formItemSlotKeySet = new Set(FORM_ITEM_SLOT_KEYS);
|
|
543
|
+
function useGroupFieldAttrs(validFields) {
|
|
544
|
+
const config = INJECT_CONFIG["pro-form-item"];
|
|
545
|
+
const injectFormItemProps = inject(config.injectionKey, config.default);
|
|
546
|
+
return computed(() => {
|
|
547
|
+
const rawInjectProps = toValue(injectFormItemProps) || {};
|
|
548
|
+
return validFields.value.map((field) => {
|
|
549
|
+
let gridItemProps2 = {};
|
|
550
|
+
let formItemProps2 = {};
|
|
551
|
+
const componentProps = { slots: {} };
|
|
552
|
+
const formItemSlots = {};
|
|
553
|
+
if (isPlainObject(field)) {
|
|
554
|
+
const { path: _path, prop: _prop, fields, formItemClass, formItemStyle, formItemContainer, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, ...rest } = field;
|
|
555
|
+
const { class: injectClassName, style: injectStyle, span: injectSpan, formItemContainer: injectFormItemContainer, xs, sm, md, lg, xl, ...injectRest } = rawInjectProps;
|
|
556
|
+
const initGridItemProps = span || span === 0 ? { span } : { xs, sm, md, lg, xl, span: injectSpan };
|
|
557
|
+
gridItemProps2 = fields ? { ...initGridItemProps, span: span ?? 24 } : initGridItemProps;
|
|
558
|
+
formItemProps2 = mergeProps(
|
|
559
|
+
injectRest,
|
|
560
|
+
{ class: injectClassName, style: injectStyle },
|
|
561
|
+
{ class: toValue(formItemClass), style: toValue(formItemStyle) },
|
|
562
|
+
formItemDataAttrs
|
|
563
|
+
);
|
|
564
|
+
const container = formItemContainer ?? injectFormItemContainer;
|
|
565
|
+
Object.keys(rest).forEach((k) => {
|
|
566
|
+
if (gridItemPropKeySet.has(k)) {
|
|
567
|
+
gridItemProps2[k] = rest[k];
|
|
568
|
+
} else if (formItemPropKeySet.has(k)) {
|
|
569
|
+
formItemProps2[k] = rest[k];
|
|
570
|
+
} else {
|
|
571
|
+
componentProps[k] = rest[k];
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
Object.assign(componentProps, componentDataAttrs);
|
|
575
|
+
Object.keys(slots).forEach((k) => {
|
|
576
|
+
if (formItemSlotKeySet.has(k)) {
|
|
577
|
+
formItemSlots[k] = slots[k];
|
|
578
|
+
} else {
|
|
579
|
+
componentProps.slots[k] = slots[k];
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
return {
|
|
583
|
+
path: resolveFieldIdentity(field, ELEMENT_FIELD_IDENTITY_KEYS),
|
|
584
|
+
gridItemProps: gridItemProps2,
|
|
585
|
+
formItemProps: formItemProps2,
|
|
586
|
+
formItemSlots,
|
|
587
|
+
componentProps,
|
|
588
|
+
container,
|
|
589
|
+
rawField: field,
|
|
590
|
+
renderKey: getFieldKey(field)
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
return {
|
|
594
|
+
path: resolveFieldIdentity(field, ELEMENT_FIELD_IDENTITY_KEYS),
|
|
595
|
+
gridItemProps: gridItemProps2,
|
|
596
|
+
formItemProps: formItemProps2,
|
|
597
|
+
formItemSlots,
|
|
598
|
+
componentProps,
|
|
599
|
+
rawField: field,
|
|
600
|
+
renderKey: getFieldKey(field)
|
|
601
|
+
};
|
|
602
|
+
});
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
606
|
+
...{ name: "BaseFormItem", inheritAttrs: false },
|
|
678
607
|
__name: "index",
|
|
679
608
|
props: {
|
|
680
|
-
|
|
609
|
+
grid: { type: [Boolean, Object], default: void 0 },
|
|
610
|
+
fields: { default: () => [] },
|
|
611
|
+
disabled: { type: Boolean, default: void 0 }
|
|
681
612
|
},
|
|
682
613
|
setup(__props) {
|
|
614
|
+
const props = __props;
|
|
615
|
+
useProviderDisabled(computed(() => props.disabled));
|
|
616
|
+
const validFields = computed(
|
|
617
|
+
() => (
|
|
618
|
+
// hidden 支持 Ref / ComputedRef 响应式形态(统一使用 toValue 取值)
|
|
619
|
+
(props.fields ?? []).filter(
|
|
620
|
+
(field) => isObjectItem(field) && !toValue(field.hidden)
|
|
621
|
+
)
|
|
622
|
+
)
|
|
623
|
+
);
|
|
624
|
+
const config = INJECT_CONFIG["pro-form"];
|
|
625
|
+
const injectFormConfig = inject(config.injectionKey, config.default);
|
|
626
|
+
const injectGrid = computed(() => {
|
|
627
|
+
var _a;
|
|
628
|
+
return (_a = toValue(injectFormConfig)) == null ? void 0 : _a.grid;
|
|
629
|
+
});
|
|
630
|
+
const enableGrid = computed(() => {
|
|
631
|
+
if (props.grid !== void 0) return !!props.grid;
|
|
632
|
+
return !!injectGrid.value;
|
|
633
|
+
});
|
|
634
|
+
const computedGridProps = computed(() => {
|
|
635
|
+
return enableGrid.value ? { ...getObject(injectGrid.value), ...getObject(props.grid) } : {};
|
|
636
|
+
});
|
|
637
|
+
const formItemInstanceMap = /* @__PURE__ */ new WeakMap();
|
|
638
|
+
const componentInstanceMap = /* @__PURE__ */ new WeakMap();
|
|
639
|
+
const warnedFrozenFields = /* @__PURE__ */ new WeakSet();
|
|
640
|
+
const defineFieldAccessors = (raw, accessors) => {
|
|
641
|
+
try {
|
|
642
|
+
for (const [key, getter] of Object.entries(accessors)) {
|
|
643
|
+
Object.defineProperty(raw, key, {
|
|
644
|
+
value: getter,
|
|
645
|
+
enumerable: false,
|
|
646
|
+
configurable: true,
|
|
647
|
+
writable: true
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
} catch {
|
|
651
|
+
if (!warnedFrozenFields.has(raw)) {
|
|
652
|
+
warnedFrozenFields.add(raw);
|
|
653
|
+
console.warn(
|
|
654
|
+
"[pro-components] 字段配置对象不可写(如被 Object.freeze),getFormItemRef / getComponentRef 等实例访问器挂载失败。"
|
|
655
|
+
);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
};
|
|
659
|
+
const setFormItemRef = (field, el, formItemProps2) => {
|
|
660
|
+
if (!field || typeof field !== "object") return;
|
|
661
|
+
const raw = toRaw(field);
|
|
662
|
+
if (el) {
|
|
663
|
+
formItemInstanceMap.set(raw, el);
|
|
664
|
+
defineFieldAccessors(raw, {
|
|
665
|
+
getFormItemRef: () => formItemInstanceMap.get(raw),
|
|
666
|
+
getFormItemComputedProps: () => formItemProps2
|
|
667
|
+
});
|
|
668
|
+
} else {
|
|
669
|
+
formItemInstanceMap.delete(raw);
|
|
670
|
+
delete raw.getFormItemRef;
|
|
671
|
+
delete raw.getFormItemComputedProps;
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
const setComponentRef = (field, el) => {
|
|
675
|
+
if (!field || typeof field !== "object") return;
|
|
676
|
+
const raw = toRaw(field);
|
|
677
|
+
if (el) {
|
|
678
|
+
componentInstanceMap.set(raw, el);
|
|
679
|
+
defineFieldAccessors(raw, {
|
|
680
|
+
getComponentRef: () => {
|
|
681
|
+
var _a;
|
|
682
|
+
return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentRef();
|
|
683
|
+
},
|
|
684
|
+
getComponentComputedProps: () => {
|
|
685
|
+
var _a;
|
|
686
|
+
return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentComputedProps();
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
} else {
|
|
690
|
+
componentInstanceMap.delete(raw);
|
|
691
|
+
delete raw.getComponentRef;
|
|
692
|
+
delete raw.getComponentComputedProps;
|
|
693
|
+
}
|
|
694
|
+
};
|
|
695
|
+
const groupedFields = useGroupFieldAttrs(validFields);
|
|
683
696
|
return (_ctx, _cache) => {
|
|
684
|
-
|
|
697
|
+
const _component_BaseFormItem = resolveComponent("BaseFormItem");
|
|
698
|
+
return openBlock(), createBlock(_sfc_main$f, mergeProps({
|
|
699
|
+
component: enableGrid.value ? unref(ElRow) : void 0
|
|
700
|
+
}, computedGridProps.value, { style: { "width": "100%" } }), {
|
|
685
701
|
default: withCtx(() => [
|
|
686
|
-
|
|
702
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(groupedFields), (item) => {
|
|
703
|
+
return openBlock(), createBlock(_sfc_main$f, mergeProps({
|
|
704
|
+
key: item.renderKey,
|
|
705
|
+
component: enableGrid.value ? unref(ElCol) : void 0
|
|
706
|
+
}, { ref_for: true }, item.gridItemProps), {
|
|
707
|
+
default: withCtx(() => [
|
|
708
|
+
createVNode(_sfc_main$f, {
|
|
709
|
+
component: item.container,
|
|
710
|
+
path: item.path
|
|
711
|
+
}, {
|
|
712
|
+
default: withCtx(() => [
|
|
713
|
+
createVNode(unref(ElFormItem), mergeProps({ ref_for: true }, item.formItemProps, {
|
|
714
|
+
ref_for: true,
|
|
715
|
+
ref: (el) => setFormItemRef(item.rawField, el, item.formItemProps),
|
|
716
|
+
prop: unref(normalizePathKey)(item.path),
|
|
717
|
+
path: item.path
|
|
718
|
+
}), createSlots({
|
|
719
|
+
default: withCtx(() => [
|
|
720
|
+
item.rawField.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
|
|
721
|
+
key: 0,
|
|
722
|
+
grid: item.rawField.grid ?? props.grid,
|
|
723
|
+
fields: item.rawField.fields,
|
|
724
|
+
disabled: toValue(item.rawField.disabled)
|
|
725
|
+
}, null, 8, ["grid", "fields", "disabled"])) : (openBlock(), createBlock(_sfc_main$d, mergeProps({
|
|
726
|
+
key: 1,
|
|
727
|
+
ref_for: true,
|
|
728
|
+
ref: (el) => setComponentRef(item.rawField, el)
|
|
729
|
+
}, { ref_for: true }, item.componentProps, {
|
|
730
|
+
path: item.path
|
|
731
|
+
}), null, 16, ["path"]))
|
|
732
|
+
]),
|
|
733
|
+
_: 2
|
|
734
|
+
}, [
|
|
735
|
+
renderList(item.formItemSlots, (slot, name) => {
|
|
736
|
+
return {
|
|
737
|
+
name,
|
|
738
|
+
fn: withCtx((scoped) => [
|
|
739
|
+
createVNode(_sfc_main$e, mergeProps({
|
|
740
|
+
path: item.path,
|
|
741
|
+
component: slot
|
|
742
|
+
}, { ref_for: true }, scoped), null, 16, ["path", "component"])
|
|
743
|
+
])
|
|
744
|
+
};
|
|
745
|
+
})
|
|
746
|
+
]), 1040, ["prop", "path"])
|
|
747
|
+
]),
|
|
748
|
+
_: 2
|
|
749
|
+
}, 1032, ["component", "path"])
|
|
750
|
+
]),
|
|
751
|
+
_: 2
|
|
752
|
+
}, 1040, ["component"]);
|
|
753
|
+
}), 128))
|
|
687
754
|
]),
|
|
688
|
-
_:
|
|
689
|
-
}, 16
|
|
755
|
+
_: 1
|
|
756
|
+
}, 16, ["component"]);
|
|
690
757
|
};
|
|
691
758
|
}
|
|
692
759
|
});
|
|
693
|
-
const
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
component: { type: [Object, Function, String, Number, Boolean, null] }
|
|
698
|
-
},
|
|
699
|
-
setup(__props) {
|
|
700
|
-
const isRenderable = (c) => c !== null && c !== void 0 && (typeof c === "function" || typeof c === "object");
|
|
701
|
-
return (_ctx, _cache) => {
|
|
702
|
-
return isRenderable(__props.component) ? (openBlock(), createBlock(resolveDynamicComponent(__props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), null, 16)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
703
|
-
createTextVNode(toDisplayString(__props.component), 1)
|
|
704
|
-
], 64));
|
|
705
|
-
};
|
|
760
|
+
const _export_sfc = (sfc, props) => {
|
|
761
|
+
const target = sfc.__vccOpts || sfc;
|
|
762
|
+
for (const [key, val] of props) {
|
|
763
|
+
target[key] = val;
|
|
706
764
|
}
|
|
707
|
-
|
|
765
|
+
return target;
|
|
766
|
+
};
|
|
767
|
+
const BaseFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-237594c9"]]);
|
|
708
768
|
const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
709
769
|
...{ name: "ProForm", inheritAttrs: false },
|
|
710
770
|
__name: "index",
|
|
711
771
|
props: {
|
|
712
|
-
grid: { type: [Boolean, Object], default:
|
|
772
|
+
grid: { type: [Boolean, Object], default: void 0 },
|
|
713
773
|
form: { default: void 0 }
|
|
714
774
|
},
|
|
715
775
|
setup(__props) {
|
|
716
776
|
const props = __props;
|
|
717
|
-
const fallbackForm =
|
|
718
|
-
const currentForm = computed(
|
|
719
|
-
() => props.form ?? fallbackForm
|
|
720
|
-
);
|
|
777
|
+
const fallbackForm = useForm();
|
|
778
|
+
const currentForm = computed(() => props.form ?? fallbackForm);
|
|
721
779
|
const formProxy = createFormProxy(() => currentForm.value);
|
|
722
780
|
provide(InjectionFormKey, formProxy);
|
|
723
781
|
const fields = computed(() => {
|
|
@@ -736,6 +794,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
736
794
|
let formInstanceCounter = 0;
|
|
737
795
|
const formInstanceKeyMap = /* @__PURE__ */ new WeakMap();
|
|
738
796
|
const getFormKey = (f) => {
|
|
797
|
+
if (f == null) return 0;
|
|
739
798
|
if (!formInstanceKeyMap.has(f)) {
|
|
740
799
|
formInstanceKeyMap.set(f, ++formInstanceCounter);
|
|
741
800
|
}
|
|
@@ -744,17 +803,24 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
744
803
|
const formKey = computed(() => getFormKey(currentForm.value));
|
|
745
804
|
const config = INJECT_CONFIG["pro-form"];
|
|
746
805
|
const injectFormConfig = inject(config.injectionKey, config.default);
|
|
747
|
-
const attrs =
|
|
806
|
+
const attrs = useReactiveAttrs();
|
|
748
807
|
const injectAttrs = computed(() => {
|
|
749
808
|
const raw = toValue(injectFormConfig);
|
|
750
809
|
const { grid: _injectGrid, ...rest } = raw || {};
|
|
751
810
|
return rest;
|
|
752
811
|
});
|
|
753
812
|
const formAttrs = computed(() => {
|
|
754
|
-
return mergeProps(
|
|
813
|
+
return mergeProps(
|
|
814
|
+
injectAttrs.value,
|
|
815
|
+
omitBy(camelizeProperties(attrs), (value) => value === void 0)
|
|
816
|
+
);
|
|
755
817
|
});
|
|
756
818
|
const slots = useSlots();
|
|
757
|
-
|
|
819
|
+
const formSlotsRef = shallowRef(slots);
|
|
820
|
+
onUpdated(() => {
|
|
821
|
+
triggerRef(formSlotsRef);
|
|
822
|
+
});
|
|
823
|
+
provide(InjectionFormSlotsKey, formSlotsRef);
|
|
758
824
|
return (_ctx, _cache) => {
|
|
759
825
|
return openBlock(), createBlock(unref(ElForm), mergeProps({
|
|
760
826
|
key: formKey.value,
|
|
@@ -766,7 +832,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
766
832
|
}, ["prevent"]))
|
|
767
833
|
}), {
|
|
768
834
|
default: withCtx(() => [
|
|
769
|
-
createVNode(
|
|
835
|
+
createVNode(BaseFormItem, {
|
|
770
836
|
fields: fields.value,
|
|
771
837
|
grid: props.grid
|
|
772
838
|
}, null, 8, ["fields", "grid"]),
|
|
@@ -778,7 +844,9 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
778
844
|
}
|
|
779
845
|
});
|
|
780
846
|
function useFields(initFields) {
|
|
781
|
-
return useFields$1(initFields
|
|
847
|
+
return useFields$1(initFields, {
|
|
848
|
+
fieldIdentityKeys: ELEMENT_FIELD_IDENTITY_KEYS
|
|
849
|
+
});
|
|
782
850
|
}
|
|
783
851
|
function useFormRef() {
|
|
784
852
|
return useFormRef$1();
|
|
@@ -803,7 +871,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
803
871
|
...{ name: "SearchForm" },
|
|
804
872
|
__name: "SearchForm",
|
|
805
873
|
props: {
|
|
806
|
-
form: {
|
|
874
|
+
form: {},
|
|
807
875
|
layout: { default: "grid" },
|
|
808
876
|
expand: { type: [Boolean, Object], default: true },
|
|
809
877
|
searchButton: { type: [Object, Function, Boolean], default: void 0 },
|
|
@@ -845,13 +913,27 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
845
913
|
const onReset = () => {
|
|
846
914
|
emit("reset");
|
|
847
915
|
};
|
|
848
|
-
|
|
916
|
+
let searchTriggeredInTick = false;
|
|
917
|
+
const emitSearch = () => {
|
|
918
|
+
searchTriggeredInTick = true;
|
|
919
|
+
nextTick(() => {
|
|
920
|
+
searchTriggeredInTick = false;
|
|
921
|
+
});
|
|
849
922
|
emit("search");
|
|
850
923
|
};
|
|
924
|
+
const onSearchSubmit = () => {
|
|
925
|
+
if (searchTriggeredInTick) return;
|
|
926
|
+
emitSearch();
|
|
927
|
+
};
|
|
928
|
+
const onSearchClick = () => {
|
|
929
|
+
if (searchTriggeredInTick) return;
|
|
930
|
+
emitSearch();
|
|
931
|
+
};
|
|
851
932
|
return (_ctx, _cache) => {
|
|
852
|
-
return openBlock(), createBlock(
|
|
933
|
+
return openBlock(), createBlock(_sfc_main$b, mergeProps(layoutProps.value, {
|
|
853
934
|
form: props.form,
|
|
854
|
-
class: "pro-table_search-form transition"
|
|
935
|
+
class: "pro-table_search-form transition",
|
|
936
|
+
onSubmit: withModifiers(onSearchSubmit, ["prevent"])
|
|
855
937
|
}), {
|
|
856
938
|
default: withCtx(() => [
|
|
857
939
|
createVNode(unref(ElSpace), {
|
|
@@ -876,17 +958,16 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
876
958
|
}))
|
|
877
959
|
], 64)) : createCommentVNode("", true)
|
|
878
960
|
], true),
|
|
879
|
-
renderSlot(_ctx.$slots, "search-button", { onSearch }, () => [
|
|
961
|
+
renderSlot(_ctx.$slots, "search-button", { onSearch: onSearchClick }, () => [
|
|
880
962
|
props.searchButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
881
963
|
props.searchButton ? (openBlock(), createBlock(resolveDynamicComponent(props.searchButton), {
|
|
882
964
|
key: 0,
|
|
883
|
-
onClick:
|
|
965
|
+
onClick: onSearchClick
|
|
884
966
|
})) : (openBlock(), createBlock(unref(ElButton), {
|
|
885
967
|
key: 1,
|
|
886
968
|
class: "pro-table_search-form_search-button",
|
|
887
969
|
type: "primary",
|
|
888
|
-
"native-type": "submit"
|
|
889
|
-
onClick: onSearch
|
|
970
|
+
"native-type": "submit"
|
|
890
971
|
}, {
|
|
891
972
|
default: withCtx(() => [
|
|
892
973
|
createTextVNode(toDisplayString(unref(t)("table.query")), 1)
|
|
@@ -930,7 +1011,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
930
1011
|
};
|
|
931
1012
|
}
|
|
932
1013
|
});
|
|
933
|
-
const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-
|
|
1014
|
+
const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-419025fd"]]);
|
|
934
1015
|
const _sfc_main$8 = {};
|
|
935
1016
|
const _hoisted_1$4 = { class: "pro-table_search-form-container" };
|
|
936
1017
|
function _sfc_render$3(_ctx, _cache) {
|
|
@@ -965,15 +1046,21 @@ function _sfc_render$1(_ctx, _cache) {
|
|
|
965
1046
|
const ColumnHeightOutlined = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$1]]);
|
|
966
1047
|
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
967
1048
|
__name: "SizeControl",
|
|
968
|
-
props: {
|
|
1049
|
+
props: /* @__PURE__ */ mergeModels({
|
|
1050
|
+
effectiveSize: { default: void 0 }
|
|
1051
|
+
}, {
|
|
969
1052
|
"size": {},
|
|
970
1053
|
"sizeModifiers": {}
|
|
971
|
-
},
|
|
1054
|
+
}),
|
|
972
1055
|
emits: ["update:size"],
|
|
973
1056
|
setup(__props) {
|
|
974
1057
|
const { t } = useLocale();
|
|
1058
|
+
const props = __props;
|
|
975
1059
|
const size = useModel(__props, "size");
|
|
976
|
-
const
|
|
1060
|
+
const hostSize = useSize();
|
|
1061
|
+
const currentSize = computed(
|
|
1062
|
+
() => (props.effectiveSize ?? size.value ?? hostSize.value) || "default"
|
|
1063
|
+
);
|
|
977
1064
|
const items = computed(() => [
|
|
978
1065
|
{ label: t("table.sizeDefault"), key: "default" },
|
|
979
1066
|
{ label: t("table.sizeMiddle"), key: "large" },
|
|
@@ -1019,7 +1106,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
1019
1106
|
};
|
|
1020
1107
|
}
|
|
1021
1108
|
});
|
|
1022
|
-
const SizeControl = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-
|
|
1109
|
+
const SizeControl = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-61d0ef11"]]);
|
|
1023
1110
|
const _sfc_main$4 = {};
|
|
1024
1111
|
const _hoisted_1$1 = {
|
|
1025
1112
|
focusable: "false",
|
|
@@ -1048,16 +1135,16 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
1048
1135
|
const { t } = useLocale();
|
|
1049
1136
|
const checkAll = ref(false);
|
|
1050
1137
|
const indeterminate = ref(false);
|
|
1051
|
-
const
|
|
1052
|
-
const rawKey = column.key
|
|
1138
|
+
const getColumnKey2 = (column) => {
|
|
1139
|
+
const rawKey = column.key || column.prop;
|
|
1053
1140
|
if (rawKey === void 0 || rawKey === null || rawKey === "")
|
|
1054
1141
|
return void 0;
|
|
1055
1142
|
return normalizePathKey(rawKey);
|
|
1056
1143
|
};
|
|
1057
1144
|
const checkedColumnsOptions = computed(
|
|
1058
|
-
() => props.columns.flatMap((item) => {
|
|
1145
|
+
() => props.columns.filter(isObjectItem).flatMap((item) => {
|
|
1059
1146
|
var _a, _b, _c, _d, _e, _f;
|
|
1060
|
-
const key =
|
|
1147
|
+
const key = getColumnKey2(item);
|
|
1061
1148
|
if (key === void 0) return [];
|
|
1062
1149
|
if (key === "__INDEX__" || item.type === "index" || ((_b = (_a = props.columnControl) == null ? void 0 : _a.excludedKeys) == null ? void 0 : _b.some((ek) => String(ek) === key)))
|
|
1063
1150
|
return [];
|
|
@@ -1069,7 +1156,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
1069
1156
|
return {
|
|
1070
1157
|
label,
|
|
1071
1158
|
value: key,
|
|
1072
|
-
checked: !item.hidden || !!disabled,
|
|
1159
|
+
checked: !toValue(item.hidden) || !!disabled,
|
|
1073
1160
|
disabled: !!disabled,
|
|
1074
1161
|
column: item
|
|
1075
1162
|
};
|
|
@@ -1085,11 +1172,12 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
1085
1172
|
);
|
|
1086
1173
|
},
|
|
1087
1174
|
set(val) {
|
|
1175
|
+
const checkedSet = new Set(val);
|
|
1088
1176
|
checkedColumnsOptions.value.forEach((item) => {
|
|
1089
1177
|
var _a;
|
|
1090
|
-
if (item.disabled) return;
|
|
1178
|
+
if (item.disabled || item.checked === checkedSet.has(item.value)) return;
|
|
1091
1179
|
(_a = props.table) == null ? void 0 : _a.setColumn(item.value, {
|
|
1092
|
-
hidden: !
|
|
1180
|
+
hidden: !checkedSet.has(item.value)
|
|
1093
1181
|
});
|
|
1094
1182
|
});
|
|
1095
1183
|
}
|
|
@@ -1204,79 +1292,76 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
1204
1292
|
};
|
|
1205
1293
|
}
|
|
1206
1294
|
});
|
|
1207
|
-
const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1295
|
+
const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-4d2b4f1c"]]);
|
|
1296
|
+
let columnKeySeed = 0;
|
|
1297
|
+
const columnKeyMap = /* @__PURE__ */ new WeakMap();
|
|
1298
|
+
const getStableColumnKey = (column) => {
|
|
1299
|
+
if (column === null || typeof column !== "object")
|
|
1300
|
+
return `raw_${String(column)}`;
|
|
1301
|
+
const raw = toRaw(column);
|
|
1302
|
+
let key = columnKeyMap.get(raw);
|
|
1303
|
+
if (key === void 0) {
|
|
1304
|
+
key = ++columnKeySeed;
|
|
1305
|
+
columnKeyMap.set(raw, key);
|
|
1306
|
+
}
|
|
1307
|
+
return key;
|
|
1308
|
+
};
|
|
1309
|
+
const getColumnKey = (column) => {
|
|
1310
|
+
const rawKey = column.key || column.prop;
|
|
1311
|
+
if (!rawKey) return getStableColumnKey(column);
|
|
1312
|
+
return normalizePathKey(rawKey);
|
|
1313
|
+
};
|
|
1314
|
+
const getCellValue = (row, column) => {
|
|
1315
|
+
const path = column.prop;
|
|
1316
|
+
if (!path) return void 0;
|
|
1317
|
+
return get(row, path);
|
|
1318
|
+
};
|
|
1319
|
+
const getColumnProps = (column) => {
|
|
1320
|
+
const { hidden, render, key, children, ...rest } = column;
|
|
1321
|
+
const prop = column.prop ? normalizePathKey(column.prop) : void 0;
|
|
1322
|
+
const columnKey = key ? normalizePathKey(key) : prop;
|
|
1323
|
+
return {
|
|
1324
|
+
...rest,
|
|
1325
|
+
label: column.label ?? column.title,
|
|
1326
|
+
prop,
|
|
1327
|
+
columnKey
|
|
1328
|
+
};
|
|
1329
|
+
};
|
|
1330
|
+
const renderColumn = (column, ancestors = /* @__PURE__ */ new Set()) => {
|
|
1331
|
+
const hasChildren = Array.isArray(column.children) && column.children.length > 0;
|
|
1332
|
+
const vnodeProps = { key: getColumnKey(column), ...getColumnProps(column) };
|
|
1333
|
+
if (hasChildren) {
|
|
1334
|
+
const nextAncestors = new Set(ancestors).add(column);
|
|
1335
|
+
return h(ElTableColumn, vnodeProps, {
|
|
1336
|
+
default: () => column.children.filter(
|
|
1337
|
+
(child) => isObjectItem(child) && !nextAncestors.has(child) && !toValue(child.hidden)
|
|
1338
|
+
).map((child) => renderColumn(child, nextAncestors))
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
if (typeof column.render === "function") {
|
|
1342
|
+
return h(ElTableColumn, vnodeProps, {
|
|
1343
|
+
default: (scope) => h(_sfc_main$e, {
|
|
1344
|
+
component: column.render({
|
|
1345
|
+
...scope,
|
|
1346
|
+
column,
|
|
1347
|
+
cellValue: getCellValue(scope.row, column)
|
|
1348
|
+
})
|
|
1349
|
+
})
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
return h(ElTableColumn, vnodeProps);
|
|
1353
|
+
};
|
|
1354
|
+
const _sfc_main$2 = defineComponent({
|
|
1355
|
+
name: "TableColumnRenderer",
|
|
1356
|
+
inheritAttrs: false,
|
|
1211
1357
|
props: {
|
|
1212
|
-
columns: {
|
|
1358
|
+
columns: {
|
|
1359
|
+
type: Array,
|
|
1360
|
+
default: () => []
|
|
1361
|
+
}
|
|
1213
1362
|
},
|
|
1214
|
-
setup(
|
|
1215
|
-
|
|
1216
|
-
const getColumnKey = (column, index2) => {
|
|
1217
|
-
const rawKey = column.key ?? column.prop;
|
|
1218
|
-
if (rawKey === void 0 || rawKey === null) return `__col_${index2}`;
|
|
1219
|
-
return normalizePathKey(rawKey);
|
|
1220
|
-
};
|
|
1221
|
-
const getCellValue = (row, column) => {
|
|
1222
|
-
const path = column.prop;
|
|
1223
|
-
if (!path) return void 0;
|
|
1224
|
-
return get(row, path);
|
|
1225
|
-
};
|
|
1226
|
-
const normalizedColumns = computed(() => {
|
|
1227
|
-
return props.columns.filter((column) => !column.hidden);
|
|
1228
|
-
});
|
|
1229
|
-
const getColumnProps = (column) => {
|
|
1230
|
-
const { hidden, render, key, children, ...rest } = column;
|
|
1231
|
-
const prop = column.prop ? normalizePathKey(column.prop) : void 0;
|
|
1232
|
-
const columnKey = key ? normalizePathKey(key) : prop;
|
|
1233
|
-
return {
|
|
1234
|
-
...rest,
|
|
1235
|
-
label: column.label ?? column.title,
|
|
1236
|
-
prop,
|
|
1237
|
-
columnKey
|
|
1238
|
-
};
|
|
1239
|
-
};
|
|
1240
|
-
return (_ctx, _cache) => {
|
|
1241
|
-
const _component_TableColumnRenderer = resolveComponent("TableColumnRenderer", true);
|
|
1242
|
-
return openBlock(true), createElementBlock(Fragment, null, renderList(normalizedColumns.value, (column, index2) => {
|
|
1243
|
-
return openBlock(), createElementBlock(Fragment, {
|
|
1244
|
-
key: getColumnKey(column, index2)
|
|
1245
|
-
}, [
|
|
1246
|
-
column.children && column.children.length > 0 ? (openBlock(), createBlock(unref(ElTableColumn), mergeProps({
|
|
1247
|
-
key: 0,
|
|
1248
|
-
ref_for: true
|
|
1249
|
-
}, getColumnProps(column)), {
|
|
1250
|
-
default: withCtx(() => [
|
|
1251
|
-
createVNode(_component_TableColumnRenderer, {
|
|
1252
|
-
columns: column.children
|
|
1253
|
-
}, null, 8, ["columns"])
|
|
1254
|
-
]),
|
|
1255
|
-
_: 2
|
|
1256
|
-
}, 1040)) : typeof column.render === "function" ? (openBlock(), createBlock(unref(ElTableColumn), mergeProps({
|
|
1257
|
-
key: 1,
|
|
1258
|
-
ref_for: true
|
|
1259
|
-
}, getColumnProps(column)), {
|
|
1260
|
-
default: withCtx((scope) => {
|
|
1261
|
-
var _a;
|
|
1262
|
-
return [
|
|
1263
|
-
createVNode(unref(_sfc_main$c), {
|
|
1264
|
-
component: (_a = column.render) == null ? void 0 : _a.call(column, {
|
|
1265
|
-
...scope,
|
|
1266
|
-
column,
|
|
1267
|
-
cellValue: getCellValue(scope.row, column)
|
|
1268
|
-
})
|
|
1269
|
-
}, null, 8, ["component"])
|
|
1270
|
-
];
|
|
1271
|
-
}),
|
|
1272
|
-
_: 2
|
|
1273
|
-
}, 1040)) : (openBlock(), createBlock(unref(ElTableColumn), mergeProps({
|
|
1274
|
-
key: 2,
|
|
1275
|
-
ref_for: true
|
|
1276
|
-
}, getColumnProps(column)), null, 16))
|
|
1277
|
-
], 64);
|
|
1278
|
-
}), 128);
|
|
1279
|
-
};
|
|
1363
|
+
setup(props) {
|
|
1364
|
+
return () => props.columns.filter((column) => isObjectItem(column) && !toValue(column.hidden)).map((column) => renderColumn(column));
|
|
1280
1365
|
}
|
|
1281
1366
|
});
|
|
1282
1367
|
const _hoisted_1 = { class: "pro-table_header" };
|
|
@@ -1331,59 +1416,63 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1331
1416
|
const config = INJECT_CONFIG["pro-table"];
|
|
1332
1417
|
const injectPropsRaw = inject(config.injectionKey, config.default);
|
|
1333
1418
|
const injectProps = computed(() => toValue(injectPropsRaw) || {});
|
|
1334
|
-
const attrs =
|
|
1335
|
-
const
|
|
1419
|
+
const attrs = useReactiveAttrs();
|
|
1420
|
+
const PRO_TABLE_CONSUMED_ATTR_KEYS = /* @__PURE__ */ new Set([
|
|
1336
1421
|
"class",
|
|
1337
1422
|
"style",
|
|
1338
1423
|
"onSearch",
|
|
1339
|
-
"onChange"
|
|
1340
|
-
"onUpdate:size",
|
|
1341
|
-
"onUpdate:loading",
|
|
1342
|
-
"data",
|
|
1343
|
-
"columns",
|
|
1344
|
-
"size",
|
|
1345
|
-
"pagination"
|
|
1346
|
-
]);
|
|
1347
|
-
const PRO_TABLE_PROVIDER_KEYS = /* @__PURE__ */ new Set([
|
|
1348
|
-
"pagination",
|
|
1349
|
-
"searchFormConfig",
|
|
1350
|
-
"control",
|
|
1351
|
-
"immediateSearch",
|
|
1352
|
-
"addIndexColumn",
|
|
1353
|
-
"tableContainer"
|
|
1424
|
+
"onChange"
|
|
1354
1425
|
]);
|
|
1426
|
+
const PRO_TABLE_PROP_KEYS = new Set(Object.keys(props));
|
|
1355
1427
|
const injectTableAttrs = computed(() => {
|
|
1356
1428
|
const tableConfig = {};
|
|
1357
1429
|
for (const [key, value] of Object.entries(injectProps.value)) {
|
|
1358
|
-
if (!
|
|
1430
|
+
if (!PRO_TABLE_PROP_KEYS.has(key)) {
|
|
1359
1431
|
tableConfig[key] = value;
|
|
1360
1432
|
}
|
|
1361
1433
|
}
|
|
1362
1434
|
return tableConfig;
|
|
1363
1435
|
});
|
|
1364
1436
|
const attrsTableProps = computed(() => {
|
|
1365
|
-
return
|
|
1366
|
-
camelizeProperties(attrs),
|
|
1367
|
-
|
|
1437
|
+
return omitBy(
|
|
1438
|
+
pick(camelizeProperties(attrs), tableProperties),
|
|
1439
|
+
(value) => value === void 0
|
|
1368
1440
|
);
|
|
1369
1441
|
});
|
|
1370
1442
|
const restTableAttrs = computed(() => {
|
|
1371
1443
|
const rest = {};
|
|
1372
1444
|
for (const [key, value] of Object.entries(attrs)) {
|
|
1373
|
-
if (!
|
|
1445
|
+
if (!PRO_TABLE_CONSUMED_ATTR_KEYS.has(key)) {
|
|
1374
1446
|
rest[key] = value;
|
|
1375
1447
|
}
|
|
1376
1448
|
}
|
|
1377
|
-
return rest;
|
|
1449
|
+
return omitBy(rest, (value) => value === void 0);
|
|
1378
1450
|
});
|
|
1379
1451
|
const size = useModel(__props, "size");
|
|
1380
1452
|
const loading = useModel(__props, "loading");
|
|
1381
1453
|
let searchSequence = 0;
|
|
1454
|
+
const SEARCH_WARN_MESSAGES = {
|
|
1455
|
+
duplicate: "同时配置了 :search prop 与 @search 监听,@search 监听不会被执行,请仅保留其一。",
|
|
1456
|
+
"not-promise": "search 未返回 Promise,本次查询不参与 loading 竞态管理(在途请求的 loading 状态保持不变)。"
|
|
1457
|
+
};
|
|
1458
|
+
const warnedSearchReasons = /* @__PURE__ */ new Set();
|
|
1459
|
+
const warnSearchConfig = (reason) => {
|
|
1460
|
+
if (warnedSearchReasons.has(reason)) return;
|
|
1461
|
+
warnedSearchReasons.add(reason);
|
|
1462
|
+
console.warn(`[ProTable] ${SEARCH_WARN_MESSAGES[reason]}`);
|
|
1463
|
+
};
|
|
1382
1464
|
const _search = async () => {
|
|
1383
|
-
|
|
1465
|
+
const search = props.search || attrs.onSearch;
|
|
1466
|
+
if (props.search && attrs.onSearch) {
|
|
1467
|
+
warnSearchConfig("duplicate");
|
|
1468
|
+
}
|
|
1469
|
+
if (!search) return;
|
|
1470
|
+
const searchPromise = search();
|
|
1471
|
+
if (!isPromise(searchPromise)) {
|
|
1472
|
+
warnSearchConfig("not-promise");
|
|
1473
|
+
return;
|
|
1474
|
+
}
|
|
1384
1475
|
const seq = ++searchSequence;
|
|
1385
|
-
const searchPromise = (_a = props.search || attrs.onSearch) == null ? void 0 : _a();
|
|
1386
|
-
if (!isPromise(searchPromise)) return;
|
|
1387
1476
|
loading.value = true;
|
|
1388
1477
|
try {
|
|
1389
1478
|
await searchPromise;
|
|
@@ -1407,7 +1496,47 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1407
1496
|
"table"
|
|
1408
1497
|
];
|
|
1409
1498
|
const slots = useSlots();
|
|
1410
|
-
const
|
|
1499
|
+
const hasRenderableContent = (nodes) => {
|
|
1500
|
+
if (nodes === null || nodes === void 0 || nodes === false) return false;
|
|
1501
|
+
if (typeof nodes === "string") return nodes.trim() !== "";
|
|
1502
|
+
if (typeof nodes === "number") return true;
|
|
1503
|
+
if (Array.isArray(nodes)) return nodes.some(hasRenderableContent);
|
|
1504
|
+
const vnode = nodes;
|
|
1505
|
+
if (vnode.type === Comment) return false;
|
|
1506
|
+
if (vnode.type === Text) return String(vnode.children ?? "").trim() !== "";
|
|
1507
|
+
if (vnode.type === Fragment) return hasRenderableContent(vnode.children);
|
|
1508
|
+
return true;
|
|
1509
|
+
};
|
|
1510
|
+
const evaluateSlotContent = () => {
|
|
1511
|
+
let hasContent = false;
|
|
1512
|
+
const runner = effect(() => {
|
|
1513
|
+
var _a;
|
|
1514
|
+
try {
|
|
1515
|
+
hasContent = hasRenderableContent((_a = slots.default) == null ? void 0 : _a.call(slots));
|
|
1516
|
+
} catch {
|
|
1517
|
+
hasContent = true;
|
|
1518
|
+
}
|
|
1519
|
+
});
|
|
1520
|
+
stop(runner);
|
|
1521
|
+
return hasContent;
|
|
1522
|
+
};
|
|
1523
|
+
let defaultSlotChecked = false;
|
|
1524
|
+
const checkDefaultSlot = () => {
|
|
1525
|
+
if (defaultSlotChecked) return;
|
|
1526
|
+
if (!Object.prototype.hasOwnProperty.call(slots, "default")) return;
|
|
1527
|
+
defaultSlotChecked = true;
|
|
1528
|
+
if (evaluateSlotContent()) {
|
|
1529
|
+
console.warn(
|
|
1530
|
+
"[pro-components] ProTable 的 default 插槽保留用于列渲染,已忽略传入的 default 插槽内容;自定义区域请使用 search-form / button-bar / toolbar / table 具名插槽。"
|
|
1531
|
+
);
|
|
1532
|
+
}
|
|
1533
|
+
};
|
|
1534
|
+
const forwardedSlotNames = () => {
|
|
1535
|
+
checkDefaultSlot();
|
|
1536
|
+
return Object.keys(slots).filter(
|
|
1537
|
+
(name) => name !== "default" && !customSlotNames.includes(name)
|
|
1538
|
+
);
|
|
1539
|
+
};
|
|
1411
1540
|
const searchPage1st = () => {
|
|
1412
1541
|
var _a, _b;
|
|
1413
1542
|
(_b = (_a = props.table) == null ? void 0 : _a.setPageParam) == null ? void 0 : _b.call(_a, { current: 1 });
|
|
@@ -1422,22 +1551,31 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1422
1551
|
container: container ? container : void 0
|
|
1423
1552
|
};
|
|
1424
1553
|
});
|
|
1554
|
+
const searchFormProps = computed(() => {
|
|
1555
|
+
const {
|
|
1556
|
+
container: _container,
|
|
1557
|
+
hidden: _hidden,
|
|
1558
|
+
...rest
|
|
1559
|
+
} = computedSearchFormConfig.value;
|
|
1560
|
+
return rest;
|
|
1561
|
+
});
|
|
1425
1562
|
const computedTableContainer = computed(() => {
|
|
1426
1563
|
const container = props.tableContainer ?? injectProps.value.tableContainer ?? DefaultTableContainer;
|
|
1427
1564
|
return container ? container : void 0;
|
|
1428
1565
|
});
|
|
1429
1566
|
const getIndex = (i) => {
|
|
1430
1567
|
var _a;
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
return i + 1;
|
|
1568
|
+
const pagination = computedPagination.value;
|
|
1569
|
+
if (pagination === false) return i + 1;
|
|
1570
|
+
const pageParam = (_a = props.table) == null ? void 0 : _a.pageParam;
|
|
1571
|
+
const current = pagination.currentPage ?? (pageParam == null ? void 0 : pageParam.current) ?? 1;
|
|
1572
|
+
const pageSize = pagination.pageSize ?? (pageParam == null ? void 0 : pageParam.pageSize) ?? 10;
|
|
1573
|
+
return (current - 1) * pageSize + i + 1;
|
|
1437
1574
|
};
|
|
1575
|
+
const hasExplicitColumns = computed(() => props.columns !== void 0);
|
|
1438
1576
|
const normalizedRawColumns = computed(() => {
|
|
1439
1577
|
var _a;
|
|
1440
|
-
const source = props.columns ?? toValue((_a = props.table) == null ? void 0 : _a.columns) ?? [];
|
|
1578
|
+
const source = (props.columns ?? toValue((_a = props.table) == null ? void 0 : _a.columns) ?? []).filter(isObjectItem);
|
|
1441
1579
|
if (props.addIndexColumn ?? injectProps.value.addIndexColumn) {
|
|
1442
1580
|
return [
|
|
1443
1581
|
{
|
|
@@ -1453,31 +1591,21 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1453
1591
|
return source;
|
|
1454
1592
|
});
|
|
1455
1593
|
const computedDataSource = computed(() => {
|
|
1456
|
-
var _a
|
|
1457
|
-
|
|
1458
|
-
return props.data ?? attrsData ?? toValue((_a = props.table) == null ? void 0 : _a.dataSource) ?? toValue((_b = props.table) == null ? void 0 : _b.data) ?? [];
|
|
1594
|
+
var _a;
|
|
1595
|
+
return props.data ?? toValue((_a = props.table) == null ? void 0 : _a.data) ?? [];
|
|
1459
1596
|
});
|
|
1460
1597
|
const computedTableProps = computed(() => {
|
|
1461
|
-
|
|
1598
|
+
return {
|
|
1462
1599
|
...injectTableAttrs.value,
|
|
1463
1600
|
...restTableAttrs.value,
|
|
1464
1601
|
...attrsTableProps.value
|
|
1465
1602
|
};
|
|
1466
|
-
delete merged.data;
|
|
1467
|
-
delete merged.columns;
|
|
1468
|
-
delete merged.size;
|
|
1469
|
-
delete merged.pagination;
|
|
1470
|
-
return merged;
|
|
1471
1603
|
});
|
|
1472
1604
|
const computedPagination = computed(() => {
|
|
1473
1605
|
var _a, _b;
|
|
1474
|
-
|
|
1475
|
-
if (props.pagination
|
|
1476
|
-
|
|
1477
|
-
}
|
|
1478
|
-
const hasUserPagination = isPlainObject(props.pagination) || isPlainObject(attrsPagination);
|
|
1479
|
-
if (hasUserPagination) {
|
|
1480
|
-
const pageConfig = props.pagination ?? attrsPagination ?? {};
|
|
1606
|
+
if (props.pagination === false) return false;
|
|
1607
|
+
if (isPlainObject(props.pagination)) {
|
|
1608
|
+
const pageConfig = props.pagination;
|
|
1481
1609
|
const globalPagination = injectProps.value.pagination === false ? {} : injectProps.value.pagination || {};
|
|
1482
1610
|
const pageParam2 = (_a = props.table) == null ? void 0 : _a.pageParam;
|
|
1483
1611
|
return {
|
|
@@ -1513,12 +1641,12 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1513
1641
|
(_a = attrs.onChange) == null ? void 0 : _a.call(attrs, currentPage, pageSize);
|
|
1514
1642
|
};
|
|
1515
1643
|
const searchFormVisible = computed(() => {
|
|
1516
|
-
var _a, _b, _c, _d
|
|
1644
|
+
var _a, _b, _c, _d;
|
|
1517
1645
|
const searchFields = (_b = (_a = props.table) == null ? void 0 : _a.searchForm) == null ? void 0 : _b.fields;
|
|
1518
1646
|
const fieldList = (Array.isArray(searchFields) ? searchFields : searchFields == null ? void 0 : searchFields.value) ?? [];
|
|
1519
|
-
return !!(((_c = computedSearchFormConfig.value) == null ? void 0 : _c.hidden) !== true && ((_d = props.table) == null ? void 0 : _d.searchForm) &&
|
|
1647
|
+
return !!(((_c = computedSearchFormConfig.value) == null ? void 0 : _c.hidden) !== true && ((_d = props.table) == null ? void 0 : _d.searchForm) && fieldList.filter((item) => isObjectItem(item) && !toValue(item.hidden)).length > 0);
|
|
1520
1648
|
});
|
|
1521
|
-
const
|
|
1649
|
+
const resolvedControl = computed(() => {
|
|
1522
1650
|
const mergedControl = props.control ?? injectProps.value.control;
|
|
1523
1651
|
if (typeof mergedControl === "boolean") {
|
|
1524
1652
|
return { sizeControl: mergedControl, columnControl: mergedControl };
|
|
@@ -1528,12 +1656,15 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1528
1656
|
const columnControl = (c == null ? void 0 : c.columnControl) ?? false;
|
|
1529
1657
|
return { sizeControl: !!sizeControl, columnControl };
|
|
1530
1658
|
});
|
|
1659
|
+
const computedControl = computed(
|
|
1660
|
+
() => hasExplicitColumns.value && resolvedControl.value.columnControl ? { ...resolvedControl.value, columnControl: false } : resolvedControl.value
|
|
1661
|
+
);
|
|
1531
1662
|
const columnControlConfig = computed(() => {
|
|
1532
1663
|
const cc = computedControl.value.columnControl;
|
|
1533
1664
|
return typeof cc === "object" ? cc : void 0;
|
|
1534
1665
|
});
|
|
1535
1666
|
const resolvedSize = computed(() => {
|
|
1536
|
-
return size.value ??
|
|
1667
|
+
return size.value ?? injectProps.value.size;
|
|
1537
1668
|
});
|
|
1538
1669
|
onMounted(() => {
|
|
1539
1670
|
if (props.immediateSearch ?? injectProps.value.immediateSearch) {
|
|
@@ -1550,7 +1681,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1550
1681
|
class: normalizeClass(["pro-table", unref(attrs).class]),
|
|
1551
1682
|
style: normalizeStyle(unref(attrs).style)
|
|
1552
1683
|
}, [
|
|
1553
|
-
searchFormVisible.value || _ctx.$slots["search-form"] ? (openBlock(), createBlock(
|
|
1684
|
+
searchFormVisible.value || _ctx.$slots["search-form"] ? (openBlock(), createBlock(_sfc_main$f, {
|
|
1554
1685
|
key: 0,
|
|
1555
1686
|
component: computedSearchFormConfig.value.container
|
|
1556
1687
|
}, {
|
|
@@ -1561,7 +1692,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1561
1692
|
((_a = props.table) == null ? void 0 : _a.searchForm) ? (openBlock(), createBlock(SearchForm, mergeProps({
|
|
1562
1693
|
key: 0,
|
|
1563
1694
|
form: props.table.searchForm
|
|
1564
|
-
},
|
|
1695
|
+
}, searchFormProps.value, {
|
|
1565
1696
|
onSearch: searchPage1st,
|
|
1566
1697
|
onReset: reset
|
|
1567
1698
|
}), null, 16, ["form"])) : createCommentVNode("", true)
|
|
@@ -1570,7 +1701,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1570
1701
|
]),
|
|
1571
1702
|
_: 3
|
|
1572
1703
|
}, 8, ["component"])) : createCommentVNode("", true),
|
|
1573
|
-
createVNode(
|
|
1704
|
+
createVNode(_sfc_main$f, { component: computedTableContainer.value }, {
|
|
1574
1705
|
default: withCtx(() => [
|
|
1575
1706
|
createElementVNode("div", _hoisted_1, [
|
|
1576
1707
|
_ctx.$slots["button-bar"] ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
@@ -1580,13 +1711,14 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1580
1711
|
renderSlot(_ctx.$slots, "toolbar", {}, void 0, true)
|
|
1581
1712
|
])) : createCommentVNode("", true),
|
|
1582
1713
|
computedControl.value.sizeControl ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
1583
|
-
createVNode(
|
|
1714
|
+
createVNode(SizeControl, {
|
|
1584
1715
|
size: size.value,
|
|
1585
|
-
"onUpdate:size": _cache[0] || (_cache[0] = ($event) => size.value = $event)
|
|
1586
|
-
|
|
1716
|
+
"onUpdate:size": _cache[0] || (_cache[0] = ($event) => size.value = $event),
|
|
1717
|
+
"effective-size": resolvedSize.value
|
|
1718
|
+
}, null, 8, ["size", "effective-size"])
|
|
1587
1719
|
])) : createCommentVNode("", true),
|
|
1588
1720
|
computedControl.value.columnControl ? (openBlock(), createElementBlock("div", _hoisted_5, [
|
|
1589
|
-
createVNode(
|
|
1721
|
+
createVNode(ColumnControl, {
|
|
1590
1722
|
columns: normalizedRawColumns.value.filter((item) => item.key !== "__INDEX__"),
|
|
1591
1723
|
table: props.table,
|
|
1592
1724
|
"column-control": columnControlConfig.value
|
|
@@ -1630,13 +1762,14 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1630
1762
|
};
|
|
1631
1763
|
}
|
|
1632
1764
|
});
|
|
1633
|
-
const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
1765
|
+
const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-d092780c"]]);
|
|
1634
1766
|
function useTable(params = {}) {
|
|
1635
1767
|
const { data, columns, ...rest } = params;
|
|
1636
1768
|
const coreTable = useTable$1({
|
|
1637
1769
|
...rest,
|
|
1638
1770
|
dataSource: data,
|
|
1639
|
-
columns
|
|
1771
|
+
columns,
|
|
1772
|
+
fieldIdentityKeys: ELEMENT_FIELD_IDENTITY_KEYS
|
|
1640
1773
|
});
|
|
1641
1774
|
const { dataSource, ...tableWithoutDataSource } = coreTable;
|
|
1642
1775
|
const table = {
|
|
@@ -1661,15 +1794,21 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1661
1794
|
Object.keys(INJECT_CONFIG).forEach(
|
|
1662
1795
|
(key) => {
|
|
1663
1796
|
const config = INJECT_CONFIG[key];
|
|
1797
|
+
const ignored = config.ignoreProps;
|
|
1664
1798
|
provide(
|
|
1665
1799
|
config.injectionKey,
|
|
1666
|
-
computed(
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1800
|
+
computed(
|
|
1801
|
+
() => {
|
|
1802
|
+
var _a;
|
|
1803
|
+
return omit(
|
|
1804
|
+
{
|
|
1805
|
+
...config.default,
|
|
1806
|
+
...getObject((_a = props.componentVars) == null ? void 0 : _a[key])
|
|
1807
|
+
},
|
|
1808
|
+
ignored ?? []
|
|
1809
|
+
);
|
|
1810
|
+
}
|
|
1811
|
+
)
|
|
1673
1812
|
);
|
|
1674
1813
|
}
|
|
1675
1814
|
);
|
|
@@ -1690,6 +1829,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1690
1829
|
}
|
|
1691
1830
|
});
|
|
1692
1831
|
}
|
|
1832
|
+
provide(
|
|
1833
|
+
INJECT_COMPONENT_VARS,
|
|
1834
|
+
computed(() => props.componentVars ?? {})
|
|
1835
|
+
);
|
|
1693
1836
|
provide(
|
|
1694
1837
|
INJECT_COMPONENTS,
|
|
1695
1838
|
computed(() => props.componentMap)
|
|
@@ -1705,11 +1848,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1705
1848
|
});
|
|
1706
1849
|
const index = {
|
|
1707
1850
|
/**
|
|
1708
|
-
*
|
|
1709
|
-
* @description 全局注册所有组件(ProForm、ProTable、ProComponentProvider)
|
|
1851
|
+
* 安装方法:全局注册 ProForm / ProTable / ProComponentProvider
|
|
1710
1852
|
*
|
|
1853
|
+
* @description 供 `app.use(ProComponents)` 调用
|
|
1711
1854
|
* @param {App} app - Vue 应用实例
|
|
1712
|
-
*
|
|
1713
1855
|
* @example
|
|
1714
1856
|
* ```ts
|
|
1715
1857
|
* import { createApp } from 'vue'
|
|
@@ -1721,16 +1863,19 @@ const index = {
|
|
|
1721
1863
|
install(app) {
|
|
1722
1864
|
app.component(_sfc_main$b.name, _sfc_main$b);
|
|
1723
1865
|
app.component(ProTable.name, ProTable);
|
|
1724
|
-
app.component(
|
|
1866
|
+
app.component(
|
|
1867
|
+
_sfc_main.name ?? "ProComponentProvider",
|
|
1868
|
+
_sfc_main
|
|
1869
|
+
);
|
|
1725
1870
|
}
|
|
1726
1871
|
};
|
|
1727
1872
|
export {
|
|
1728
|
-
_sfc_main$
|
|
1873
|
+
_sfc_main$f as ContainerFragment,
|
|
1729
1874
|
LOCALE_INJECT_KEY,
|
|
1730
1875
|
_sfc_main as ProComponentProvider,
|
|
1731
1876
|
_sfc_main$b as ProForm,
|
|
1732
1877
|
ProTable,
|
|
1733
|
-
_sfc_main$
|
|
1878
|
+
_sfc_main$e as SlotComponent,
|
|
1734
1879
|
index as default,
|
|
1735
1880
|
enUS,
|
|
1736
1881
|
useFields,
|