@qin-ui/element-plus-pro 1.2.4 → 1.3.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.
Files changed (171) hide show
  1. package/README.md +5 -5
  2. package/api.json +1 -25
  3. package/es/__tests__/BaseField.spec.d.ts +2 -0
  4. package/es/__tests__/BaseField.spec.d.ts.map +1 -0
  5. package/es/__tests__/BaseFormItem.spec.d.ts +2 -0
  6. package/es/__tests__/BaseFormItem.spec.d.ts.map +1 -0
  7. package/es/__tests__/ProForm.spec.d.ts +2 -0
  8. package/es/__tests__/ProForm.spec.d.ts.map +1 -0
  9. package/es/__tests__/ProTable.spec.d.ts +2 -0
  10. package/es/__tests__/ProTable.spec.d.ts.map +1 -0
  11. package/es/__tests__/SearchForm.spec.d.ts +2 -0
  12. package/es/__tests__/SearchForm.spec.d.ts.map +1 -0
  13. package/es/__tests__/controls.spec.d.ts +2 -0
  14. package/es/__tests__/controls.spec.d.ts.map +1 -0
  15. package/es/__tests__/helpers/fixtures.d.ts +15 -0
  16. package/es/__tests__/helpers/fixtures.d.ts.map +1 -0
  17. package/es/__tests__/helpers/mount.d.ts +38 -0
  18. package/es/__tests__/helpers/mount.d.ts.map +1 -0
  19. package/es/__tests__/hooks-locale.spec.d.ts +2 -0
  20. package/es/__tests__/hooks-locale.spec.d.ts.map +1 -0
  21. package/es/__tests__/index.spec.d.ts +2 -0
  22. package/es/__tests__/index.spec.d.ts.map +1 -0
  23. package/es/__tests__/integration.spec.d.ts +2 -0
  24. package/es/__tests__/integration.spec.d.ts.map +1 -0
  25. package/es/__tests__/setup.d.ts +14 -0
  26. package/es/__tests__/setup.d.ts.map +1 -0
  27. package/es/element-plus-pro.css +14 -14
  28. package/es/index.js +415 -274
  29. package/es/index.js.map +1 -1
  30. package/es/{components → src/components}/component-provider/components/index.vue.d.ts +5 -1
  31. package/es/src/components/component-provider/components/index.vue.d.ts.map +1 -0
  32. package/es/src/components/component-provider/constants/index.d.ts.map +1 -0
  33. package/es/src/components/component-provider/index.d.ts.map +1 -0
  34. package/es/{components → src/components}/component-provider/types/index.d.ts +9 -5
  35. package/es/src/components/component-provider/types/index.d.ts.map +1 -0
  36. package/es/{components → src/components}/form/components/BaseField/index.vue.d.ts +4 -1
  37. package/es/src/components/form/components/BaseField/index.vue.d.ts.map +1 -0
  38. package/es/src/components/form/components/BaseField/utils/index.d.ts +5 -0
  39. package/es/src/components/form/components/BaseField/utils/index.d.ts.map +1 -0
  40. package/es/{components → src/components}/form/components/BaseFormItem/index.vue.d.ts +4 -2
  41. package/es/src/components/form/components/BaseFormItem/index.vue.d.ts.map +1 -0
  42. package/es/src/components/form/components/ContainerFragment/index.vue.d.ts.map +1 -0
  43. package/es/src/components/form/components/ProForm/index.vue.d.ts.map +1 -0
  44. package/es/src/components/form/components/SlotComponent/index.vue.d.ts.map +1 -0
  45. package/es/src/components/form/components/index.d.ts.map +1 -0
  46. package/es/src/components/form/constants/index.d.ts.map +1 -0
  47. package/es/src/components/form/hooks/index.d.ts.map +1 -0
  48. package/es/src/components/form/hooks/useFields.d.ts.map +1 -0
  49. package/es/src/components/form/hooks/useForm.d.ts.map +1 -0
  50. package/es/src/components/form/hooks/useFormRef.d.ts.map +1 -0
  51. package/es/src/components/form/hooks/useGroupFieldAttrs.d.ts.map +1 -0
  52. package/es/src/components/form/index.d.ts.map +1 -0
  53. package/es/{components → src/components}/form/types/index.d.ts +26 -2
  54. package/es/src/components/form/types/index.d.ts.map +1 -0
  55. package/es/{components → src/components}/table/components/ColumnControl.vue.d.ts +4 -1
  56. package/es/src/components/table/components/ColumnControl.vue.d.ts.map +1 -0
  57. package/es/src/components/table/components/DefaultSearchFormContainer.vue.d.ts.map +1 -0
  58. package/es/src/components/table/components/DefaultTableContainer.vue.d.ts.map +1 -0
  59. package/es/src/components/table/components/ProTable.vue.d.ts.map +1 -0
  60. package/es/{components → src/components}/table/components/SearchForm.vue.d.ts +14 -4
  61. package/es/src/components/table/components/SearchForm.vue.d.ts.map +1 -0
  62. package/es/src/components/table/components/SizeControl.vue.d.ts.map +1 -0
  63. package/es/src/components/table/components/TableColumnRenderer.vue.d.ts.map +1 -0
  64. package/es/src/components/table/components/icons/ColumnHeightOutlined.vue.d.ts.map +1 -0
  65. package/es/src/components/table/components/icons/DownOutlined.vue.d.ts.map +1 -0
  66. package/es/src/components/table/components/icons/FilterOutlined.vue.d.ts.map +1 -0
  67. package/es/src/components/table/components/index.d.ts.map +1 -0
  68. package/es/src/components/table/index.d.ts.map +1 -0
  69. package/es/src/components/table/types/index.d.ts.map +1 -0
  70. package/es/src/components/table/useTable.d.ts.map +1 -0
  71. package/es/{index.d.ts → src/index.d.ts} +1 -1
  72. package/es/src/index.d.ts.map +1 -0
  73. package/es/src/locale/en-US.d.ts.map +1 -0
  74. package/es/src/locale/index.d.ts.map +1 -0
  75. package/es/src/locale/zh-CN.d.ts.map +1 -0
  76. package/es/src/locale/zh-TW.d.ts.map +1 -0
  77. package/es/src/shared/core/index.d.ts +6 -0
  78. package/es/src/shared/core/index.d.ts.map +1 -0
  79. package/es/{shared → src/shared}/ui/index.d.ts +2 -0
  80. package/es/src/shared/ui/index.d.ts.map +1 -0
  81. package/package.json +8 -3
  82. package/src/components/component-provider/components/index.vue +37 -8
  83. package/src/components/component-provider/constants/index.ts +2 -2
  84. package/src/components/component-provider/types/index.ts +9 -5
  85. package/src/components/form/components/BaseField/index.vue +67 -35
  86. package/src/components/form/components/BaseField/utils/index.ts +6 -11
  87. package/src/components/form/components/BaseFormItem/index.vue +47 -41
  88. package/src/components/form/components/ProForm/index.vue +72 -18
  89. package/src/components/form/hooks/useGroupFieldAttrs.ts +8 -4
  90. package/src/components/form/types/index.ts +26 -2
  91. package/src/components/table/components/ColumnControl.vue +18 -24
  92. package/src/components/table/components/ProTable.vue +112 -57
  93. package/src/components/table/components/SearchForm.vue +85 -60
  94. package/src/components/table/components/SizeControl.vue +2 -2
  95. package/src/components/table/components/TableColumnRenderer.vue +12 -9
  96. package/src/components/table/useTable.ts +12 -7
  97. package/src/index.ts +1 -1
  98. package/src/locale/index.ts +6 -2
  99. package/src/shared/core/index.ts +4 -2
  100. package/src/shared/ui/index.ts +11 -5
  101. package/es/components/component-provider/components/index.vue.d.ts.map +0 -1
  102. package/es/components/component-provider/constants/index.d.ts.map +0 -1
  103. package/es/components/component-provider/index.d.ts.map +0 -1
  104. package/es/components/component-provider/types/index.d.ts.map +0 -1
  105. package/es/components/form/components/BaseField/index.vue.d.ts.map +0 -1
  106. package/es/components/form/components/BaseField/utils/index.d.ts +0 -5
  107. package/es/components/form/components/BaseField/utils/index.d.ts.map +0 -1
  108. package/es/components/form/components/BaseFormItem/index.vue.d.ts.map +0 -1
  109. package/es/components/form/components/ContainerFragment/index.vue.d.ts.map +0 -1
  110. package/es/components/form/components/ProForm/index.vue.d.ts.map +0 -1
  111. package/es/components/form/components/SlotComponent/index.vue.d.ts.map +0 -1
  112. package/es/components/form/components/index.d.ts.map +0 -1
  113. package/es/components/form/constants/index.d.ts.map +0 -1
  114. package/es/components/form/hooks/index.d.ts.map +0 -1
  115. package/es/components/form/hooks/useFields.d.ts.map +0 -1
  116. package/es/components/form/hooks/useForm.d.ts.map +0 -1
  117. package/es/components/form/hooks/useFormRef.d.ts.map +0 -1
  118. package/es/components/form/hooks/useGroupFieldAttrs.d.ts.map +0 -1
  119. package/es/components/form/index.d.ts.map +0 -1
  120. package/es/components/form/types/index.d.ts.map +0 -1
  121. package/es/components/table/components/ColumnControl.vue.d.ts.map +0 -1
  122. package/es/components/table/components/DefaultSearchFormContainer.vue.d.ts.map +0 -1
  123. package/es/components/table/components/DefaultTableContainer.vue.d.ts.map +0 -1
  124. package/es/components/table/components/ProTable.vue.d.ts.map +0 -1
  125. package/es/components/table/components/SearchForm.vue.d.ts.map +0 -1
  126. package/es/components/table/components/SizeControl.vue.d.ts.map +0 -1
  127. package/es/components/table/components/TableColumnRenderer.vue.d.ts.map +0 -1
  128. package/es/components/table/components/icons/ColumnHeightOutlined.vue.d.ts.map +0 -1
  129. package/es/components/table/components/icons/DownOutlined.vue.d.ts.map +0 -1
  130. package/es/components/table/components/icons/FilterOutlined.vue.d.ts.map +0 -1
  131. package/es/components/table/components/index.d.ts.map +0 -1
  132. package/es/components/table/index.d.ts.map +0 -1
  133. package/es/components/table/types/index.d.ts.map +0 -1
  134. package/es/components/table/useTable.d.ts.map +0 -1
  135. package/es/index.d.ts.map +0 -1
  136. package/es/locale/en-US.d.ts.map +0 -1
  137. package/es/locale/index.d.ts.map +0 -1
  138. package/es/locale/zh-CN.d.ts.map +0 -1
  139. package/es/locale/zh-TW.d.ts.map +0 -1
  140. package/es/shared/core/index.d.ts +0 -6
  141. package/es/shared/core/index.d.ts.map +0 -1
  142. package/es/shared/ui/index.d.ts.map +0 -1
  143. /package/es/{components → src/components}/component-provider/constants/index.d.ts +0 -0
  144. /package/es/{components → src/components}/component-provider/index.d.ts +0 -0
  145. /package/es/{components → src/components}/form/components/ContainerFragment/index.vue.d.ts +0 -0
  146. /package/es/{components → src/components}/form/components/ProForm/index.vue.d.ts +0 -0
  147. /package/es/{components → src/components}/form/components/SlotComponent/index.vue.d.ts +0 -0
  148. /package/es/{components → src/components}/form/components/index.d.ts +0 -0
  149. /package/es/{components → src/components}/form/constants/index.d.ts +0 -0
  150. /package/es/{components → src/components}/form/hooks/index.d.ts +0 -0
  151. /package/es/{components → src/components}/form/hooks/useFields.d.ts +0 -0
  152. /package/es/{components → src/components}/form/hooks/useForm.d.ts +0 -0
  153. /package/es/{components → src/components}/form/hooks/useFormRef.d.ts +0 -0
  154. /package/es/{components → src/components}/form/hooks/useGroupFieldAttrs.d.ts +0 -0
  155. /package/es/{components → src/components}/form/index.d.ts +0 -0
  156. /package/es/{components → src/components}/table/components/DefaultSearchFormContainer.vue.d.ts +0 -0
  157. /package/es/{components → src/components}/table/components/DefaultTableContainer.vue.d.ts +0 -0
  158. /package/es/{components → src/components}/table/components/ProTable.vue.d.ts +0 -0
  159. /package/es/{components → src/components}/table/components/SizeControl.vue.d.ts +0 -0
  160. /package/es/{components → src/components}/table/components/TableColumnRenderer.vue.d.ts +0 -0
  161. /package/es/{components → src/components}/table/components/icons/ColumnHeightOutlined.vue.d.ts +0 -0
  162. /package/es/{components → src/components}/table/components/icons/DownOutlined.vue.d.ts +0 -0
  163. /package/es/{components → src/components}/table/components/icons/FilterOutlined.vue.d.ts +0 -0
  164. /package/es/{components → src/components}/table/components/index.d.ts +0 -0
  165. /package/es/{components → src/components}/table/index.d.ts +0 -0
  166. /package/es/{components → src/components}/table/types/index.d.ts +0 -0
  167. /package/es/{components → src/components}/table/useTable.d.ts +0 -0
  168. /package/es/{locale → src/locale}/en-US.d.ts +0 -0
  169. /package/es/{locale → src/locale}/index.d.ts +0 -0
  170. /package/es/{locale → src/locale}/zh-CN.d.ts +0 -0
  171. /package/es/{locale → src/locale}/zh-TW.d.ts +0 -0
