@qin-ui/element-plus-pro 1.2.4 → 1.3.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.
Files changed (179) hide show
  1. package/AI-CONTEXT.md +1 -1
  2. package/README.md +5 -5
  3. package/api.json +1 -25
  4. package/es/__tests__/BaseField.spec.d.ts +2 -0
  5. package/es/__tests__/BaseField.spec.d.ts.map +1 -0
  6. package/es/__tests__/BaseFormItem.spec.d.ts +2 -0
  7. package/es/__tests__/BaseFormItem.spec.d.ts.map +1 -0
  8. package/es/__tests__/ProForm.spec.d.ts +2 -0
  9. package/es/__tests__/ProForm.spec.d.ts.map +1 -0
  10. package/es/__tests__/ProTable.spec.d.ts +2 -0
  11. package/es/__tests__/ProTable.spec.d.ts.map +1 -0
  12. package/es/__tests__/SearchForm.spec.d.ts +2 -0
  13. package/es/__tests__/SearchForm.spec.d.ts.map +1 -0
  14. package/es/__tests__/controls.spec.d.ts +2 -0
  15. package/es/__tests__/controls.spec.d.ts.map +1 -0
  16. package/es/__tests__/cross-package.spec.d.ts +2 -0
  17. package/es/__tests__/cross-package.spec.d.ts.map +1 -0
  18. package/es/__tests__/helpers/fixtures.d.ts +15 -0
  19. package/es/__tests__/helpers/fixtures.d.ts.map +1 -0
  20. package/es/__tests__/helpers/mount.d.ts +38 -0
  21. package/es/__tests__/helpers/mount.d.ts.map +1 -0
  22. package/es/__tests__/hooks-locale.spec.d.ts +2 -0
  23. package/es/__tests__/hooks-locale.spec.d.ts.map +1 -0
  24. package/es/__tests__/index.spec.d.ts +2 -0
  25. package/es/__tests__/index.spec.d.ts.map +1 -0
  26. package/es/__tests__/integration.spec.d.ts +2 -0
  27. package/es/__tests__/integration.spec.d.ts.map +1 -0
  28. package/es/__tests__/setup.d.ts +14 -0
  29. package/es/__tests__/setup.d.ts.map +1 -0
  30. package/es/element-plus-pro.css +14 -14
  31. package/es/index.js +425 -434
  32. package/es/index.js.map +1 -1
  33. package/es/{components → src/components}/component-provider/components/index.vue.d.ts +5 -1
  34. package/es/src/components/component-provider/components/index.vue.d.ts.map +1 -0
  35. package/es/{components → src/components}/component-provider/constants/index.d.ts +2 -2
  36. package/es/src/components/component-provider/constants/index.d.ts.map +1 -0
  37. package/es/src/components/component-provider/index.d.ts.map +1 -0
  38. package/es/{components → src/components}/component-provider/types/index.d.ts +9 -5
  39. package/es/src/components/component-provider/types/index.d.ts.map +1 -0
  40. package/es/{components → src/components}/form/components/BaseField/index.vue.d.ts +4 -1
  41. package/es/src/components/form/components/BaseField/index.vue.d.ts.map +1 -0
  42. package/es/src/components/form/components/BaseField/utils/index.d.ts +6 -0
  43. package/es/src/components/form/components/BaseField/utils/index.d.ts.map +1 -0
  44. package/es/{components → src/components}/form/components/BaseFormItem/index.vue.d.ts +4 -2
  45. package/es/src/components/form/components/BaseFormItem/index.vue.d.ts.map +1 -0
  46. package/es/src/components/form/components/ContainerFragment/index.vue.d.ts.map +1 -0
  47. package/es/src/components/form/components/ProForm/index.vue.d.ts.map +1 -0
  48. package/es/src/components/form/components/SlotComponent/index.vue.d.ts.map +1 -0
  49. package/es/src/components/form/components/index.d.ts.map +1 -0
  50. package/es/src/components/form/constants/index.d.ts.map +1 -0
  51. package/es/src/components/form/hooks/index.d.ts.map +1 -0
  52. package/es/src/components/form/hooks/useFields.d.ts.map +1 -0
  53. package/es/src/components/form/hooks/useForm.d.ts.map +1 -0
  54. package/es/src/components/form/hooks/useFormRef.d.ts.map +1 -0
  55. package/es/src/components/form/hooks/useGroupFieldAttrs.d.ts.map +1 -0
  56. package/es/src/components/form/index.d.ts.map +1 -0
  57. package/es/{components → src/components}/form/types/index.d.ts +26 -2
  58. package/es/src/components/form/types/index.d.ts.map +1 -0
  59. package/es/{components → src/components}/table/components/ColumnControl.vue.d.ts +4 -1
  60. package/es/src/components/table/components/ColumnControl.vue.d.ts.map +1 -0
  61. package/es/src/components/table/components/DefaultSearchFormContainer.vue.d.ts.map +1 -0
  62. package/es/src/components/table/components/DefaultTableContainer.vue.d.ts.map +1 -0
  63. package/es/{components → src/components}/table/components/ProTable.vue.d.ts +4 -1
  64. package/es/src/components/table/components/ProTable.vue.d.ts.map +1 -0
  65. package/es/{components → src/components}/table/components/SearchForm.vue.d.ts +14 -4
  66. package/es/src/components/table/components/SearchForm.vue.d.ts.map +1 -0
  67. package/es/src/components/table/components/SizeControl.vue.d.ts.map +1 -0
  68. package/es/src/components/table/components/TableColumnRenderer.vue.d.ts.map +1 -0
  69. package/es/src/components/table/components/icons/ColumnHeightOutlined.vue.d.ts.map +1 -0
  70. package/es/src/components/table/components/icons/DownOutlined.vue.d.ts.map +1 -0
  71. package/es/src/components/table/components/icons/FilterOutlined.vue.d.ts.map +1 -0
  72. package/es/src/components/table/components/index.d.ts.map +1 -0
  73. package/es/src/components/table/index.d.ts.map +1 -0
  74. package/es/{components → src/components}/table/types/index.d.ts +3 -0
  75. package/es/src/components/table/types/index.d.ts.map +1 -0
  76. package/es/src/components/table/useTable.d.ts.map +1 -0
  77. package/es/{index.d.ts → src/index.d.ts} +1 -1
  78. package/es/src/index.d.ts.map +1 -0
  79. package/es/src/locale/en-US.d.ts.map +1 -0
  80. package/es/{locale → src/locale}/index.d.ts +1 -1
  81. package/es/src/locale/index.d.ts.map +1 -0
  82. package/es/src/locale/zh-CN.d.ts.map +1 -0
  83. package/es/src/locale/zh-TW.d.ts.map +1 -0
  84. package/es/src/shared/core/index.d.ts +6 -0
  85. package/es/src/shared/core/index.d.ts.map +1 -0
  86. package/es/{shared → src/shared}/ui/index.d.ts +2 -0
  87. package/es/src/shared/ui/index.d.ts.map +1 -0
  88. package/package.json +8 -3
  89. package/src/components/component-provider/components/index.vue +41 -11
  90. package/src/components/component-provider/constants/index.ts +6 -5
  91. package/src/components/component-provider/types/index.ts +9 -5
  92. package/src/components/form/components/BaseField/index.vue +67 -38
  93. package/src/components/form/components/BaseField/utils/index.ts +17 -11
  94. package/src/components/form/components/BaseFormItem/index.vue +48 -41
  95. package/src/components/form/components/ProForm/index.vue +64 -20
  96. package/src/components/form/components/SlotComponent/index.vue +9 -6
  97. package/src/components/form/hooks/useGroupFieldAttrs.ts +13 -6
  98. package/src/components/form/types/index.ts +26 -2
  99. package/src/components/table/components/ColumnControl.vue +31 -38
  100. package/src/components/table/components/ProTable.vue +142 -84
  101. package/src/components/table/components/SearchForm.vue +49 -202
  102. package/src/components/table/components/SizeControl.vue +2 -2
  103. package/src/components/table/components/TableColumnRenderer.vue +16 -11
  104. package/src/components/table/types/index.ts +3 -0
  105. package/src/components/table/useTable.ts +12 -7
  106. package/src/index.ts +1 -1
  107. package/src/locale/en-US.ts +1 -1
  108. package/src/locale/index.ts +7 -7
  109. package/src/locale/zh-CN.ts +1 -1
  110. package/src/locale/zh-TW.ts +1 -1
  111. package/src/shared/core/index.ts +15 -2
  112. package/src/shared/ui/index.ts +20 -9
  113. package/es/components/component-provider/components/index.vue.d.ts.map +0 -1
  114. package/es/components/component-provider/constants/index.d.ts.map +0 -1
  115. package/es/components/component-provider/index.d.ts.map +0 -1
  116. package/es/components/component-provider/types/index.d.ts.map +0 -1
  117. package/es/components/form/components/BaseField/index.vue.d.ts.map +0 -1
  118. package/es/components/form/components/BaseField/utils/index.d.ts +0 -5
  119. package/es/components/form/components/BaseField/utils/index.d.ts.map +0 -1
  120. package/es/components/form/components/BaseFormItem/index.vue.d.ts.map +0 -1
  121. package/es/components/form/components/ContainerFragment/index.vue.d.ts.map +0 -1
  122. package/es/components/form/components/ProForm/index.vue.d.ts.map +0 -1
  123. package/es/components/form/components/SlotComponent/index.vue.d.ts.map +0 -1
  124. package/es/components/form/components/index.d.ts.map +0 -1
  125. package/es/components/form/constants/index.d.ts.map +0 -1
  126. package/es/components/form/hooks/index.d.ts.map +0 -1
  127. package/es/components/form/hooks/useFields.d.ts.map +0 -1
  128. package/es/components/form/hooks/useForm.d.ts.map +0 -1
  129. package/es/components/form/hooks/useFormRef.d.ts.map +0 -1
  130. package/es/components/form/hooks/useGroupFieldAttrs.d.ts.map +0 -1
  131. package/es/components/form/index.d.ts.map +0 -1
  132. package/es/components/form/types/index.d.ts.map +0 -1
  133. package/es/components/table/components/ColumnControl.vue.d.ts.map +0 -1
  134. package/es/components/table/components/DefaultSearchFormContainer.vue.d.ts.map +0 -1
  135. package/es/components/table/components/DefaultTableContainer.vue.d.ts.map +0 -1
  136. package/es/components/table/components/ProTable.vue.d.ts.map +0 -1
  137. package/es/components/table/components/SearchForm.vue.d.ts.map +0 -1
  138. package/es/components/table/components/SizeControl.vue.d.ts.map +0 -1
  139. package/es/components/table/components/TableColumnRenderer.vue.d.ts.map +0 -1
  140. package/es/components/table/components/icons/ColumnHeightOutlined.vue.d.ts.map +0 -1
  141. package/es/components/table/components/icons/DownOutlined.vue.d.ts.map +0 -1
  142. package/es/components/table/components/icons/FilterOutlined.vue.d.ts.map +0 -1
  143. package/es/components/table/components/index.d.ts.map +0 -1
  144. package/es/components/table/index.d.ts.map +0 -1
  145. package/es/components/table/types/index.d.ts.map +0 -1
  146. package/es/components/table/useTable.d.ts.map +0 -1
  147. package/es/index.d.ts.map +0 -1
  148. package/es/locale/en-US.d.ts.map +0 -1
  149. package/es/locale/index.d.ts.map +0 -1
  150. package/es/locale/zh-CN.d.ts.map +0 -1
  151. package/es/locale/zh-TW.d.ts.map +0 -1
  152. package/es/shared/core/index.d.ts +0 -6
  153. package/es/shared/core/index.d.ts.map +0 -1
  154. package/es/shared/ui/index.d.ts.map +0 -1
  155. /package/es/{components → src/components}/component-provider/index.d.ts +0 -0
  156. /package/es/{components → src/components}/form/components/ContainerFragment/index.vue.d.ts +0 -0
  157. /package/es/{components → src/components}/form/components/ProForm/index.vue.d.ts +0 -0
  158. /package/es/{components → src/components}/form/components/SlotComponent/index.vue.d.ts +0 -0
  159. /package/es/{components → src/components}/form/components/index.d.ts +0 -0
  160. /package/es/{components → src/components}/form/constants/index.d.ts +0 -0
  161. /package/es/{components → src/components}/form/hooks/index.d.ts +0 -0
  162. /package/es/{components → src/components}/form/hooks/useFields.d.ts +0 -0
  163. /package/es/{components → src/components}/form/hooks/useForm.d.ts +0 -0
  164. /package/es/{components → src/components}/form/hooks/useFormRef.d.ts +0 -0
  165. /package/es/{components → src/components}/form/hooks/useGroupFieldAttrs.d.ts +0 -0
  166. /package/es/{components → src/components}/form/index.d.ts +0 -0
  167. /package/es/{components → src/components}/table/components/DefaultSearchFormContainer.vue.d.ts +0 -0
  168. /package/es/{components → src/components}/table/components/DefaultTableContainer.vue.d.ts +0 -0
  169. /package/es/{components → src/components}/table/components/SizeControl.vue.d.ts +0 -0
  170. /package/es/{components → src/components}/table/components/TableColumnRenderer.vue.d.ts +0 -0
  171. /package/es/{components → src/components}/table/components/icons/ColumnHeightOutlined.vue.d.ts +0 -0
  172. /package/es/{components → src/components}/table/components/icons/DownOutlined.vue.d.ts +0 -0
  173. /package/es/{components → src/components}/table/components/icons/FilterOutlined.vue.d.ts +0 -0
  174. /package/es/{components → src/components}/table/components/index.d.ts +0 -0
  175. /package/es/{components → src/components}/table/index.d.ts +0 -0
  176. /package/es/{components → src/components}/table/useTable.d.ts +0 -0
  177. /package/es/{locale → src/locale}/en-US.d.ts +0 -0
  178. /package/es/{locale → src/locale}/zh-CN.d.ts +0 -0
  179. /package/es/{locale → src/locale}/zh-TW.d.ts +0 -0
