@qin-ui/element-plus-pro 1.3.5 → 1.4.1
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 +27 -3
- package/README.md +42 -31
- 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 +15 -1
- 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 +13 -1
- 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 +307 -227
- 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 +5 -4
- 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 +25 -12
- package/src/components/form/components/BaseField/utils/index.ts +16 -1
- package/src/components/form/components/BaseFormItem/index.vue +25 -32
- package/src/components/form/components/ContainerFragment/index.vue +3 -1
- package/src/components/form/components/ProForm/index.vue +41 -21
- 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 +24 -17
- 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 +16 -6
- package/src/components/table/components/ProTable.vue +183 -93
- package/src/components/table/components/SearchForm.vue +60 -22
- package/src/components/table/components/SizeControl.vue +23 -1
- package/src/components/table/components/TableColumnRenderer.vue +82 -63
- 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 +0 -1
- 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, defineComponent, createBlock, renderSlot, openBlock, resolveDynamicComponent, normalizeProps, mergeProps, withCtx, createElementBlock, Fragment, createTextVNode, toDisplayString, ref,
|
|
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, 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, cloneDeep, InjectionFormSlotsKey, isPlainObject,
|
|
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` 显式传入;grid 仅作为启用时的参数默认值,不开启网格
|
|
58
|
+
ignoreProps: ["form"],
|
|
44
59
|
default: { grid: { gutter: 24 } }
|
|
45
60
|
},
|
|
46
61
|
"pro-form-item": {
|
|
@@ -250,8 +265,14 @@ const componentMap = {
|
|
|
250
265
|
"tree-select": ElTreeSelect,
|
|
251
266
|
"transfer": ElTransfer
|
|
252
267
|
};
|
|
268
|
+
const ELEMENT_FIELD_IDENTITY_KEYS = ["prop", "path"];
|
|
253
269
|
function useForm(...args) {
|
|
254
|
-
|
|
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
|
+
});
|
|
255
276
|
}
|
|
256
277
|
const PLACEHOLDER_KEYS = {
|
|
257
278
|
input: "input.placeholder",
|
|
@@ -355,7 +376,7 @@ const useLocale = () => {
|
|
|
355
376
|
const { lang: elLang } = useLocale$1();
|
|
356
377
|
const override = inject(LOCALE_INJECT_KEY, void 0);
|
|
357
378
|
const lang = computed(() => {
|
|
358
|
-
if (
|
|
379
|
+
if (toValue(elLocaleContext) == null) return "zh-CN";
|
|
359
380
|
return resolveLocaleName(elLang.value);
|
|
360
381
|
});
|
|
361
382
|
const pack = computed(
|
|
@@ -384,11 +405,12 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
384
405
|
const { t } = useLocale();
|
|
385
406
|
const form = useForm(false);
|
|
386
407
|
const componentRef = ref();
|
|
387
|
-
const attrs =
|
|
408
|
+
const attrs = useReactiveAttrs();
|
|
388
409
|
const typeVal = attrs.type;
|
|
389
410
|
const injectConfigKey = typeof props.component === "string" ? [props.component, typeVal].filter(Boolean).join(".") : "";
|
|
390
411
|
const componentInjectConfig = injectConfigKey ? getInjectConfig(injectConfigKey) : void 0;
|
|
391
412
|
const rawInjectComponentProps = componentInjectConfig ? inject(componentInjectConfig.injectionKey, componentInjectConfig.default) : void 0;
|
|
413
|
+
const componentVars = inject(INJECT_COMPONENT_VARS, void 0);
|
|
392
414
|
const value = computed({
|
|
393
415
|
get() {
|
|
394
416
|
var _a;
|
|
@@ -419,7 +441,11 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
419
441
|
});
|
|
420
442
|
const parentDisabled = useDisabledContext();
|
|
421
443
|
const groupedAttrs = computed(() => {
|
|
422
|
-
|
|
444
|
+
var _a;
|
|
445
|
+
const currentInjectProps = {
|
|
446
|
+
...toValue(rawInjectComponentProps) || {},
|
|
447
|
+
...getObject((_a = toValue(componentVars)) == null ? void 0 : _a[injectConfigKey])
|
|
448
|
+
};
|
|
423
449
|
const initProps = getInitProps(
|
|
424
450
|
{
|
|
425
451
|
component: props.component,
|
|
@@ -429,7 +455,8 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
429
455
|
t
|
|
430
456
|
);
|
|
431
457
|
const modelPropName = attrs.modelProp ?? initProps.modelProp ?? "modelValue";
|
|
432
|
-
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);
|
|
433
460
|
const mergedProps = mergeProps(
|
|
434
461
|
initProps,
|
|
435
462
|
attrs,
|
|
@@ -495,9 +522,20 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
495
522
|
};
|
|
496
523
|
}
|
|
497
524
|
});
|
|
498
|
-
const
|
|
499
|
-
|
|
500
|
-
)
|
|
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());
|
|
501
539
|
const gridItemPropKeys = Object.keys(gridItemProps());
|
|
502
540
|
const gridItemPropKeySet = new Set(gridItemPropKeys);
|
|
503
541
|
const formItemPropKeySet = new Set(formItemPropKeys);
|
|
@@ -513,7 +551,7 @@ function useGroupFieldAttrs(validFields) {
|
|
|
513
551
|
const componentProps = { slots: {} };
|
|
514
552
|
const formItemSlots = {};
|
|
515
553
|
if (isPlainObject(field)) {
|
|
516
|
-
const { path,
|
|
554
|
+
const { path: _path, prop: _prop, fields, formItemClass, formItemStyle, formItemContainer, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, ...rest } = field;
|
|
517
555
|
const { class: injectClassName, style: injectStyle, span: injectSpan, formItemContainer: injectFormItemContainer, xs, sm, md, lg, xl, ...injectRest } = rawInjectProps;
|
|
518
556
|
const initGridItemProps = span || span === 0 ? { span } : { xs, sm, md, lg, xl, span: injectSpan };
|
|
519
557
|
gridItemProps2 = fields ? { ...initGridItemProps, span: span ?? 24 } : initGridItemProps;
|
|
@@ -541,25 +579,25 @@ function useGroupFieldAttrs(validFields) {
|
|
|
541
579
|
componentProps.slots[k] = slots[k];
|
|
542
580
|
}
|
|
543
581
|
});
|
|
544
|
-
const raw2 = toValue(name) ?? toValue(path);
|
|
545
582
|
return {
|
|
546
|
-
path:
|
|
583
|
+
path: resolveFieldIdentity(field, ELEMENT_FIELD_IDENTITY_KEYS),
|
|
547
584
|
gridItemProps: gridItemProps2,
|
|
548
585
|
formItemProps: formItemProps2,
|
|
549
586
|
formItemSlots,
|
|
550
587
|
componentProps,
|
|
551
588
|
container,
|
|
552
|
-
rawField: field
|
|
589
|
+
rawField: field,
|
|
590
|
+
renderKey: getFieldKey(field)
|
|
553
591
|
};
|
|
554
592
|
}
|
|
555
|
-
const raw = toValue(field == null ? void 0 : field.name) ?? toValue(field == null ? void 0 : field.path);
|
|
556
593
|
return {
|
|
557
|
-
path:
|
|
594
|
+
path: resolveFieldIdentity(field, ELEMENT_FIELD_IDENTITY_KEYS),
|
|
558
595
|
gridItemProps: gridItemProps2,
|
|
559
596
|
formItemProps: formItemProps2,
|
|
560
597
|
formItemSlots,
|
|
561
598
|
componentProps,
|
|
562
|
-
rawField: field
|
|
599
|
+
rawField: field,
|
|
600
|
+
renderKey: getFieldKey(field)
|
|
563
601
|
};
|
|
564
602
|
});
|
|
565
603
|
});
|
|
@@ -569,25 +607,18 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
569
607
|
__name: "index",
|
|
570
608
|
props: {
|
|
571
609
|
grid: { type: [Boolean, Object], default: void 0 },
|
|
572
|
-
fields: { default: () => [] }
|
|
610
|
+
fields: { default: () => [] },
|
|
611
|
+
disabled: { type: Boolean, default: void 0 }
|
|
573
612
|
},
|
|
574
613
|
setup(__props) {
|
|
575
|
-
let fieldKeySeed = 0;
|
|
576
|
-
const fieldKeyMap = /* @__PURE__ */ new WeakMap();
|
|
577
|
-
const getFieldKey = (field) => {
|
|
578
|
-
const raw = toRaw(field);
|
|
579
|
-
let key = fieldKeyMap.get(raw);
|
|
580
|
-
if (key === void 0) {
|
|
581
|
-
key = ++fieldKeySeed;
|
|
582
|
-
fieldKeyMap.set(raw, key);
|
|
583
|
-
}
|
|
584
|
-
return key;
|
|
585
|
-
};
|
|
586
614
|
const props = __props;
|
|
615
|
+
useProviderDisabled(computed(() => props.disabled));
|
|
587
616
|
const validFields = computed(
|
|
588
617
|
() => (
|
|
589
|
-
// hidden 支持 Ref/ComputedRef
|
|
590
|
-
(props.fields ?? []).filter(
|
|
618
|
+
// hidden 支持 Ref / ComputedRef 响应式形态(统一使用 toValue 取值)
|
|
619
|
+
(props.fields ?? []).filter(
|
|
620
|
+
(field) => isObjectItem(field) && !toValue(field.hidden)
|
|
621
|
+
)
|
|
591
622
|
)
|
|
592
623
|
);
|
|
593
624
|
const config = INJECT_CONFIG["pro-form"];
|
|
@@ -596,10 +627,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
596
627
|
var _a;
|
|
597
628
|
return (_a = toValue(injectFormConfig)) == null ? void 0 : _a.grid;
|
|
598
629
|
});
|
|
599
|
-
const enableGrid = computed(() =>
|
|
600
|
-
if (props.grid !== void 0) return !!props.grid;
|
|
601
|
-
return !!injectGrid.value;
|
|
602
|
-
});
|
|
630
|
+
const enableGrid = computed(() => !!props.grid);
|
|
603
631
|
const computedGridProps = computed(() => {
|
|
604
632
|
return enableGrid.value ? { ...getObject(injectGrid.value), ...getObject(props.grid) } : {};
|
|
605
633
|
});
|
|
@@ -670,7 +698,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
670
698
|
default: withCtx(() => [
|
|
671
699
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(groupedFields), (item) => {
|
|
672
700
|
return openBlock(), createBlock(_sfc_main$f, mergeProps({
|
|
673
|
-
key: item.
|
|
701
|
+
key: item.renderKey,
|
|
674
702
|
component: enableGrid.value ? unref(ElCol) : void 0
|
|
675
703
|
}, { ref_for: true }, item.gridItemProps), {
|
|
676
704
|
default: withCtx(() => [
|
|
@@ -689,8 +717,9 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
689
717
|
item.rawField.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
|
|
690
718
|
key: 0,
|
|
691
719
|
grid: item.rawField.grid ?? props.grid,
|
|
692
|
-
fields: item.rawField.fields
|
|
693
|
-
|
|
720
|
+
fields: item.rawField.fields,
|
|
721
|
+
disabled: toValue(item.rawField.disabled)
|
|
722
|
+
}, null, 8, ["grid", "fields", "disabled"])) : (openBlock(), createBlock(_sfc_main$d, mergeProps({
|
|
694
723
|
key: 1,
|
|
695
724
|
ref_for: true,
|
|
696
725
|
ref: (el) => setComponentRef(item.rawField, el)
|
|
@@ -732,7 +761,7 @@ const _export_sfc = (sfc, props) => {
|
|
|
732
761
|
}
|
|
733
762
|
return target;
|
|
734
763
|
};
|
|
735
|
-
const BaseFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-
|
|
764
|
+
const BaseFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-dea0b53c"]]);
|
|
736
765
|
const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
737
766
|
...{ name: "ProForm", inheritAttrs: false },
|
|
738
767
|
__name: "index",
|
|
@@ -742,10 +771,8 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
742
771
|
},
|
|
743
772
|
setup(__props) {
|
|
744
773
|
const props = __props;
|
|
745
|
-
|
|
746
|
-
const currentForm = computed(
|
|
747
|
-
() => props.form ?? (fallbackForm ?? (fallbackForm = useForm()))
|
|
748
|
-
);
|
|
774
|
+
const fallbackForm = useForm();
|
|
775
|
+
const currentForm = computed(() => props.form ?? fallbackForm);
|
|
749
776
|
const formProxy = createFormProxy(() => currentForm.value);
|
|
750
777
|
provide(InjectionFormKey, formProxy);
|
|
751
778
|
const fields = computed(() => {
|
|
@@ -773,14 +800,17 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
773
800
|
const formKey = computed(() => getFormKey(currentForm.value));
|
|
774
801
|
const config = INJECT_CONFIG["pro-form"];
|
|
775
802
|
const injectFormConfig = inject(config.injectionKey, config.default);
|
|
776
|
-
const attrs =
|
|
803
|
+
const attrs = useReactiveAttrs();
|
|
777
804
|
const injectAttrs = computed(() => {
|
|
778
805
|
const raw = toValue(injectFormConfig);
|
|
779
806
|
const { grid: _injectGrid, ...rest } = raw || {};
|
|
780
807
|
return rest;
|
|
781
808
|
});
|
|
782
809
|
const formAttrs = computed(() => {
|
|
783
|
-
return mergeProps(
|
|
810
|
+
return mergeProps(
|
|
811
|
+
injectAttrs.value,
|
|
812
|
+
omitBy(camelizeProperties(attrs), (value) => value === void 0)
|
|
813
|
+
);
|
|
784
814
|
});
|
|
785
815
|
const slots = useSlots();
|
|
786
816
|
const formSlotsRef = shallowRef(slots);
|
|
@@ -811,7 +841,9 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
811
841
|
}
|
|
812
842
|
});
|
|
813
843
|
function useFields(initFields) {
|
|
814
|
-
return useFields$1(initFields
|
|
844
|
+
return useFields$1(initFields, {
|
|
845
|
+
fieldIdentityKeys: ELEMENT_FIELD_IDENTITY_KEYS
|
|
846
|
+
});
|
|
815
847
|
}
|
|
816
848
|
function useFormRef() {
|
|
817
849
|
return useFormRef$1();
|
|
@@ -836,7 +868,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
836
868
|
...{ name: "SearchForm" },
|
|
837
869
|
__name: "SearchForm",
|
|
838
870
|
props: {
|
|
839
|
-
form: {
|
|
871
|
+
form: {},
|
|
840
872
|
layout: { default: "grid" },
|
|
841
873
|
expand: { type: [Boolean, Object], default: true },
|
|
842
874
|
searchButton: { type: [Object, Function, Boolean], default: void 0 },
|
|
@@ -878,14 +910,27 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
878
910
|
const onReset = () => {
|
|
879
911
|
emit("reset");
|
|
880
912
|
};
|
|
881
|
-
|
|
913
|
+
let searchTriggeredInTick = false;
|
|
914
|
+
const emitSearch = () => {
|
|
915
|
+
searchTriggeredInTick = true;
|
|
916
|
+
nextTick(() => {
|
|
917
|
+
searchTriggeredInTick = false;
|
|
918
|
+
});
|
|
882
919
|
emit("search");
|
|
883
920
|
};
|
|
921
|
+
const onSearchSubmit = () => {
|
|
922
|
+
if (searchTriggeredInTick) return;
|
|
923
|
+
emitSearch();
|
|
924
|
+
};
|
|
925
|
+
const onSearchClick = () => {
|
|
926
|
+
if (searchTriggeredInTick) return;
|
|
927
|
+
emitSearch();
|
|
928
|
+
};
|
|
884
929
|
return (_ctx, _cache) => {
|
|
885
930
|
return openBlock(), createBlock(_sfc_main$b, mergeProps(layoutProps.value, {
|
|
886
931
|
form: props.form,
|
|
887
932
|
class: "pro-table_search-form transition",
|
|
888
|
-
onSubmit: withModifiers(
|
|
933
|
+
onSubmit: withModifiers(onSearchSubmit, ["prevent"])
|
|
889
934
|
}), {
|
|
890
935
|
default: withCtx(() => [
|
|
891
936
|
createVNode(unref(ElSpace), {
|
|
@@ -910,11 +955,11 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
910
955
|
}))
|
|
911
956
|
], 64)) : createCommentVNode("", true)
|
|
912
957
|
], true),
|
|
913
|
-
renderSlot(_ctx.$slots, "search-button", { onSearch }, () => [
|
|
958
|
+
renderSlot(_ctx.$slots, "search-button", { onSearch: onSearchClick }, () => [
|
|
914
959
|
props.searchButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
915
960
|
props.searchButton ? (openBlock(), createBlock(resolveDynamicComponent(props.searchButton), {
|
|
916
961
|
key: 0,
|
|
917
|
-
onClick:
|
|
962
|
+
onClick: onSearchClick
|
|
918
963
|
})) : (openBlock(), createBlock(unref(ElButton), {
|
|
919
964
|
key: 1,
|
|
920
965
|
class: "pro-table_search-form_search-button",
|
|
@@ -963,7 +1008,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
963
1008
|
};
|
|
964
1009
|
}
|
|
965
1010
|
});
|
|
966
|
-
const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-
|
|
1011
|
+
const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-419025fd"]]);
|
|
967
1012
|
const _sfc_main$8 = {};
|
|
968
1013
|
const _hoisted_1$4 = { class: "pro-table_search-form-container" };
|
|
969
1014
|
function _sfc_render$3(_ctx, _cache) {
|
|
@@ -998,15 +1043,21 @@ function _sfc_render$1(_ctx, _cache) {
|
|
|
998
1043
|
const ColumnHeightOutlined = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$1]]);
|
|
999
1044
|
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
1000
1045
|
__name: "SizeControl",
|
|
1001
|
-
props: {
|
|
1046
|
+
props: /* @__PURE__ */ mergeModels({
|
|
1047
|
+
effectiveSize: { default: void 0 }
|
|
1048
|
+
}, {
|
|
1002
1049
|
"size": {},
|
|
1003
1050
|
"sizeModifiers": {}
|
|
1004
|
-
},
|
|
1051
|
+
}),
|
|
1005
1052
|
emits: ["update:size"],
|
|
1006
1053
|
setup(__props) {
|
|
1007
1054
|
const { t } = useLocale();
|
|
1055
|
+
const props = __props;
|
|
1008
1056
|
const size = useModel(__props, "size");
|
|
1009
|
-
const
|
|
1057
|
+
const hostSize = useSize();
|
|
1058
|
+
const currentSize = computed(
|
|
1059
|
+
() => (props.effectiveSize ?? size.value ?? hostSize.value) || "default"
|
|
1060
|
+
);
|
|
1010
1061
|
const items = computed(() => [
|
|
1011
1062
|
{ label: t("table.sizeDefault"), key: "default" },
|
|
1012
1063
|
{ label: t("table.sizeMiddle"), key: "large" },
|
|
@@ -1052,7 +1103,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
1052
1103
|
};
|
|
1053
1104
|
}
|
|
1054
1105
|
});
|
|
1055
|
-
const SizeControl = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-
|
|
1106
|
+
const SizeControl = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-61d0ef11"]]);
|
|
1056
1107
|
const _sfc_main$4 = {};
|
|
1057
1108
|
const _hoisted_1$1 = {
|
|
1058
1109
|
focusable: "false",
|
|
@@ -1081,16 +1132,16 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
1081
1132
|
const { t } = useLocale();
|
|
1082
1133
|
const checkAll = ref(false);
|
|
1083
1134
|
const indeterminate = ref(false);
|
|
1084
|
-
const
|
|
1085
|
-
const rawKey = column.key
|
|
1135
|
+
const getColumnKey2 = (column) => {
|
|
1136
|
+
const rawKey = column.key || column.prop;
|
|
1086
1137
|
if (rawKey === void 0 || rawKey === null || rawKey === "")
|
|
1087
1138
|
return void 0;
|
|
1088
1139
|
return normalizePathKey(rawKey);
|
|
1089
1140
|
};
|
|
1090
1141
|
const checkedColumnsOptions = computed(
|
|
1091
|
-
() => props.columns.flatMap((item) => {
|
|
1142
|
+
() => props.columns.filter(isObjectItem).flatMap((item) => {
|
|
1092
1143
|
var _a, _b, _c, _d, _e, _f;
|
|
1093
|
-
const key =
|
|
1144
|
+
const key = getColumnKey2(item);
|
|
1094
1145
|
if (key === void 0) return [];
|
|
1095
1146
|
if (key === "__INDEX__" || item.type === "index" || ((_b = (_a = props.columnControl) == null ? void 0 : _a.excludedKeys) == null ? void 0 : _b.some((ek) => String(ek) === key)))
|
|
1096
1147
|
return [];
|
|
@@ -1102,7 +1153,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
1102
1153
|
return {
|
|
1103
1154
|
label,
|
|
1104
1155
|
value: key,
|
|
1105
|
-
checked: !item.hidden || !!disabled,
|
|
1156
|
+
checked: !toValue(item.hidden) || !!disabled,
|
|
1106
1157
|
disabled: !!disabled,
|
|
1107
1158
|
column: item
|
|
1108
1159
|
};
|
|
@@ -1238,91 +1289,76 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
1238
1289
|
};
|
|
1239
1290
|
}
|
|
1240
1291
|
});
|
|
1241
|
-
const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1292
|
+
const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-4d2b4f1c"]]);
|
|
1293
|
+
let columnKeySeed = 0;
|
|
1294
|
+
const columnKeyMap = /* @__PURE__ */ new WeakMap();
|
|
1295
|
+
const getStableColumnKey = (column) => {
|
|
1296
|
+
if (column === null || typeof column !== "object")
|
|
1297
|
+
return `raw_${String(column)}`;
|
|
1298
|
+
const raw = toRaw(column);
|
|
1299
|
+
let key = columnKeyMap.get(raw);
|
|
1300
|
+
if (key === void 0) {
|
|
1301
|
+
key = ++columnKeySeed;
|
|
1302
|
+
columnKeyMap.set(raw, key);
|
|
1303
|
+
}
|
|
1304
|
+
return key;
|
|
1305
|
+
};
|
|
1306
|
+
const getColumnKey = (column) => {
|
|
1307
|
+
const rawKey = column.key || column.prop;
|
|
1308
|
+
if (!rawKey) return getStableColumnKey(column);
|
|
1309
|
+
return normalizePathKey(rawKey);
|
|
1310
|
+
};
|
|
1311
|
+
const getCellValue = (row, column) => {
|
|
1312
|
+
const path = column.prop;
|
|
1313
|
+
if (!path) return void 0;
|
|
1314
|
+
return get(row, path);
|
|
1315
|
+
};
|
|
1316
|
+
const getColumnProps = (column) => {
|
|
1317
|
+
const { hidden, render, key, children, ...rest } = column;
|
|
1318
|
+
const prop = column.prop ? normalizePathKey(column.prop) : void 0;
|
|
1319
|
+
const columnKey = key ? normalizePathKey(key) : prop;
|
|
1320
|
+
return {
|
|
1321
|
+
...rest,
|
|
1322
|
+
label: column.label ?? column.title,
|
|
1323
|
+
prop,
|
|
1324
|
+
columnKey
|
|
1325
|
+
};
|
|
1326
|
+
};
|
|
1327
|
+
const renderColumn = (column, ancestors = /* @__PURE__ */ new Set()) => {
|
|
1328
|
+
const hasChildren = Array.isArray(column.children) && column.children.length > 0;
|
|
1329
|
+
const vnodeProps = { key: getColumnKey(column), ...getColumnProps(column) };
|
|
1330
|
+
if (hasChildren) {
|
|
1331
|
+
const nextAncestors = new Set(ancestors).add(column);
|
|
1332
|
+
return h(ElTableColumn, vnodeProps, {
|
|
1333
|
+
default: () => column.children.filter(
|
|
1334
|
+
(child) => isObjectItem(child) && !nextAncestors.has(child) && !toValue(child.hidden)
|
|
1335
|
+
).map((child) => renderColumn(child, nextAncestors))
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1338
|
+
if (typeof column.render === "function") {
|
|
1339
|
+
return h(ElTableColumn, vnodeProps, {
|
|
1340
|
+
default: (scope) => h(_sfc_main$e, {
|
|
1341
|
+
component: column.render({
|
|
1342
|
+
...scope,
|
|
1343
|
+
column,
|
|
1344
|
+
cellValue: getCellValue(scope.row, column)
|
|
1345
|
+
})
|
|
1346
|
+
})
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1349
|
+
return h(ElTableColumn, vnodeProps);
|
|
1350
|
+
};
|
|
1351
|
+
const _sfc_main$2 = defineComponent({
|
|
1352
|
+
name: "TableColumnRenderer",
|
|
1353
|
+
inheritAttrs: false,
|
|
1245
1354
|
props: {
|
|
1246
|
-
columns: {
|
|
1355
|
+
columns: {
|
|
1356
|
+
type: Array,
|
|
1357
|
+
default: () => []
|
|
1358
|
+
}
|
|
1247
1359
|
},
|
|
1248
|
-
setup(
|
|
1249
|
-
|
|
1250
|
-
let columnKeySeed = 0;
|
|
1251
|
-
const columnKeyMap = /* @__PURE__ */ new WeakMap();
|
|
1252
|
-
const getStableColumnKey = (column) => {
|
|
1253
|
-
const raw = toRaw(column);
|
|
1254
|
-
let key = columnKeyMap.get(raw);
|
|
1255
|
-
if (key === void 0) {
|
|
1256
|
-
key = ++columnKeySeed;
|
|
1257
|
-
columnKeyMap.set(raw, key);
|
|
1258
|
-
}
|
|
1259
|
-
return key;
|
|
1260
|
-
};
|
|
1261
|
-
const getColumnKey = (column) => {
|
|
1262
|
-
const rawKey = column.key ?? column.prop;
|
|
1263
|
-
if (rawKey === void 0 || rawKey === null)
|
|
1264
|
-
return getStableColumnKey(column);
|
|
1265
|
-
return normalizePathKey(rawKey);
|
|
1266
|
-
};
|
|
1267
|
-
const getCellValue = (row, column) => {
|
|
1268
|
-
const path = column.prop;
|
|
1269
|
-
if (!path) return void 0;
|
|
1270
|
-
return get(row, path);
|
|
1271
|
-
};
|
|
1272
|
-
const normalizedColumns = computed(() => {
|
|
1273
|
-
return props.columns.filter((column) => !column.hidden);
|
|
1274
|
-
});
|
|
1275
|
-
const getColumnProps = (column) => {
|
|
1276
|
-
const { hidden, render, key, children, ...rest } = column;
|
|
1277
|
-
const prop = column.prop ? normalizePathKey(column.prop) : void 0;
|
|
1278
|
-
const columnKey = key ? normalizePathKey(key) : prop;
|
|
1279
|
-
return {
|
|
1280
|
-
...rest,
|
|
1281
|
-
label: column.label ?? column.title,
|
|
1282
|
-
prop,
|
|
1283
|
-
columnKey
|
|
1284
|
-
};
|
|
1285
|
-
};
|
|
1286
|
-
return (_ctx, _cache) => {
|
|
1287
|
-
const _component_TableColumnRenderer = resolveComponent("TableColumnRenderer", true);
|
|
1288
|
-
return openBlock(true), createElementBlock(Fragment, null, renderList(normalizedColumns.value, (column) => {
|
|
1289
|
-
return openBlock(), createElementBlock(Fragment, {
|
|
1290
|
-
key: getColumnKey(column)
|
|
1291
|
-
}, [
|
|
1292
|
-
column.children && column.children.length > 0 ? (openBlock(), createBlock(unref(ElTableColumn), mergeProps({
|
|
1293
|
-
key: 0,
|
|
1294
|
-
ref_for: true
|
|
1295
|
-
}, getColumnProps(column)), {
|
|
1296
|
-
default: withCtx(() => [
|
|
1297
|
-
createVNode(_component_TableColumnRenderer, {
|
|
1298
|
-
columns: column.children
|
|
1299
|
-
}, null, 8, ["columns"])
|
|
1300
|
-
]),
|
|
1301
|
-
_: 2
|
|
1302
|
-
}, 1040)) : typeof column.render === "function" ? (openBlock(), createBlock(unref(ElTableColumn), mergeProps({
|
|
1303
|
-
key: 1,
|
|
1304
|
-
ref_for: true
|
|
1305
|
-
}, getColumnProps(column)), {
|
|
1306
|
-
default: withCtx((scope) => {
|
|
1307
|
-
var _a;
|
|
1308
|
-
return [
|
|
1309
|
-
createVNode(_sfc_main$e, {
|
|
1310
|
-
component: (_a = column.render) == null ? void 0 : _a.call(column, {
|
|
1311
|
-
...scope,
|
|
1312
|
-
column,
|
|
1313
|
-
cellValue: getCellValue(scope.row, column)
|
|
1314
|
-
})
|
|
1315
|
-
}, null, 8, ["component"])
|
|
1316
|
-
];
|
|
1317
|
-
}),
|
|
1318
|
-
_: 2
|
|
1319
|
-
}, 1040)) : (openBlock(), createBlock(unref(ElTableColumn), mergeProps({
|
|
1320
|
-
key: 2,
|
|
1321
|
-
ref_for: true
|
|
1322
|
-
}, getColumnProps(column)), null, 16))
|
|
1323
|
-
], 64);
|
|
1324
|
-
}), 128);
|
|
1325
|
-
};
|
|
1360
|
+
setup(props) {
|
|
1361
|
+
return () => props.columns.filter((column) => isObjectItem(column) && !toValue(column.hidden)).map((column) => renderColumn(column));
|
|
1326
1362
|
}
|
|
1327
1363
|
});
|
|
1328
1364
|
const _hoisted_1 = { class: "pro-table_header" };
|
|
@@ -1377,72 +1413,60 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1377
1413
|
const config = INJECT_CONFIG["pro-table"];
|
|
1378
1414
|
const injectPropsRaw = inject(config.injectionKey, config.default);
|
|
1379
1415
|
const injectProps = computed(() => toValue(injectPropsRaw) || {});
|
|
1380
|
-
const attrs =
|
|
1381
|
-
const
|
|
1416
|
+
const attrs = useReactiveAttrs();
|
|
1417
|
+
const PRO_TABLE_CONSUMED_ATTR_KEYS = /* @__PURE__ */ new Set([
|
|
1382
1418
|
"class",
|
|
1383
1419
|
"style",
|
|
1384
1420
|
"onSearch",
|
|
1385
|
-
"onChange"
|
|
1386
|
-
"onUpdate:size",
|
|
1387
|
-
"onUpdate:loading",
|
|
1388
|
-
"data",
|
|
1389
|
-
"columns",
|
|
1390
|
-
"size",
|
|
1391
|
-
"pagination"
|
|
1392
|
-
]);
|
|
1393
|
-
const PRO_TABLE_PROVIDER_KEYS = /* @__PURE__ */ new Set([
|
|
1394
|
-
"pagination",
|
|
1395
|
-
"searchFormConfig",
|
|
1396
|
-
"control",
|
|
1397
|
-
"immediateSearch",
|
|
1398
|
-
"addIndexColumn",
|
|
1399
|
-
"tableContainer"
|
|
1421
|
+
"onChange"
|
|
1400
1422
|
]);
|
|
1423
|
+
const PRO_TABLE_PROP_KEYS = new Set(Object.keys(props));
|
|
1401
1424
|
const injectTableAttrs = computed(() => {
|
|
1402
1425
|
const tableConfig = {};
|
|
1403
1426
|
for (const [key, value] of Object.entries(injectProps.value)) {
|
|
1404
|
-
if (!
|
|
1427
|
+
if (!PRO_TABLE_PROP_KEYS.has(key)) {
|
|
1405
1428
|
tableConfig[key] = value;
|
|
1406
1429
|
}
|
|
1407
1430
|
}
|
|
1408
1431
|
return tableConfig;
|
|
1409
1432
|
});
|
|
1410
1433
|
const attrsTableProps = computed(() => {
|
|
1411
|
-
return
|
|
1412
|
-
camelizeProperties(attrs),
|
|
1413
|
-
|
|
1434
|
+
return omitBy(
|
|
1435
|
+
pick(camelizeProperties(attrs), tableProperties),
|
|
1436
|
+
(value) => value === void 0
|
|
1414
1437
|
);
|
|
1415
1438
|
});
|
|
1416
1439
|
const restTableAttrs = computed(() => {
|
|
1417
1440
|
const rest = {};
|
|
1418
1441
|
for (const [key, value] of Object.entries(attrs)) {
|
|
1419
|
-
if (!
|
|
1442
|
+
if (!PRO_TABLE_CONSUMED_ATTR_KEYS.has(key)) {
|
|
1420
1443
|
rest[key] = value;
|
|
1421
1444
|
}
|
|
1422
1445
|
}
|
|
1423
|
-
return rest;
|
|
1446
|
+
return omitBy(rest, (value) => value === void 0);
|
|
1424
1447
|
});
|
|
1425
1448
|
const size = useModel(__props, "size");
|
|
1426
1449
|
const loading = useModel(__props, "loading");
|
|
1427
1450
|
let searchSequence = 0;
|
|
1428
|
-
|
|
1451
|
+
const SEARCH_WARN_MESSAGES = {
|
|
1452
|
+
duplicate: "同时配置了 :search prop 与 @search 监听,@search 监听不会被执行,请仅保留其一。",
|
|
1453
|
+
"not-promise": "search 未返回 Promise,本次查询不参与 loading 竞态管理(在途请求的 loading 状态保持不变)。"
|
|
1454
|
+
};
|
|
1455
|
+
const warnedSearchReasons = /* @__PURE__ */ new Set();
|
|
1429
1456
|
const warnSearchConfig = (reason) => {
|
|
1430
|
-
if (
|
|
1431
|
-
|
|
1432
|
-
console.warn(`[ProTable] ${reason}`);
|
|
1457
|
+
if (warnedSearchReasons.has(reason)) return;
|
|
1458
|
+
warnedSearchReasons.add(reason);
|
|
1459
|
+
console.warn(`[ProTable] ${SEARCH_WARN_MESSAGES[reason]}`);
|
|
1433
1460
|
};
|
|
1434
1461
|
const _search = async () => {
|
|
1435
|
-
|
|
1462
|
+
const search = props.search || attrs.onSearch;
|
|
1436
1463
|
if (props.search && attrs.onSearch) {
|
|
1437
|
-
warnSearchConfig(
|
|
1438
|
-
"同时配置了 :search prop 与 @search 监听,@search 监听不会被执行,请仅保留其一。"
|
|
1439
|
-
);
|
|
1464
|
+
warnSearchConfig("duplicate");
|
|
1440
1465
|
}
|
|
1441
|
-
|
|
1466
|
+
if (!search) return;
|
|
1467
|
+
const searchPromise = search();
|
|
1442
1468
|
if (!isPromise(searchPromise)) {
|
|
1443
|
-
warnSearchConfig(
|
|
1444
|
-
"search 未返回 Promise,本次查询不参与 loading 竞态管理(在途请求的 loading 状态保持不变)。"
|
|
1445
|
-
);
|
|
1469
|
+
warnSearchConfig("not-promise");
|
|
1446
1470
|
return;
|
|
1447
1471
|
}
|
|
1448
1472
|
const seq = ++searchSequence;
|
|
@@ -1469,7 +1493,47 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1469
1493
|
"table"
|
|
1470
1494
|
];
|
|
1471
1495
|
const slots = useSlots();
|
|
1472
|
-
const
|
|
1496
|
+
const hasRenderableContent = (nodes) => {
|
|
1497
|
+
if (nodes === null || nodes === void 0 || nodes === false) return false;
|
|
1498
|
+
if (typeof nodes === "string") return nodes.trim() !== "";
|
|
1499
|
+
if (typeof nodes === "number") return true;
|
|
1500
|
+
if (Array.isArray(nodes)) return nodes.some(hasRenderableContent);
|
|
1501
|
+
const vnode = nodes;
|
|
1502
|
+
if (vnode.type === Comment) return false;
|
|
1503
|
+
if (vnode.type === Text) return String(vnode.children ?? "").trim() !== "";
|
|
1504
|
+
if (vnode.type === Fragment) return hasRenderableContent(vnode.children);
|
|
1505
|
+
return true;
|
|
1506
|
+
};
|
|
1507
|
+
const evaluateSlotContent = () => {
|
|
1508
|
+
let hasContent = false;
|
|
1509
|
+
const runner = effect(() => {
|
|
1510
|
+
var _a;
|
|
1511
|
+
try {
|
|
1512
|
+
hasContent = hasRenderableContent((_a = slots.default) == null ? void 0 : _a.call(slots));
|
|
1513
|
+
} catch {
|
|
1514
|
+
hasContent = true;
|
|
1515
|
+
}
|
|
1516
|
+
});
|
|
1517
|
+
stop(runner);
|
|
1518
|
+
return hasContent;
|
|
1519
|
+
};
|
|
1520
|
+
let defaultSlotChecked = false;
|
|
1521
|
+
const checkDefaultSlot = () => {
|
|
1522
|
+
if (defaultSlotChecked) return;
|
|
1523
|
+
if (!Object.prototype.hasOwnProperty.call(slots, "default")) return;
|
|
1524
|
+
defaultSlotChecked = true;
|
|
1525
|
+
if (evaluateSlotContent()) {
|
|
1526
|
+
console.warn(
|
|
1527
|
+
"[pro-components] ProTable 的 default 插槽保留用于列渲染,已忽略传入的 default 插槽内容;自定义区域请使用 search-form / button-bar / toolbar / table 具名插槽。"
|
|
1528
|
+
);
|
|
1529
|
+
}
|
|
1530
|
+
};
|
|
1531
|
+
const forwardedSlotNames = () => {
|
|
1532
|
+
checkDefaultSlot();
|
|
1533
|
+
return Object.keys(slots).filter(
|
|
1534
|
+
(name) => name !== "default" && !customSlotNames.includes(name)
|
|
1535
|
+
);
|
|
1536
|
+
};
|
|
1473
1537
|
const searchPage1st = () => {
|
|
1474
1538
|
var _a, _b;
|
|
1475
1539
|
(_b = (_a = props.table) == null ? void 0 : _a.setPageParam) == null ? void 0 : _b.call(_a, { current: 1 });
|
|
@@ -1484,22 +1548,31 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1484
1548
|
container: container ? container : void 0
|
|
1485
1549
|
};
|
|
1486
1550
|
});
|
|
1551
|
+
const searchFormProps = computed(() => {
|
|
1552
|
+
const {
|
|
1553
|
+
container: _container,
|
|
1554
|
+
hidden: _hidden,
|
|
1555
|
+
...rest
|
|
1556
|
+
} = computedSearchFormConfig.value;
|
|
1557
|
+
return rest;
|
|
1558
|
+
});
|
|
1487
1559
|
const computedTableContainer = computed(() => {
|
|
1488
1560
|
const container = props.tableContainer ?? injectProps.value.tableContainer ?? DefaultTableContainer;
|
|
1489
1561
|
return container ? container : void 0;
|
|
1490
1562
|
});
|
|
1491
1563
|
const getIndex = (i) => {
|
|
1492
1564
|
var _a;
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
return i + 1;
|
|
1565
|
+
const pagination = computedPagination.value;
|
|
1566
|
+
if (pagination === false) return i + 1;
|
|
1567
|
+
const pageParam = (_a = props.table) == null ? void 0 : _a.pageParam;
|
|
1568
|
+
const current = pagination.currentPage ?? (pageParam == null ? void 0 : pageParam.current) ?? 1;
|
|
1569
|
+
const pageSize = pagination.pageSize ?? (pageParam == null ? void 0 : pageParam.pageSize) ?? 10;
|
|
1570
|
+
return (current - 1) * pageSize + i + 1;
|
|
1499
1571
|
};
|
|
1572
|
+
const hasExplicitColumns = computed(() => props.columns !== void 0);
|
|
1500
1573
|
const normalizedRawColumns = computed(() => {
|
|
1501
1574
|
var _a;
|
|
1502
|
-
const source = props.columns ?? toValue((_a = props.table) == null ? void 0 : _a.columns) ?? [];
|
|
1575
|
+
const source = (props.columns ?? toValue((_a = props.table) == null ? void 0 : _a.columns) ?? []).filter(isObjectItem);
|
|
1503
1576
|
if (props.addIndexColumn ?? injectProps.value.addIndexColumn) {
|
|
1504
1577
|
return [
|
|
1505
1578
|
{
|
|
@@ -1516,30 +1589,20 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1516
1589
|
});
|
|
1517
1590
|
const computedDataSource = computed(() => {
|
|
1518
1591
|
var _a;
|
|
1519
|
-
|
|
1520
|
-
return props.data ?? attrsData ?? toValue((_a = props.table) == null ? void 0 : _a.data) ?? [];
|
|
1592
|
+
return props.data ?? toValue((_a = props.table) == null ? void 0 : _a.data) ?? [];
|
|
1521
1593
|
});
|
|
1522
1594
|
const computedTableProps = computed(() => {
|
|
1523
|
-
|
|
1595
|
+
return {
|
|
1524
1596
|
...injectTableAttrs.value,
|
|
1525
1597
|
...restTableAttrs.value,
|
|
1526
1598
|
...attrsTableProps.value
|
|
1527
1599
|
};
|
|
1528
|
-
delete merged.data;
|
|
1529
|
-
delete merged.columns;
|
|
1530
|
-
delete merged.size;
|
|
1531
|
-
delete merged.pagination;
|
|
1532
|
-
return merged;
|
|
1533
1600
|
});
|
|
1534
1601
|
const computedPagination = computed(() => {
|
|
1535
1602
|
var _a, _b;
|
|
1536
|
-
|
|
1537
|
-
if (props.pagination
|
|
1538
|
-
|
|
1539
|
-
}
|
|
1540
|
-
const hasUserPagination = isPlainObject(props.pagination) || isPlainObject(attrsPagination);
|
|
1541
|
-
if (hasUserPagination) {
|
|
1542
|
-
const pageConfig = props.pagination ?? attrsPagination ?? {};
|
|
1603
|
+
if (props.pagination === false) return false;
|
|
1604
|
+
if (isPlainObject(props.pagination)) {
|
|
1605
|
+
const pageConfig = props.pagination;
|
|
1543
1606
|
const globalPagination = injectProps.value.pagination === false ? {} : injectProps.value.pagination || {};
|
|
1544
1607
|
const pageParam2 = (_a = props.table) == null ? void 0 : _a.pageParam;
|
|
1545
1608
|
return {
|
|
@@ -1575,12 +1638,12 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1575
1638
|
(_a = attrs.onChange) == null ? void 0 : _a.call(attrs, currentPage, pageSize);
|
|
1576
1639
|
};
|
|
1577
1640
|
const searchFormVisible = computed(() => {
|
|
1578
|
-
var _a, _b, _c, _d
|
|
1641
|
+
var _a, _b, _c, _d;
|
|
1579
1642
|
const searchFields = (_b = (_a = props.table) == null ? void 0 : _a.searchForm) == null ? void 0 : _b.fields;
|
|
1580
1643
|
const fieldList = (Array.isArray(searchFields) ? searchFields : searchFields == null ? void 0 : searchFields.value) ?? [];
|
|
1581
|
-
return !!(((_c = computedSearchFormConfig.value) == null ? void 0 : _c.hidden) !== true && ((_d = props.table) == null ? void 0 : _d.searchForm) &&
|
|
1644
|
+
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);
|
|
1582
1645
|
});
|
|
1583
|
-
const
|
|
1646
|
+
const resolvedControl = computed(() => {
|
|
1584
1647
|
const mergedControl = props.control ?? injectProps.value.control;
|
|
1585
1648
|
if (typeof mergedControl === "boolean") {
|
|
1586
1649
|
return { sizeControl: mergedControl, columnControl: mergedControl };
|
|
@@ -1590,12 +1653,15 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1590
1653
|
const columnControl = (c == null ? void 0 : c.columnControl) ?? false;
|
|
1591
1654
|
return { sizeControl: !!sizeControl, columnControl };
|
|
1592
1655
|
});
|
|
1656
|
+
const computedControl = computed(
|
|
1657
|
+
() => hasExplicitColumns.value && resolvedControl.value.columnControl ? { ...resolvedControl.value, columnControl: false } : resolvedControl.value
|
|
1658
|
+
);
|
|
1593
1659
|
const columnControlConfig = computed(() => {
|
|
1594
1660
|
const cc = computedControl.value.columnControl;
|
|
1595
1661
|
return typeof cc === "object" ? cc : void 0;
|
|
1596
1662
|
});
|
|
1597
1663
|
const resolvedSize = computed(() => {
|
|
1598
|
-
return size.value ??
|
|
1664
|
+
return size.value ?? injectProps.value.size;
|
|
1599
1665
|
});
|
|
1600
1666
|
onMounted(() => {
|
|
1601
1667
|
if (props.immediateSearch ?? injectProps.value.immediateSearch) {
|
|
@@ -1623,7 +1689,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1623
1689
|
((_a = props.table) == null ? void 0 : _a.searchForm) ? (openBlock(), createBlock(SearchForm, mergeProps({
|
|
1624
1690
|
key: 0,
|
|
1625
1691
|
form: props.table.searchForm
|
|
1626
|
-
},
|
|
1692
|
+
}, searchFormProps.value, {
|
|
1627
1693
|
onSearch: searchPage1st,
|
|
1628
1694
|
onReset: reset
|
|
1629
1695
|
}), null, 16, ["form"])) : createCommentVNode("", true)
|
|
@@ -1644,8 +1710,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1644
1710
|
computedControl.value.sizeControl ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
1645
1711
|
createVNode(SizeControl, {
|
|
1646
1712
|
size: size.value,
|
|
1647
|
-
"onUpdate:size": _cache[0] || (_cache[0] = ($event) => size.value = $event)
|
|
1648
|
-
|
|
1713
|
+
"onUpdate:size": _cache[0] || (_cache[0] = ($event) => size.value = $event),
|
|
1714
|
+
"effective-size": resolvedSize.value
|
|
1715
|
+
}, null, 8, ["size", "effective-size"])
|
|
1649
1716
|
])) : createCommentVNode("", true),
|
|
1650
1717
|
computedControl.value.columnControl ? (openBlock(), createElementBlock("div", _hoisted_5, [
|
|
1651
1718
|
createVNode(ColumnControl, {
|
|
@@ -1692,13 +1759,14 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1692
1759
|
};
|
|
1693
1760
|
}
|
|
1694
1761
|
});
|
|
1695
|
-
const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
1762
|
+
const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-d092780c"]]);
|
|
1696
1763
|
function useTable(params = {}) {
|
|
1697
1764
|
const { data, columns, ...rest } = params;
|
|
1698
1765
|
const coreTable = useTable$1({
|
|
1699
1766
|
...rest,
|
|
1700
1767
|
dataSource: data,
|
|
1701
|
-
columns
|
|
1768
|
+
columns,
|
|
1769
|
+
fieldIdentityKeys: ELEMENT_FIELD_IDENTITY_KEYS
|
|
1702
1770
|
});
|
|
1703
1771
|
const { dataSource, ...tableWithoutDataSource } = coreTable;
|
|
1704
1772
|
const table = {
|
|
@@ -1723,15 +1791,21 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1723
1791
|
Object.keys(INJECT_CONFIG).forEach(
|
|
1724
1792
|
(key) => {
|
|
1725
1793
|
const config = INJECT_CONFIG[key];
|
|
1794
|
+
const ignored = config.ignoreProps;
|
|
1726
1795
|
provide(
|
|
1727
1796
|
config.injectionKey,
|
|
1728
|
-
computed(
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1797
|
+
computed(
|
|
1798
|
+
() => {
|
|
1799
|
+
var _a;
|
|
1800
|
+
return omit(
|
|
1801
|
+
{
|
|
1802
|
+
...config.default,
|
|
1803
|
+
...getObject((_a = props.componentVars) == null ? void 0 : _a[key])
|
|
1804
|
+
},
|
|
1805
|
+
ignored ?? []
|
|
1806
|
+
);
|
|
1807
|
+
}
|
|
1808
|
+
)
|
|
1735
1809
|
);
|
|
1736
1810
|
}
|
|
1737
1811
|
);
|
|
@@ -1752,6 +1826,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1752
1826
|
}
|
|
1753
1827
|
});
|
|
1754
1828
|
}
|
|
1829
|
+
provide(
|
|
1830
|
+
INJECT_COMPONENT_VARS,
|
|
1831
|
+
computed(() => props.componentVars ?? {})
|
|
1832
|
+
);
|
|
1755
1833
|
provide(
|
|
1756
1834
|
INJECT_COMPONENTS,
|
|
1757
1835
|
computed(() => props.componentMap)
|
|
@@ -1767,11 +1845,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1767
1845
|
});
|
|
1768
1846
|
const index = {
|
|
1769
1847
|
/**
|
|
1770
|
-
*
|
|
1771
|
-
* @description 全局注册所有组件(ProForm、ProTable、ProComponentProvider)
|
|
1848
|
+
* 安装方法:全局注册 ProForm / ProTable / ProComponentProvider
|
|
1772
1849
|
*
|
|
1850
|
+
* @description 供 `app.use(ProComponents)` 调用
|
|
1773
1851
|
* @param {App} app - Vue 应用实例
|
|
1774
|
-
*
|
|
1775
1852
|
* @example
|
|
1776
1853
|
* ```ts
|
|
1777
1854
|
* import { createApp } from 'vue'
|
|
@@ -1783,7 +1860,10 @@ const index = {
|
|
|
1783
1860
|
install(app) {
|
|
1784
1861
|
app.component(_sfc_main$b.name, _sfc_main$b);
|
|
1785
1862
|
app.component(ProTable.name, ProTable);
|
|
1786
|
-
app.component(
|
|
1863
|
+
app.component(
|
|
1864
|
+
_sfc_main.name ?? "ProComponentProvider",
|
|
1865
|
+
_sfc_main
|
|
1866
|
+
);
|
|
1787
1867
|
}
|
|
1788
1868
|
};
|
|
1789
1869
|
export {
|