package/es/index.js CHANGED
@@ -1,25 +1,22 @@
1
1
  import "./element-plus-pro.css";
2
- import { inject, computed, provide, toValue, mergeProps, defineComponent, resolveComponent, createBlock, openBlock, unref, withCtx, createElementBlock, Fragment, renderList, createVNode, createSlots, ref, useAttrs, createCommentVNode, resolveDynamicComponent, renderSlot, normalizeProps, isVNode, createTextVNode, toDisplayString, useSlots, reactive, withModifiers, createElementVNode, onBeforeUnmount, watch, watchEffect, withKeys, normalizeStyle, nextTick, useModel, onMounted, mergeModels, resolveDirective, normalizeClass, withDirectives, guardReactiveProps } from "vue";
3
- import { ElTable, ElPagination, useFormDisabled, ElCol, ElFormItem, ElTransfer, ElTreeSelect, ElSlider, ElSwitch, ElRadioGroup, ElCheckboxGroup, ElTimeSelect, ElTimePicker, ElDatePicker, ElCascader, ElSelect, ElAutocomplete, ElInputNumber, ElInput, ElRow, useLocale as useLocale$1, ElForm, ElSpace, ElButton, ElDropdown, ElDropdownMenu, ElDropdownItem, ElCheckbox, ElTableColumn } from "element-plus";
4
- import { isPlainObject, getObject, toPath, useForm as useForm$1, zhCN as zhCN$1, zhTW as zhTW$1, enUS as enUS$1, resolveLocaleName, format, omit, InjectionFormSlotsKey, cloneDeep, InjectionFormKey, camelizeProperties, useFields as useFields$1, useFormRef as useFormRef$1, get, pick, useTable as useTable$1 } from "@qin-ui/pro-components-core";
2
+ import { inject, computed, toValue, mergeProps, defineComponent, resolveComponent, createBlock, openBlock, unref, withCtx, createElementBlock, Fragment, renderList, createVNode, createSlots, toRaw, ref, useAttrs, createCommentVNode, resolveDynamicComponent, renderSlot, normalizeProps, isVNode, createTextVNode, toDisplayString, provide, useSlots, withModifiers, createElementVNode, onBeforeUnmount, watch, watchEffect, normalizeStyle, useModel, onMounted, mergeModels, resolveDirective, normalizeClass, withDirectives, guardReactiveProps, nextTick } from "vue";
3
+ import { ElTable, ElPagination, useFormDisabled, ElCol, ElFormItem, ElTransfer, ElTreeSelect, ElSlider, ElSwitch, ElRadioGroup, ElCheckboxGroup, ElTimeSelect, ElTimePicker, ElDatePicker, ElCascader, ElSelect, ElAutocomplete, ElInputNumber, ElInput, ElRow, localeContextKey, useLocale as useLocale$1, ElForm, ElSpace, ElButton, ElDropdown, ElDropdownMenu, ElDropdownItem, ElCheckbox, ElTableColumn, ElLoading } from "element-plus";
4
+ import { isPlainObject, getObject, normalizePathKey, useForm as useForm$1, zhCN as zhCN$1, zhTW as zhTW$1, enUS as enUS$1, resolveLocaleName, format, cloneDeep, InjectionFormSlotsKey, InjectionFormKey, camelizeProperties, useFields as useFields$1, useFormRef as useFormRef$1, get, pick, isPromise, useTable as useTable$1 } 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 || {};
8
8
  const gridItemProps = () => ElCol.props || {};
9
9
  const formItemProps = () => ElFormItem.props || {};
10
- const DisabledContextKey = Symbol("pro-form-disabled-context");
10
+ const DisabledContextKey = Symbol.for("pro-form-disabled-context");
11
11
  const useDisabledContext = () => {
12
12
  const formDisabled = useFormDisabled();
13
- return inject(
14
- DisabledContextKey,
15
- computed(() => !!formDisabled.value)
16
- );
17
- };
18
- const useDisabledContextProvider = (disabled) => {
19
- provide(
20
- DisabledContextKey,
21
- computed(() => !!toValue(disabled))
22
- );
13
+ const customDisabled = inject(DisabledContextKey, void 0);
14
+ return computed(() => {
15
+ if (customDisabled !== void 0 && toValue(customDisabled) !== void 0) {
16
+ return Boolean(toValue(customDisabled));
17
+ }
18
+ return Boolean(formDisabled.value);
19
+ });
23
20
  };