package/es/index.js CHANGED
@@ -1,25 +1,26 @@
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, createTextVNode, toDisplayString, provide, useSlots, withModifiers, createElementVNode, normalizeStyle, useModel, watch, mergeModels, onMounted, resolveDirective, normalizeClass, withDirectives, guardReactiveProps, nextTick } from "vue";
3
+ import { ElTable, ElPagination, ElCol, ElFormItem, useFormDisabled, 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, createFormProxy, InjectionFormKey, camelizeProperties, useFields as useFields$1, useFormRef as useFormRef$1, useSearchFormExpand, get, pick, isPromise, useTable as useTable$1 } from "@qin-ui/pro-components-core";
5
5
  import { useFormData } from "@qin-ui/pro-components-core";
6
- const tableProps = () => ElTable.props || {};
7
- const paginationProps = () => ElPagination.props || {};
8
- const gridItemProps = () => ElCol.props || {};
9
- const formItemProps = () => ElFormItem.props || {};
10
- const DisabledContextKey = Symbol("pro-form-disabled-context");
6
+ const _tableProps = ElTable.props || {};
7
+ const _paginationProps = ElPagination.props || {};
8
+ const _gridItemProps = ElCol.props || {};
9
+ const _formItemProps = ElFormItem.props || {};
10
+ const tableProps = () => _tableProps;
11
+ const paginationProps = () => _paginationProps;
12
+ const gridItemProps = () => _gridItemProps;
13
+ const formItemProps = () => _formItemProps;
14
+ const DisabledContextKey = Symbol.for("pro-form-disabled-context");
11
15
  const useDisabledContext = () => {
12
16
  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
- );
17
+ const customDisabled = inject(DisabledContextKey, void 0);
18
+ return computed(() => {
19
+ if (customDisabled !== void 0 && toValue(customDisabled) !== void 0) {
20
+ return Boolean(toValue(customDisabled));
21
+ }
22
+ return Boolean(formDisabled.value);
23
+ });
23
24
  };
