@qin-ui/element-plus-pro 1.2.3 → 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 (177) 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 +478 -358
  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/{components → src/components}/form/constants/index.d.ts +1 -1
  47. package/es/src/components/form/constants/index.d.ts.map +1 -0
  48. package/es/src/components/form/hooks/index.d.ts.map +1 -0
  49. package/es/src/components/form/hooks/useFields.d.ts.map +1 -0
  50. package/es/src/components/form/hooks/useForm.d.ts.map +1 -0
  51. package/es/src/components/form/hooks/useFormRef.d.ts.map +1 -0
  52. package/es/src/components/form/hooks/useGroupFieldAttrs.d.ts +18 -0
  53. package/es/src/components/form/hooks/useGroupFieldAttrs.d.ts.map +1 -0
  54. package/es/src/components/form/index.d.ts.map +1 -0
  55. package/es/{components → src/components}/form/types/index.d.ts +26 -2
  56. package/es/src/components/form/types/index.d.ts.map +1 -0
  57. package/es/{components → src/components}/table/components/ColumnControl.vue.d.ts +4 -1
  58. package/es/src/components/table/components/ColumnControl.vue.d.ts.map +1 -0
  59. package/es/src/components/table/components/DefaultSearchFormContainer.vue.d.ts.map +1 -0
  60. package/es/src/components/table/components/DefaultTableContainer.vue.d.ts.map +1 -0
  61. package/es/src/components/table/components/ProTable.vue.d.ts.map +1 -0
  62. package/es/{components → src/components}/table/components/SearchForm.vue.d.ts +14 -4
  63. package/es/src/components/table/components/SearchForm.vue.d.ts.map +1 -0
  64. package/es/src/components/table/components/SizeControl.vue.d.ts.map +1 -0
  65. package/es/src/components/table/components/TableColumnRenderer.vue.d.ts.map +1 -0
  66. package/es/src/components/table/components/icons/ColumnHeightOutlined.vue.d.ts.map +1 -0
  67. package/es/src/components/table/components/icons/DownOutlined.vue.d.ts.map +1 -0
  68. package/es/src/components/table/components/icons/FilterOutlined.vue.d.ts.map +1 -0
  69. package/es/src/components/table/components/index.d.ts.map +1 -0
  70. package/es/src/components/table/index.d.ts.map +1 -0
  71. package/es/src/components/table/types/index.d.ts.map +1 -0
  72. package/es/src/components/table/useTable.d.ts.map +1 -0
  73. package/es/{index.d.ts → src/index.d.ts} +1 -1
  74. package/es/src/index.d.ts.map +1 -0
  75. package/es/src/locale/en-US.d.ts.map +1 -0
  76. package/es/src/locale/index.d.ts.map +1 -0
  77. package/es/src/locale/zh-CN.d.ts.map +1 -0
  78. package/es/src/locale/zh-TW.d.ts.map +1 -0
  79. package/es/src/shared/core/index.d.ts +6 -0
  80. package/es/src/shared/core/index.d.ts.map +1 -0
  81. package/es/{shared → src/shared}/ui/index.d.ts +2 -0
  82. package/es/src/shared/ui/index.d.ts.map +1 -0
  83. package/package.json +8 -3
  84. package/src/components/component-provider/components/index.vue +37 -8
  85. package/src/components/component-provider/constants/index.ts +2 -2
  86. package/src/components/component-provider/types/index.ts +9 -5
  87. package/src/components/form/components/BaseField/index.vue +67 -35
  88. package/src/components/form/components/BaseField/utils/index.ts +6 -11
  89. package/src/components/form/components/BaseFormItem/index.vue +87 -100
  90. package/src/components/form/components/ProForm/index.vue +72 -18
  91. package/src/components/form/constants/index.ts +1 -5
  92. package/src/components/form/hooks/useGroupFieldAttrs.ts +123 -0
  93. package/src/components/form/types/index.ts +26 -2
  94. package/src/components/table/components/ColumnControl.vue +18 -24
  95. package/src/components/table/components/ProTable.vue +112 -57
  96. package/src/components/table/components/SearchForm.vue +85 -60
  97. package/src/components/table/components/SizeControl.vue +2 -2
  98. package/src/components/table/components/TableColumnRenderer.vue +12 -9
  99. package/src/components/table/useTable.ts +12 -7
  100. package/src/index.ts +1 -1
  101. package/src/locale/index.ts +6 -2
  102. package/src/shared/core/index.ts +4 -3
  103. package/src/shared/ui/index.ts +11 -5
  104. package/es/components/component-provider/components/index.vue.d.ts.map +0 -1
  105. package/es/components/component-provider/constants/index.d.ts.map +0 -1
  106. package/es/components/component-provider/index.d.ts.map +0 -1
  107. package/es/components/component-provider/types/index.d.ts.map +0 -1
  108. package/es/components/form/components/BaseField/index.vue.d.ts.map +0 -1
  109. package/es/components/form/components/BaseField/utils/index.d.ts +0 -5
  110. package/es/components/form/components/BaseField/utils/index.d.ts.map +0 -1
  111. package/es/components/form/components/BaseFormItem/index.vue.d.ts.map +0 -1
  112. package/es/components/form/components/ContainerFragment/index.vue.d.ts.map +0 -1
  113. package/es/components/form/components/GroupedFieldAttrs/index.vue.d.ts +0 -31
  114. package/es/components/form/components/GroupedFieldAttrs/index.vue.d.ts.map +0 -1
  115. package/es/components/form/components/PathProvider/index.vue.d.ts +0 -24
  116. package/es/components/form/components/PathProvider/index.vue.d.ts.map +0 -1
  117. package/es/components/form/components/ProForm/index.vue.d.ts.map +0 -1
  118. package/es/components/form/components/SlotComponent/index.vue.d.ts.map +0 -1
  119. package/es/components/form/components/index.d.ts.map +0 -1
  120. package/es/components/form/constants/index.d.ts.map +0 -1
  121. package/es/components/form/hooks/index.d.ts.map +0 -1
  122. package/es/components/form/hooks/useFields.d.ts.map +0 -1
  123. package/es/components/form/hooks/useForm.d.ts.map +0 -1
  124. package/es/components/form/hooks/useFormRef.d.ts.map +0 -1
  125. package/es/components/form/index.d.ts.map +0 -1
  126. package/es/components/form/types/index.d.ts.map +0 -1
  127. package/es/components/table/components/ColumnControl.vue.d.ts.map +0 -1
  128. package/es/components/table/components/DefaultSearchFormContainer.vue.d.ts.map +0 -1
  129. package/es/components/table/components/DefaultTableContainer.vue.d.ts.map +0 -1
  130. package/es/components/table/components/ProTable.vue.d.ts.map +0 -1
  131. package/es/components/table/components/SearchForm.vue.d.ts.map +0 -1
  132. package/es/components/table/components/SizeControl.vue.d.ts.map +0 -1
  133. package/es/components/table/components/TableColumnRenderer.vue.d.ts.map +0 -1
  134. package/es/components/table/components/icons/ColumnHeightOutlined.vue.d.ts.map +0 -1
  135. package/es/components/table/components/icons/DownOutlined.vue.d.ts.map +0 -1
  136. package/es/components/table/components/icons/FilterOutlined.vue.d.ts.map +0 -1
  137. package/es/components/table/components/index.d.ts.map +0 -1
  138. package/es/components/table/index.d.ts.map +0 -1
  139. package/es/components/table/types/index.d.ts.map +0 -1
  140. package/es/components/table/useTable.d.ts.map +0 -1
  141. package/es/index.d.ts.map +0 -1
  142. package/es/locale/en-US.d.ts.map +0 -1
  143. package/es/locale/index.d.ts.map +0 -1
  144. package/es/locale/zh-CN.d.ts.map +0 -1
  145. package/es/locale/zh-TW.d.ts.map +0 -1
  146. package/es/shared/core/index.d.ts +0 -6
  147. package/es/shared/core/index.d.ts.map +0 -1
  148. package/es/shared/ui/index.d.ts.map +0 -1
  149. package/src/components/form/components/GroupedFieldAttrs/index.vue +0 -115
  150. package/src/components/form/components/PathProvider/index.vue +0 -19
  151. /package/es/{components → src/components}/component-provider/constants/index.d.ts +0 -0
  152. /package/es/{components → src/components}/component-provider/index.d.ts +0 -0
  153. /package/es/{components → src/components}/form/components/ContainerFragment/index.vue.d.ts +0 -0
  154. /package/es/{components → src/components}/form/components/ProForm/index.vue.d.ts +0 -0
  155. /package/es/{components → src/components}/form/components/SlotComponent/index.vue.d.ts +0 -0
  156. /package/es/{components → src/components}/form/components/index.d.ts +0 -0
  157. /package/es/{components → src/components}/form/hooks/index.d.ts +0 -0
  158. /package/es/{components → src/components}/form/hooks/useFields.d.ts +0 -0
  159. /package/es/{components → src/components}/form/hooks/useForm.d.ts +0 -0
  160. /package/es/{components → src/components}/form/hooks/useFormRef.d.ts +0 -0
  161. /package/es/{components → src/components}/form/index.d.ts +0 -0
  162. /package/es/{components → src/components}/table/components/DefaultSearchFormContainer.vue.d.ts +0 -0
  163. /package/es/{components → src/components}/table/components/DefaultTableContainer.vue.d.ts +0 -0
  164. /package/es/{components → src/components}/table/components/ProTable.vue.d.ts +0 -0
  165. /package/es/{components → src/components}/table/components/SizeControl.vue.d.ts +0 -0
  166. /package/es/{components → src/components}/table/components/TableColumnRenderer.vue.d.ts +0 -0
  167. /package/es/{components → src/components}/table/components/icons/ColumnHeightOutlined.vue.d.ts +0 -0
  168. /package/es/{components → src/components}/table/components/icons/DownOutlined.vue.d.ts +0 -0
  169. /package/es/{components → src/components}/table/components/icons/FilterOutlined.vue.d.ts +0 -0
  170. /package/es/{components → src/components}/table/components/index.d.ts +0 -0
  171. /package/es/{components → src/components}/table/index.d.ts +0 -0
  172. /package/es/{components → src/components}/table/types/index.d.ts +0 -0
  173. /package/es/{components → src/components}/table/useTable.d.ts +0 -0
  174. /package/es/{locale → src/locale}/en-US.d.ts +0 -0
  175. /package/es/{locale → src/locale}/index.d.ts +0 -0
  176. /package/es/{locale → src/locale}/zh-CN.d.ts +0 -0
  177. /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, defineComponent, renderSlot, mergeProps, normalizeProps, guardReactiveProps, resolveComponent, createBlock, openBlock, unref, withCtx, createElementBlock, Fragment, renderList, createVNode, createSlots, ref, useAttrs, createCommentVNode, resolveDynamicComponent, isVNode, createTextVNode, toDisplayString, useSlots, reactive, withModifiers, createElementVNode, onBeforeUnmount, watch, watchEffect, withKeys, normalizeStyle, nextTick, useModel, onMounted, mergeModels, resolveDirective, normalizeClass, withDirectives } from "vue";