24
21
  const INJECT_CONFIG = {
25
22
  "pro-table": {
@@ -205,12 +202,15 @@ const componentMap = {
205
202
  "tree-select": ElTreeSelect,
206
203
  "transfer": ElTransfer
207
204
  };
208
- const formItemPropKeys = Object.keys(formItemProps());
205
+ const formItemPropKeys = Object.keys(formItemProps()).filter(
206
+ (k) => k !== "disabled"
207
+ );
209
208
  const gridItemPropKeys = Object.keys(gridItemProps());
210
209
  function useGroupFieldAttrs(validFields) {
211
210
  const config = INJECT_CONFIG["pro-form-item"];
212
211
  const injectFormItemProps = inject(config.injectionKey, config.default);
213
212
  return computed(() => {
213
+ const rawInjectProps = toValue(injectFormItemProps) || {};
214
214
  return validFields.value.map((field) => {
215
215
  let gridItemProps2 = {};
216
216
  let formItemProps2 = {};
@@ -229,7 +229,7 @@ function useGroupFieldAttrs(validFields) {
229
229
  lg,
230
230
  xl,
231
231
  ...injectRest
232
- } = injectFormItemProps;
232
+ } = rawInjectProps;
233
233
  const initGridItemProps = span || span === 0 ? { span } : { xs, sm, md, lg, xl, span: injectSpan };
234
234
  gridItemProps2 = fields ? { span: span ?? 24 } : initGridItemProps;
235
235
  formItemProps2 = mergeProps(
@@ -256,7 +256,7 @@ function useGroupFieldAttrs(validFields) {
256
256
  componentProps.slots[k] = slots[k];
257
257
  }
258
258
  });
259
- const raw2 = toValue(path) ?? toValue(name);
259
+ const raw2 = toValue(name) ?? toValue(path);
260
260
  return {
261
261
  path: Array.isArray(raw2) ? raw2.join(".") : raw2 || "",
262
262
  gridItemProps: gridItemProps2,
@@ -267,7 +267,7 @@ function useGroupFieldAttrs(validFields) {
267
267
  rawField: field
268
268
  };
269
269
  }
270
- const raw = toValue(field == null ? void 0 : field.path) ?? toValue(field == null ? void 0 : field.name);
270
+ const raw = toValue(field == null ? void 0 : field.name) ?? toValue(field == null ? void 0 : field.path);
271
271
  return {
272
272
  path: Array.isArray(raw) ? raw.join(".") : raw || "",
273
273
  gridItemProps: gridItemProps2,
@@ -283,46 +283,56 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
283
283
  ...{ name: "BaseFormItem", inheritAttrs: false },
284
284
  __name: "index",
285
285
  props: {
286
- grid: { type: [Boolean, Object], default: () => void 0 },
287
- fields: { default: () => [] },
288
- disabled: { type: Boolean, default: () => void 0 }
286
+ grid: { type: [Boolean, Object], default: void 0 },
287
+ fields: { default: () => [] }
289
288
  },
290
289
  setup(__props) {
291
- const validFields = computed(() => {
292
- var _a, _b;
293
- return (_b = (_a = __props.fields).filter) == null ? void 0 : _b.call(_a, (field) => !field.hidden);
294
- });
295
- useDisabledContextProvider(computed(() => __props.disabled));
290
+ const props = __props;
291
+ const validFields = computed(
292
+ () => (props.fields ?? []).filter((field) => !field.hidden)
293
+ );
296
294
  const config = INJECT_CONFIG["pro-form"];
297
- const { grid: injectGrid } = inject(config.injectionKey, config.default);
295
+ const injectFormConfig = inject(config.injectionKey, config.default);
296
+ const injectGrid = computed(() => {
297
+ var _a;
298
+ return (_a = toValue(injectFormConfig)) == null ? void 0 : _a.grid;
299
+ });
298
300
  const enableGrid = computed(() => {
299
- if (__props.grid !== void 0) return !!__props.grid;
300
- return !!injectGrid;
301
+ if (props.grid !== void 0) return !!props.grid;
302
+ return !!injectGrid.value;
301
303
  });
302
304
  const computedGridProps = computed(() => {
303
- return enableGrid.value ? { ...getObject(injectGrid), ...getObject(__props.grid) } : {};
305
+ return enableGrid.value ? { ...getObject(injectGrid.value), ...getObject(props.grid) } : {};
304
306
  });
305
- const formItemRefs = [];
306
- const componentRefs = [];
307
- const onFormItemMounted = (index2, formItemProps2) => {
308
- const field = validFields.value[index2];
309
- Object.assign(field, {
310
- getFormItemRef: () => formItemRefs[index2],
311
- getFormItemComputedProps: () => formItemProps2
312
- });
307
+ const formItemInstanceMap = /* @__PURE__ */ new WeakMap();
308
+ const componentInstanceMap = /* @__PURE__ */ new WeakMap();
309
+ const setFormItemRef = (field, el, formItemProps2) => {
310
+ if (!field || typeof field !== "object") return;
311
+ const raw = toRaw(field);
312
+ if (el) {
313
+ formItemInstanceMap.set(raw, el);
314
+ raw.getFormItemRef = () => formItemInstanceMap.get(raw);
315
+ raw.getFormItemComputedProps = () => formItemProps2;
316
+ } else {
317
+ formItemInstanceMap.delete(raw);
318
+ }
313
319
  };
314
- const onComponentMounted = (index2) => {
315
- const field = validFields.value[index2];
316
- Object.assign(field, {
317
- getComponentRef: () => {
320
+ const setComponentRef = (field, el) => {
321
+ if (!field || typeof field !== "object") return;
322
+ const raw = toRaw(field);
323
+ if (el) {
324
+ componentInstanceMap.set(raw, el);
325
+ raw.getComponentRef = () => {
318
326
  var _a;
319
- return (_a = componentRefs[index2]) == null ? void 0 : _a.getComponentRef();
320
- },
321
- getComponentComputedProps: () => {
327
+ return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentRef();
328
+ };
329
+ raw.getComponentComputedProps = () => {
322
330
  var _a;
323
- return (_a = componentRefs[index2]) == null ? void 0 : _a.getComponentComputedProps();
324
- }
325
- });
331
+ return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentComputedProps();
332
+ };
333
+ } else {
334
+ componentInstanceMap.delete(raw);
335
+ }
326
336
  };
327
337
  const groupedFields = useGroupFieldAttrs(validFields);
328
338
  return (_ctx, _cache) => {
@@ -344,25 +354,22 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
344
354
  default: withCtx(() => [
345
355
  createVNode(unref(ElFormItem), mergeProps({ ref_for: true }, item.formItemProps, {
346
356
  ref_for: true,
347
- ref: (el) => formItemRefs[index2] = el,
348
- prop: unref(toPath)(item.path).join("."),
349
- path: item.path,
350
- onVnodeMounted: ($event) => onFormItemMounted(index2, item.formItemProps)
357
+ ref: (el) => setFormItemRef(item.rawField, el, item.formItemProps),
358
+ prop: unref(normalizePathKey)(item.path),
359
+ path: item.path
351
360
  }), createSlots({
352
361
  default: withCtx(() => [
353
362
  item.rawField.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
354
363
  key: 0,
355
- grid: item.rawField.grid ?? __props.grid,
356
- fields: item.rawField.fields,
357
- disabled: toValue(item.rawField.disabled)
358
- }, null, 8, ["grid", "fields", "disabled"])) : (openBlock(), createBlock(unref(_sfc_main$e), mergeProps({
364
+ grid: item.rawField.grid ?? props.grid,
365
+ fields: item.rawField.fields
366
+ }, null, 8, ["grid", "fields"])) : (openBlock(), createBlock(unref(_sfc_main$e), mergeProps({
359
367
  key: 1,
360
368
  ref_for: true,
361
- ref: (el) => componentRefs[index2] = el
369
+ ref: (el) => setComponentRef(item.rawField, el)
362
370
  }, { ref_for: true }, item.componentProps, {
363
- path: item.path,
364
- onVnodeMounted: ($event) => onComponentMounted(index2)
365
- }), null, 16, ["path", "onVnodeMounted"]))
371
+ path: item.path
372
+ }), null, 16, ["path"]))
366
373
  ]),
367
374
  _: 2
368
375
  }, [
@@ -377,7 +384,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
377
384
  ])
378
385
  };
379
386
  })
380
- ]), 1040, ["prop", "path", "onVnodeMounted"])
387
+ ]), 1040, ["prop", "path"])
381
388
  ]),
382
389
  _: 2
383
390
  }, 1032, ["component", "path"])
@@ -398,7 +405,7 @@ const _export_sfc = (sfc, props) => {
398
405
  }
399
406
  return target;
400
407
  };
401
- const BaseFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-295cd434"]]);
408
+ const BaseFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-3cc74dbb"]]);
402
409
  function useForm(...args) {
403
410
  return useForm$1(...args);
404
411
  }
@@ -443,13 +450,10 @@ const getPlaceholderProps = (key, injectProps, t) => {
443
450
  if (!placeholderKey || injectProps.placeholder !== void 0) return {};
444
451
  return { placeholder: t(placeholderKey) };
445
452
  };