24
25
  const INJECT_CONFIG = {
25
26
  "pro-table": {
@@ -71,7 +72,7 @@ const INJECT_CONFIG = {
71
72
  injectionKey: Symbol(""),
72
73
  default: {
73
74
  max: 10 ** 15 - 1,
74
- min: -1000000000000001,
75
+ min: -999999999999999,
75
76
  controls: false,
76
77
  style: { width: "100%" }
77
78
  }
@@ -205,12 +206,17 @@ const componentMap = {
205
206
  "tree-select": ElTreeSelect,
206
207
  "transfer": ElTransfer
207
208
  };
208
- const formItemPropKeys = Object.keys(formItemProps());
209
+ const formItemPropKeys = Object.keys(formItemProps()).filter(
210
+ (k) => k !== "disabled"
211
+ );
209
212
  const gridItemPropKeys = Object.keys(gridItemProps());
213
+ const gridItemPropKeySet = new Set(gridItemPropKeys);
214
+ const formItemPropKeySet = new Set(formItemPropKeys);
210
215
  function useGroupFieldAttrs(validFields) {
211
216
  const config = INJECT_CONFIG["pro-form-item"];
212
217
  const injectFormItemProps = inject(config.injectionKey, config.default);
213
218
  return computed(() => {
219
+ const rawInjectProps = toValue(injectFormItemProps) || {};
214
220
  return validFields.value.map((field) => {
215
221
  let gridItemProps2 = {};
216
222
  let formItemProps2 = {};
@@ -229,7 +235,7 @@ function useGroupFieldAttrs(validFields) {
229
235
  lg,
230
236
  xl,
231
237
  ...injectRest
232
- } = injectFormItemProps;
238
+ } = rawInjectProps;
233
239
  const initGridItemProps = span || span === 0 ? { span } : { xs, sm, md, lg, xl, span: injectSpan };
234
240
  gridItemProps2 = fields ? { span: span ?? 24 } : initGridItemProps;
235
241
  formItemProps2 = mergeProps(
@@ -240,9 +246,9 @@ function useGroupFieldAttrs(validFields) {
240
246
  );
241
247
  const container = formItemContainer ?? injectFormItemContainer;
242
248
  Object.keys(rest).forEach((k) => {
243
- if (gridItemPropKeys.includes(k)) {
249
+ if (gridItemPropKeySet.has(k)) {
244
250
  gridItemProps2[k] = rest[k];
245
- } else if (formItemPropKeys.includes(k)) {
251
+ } else if (formItemPropKeySet.has(k)) {
246
252
  formItemProps2[k] = rest[k];
247
253
  } else {
248
254
  componentProps[k] = rest[k];
@@ -256,7 +262,7 @@ function useGroupFieldAttrs(validFields) {
256
262
  componentProps.slots[k] = slots[k];
257
263
  }
258
264
  });
259
- const raw2 = toValue(path) ?? toValue(name);
265
+ const raw2 = toValue(name) ?? toValue(path);
260
266
  return {
261
267
  path: Array.isArray(raw2) ? raw2.join(".") : raw2 || "",
262
268
  gridItemProps: gridItemProps2,
@@ -267,7 +273,7 @@ function useGroupFieldAttrs(validFields) {
267
273
  rawField: field
268
274
  };
269
275
  }
270
- const raw = toValue(field == null ? void 0 : field.path) ?? toValue(field == null ? void 0 : field.name);
276
+ const raw = toValue(field == null ? void 0 : field.name) ?? toValue(field == null ? void 0 : field.path);
271
277
  return {
272
278
  path: Array.isArray(raw) ? raw.join(".") : raw || "",
273
279
  gridItemProps: gridItemProps2,
@@ -283,46 +289,59 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
283
289
  ...{ name: "BaseFormItem", inheritAttrs: false },
284
290
  __name: "index",
285
291
  props: {
286
- grid: { type: [Boolean, Object], default: () => void 0 },
287
- fields: { default: () => [] },
288
- disabled: { type: Boolean, default: () => void 0 }
292
+ grid: { type: [Boolean, Object], default: void 0 },
293
+ fields: { default: () => [] }
289
294
  },
290
295
  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));
296
+ const props = __props;
297
+ const validFields = computed(
298
+ () => (
299
+ // hidden 支持 Ref/ComputedRef/getter 等响应式形态(统一使用 toValue 取值)
300
+ (props.fields ?? []).filter((field) => !toValue(field.hidden))
301
+ )
302
+ );
296
303
  const config = INJECT_CONFIG["pro-form"];
297
- const { grid: injectGrid } = inject(config.injectionKey, config.default);
304
+ const injectFormConfig = inject(config.injectionKey, config.default);
305
+ const injectGrid = computed(() => {
306
+ var _a;
307
+ return (_a = toValue(injectFormConfig)) == null ? void 0 : _a.grid;
308
+ });
298
309
  const enableGrid = computed(() => {
299
- if (__props.grid !== void 0) return !!__props.grid;
300
- return !!injectGrid;
310
+ if (props.grid !== void 0) return !!props.grid;
311
+ return !!injectGrid.value;
301
312
  });
302
313
  const computedGridProps = computed(() => {
303
- return enableGrid.value ? { ...getObject(injectGrid), ...getObject(__props.grid) } : {};
314
+ return enableGrid.value ? { ...getObject(injectGrid.value), ...getObject(props.grid) } : {};
304
315
  });
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
- });
316
+ const formItemInstanceMap = /* @__PURE__ */ new WeakMap();
317
+ const componentInstanceMap = /* @__PURE__ */ new WeakMap();
318
+ const setFormItemRef = (field, el, formItemProps2) => {
319
+ if (!field || typeof field !== "object") return;
320
+ const raw = toRaw(field);
321
+ if (el) {
322
+ formItemInstanceMap.set(raw, el);
323
+ raw.getFormItemRef = () => formItemInstanceMap.get(raw);
324
+ raw.getFormItemComputedProps = () => formItemProps2;
325
+ } else {
326
+ formItemInstanceMap.delete(raw);
327
+ }
313
328
  };
314
- const onComponentMounted = (index2) => {
315
- const field = validFields.value[index2];
316
- Object.assign(field, {
317
- getComponentRef: () => {
329
+ const setComponentRef = (field, el) => {
330
+ if (!field || typeof field !== "object") return;
331
+ const raw = toRaw(field);
332
+ if (el) {
333
+ componentInstanceMap.set(raw, el);
334
+ raw.getComponentRef = () => {
318
335
  var _a;
319
- return (_a = componentRefs[index2]) == null ? void 0 : _a.getComponentRef();
320
- },
321
- getComponentComputedProps: () => {
336
+ return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentRef();
337
+ };
338
+ raw.getComponentComputedProps = () => {
322
339
  var _a;
323
- return (_a = componentRefs[index2]) == null ? void 0 : _a.getComponentComputedProps();
324
- }
325
- });
340
+ return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentComputedProps();
341
+ };
342
+ } else {
343
+ componentInstanceMap.delete(raw);
344
+ }
326
345
  };
327
346
  const groupedFields = useGroupFieldAttrs(validFields);
328
347
  return (_ctx, _cache) => {
@@ -344,25 +363,22 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
344
363
  default: withCtx(() => [
345
364
  createVNode(unref(ElFormItem), mergeProps({ ref_for: true }, item.formItemProps, {
346
365
  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)
366
+ ref: (el) => setFormItemRef(item.rawField, el, item.formItemProps),
367
+ prop: unref(normalizePathKey)(item.path),
368
+ path: item.path
351
369
  }), createSlots({
352
370
  default: withCtx(() => [
353
371
  item.rawField.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
354
372
  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({
373
+ grid: item.rawField.grid ?? props.grid,
374
+ fields: item.rawField.fields
375
+ }, null, 8, ["grid", "fields"])) : (openBlock(), createBlock(unref(_sfc_main$e), mergeProps({
359
376
  key: 1,
360
377
  ref_for: true,
361
- ref: (el) => componentRefs[index2] = el
378
+ ref: (el) => setComponentRef(item.rawField, el)
362
379
  }, { ref_for: true }, item.componentProps, {
363
- path: item.path,
364
- onVnodeMounted: ($event) => onComponentMounted(index2)
365
- }), null, 16, ["path", "onVnodeMounted"]))
380
+ path: item.path
381
+ }), null, 16, ["path"]))
366
382
  ]),
367
383
  _: 2
368
384
  }, [
@@ -377,7 +393,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
377
393
  ])
378
394
  };
379
395
  })
380
- ]), 1040, ["prop", "path", "onVnodeMounted"])
396
+ ]), 1040, ["prop", "path"])
381
397
  ]),
382
398
  _: 2
383
399
  }, 1032, ["component", "path"])
@@ -398,7 +414,7 @@ const _export_sfc = (sfc, props) => {
398
414
  }
399
415
  return target;
400
416
  };
401
- const BaseFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-295cd434"]]);
417
+ const BaseFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-e8f152ee"]]);
402
418
  function useForm(...args) {
403
419
  return useForm$1(...args);
404
420
  }
@@ -443,17 +459,22 @@ const getPlaceholderProps = (key, injectProps, t) => {
443
459
  if (!placeholderKey || injectProps.placeholder !== void 0) return {};
444
460
  return { placeholder: t(placeholderKey) };
445
461
  };