3
- import { ElFormItem, ElCol, ElTable, ElPagination, useFormDisabled, 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 { InjectionPathKey, 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,40 +202,22 @@ const componentMap = {
205
202
  "tree-select": ElTreeSelect,
206
203
  "transfer": ElTransfer
207
204
  };
208
- const _sfc_main$h = /* @__PURE__ */ defineComponent({
209
- __name: "index",
210
- props: {
211
- path: {}
212
- },
213
- setup(__props) {
214
- const props = __props;
215
- const namePath = computed(() => {
216
- return Array.isArray(props.path) ? props.path.join(".") : props.path;
217
- });
218
- provide(InjectionPathKey, namePath);
219
- return (_ctx, _cache) => {
220
- return renderSlot(_ctx.$slots, "default", { path: namePath.value });
221
- };
222
- }
223
- });
224
- const _sfc_main$g = /* @__PURE__ */ defineComponent({
225
- __name: "index",
226
- props: {
227
- field: {}
228
- },
229
- setup(__props) {
230
- const formItemPropKeys = Object.keys(formItemProps());
231
- const gridItemPropKeys = Object.keys(gridItemProps());
232
- const props = __props;
233
- const config = INJECT_CONFIG["pro-form-item"];
234
- const injectFormItemProps = inject(config.injectionKey, config.default);
235
- const groupedAttributes = computed(() => {
205
+ const formItemPropKeys = Object.keys(formItemProps()).filter(
206
+ (k) => k !== "disabled"
207
+ );
208
+ const gridItemPropKeys = Object.keys(gridItemProps());
209
+ function useGroupFieldAttrs(validFields) {
210
+ const config = INJECT_CONFIG["pro-form-item"];
211
+ const injectFormItemProps = inject(config.injectionKey, config.default);
212
+ return computed(() => {
213
+ const rawInjectProps = toValue(injectFormItemProps) || {};
214
+ return validFields.value.map((field) => {
236
215
  let gridItemProps2 = {};
237
216
  let formItemProps2 = {};
238
217
  const componentProps = { slots: {} };
239
218
  const formItemSlots = {};
240
- if (isPlainObject(props.field)) {
241
- const { path, name, fields, formItemClass, formItemStyle, formItemContainer, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, ...rest } = props.field;
219
+ if (isPlainObject(field)) {
220
+ const { path, name, fields, formItemClass, formItemStyle, formItemContainer, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, ...rest } = field;
242
221
  const {
243
222
  class: injectClassName,
244
223
  style: injectStyle,
@@ -250,7 +229,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
250
229
  lg,
251
230
  xl,
252
231
  ...injectRest
253
- } = injectFormItemProps;
232
+ } = rawInjectProps;
254
233
  const initGridItemProps = span || span === 0 ? { span } : { xs, sm, md, lg, xl, span: injectSpan };
255
234
  gridItemProps2 = fields ? { span: span ?? 24 } : initGridItemProps;
256
235
  formItemProps2 = mergeProps(
@@ -259,7 +238,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
259
238
  { class: toValue(formItemClass), style: toValue(formItemStyle) },
260
239
  formItemDataAttrs
261
240
  );
262
- formItemProps2.container = formItemContainer ?? injectFormItemContainer;
241
+ const container = formItemContainer ?? injectFormItemContainer;
263
242
  Object.keys(rest).forEach((k) => {
264
243
  if (gridItemPropKeys.includes(k)) {
265
244
  gridItemProps2[k] = rest[k];
@@ -274,137 +253,144 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
274
253
  if (FORM_ITEM_SLOT_KEYS.includes(k)) {
275
254
  formItemSlots[k] = slots[k];
276
255
  } else {
277
- componentProps["slots"][k] = slots[k];
256
+ componentProps.slots[k] = slots[k];
278
257
  }
279
258
  });
259
+ const raw2 = toValue(name) ?? toValue(path);
260
+ return {
261
+ path: Array.isArray(raw2) ? raw2.join(".") : raw2 || "",
262
+ gridItemProps: gridItemProps2,
263
+ formItemProps: formItemProps2,
264
+ formItemSlots,
265
+ componentProps,
266
+ container,
267
+ rawField: field
268
+ };
280
269
  }
281
- return { gridItemProps: gridItemProps2, formItemProps: formItemProps2, componentProps, formItemSlots };
270
+ const raw = toValue(field == null ? void 0 : field.name) ?? toValue(field == null ? void 0 : field.path);
271
+ return {
272
+ path: Array.isArray(raw) ? raw.join(".") : raw || "",
273
+ gridItemProps: gridItemProps2,
274
+ formItemProps: formItemProps2,
275
+ formItemSlots,
276
+ componentProps,
277
+ rawField: field
278
+ };
282
279
  });
283
- return (_ctx, _cache) => {
284
- return renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(groupedAttributes.value)));
285
- };
286
- }
287
- });
280
+ });
281
+ }
288
282
  const _sfc_main$f = /* @__PURE__ */ defineComponent({
289
283
  ...{ name: "BaseFormItem", inheritAttrs: false },
290
284
  __name: "index",
291
285
  props: {
292
- grid: { type: [Boolean, Object], default: () => void 0 },
293
- fields: { default: () => [] },
294
- disabled: { type: Boolean, default: () => void 0 }
286
+ grid: { type: [Boolean, Object], default: void 0 },
287
+ fields: { default: () => [] }
295
288
  },
296
289
  setup(__props) {
297
- const validFields = computed(() => {
298
- var _a, _b;
299
- return (_b = (_a = __props.fields).filter) == null ? void 0 : _b.call(_a, (field) => !field.hidden);
300
- });
301
- useDisabledContextProvider(computed(() => __props.disabled));
290
+ const props = __props;
291
+ const validFields = computed(
292
+ () => (props.fields ?? []).filter((field) => !field.hidden)
293
+ );
302
294
  const config = INJECT_CONFIG["pro-form"];
303
- 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
+ });
304
300
  const enableGrid = computed(() => {
305
- if (__props.grid !== void 0) return !!__props.grid;
306
- return !!injectGrid;
301
+ if (props.grid !== void 0) return !!props.grid;
302
+ return !!injectGrid.value;
307
303
  });
308
304
  const computedGridProps = computed(() => {
309
- return enableGrid.value ? { ...getObject(injectGrid), ...getObject(__props.grid) } : {};
305
+ return enableGrid.value ? { ...getObject(injectGrid.value), ...getObject(props.grid) } : {};
310
306
  });
311
- const formItemRefs = [];
312
- const componentRefs = [];
313
- const onFormItemMounted = (index2, formItemProps2) => {
314
- const field = validFields.value[index2];
315
- Object.assign(field, {
316
- getFormItemRef: () => formItemRefs[index2],
317
- getFormItemComputedProps: () => formItemProps2
318
- });
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
+ }
319
319
  };
320
- const onComponentMounted = (index2) => {
321
- const field = validFields.value[index2];
322
- Object.assign(field, {
323
- 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 = () => {
324
326
  var _a;
325
- return (_a = componentRefs[index2]) == null ? void 0 : _a.getComponentRef();
326
- },
327
- getComponentComputedProps: () => {
327
+ return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentRef();
328
+ };
329
+ raw.getComponentComputedProps = () => {
328
330
  var _a;
329
- return (_a = componentRefs[index2]) == null ? void 0 : _a.getComponentComputedProps();
330
- }
331
- });
331
+ return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentComputedProps();
332
+ };
333
+ } else {
334
+ componentInstanceMap.delete(raw);
335
+ }
332
336
  };
337
+ const groupedFields = useGroupFieldAttrs(validFields);
333
338
  return (_ctx, _cache) => {
334
339
  const _component_BaseFormItem = resolveComponent("BaseFormItem");
335
340
  return openBlock(), createBlock(unref(_sfc_main$d), mergeProps({
336
341
  component: enableGrid.value ? unref(ElRow) : void 0
337
342
  }, computedGridProps.value, { style: { "width": "100%" } }), {
338
343
  default: withCtx(() => [
339
- (openBlock(true), createElementBlock(Fragment, null, renderList(validFields.value, ({ path: _path, ...field }, index2) => {
340
- return openBlock(), createBlock(_sfc_main$h, mergeProps({
341
- key: unref(toPath)(toValue(_path ?? index2)).join(".") || index2
342
- }, { ref_for: true }, { path: _path }), {
343
- default: withCtx(({ path }) => [
344
- createVNode(_sfc_main$g, { field }, {
345
- default: withCtx(({
346
- gridItemProps: gridItemProps2,
347
- formItemProps: { container, ...formItemProps2 },
348
- componentProps,
349
- formItemSlots
350
- }) => [
351
- createVNode(unref(_sfc_main$d), mergeProps({
352
- component: enableGrid.value ? unref(ElCol) : void 0
353
- }, { ref_for: true }, gridItemProps2), {
344
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(groupedFields), (item, index2) => {
345
+ return openBlock(), createBlock(unref(_sfc_main$d), mergeProps({
346
+ key: item.path || index2,
347
+ component: enableGrid.value ? unref(ElCol) : void 0
348
+ }, { ref_for: true }, item.gridItemProps), {
349
+ default: withCtx(() => [
350
+ createVNode(unref(_sfc_main$d), {
351
+ component: item.container,
352
+ path: item.path
353
+ }, {
354
+ default: withCtx(() => [
355
+ createVNode(unref(ElFormItem), mergeProps({ ref_for: true }, item.formItemProps, {
356
+ ref_for: true,
357
+ ref: (el) => setFormItemRef(item.rawField, el, item.formItemProps),
358
+ prop: unref(normalizePathKey)(item.path),
359
+ path: item.path
360
+ }), createSlots({
354
361
  default: withCtx(() => [
355
- createVNode(unref(_sfc_main$d), {
356
- component: container,
357
- path
358
- }, {
359
- default: withCtx(() => [
360
- createVNode(unref(ElFormItem), mergeProps({ ref_for: true }, formItemProps2, {
361
- ref_for: true,
362
- ref: (el) => formItemRefs[index2] = el,
363
- prop: unref(toPath)(path).join("."),
364
- path,
365
- onVnodeMounted: ($event) => onFormItemMounted(index2, formItemProps2)
366
- }), createSlots({
367
- default: withCtx(() => [
368
- field.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
369
- key: 0,
370
- grid: field.grid ?? __props.grid,
371
- fields: field.fields,
372
- disabled: toValue(field.disabled)
373
- }, null, 8, ["grid", "fields", "disabled"])) : (openBlock(), createBlock(unref(_sfc_main$e), mergeProps({
374
- key: 1,
375
- ref_for: true,
376
- ref: (el) => componentRefs[index2] = el
377
- }, { ref_for: true }, componentProps, {
378
- path,
379
- onVnodeMounted: ($event) => onComponentMounted(index2)
380
- }), null, 16, ["path", "onVnodeMounted"]))
381
- ]),
382
- _: 2
383
- }, [
384
- renderList(formItemSlots, (slot, name) => {
385
- return {
386
- name,
387
- fn: withCtx((scoped) => [
388
- createVNode(unref(_sfc_main$c), mergeProps({
389
- path,
390
- component: slot
391
- }, { ref_for: true }, scoped), null, 16, ["path", "component"])
392
- ])
393
- };
394
- })
395
- ]), 1040, ["prop", "path", "onVnodeMounted"])
396
- ]),
397
- _: 2
398
- }, 1032, ["component", "path"])
362
+ item.rawField.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
363
+ key: 0,
364
+ grid: item.rawField.grid ?? props.grid,
365
+ fields: item.rawField.fields
366
+ }, null, 8, ["grid", "fields"])) : (openBlock(), createBlock(unref(_sfc_main$e), mergeProps({
367
+ key: 1,
368
+ ref_for: true,
369
+ ref: (el) => setComponentRef(item.rawField, el)
370
+ }, { ref_for: true }, item.componentProps, {
371
+ path: item.path
372
+ }), null, 16, ["path"]))
399
373
  ]),
400
374
  _: 2
401
- }, 1040, ["component"])
375
+ }, [
376
+ renderList(item.formItemSlots, (slot, name) => {
377
+ return {
378
+ name,
379
+ fn: withCtx((scoped) => [
380
+ createVNode(unref(_sfc_main$c), mergeProps({
381
+ path: item.path,
382
+ component: slot
383
+ }, { ref_for: true }, scoped), null, 16, ["path", "component"])
384
+ ])
385
+ };
386
+ })
387
+ ]), 1040, ["prop", "path"])
402
388
  ]),
403
389
  _: 2
404
- }, 1032, ["field"])
390
+ }, 1032, ["component", "path"])
405
391
  ]),
406
392
  _: 2
407
- }, 1040);
393
+ }, 1040, ["component"]);
408
394
  }), 128))
409
395
  ]),
410
396
  _: 1
@@ -419,7 +405,7 @@ const _export_sfc = (sfc, props) => {
419
405
  }
420
406
  return target;
421
407
  };
422
- const BaseFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-d52742ce"]]);
408
+ const BaseFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-3cc74dbb"]]);
423
409
  function useForm(...args) {
424
410
  return useForm$1(...args);
425
411
  }
@@ -464,13 +450,10 @@ const getPlaceholderProps = (key, injectProps, t) => {
464
450
  if (!placeholderKey || injectProps.placeholder !== void 0) return {};
465
451
  return { placeholder: t(placeholderKey) };
466
452
  };
467
- const getInitProps = (field, t) => {
453
+ const getInitProps = (field, injectProps = {}, t) => {
468
454
  const { component, type } = field;
469
455
  if (typeof component === "string") {
470
456
  const k = [component, type].filter(Boolean).join(".");
471
- const config = getInjectConfig(k);
472
- if (!config) return getPlaceholderProps(k, {}, t);
473
- const injectProps = inject(config.injectionKey, config.default);
474
457
  return { ...injectProps, ...getPlaceholderProps(k, injectProps, t) };
475
458
  }
476
459
  return {};
@@ -516,9 +499,13 @@ const enUS = {
516
499
  };
517
500
  const LOCALE_INJECT_KEY = Symbol("pro-locale");
518
501
  const useLocale = () => {
502
+ const elLocaleContext = inject(localeContextKey, void 0);
519
503
  const { lang: elLang } = useLocale$1();
520
504
  const override = inject(LOCALE_INJECT_KEY, void 0);
521
- const lang = computed(() => resolveLocaleName(elLang.value));
505
+ const lang = computed(() => {
506
+ if (!elLocaleContext) return "zh-CN";
507
+ return resolveLocaleName(elLang.value);
508
+ });
522
509
  const pack = computed(
523
510
  () => lang.value === "zh-TW" ? zhTW : lang.value === "en-US" ? enUS : zhCN
524
511
  );
@@ -533,21 +520,23 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
533
520
  ...{ name: "BaseField", inheritAttrs: false },
534
521
  __name: "index",
535
522
  props: {
536
- component: { default: () => void 0 },
523
+ component: { default: void 0 },
537
524
  path: { default: "" }
538
525
  },
539
526
  setup(__props, { expose: __expose }) {
527
+ const props = __props;
540
528
  const { t } = useLocale();
541
529
  const form = useForm(false);
542
- const { getFormData, setFormData } = form;
543
530
  const componentRef = ref();
544
531
  const attrs = useAttrs();
545
- function getOldValue() {
546
- return cloneDeep(getFormData == null ? void 0 : getFormData(__props.path));
547
- }
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;
548
536
  const value = computed({
549
537
  get() {
550
- 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);
551
540
  const { valueFormatter } = groupedAttrs.value;
552
541
  if (typeof valueFormatter === "object" && typeof valueFormatter.get === "function") {
553
542
  val = valueFormatter.get(val);
@@ -555,59 +544,61 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
555
544
  return val;
556
545
  },
557
546
  set(val) {
547
+ var _a, _b;
558
548
  let newVal = val;
559
549
  const { valueFormatter } = groupedAttrs.value;
560
- if (valueFormatter) {
561
- if (typeof valueFormatter === "function") {
562
- newVal = valueFormatter(val, getOldValue());
563
- } else if (typeof valueFormatter.set === "function") {
564
- newVal = valueFormatter.set(val, getOldValue());
565
- }
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);
566
554
  }
567
- setFormData == null ? void 0 : setFormData(__props.path, newVal);
555
+ (_b = form.setFormData) == null ? void 0 : _b.call(form, props.path, newVal);
568
556
  }
569
557
  });
570
558
  const parentDisabled = useDisabledContext();
571
559
  const groupedAttrs = computed(() => {
560
+ const currentInjectProps = toValue(rawInjectComponentProps) || {};
572
561
  const initProps = getInitProps(
573
562
  {
574
- component: __props.component,
563
+ component: props.component,
575
564
  type: attrs.type
576
565
  },
566
+ currentInjectProps,
577
567
  t
578
568
  );
579
569
  const modelPropName = attrs.modelProp ?? initProps.modelProp ?? "modelValue";
570
+ const effectiveDisabled = attrs.disabled !== void 0 ? Boolean(attrs.disabled) : Boolean(parentDisabled.value || initProps.disabled);
580
571
  const mergedProps = mergeProps(
581
572
  initProps,
582
573
  attrs,
583
574
  { class: attrs.componentClass, style: attrs.componentStyle },
584
575
  { class: initProps.componentClass, style: initProps.componentStyle },
585
- { disabled: attrs.disabled ?? parentDisabled.value ?? initProps.disabled },
576
+ { disabled: effectiveDisabled },
586
577
  { modelProp: modelPropName }
587
578
  );
588
- const { valueFormatter, modelProp, slots, componentClass, componentStyle, componentContainer, ...rest } = mergedProps;
589
- const modelBindingProp = modelProp ?? "modelValue";
590
- const bindAttrs = omit(rest, [
591
- modelBindingProp,
592
- `onUpdate:${modelBindingProp}`
593
- ]);
579
+ const { valueFormatter, modelProp, slots, componentClass, componentStyle, componentContainer, [modelPropName]: _modelVal, [`onUpdate:${modelPropName}`]: _onUpdateModelVal, ...bindAttrs } = mergedProps;
594
580
  return {
595
581
  attrs: bindAttrs,
596
582
  slots,
597
583
  componentContainer,
598
- modelProp: modelBindingProp,
584
+ modelProp: modelPropName,
599
585
  valueFormatter
600
586
  };
601
587
  });
602
588
  const formSlots = inject(InjectionFormSlotsKey, void 0);
603
589
  const customComponents = inject(INJECT_COMPONENTS, {});
604
590
  const is = computed(() => {
605
- const teleportSlot = __props.path && (formSlots == null ? void 0 : formSlots[__props.path]);
591
+ const teleportSlot = props.path && (formSlots == null ? void 0 : formSlots[props.path]);
606
592
  if (teleportSlot) return teleportSlot;
607
- if (typeof __props.component === "string") {
608
- 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;
609
600
  }
610
- return __props.component;
601
+ return props.component;
611
602
  });
612
603
  __expose({
613
604
  getComponentRef: () => componentRef.value,
@@ -616,7 +607,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
616
607
  return (_ctx, _cache) => {
617
608
  return openBlock(), createBlock(unref(_sfc_main$d), {
618
609
  component: groupedAttrs.value.componentContainer,
619
- path: __props.path
610
+ path: props.path
620
611
  }, {
621
612
  default: withCtx(() => [
622
613
  is.value ? (openBlock(), createBlock(resolveDynamicComponent(is.value), mergeProps({ key: 0 }, groupedAttrs.value.attrs, {
@@ -624,13 +615,15 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
624
615
  ref: componentRef,
625
616
  [`${groupedAttrs.value.modelProp}`]: value.value,
626
617
  [`onUpdate:${groupedAttrs.value.modelProp}`]: _cache[0] || (_cache[0] = ($event) => value.value = $event),
627
- path: __props.path
618
+ path: props.path
628
619
  }), createSlots({ _: 2 }, [
629
620
  renderList(groupedAttrs.value.slots, (slot, name) => {
630
621
  return {
631
622
  name,
632
623
  fn: withCtx((scoped) => [
633
- 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"])
634
627
  ])
635
628
  };
636
629
  })
@@ -677,36 +670,83 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
677
670
  __name: "index",
678
671
  props: {
679
672
  grid: { type: [Boolean, Object], default: false },
680
- form: { default: () => ({}) }
673
+ form: { default: void 0 }
681
674
  },
682
675
  setup(__props) {
683
- provide(InjectionFormKey, __props.form);
684
- const { formData, fields, setFormRef } = __props.form;
685
- 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));
686
726
  const config = INJECT_CONFIG["pro-form"];
727
+ const injectFormConfig = inject(config.injectionKey, config.default);
687
728
  const attrs = useAttrs();
688
- const { grid: _injectGrid, ...injectAttrs } = inject(
689
- config.injectionKey,
690
- config.default
691
- );
729
+ const injectAttrs = computed(() => {
730
+ const raw = toValue(injectFormConfig);
731
+ const { grid: _injectGrid, ...rest } = raw || {};
732
+ return rest;
733
+ });
692
734
  const slots = useSlots();
693
- provide(InjectionFormSlotsKey, reactive(slots));
735
+ provide(InjectionFormSlotsKey, slots);
694
736
  return (_ctx, _cache) => {
695
737
  return openBlock(), createBlock(unref(ElForm), mergeProps({
696
- ref: (el) => {
697
- var _a;
698
- return (_a = unref(setFormRef)) == null ? void 0 : _a(el);
699
- },
700
- model: unref(formData)
701
- }, 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))), {
702
742
  class: "pro-form",
703
743
  onSubmit: _cache[0] || (_cache[0] = withModifiers(() => {
704
744
  }, ["prevent"]))
705
745
  }), {
706
746
  default: withCtx(() => [
707
747
  createVNode(unref(BaseFormItem), {
708
- fields: _fields.value,
709
- grid: __props.grid
748
+ fields: fields.value,
749
+ grid: props.grid
710
750
  }, null, 8, ["fields", "grid"]),
711
751
  renderSlot(_ctx.$slots, "default")
712
752
  ]),
@@ -741,7 +781,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
741
781
  ...{ name: "SearchForm" },
742
782
  __name: "SearchForm",
743
783
  props: {
744
- form: {},
784
+ form: { default: void 0 },
745
785
  layout: { default: "grid" },
746
786
  expand: { type: [Boolean, Object], default: true },
747
787
  searchButton: { type: [Object, Function, Boolean], default: void 0 },
@@ -755,6 +795,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
755
795
  emits: ["search", "reset"],
756
796
  setup(__props, { emit: __emit }) {
757
797
  const { t } = useLocale();
798
+ const props = __props;
758
799
  const emit = __emit;
759
800
  const proFormHeight = ref("unset");
760
801
  const collapseHeight = ref(0);
@@ -775,45 +816,45 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
775
816
  cleanupObservers();
776
817
  });
777
818
  const computedExpand = computed(() => {
778
- if (!__props.expand) return false;
779
- 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 };
780
821
  return {
781
- minExpandRows: Math.max(Math.floor(__props.expand.minExpandRows ?? 2), 1),
782
- expandStatus: __props.expand.expandStatus ?? false
822
+ minExpandRows: Math.max(Math.floor(props.expand.minExpandRows ?? 2), 1),
823
+ expandStatus: props.expand.expandStatus ?? false
783
824
  };
784
825
  });
785
826
  const showExpandToggle = ref(false);
786
827
  const expandStatus = ref(true);
787
- const { formRef, getFormData } = __props.form;
788
828
  const updateHeights = () => {
789
- var _a, _b, _c, _d, _e, _f;
790
- if (!__props.expand || !formRef.value) return;
791
- 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;
792
832
  if (!proFormEl) return;
793
- 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;
794
834
  if (itemHeight && itemHeight > 0) {
795
835
  rowHeight.value = itemHeight;
796
836
  }
797
- 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;
798
838
  if (naturalHeight > 0) {
799
839
  proFormHeight.value = naturalHeight;
800
840
  }
801
841
  };
842
+ const isManualToggle = ref(false);
802
843
  const changeExpandStatus = () => {
844
+ isManualToggle.value = true;
803
845
  expandStatus.value = !expandStatus.value;
804
- nextTick(() => {
805
- updateHeights();
806
- });
807
846
  };
808
847
  const hasFieldValue = (val) => val !== null && val !== void 0 && val !== "" && !(Array.isArray(val) && val.length === 0) && !(typeof val === "object" && Object.keys(val).length === 0);
809
848
  const setInitExpandStatus = () => {
810
- var _a;
811
- expandStatus.value = false;
812
- if (formRef.value && __props.expand) {
813
- const formEl = formRef.value.$el;
814
- 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(
815
856
  formEl,
816
- "[class*='-form-item'] > [path]"
857
+ "[class*='-form-item'] [path]"
817
858
  );
818
859
  if (!formItemsEl || formItemsEl.length === 0) return;
819
860
  if (intersectionObserver) {
@@ -821,13 +862,15 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
821
862
  }
822
863
  intersectionObserver = new IntersectionObserver(
823
864
  (entries) => {
865
+ if (isManualToggle.value) return;
824
866
  expandStatus.value = entries.some((e) => {
867
+ var _a2, _b2;
825
868
  if (e.intersectionRatio === 0) {
826
869
  const path = e.target.getAttribute("path");
827
- 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;
828
871
  return hasFieldValue(searchFieldValue);
829
872
  }
830
- return __props.expand.expandStatus;
873
+ return computedExpand.value ? computedExpand.value.expandStatus : false;
831
874
  });
832
875
  intersectionObserver == null ? void 0 : intersectionObserver.disconnect();
833
876
  },
@@ -842,10 +885,13 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
842
885
  [
843
886
  () => {
844
887
  var _a, _b, _c;
845
- 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;
889
+ },
890
+ () => {
891
+ var _a, _b;
892
+ return (_b = (_a = props.form) == null ? void 0 : _a.formRef) == null ? void 0 : _b.value;
846
893
  },
847
- () => formRef.value,
848
- () => __props.expand
894
+ () => props.expand
849
895
  ],
850
896
  () => {
851
897
  updateHeights();
@@ -853,7 +899,10 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
853
899
  { flush: "post", immediate: true }
854
900
  );
855
901
  watch(
856
- () => formRef.value,
902
+ () => {
903
+ var _a, _b;
904
+ return (_b = (_a = props.form) == null ? void 0 : _a.formRef) == null ? void 0 : _b.value;
905
+ },
857
906
  (val) => {
858
907
  if (resizeObserver) {
859
908
  resizeObserver.disconnect();
@@ -872,10 +921,10 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
872
921
  watchEffect(
873
922
  () => {
874
923
  if (typeof proFormHeight.value !== "number") return;
875
- if (__props.layout === "grid" && computedExpand.value) {
924
+ if (props.layout === "grid" && computedExpand.value) {
876
925
  const { minExpandRows } = computedExpand.value;
877
926
  collapseHeight.value = Math.min(
878
- minExpandRows * rowHeight.value + (minExpandRows - 1) * __props.rowGap,
927
+ minExpandRows * rowHeight.value + (minExpandRows - 1) * props.rowGap,
879
928
  +proFormHeight.value
880
929
  );
881
930
  showExpandToggle.value = +proFormHeight.value - collapseHeight.value > 1;
@@ -888,28 +937,30 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
888
937
  },
889
938
  { flush: "post" }
890
939
  );
891
- const layoutProps = computed(
892
- () => __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" ? {
893
944
  grid: {
894
- gutter: __props.columnGap,
895
- style: { rowGap: `${__props.rowGap}px` }
945
+ gutter: props.columnGap,
946
+ style: { rowGap: `${props.rowGap}px` }
896
947
  },
897
948
  style: {
898
949
  display: "flex",
899
950
  overflow: "hidden",
900
- columnGap: `${__props.columnGap}px`,
901
- height: `${expandStatus.value ? proFormHeight.value : collapseHeight.value}px`
951
+ columnGap: `${props.columnGap}px`,
952
+ height: heightStyle
902
953
  }
903
954
  } : {
904
955
  inline: true,
905
956
  style: {
906
957
  display: "flex",
907
958
  flexWrap: "wrap",
908
- gap: `${__props.rowGap}px ${__props.columnGap}px`
959
+ gap: `${props.rowGap}px ${props.columnGap}px`
909
960
  },
910
961
  grid: false
911
- }
912
- );
962
+ };
963
+ });
913
964
  const onReset = () => {
914
965
  emit("reset");
915
966
  };
@@ -918,9 +969,8 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
918
969
  };
919
970
  return (_ctx, _cache) => {
920
971
  return openBlock(), createBlock(unref(_sfc_main$b), mergeProps(layoutProps.value, {
921
- form: __props.form,
922
- class: "pro-table_search-form transition",
923
- onKeyup: withKeys(onSearch, ["enter"])
972
+ form: props.form,
973
+ class: "pro-table_search-form transition"
924
974
  }), {
925
975
  default: withCtx(() => [
926
976
  createVNode(unref(ElSpace), {
@@ -928,9 +978,9 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
928
978
  class: "pro-table_search-form_button-group"
929
979
  }, {
930
980
  default: withCtx(() => [
931
- renderSlot(_ctx.$slots, "reset-button", { onClick: onReset }, () => [
932
- __props.resetButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
933
- __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), {
934
984
  key: 0,
935
985
  onClick: onReset
936
986
  })) : (openBlock(), createBlock(unref(ElButton), {
@@ -945,9 +995,9 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
945
995
  }))
946
996
  ], 64)) : createCommentVNode("", true)
947
997
  ], true),
948
- renderSlot(_ctx.$slots, "search-button", { onClick: onSearch }, () => [
949
- __props.searchButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
950
- __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), {
951
1001
  key: 0,
952
1002
  onClick: onSearch
953
1003
  })) : (openBlock(), createBlock(unref(ElButton), {
@@ -964,9 +1014,12 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
964
1014
  }))
965
1015
  ], 64)) : createCommentVNode("", true)
966
1016
  ], true),
967
- renderSlot(_ctx.$slots, "expand-button", { onClick: changeExpandStatus }, () => [
968
- __props.expandButton !== false && showExpandToggle.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
969
- __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), {
970
1023
  key: 0,
971
1024
  "expand-status": expandStatus.value,
972
1025
  onClick: changeExpandStatus
@@ -996,7 +1049,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
996
1049
  };
997
1050
  }
998
1051
  });
999
- 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"]]);
1000
1053
  const _sfc_main$8 = {};
1001
1054
  const _hoisted_1$4 = { class: "pro-table_search-form-container" };
1002
1055
  function _sfc_render$3(_ctx, _cache) {
@@ -1039,7 +1092,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1039
1092
  setup(__props) {
1040
1093
  const { t } = useLocale();
1041
1094
  const size = useModel(__props, "size");
1042
- size.value = size.value ?? "default";
1095
+ const currentSize = computed(() => size.value ?? "default");
1043
1096
  const items = computed(() => [
1044
1097
  { label: t("table.sizeDefault"), key: "default" },
1045
1098
  { label: t("table.sizeMiddle"), key: "large" },
@@ -1057,7 +1110,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1057
1110
  return openBlock(), createBlock(unref(ElDropdownItem), {
1058
1111
  key: item.key,
1059
1112
  command: item.key,
1060
- disabled: item.key === size.value
1113
+ disabled: item.key === currentSize.value
1061
1114
  }, {
1062
1115
  default: withCtx(() => [
1063
1116
  createTextVNode(toDisplayString(item.label), 1)
@@ -1085,7 +1138,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1085
1138
  };
1086
1139
  }
1087
1140
  });
1088
- 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"]]);
1089
1142
  const _sfc_main$4 = {};
1090
1143
  const _hoisted_1$1 = {
1091
1144
  focusable: "false",
@@ -1106,27 +1159,27 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1106
1159
  __name: "ColumnControl",
1107
1160
  props: {
1108
1161
  columns: {},
1109
- table: { default: () => void 0 },
1110
- columnControl: { default: () => void 0 }
1162
+ table: { default: void 0 },
1163
+ columnControl: { default: void 0 }
1111
1164
  },
1112
1165
  setup(__props) {
1166
+ const props = __props;
1113
1167
  const { t } = useLocale();
1114
- const open = ref(false);
1115
1168
  const checkAll = ref(false);
1116
1169
  const indeterminate = ref(false);
1117
1170
  const getColumnKey = (column, index2) => {
1118
- const key = column.key ?? column.prop;
1119
- if (key === void 0 || key === null) return `__col_${index2}`;
1120
- 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);
1121
1174
  };
1122
1175
  const checkedColumnsOptions = computed(
1123
- () => __props.columns.map((item, index2) => {
1176
+ () => props.columns.map((item, index2) => {
1124
1177
  var _a, _b, _c, _d;
1125
1178
  const key = getColumnKey(item, index2);
1126
- 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(
1127
1180
  (ek) => String(ek) === key
1128
1181
  );
1129
- 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(
1130
1183
  (dk) => String(dk) === key
1131
1184
  );
1132
1185
  const label = String(
@@ -1155,7 +1208,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1155
1208
  checkedColumnsOptions.value.forEach((item) => {
1156
1209
  var _a;
1157
1210
  if (item.disabled) return;
1158
- (_a = __props.table) == null ? void 0 : _a.setColumn(item.value, {
1211
+ (_a = props.table) == null ? void 0 : _a.setColumn(item.value, {
1159
1212
  hidden: !val.includes(item.value)
1160
1213
  });
1161
1214
  });
@@ -1191,20 +1244,20 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1191
1244
  );
1192
1245
  onMounted(() => {
1193
1246
  var _a, _b;
1194
- (_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) => {
1195
1248
  var _a2;
1196
- (_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 });
1197
1250
  });
1198
1251
  });
1199
1252
  watch(
1200
1253
  () => {
1201
1254
  var _a;
1202
- return (_a = __props.columnControl) == null ? void 0 : _a.disabledKeys;
1255
+ return (_a = props.columnControl) == null ? void 0 : _a.disabledKeys;
1203
1256
  },
1204
1257
  (keys) => {
1205
1258
  keys == null ? void 0 : keys.forEach((key) => {
1206
1259
  var _a;
1207
- (_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 });
1208
1261
  });
1209
1262
  },
1210
1263
  { deep: true }
@@ -1212,16 +1265,14 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1212
1265
  return (_ctx, _cache) => {
1213
1266
  return openBlock(), createBlock(unref(ElDropdown), {
1214
1267
  trigger: "click",
1215
- "hide-on-click": false,
1216
- visible: open.value,
1217
- onVisibleChange: _cache[0] || (_cache[0] = (val) => open.value = val)
1268
+ "hide-on-click": false
1218
1269
  }, {
1219
1270
  dropdown: withCtx(() => [
1220
1271
  createVNode(unref(ElDropdownMenu), null, {
1221
1272
  default: withCtx(() => {
1222
1273
  var _a;
1223
1274
  return [
1224
- !((_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), {
1225
1276
  key: 0,
1226
1277
  disabled: true,
1227
1278
  divided: false
@@ -1277,39 +1328,41 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1277
1328
  })
1278
1329
  ]),
1279
1330
  _: 1
1280
- }, 8, ["visible"]);
1331
+ });
1281
1332
  };
1282
1333
  }
1283
1334
  });
1284
- 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"]]);
1285
1336
  const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1286
1337
  ...{ name: "TableColumnRenderer" },
1287
1338
  __name: "TableColumnRenderer",
1288
1339
  props: {
1289
- columns: {}
1340
+ columns: { default: () => [] }
1290
1341
  },
1291
1342
  setup(__props) {
1343
+ const props = __props;
1292
1344
  const getColumnKey = (column, index2) => {
1293
- const key = column.key ?? column.prop;
1294
- if (key === void 0 || key === null) return `__col_${index2}`;
1295
- 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);
1296
1348
  };
1297
1349
  const getCellValue = (row, column) => {
1298
1350
  const path = column.prop;
1299
1351
  if (!path) return void 0;
1300
- return get(row, toPath(path));
1352
+ return get(row, path);
1301
1353
  };
1302
1354
  const normalizedColumns = computed(() => {
1303
- return __props.columns.filter((column) => !column.hidden);
1355
+ return props.columns.filter((column) => !column.hidden);
1304
1356
  });
1305
1357
  const getColumnProps = (column) => {
1306
1358
  const { hidden, render, key, children, ...rest } = column;
1307
- 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;
1308
1361
  return {
1309
1362
  ...rest,
1310
1363
  label: column.label ?? column.title,
1311
1364
  prop,
1312
- columnKey: key ? String(key) : prop
1365
+ columnKey
1313
1366
  };
1314
1367
  };
1315
1368
  return (_ctx, _cache) => {
@@ -1372,19 +1425,25 @@ const _hoisted_5 = {
1372
1425
  class: "pro-table_header_column-control"
1373
1426
  };
1374
1427
  const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1375
- ...{ name: "ProTable", inheritAttrs: false },
1428
+ ...{
1429
+ name: "ProTable",
1430
+ directives: {
1431
+ loading: ElLoading.directive
1432
+ },
1433
+ inheritAttrs: false
1434
+ },
1376
1435
  __name: "ProTable",
1377
1436
  props: /* @__PURE__ */ mergeModels({
1378
- table: { default: () => void 0 },
1437
+ table: { default: void 0 },
1379
1438
  search: { type: Function, default: void 0 },
1380
- addIndexColumn: { type: Boolean, default: () => void 0 },
1381
- immediateSearch: { type: Boolean, default: () => void 0 },
1382
- control: { type: [Boolean, Object], default: () => void 0 },
1383
- 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 },
1384
1443
  tableContainer: { type: [Object, Function, Boolean], default: void 0 },
1385
- columns: { default: () => void 0 },
1386
- data: { default: () => void 0 },
1387
- 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 },
1388
1447
  size: {},
1389
1448
  width: {},
1390
1449
  height: {},
@@ -1392,61 +1451,63 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1392
1451
  fit: { type: Boolean },
1393
1452
  stripe: { type: Boolean },
1394
1453
  border: { type: Boolean },
1395
- rowKey: { type: [String, Function] },
1454
+ rowKey: {},
1396
1455
  context: {},
1397
1456
  showHeader: { type: Boolean },
1398
1457
  showSummary: { type: Boolean },
1399
1458
  sumText: {},
1400
- summaryMethod: { type: Function },
1401
- rowClassName: { type: [String, Function] },
1402
- rowStyle: { type: [Object, Function] },
1403
- cellClassName: { type: [String, Function] },
1404
- cellStyle: { type: [Object, Function] },
1405
- headerRowClassName: { type: [String, Function] },
1406
- headerRowStyle: { type: [Object, Function] },
1407
- headerCellClassName: { type: [String, Function] },
1408
- headerCellStyle: { type: [Object, Function] },
1459
+ summaryMethod: {},
1460
+ rowClassName: {},
1461
+ rowStyle: {},
1462
+ cellClassName: {},
1463
+ cellStyle: {},
1464
+ headerRowClassName: {},
1465
+ headerRowStyle: {},
1466
+ headerCellClassName: {},
1467
+ headerCellStyle: {},
1409
1468
  highlightCurrentRow: { type: Boolean },
1410
1469
  currentRowKey: {},
1411
1470
  emptyText: {},
1412
1471
  expandRowKeys: {},
1413
1472
  defaultExpandAll: { type: Boolean },
1414
- rowExpandable: { type: Function },
1473
+ rowExpandable: {},
1415
1474
  defaultSort: {},
1416
1475
  tooltipEffect: {},
1417
1476
  tooltipOptions: {},
1418
- spanMethod: { type: Function },
1477
+ spanMethod: {},
1419
1478
  selectOnIndeterminate: { type: Boolean },
1420
1479
  indent: {},
1421
1480
  treeProps: {},
1422
1481
  lazy: { type: Boolean },
1423
- load: { type: Function },
1482
+ load: {},
1424
1483
  className: {},
1425
1484
  style: { type: [Boolean, null, String, Object, Array] },
1426
1485
  tableLayout: {},
1427
1486
  scrollbarAlwaysOn: { type: Boolean },
1428
1487
  flexible: { type: Boolean },
1429
1488
  showOverflowTooltip: { type: [Boolean, Object] },
1430
- tooltipFormatter: { type: Function },
1489
+ tooltipFormatter: {},
1431
1490
  appendFilterPanelTo: {},
1432
1491
  scrollbarTabindex: {},
1433
1492
  nativeScrollbar: { type: Boolean }
1434
1493
  }, {
1435
1494
  "size": {},
1436
1495
  "sizeModifiers": {},
1437
- "loading": { type: Boolean },
1496
+ "loading": { type: Boolean, ...{ default: false } },
1438
1497
  "loadingModifiers": {}
1439
1498
  }),
1440
1499
  emits: ["update:size", "update:loading"],
1441
1500
  setup(__props) {
1501
+ const props = __props;
1442
1502
  const { t } = useLocale();
1443
1503
  const config = INJECT_CONFIG["pro-table"];
1444
- const injectProps = inject(config.injectionKey, config.default);
1504
+ const injectPropsRaw = inject(config.injectionKey, config.default);
1505
+ const injectProps = computed(() => toValue(injectPropsRaw) || {});
1445
1506
  const tableProperties = Object.keys(tableProps());
1446
1507
  const paginationProperties = Object.keys(paginationProps());
1447
1508
  const attrs = useAttrs();
1448
1509
  const injectTableAttrs = computed(() => {
1449
- return pick(injectProps, tableProperties);
1510
+ return pick(injectProps.value, tableProperties);
1450
1511
  });
1451
1512
  const attrsTableProps = computed(() => {
1452
1513
  return pick(
@@ -1454,27 +1515,23 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1454
1515
  tableProperties
1455
1516
  );
1456
1517
  });
1457
- const {
1458
- columns: tableColumns,
1459
- data: tableData,
1460
- searchForm,
1461
- pageParam,
1462
- setPageParam
1463
- } = __props.table || {};
1464
1518
  const size = useModel(__props, "size");
1465
1519
  const loading = useModel(__props, "loading");
1466
1520
  const _search = async () => {
1467
1521
  var _a;
1468
- try {
1522
+ const searchPromise = (_a = props.search || attrs.onSearch) == null ? void 0 : _a();
1523
+ if (isPromise(searchPromise)) {
1469
1524
  loading.value = true;
1470
- await ((_a = __props.search) == null ? void 0 : _a.call(__props));
1471
- } finally {
1472
- loading.value = false;
1525
+ try {
1526
+ await searchPromise;
1527
+ } finally {
1528
+ loading.value = false;
1529
+ }
1473
1530
  }
1474
1531
  };
1475
1532
  const reset = () => {
1476
- var _a;
1477
- (_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);
1478
1535
  nextTick(() => {
1479
1536
  _search();
1480
1537
  });
@@ -1496,31 +1553,43 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1496
1553
  });
1497
1554
  const tableSlotNames = computed(() => Object.keys(tableSlots.value));
1498
1555
  const searchPage1st = () => {
1499
- 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 });
1500
1558
  _search();
1501
1559
  };
1502
1560
  const computedSearchFormConfig = computed(() => {
1503
1561
  var _a, _b;
1504
- 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;
1505
1563
  return {
1506
- ...injectProps.searchFormConfig,
1507
- ...getObject(__props.searchFormConfig),
1564
+ ...injectProps.value.searchFormConfig,
1565
+ ...getObject(props.searchFormConfig),
1508
1566
  container: container ? container : void 0
1509
1567
  };
1510
1568
  });
1511
1569
  const computedTableContainer = computed(() => {
1512
- const container = __props.tableContainer ?? injectProps.tableContainer ?? DefaultTableContainer;
1570
+ const container = props.tableContainer ?? injectProps.value.tableContainer ?? DefaultTableContainer;
1513
1571
  return container ? container : void 0;
1514
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
+ };
1515
1582
  const normalizedRawColumns = computed(() => {
1516
- const source = __props.columns ?? (tableColumns == null ? void 0 : tableColumns.value) ?? [];
1517
- 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) {
1518
1586
  return [
1519
1587
  {
1520
1588
  key: "_index",
1521
1589
  type: "index",
1522
1590
  label: t("table.index"),
1523
- width: 80
1591
+ width: 80,
1592
+ index: getIndex
1524
1593
  },
1525
1594
  ...source
1526
1595
  ];
@@ -1528,8 +1597,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1528
1597
  return source;
1529
1598
  });
1530
1599
  const computedDataSource = computed(() => {
1600
+ var _a, _b;
1531
1601
  const attrsData = attrsTableProps.value.data;
1532
- 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) ?? [];
1533
1603
  });
1534
1604
  const computedTableProps = computed(() => {
1535
1605
  const merged = {
@@ -1540,23 +1610,42 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1540
1610
  return merged;
1541
1611
  });
1542
1612
  const computedPagination = computed(() => {
1543
- if (__props.pagination === false) return false;
1544
- 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;
1545
1633
  return {
1546
- ...injectProps.pagination,
1547
- ...pick(pageConfig, paginationProperties),
1548
- currentPage: pageConfig.currentPage ?? (pageParam == null ? void 0 : pageParam.current) ?? 1,
1549
- pageSize: pageConfig.pageSize ?? (pageParam == null ? void 0 : pageParam.pageSize) ?? 10,
1550
- 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
1551
1638
  };
1552
1639
  });
1553
1640
  const showPagination = computed(() => computedPagination.value !== false);
1554
1641
  const onCurrentChange = (current) => {
1555
- 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 });
1556
1644
  _search();
1557
1645
  };
1558
1646
  const onSizeChange = (pageSize) => {
1559
- 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 });
1560
1649
  _search();
1561
1650
  };
1562
1651
  const onPaginationChange = (currentPage, pageSize) => {
@@ -1564,17 +1653,19 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1564
1653
  (_a = attrs.onChange) == null ? void 0 : _a.call(attrs, currentPage, pageSize);
1565
1654
  };
1566
1655
  const showSearch = computed(() => {
1567
- var _a, _b;
1568
- 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);
1569
1660
  });
1570
1661
  const computedControl = computed(() => {
1571
- const mergedControl = __props.control ?? injectProps.control;
1662
+ const mergedControl = props.control ?? injectProps.value.control;
1572
1663
  if (typeof mergedControl === "boolean") {
1573
1664
  return { sizeControl: mergedControl, columnControl: mergedControl };
1574
1665
  }
1575
1666
  const c = mergedControl;
1576
- const sizeControl = c.sizeControl ?? true;
1577
- 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;
1578
1669
  return { sizeControl: !!sizeControl, columnControl };
1579
1670
  });
1580
1671
  const columnControlConfig = computed(() => {
@@ -1585,7 +1676,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1585
1676
  return size.value ?? attrsTableProps.value.size ?? injectTableAttrs.value.size;
1586
1677
  });
1587
1678
  onMounted(() => {
1588
- if (__props.immediateSearch ?? injectProps.immediateSearch) {
1679
+ if (props.immediateSearch ?? injectProps.value.immediateSearch) {
1589
1680
  _search();
1590
1681
  }
1591
1682
  });
@@ -1600,15 +1691,18 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1600
1691
  component: computedSearchFormConfig.value.container
1601
1692
  }, {
1602
1693
  default: withCtx(() => [
1603
- renderSlot(_ctx.$slots, "search-form", {}, () => [
1604
- unref(searchForm) ? (openBlock(), createBlock(SearchForm, mergeProps({
1605
- key: 0,
1606
- form: unref(searchForm)
1607
- }, computedSearchFormConfig.value, {
1608
- onSearch: searchPage1st,
1609
- onReset: reset
1610
- }), null, 16, ["form"])) : createCommentVNode("", true)
1611
- ], 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)
1612
1706
  ]),
1613
1707
  _: 3
1614
1708
  }, 8, ["component"])) : createCommentVNode("", true),
@@ -1630,7 +1724,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1630
1724
  computedControl.value.columnControl ? (openBlock(), createElementBlock("div", _hoisted_5, [
1631
1725
  createVNode(unref(ColumnControl), {
1632
1726
  columns: normalizedRawColumns.value.filter((item) => item.key !== "_index"),
1633
- table: __props.table,
1727
+ table: props.table,
1634
1728
  "column-control": columnControlConfig.value
1635
1729
  }, null, 8, ["columns", "table", "column-control"])
1636
1730
  ])) : createCommentVNode("", true)
@@ -1672,7 +1766,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1672
1766
  };
1673
1767
  }
1674
1768
  });
1675
- 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"]]);
1676
1770
  function useTable(params = {}) {
1677
1771
  const { data, columns, ...rest } = params;
1678
1772
  const coreTable = useTable$1({
@@ -1694,16 +1788,42 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1694
1788
  },
1695
1789
  __name: "index",
1696
1790
  props: {
1697
- componentVars: {},
1698
- componentMap: {},
1699
- locale: {}
1791
+ componentVars: { default: void 0 },
1792
+ componentMap: { default: void 0 },
1793
+ locale: { default: void 0 }
1700
1794
  },
1701
1795
  setup(__props) {
1702
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
+ );
1703
1812
  if (props.componentVars) {
1704
- Object.entries(props.componentVars).forEach(([key, val]) => {
1705
- const config = ensureInjectConfig(key);
1706
- 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
+ }
1707
1827
  });
1708
1828
  }
1709
1829
  if (props.componentMap) {