446
- const getInitProps = (field, t) => {
453
+ const getInitProps = (field, injectProps = {}, t) => {
447
454
  const { component, type } = field;
448
455
  if (typeof component === "string") {
449
456
  const k = [component, type].filter(Boolean).join(".");
450
- const config = getInjectConfig(k);
451
- if (!config) return getPlaceholderProps(k, {}, t);
452
- const injectProps = inject(config.injectionKey, config.default);
453
457
  return { ...injectProps, ...getPlaceholderProps(k, injectProps, t) };
454
458
  }
455
459
  return {};
@@ -495,9 +499,13 @@ const enUS = {
495
499
  };
496
500
  const LOCALE_INJECT_KEY = Symbol("pro-locale");
497
501
  const useLocale = () => {
502
+ const elLocaleContext = inject(localeContextKey, void 0);
498
503
  const { lang: elLang } = useLocale$1();
499
504
  const override = inject(LOCALE_INJECT_KEY, void 0);
500
- const lang = computed(() => resolveLocaleName(elLang.value));
505
+ const lang = computed(() => {
506
+ if (!elLocaleContext) return "zh-CN";
507
+ return resolveLocaleName(elLang.value);
508
+ });
501
509
  const pack = computed(
502
510
  () => lang.value === "zh-TW" ? zhTW : lang.value === "en-US" ? enUS : zhCN
503
511
  );
@@ -512,21 +520,23 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
512
520
  ...{ name: "BaseField", inheritAttrs: false },
513
521
  __name: "index",
514
522
  props: {
515
- component: { default: () => void 0 },
523
+ component: { default: void 0 },
516
524
  path: { default: "" }
517
525
  },
518
526
  setup(__props, { expose: __expose }) {
527
+ const props = __props;
519
528
  const { t } = useLocale();
520
529
  const form = useForm(false);
521
- const { getFormData, setFormData } = form;
522
530
  const componentRef = ref();
523
531
  const attrs = useAttrs();
524
- function getOldValue() {
525
- return cloneDeep(getFormData == null ? void 0 : getFormData(__props.path));
526
- }
532
+ const typeVal = attrs.type;
533
+ const injectConfigKey = typeof props.component === "string" ? [props.component, typeVal].filter(Boolean).join(".") : "";
534
+ const componentInjectConfig = injectConfigKey ? getInjectConfig(injectConfigKey) : void 0;
535
+ const rawInjectComponentProps = componentInjectConfig ? inject(componentInjectConfig.injectionKey, componentInjectConfig.default) : void 0;
527
536
  const value = computed({
528
537
  get() {
529
- let val = getFormData == null ? void 0 : getFormData(__props.path);
538
+ var _a;
539
+ let val = (_a = form.getFormData) == null ? void 0 : _a.call(form, props.path);
530
540
  const { valueFormatter } = groupedAttrs.value;
531
541
  if (typeof valueFormatter === "object" && typeof valueFormatter.get === "function") {
532
542
  val = valueFormatter.get(val);
@@ -534,59 +544,61 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
534
544
  return val;
535
545
  },
536
546
  set(val) {
547
+ var _a, _b;
537
548
  let newVal = val;
538
549
  const { valueFormatter } = groupedAttrs.value;
539
- if (valueFormatter) {
540
- if (typeof valueFormatter === "function") {
541
- newVal = valueFormatter(val, getOldValue());
542
- } else if (typeof valueFormatter.set === "function") {
543
- newVal = valueFormatter.set(val, getOldValue());
544
- }
550
+ const setFormatter = typeof valueFormatter === "function" ? valueFormatter : typeof valueFormatter === "object" && typeof (valueFormatter == null ? void 0 : valueFormatter.set) === "function" ? valueFormatter.set : void 0;
551
+ if (setFormatter) {
552
+ const oldVal = setFormatter.length > 1 ? cloneDeep((_a = form.getFormData) == null ? void 0 : _a.call(form, props.path)) : void 0;
553
+ newVal = setFormatter(val, oldVal);
545
554
  }
546
- setFormData == null ? void 0 : setFormData(__props.path, newVal);
555
+ (_b = form.setFormData) == null ? void 0 : _b.call(form, props.path, newVal);
547
556
  }
548
557
  });
549
558
  const parentDisabled = useDisabledContext();
550
559
  const groupedAttrs = computed(() => {
560
+ const currentInjectProps = toValue(rawInjectComponentProps) || {};
551
561
  const initProps = getInitProps(
552
562
  {
553
- component: __props.component,
563
+ component: props.component,
554
564
  type: attrs.type
555
565
  },
566
+ currentInjectProps,
556
567
  t
557
568
  );
558
569
  const modelPropName = attrs.modelProp ?? initProps.modelProp ?? "modelValue";
570
+ const effectiveDisabled = attrs.disabled !== void 0 ? Boolean(attrs.disabled) : Boolean(parentDisabled.value || initProps.disabled);
559
571
  const mergedProps = mergeProps(
560
572
  initProps,
561
573
  attrs,
562
574
  { class: attrs.componentClass, style: attrs.componentStyle },
563
575
  { class: initProps.componentClass, style: initProps.componentStyle },
564
- { disabled: attrs.disabled ?? parentDisabled.value ?? initProps.disabled },
576
+ { disabled: effectiveDisabled },
565
577
  { modelProp: modelPropName }
566
578
  );
567
- const { valueFormatter, modelProp, slots, componentClass, componentStyle, componentContainer, ...rest } = mergedProps;
568
- const modelBindingProp = modelProp ?? "modelValue";
569
- const bindAttrs = omit(rest, [
570
- modelBindingProp,
571
- `onUpdate:${modelBindingProp}`
572
- ]);
579
+ const { valueFormatter, modelProp, slots, componentClass, componentStyle, componentContainer, [modelPropName]: _modelVal, [`onUpdate:${modelPropName}`]: _onUpdateModelVal, ...bindAttrs } = mergedProps;
573
580
  return {
574
581
  attrs: bindAttrs,
575
582
  slots,
576
583
  componentContainer,
577
- modelProp: modelBindingProp,
584
+ modelProp: modelPropName,
578
585
  valueFormatter
579
586
  };
580
587
  });
581
588
  const formSlots = inject(InjectionFormSlotsKey, void 0);
582
589
  const customComponents = inject(INJECT_COMPONENTS, {});
583
590
  const is = computed(() => {
584
- const teleportSlot = __props.path && (formSlots == null ? void 0 : formSlots[__props.path]);
591
+ const teleportSlot = props.path && (formSlots == null ? void 0 : formSlots[props.path]);
585
592
  if (teleportSlot) return teleportSlot;
586
- if (typeof __props.component === "string") {
587
- return customComponents[__props.component] || componentMap[__props.component] || __props.component;
593
+ if (typeof props.component === "string") {
594
+ const resolved = customComponents[props.component] || componentMap[props.component];
595
+ if (resolved) return resolved;
596
+ console.warn(
597
+ `[pro-components] 未识别的组件类型 "${props.component}",已降级为原生元素渲染。如为自定义组件请在 componentMap 或 ProComponentProvider 中注册。`
598
+ );
599
+ return props.component;
588
600
  }
589
- return __props.component;
601
+ return props.component;
590
602
  });
591
603
  __expose({
592
604
  getComponentRef: () => componentRef.value,
@@ -595,7 +607,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
595
607
  return (_ctx, _cache) => {
596
608
  return openBlock(), createBlock(unref(_sfc_main$d), {
597
609
  component: groupedAttrs.value.componentContainer,
598
- path: __props.path
610
+ path: props.path
599
611
  }, {
600
612
  default: withCtx(() => [
601
613
  is.value ? (openBlock(), createBlock(resolveDynamicComponent(is.value), mergeProps({ key: 0 }, groupedAttrs.value.attrs, {
@@ -603,13 +615,15 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
603
615
  ref: componentRef,
604
616
  [`${groupedAttrs.value.modelProp}`]: value.value,
605
617
  [`onUpdate:${groupedAttrs.value.modelProp}`]: _cache[0] || (_cache[0] = ($event) => value.value = $event),
606
- path: __props.path
618
+ path: props.path
607
619
  }), createSlots({ _: 2 }, [
608
620
  renderList(groupedAttrs.value.slots, (slot, name) => {
609
621
  return {
610
622
  name,
611
623
  fn: withCtx((scoped) => [
612
- createVNode(unref(_sfc_main$c), mergeProps({ path: __props.path }, scoped, { component: slot }), null, 16, ["path", "component"])
624
+ createVNode(unref(_sfc_main$c), mergeProps({
625
+ path: props.path
626
+ }, scoped, { component: slot }), null, 16, ["path", "component"])
613
627
  ])
614
628
  };
615
629
  })
@@ -656,36 +670,83 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
656
670
  __name: "index",
657
671
  props: {
658
672
  grid: { type: [Boolean, Object], default: false },
659
- form: { default: () => ({}) }
673
+ form: { default: void 0 }
660
674
  },
661
675
  setup(__props) {
662
- provide(InjectionFormKey, __props.form);
663
- const { formData, fields, setFormRef } = __props.form;
664
- const _fields = computed(() => fields.value);
676
+ const props = __props;
677
+ const fallbackForm = props.form ? void 0 : useForm();
678
+ const currentForm = computed(
679
+ () => props.form ?? fallbackForm
680
+ );
681
+ const formProxy = new Proxy({}, {
682
+ get(_, prop) {
683
+ const target = currentForm.value;
684
+ const val = target == null ? void 0 : target[prop];
685
+ if (typeof val === "function") {
686
+ return (...args) => {
687
+ var _a, _b;
688
+ return (_b = (_a = currentForm.value) == null ? void 0 : _a[prop]) == null ? void 0 : _b.call(_a, ...args);
689
+ };
690
+ }
691
+ return val;
692
+ },
693
+ set(_, prop, value) {
694
+ if (currentForm.value) {
695
+ currentForm.value[prop] = value;
696
+ }
697
+ return true;
698
+ },
699
+ has(_, prop) {
700
+ return Boolean(currentForm.value && prop in currentForm.value);
701
+ }
702
+ });
703
+ provide(InjectionFormKey, formProxy);
704
+ const fields = computed(() => {
705
+ var _a;
706
+ const f = (_a = currentForm.value) == null ? void 0 : _a.fields;
707
+ return (Array.isArray(f) ? f : f == null ? void 0 : f.value) ?? [];
708
+ });
709
+ const formData = computed(() => {
710
+ var _a;
711
+ return (_a = currentForm.value) == null ? void 0 : _a.formData;
712
+ });
713
+ const setFormRef = (el) => {
714
+ var _a, _b;
715
+ return (_b = (_a = currentForm.value) == null ? void 0 : _a.setFormRef) == null ? void 0 : _b.call(_a, el);
716
+ };
717
+ let formInstanceCounter = 0;
718
+ const formInstanceKeyMap = /* @__PURE__ */ new WeakMap();
719
+ const getFormKey = (f) => {
720
+ if (!formInstanceKeyMap.has(f)) {
721
+ formInstanceKeyMap.set(f, ++formInstanceCounter);
722
+ }
723
+ return formInstanceKeyMap.get(f);
724
+ };
725
+ const formKey = computed(() => getFormKey(currentForm.value));
665
726
  const config = INJECT_CONFIG["pro-form"];
727
+ const injectFormConfig = inject(config.injectionKey, config.default);
666
728
  const attrs = useAttrs();
667
- const { grid: _injectGrid, ...injectAttrs } = inject(
668
- config.injectionKey,
669
- config.default
670
- );
729
+ const injectAttrs = computed(() => {
730
+ const raw = toValue(injectFormConfig);
731
+ const { grid: _injectGrid, ...rest } = raw || {};
732
+ return rest;
733
+ });
671
734
  const slots = useSlots();
672
- provide(InjectionFormSlotsKey, reactive(slots));
735
+ provide(InjectionFormSlotsKey, slots);
673
736
  return (_ctx, _cache) => {
674
737
  return openBlock(), createBlock(unref(ElForm), mergeProps({
675
- ref: (el) => {
676
- var _a;
677
- return (_a = unref(setFormRef)) == null ? void 0 : _a(el);
678
- },
679
- model: unref(formData)
680
- }, mergeProps(injectAttrs, unref(camelizeProperties)(unref(attrs))), {
738
+ key: formKey.value,
739
+ ref: setFormRef,
740
+ model: formData.value
741
+ }, mergeProps(injectAttrs.value, unref(camelizeProperties)(unref(attrs))), {
681
742
  class: "pro-form",
682
743
  onSubmit: _cache[0] || (_cache[0] = withModifiers(() => {
683
744
  }, ["prevent"]))
684
745
  }), {
685
746
  default: withCtx(() => [
686
747
  createVNode(unref(BaseFormItem), {
687
- fields: _fields.value,
688
- grid: __props.grid
748
+ fields: fields.value,
749
+ grid: props.grid
689
750
  }, null, 8, ["fields", "grid"]),
690
751
  renderSlot(_ctx.$slots, "default")
691
752
  ]),
@@ -720,7 +781,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
720
781
  ...{ name: "SearchForm" },
721
782
  __name: "SearchForm",
722
783
  props: {
723
- form: {},
784
+ form: { default: void 0 },
724
785
  layout: { default: "grid" },
725
786
  expand: { type: [Boolean, Object], default: true },
726
787
  searchButton: { type: [Object, Function, Boolean], default: void 0 },
@@ -734,6 +795,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
734
795
  emits: ["search", "reset"],
735
796
  setup(__props, { emit: __emit }) {
736
797
  const { t } = useLocale();
798
+ const props = __props;
737
799
  const emit = __emit;
738
800
  const proFormHeight = ref("unset");
739
801
  const collapseHeight = ref(0);
@@ -754,45 +816,45 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
754
816
  cleanupObservers();
755
817
  });
756
818
  const computedExpand = computed(() => {
757
- if (!__props.expand) return false;
758
- if (__props.expand === true) return { minExpandRows: 2, expandStatus: false };
819
+ if (!props.expand) return false;
820
+ if (props.expand === true) return { minExpandRows: 2, expandStatus: false };
759
821
  return {
760
- minExpandRows: Math.max(Math.floor(__props.expand.minExpandRows ?? 2), 1),
761
- expandStatus: __props.expand.expandStatus ?? false
822
+ minExpandRows: Math.max(Math.floor(props.expand.minExpandRows ?? 2), 1),
823
+ expandStatus: props.expand.expandStatus ?? false
762
824
  };
763
825
  });
764
826
  const showExpandToggle = ref(false);
765
827
  const expandStatus = ref(true);
766
- const { formRef, getFormData } = __props.form;
767
828
  const updateHeights = () => {
768
- var _a, _b, _c, _d, _e, _f;
769
- if (!__props.expand || !formRef.value) return;
770
- const proFormEl = (_a = formRef.value) == null ? void 0 : _a.$el;
829
+ var _a, _b, _c, _d, _e, _f, _g, _h;
830
+ if (!props.expand || !((_b = (_a = props.form) == null ? void 0 : _a.formRef) == null ? void 0 : _b.value)) return;
831
+ const proFormEl = (_c = props.form.formRef.value) == null ? void 0 : _c.$el;
771
832
  if (!proFormEl) return;
772
- const itemHeight = (_d = (_c = (_b = proFormEl == null ? void 0 : proFormEl.querySelector("[class*='-form-item']")) == null ? void 0 : _b.getBoundingClientRect) == null ? void 0 : _c.call(_b)) == null ? void 0 : _d.height;
833
+ const itemHeight = (_f = (_e = (_d = proFormEl == null ? void 0 : proFormEl.querySelector("[class*='-form-item']")) == null ? void 0 : _d.getBoundingClientRect) == null ? void 0 : _e.call(_d)) == null ? void 0 : _f.height;
773
834
  if (itemHeight && itemHeight > 0) {
774
835
  rowHeight.value = itemHeight;
775
836
  }
776
- const naturalHeight = proFormEl.scrollHeight || ((_f = (_e = proFormEl.getBoundingClientRect) == null ? void 0 : _e.call(proFormEl)) == null ? void 0 : _f.height) || 0;
837
+ const naturalHeight = proFormEl.scrollHeight || ((_h = (_g = proFormEl.getBoundingClientRect) == null ? void 0 : _g.call(proFormEl)) == null ? void 0 : _h.height) || 0;
777
838
  if (naturalHeight > 0) {
778
839
  proFormHeight.value = naturalHeight;
779
840
  }
780
841
  };
842
+ const isManualToggle = ref(false);
781
843
  const changeExpandStatus = () => {
844
+ isManualToggle.value = true;
782
845
  expandStatus.value = !expandStatus.value;
783
- nextTick(() => {
784
- updateHeights();
785
- });
786
846
  };
787
847
  const hasFieldValue = (val) => val !== null && val !== void 0 && val !== "" && !(Array.isArray(val) && val.length === 0) && !(typeof val === "object" && Object.keys(val).length === 0);
788
848
  const setInitExpandStatus = () => {
789
- var _a;
790
- expandStatus.value = false;
791
- if (formRef.value && __props.expand) {
792
- const formEl = formRef.value.$el;
793
- const formItemsEl = (_a = formEl == null ? void 0 : formEl.querySelectorAll) == null ? void 0 : _a.call(
849
+ var _a, _b, _c;
850
+ if (isManualToggle.value) return;
851
+ const initStatus = computedExpand.value ? computedExpand.value.expandStatus : false;
852
+ expandStatus.value = initStatus;
853
+ if (((_b = (_a = props.form) == null ? void 0 : _a.formRef) == null ? void 0 : _b.value) && computedExpand.value) {
854
+ const formEl = props.form.formRef.value.$el;
855
+ const formItemsEl = (_c = formEl == null ? void 0 : formEl.querySelectorAll) == null ? void 0 : _c.call(
794
856
  formEl,
795
- "[class*='-form-item'] > [path]"
857
+ "[class*='-form-item'] [path]"
796
858
  );
797
859
  if (!formItemsEl || formItemsEl.length === 0) return;
798
860
  if (intersectionObserver) {
@@ -800,13 +862,15 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
800
862
  }
801
863
  intersectionObserver = new IntersectionObserver(
802
864
  (entries) => {
865
+ if (isManualToggle.value) return;
803
866
  expandStatus.value = entries.some((e) => {
867
+ var _a2, _b2;
804
868
  if (e.intersectionRatio === 0) {
805
869
  const path = e.target.getAttribute("path");
806
- const searchFieldValue = path ? getFormData == null ? void 0 : getFormData(path) : void 0;
870
+ const searchFieldValue = path ? (_b2 = (_a2 = props.form) == null ? void 0 : _a2.getFormData) == null ? void 0 : _b2.call(_a2, path) : void 0;
807
871
  return hasFieldValue(searchFieldValue);
808
872
  }
809
- return __props.expand.expandStatus;
873
+ return computedExpand.value ? computedExpand.value.expandStatus : false;
810
874
  });
811
875
  intersectionObserver == null ? void 0 : intersectionObserver.disconnect();
812
876
  },
@@ -821,10 +885,13 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
821
885
  [
822
886
  () => {
823
887
  var _a, _b, _c;
824
- return (_c = (_b = (_a = __props.form) == null ? void 0 : _a.fields.value) == null ? void 0 : _b.filter((f) => !f.hidden)) == null ? void 0 : _c.length;
888
+ return (_c = (_b = (_a = props.form) == null ? void 0 : _a.fields.value) == null ? void 0 : _b.filter((f) => !f.hidden)) == null ? void 0 : _c.length;
825
889
  },
826
- () => formRef.value,
827
- () => __props.expand
890
+ () => {
891
+ var _a, _b;
892
+ return (_b = (_a = props.form) == null ? void 0 : _a.formRef) == null ? void 0 : _b.value;
893
+ },
894
+ () => props.expand
828
895
  ],
829
896
  () => {
830
897
  updateHeights();
@@ -832,7 +899,10 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
832
899
  { flush: "post", immediate: true }
833
900
  );
834
901
  watch(
835
- () => formRef.value,
902
+ () => {
903
+ var _a, _b;
904
+ return (_b = (_a = props.form) == null ? void 0 : _a.formRef) == null ? void 0 : _b.value;
905
+ },
836
906
  (val) => {
837
907
  if (resizeObserver) {
838
908
  resizeObserver.disconnect();
@@ -851,10 +921,10 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
851
921
  watchEffect(
852
922
  () => {
853
923
  if (typeof proFormHeight.value !== "number") return;
854
- if (__props.layout === "grid" && computedExpand.value) {
924
+ if (props.layout === "grid" && computedExpand.value) {
855
925
  const { minExpandRows } = computedExpand.value;
856
926
  collapseHeight.value = Math.min(
857
- minExpandRows * rowHeight.value + (minExpandRows - 1) * __props.rowGap,
927
+ minExpandRows * rowHeight.value + (minExpandRows - 1) * props.rowGap,
858
928
  +proFormHeight.value
859
929
  );
860
930
  showExpandToggle.value = +proFormHeight.value - collapseHeight.value > 1;
@@ -867,28 +937,30 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
867
937
  },
868
938
  { flush: "post" }
869
939
  );
870
- const layoutProps = computed(
871
- () => __props.layout === "grid" ? {
940
+ const layoutProps = computed(() => {
941
+ const currentHeight = expandStatus.value ? proFormHeight.value : collapseHeight.value;
942
+ const heightStyle = currentHeight !== "unset" && currentHeight !== void 0 ? `${currentHeight}px` : void 0;
943
+ return props.layout === "grid" ? {
872
944
  grid: {
873
- gutter: __props.columnGap,
874
- style: { rowGap: `${__props.rowGap}px` }
945
+ gutter: props.columnGap,
946
+ style: { rowGap: `${props.rowGap}px` }
875
947
  },
876
948
  style: {
877
949
  display: "flex",
878
950
  overflow: "hidden",
879
- columnGap: `${__props.columnGap}px`,
880
- height: `${expandStatus.value ? proFormHeight.value : collapseHeight.value}px`
951
+ columnGap: `${props.columnGap}px`,
952
+ height: heightStyle
881
953
  }
882
954
  } : {
883
955
  inline: true,
884
956
  style: {
885
957
  display: "flex",
886
958
  flexWrap: "wrap",
887
- gap: `${__props.rowGap}px ${__props.columnGap}px`
959
+ gap: `${props.rowGap}px ${props.columnGap}px`
888
960
  },
889
961
  grid: false
890
- }
891
- );
962
+ };
963
+ });
892
964
  const onReset = () => {
893
965
  emit("reset");
894
966
  };
@@ -897,9 +969,8 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
897
969
  };
898
970
  return (_ctx, _cache) => {
899
971
  return openBlock(), createBlock(unref(_sfc_main$b), mergeProps(layoutProps.value, {
900
- form: __props.form,
901
- class: "pro-table_search-form transition",
902
- onKeyup: withKeys(onSearch, ["enter"])
972
+ form: props.form,
973
+ class: "pro-table_search-form transition"
903
974
  }), {
904
975
  default: withCtx(() => [
905
976
  createVNode(unref(ElSpace), {
@@ -907,9 +978,9 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
907
978
  class: "pro-table_search-form_button-group"
908
979
  }, {
909
980
  default: withCtx(() => [
910
- renderSlot(_ctx.$slots, "reset-button", { onClick: onReset }, () => [
911
- __props.resetButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
912
- __props.resetButton ? (openBlock(), createBlock(resolveDynamicComponent(__props.resetButton), {
981
+ renderSlot(_ctx.$slots, "reset-button", { onReset }, () => [
982
+ props.resetButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
983
+ props.resetButton ? (openBlock(), createBlock(resolveDynamicComponent(props.resetButton), {
913
984
  key: 0,
914
985
  onClick: onReset
915
986
  })) : (openBlock(), createBlock(unref(ElButton), {
@@ -924,9 +995,9 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
924
995
  }))
925
996
  ], 64)) : createCommentVNode("", true)
926
997
  ], true),
927
- renderSlot(_ctx.$slots, "search-button", { onClick: onSearch }, () => [
928
- __props.searchButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
929
- __props.searchButton ? (openBlock(), createBlock(resolveDynamicComponent(__props.searchButton), {
998
+ renderSlot(_ctx.$slots, "search-button", { onSearch }, () => [
999
+ props.searchButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
1000
+ props.searchButton ? (openBlock(), createBlock(resolveDynamicComponent(props.searchButton), {
930
1001
  key: 0,
931
1002
  onClick: onSearch
932
1003
  })) : (openBlock(), createBlock(unref(ElButton), {
@@ -943,9 +1014,12 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
943
1014
  }))
944
1015
  ], 64)) : createCommentVNode("", true)
945
1016
  ], true),
946
- renderSlot(_ctx.$slots, "expand-button", { onClick: changeExpandStatus }, () => [
947
- __props.expandButton !== false && showExpandToggle.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
948
- __props.expandButton ? (openBlock(), createBlock(resolveDynamicComponent(__props.expandButton), {
1017
+ renderSlot(_ctx.$slots, "expand-button", {
1018
+ expandStatus: expandStatus.value,
1019
+ changeExpandStatus
1020
+ }, () => [
1021
+ props.expandButton !== false && showExpandToggle.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
1022
+ props.expandButton ? (openBlock(), createBlock(resolveDynamicComponent(props.expandButton), {
949
1023
  key: 0,
950
1024
  "expand-status": expandStatus.value,
951
1025
  onClick: changeExpandStatus
@@ -975,7 +1049,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
975
1049
  };
976
1050
  }
977
1051
  });
978
- const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-20c91e48"]]);
1052
+ const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-54c7c01c"]]);
979
1053
  const _sfc_main$8 = {};
980
1054
  const _hoisted_1$4 = { class: "pro-table_search-form-container" };
981
1055
  function _sfc_render$3(_ctx, _cache) {
@@ -1018,7 +1092,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1018
1092
  setup(__props) {
1019
1093
  const { t } = useLocale();
1020
1094
  const size = useModel(__props, "size");
1021
- size.value = size.value ?? "default";
1095
+ const currentSize = computed(() => size.value ?? "default");
1022
1096
  const items = computed(() => [
1023
1097
  { label: t("table.sizeDefault"), key: "default" },
1024
1098
  { label: t("table.sizeMiddle"), key: "large" },
@@ -1036,7 +1110,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1036
1110
  return openBlock(), createBlock(unref(ElDropdownItem), {
1037
1111
  key: item.key,
1038
1112
  command: item.key,
1039
- disabled: item.key === size.value
1113
+ disabled: item.key === currentSize.value
1040
1114
  }, {
1041
1115
  default: withCtx(() => [
1042
1116
  createTextVNode(toDisplayString(item.label), 1)
@@ -1064,7 +1138,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1064
1138
  };
1065
1139
  }
1066
1140
  });
1067
- const SizeControl = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-b114045c"]]);
1141
+ const SizeControl = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-e31e9c15"]]);
1068
1142
  const _sfc_main$4 = {};
1069
1143
  const _hoisted_1$1 = {
1070
1144
  focusable: "false",
@@ -1085,27 +1159,27 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1085
1159
  __name: "ColumnControl",
1086
1160
  props: {
1087
1161
  columns: {},
1088
- table: { default: () => void 0 },
1089
- columnControl: { default: () => void 0 }
1162
+ table: { default: void 0 },
1163
+ columnControl: { default: void 0 }
1090
1164
  },
1091
1165
  setup(__props) {
1166
+ const props = __props;
1092
1167
  const { t } = useLocale();
1093
- const open = ref(false);
1094
1168
  const checkAll = ref(false);
1095
1169
  const indeterminate = ref(false);
1096
1170
  const getColumnKey = (column, index2) => {
1097
- const key = column.key ?? column.prop;
1098
- if (key === void 0 || key === null) return `__col_${index2}`;
1099
- return Array.isArray(key) ? key.join(".") : String(key);
1171
+ const rawKey = column.key ?? column.prop;
1172
+ if (rawKey === void 0 || rawKey === null) return `__col_${index2}`;
1173
+ return normalizePathKey(rawKey);
1100
1174
  };
1101
1175
  const checkedColumnsOptions = computed(
1102
- () => __props.columns.map((item, index2) => {
1176
+ () => props.columns.map((item, index2) => {
1103
1177
  var _a, _b, _c, _d;
1104
1178
  const key = getColumnKey(item, index2);
1105
- const excluded = (_b = (_a = __props.columnControl) == null ? void 0 : _a.excludedKeys) == null ? void 0 : _b.some(
1179
+ const excluded = (_b = (_a = props.columnControl) == null ? void 0 : _a.excludedKeys) == null ? void 0 : _b.some(
1106
1180
  (ek) => String(ek) === key
1107
1181
  );
1108
- const disabled = (_d = (_c = __props.columnControl) == null ? void 0 : _c.disabledKeys) == null ? void 0 : _d.some(
1182
+ const disabled = (_d = (_c = props.columnControl) == null ? void 0 : _c.disabledKeys) == null ? void 0 : _d.some(
1109
1183
  (dk) => String(dk) === key
1110
1184
  );
1111
1185
  const label = String(
@@ -1134,7 +1208,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1134
1208
  checkedColumnsOptions.value.forEach((item) => {
1135
1209
  var _a;
1136
1210
  if (item.disabled) return;
1137
- (_a = __props.table) == null ? void 0 : _a.setColumn(item.value, {
1211
+ (_a = props.table) == null ? void 0 : _a.setColumn(item.value, {
1138
1212
  hidden: !val.includes(item.value)
1139
1213
  });
1140
1214
  });
@@ -1170,20 +1244,20 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1170
1244
  );
1171
1245
  onMounted(() => {
1172
1246
  var _a, _b;
1173
- (_b = (_a = __props.columnControl) == null ? void 0 : _a.disabledKeys) == null ? void 0 : _b.forEach((key) => {
1247
+ (_b = (_a = props.columnControl) == null ? void 0 : _a.disabledKeys) == null ? void 0 : _b.forEach((key) => {
1174
1248
  var _a2;
1175
- (_a2 = __props.table) == null ? void 0 : _a2.setColumn(String(key), { hidden: false });
1249
+ (_a2 = props.table) == null ? void 0 : _a2.setColumn(String(key), { hidden: false });
1176
1250
  });
1177
1251
  });
1178
1252
  watch(
1179
1253
  () => {
1180
1254
  var _a;
1181
- return (_a = __props.columnControl) == null ? void 0 : _a.disabledKeys;
1255
+ return (_a = props.columnControl) == null ? void 0 : _a.disabledKeys;
1182
1256
  },
1183
1257
  (keys) => {
1184
1258
  keys == null ? void 0 : keys.forEach((key) => {
1185
1259
  var _a;
1186
- (_a = __props.table) == null ? void 0 : _a.setColumn(String(key), { hidden: false });
1260
+ (_a = props.table) == null ? void 0 : _a.setColumn(String(key), { hidden: false });
1187
1261
  });
1188
1262
  },
1189
1263
  { deep: true }
@@ -1191,16 +1265,14 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1191
1265
  return (_ctx, _cache) => {
1192
1266
  return openBlock(), createBlock(unref(ElDropdown), {
1193
1267
  trigger: "click",
1194
- "hide-on-click": false,
1195
- visible: open.value,
1196
- onVisibleChange: _cache[0] || (_cache[0] = (val) => open.value = val)
1268
+ "hide-on-click": false
1197
1269
  }, {
1198
1270
  dropdown: withCtx(() => [
1199
1271
  createVNode(unref(ElDropdownMenu), null, {
1200
1272
  default: withCtx(() => {
1201
1273
  var _a;
1202
1274
  return [
1203
- !((_a = __props.columnControl) == null ? void 0 : _a.disableCheckAll) ? (openBlock(), createBlock(unref(ElDropdownItem), {
1275
+ !((_a = props.columnControl) == null ? void 0 : _a.disableCheckAll) ? (openBlock(), createBlock(unref(ElDropdownItem), {
1204
1276
  key: 0,
1205
1277
  disabled: true,
1206
1278
  divided: false
@@ -1256,39 +1328,41 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1256
1328
  })
1257
1329
  ]),
1258
1330
  _: 1
1259
- }, 8, ["visible"]);
1331
+ });
1260
1332
  };
1261
1333
  }
1262
1334
  });
1263
- const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-97c582f9"]]);
1335
+ const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-f98ee06d"]]);
1264
1336
  const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1265
1337
  ...{ name: "TableColumnRenderer" },
1266
1338
  __name: "TableColumnRenderer",
1267
1339
  props: {
1268
- columns: {}
1340
+ columns: { default: () => [] }
1269
1341
  },
1270
1342
  setup(__props) {
1343
+ const props = __props;
1271
1344
  const getColumnKey = (column, index2) => {
1272
- const key = column.key ?? column.prop;
1273
- if (key === void 0 || key === null) return `__col_${index2}`;
1274
- return Array.isArray(key) ? key.join(".") : String(key);
1345
+ const rawKey = column.key ?? column.prop;
1346
+ if (rawKey === void 0 || rawKey === null) return `__col_${index2}`;
1347
+ return normalizePathKey(rawKey);
1275
1348
  };
1276
1349
  const getCellValue = (row, column) => {
1277
1350
  const path = column.prop;
1278
1351
  if (!path) return void 0;
1279
- return get(row, toPath(path));
1352
+ return get(row, path);
1280
1353
  };
1281
1354
  const normalizedColumns = computed(() => {
1282
- return __props.columns.filter((column) => !column.hidden);
1355
+ return props.columns.filter((column) => !column.hidden);
1283
1356
  });
1284
1357
  const getColumnProps = (column) => {
1285
1358
  const { hidden, render, key, children, ...rest } = column;
1286
- const prop = column.prop ? String(column.prop) : void 0;
1359
+ const prop = column.prop ? normalizePathKey(column.prop) : void 0;
1360
+ const columnKey = key ? normalizePathKey(key) : prop;
1287
1361
  return {
1288
1362
  ...rest,
1289
1363
  label: column.label ?? column.title,
1290
1364
  prop,
1291
- columnKey: key ? String(key) : prop
1365
+ columnKey
1292
1366
  };
1293
1367
  };
1294
1368
  return (_ctx, _cache) => {
@@ -1351,19 +1425,25 @@ const _hoisted_5 = {
1351
1425
  class: "pro-table_header_column-control"
1352
1426
  };
1353
1427
  const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1354
- ...{ name: "ProTable", inheritAttrs: false },
1428
+ ...{
1429
+ name: "ProTable",
1430
+ directives: {
1431
+ loading: ElLoading.directive
1432
+ },
1433
+ inheritAttrs: false
1434
+ },
1355
1435
  __name: "ProTable",
1356
1436
  props: /* @__PURE__ */ mergeModels({
1357
- table: { default: () => void 0 },
1437
+ table: { default: void 0 },
1358
1438
  search: { type: Function, default: void 0 },
1359
- addIndexColumn: { type: Boolean, default: () => void 0 },
1360
- immediateSearch: { type: Boolean, default: () => void 0 },
1361
- control: { type: [Boolean, Object], default: () => void 0 },
1362
- searchFormConfig: { default: () => void 0 },
1439
+ addIndexColumn: { type: Boolean, default: void 0 },
1440
+ immediateSearch: { type: Boolean, default: void 0 },
1441
+ control: { type: [Boolean, Object], default: void 0 },
1442
+ searchFormConfig: { default: void 0 },
1363
1443
  tableContainer: { type: [Object, Function, Boolean], default: void 0 },
1364
- columns: { default: () => void 0 },
1365
- data: { default: () => void 0 },
1366
- pagination: { type: [Boolean, Object], default: () => void 0 },
1444
+ columns: { default: void 0 },
1445
+ data: { default: void 0 },
1446
+ pagination: { type: [Boolean, Object], default: void 0 },
1367
1447
  size: {},
1368
1448
  width: {},
1369
1449
  height: {},
@@ -1371,61 +1451,63 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1371
1451
  fit: { type: Boolean },
1372
1452
  stripe: { type: Boolean },
1373
1453
  border: { type: Boolean },
1374
- rowKey: { type: [String, Function] },
1454
+ rowKey: {},
1375
1455
  context: {},
1376
1456
  showHeader: { type: Boolean },
1377
1457
  showSummary: { type: Boolean },
1378
1458
  sumText: {},
1379
- summaryMethod: { type: Function },
1380
- rowClassName: { type: [String, Function] },
1381
- rowStyle: { type: [Object, Function] },
1382
- cellClassName: { type: [String, Function] },
1383
- cellStyle: { type: [Object, Function] },
1384
- headerRowClassName: { type: [String, Function] },
1385
- headerRowStyle: { type: [Object, Function] },
1386
- headerCellClassName: { type: [String, Function] },
1387
- headerCellStyle: { type: [Object, Function] },
1459
+ summaryMethod: {},
1460
+ rowClassName: {},
1461
+ rowStyle: {},
1462
+ cellClassName: {},
1463
+ cellStyle: {},
1464
+ headerRowClassName: {},
1465
+ headerRowStyle: {},
1466
+ headerCellClassName: {},
1467
+ headerCellStyle: {},
1388
1468
  highlightCurrentRow: { type: Boolean },
1389
1469
  currentRowKey: {},
1390
1470
  emptyText: {},
1391
1471
  expandRowKeys: {},
1392
1472
  defaultExpandAll: { type: Boolean },
1393
- rowExpandable: { type: Function },
1473
+ rowExpandable: {},
1394
1474
  defaultSort: {},
1395
1475
  tooltipEffect: {},
1396
1476
  tooltipOptions: {},
1397
- spanMethod: { type: Function },
1477
+ spanMethod: {},
1398
1478
  selectOnIndeterminate: { type: Boolean },
1399
1479
  indent: {},
1400
1480
  treeProps: {},
1401
1481
  lazy: { type: Boolean },
1402
- load: { type: Function },
1482
+ load: {},
1403
1483
  className: {},
1404
1484
  style: { type: [Boolean, null, String, Object, Array] },
1405
1485
  tableLayout: {},
1406
1486
  scrollbarAlwaysOn: { type: Boolean },
1407
1487
  flexible: { type: Boolean },
1408
1488
  showOverflowTooltip: { type: [Boolean, Object] },
1409
- tooltipFormatter: { type: Function },
1489
+ tooltipFormatter: {},
1410
1490
  appendFilterPanelTo: {},
1411
1491
  scrollbarTabindex: {},
1412
1492
  nativeScrollbar: { type: Boolean }
1413
1493
  }, {
1414
1494
  "size": {},
1415
1495
  "sizeModifiers": {},
1416
- "loading": { type: Boolean },
1496
+ "loading": { type: Boolean, ...{ default: false } },
1417
1497
  "loadingModifiers": {}
1418
1498
  }),
1419
1499
  emits: ["update:size", "update:loading"],
1420
1500
  setup(__props) {
1501
+ const props = __props;
1421
1502
  const { t } = useLocale();
1422
1503
  const config = INJECT_CONFIG["pro-table"];
1423
- const injectProps = inject(config.injectionKey, config.default);
1504
+ const injectPropsRaw = inject(config.injectionKey, config.default);
1505
+ const injectProps = computed(() => toValue(injectPropsRaw) || {});
1424
1506
  const tableProperties = Object.keys(tableProps());
1425
1507
  const paginationProperties = Object.keys(paginationProps());
1426
1508
  const attrs = useAttrs();
1427
1509
  const injectTableAttrs = computed(() => {
1428
- return pick(injectProps, tableProperties);
1510
+ return pick(injectProps.value, tableProperties);
1429
1511
  });
1430
1512
  const attrsTableProps = computed(() => {
1431
1513
  return pick(
@@ -1433,27 +1515,23 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1433
1515
  tableProperties
1434
1516
  );
1435
1517
  });
1436
- const {
1437
- columns: tableColumns,
1438
- data: tableData,
1439
- searchForm,
1440
- pageParam,
1441
- setPageParam
1442
- } = __props.table || {};
1443
1518
  const size = useModel(__props, "size");
1444
1519
  const loading = useModel(__props, "loading");
1445
1520
  const _search = async () => {
1446
1521
  var _a;
1447
- try {
1522
+ const searchPromise = (_a = props.search || attrs.onSearch) == null ? void 0 : _a();
1523
+ if (isPromise(searchPromise)) {
1448
1524
  loading.value = true;
1449
- await ((_a = __props.search) == null ? void 0 : _a.call(__props));
1450
- } finally {
1451
- loading.value = false;
1525
+ try {
1526
+ await searchPromise;
1527
+ } finally {
1528
+ loading.value = false;
1529
+ }
1452
1530
  }
1453
1531
  };
1454
1532
  const reset = () => {
1455
- var _a;
1456
- (_a = __props.table) == null ? void 0 : _a.resetQueryParams();
1533
+ var _a, _b;
1534
+ (_b = (_a = props.table) == null ? void 0 : _a.resetQueryParams) == null ? void 0 : _b.call(_a);
1457
1535
  nextTick(() => {
1458
1536
  _search();
1459
1537
  });
@@ -1475,31 +1553,43 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1475
1553
  });
1476
1554
  const tableSlotNames = computed(() => Object.keys(tableSlots.value));
1477
1555
  const searchPage1st = () => {
1478
- setPageParam == null ? void 0 : setPageParam({ current: 1 });
1556
+ var _a, _b;
1557
+ (_b = (_a = props.table) == null ? void 0 : _a.setPageParam) == null ? void 0 : _b.call(_a, { current: 1 });
1479
1558
  _search();
1480
1559
  };
1481
1560
  const computedSearchFormConfig = computed(() => {
1482
1561
  var _a, _b;
1483
- const container = ((_a = __props.searchFormConfig) == null ? void 0 : _a.container) ?? ((_b = injectProps.searchFormConfig) == null ? void 0 : _b.container) ?? DefaultSearchFormContainer;
1562
+ const container = ((_a = props.searchFormConfig) == null ? void 0 : _a.container) ?? ((_b = injectProps.value.searchFormConfig) == null ? void 0 : _b.container) ?? DefaultSearchFormContainer;
1484
1563
  return {
1485
- ...injectProps.searchFormConfig,
1486
- ...getObject(__props.searchFormConfig),
1564
+ ...injectProps.value.searchFormConfig,
1565
+ ...getObject(props.searchFormConfig),
1487
1566
  container: container ? container : void 0
1488
1567
  };
1489
1568
  });
1490
1569
  const computedTableContainer = computed(() => {
1491
- const container = __props.tableContainer ?? injectProps.tableContainer ?? DefaultTableContainer;
1570
+ const container = props.tableContainer ?? injectProps.value.tableContainer ?? DefaultTableContainer;
1492
1571
  return container ? container : void 0;
1493
1572
  });
1573
+ const getIndex = (i) => {
1574
+ var _a;
1575
+ if (((_a = props.table) == null ? void 0 : _a.pageParam) && computedPagination.value !== false) {
1576
+ const current = props.table.pageParam.current ?? 1;
1577
+ const pageSize = props.table.pageParam.pageSize ?? 10;
1578
+ return (current - 1) * pageSize + i + 1;
1579
+ }
1580
+ return i + 1;
1581
+ };
1494
1582
  const normalizedRawColumns = computed(() => {
1495
- const source = __props.columns ?? (tableColumns == null ? void 0 : tableColumns.value) ?? [];
1496
- if (__props.addIndexColumn ?? injectProps.addIndexColumn) {
1583
+ var _a;
1584
+ const source = props.columns ?? toValue((_a = props.table) == null ? void 0 : _a.columns) ?? [];
1585
+ if (props.addIndexColumn ?? injectProps.value.addIndexColumn) {
1497
1586
  return [
1498
1587
  {
1499
1588
  key: "_index",
1500
1589
  type: "index",
1501
1590
  label: t("table.index"),
1502
- width: 80
1591
+ width: 80,
1592
+ index: getIndex
1503
1593
  },
1504
1594
  ...source
1505
1595
  ];
@@ -1507,8 +1597,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1507
1597
  return source;
1508
1598
  });
1509
1599
  const computedDataSource = computed(() => {
1600
+ var _a, _b;
1510
1601
  const attrsData = attrsTableProps.value.data;
1511
- return __props.data ?? attrsData ?? (tableData == null ? void 0 : tableData.value) ?? [];
1602
+ return props.data ?? attrsData ?? toValue((_a = props.table) == null ? void 0 : _a.dataSource) ?? toValue((_b = props.table) == null ? void 0 : _b.data) ?? [];
1512
1603
  });
1513
1604
  const computedTableProps = computed(() => {
1514
1605
  const merged = {
@@ -1519,23 +1610,42 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1519
1610
  return merged;
1520
1611
  });
1521
1612
  const computedPagination = computed(() => {
1522
- if (__props.pagination === false) return false;
1523
- const pageConfig = __props.pagination ?? {};
1613
+ var _a, _b;
1614
+ const attrsPagination = attrsTableProps.value.pagination;
1615
+ if (props.pagination === false || attrsPagination === false) {
1616
+ return false;
1617
+ }
1618
+ const hasUserPagination = isPlainObject(props.pagination) || isPlainObject(attrsPagination);
1619
+ if (hasUserPagination) {
1620
+ const pageConfig = props.pagination ?? attrsPagination ?? {};
1621
+ const globalPagination = injectProps.value.pagination === false ? {} : injectProps.value.pagination || {};
1622
+ const pageParam2 = (_a = props.table) == null ? void 0 : _a.pageParam;
1623
+ return {
1624
+ ...globalPagination,
1625
+ ...pick(pageConfig, paginationProperties),
1626
+ currentPage: (pageParam2 == null ? void 0 : pageParam2.current) ?? pageConfig.currentPage ?? 1,
1627
+ pageSize: (pageParam2 == null ? void 0 : pageParam2.pageSize) ?? pageConfig.pageSize ?? 10,
1628
+ total: (pageParam2 == null ? void 0 : pageParam2.total) ?? pageConfig.total ?? 0
1629
+ };
1630
+ }
1631
+ if (injectProps.value.pagination === false) return false;
1632
+ const pageParam = (_b = props.table) == null ? void 0 : _b.pageParam;
1524
1633
  return {
1525
- ...injectProps.pagination,
1526
- ...pick(pageConfig, paginationProperties),
1527
- currentPage: pageConfig.currentPage ?? (pageParam == null ? void 0 : pageParam.current) ?? 1,
1528
- pageSize: pageConfig.pageSize ?? (pageParam == null ? void 0 : pageParam.pageSize) ?? 10,
1529
- total: pageConfig.total ?? (pageParam == null ? void 0 : pageParam.total) ?? 0
1634
+ ...injectProps.value.pagination,
1635
+ currentPage: (pageParam == null ? void 0 : pageParam.current) ?? 1,
1636
+ pageSize: (pageParam == null ? void 0 : pageParam.pageSize) ?? 10,
1637
+ total: (pageParam == null ? void 0 : pageParam.total) ?? 0
1530
1638
  };
1531
1639
  });
1532
1640
  const showPagination = computed(() => computedPagination.value !== false);
1533
1641
  const onCurrentChange = (current) => {
1534
- setPageParam == null ? void 0 : setPageParam({ current });
1642
+ var _a, _b;
1643
+ (_b = (_a = props.table) == null ? void 0 : _a.setPageParam) == null ? void 0 : _b.call(_a, { current });
1535
1644
  _search();
1536
1645
  };
1537
1646
  const onSizeChange = (pageSize) => {
1538
- setPageParam == null ? void 0 : setPageParam({ pageSize, current: 1 });
1647
+ var _a, _b;
1648
+ (_b = (_a = props.table) == null ? void 0 : _a.setPageParam) == null ? void 0 : _b.call(_a, { pageSize, current: 1 });
1539
1649
  _search();
1540
1650
  };
1541
1651
  const onPaginationChange = (currentPage, pageSize) => {
@@ -1543,17 +1653,19 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1543
1653
  (_a = attrs.onChange) == null ? void 0 : _a.call(attrs, currentPage, pageSize);
1544
1654
  };
1545
1655
  const showSearch = computed(() => {
1546
- var _a, _b;
1547
- return !!(searchFormSlot || ((_a = computedSearchFormConfig.value) == null ? void 0 : _a.hidden) !== true && searchForm && ((_b = searchForm.fields.value.filter((item) => !item.hidden)) == null ? void 0 : _b.length) > 0);
1656
+ var _a, _b, _c, _d, _e;
1657
+ const searchFields = (_b = (_a = props.table) == null ? void 0 : _a.searchForm) == null ? void 0 : _b.fields;
1658
+ const fieldList = (Array.isArray(searchFields) ? searchFields : searchFields == null ? void 0 : searchFields.value) ?? [];
1659
+ return !!(searchFormSlot || ((_c = computedSearchFormConfig.value) == null ? void 0 : _c.hidden) !== true && ((_d = props.table) == null ? void 0 : _d.searchForm) && ((_e = fieldList.filter((item) => !item.hidden)) == null ? void 0 : _e.length) > 0);
1548
1660
  });
1549
1661
  const computedControl = computed(() => {
1550
- const mergedControl = __props.control ?? injectProps.control;
1662
+ const mergedControl = props.control ?? injectProps.value.control;
1551
1663
  if (typeof mergedControl === "boolean") {
1552
1664
  return { sizeControl: mergedControl, columnControl: mergedControl };
1553
1665
  }
1554
1666
  const c = mergedControl;
1555
- const sizeControl = c.sizeControl ?? true;
1556
- const columnControl = c.columnControl ?? true;
1667
+ const sizeControl = (c == null ? void 0 : c.sizeControl) ?? false;
1668
+ const columnControl = (c == null ? void 0 : c.columnControl) ?? false;
1557
1669
  return { sizeControl: !!sizeControl, columnControl };
1558
1670
  });
1559
1671
  const columnControlConfig = computed(() => {
@@ -1564,7 +1676,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1564
1676
  return size.value ?? attrsTableProps.value.size ?? injectTableAttrs.value.size;
1565
1677
  });
1566
1678
  onMounted(() => {
1567
- if (__props.immediateSearch ?? injectProps.immediateSearch) {
1679
+ if (props.immediateSearch ?? injectProps.value.immediateSearch) {
1568
1680
  _search();
1569
1681
  }
1570
1682
  });
@@ -1579,15 +1691,18 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1579
1691
  component: computedSearchFormConfig.value.container
1580
1692
  }, {
1581
1693
  default: withCtx(() => [
1582
- renderSlot(_ctx.$slots, "search-form", {}, () => [
1583
- unref(searchForm) ? (openBlock(), createBlock(SearchForm, mergeProps({
1584
- key: 0,
1585
- form: unref(searchForm)
1586
- }, computedSearchFormConfig.value, {
1587
- onSearch: searchPage1st,
1588
- onReset: reset
1589
- }), null, 16, ["form"])) : createCommentVNode("", true)
1590
- ], true)
1694
+ renderSlot(_ctx.$slots, "search-form", {}, () => {
1695
+ var _a;
1696
+ return [
1697
+ ((_a = props.table) == null ? void 0 : _a.searchForm) ? (openBlock(), createBlock(SearchForm, mergeProps({
1698
+ key: 0,
1699
+ form: props.table.searchForm
1700
+ }, computedSearchFormConfig.value, {
1701
+ onSearch: searchPage1st,
1702
+ onReset: reset
1703
+ }), null, 16, ["form"])) : createCommentVNode("", true)
1704
+ ];
1705
+ }, true)
1591
1706
  ]),
1592
1707
  _: 3
1593
1708
  }, 8, ["component"])) : createCommentVNode("", true),
@@ -1609,7 +1724,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1609
1724
  computedControl.value.columnControl ? (openBlock(), createElementBlock("div", _hoisted_5, [
1610
1725
  createVNode(unref(ColumnControl), {
1611
1726
  columns: normalizedRawColumns.value.filter((item) => item.key !== "_index"),
1612
- table: __props.table,
1727
+ table: props.table,
1613
1728
  "column-control": columnControlConfig.value
1614
1729
  }, null, 8, ["columns", "table", "column-control"])
1615
1730
  ])) : createCommentVNode("", true)
@@ -1651,7 +1766,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1651
1766
  };
1652
1767
  }
1653
1768
  });
1654
- const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-127db81d"]]);
1769
+ const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-e1546aaf"]]);
1655
1770
  function useTable(params = {}) {
1656
1771
  const { data, columns, ...rest } = params;
1657
1772
  const coreTable = useTable$1({
@@ -1673,16 +1788,42 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1673
1788
  },
1674
1789
  __name: "index",
1675
1790
  props: {
1676
- componentVars: {},
1677
- componentMap: {},
1678
- locale: {}
1791
+ componentVars: { default: void 0 },
1792
+ componentMap: { default: void 0 },
1793
+ locale: { default: void 0 }
1679
1794
  },
1680
1795
  setup(__props) {
1681
1796
  const props = __props;
1797
+ Object.keys(INJECT_CONFIG).forEach(
1798
+ (key) => {
1799
+ const config = INJECT_CONFIG[key];
1800
+ provide(
1801
+ config.injectionKey,
1802
+ computed(() => {
1803
+ var _a;
1804
+ return {
1805
+ ...config.default,
1806
+ ...getObject((_a = props.componentVars) == null ? void 0 : _a[key])
1807
+ };
1808
+ })
1809
+ );
1810
+ }
1811
+ );
1682
1812
  if (props.componentVars) {
1683
- Object.entries(props.componentVars).forEach(([key, val]) => {
1684
- const config = ensureInjectConfig(key);
1685
- provide(config.injectionKey, { ...config.default, ...getObject(val) });
1813
+ Object.keys(props.componentVars).forEach((key) => {
1814
+ if (!(key in INJECT_CONFIG)) {
1815
+ const config = ensureInjectConfig(key);
1816
+ provide(
1817
+ config.injectionKey,
1818
+ computed(() => {
1819
+ var _a;
1820
+ return {
1821
+ ...config.default,
1822
+ ...getObject((_a = props.componentVars) == null ? void 0 : _a[key])
1823
+ };
1824
+ })
1825
+ );
1826
+ }
1686
1827
  });
1687
1828
  }
1688
1829
  if (props.componentMap) {