446
- const getInitProps = (field, t) => {
462
+ const getInitProps = (field, injectProps = {}, t) => {
447
463
  const { component, type } = field;
448
464
  if (typeof component === "string") {
449
465
  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
466
  return { ...injectProps, ...getPlaceholderProps(k, injectProps, t) };
454
467
  }
455
468
  return {};
456
469
  };
470
+ const warnedUnknownComponents = /* @__PURE__ */ new Set();
471
+ function warnUnknownComponent(name) {
472
+ if (warnedUnknownComponents.has(name)) return;
473
+ warnedUnknownComponents.add(name);
474
+ console.warn(
475
+ `[pro-components] 未识别的组件类型 "${name}",已降级为原生元素渲染。如为自定义组件请在 componentMap 或 ProComponentProvider 中注册。`
476
+ );
477
+ }
457
478
  const zhCN = {
458
479
  ...zhCN$1,
459
480
  // 日期/时间选择器占位符(对应 INJECT_CONFIG 中 date-picker.* 的占位默认值)
@@ -495,9 +516,13 @@ const enUS = {
495
516
  };
496
517
  const LOCALE_INJECT_KEY = Symbol("pro-locale");
497
518
  const useLocale = () => {
519
+ const elLocaleContext = inject(localeContextKey, void 0);
498
520
  const { lang: elLang } = useLocale$1();
499
521
  const override = inject(LOCALE_INJECT_KEY, void 0);
500
- const lang = computed(() => resolveLocaleName(elLang.value));
522
+ const lang = computed(() => {
523
+ if (!elLocaleContext) return "zh-CN";
524
+ return resolveLocaleName(elLang.value);
525
+ });
501
526
  const pack = computed(
502
527
  () => lang.value === "zh-TW" ? zhTW : lang.value === "en-US" ? enUS : zhCN
503
528
  );
@@ -512,21 +537,23 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
512
537
  ...{ name: "BaseField", inheritAttrs: false },
513
538
  __name: "index",
514
539
  props: {
515
- component: { default: () => void 0 },
540
+ component: { default: void 0 },
516
541
  path: { default: "" }
517
542
  },
518
543
  setup(__props, { expose: __expose }) {
544
+ const props = __props;
519
545
  const { t } = useLocale();
520
546
  const form = useForm(false);
521
- const { getFormData, setFormData } = form;
522
547
  const componentRef = ref();
523
548
  const attrs = useAttrs();
524
- function getOldValue() {
525
- return cloneDeep(getFormData == null ? void 0 : getFormData(__props.path));
526
- }
549
+ const typeVal = attrs.type;
550
+ const injectConfigKey = typeof props.component === "string" ? [props.component, typeVal].filter(Boolean).join(".") : "";
551
+ const componentInjectConfig = injectConfigKey ? getInjectConfig(injectConfigKey) : void 0;
552
+ const rawInjectComponentProps = componentInjectConfig ? inject(componentInjectConfig.injectionKey, componentInjectConfig.default) : void 0;
527
553
  const value = computed({
528
554
  get() {
529
- let val = getFormData == null ? void 0 : getFormData(__props.path);
555
+ var _a;
556
+ let val = (_a = form.getFormData) == null ? void 0 : _a.call(form, props.path);
530
557
  const { valueFormatter } = groupedAttrs.value;
531
558
  if (typeof valueFormatter === "object" && typeof valueFormatter.get === "function") {
532
559
  val = valueFormatter.get(val);
@@ -534,59 +561,59 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
534
561
  return val;
535
562
  },
536
563
  set(val) {
564
+ var _a, _b;
537
565
  let newVal = val;
538
566
  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
- }
567
+ const setFormatter = typeof valueFormatter === "function" ? valueFormatter : typeof valueFormatter === "object" && typeof (valueFormatter == null ? void 0 : valueFormatter.set) === "function" ? valueFormatter.set : void 0;
568
+ if (setFormatter) {
569
+ const oldVal = setFormatter.length > 1 ? cloneDeep((_a = form.getFormData) == null ? void 0 : _a.call(form, props.path)) : void 0;
570
+ newVal = setFormatter(val, oldVal);
545
571
  }
546
- setFormData == null ? void 0 : setFormData(__props.path, newVal);
572
+ (_b = form.setFormData) == null ? void 0 : _b.call(form, props.path, newVal);
547
573
  }
548
574
  });
549
575
  const parentDisabled = useDisabledContext();
550
576
  const groupedAttrs = computed(() => {
577
+ const currentInjectProps = toValue(rawInjectComponentProps) || {};
551
578
  const initProps = getInitProps(
552
579
  {
553
- component: __props.component,
580
+ component: props.component,
554
581
  type: attrs.type
555
582
  },
583
+ currentInjectProps,
556
584
  t
557
585
  );
558
586
  const modelPropName = attrs.modelProp ?? initProps.modelProp ?? "modelValue";
587
+ const effectiveDisabled = attrs.disabled !== void 0 ? Boolean(attrs.disabled) : Boolean(parentDisabled.value || initProps.disabled);
559
588
  const mergedProps = mergeProps(
560
589
  initProps,
561
590
  attrs,
562
591
  { class: attrs.componentClass, style: attrs.componentStyle },
563
- { class: initProps.componentClass, style: initProps.componentStyle },
564
- { disabled: attrs.disabled ?? parentDisabled.value ?? initProps.disabled },
592
+ { disabled: effectiveDisabled },
565
593
  { modelProp: modelPropName }
566
594
  );
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
- ]);
595
+ const { valueFormatter, modelProp, slots, componentClass, componentStyle, componentContainer, [modelPropName]: _modelVal, [`onUpdate:${modelPropName}`]: _onUpdateModelVal, ...bindAttrs } = mergedProps;
573
596
  return {
574
597
  attrs: bindAttrs,
575
598
  slots,
576
599
  componentContainer,
577
- modelProp: modelBindingProp,
600
+ modelProp: modelPropName,
578
601
  valueFormatter
579
602
  };
580
603
  });
581
604
  const formSlots = inject(InjectionFormSlotsKey, void 0);
582
605
  const customComponents = inject(INJECT_COMPONENTS, {});
583
606
  const is = computed(() => {
584
- const teleportSlot = __props.path && (formSlots == null ? void 0 : formSlots[__props.path]);
607
+ var _a;
608
+ const teleportSlot = props.path && (formSlots == null ? void 0 : formSlots[props.path]);
585
609
  if (teleportSlot) return teleportSlot;
586
- if (typeof __props.component === "string") {
587
- return customComponents[__props.component] || componentMap[__props.component] || __props.component;
610
+ if (typeof props.component === "string") {
611
+ const resolved = ((_a = toValue(customComponents)) == null ? void 0 : _a[props.component]) || componentMap[props.component];
612
+ if (resolved) return resolved;
613
+ warnUnknownComponent(props.component);
614
+ return props.component;
588
615
  }
589
- return __props.component;
616
+ return props.component;
590
617
  });
591
618
  __expose({
592
619
  getComponentRef: () => componentRef.value,
@@ -595,7 +622,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
595
622
  return (_ctx, _cache) => {
596
623
  return openBlock(), createBlock(unref(_sfc_main$d), {
597
624
  component: groupedAttrs.value.componentContainer,
598
- path: __props.path
625
+ path: props.path
599
626
  }, {
600
627
  default: withCtx(() => [
601
628
  is.value ? (openBlock(), createBlock(resolveDynamicComponent(is.value), mergeProps({ key: 0 }, groupedAttrs.value.attrs, {
@@ -603,13 +630,15 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
603
630
  ref: componentRef,
604
631
  [`${groupedAttrs.value.modelProp}`]: value.value,
605
632
  [`onUpdate:${groupedAttrs.value.modelProp}`]: _cache[0] || (_cache[0] = ($event) => value.value = $event),
606
- path: __props.path
633
+ path: props.path
607
634
  }), createSlots({ _: 2 }, [
608
635
  renderList(groupedAttrs.value.slots, (slot, name) => {
609
636
  return {
610
637
  name,
611
638
  fn: withCtx((scoped) => [
612
- createVNode(unref(_sfc_main$c), mergeProps({ path: __props.path }, scoped, { component: slot }), null, 16, ["path", "component"])
639
+ createVNode(unref(_sfc_main$c), mergeProps({
640
+ path: props.path
641
+ }, scoped, { component: slot }), null, 16, ["path", "component"])
613
642
  ])
614
643
  };
615
644
  })
@@ -644,8 +673,9 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
644
673
  component: { type: [Object, Function, String, Number, Boolean, null] }
645
674
  },
646
675
  setup(__props) {
676
+ const isRenderable = (c) => c !== null && c !== void 0 && (typeof c === "function" || typeof c === "object");
647
677
  return (_ctx, _cache) => {
648
- return isVNode(__props.component) || typeof __props.component === "function" ? (openBlock(), createBlock(resolveDynamicComponent(__props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), null, 16)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
678
+ return isRenderable(__props.component) ? (openBlock(), createBlock(resolveDynamicComponent(__props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), null, 16)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
649
679
  createTextVNode(toDisplayString(__props.component), 1)
650
680
  ], 64));
651
681
  };
@@ -656,36 +686,65 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
656
686
  __name: "index",
657
687
  props: {
658
688
  grid: { type: [Boolean, Object], default: false },
659
- form: { default: () => ({}) }
689
+ form: { default: void 0 }
660
690
  },
661
691
  setup(__props) {
662
- provide(InjectionFormKey, __props.form);
663
- const { formData, fields, setFormRef } = __props.form;
664
- const _fields = computed(() => fields.value);
692
+ const props = __props;
693
+ const fallbackForm = props.form ? void 0 : useForm();
694
+ const currentForm = computed(
695
+ () => props.form ?? fallbackForm
696
+ );
697
+ const formProxy = createFormProxy(() => currentForm.value);
698
+ provide(InjectionFormKey, formProxy);
699
+ const fields = computed(() => {
700
+ var _a;
701
+ const f = (_a = currentForm.value) == null ? void 0 : _a.fields;
702
+ return (Array.isArray(f) ? f : f == null ? void 0 : f.value) ?? [];
703
+ });
704
+ const formData = computed(() => {
705
+ var _a;
706
+ return (_a = currentForm.value) == null ? void 0 : _a.formData;
707
+ });
708
+ const setFormRef = (el) => {
709
+ var _a, _b;
710
+ return (_b = (_a = currentForm.value) == null ? void 0 : _a.setFormRef) == null ? void 0 : _b.call(_a, el);
711
+ };
712
+ let formInstanceCounter = 0;
713
+ const formInstanceKeyMap = /* @__PURE__ */ new WeakMap();
714
+ const getFormKey = (f) => {
715
+ if (!formInstanceKeyMap.has(f)) {
716
+ formInstanceKeyMap.set(f, ++formInstanceCounter);
717
+ }
718
+ return formInstanceKeyMap.get(f);
719
+ };
720
+ const formKey = computed(() => getFormKey(currentForm.value));
665
721
  const config = INJECT_CONFIG["pro-form"];
722
+ const injectFormConfig = inject(config.injectionKey, config.default);
666
723
  const attrs = useAttrs();
667
- const { grid: _injectGrid, ...injectAttrs } = inject(
668
- config.injectionKey,
669
- config.default
670
- );
724
+ const injectAttrs = computed(() => {
725
+ const raw = toValue(injectFormConfig);
726
+ const { grid: _injectGrid, ...rest } = raw || {};
727
+ return rest;
728
+ });
729
+ const formAttrs = computed(() => {
730
+ return mergeProps(injectAttrs.value, camelizeProperties(attrs));
731
+ });
671
732
  const slots = useSlots();
672
- provide(InjectionFormSlotsKey, reactive(slots));
733
+ provide(InjectionFormSlotsKey, slots);
673
734
  return (_ctx, _cache) => {
674
735
  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))), {
736
+ key: formKey.value,
737
+ ref: setFormRef,
738
+ model: formData.value
739
+ }, formAttrs.value, {
681
740
  class: "pro-form",
682
741
  onSubmit: _cache[0] || (_cache[0] = withModifiers(() => {
683
742
  }, ["prevent"]))
684
743
  }), {
685
744
  default: withCtx(() => [
686
745
  createVNode(unref(BaseFormItem), {
687
- fields: _fields.value,
688
- grid: __props.grid
746
+ fields: fields.value,
747
+ grid: props.grid
689
748
  }, null, 8, ["fields", "grid"]),
690
749
  renderSlot(_ctx.$slots, "default")
691
750
  ]),
@@ -720,7 +779,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
720
779
  ...{ name: "SearchForm" },
721
780
  __name: "SearchForm",
722
781
  props: {
723
- form: {},
782
+ form: { default: void 0 },
724
783
  layout: { default: "grid" },
725
784
  expand: { type: [Boolean, Object], default: true },
726
785
  searchButton: { type: [Object, Function, Boolean], default: void 0 },
@@ -734,161 +793,31 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
734
793
  emits: ["search", "reset"],
735
794
  setup(__props, { emit: __emit }) {
736
795
  const { t } = useLocale();
796
+ const props = __props;
737
797
  const emit = __emit;
738
- const proFormHeight = ref("unset");
739
- const collapseHeight = ref(0);
740
- const rowHeight = ref(32);
741
- let resizeObserver = null;
742
- let intersectionObserver = null;
743
- const cleanupObservers = () => {
744
- if (resizeObserver) {
745
- resizeObserver.disconnect();
746
- resizeObserver = null;
747
- }
748
- if (intersectionObserver) {
749
- intersectionObserver.disconnect();
750
- intersectionObserver = null;
751
- }
752
- };
753
- onBeforeUnmount(() => {
754
- cleanupObservers();
755
- });
756
- const computedExpand = computed(() => {
757
- if (!__props.expand) return false;
758
- if (__props.expand === true) return { minExpandRows: 2, expandStatus: false };
759
- return {
760
- minExpandRows: Math.max(Math.floor(__props.expand.minExpandRows ?? 2), 1),
761
- expandStatus: __props.expand.expandStatus ?? false
762
- };
763
- });
764
- const showExpandToggle = ref(false);
765
- const expandStatus = ref(true);
766
- const { formRef, getFormData } = __props.form;
767
- 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;
771
- 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;
773
- if (itemHeight && itemHeight > 0) {
774
- rowHeight.value = itemHeight;
775
- }
776
- const naturalHeight = proFormEl.scrollHeight || ((_f = (_e = proFormEl.getBoundingClientRect) == null ? void 0 : _e.call(proFormEl)) == null ? void 0 : _f.height) || 0;
777
- if (naturalHeight > 0) {
778
- proFormHeight.value = naturalHeight;
779
- }
780
- };
781
- const changeExpandStatus = () => {
782
- expandStatus.value = !expandStatus.value;
783
- nextTick(() => {
784
- updateHeights();
785
- });
786
- };
787
- const hasFieldValue = (val) => val !== null && val !== void 0 && val !== "" && !(Array.isArray(val) && val.length === 0) && !(typeof val === "object" && Object.keys(val).length === 0);
788
- 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(
794
- formEl,
795
- "[class*='-form-item'] > [path]"
796
- );
797
- if (!formItemsEl || formItemsEl.length === 0) return;
798
- if (intersectionObserver) {
799
- intersectionObserver.disconnect();
800
- }
801
- intersectionObserver = new IntersectionObserver(
802
- (entries) => {
803
- expandStatus.value = entries.some((e) => {
804
- if (e.intersectionRatio === 0) {
805
- const path = e.target.getAttribute("path");
806
- const searchFieldValue = path ? getFormData == null ? void 0 : getFormData(path) : void 0;
807
- return hasFieldValue(searchFieldValue);
808
- }
809
- return __props.expand.expandStatus;
810
- });
811
- intersectionObserver == null ? void 0 : intersectionObserver.disconnect();
812
- },
813
- { root: formEl }
814
- );
815
- formItemsEl.forEach((element) => {
816
- intersectionObserver == null ? void 0 : intersectionObserver.observe(element);
817
- });
818
- }
819
- };
820
- watch(
821
- [
822
- () => {
823
- 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;
825
- },
826
- () => formRef.value,
827
- () => __props.expand
828
- ],
829
- () => {
830
- updateHeights();
831
- },
832
- { flush: "post", immediate: true }
833
- );
834
- watch(
835
- () => formRef.value,
836
- (val) => {
837
- if (resizeObserver) {
838
- resizeObserver.disconnect();
839
- resizeObserver = null;
840
- }
841
- const formEl = val == null ? void 0 : val.$el;
842
- if (formEl && typeof ResizeObserver !== "undefined") {
843
- resizeObserver = new ResizeObserver(() => {
844
- updateHeights();
845
- });
846
- resizeObserver.observe(formEl);
847
- }
848
- },
849
- { immediate: true }
850
- );
851
- watchEffect(
852
- () => {
853
- if (typeof proFormHeight.value !== "number") return;
854
- if (__props.layout === "grid" && computedExpand.value) {
855
- const { minExpandRows } = computedExpand.value;
856
- collapseHeight.value = Math.min(
857
- minExpandRows * rowHeight.value + (minExpandRows - 1) * __props.rowGap,
858
- +proFormHeight.value
859
- );
860
- showExpandToggle.value = +proFormHeight.value - collapseHeight.value > 1;
861
- if (showExpandToggle.value) {
862
- setInitExpandStatus();
863
- }
864
- } else {
865
- showExpandToggle.value = false;
866
- }
867
- },
868
- { flush: "post" }
869
- );
870
- const layoutProps = computed(
871
- () => __props.layout === "grid" ? {
798
+ const { showExpandToggle, expandStatus, changeExpandStatus, heightStyle } = useSearchFormExpand(props);
799
+ const layoutProps = computed(() => {
800
+ return props.layout === "grid" ? {
872
801
  grid: {
873
- gutter: __props.columnGap,
874
- style: { rowGap: `${__props.rowGap}px` }
802
+ gutter: props.columnGap,
803
+ style: { rowGap: `${props.rowGap}px` }
875
804
  },
876
805
  style: {
877
806
  display: "flex",
878
807
  overflow: "hidden",
879
- columnGap: `${__props.columnGap}px`,
880
- height: `${expandStatus.value ? proFormHeight.value : collapseHeight.value}px`
808
+ columnGap: `${props.columnGap}px`,
809
+ height: heightStyle.value
881
810
  }
882
811
  } : {
883
812
  inline: true,
884
813
  style: {
885
814
  display: "flex",
886
815
  flexWrap: "wrap",
887
- gap: `${__props.rowGap}px ${__props.columnGap}px`
816
+ gap: `${props.rowGap}px ${props.columnGap}px`
888
817
  },
889
818
  grid: false
890
- }
891
- );
819
+ };
820
+ });
892
821
  const onReset = () => {
893
822
  emit("reset");
894
823
  };
@@ -897,9 +826,8 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
897
826
  };
898
827
  return (_ctx, _cache) => {
899
828
  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"])
829
+ form: props.form,
830
+ class: "pro-table_search-form transition"
903
831
  }), {
904
832
  default: withCtx(() => [
905
833
  createVNode(unref(ElSpace), {
@@ -907,9 +835,9 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
907
835
  class: "pro-table_search-form_button-group"
908
836
  }, {
909
837
  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), {
838
+ renderSlot(_ctx.$slots, "reset-button", { onReset }, () => [
839
+ props.resetButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
840
+ props.resetButton ? (openBlock(), createBlock(resolveDynamicComponent(props.resetButton), {
913
841
  key: 0,
914
842
  onClick: onReset
915
843
  })) : (openBlock(), createBlock(unref(ElButton), {
@@ -924,9 +852,9 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
924
852
  }))
925
853
  ], 64)) : createCommentVNode("", true)
926
854
  ], 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), {
855
+ renderSlot(_ctx.$slots, "search-button", { onSearch }, () => [
856
+ props.searchButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
857
+ props.searchButton ? (openBlock(), createBlock(resolveDynamicComponent(props.searchButton), {
930
858
  key: 0,
931
859
  onClick: onSearch
932
860
  })) : (openBlock(), createBlock(unref(ElButton), {
@@ -943,27 +871,30 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
943
871
  }))
944
872
  ], 64)) : createCommentVNode("", true)
945
873
  ], 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), {
874
+ renderSlot(_ctx.$slots, "expand-button", {
875
+ expandStatus: unref(expandStatus),
876
+ changeExpandStatus: unref(changeExpandStatus)
877
+ }, () => [
878
+ props.expandButton !== false && unref(showExpandToggle) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
879
+ props.expandButton ? (openBlock(), createBlock(resolveDynamicComponent(props.expandButton), {
949
880
  key: 0,
950
- "expand-status": expandStatus.value,
951
- onClick: changeExpandStatus
952
- }, null, 8, ["expand-status"])) : (openBlock(), createBlock(unref(ElButton), {
881
+ "expand-status": unref(expandStatus),
882
+ onClick: unref(changeExpandStatus)
883
+ }, null, 8, ["expand-status", "onClick"])) : (openBlock(), createBlock(unref(ElButton), {
953
884
  key: 1,
954
885
  text: "",
955
886
  class: "pro-table_search-form_expand-toggle-button",
956
- onClick: changeExpandStatus
887
+ onClick: unref(changeExpandStatus)
957
888
  }, {
958
889
  default: withCtx(() => [
959
- createTextVNode(toDisplayString(expandStatus.value ? unref(t)("table.collapse") : unref(t)("table.expand")) + " ", 1),
890
+ createTextVNode(toDisplayString(unref(expandStatus) ? unref(t)("table.collapse") : unref(t)("table.expand")) + " ", 1),
960
891
  createVNode(DownOutlined, {
961
892
  class: "transition",
962
- style: normalizeStyle([{ "margin-left": "4px" }, { transform: `rotate(${expandStatus.value ? -180 : 0}deg)` }])
893
+ style: normalizeStyle([{ "margin-left": "4px" }, { transform: `rotate(${unref(expandStatus) ? -180 : 0}deg)` }])
963
894
  }, null, 8, ["style"])
964
895
  ]),
965
896
  _: 1
966
- }))
897
+ }, 8, ["onClick"]))
967
898
  ], 64)) : createCommentVNode("", true)
968
899
  ], true)
969
900
  ]),
@@ -975,7 +906,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
975
906
  };
976
907
  }
977
908
  });
978
- const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-20c91e48"]]);
909
+ const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-9c362a11"]]);
979
910
  const _sfc_main$8 = {};
980
911
  const _hoisted_1$4 = { class: "pro-table_search-form-container" };
981
912
  function _sfc_render$3(_ctx, _cache) {
@@ -1018,7 +949,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1018
949
  setup(__props) {
1019
950
  const { t } = useLocale();
1020
951
  const size = useModel(__props, "size");
1021
- size.value = size.value ?? "default";
952
+ const currentSize = computed(() => size.value ?? "default");
1022
953
  const items = computed(() => [
1023
954
  { label: t("table.sizeDefault"), key: "default" },
1024
955
  { label: t("table.sizeMiddle"), key: "large" },
@@ -1036,7 +967,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1036
967
  return openBlock(), createBlock(unref(ElDropdownItem), {
1037
968
  key: item.key,
1038
969
  command: item.key,
1039
- disabled: item.key === size.value
970
+ disabled: item.key === currentSize.value
1040
971
  }, {
1041
972
  default: withCtx(() => [
1042
973
  createTextVNode(toDisplayString(item.label), 1)
@@ -1064,7 +995,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1064
995
  };
1065
996
  }
1066
997
  });
1067
- const SizeControl = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-b114045c"]]);
998
+ const SizeControl = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-e31e9c15"]]);
1068
999
  const _sfc_main$4 = {};
1069
1000
  const _hoisted_1$1 = {
1070
1001
  focusable: "false",
@@ -1085,32 +1016,33 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1085
1016
  __name: "ColumnControl",
1086
1017
  props: {
1087
1018
  columns: {},
1088
- table: { default: () => void 0 },
1089
- columnControl: { default: () => void 0 }
1019
+ table: { default: void 0 },
1020
+ columnControl: { default: void 0 }
1090
1021
  },
1091
1022
  setup(__props) {
1023
+ const props = __props;
1092
1024
  const { t } = useLocale();
1093
- const open = ref(false);
1094
1025
  const checkAll = ref(false);
1095
1026
  const indeterminate = ref(false);
1096
1027
  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);
1028
+ const rawKey = column.key ?? column.prop;
1029
+ if (rawKey === void 0 || rawKey === null) return `__col_${index2}`;
1030
+ return normalizePathKey(rawKey);
1100
1031
  };
1101
1032
  const checkedColumnsOptions = computed(
1102
- () => __props.columns.map((item, index2) => {
1103
- var _a, _b, _c, _d;
1033
+ () => props.columns.map((item, index2) => {
1034
+ var _a, _b, _c, _d, _e, _f;
1104
1035
  const key = getColumnKey(item, index2);
1105
- const excluded = (_b = (_a = __props.columnControl) == null ? void 0 : _a.excludedKeys) == null ? void 0 : _b.some(
1036
+ const excluded = (_b = (_a = props.columnControl) == null ? void 0 : _a.excludedKeys) == null ? void 0 : _b.some(
1106
1037
  (ek) => String(ek) === key
1107
1038
  );
1108
- const disabled = (_d = (_c = __props.columnControl) == null ? void 0 : _c.disabledKeys) == null ? void 0 : _d.some(
1039
+ const disabled = (_d = (_c = props.columnControl) == null ? void 0 : _c.disabledKeys) == null ? void 0 : _d.some(
1109
1040
  (dk) => String(dk) === key
1110
1041
  );
1111
- const label = String(
1112
- item.label ?? item.title ?? item.prop ?? t("table.columnFallback", { index: index2 + 1 })
1113
- );
1042
+ const rawTitle = item.label ?? item.title;
1043
+ const titleLabel = typeof rawTitle === "string" ? rawTitle : void 0;
1044
+ const propLabel = item.prop !== void 0 && item.prop !== null ? String(item.prop) : void 0;
1045
+ const label = ((_f = (_e = props.columnControl) == null ? void 0 : _e.labels) == null ? void 0 : _f[key]) ?? titleLabel ?? propLabel ?? key ?? t("table.columnFallback", { index: index2 + 1 });
1114
1046
  return {
1115
1047
  label,
1116
1048
  value: key,
@@ -1134,7 +1066,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1134
1066
  checkedColumnsOptions.value.forEach((item) => {
1135
1067
  var _a;
1136
1068
  if (item.disabled) return;
1137
- (_a = __props.table) == null ? void 0 : _a.setColumn(item.value, {
1069
+ (_a = props.table) == null ? void 0 : _a.setColumn(item.value, {
1138
1070
  hidden: !val.includes(item.value)
1139
1071
  });
1140
1072
  });
@@ -1144,7 +1076,6 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1144
1076
  var _a;
1145
1077
  const checked = !!(((_a = value == null ? void 0 : value.target) == null ? void 0 : _a.checked) ?? value);
1146
1078
  checkedColumnKeys.value = checked ? controllableOptions.value.map((item) => item.value) : [];
1147
- indeterminate.value = false;
1148
1079
  };
1149
1080
  const toggleColumnsItem = (val) => {
1150
1081
  const item = checkedColumnsOptions.value.find((o) => o.value === val);
@@ -1168,39 +1099,30 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1168
1099
  },
1169
1100
  { immediate: true }
1170
1101
  );
1171
- onMounted(() => {
1172
- var _a, _b;
1173
- (_b = (_a = __props.columnControl) == null ? void 0 : _a.disabledKeys) == null ? void 0 : _b.forEach((key) => {
1174
- var _a2;
1175
- (_a2 = __props.table) == null ? void 0 : _a2.setColumn(String(key), { hidden: false });
1176
- });
1177
- });
1178
1102
  watch(
1179
1103
  () => {
1180
1104
  var _a;
1181
- return (_a = __props.columnControl) == null ? void 0 : _a.disabledKeys;
1105
+ return (_a = props.columnControl) == null ? void 0 : _a.disabledKeys;
1182
1106
  },
1183
1107
  (keys) => {
1184
1108
  keys == null ? void 0 : keys.forEach((key) => {
1185
1109
  var _a;
1186
- (_a = __props.table) == null ? void 0 : _a.setColumn(String(key), { hidden: false });
1110
+ (_a = props.table) == null ? void 0 : _a.setColumn(String(key), { hidden: false });
1187
1111
  });
1188
1112
  },
1189
- { deep: true }
1113
+ { immediate: true, deep: true }
1190
1114
  );
1191
1115
  return (_ctx, _cache) => {
1192
1116
  return openBlock(), createBlock(unref(ElDropdown), {
1193
1117
  trigger: "click",
1194
- "hide-on-click": false,
1195
- visible: open.value,
1196
- onVisibleChange: _cache[0] || (_cache[0] = (val) => open.value = val)
1118
+ "hide-on-click": false
1197
1119
  }, {
1198
1120
  dropdown: withCtx(() => [
1199
1121
  createVNode(unref(ElDropdownMenu), null, {
1200
1122
  default: withCtx(() => {
1201
1123
  var _a;
1202
1124
  return [
1203
- !((_a = __props.columnControl) == null ? void 0 : _a.disableCheckAll) ? (openBlock(), createBlock(unref(ElDropdownItem), {
1125
+ !((_a = props.columnControl) == null ? void 0 : _a.disableCheckAll) ? (openBlock(), createBlock(unref(ElDropdownItem), {
1204
1126
  key: 0,
1205
1127
  disabled: true,
1206
1128
  divided: false
@@ -1256,39 +1178,41 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1256
1178
  })
1257
1179
  ]),
1258
1180
  _: 1
1259
- }, 8, ["visible"]);
1181
+ });
1260
1182
  };
1261
1183
  }
1262
1184
  });
1263
- const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-97c582f9"]]);
1185
+ const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-92c3fe41"]]);
1264
1186
  const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1265
1187
  ...{ name: "TableColumnRenderer" },
1266
1188
  __name: "TableColumnRenderer",
1267
1189
  props: {
1268
- columns: {}
1190
+ columns: { default: () => [] }
1269
1191
  },
1270
1192
  setup(__props) {
1193
+ const props = __props;
1271
1194
  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);
1195
+ const rawKey = column.key ?? column.prop;
1196
+ if (rawKey === void 0 || rawKey === null) return `__col_${index2}`;
1197
+ return normalizePathKey(rawKey);
1275
1198
  };
1276
1199
  const getCellValue = (row, column) => {
1277
1200
  const path = column.prop;
1278
1201
  if (!path) return void 0;
1279
- return get(row, toPath(path));
1202
+ return get(row, path);
1280
1203
  };
1281
1204
  const normalizedColumns = computed(() => {
1282
- return __props.columns.filter((column) => !column.hidden);
1205
+ return props.columns.filter((column) => !column.hidden);
1283
1206
  });
1284
1207
  const getColumnProps = (column) => {
1285
1208
  const { hidden, render, key, children, ...rest } = column;
1286
- const prop = column.prop ? String(column.prop) : void 0;
1209
+ const prop = column.prop ? normalizePathKey(column.prop) : void 0;
1210
+ const columnKey = key ? normalizePathKey(key) : prop;
1287
1211
  return {
1288
1212
  ...rest,
1289
1213
  label: column.label ?? column.title,
1290
1214
  prop,
1291
- columnKey: key ? String(key) : prop
1215
+ columnKey
1292
1216
  };
1293
1217
  };
1294
1218
  return (_ctx, _cache) => {
@@ -1314,13 +1238,13 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1314
1238
  default: withCtx((scope) => {
1315
1239
  var _a;
1316
1240
  return [
1317
- (openBlock(), createBlock(resolveDynamicComponent(
1318
- (_a = column.render) == null ? void 0 : _a.call(column, {
1241
+ createVNode(unref(_sfc_main$c), {
1242
+ component: (_a = column.render) == null ? void 0 : _a.call(column, {
1319
1243
  ...scope,
1320
1244
  column,
1321
1245
  cellValue: getCellValue(scope.row, column)
1322
1246
  })
1323
- )))
1247
+ }, null, 8, ["component"])
1324
1248
  ];
1325
1249
  }),
1326
1250
  _: 2
@@ -1351,19 +1275,25 @@ const _hoisted_5 = {
1351
1275
  class: "pro-table_header_column-control"
1352
1276
  };
1353
1277
  const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1354
- ...{ name: "ProTable", inheritAttrs: false },
1278
+ ...{
1279
+ name: "ProTable",
1280
+ directives: {
1281
+ loading: ElLoading.directive
1282
+ },
1283
+ inheritAttrs: false
1284
+ },
1355
1285
  __name: "ProTable",
1356
1286
  props: /* @__PURE__ */ mergeModels({
1357
- table: { default: () => void 0 },
1287
+ table: { default: void 0 },
1358
1288
  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 },
1289
+ addIndexColumn: { type: Boolean, default: void 0 },
1290
+ immediateSearch: { type: Boolean, default: void 0 },
1291
+ control: { type: [Boolean, Object], default: void 0 },
1292
+ searchFormConfig: { default: void 0 },
1363
1293
  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 },
1294
+ columns: { default: void 0 },
1295
+ data: { default: void 0 },
1296
+ pagination: { type: [Boolean, Object], default: void 0 },
1367
1297
  size: {},
1368
1298
  width: {},
1369
1299
  height: {},
@@ -1371,61 +1301,63 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1371
1301
  fit: { type: Boolean },
1372
1302
  stripe: { type: Boolean },
1373
1303
  border: { type: Boolean },
1374
- rowKey: { type: [String, Function] },
1304
+ rowKey: {},
1375
1305
  context: {},
1376
1306
  showHeader: { type: Boolean },
1377
1307
  showSummary: { type: Boolean },
1378
1308
  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] },
1309
+ summaryMethod: {},
1310
+ rowClassName: {},
1311
+ rowStyle: {},
1312
+ cellClassName: {},
1313
+ cellStyle: {},
1314
+ headerRowClassName: {},
1315
+ headerRowStyle: {},
1316
+ headerCellClassName: {},
1317
+ headerCellStyle: {},
1388
1318
  highlightCurrentRow: { type: Boolean },
1389
1319
  currentRowKey: {},
1390
1320
  emptyText: {},
1391
1321
  expandRowKeys: {},
1392
1322
  defaultExpandAll: { type: Boolean },
1393
- rowExpandable: { type: Function },
1323
+ rowExpandable: {},
1394
1324
  defaultSort: {},
1395
1325
  tooltipEffect: {},
1396
1326
  tooltipOptions: {},
1397
- spanMethod: { type: Function },
1327
+ spanMethod: {},
1398
1328
  selectOnIndeterminate: { type: Boolean },
1399
1329
  indent: {},
1400
1330
  treeProps: {},
1401
1331
  lazy: { type: Boolean },
1402
- load: { type: Function },
1332
+ load: {},
1403
1333
  className: {},
1404
1334
  style: { type: [Boolean, null, String, Object, Array] },
1405
1335
  tableLayout: {},
1406
1336
  scrollbarAlwaysOn: { type: Boolean },
1407
1337
  flexible: { type: Boolean },
1408
1338
  showOverflowTooltip: { type: [Boolean, Object] },
1409
- tooltipFormatter: { type: Function },
1339
+ tooltipFormatter: {},
1410
1340
  appendFilterPanelTo: {},
1411
1341
  scrollbarTabindex: {},
1412
1342
  nativeScrollbar: { type: Boolean }
1413
1343
  }, {
1414
1344
  "size": {},
1415
1345
  "sizeModifiers": {},
1416
- "loading": { type: Boolean },
1346
+ "loading": { type: Boolean, ...{ default: false } },
1417
1347
  "loadingModifiers": {}
1418
1348
  }),
1419
1349
  emits: ["update:size", "update:loading"],
1420
- setup(__props) {
1421
- const { t } = useLocale();
1422
- const config = INJECT_CONFIG["pro-table"];
1423
- const injectProps = inject(config.injectionKey, config.default);
1350
+ setup(__props, { expose: __expose }) {
1424
1351
  const tableProperties = Object.keys(tableProps());
1425
1352
  const paginationProperties = Object.keys(paginationProps());
1353
+ const props = __props;
1354
+ const { t } = useLocale();
1355
+ const config = INJECT_CONFIG["pro-table"];
1356
+ const injectPropsRaw = inject(config.injectionKey, config.default);
1357
+ const injectProps = computed(() => toValue(injectPropsRaw) || {});
1426
1358
  const attrs = useAttrs();
1427
1359
  const injectTableAttrs = computed(() => {
1428
- return pick(injectProps, tableProperties);
1360
+ return pick(injectProps.value, tableProperties);
1429
1361
  });
1430
1362
  const attrsTableProps = computed(() => {
1431
1363
  return pick(
@@ -1433,73 +1365,76 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1433
1365
  tableProperties
1434
1366
  );
1435
1367
  });
1436
- const {
1437
- columns: tableColumns,
1438
- data: tableData,
1439
- searchForm,
1440
- pageParam,
1441
- setPageParam
1442
- } = __props.table || {};
1443
1368
  const size = useModel(__props, "size");
1444
1369
  const loading = useModel(__props, "loading");
1370
+ let searchSequence = 0;
1445
1371
  const _search = async () => {
1446
1372
  var _a;
1373
+ const seq = ++searchSequence;
1374
+ const searchPromise = (_a = props.search || attrs.onSearch) == null ? void 0 : _a();
1375
+ if (!isPromise(searchPromise)) return;
1376
+ loading.value = true;
1447
1377
  try {
1448
- loading.value = true;
1449
- await ((_a = __props.search) == null ? void 0 : _a.call(__props));
1378
+ await searchPromise;
1450
1379
  } finally {
1451
- loading.value = false;
1380
+ if (seq === searchSequence) {
1381
+ loading.value = false;
1382
+ }
1452
1383
  }
1453
1384
  };
1454
1385
  const reset = () => {
1455
- var _a;
1456
- (_a = __props.table) == null ? void 0 : _a.resetQueryParams();
1386
+ var _a, _b;
1387
+ (_b = (_a = props.table) == null ? void 0 : _a.resetQueryParams) == null ? void 0 : _b.call(_a);
1457
1388
  nextTick(() => {
1458
1389
  _search();
1459
1390
  });
1460
1391
  };
1392
+ const customSlotNames = [
1393
+ "search-form",
1394
+ "button-bar",
1395
+ "toolbar",
1396
+ "table"
1397
+ ];
1461
1398
  const slots = useSlots();
1462
- const searchFormSlot = slots["search-form"];
1463
- const buttonBarSlot = slots["button-bar"];
1464
- const toolbarSlot = slots["toolbar"];
1465
- const tableSlots = computed(() => {
1466
- const customNames = /* @__PURE__ */ new Set([
1467
- "search-form",
1468
- "button-bar",
1469
- "toolbar",
1470
- "table"
1471
- ]);
1472
- return Object.fromEntries(
1473
- Object.entries(slots).filter(([name]) => !customNames.has(name))
1474
- );
1475
- });
1476
- const tableSlotNames = computed(() => Object.keys(tableSlots.value));
1399
+ const forwardedSlotNames = () => Object.keys(slots).filter((name) => !customSlotNames.includes(name));
1477
1400
  const searchPage1st = () => {
1478
- setPageParam == null ? void 0 : setPageParam({ current: 1 });
1401
+ var _a, _b;
1402
+ (_b = (_a = props.table) == null ? void 0 : _a.setPageParam) == null ? void 0 : _b.call(_a, { current: 1 });
1479
1403
  _search();
1480
1404
  };
1481
1405
  const computedSearchFormConfig = computed(() => {
1482
1406
  var _a, _b;
1483
- const container = ((_a = __props.searchFormConfig) == null ? void 0 : _a.container) ?? ((_b = injectProps.searchFormConfig) == null ? void 0 : _b.container) ?? DefaultSearchFormContainer;
1407
+ const container = ((_a = props.searchFormConfig) == null ? void 0 : _a.container) ?? ((_b = injectProps.value.searchFormConfig) == null ? void 0 : _b.container) ?? DefaultSearchFormContainer;
1484
1408
  return {
1485
- ...injectProps.searchFormConfig,
1486
- ...getObject(__props.searchFormConfig),
1409
+ ...injectProps.value.searchFormConfig,
1410
+ ...getObject(props.searchFormConfig),
1487
1411
  container: container ? container : void 0
1488
1412
  };
1489
1413
  });
1490
1414
  const computedTableContainer = computed(() => {
1491
- const container = __props.tableContainer ?? injectProps.tableContainer ?? DefaultTableContainer;
1415
+ const container = props.tableContainer ?? injectProps.value.tableContainer ?? DefaultTableContainer;
1492
1416
  return container ? container : void 0;
1493
1417
  });
1418
+ const getIndex = (i) => {
1419
+ var _a;
1420
+ if (((_a = props.table) == null ? void 0 : _a.pageParam) && computedPagination.value !== false) {
1421
+ const current = props.table.pageParam.current ?? 1;
1422
+ const pageSize = props.table.pageParam.pageSize ?? 10;
1423
+ return (current - 1) * pageSize + i + 1;
1424
+ }
1425
+ return i + 1;
1426
+ };
1494
1427
  const normalizedRawColumns = computed(() => {
1495
- const source = __props.columns ?? (tableColumns == null ? void 0 : tableColumns.value) ?? [];
1496
- if (__props.addIndexColumn ?? injectProps.addIndexColumn) {
1428
+ var _a;
1429
+ const source = props.columns ?? toValue((_a = props.table) == null ? void 0 : _a.columns) ?? [];
1430
+ if (props.addIndexColumn ?? injectProps.value.addIndexColumn) {
1497
1431
  return [
1498
1432
  {
1499
1433
  key: "_index",
1500
1434
  type: "index",
1501
1435
  label: t("table.index"),
1502
- width: 80
1436
+ width: 80,
1437
+ index: getIndex
1503
1438
  },
1504
1439
  ...source
1505
1440
  ];
@@ -1507,8 +1442,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1507
1442
  return source;
1508
1443
  });
1509
1444
  const computedDataSource = computed(() => {
1445
+ var _a, _b;
1510
1446
  const attrsData = attrsTableProps.value.data;
1511
- return __props.data ?? attrsData ?? (tableData == null ? void 0 : tableData.value) ?? [];
1447
+ return props.data ?? attrsData ?? toValue((_a = props.table) == null ? void 0 : _a.dataSource) ?? toValue((_b = props.table) == null ? void 0 : _b.data) ?? [];
1512
1448
  });
1513
1449
  const computedTableProps = computed(() => {
1514
1450
  const merged = {
@@ -1519,41 +1455,62 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1519
1455
  return merged;
1520
1456
  });
1521
1457
  const computedPagination = computed(() => {
1522
- if (__props.pagination === false) return false;
1523
- const pageConfig = __props.pagination ?? {};
1458
+ var _a, _b;
1459
+ const attrsPagination = attrsTableProps.value.pagination;
1460
+ if (props.pagination === false || attrsPagination === false) {
1461
+ return false;
1462
+ }
1463
+ const hasUserPagination = isPlainObject(props.pagination) || isPlainObject(attrsPagination);
1464
+ if (hasUserPagination) {
1465
+ const pageConfig = props.pagination ?? attrsPagination ?? {};
1466
+ const globalPagination = injectProps.value.pagination === false ? {} : injectProps.value.pagination || {};
1467
+ const pageParam2 = (_a = props.table) == null ? void 0 : _a.pageParam;
1468
+ return {
1469
+ ...globalPagination,
1470
+ ...pick(pageConfig, paginationProperties),
1471
+ currentPage: (pageParam2 == null ? void 0 : pageParam2.current) ?? pageConfig.currentPage ?? 1,
1472
+ pageSize: (pageParam2 == null ? void 0 : pageParam2.pageSize) ?? pageConfig.pageSize ?? 10,
1473
+ total: (pageParam2 == null ? void 0 : pageParam2.total) ?? pageConfig.total ?? 0
1474
+ };
1475
+ }
1476
+ if (injectProps.value.pagination === false) return false;
1477
+ const pageParam = (_b = props.table) == null ? void 0 : _b.pageParam;
1524
1478
  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
1479
+ ...injectProps.value.pagination,
1480
+ currentPage: (pageParam == null ? void 0 : pageParam.current) ?? 1,
1481
+ pageSize: (pageParam == null ? void 0 : pageParam.pageSize) ?? 10,
1482
+ total: (pageParam == null ? void 0 : pageParam.total) ?? 0
1530
1483
  };
1531
1484
  });
1532
1485
  const showPagination = computed(() => computedPagination.value !== false);
1533
1486
  const onCurrentChange = (current) => {
1534
- setPageParam == null ? void 0 : setPageParam({ current });
1487
+ var _a, _b;
1488
+ (_b = (_a = props.table) == null ? void 0 : _a.setPageParam) == null ? void 0 : _b.call(_a, { current });
1535
1489
  _search();
1536
1490
  };
1537
1491
  const onSizeChange = (pageSize) => {
1538
- setPageParam == null ? void 0 : setPageParam({ pageSize, current: 1 });
1492
+ var _a, _b;
1493
+ (_b = (_a = props.table) == null ? void 0 : _a.setPageParam) == null ? void 0 : _b.call(_a, { pageSize, current: 1 });
1539
1494
  _search();
1540
1495
  };
1541
1496
  const onPaginationChange = (currentPage, pageSize) => {
1542
1497
  var _a;
1543
1498
  (_a = attrs.onChange) == null ? void 0 : _a.call(attrs, currentPage, pageSize);
1544
1499
  };
1545
- 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);
1500
+ const searchFormVisible = computed(() => {
1501
+ var _a, _b, _c, _d, _e;
1502
+ const searchFields = (_b = (_a = props.table) == null ? void 0 : _a.searchForm) == null ? void 0 : _b.fields;
1503
+ const fieldList = (Array.isArray(searchFields) ? searchFields : searchFields == null ? void 0 : searchFields.value) ?? [];
1504
+ return !!(((_c = computedSearchFormConfig.value) == null ? void 0 : _c.hidden) !== true && ((_d = props.table) == null ? void 0 : _d.searchForm) && ((_e = fieldList.filter((item) => !toValue(item.hidden))) == null ? void 0 : _e.length) > 0);
1548
1505
  });
1549
1506
  const computedControl = computed(() => {
1550
- const mergedControl = __props.control ?? injectProps.control;
1507
+ const mergedControl = props.control ?? injectProps.value.control;
1551
1508
  if (typeof mergedControl === "boolean") {
1552
1509
  return { sizeControl: mergedControl, columnControl: mergedControl };
1553
1510
  }
1554
1511
  const c = mergedControl;
1555
- const sizeControl = c.sizeControl ?? true;
1556
- const columnControl = c.columnControl ?? true;
1512
+ const sizeControl = (c == null ? void 0 : c.sizeControl) ?? false;
1513
+ const columnControl = (c == null ? void 0 : c.columnControl) ?? false;
1557
1514
  return { sizeControl: !!sizeControl, columnControl };
1558
1515
  });
1559
1516
  const columnControlConfig = computed(() => {
@@ -1564,40 +1521,47 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1564
1521
  return size.value ?? attrsTableProps.value.size ?? injectTableAttrs.value.size;
1565
1522
  });
1566
1523
  onMounted(() => {
1567
- if (__props.immediateSearch ?? injectProps.immediateSearch) {
1524
+ if (props.immediateSearch ?? injectProps.value.immediateSearch) {
1568
1525
  _search();
1569
1526
  }
1570
1527
  });
1528
+ __expose({
1529
+ /** 手动触发一次查询(与内部搜索共用 loading 竞态守卫),便于外部刷新列表 */
1530
+ search: _search
1531
+ });
1571
1532
  return (_ctx, _cache) => {
1572
1533
  const _directive_loading = resolveDirective("loading");
1573
1534
  return openBlock(), createElementBlock("div", {
1574
1535
  class: normalizeClass(["pro-table", unref(attrs).class]),
1575
1536
  style: normalizeStyle(unref(attrs).style)
1576
1537
  }, [
1577
- showSearch.value ? (openBlock(), createBlock(unref(_sfc_main$d), {
1538
+ searchFormVisible.value || _ctx.$slots["search-form"] ? (openBlock(), createBlock(unref(_sfc_main$d), {
1578
1539
  key: 0,
1579
1540
  component: computedSearchFormConfig.value.container
1580
1541
  }, {
1581
1542
  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)
1543
+ renderSlot(_ctx.$slots, "search-form", {}, () => {
1544
+ var _a;
1545
+ return [
1546
+ ((_a = props.table) == null ? void 0 : _a.searchForm) ? (openBlock(), createBlock(SearchForm, mergeProps({
1547
+ key: 0,
1548
+ form: props.table.searchForm
1549
+ }, computedSearchFormConfig.value, {
1550
+ onSearch: searchPage1st,
1551
+ onReset: reset
1552
+ }), null, 16, ["form"])) : createCommentVNode("", true)
1553
+ ];
1554
+ }, true)
1591
1555
  ]),
1592
1556
  _: 3
1593
1557
  }, 8, ["component"])) : createCommentVNode("", true),
1594
1558
  createVNode(unref(_sfc_main$d), { component: computedTableContainer.value }, {
1595
1559
  default: withCtx(() => [
1596
1560
  createElementVNode("div", _hoisted_1, [
1597
- unref(buttonBarSlot) ? (openBlock(), createElementBlock("div", _hoisted_2, [
1561
+ _ctx.$slots["button-bar"] ? (openBlock(), createElementBlock("div", _hoisted_2, [
1598
1562
  renderSlot(_ctx.$slots, "button-bar", {}, void 0, true)
1599
1563
  ])) : createCommentVNode("", true),
1600
- unref(toolbarSlot) ? (openBlock(), createElementBlock("div", _hoisted_3, [
1564
+ _ctx.$slots["toolbar"] ? (openBlock(), createElementBlock("div", _hoisted_3, [
1601
1565
  renderSlot(_ctx.$slots, "toolbar", {}, void 0, true)
1602
1566
  ])) : createCommentVNode("", true),
1603
1567
  computedControl.value.sizeControl ? (openBlock(), createElementBlock("div", _hoisted_4, [
@@ -1609,7 +1573,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1609
1573
  computedControl.value.columnControl ? (openBlock(), createElementBlock("div", _hoisted_5, [
1610
1574
  createVNode(unref(ColumnControl), {
1611
1575
  columns: normalizedRawColumns.value.filter((item) => item.key !== "_index"),
1612
- table: __props.table,
1576
+ table: props.table,
1613
1577
  "column-control": columnControlConfig.value
1614
1578
  }, null, 8, ["columns", "table", "column-control"])
1615
1579
  ])) : createCommentVNode("", true)
@@ -1624,7 +1588,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1624
1588
  ]),
1625
1589
  _: 2
1626
1590
  }, [
1627
- renderList(tableSlotNames.value, (name) => {
1591
+ renderList(forwardedSlotNames(), (name) => {
1628
1592
  return {
1629
1593
  name,
1630
1594
  fn: withCtx((scoped) => [
@@ -1651,7 +1615,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1651
1615
  };
1652
1616
  }
1653
1617
  });
1654
- const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-127db81d"]]);
1618
+ const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-e9641e7c"]]);
1655
1619
  function useTable(params = {}) {
1656
1620
  const { data, columns, ...rest } = params;
1657
1621
  const coreTable = useTable$1({
@@ -1673,21 +1637,48 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1673
1637
  },
1674
1638
  __name: "index",
1675
1639
  props: {
1676
- componentVars: {},
1677
- componentMap: {},
1678
- locale: {}
1640
+ componentVars: { default: void 0 },
1641
+ componentMap: { default: void 0 },
1642
+ locale: { default: void 0 }
1679
1643
  },
1680
1644
  setup(__props) {
1681
1645
  const props = __props;
1646
+ Object.keys(INJECT_CONFIG).forEach(
1647
+ (key) => {
1648
+ const config = INJECT_CONFIG[key];
1649
+ provide(
1650
+ config.injectionKey,
1651
+ computed(() => {
1652
+ var _a;
1653
+ return {
1654
+ ...config.default,
1655
+ ...getObject((_a = props.componentVars) == null ? void 0 : _a[key])
1656
+ };
1657
+ })
1658
+ );
1659
+ }
1660
+ );
1682
1661
  if (props.componentVars) {
1683
- Object.entries(props.componentVars).forEach(([key, val]) => {
1684
- const config = ensureInjectConfig(key);
1685
- provide(config.injectionKey, { ...config.default, ...getObject(val) });
1662
+ Object.keys(props.componentVars).forEach((key) => {
1663
+ if (!(key in INJECT_CONFIG)) {
1664
+ const config = ensureInjectConfig(key);
1665
+ provide(
1666
+ config.injectionKey,
1667
+ computed(() => {
1668
+ var _a;
1669
+ return {
1670
+ ...config.default,
1671
+ ...getObject((_a = props.componentVars) == null ? void 0 : _a[key])
1672
+ };
1673
+ })
1674
+ );
1675
+ }
1686
1676
  });
1687
1677
  }
1688
- if (props.componentMap) {
1689
- provide(INJECT_COMPONENTS, props.componentMap);
1690
- }
1678
+ provide(
1679
+ INJECT_COMPONENTS,
1680
+ computed(() => props.componentMap)
1681
+ );
1691
1682
  provide(
1692
1683
  LOCALE_INJECT_KEY,
1693
1684
  computed(() => props.locale)