@qin-ui/antd-vue-pro 2.3.3 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/README.md +7 -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/antd-vue-pro.css +13 -13
  28. package/es/index.js +435 -319
  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/src/components/component-provider/types/index.d.ts.map +1 -0
  35. package/es/{components → src/components}/form/components/BaseField/index.vue.d.ts +4 -1
  36. package/es/src/components/form/components/BaseField/index.vue.d.ts.map +1 -0
  37. package/es/src/components/form/components/BaseField/utils/index.d.ts +5 -0
  38. package/es/src/components/form/components/BaseField/utils/index.d.ts.map +1 -0
  39. package/es/{components → src/components}/form/components/BaseFormItem/index.vue.d.ts +5 -1
  40. package/es/src/components/form/components/BaseFormItem/index.vue.d.ts.map +1 -0
  41. package/es/{components → src/components}/form/components/ContainerFragment/index.vue.d.ts +3 -1
  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 +11 -0
  45. package/es/src/components/form/components/SlotComponent/index.vue.d.ts.map +1 -0
  46. package/es/src/components/form/components/index.d.ts.map +1 -0
  47. package/es/{components → src/components}/form/constants/index.d.ts +1 -1
  48. package/es/src/components/form/constants/index.d.ts.map +1 -0
  49. package/es/src/components/form/hooks/index.d.ts.map +1 -0
  50. package/es/src/components/form/hooks/useFields.d.ts.map +1 -0
  51. package/es/src/components/form/hooks/useForm.d.ts.map +1 -0
  52. package/es/src/components/form/hooks/useFormRef.d.ts.map +1 -0
  53. package/es/src/components/form/hooks/useGroupFieldAttrs.d.ts +22 -0
  54. package/es/src/components/form/hooks/useGroupFieldAttrs.d.ts.map +1 -0
  55. package/es/src/components/form/index.d.ts.map +1 -0
  56. package/es/{components → src/components}/form/types/index.d.ts +26 -2
  57. package/es/src/components/form/types/index.d.ts.map +1 -0
  58. package/es/{components → src/components}/table/components/ColumnControl.vue.d.ts +4 -1
  59. package/es/src/components/table/components/ColumnControl.vue.d.ts.map +1 -0
  60. package/es/src/components/table/components/DefaultSearchFormContainer.vue.d.ts.map +1 -0
  61. package/es/src/components/table/components/DefaultTableContainer.vue.d.ts.map +1 -0
  62. package/es/{components → src/components}/table/components/ProTable.vue.d.ts +0 -2
  63. package/es/src/components/table/components/ProTable.vue.d.ts.map +1 -0
  64. package/es/{components → src/components}/table/components/SearchForm.vue.d.ts +14 -4
  65. package/es/src/components/table/components/SearchForm.vue.d.ts.map +1 -0
  66. package/es/src/components/table/components/SizeControl.vue.d.ts.map +1 -0
  67. package/es/src/components/table/components/icons/ColumnHeightOutlined.vue.d.ts.map +1 -0
  68. package/es/src/components/table/components/icons/DownOutlined.vue.d.ts.map +1 -0
  69. package/es/src/components/table/components/icons/FilterOutlined.vue.d.ts.map +1 -0
  70. package/es/src/components/table/components/index.d.ts.map +1 -0
  71. package/es/src/components/table/hooks/index.d.ts.map +1 -0
  72. package/es/src/components/table/hooks/useTable.d.ts.map +1 -0
  73. package/es/src/components/table/index.d.ts.map +1 -0
  74. package/es/src/components/table/types/index.d.ts.map +1 -0
  75. package/es/{index.d.ts → src/index.d.ts} +1 -1
  76. package/es/src/index.d.ts.map +1 -0
  77. package/es/src/locale/index.d.ts.map +1 -0
  78. package/es/src/shared/core/index.d.ts +6 -0
  79. package/es/src/shared/core/index.d.ts.map +1 -0
  80. package/es/src/shared/ui/index.d.ts.map +1 -0
  81. package/package.json +8 -3
  82. package/src/components/component-provider/components/index.vue +37 -8
  83. package/src/components/component-provider/constants/index.ts +2 -1
  84. package/src/components/form/components/BaseField/index.vue +61 -34
  85. package/src/components/form/components/BaseField/utils/index.ts +6 -11
  86. package/src/components/form/components/BaseFormItem/index.vue +91 -94
  87. package/src/components/form/components/ContainerFragment/index.vue +4 -2
  88. package/src/components/form/components/ProForm/index.vue +70 -18
  89. package/src/components/form/components/SlotComponent/index.vue +6 -4
  90. package/src/components/form/constants/index.ts +1 -5
  91. package/src/components/form/hooks/useGroupFieldAttrs.ts +126 -0
  92. package/src/components/form/types/index.ts +26 -2
  93. package/src/components/table/components/ColumnControl.vue +16 -15
  94. package/src/components/table/components/ProTable.vue +92 -65
  95. package/src/components/table/components/SearchForm.vue +80 -59
  96. package/src/components/table/components/SizeControl.vue +4 -2
  97. package/src/index.ts +1 -1
  98. package/src/shared/core/index.ts +4 -2
  99. package/es/components/component-provider/components/index.vue.d.ts.map +0 -1
  100. package/es/components/component-provider/constants/index.d.ts.map +0 -1
  101. package/es/components/component-provider/index.d.ts.map +0 -1
  102. package/es/components/component-provider/types/index.d.ts.map +0 -1
  103. package/es/components/form/components/BaseField/index.vue.d.ts.map +0 -1
  104. package/es/components/form/components/BaseField/utils/index.d.ts +0 -5
  105. package/es/components/form/components/BaseField/utils/index.d.ts.map +0 -1
  106. package/es/components/form/components/BaseFormItem/index.vue.d.ts.map +0 -1
  107. package/es/components/form/components/ContainerFragment/index.vue.d.ts.map +0 -1
  108. package/es/components/form/components/GroupedFieldAttrs/index.vue.d.ts +0 -29
  109. package/es/components/form/components/GroupedFieldAttrs/index.vue.d.ts.map +0 -1
  110. package/es/components/form/components/PathProvider/index.vue.d.ts +0 -24
  111. package/es/components/form/components/PathProvider/index.vue.d.ts.map +0 -1
  112. package/es/components/form/components/ProForm/index.vue.d.ts.map +0 -1
  113. package/es/components/form/components/SlotComponent/index.vue.d.ts +0 -7
  114. package/es/components/form/components/SlotComponent/index.vue.d.ts.map +0 -1
  115. package/es/components/form/components/index.d.ts.map +0 -1
  116. package/es/components/form/constants/index.d.ts.map +0 -1
  117. package/es/components/form/hooks/index.d.ts.map +0 -1
  118. package/es/components/form/hooks/useFields.d.ts.map +0 -1
  119. package/es/components/form/hooks/useForm.d.ts.map +0 -1
  120. package/es/components/form/hooks/useFormRef.d.ts.map +0 -1
  121. package/es/components/form/index.d.ts.map +0 -1
  122. package/es/components/form/types/index.d.ts.map +0 -1
  123. package/es/components/table/components/ColumnControl.vue.d.ts.map +0 -1
  124. package/es/components/table/components/DefaultSearchFormContainer.vue.d.ts.map +0 -1
  125. package/es/components/table/components/DefaultTableContainer.vue.d.ts.map +0 -1
  126. package/es/components/table/components/ProTable.vue.d.ts.map +0 -1
  127. package/es/components/table/components/SearchForm.vue.d.ts.map +0 -1
  128. package/es/components/table/components/SizeControl.vue.d.ts.map +0 -1
  129. package/es/components/table/components/icons/ColumnHeightOutlined.vue.d.ts.map +0 -1
  130. package/es/components/table/components/icons/DownOutlined.vue.d.ts.map +0 -1
  131. package/es/components/table/components/icons/FilterOutlined.vue.d.ts.map +0 -1
  132. package/es/components/table/components/index.d.ts.map +0 -1
  133. package/es/components/table/hooks/index.d.ts.map +0 -1
  134. package/es/components/table/hooks/useTable.d.ts.map +0 -1
  135. package/es/components/table/index.d.ts.map +0 -1
  136. package/es/components/table/types/index.d.ts.map +0 -1
  137. package/es/index.d.ts.map +0 -1
  138. package/es/locale/index.d.ts.map +0 -1
  139. package/es/shared/core/index.d.ts +0 -6
  140. package/es/shared/core/index.d.ts.map +0 -1
  141. package/es/shared/ui/index.d.ts.map +0 -1
  142. package/src/components/form/components/GroupedFieldAttrs/index.vue +0 -118
  143. package/src/components/form/components/PathProvider/index.vue +0 -19
  144. /package/es/{components → src/components}/component-provider/constants/index.d.ts +0 -0
  145. /package/es/{components → src/components}/component-provider/index.d.ts +0 -0
  146. /package/es/{components → src/components}/component-provider/types/index.d.ts +0 -0
  147. /package/es/{components → src/components}/form/components/ProForm/index.vue.d.ts +0 -0
  148. /package/es/{components → src/components}/form/components/index.d.ts +0 -0
  149. /package/es/{components → src/components}/form/hooks/index.d.ts +0 -0
  150. /package/es/{components → src/components}/form/hooks/useFields.d.ts +0 -0
  151. /package/es/{components → src/components}/form/hooks/useForm.d.ts +0 -0
  152. /package/es/{components → src/components}/form/hooks/useFormRef.d.ts +0 -0
  153. /package/es/{components → src/components}/form/index.d.ts +0 -0
  154. /package/es/{components → src/components}/table/components/DefaultSearchFormContainer.vue.d.ts +0 -0
  155. /package/es/{components → src/components}/table/components/DefaultTableContainer.vue.d.ts +0 -0
  156. /package/es/{components → src/components}/table/components/SizeControl.vue.d.ts +0 -0
  157. /package/es/{components → src/components}/table/components/icons/ColumnHeightOutlined.vue.d.ts +0 -0
  158. /package/es/{components → src/components}/table/components/icons/DownOutlined.vue.d.ts +0 -0
  159. /package/es/{components → src/components}/table/components/icons/FilterOutlined.vue.d.ts +0 -0
  160. /package/es/{components → src/components}/table/components/index.d.ts +0 -0
  161. /package/es/{components → src/components}/table/hooks/index.d.ts +0 -0
  162. /package/es/{components → src/components}/table/hooks/useTable.d.ts +0 -0
  163. /package/es/{components → src/components}/table/index.d.ts +0 -0
  164. /package/es/{components → src/components}/table/types/index.d.ts +0 -0
  165. /package/es/{locale → src/locale}/index.d.ts +0 -0
  166. /package/es/{shared → src/shared}/ui/index.d.ts +0 -0
package/es/index.js CHANGED
@@ -1,14 +1,17 @@
1
1
  import "./antd-vue-pro.css";
2
- import { defineComponent, computed, provide, renderSlot, inject, mergeProps, toValue, normalizeProps, guardReactiveProps, resolveComponent, createBlock, openBlock, unref, withCtx, createElementBlock, Fragment, renderList, createVNode, createSlots, ref, useAttrs, createCommentVNode, resolveDynamicComponent, isVNode, createTextVNode, toDisplayString, useSlots, reactive, createElementVNode, onBeforeUnmount, watch, watchEffect, normalizeStyle, nextTick, useModel, onMounted, mergeModels, normalizeClass } from "vue";
3
- import { InjectionPathKey, isPlainObject, getObject, toPath, useForm as useForm$1, resolveLocaleName, zhTW, enUS, zhCN, format, omit, InjectionFormSlotsKey, cloneDeep, InjectionFormKey, camelizeProperties, useFields as useFields$1, useFormRef as useFormRef$1, pick, useTable as useTable$1 } from "@qin-ui/pro-components-core";
4
- import { enUS as enUS2, useFormData, zhCN as zhCN2, zhTW as zhTW2 } 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, createElementVNode, onBeforeUnmount, watch, watchEffect, normalizeStyle, useModel, onMounted, mergeModels, normalizeClass, guardReactiveProps, nextTick } from "vue";
5
3
  import { Transfer, TreeSelect, Slider, Switch, RadioGroup, CheckboxGroup, TimePicker, RangePicker, DatePicker, Cascader, Select, InputNumber, InputPassword, InputSearch, Textarea, Input, Row, Col, FormItem, Form, Space, Button, theme, Dropdown, Menu, MenuItem, Checkbox, MenuDivider, Table } from "ant-design-vue";
6
- import { formItemProps, useInjectFormItemContext } from "ant-design-vue/es/form";
4
+ import { isPlainObject, getObject, toPath, useForm as useForm$1, resolveLocaleName, zhTW, enUS, zhCN, format, cloneDeep, InjectionFormSlotsKey, InjectionFormKey, camelizeProperties, useFields as useFields$1, useFormRef as useFormRef$1, pick, isPromise, useTable as useTable$1 } from "@qin-ui/pro-components-core";
5
+ import { enUS as enUS2, useFormData, zhCN as zhCN2, zhTW as zhTW2 } from "@qin-ui/pro-components-core";
7
6
  import { colProps } from "ant-design-vue/es/grid/Col";
7
+ import { formItemProps, useInjectFormItemContext } from "ant-design-vue/es/form";
8
8
  import { useConfigContextInject } from "ant-design-vue/es/config-provider/context";
9
9
  import { useProviderDisabled, useInjectDisabled } from "ant-design-vue/es/config-provider/DisabledContext";
10
10
  import { tableProps } from "ant-design-vue/es/table";
11
- const getPopupContainer = (triggerNode) => triggerNode.closest("form[class*='-form']");
11
+ const getPopupContainer = (triggerNode) => {
12
+ var _a;
13
+ return ((_a = triggerNode.closest) == null ? void 0 : _a.call(triggerNode, "form[class*='-form']")) || (typeof document !== "undefined" ? document.body : void 0);
14
+ };
12
15
  const INJECT_COMPONENTS = Symbol("INJECT_COMPONENTS");
13
16
  const INJECT_CONFIG = {
14
17
  "pro-table": {
@@ -169,42 +172,22 @@ const componentMap = {
169
172
  "tree-select": TreeSelect,
170
173
  "transfer": Transfer
171
174
  };
172
- const _sfc_main$g = /* @__PURE__ */ defineComponent({
173
- __name: "index",
174
- props: {
175
- path: {}
176
- },
177
- setup(__props) {
178
- const props = __props;
179
- const namePath = computed(() => {
180
- return Array.isArray(props.path) ? props.path.join(".") : props.path;
181
- });
182
- provide(InjectionPathKey, namePath);
183
- return (_ctx, _cache) => {
184
- return renderSlot(_ctx.$slots, "default", { path: namePath.value });
185
- };
186
- }
187
- });
188
- const _sfc_main$f = /* @__PURE__ */ defineComponent({
189
- __name: "index",
190
- props: {
191
- field: {}
192
- },
193
- setup(__props) {
194
- const formItemPropKeys = Object.keys(formItemProps()).concat([
195
- "formItemContainer"
196
- ]);
197
- const gridItemPropKeys = Object.keys(colProps());
198
- const props = __props;
199
- const config = INJECT_CONFIG["pro-form-item"];
200
- const injectFormItemProps = inject(config.injectionKey, config.default);
201
- const groupedAttributes = computed(() => {
175
+ const formItemPropKeys = Object.keys(formItemProps()).concat([
176
+ "formItemContainer"
177
+ ]);
178
+ const gridItemPropKeys = Object.keys(colProps());
179
+ function useGroupFieldAttrs(validFields) {
180
+ const config = INJECT_CONFIG["pro-form-item"];
181
+ const injectFormItemProps = inject(config.injectionKey, config.default);
182
+ return computed(() => {
183
+ const rawInject = toValue(injectFormItemProps) || {};
184
+ return validFields.value.map((field) => {
202
185
  let gridItemProps2 = {};
203
186
  let formItemProps2 = {};
204
187
  const componentProps = { slots: {} };
205
188
  const formItemSlots = {};
206
- if (isPlainObject(props.field)) {
207
- const { path, name, fields, formItemClass, formItemStyle, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, ...rest } = props.field;
189
+ if (isPlainObject(field)) {
190
+ const { path, name, fields, formItemClass, formItemStyle, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, formItemContainer, ...rest } = field;
208
191
  const {
209
192
  class: injectClassName,
210
193
  style: injectStyle,
@@ -216,7 +199,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
216
199
  xl,
217
200
  xxl,
218
201
  ...injectRest
219
- } = injectFormItemProps;
202
+ } = rawInject;
220
203
  const initGridItemProps = span || span === 0 ? { span } : { xs, sm, md, lg, xl, xxl, span: injectSpan };
221
204
  gridItemProps2 = fields ? { span: span ?? 24 } : initGridItemProps;
222
205
  formItemProps2 = mergeProps(
@@ -239,137 +222,147 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
239
222
  if (FORM_ITEM_SLOT_KEYS.includes(k)) {
240
223
  formItemSlots[k] = slots[k];
241
224
  } else {
242
- componentProps["slots"][k] = slots[k];
225
+ componentProps.slots[k] = slots[k];
243
226
  }
244
227
  });
228
+ const raw2 = toValue(name) ?? toValue(path);
229
+ return {
230
+ path: Array.isArray(raw2) ? raw2.join(".") : raw2 || "",
231
+ gridItemProps: gridItemProps2,
232
+ formItemProps: formItemProps2,
233
+ formItemSlots,
234
+ componentProps,
235
+ formItemContainer,
236
+ rawField: field
237
+ };
245
238
  }
246
- return { gridItemProps: gridItemProps2, formItemProps: formItemProps2, componentProps, formItemSlots };
239
+ const raw = toValue(field == null ? void 0 : field.name) ?? toValue(field == null ? void 0 : field.path);
240
+ return {
241
+ path: Array.isArray(raw) ? raw.join(".") : raw || "",
242
+ gridItemProps: gridItemProps2,
243
+ formItemProps: formItemProps2,
244
+ formItemSlots,
245
+ componentProps,
246
+ rawField: field
247
+ };
247
248
  });
248
- return (_ctx, _cache) => {
249
- return renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(groupedAttributes.value)));
250
- };
251
- }
252
- });
249
+ });
250
+ }
253
251
  const _sfc_main$e = /* @__PURE__ */ defineComponent({
254
252
  ...{ name: "BaseFormItem", inheritAttrs: false },
255
253
  __name: "index",
256
254
  props: {
257
- grid: { type: [Boolean, Object], default: () => void 0 },
255
+ grid: { type: [Boolean, Object], default: void 0 },
258
256
  fields: { default: () => [] },
259
- disabled: { type: Boolean, default: () => void 0 }
257
+ disabled: { type: Boolean, default: void 0 }
260
258
  },
261
259
  setup(__props) {
262
- const validFields = computed(() => {
263
- var _a, _b;
264
- return (_b = (_a = __props.fields).filter) == null ? void 0 : _b.call(_a, (field) => !field.hidden);
265
- });
266
- useProviderDisabled(computed(() => __props.disabled));
260
+ const props = __props;
261
+ const validFields = computed(
262
+ () => (props.fields ?? []).filter((field) => !field.hidden)
263
+ );
264
+ useProviderDisabled(computed(() => props.disabled));
267
265
  const config = INJECT_CONFIG["pro-form"];
268
- const { grid: injectGrid } = inject(config.injectionKey, config.default);
266
+ const injectFormConfig = inject(config.injectionKey, config.default);
267
+ const injectGrid = computed(() => {
268
+ var _a;
269
+ return (_a = toValue(injectFormConfig)) == null ? void 0 : _a.grid;
270
+ });
269
271
  const enableGrid = computed(() => {
270
- if (__props.grid !== void 0) return !!__props.grid;
271
- return !!injectGrid;
272
+ if (props.grid !== void 0) return !!props.grid;
273
+ return !!injectGrid.value;
272
274
  });
273
275
  const computedGridProps = computed(() => {
274
- return enableGrid.value ? { ...getObject(injectGrid), ...getObject(__props.grid) } : {};
276
+ return enableGrid.value ? { ...getObject(injectGrid.value), ...getObject(props.grid) } : {};
275
277
  });
276
- const formItemRefs = [];
277
- const componentRefs = [];
278
- const onFormItemMounted = (index2, formItemProps2) => {
279
- const field = validFields.value[index2];
280
- Object.assign(field, {
281
- getFormItemRef: () => formItemRefs[index2],
282
- getFormItemComputedProps: () => formItemProps2
283
- });
278
+ const formItemInstanceMap = /* @__PURE__ */ new WeakMap();
279
+ const componentInstanceMap = /* @__PURE__ */ new WeakMap();
280
+ const setFormItemRef = (field, el, formItemProps2) => {
281
+ if (!field || typeof field !== "object") return;
282
+ const raw = toRaw(field);
283
+ if (el) {
284
+ formItemInstanceMap.set(raw, el);
285
+ raw.getFormItemRef = () => formItemInstanceMap.get(raw);
286
+ raw.getFormItemComputedProps = () => formItemProps2;
287
+ } else {
288
+ formItemInstanceMap.delete(raw);
289
+ }
284
290
  };
285
- const onComponentMounted = (index2) => {
286
- const field = validFields.value[index2];
287
- Object.assign(field, {
288
- getComponentRef: () => {
291
+ const setComponentRef = (field, el) => {
292
+ if (!field || typeof field !== "object") return;
293
+ const raw = toRaw(field);
294
+ if (el) {
295
+ componentInstanceMap.set(raw, el);
296
+ raw.getComponentRef = () => {
289
297
  var _a;
290
- return (_a = componentRefs[index2]) == null ? void 0 : _a.getComponentRef();
291
- },
292
- getComponentComputedProps: () => {
298
+ return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentRef();
299
+ };
300
+ raw.getComponentComputedProps = () => {
293
301
  var _a;
294
- return (_a = componentRefs[index2]) == null ? void 0 : _a.getComponentComputedProps();
295
- }
296
- });
302
+ return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentComputedProps();
303
+ };
304
+ } else {
305
+ componentInstanceMap.delete(raw);
306
+ }
297
307
  };
308
+ const groupedFields = useGroupFieldAttrs(validFields);
298
309
  return (_ctx, _cache) => {
299
310
  const _component_BaseFormItem = resolveComponent("BaseFormItem");
300
311
  return openBlock(), createBlock(unref(_sfc_main$c), mergeProps({
301
312
  component: enableGrid.value ? unref(Row) : void 0
302
313
  }, computedGridProps.value), {
303
314
  default: withCtx(() => [
304
- (openBlock(true), createElementBlock(Fragment, null, renderList(validFields.value, ({ path: _path, name: _name, ...field }, index2) => {
305
- return openBlock(), createBlock(_sfc_main$g, mergeProps({
306
- key: unref(toPath)(toValue(_name ?? _path)).join(".") || index2
307
- }, { ref_for: true }, { path: _name ?? _path }), {
308
- default: withCtx(({ path }) => [
309
- createVNode(_sfc_main$f, { field }, {
310
- default: withCtx(({
311
- gridItemProps,
312
- formItemProps: { formItemContainer, ...formItemProps2 },
313
- componentProps,
314
- formItemSlots
315
- }) => [
316
- createVNode(unref(_sfc_main$c), mergeProps({
317
- component: enableGrid.value ? unref(Col) : void 0
318
- }, { ref_for: true }, gridItemProps), {
315
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(groupedFields), (item, index2) => {
316
+ return openBlock(), createBlock(unref(_sfc_main$c), mergeProps({
317
+ key: item.path || index2,
318
+ component: enableGrid.value ? unref(Col) : void 0
319
+ }, { ref_for: true }, item.gridItemProps), {
320
+ default: withCtx(() => [
321
+ createVNode(unref(_sfc_main$c), {
322
+ component: item.formItemContainer,
323
+ path: item.path
324
+ }, {
325
+ default: withCtx(() => [
326
+ createVNode(unref(FormItem), mergeProps({ ref_for: true }, item.formItemProps, {
327
+ ref_for: true,
328
+ ref: (el) => setFormItemRef(item.rawField, el, item.formItemProps),
329
+ name: unref(toPath)(item.path),
330
+ path: item.path
331
+ }), createSlots({
319
332
  default: withCtx(() => [
320
- createVNode(unref(_sfc_main$c), {
321
- component: formItemContainer,
322
- path
323
- }, {
324
- default: withCtx(() => [
325
- createVNode(unref(FormItem), mergeProps({ ref_for: true }, formItemProps2, {
326
- ref_for: true,
327
- ref: (el) => formItemRefs[index2] = el,
328
- name: unref(toPath)(path),
329
- path,
330
- onVnodeMounted: ($event) => onFormItemMounted(index2, formItemProps2)
331
- }), createSlots({
332
- default: withCtx(() => [
333
- field.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
334
- key: 0,
335
- grid: field.grid ?? __props.grid,
336
- fields: field.fields,
337
- disabled: toValue(field.disabled)
338
- }, null, 8, ["grid", "fields", "disabled"])) : (openBlock(), createBlock(unref(_sfc_main$d), mergeProps({
339
- key: 1,
340
- ref_for: true,
341
- ref: (el) => componentRefs[index2] = el
342
- }, { ref_for: true }, componentProps, {
343
- path,
344
- onVnodeMounted: ($event) => onComponentMounted(index2)
345
- }), null, 16, ["path", "onVnodeMounted"]))
346
- ]),
347
- _: 2
348
- }, [
349
- renderList(formItemSlots, (slot, name) => {
350
- return {
351
- name,
352
- fn: withCtx((scoped) => [
353
- createVNode(unref(_sfc_main$b), mergeProps({
354
- path,
355
- component: slot
356
- }, { ref_for: true }, scoped), null, 16, ["path", "component"])
357
- ])
358
- };
359
- })
360
- ]), 1040, ["name", "path", "onVnodeMounted"])
361
- ]),
362
- _: 2
363
- }, 1032, ["component", "path"])
333
+ item.rawField.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
334
+ key: 0,
335
+ grid: item.rawField.grid ?? props.grid,
336
+ fields: item.rawField.fields,
337
+ disabled: toValue(item.rawField.disabled)
338
+ }, null, 8, ["grid", "fields", "disabled"])) : (openBlock(), createBlock(unref(_sfc_main$d), mergeProps({
339
+ key: 1,
340
+ ref_for: true,
341
+ ref: (el) => setComponentRef(item.rawField, el)
342
+ }, { ref_for: true }, item.componentProps, {
343
+ path: item.path
344
+ }), null, 16, ["path"]))
364
345
  ]),
365
346
  _: 2
366
- }, 1040, ["component"])
347
+ }, [
348
+ renderList(item.formItemSlots, (slot, name) => {
349
+ return {
350
+ name,
351
+ fn: withCtx((scoped) => [
352
+ createVNode(unref(_sfc_main$b), mergeProps({
353
+ path: item.path,
354
+ component: slot
355
+ }, { ref_for: true }, scoped), null, 16, ["path", "component"])
356
+ ])
357
+ };
358
+ })
359
+ ]), 1040, ["name", "path"])
367
360
  ]),
368
361
  _: 2
369
- }, 1032, ["field"])
362
+ }, 1032, ["component", "path"])
370
363
  ]),
371
364
  _: 2
372
- }, 1040);
365
+ }, 1040, ["component"]);
373
366
  }), 128))
374
367
  ]),
375
368
  _: 1
@@ -393,14 +386,11 @@ const getPlaceholderProps = (key, injectProps, t) => {
393
386
  if (!placeholderKey || injectProps.placeholder !== void 0) return {};
394
387
  return { placeholder: t(placeholderKey) };
395
388
  };
396
- const getInitProps = (field, t) => {
389
+ const getInitProps = (field, injectProps = {}, t) => {
397
390
  const { component } = field;
398
391
  const picker = component === "date-picker" ? "" : field.picker;
399
392
  if (typeof component === "string") {
400
393
  const k = [component, picker].filter(Boolean).join(".");
401
- const config = getInjectConfig(k);
402
- if (!config) return getPlaceholderProps(k, {}, t);
403
- const injectProps = inject(config.injectionKey, config.default);
404
394
  return { ...injectProps, ...getPlaceholderProps(k, injectProps, t) };
405
395
  }
406
396
  return {};
@@ -429,25 +419,27 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
429
419
  ...{ name: "BaseField", inheritAttrs: false },
430
420
  __name: "index",
431
421
  props: {
432
- component: { default: () => void 0 },
422
+ component: { default: void 0 },
433
423
  path: { default: "" }
434
424
  },
435
425
  setup(__props, { expose: __expose }) {
426
+ const props = __props;
436
427
  const { t } = useLocale();
437
428
  const form = useForm(false);
438
- const { getFormData, setFormData } = form;
439
429
  const componentRef = ref();
440
430
  const formItemContext = useInjectFormItemContext();
441
431
  const triggerFormItemChange = () => {
442
432
  formItemContext.onFieldChange();
443
433
  };
444
434
  const attrs = useAttrs();
445
- function getOldValue() {
446
- return cloneDeep(getFormData == null ? void 0 : getFormData(__props.path));
447
- }
435
+ const pickerVal = attrs.picker;
436
+ const injectConfigKey = typeof props.component === "string" ? [props.component, pickerVal].filter(Boolean).join(".") : "";
437
+ const componentInjectConfig = injectConfigKey ? getInjectConfig(injectConfigKey) : void 0;
438
+ const rawInjectComponentProps = componentInjectConfig ? inject(componentInjectConfig.injectionKey, componentInjectConfig.default) : void 0;
448
439
  const value = computed({
449
440
  get() {
450
- let val = getFormData == null ? void 0 : getFormData(__props.path);
441
+ var _a;
442
+ let val = (_a = form.getFormData) == null ? void 0 : _a.call(form, props.path);
451
443
  const { valueFormatter } = groupedAttrs.value;
452
444
  if (typeof valueFormatter === "object" && typeof valueFormatter.get === "function") {
453
445
  val = valueFormatter.get(val);
@@ -455,38 +447,36 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
455
447
  return val;
456
448
  },
457
449
  set(val) {
450
+ var _a, _b;
458
451
  let newVal = val;
459
452
  const { valueFormatter } = groupedAttrs.value;
460
- if (valueFormatter) {
461
- if (typeof valueFormatter === "function") {
462
- newVal = valueFormatter(val, getOldValue());
463
- } else if (typeof valueFormatter.set === "function") {
464
- newVal = valueFormatter.set(val, getOldValue());
465
- }
453
+ const setFormatter = typeof valueFormatter === "function" ? valueFormatter : typeof valueFormatter === "object" && typeof (valueFormatter == null ? void 0 : valueFormatter.set) === "function" ? valueFormatter.set : void 0;
454
+ if (setFormatter) {
455
+ const oldVal = setFormatter.length > 1 ? cloneDeep((_a = form.getFormData) == null ? void 0 : _a.call(form, props.path)) : void 0;
456
+ newVal = setFormatter(val, oldVal);
466
457
  }
467
- setFormData == null ? void 0 : setFormData(__props.path, newVal);
458
+ (_b = form.setFormData) == null ? void 0 : _b.call(form, props.path, newVal);
468
459
  triggerFormItemChange();
469
460
  }
470
461
  });
471
462
  const parentDisabled = useInjectDisabled();
472
463
  const groupedAttrs = computed(() => {
464
+ const currentInjectProps = toValue(rawInjectComponentProps) || {};
473
465
  const initProps = getInitProps(
474
- {
475
- component: __props.component,
476
- picker: attrs.picker
477
- },
466
+ { component: props.component, picker: attrs.picker },
467
+ currentInjectProps,
478
468
  t
479
469
  );
470
+ const effectiveModelProp = attrs.modelProp ?? initProps.modelProp ?? "value";
480
471
  const mergedProps = mergeProps(
481
472
  initProps,
482
473
  attrs,
483
474
  { class: attrs.componentClass, style: attrs.componentStyle },
484
475
  { class: initProps.componentClass, style: initProps.componentStyle },
485
476
  { disabled: attrs.disabled ?? parentDisabled.value ?? initProps.disabled },
486
- { modelProp: attrs.modelProp ?? initProps.modelProp ?? "value" }
477
+ { modelProp: effectiveModelProp }
487
478
  );
488
- const { valueFormatter, modelProp, slots, componentClass, componentStyle, componentContainer, ...rest } = mergedProps;
489
- const bindAttrs = omit(rest, [modelProp, `onUpdate:${modelProp}`]);
479
+ const { valueFormatter, modelProp, slots, componentClass, componentStyle, componentContainer, [effectiveModelProp]: _modelVal, [`onUpdate:${effectiveModelProp}`]: _onUpdateModelVal, ...bindAttrs } = mergedProps;
490
480
  return {
491
481
  attrs: bindAttrs,
492
482
  slots,
@@ -498,12 +488,17 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
498
488
  const formSlots = inject(InjectionFormSlotsKey, void 0);
499
489
  const customComponents = inject(INJECT_COMPONENTS, {});
500
490
  const is = computed(() => {
501
- const teleportSlot = __props.path && (formSlots == null ? void 0 : formSlots[__props.path]);
491
+ const teleportSlot = props.path && (formSlots == null ? void 0 : formSlots[props.path]);
502
492
  if (teleportSlot) return teleportSlot;
503
- if (typeof __props.component === "string") {
504
- return customComponents[__props.component] || componentMap[__props.component] || __props.component;
493
+ if (typeof props.component === "string") {
494
+ const resolved = customComponents[props.component] || componentMap[props.component];
495
+ if (resolved) return resolved;
496
+ console.warn(
497
+ `[pro-components] 未识别的组件类型 "${props.component}",已降级为原生元素渲染。如为自定义组件请在 componentMap 或 ProComponentProvider 中注册。`
498
+ );
499
+ return props.component;
505
500
  }
506
- return __props.component;
501
+ return props.component;
507
502
  });
508
503
  __expose({
509
504
  getComponentRef: () => componentRef.value,
@@ -512,7 +507,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
512
507
  return (_ctx, _cache) => {
513
508
  return openBlock(), createBlock(unref(_sfc_main$c), {
514
509
  component: groupedAttrs.value.componentContainer,
515
- path: __props.path
510
+ path: props.path
516
511
  }, {
517
512
  default: withCtx(() => [
518
513
  is.value ? (openBlock(), createBlock(resolveDynamicComponent(is.value), mergeProps({ key: 0 }, groupedAttrs.value.attrs, {
@@ -520,13 +515,15 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
520
515
  ref: componentRef,
521
516
  [`${groupedAttrs.value.modelProp}`]: value.value,
522
517
  [`onUpdate:${groupedAttrs.value.modelProp}`]: _cache[0] || (_cache[0] = ($event) => value.value = $event),
523
- path: __props.path
518
+ path: props.path
524
519
  }), createSlots({ _: 2 }, [
525
520
  renderList(groupedAttrs.value.slots, (slot, name) => {
526
521
  return {
527
522
  name,
528
523
  fn: withCtx((scoped) => [
529
- createVNode(unref(_sfc_main$b), mergeProps({ path: __props.path }, scoped, { component: slot }), null, 16, ["path", "component"])
524
+ createVNode(unref(_sfc_main$b), mergeProps({
525
+ path: props.path
526
+ }, scoped, { component: slot }), null, 16, ["path", "component"])
530
527
  ])
531
528
  };
532
529
  })
@@ -541,11 +538,12 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
541
538
  ...{ name: "ContainerFragment", inheritAttrs: false },
542
539
  __name: "index",
543
540
  props: {
544
- component: { type: [Object, Function] }
541
+ component: { type: [Object, Function], default: void 0 }
545
542
  },
546
543
  setup(__props) {
544
+ const props = __props;
547
545
  return (_ctx, _cache) => {
548
- return __props.component ? (openBlock(), createBlock(resolveDynamicComponent(__props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), {
546
+ return props.component ? (openBlock(), createBlock(resolveDynamicComponent(props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), {
549
547
  default: withCtx(() => [
550
548
  renderSlot(_ctx.$slots, "default")
551
549
  ]),
@@ -558,12 +556,13 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
558
556
  ...{ name: "SlotComponent", inheritAttrs: false },
559
557
  __name: "index",
560
558
  props: {
561
- component: { type: [Object, Function, String, Number, Boolean, null] }
559
+ component: { type: [Object, Function, String, Number, Boolean, null], default: void 0 }
562
560
  },
563
561
  setup(__props) {
562
+ const props = __props;
564
563
  return (_ctx, _cache) => {
565
- 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 }, [
566
- createTextVNode(toDisplayString(__props.component), 1)
564
+ 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 }, [
565
+ createTextVNode(toDisplayString(props.component), 1)
567
566
  ], 64));
568
567
  };
569
568
  }
@@ -573,30 +572,78 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
573
572
  __name: "index",
574
573
  props: {
575
574
  grid: { type: [Boolean, Object], default: false },
576
- form: { default: () => ({}) }
575
+ form: { default: void 0 }
577
576
  },
578
577
  setup(__props) {
579
- provide(InjectionFormKey, __props.form);
580
- const { formData, fields, setFormRef } = __props.form;
581
- const config = INJECT_CONFIG["pro-form"];
582
- const { grid: _injectGrid, ...injectAttrs } = inject(
583
- config.injectionKey,
584
- config.default
578
+ const props = __props;
579
+ const fallbackForm = props.form ? void 0 : useForm();
580
+ const currentForm = computed(
581
+ () => props.form ?? fallbackForm
585
582
  );
583
+ const formProxy = new Proxy({}, {
584
+ get(_, prop) {
585
+ const target = currentForm.value;
586
+ const val = target == null ? void 0 : target[prop];
587
+ if (typeof val === "function") {
588
+ return (...args) => {
589
+ var _a, _b;
590
+ return (_b = (_a = currentForm.value) == null ? void 0 : _a[prop]) == null ? void 0 : _b.call(_a, ...args);
591
+ };
592
+ }
593
+ return val;
594
+ },
595
+ set(_, prop, value) {
596
+ if (currentForm.value) {
597
+ currentForm.value[prop] = value;
598
+ }
599
+ return true;
600
+ },
601
+ has(_, prop) {
602
+ return Boolean(currentForm.value && prop in currentForm.value);
603
+ }
604
+ });
605
+ provide(InjectionFormKey, formProxy);
606
+ const fields = computed(() => {
607
+ var _a;
608
+ const f = (_a = currentForm.value) == null ? void 0 : _a.fields;
609
+ return (Array.isArray(f) ? f : f == null ? void 0 : f.value) ?? [];
610
+ });
611
+ const formData = computed(() => {
612
+ var _a;
613
+ return (_a = currentForm.value) == null ? void 0 : _a.formData;
614
+ });
615
+ const setFormRef = (el) => {
616
+ var _a, _b;
617
+ return (_b = (_a = currentForm.value) == null ? void 0 : _a.setFormRef) == null ? void 0 : _b.call(_a, el);
618
+ };
619
+ let formInstanceCounter = 0;
620
+ const formInstanceKeyMap = /* @__PURE__ */ new WeakMap();
621
+ const getFormKey = (f) => {
622
+ if (!formInstanceKeyMap.has(f)) {
623
+ formInstanceKeyMap.set(f, ++formInstanceCounter);
624
+ }
625
+ return formInstanceKeyMap.get(f);
626
+ };
627
+ const formKey = computed(() => getFormKey(currentForm.value));
628
+ const config = INJECT_CONFIG["pro-form"];
629
+ const injectFormConfig = inject(config.injectionKey, config.default);
630
+ const injectAttrs = computed(() => {
631
+ const raw = toValue(injectFormConfig);
632
+ const { grid: _injectGrid, ...rest } = raw || {};
633
+ return rest;
634
+ });
586
635
  const slots = useSlots();
587
- provide(InjectionFormSlotsKey, reactive(slots));
636
+ provide(InjectionFormSlotsKey, slots);
588
637
  return (_ctx, _cache) => {
589
638
  return openBlock(), createBlock(unref(Form), mergeProps({
590
- ref: (el) => {
591
- var _a;
592
- return (_a = unref(setFormRef)) == null ? void 0 : _a(el);
593
- },
594
- model: unref(formData)
595
- }, mergeProps(injectAttrs, unref(camelizeProperties)(_ctx.$attrs)), { class: "pro-form" }), {
639
+ key: formKey.value,
640
+ ref: setFormRef,
641
+ model: formData.value
642
+ }, mergeProps(injectAttrs.value, unref(camelizeProperties)(_ctx.$attrs)), { class: "pro-form" }), {
596
643
  default: withCtx(() => [
597
644
  createVNode(unref(_sfc_main$e), {
598
- fields: unref(fields),
599
- grid: __props.grid
645
+ fields: fields.value,
646
+ grid: props.grid
600
647
  }, null, 8, ["fields", "grid"]),
601
648
  renderSlot(_ctx.$slots, "default")
602
649
  ]),
@@ -638,7 +685,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
638
685
  ...{ name: "SearchForm" },
639
686
  __name: "SearchForm",
640
687
  props: {
641
- form: {},
688
+ form: { default: void 0 },
642
689
  layout: { default: "grid" },
643
690
  expand: { type: [Boolean, Object], default: true },
644
691
  searchButton: { type: [Object, Function, Boolean], default: void 0 },
@@ -652,6 +699,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
652
699
  emits: ["search", "reset"],
653
700
  setup(__props, { emit: __emit }) {
654
701
  const { t } = useLocale();
702
+ const props = __props;
655
703
  const emit = __emit;
656
704
  const proFormHeight = ref("unset");
657
705
  const collapseHeight = ref(0);
@@ -672,43 +720,43 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
672
720
  cleanupObservers();
673
721
  });
674
722
  const computedExpand = computed(() => {
675
- if (!__props.expand) return false;
676
- if (__props.expand === true) return { minExpandRows: 2, expandStatus: false };
723
+ if (!props.expand) return false;
724
+ if (props.expand === true) return { minExpandRows: 2, expandStatus: false };
677
725
  return {
678
- minExpandRows: Math.max(Math.floor(__props.expand.minExpandRows ?? 2), 1),
679
- expandStatus: __props.expand.expandStatus ?? false
726
+ minExpandRows: Math.max(Math.floor(props.expand.minExpandRows ?? 2), 1),
727
+ expandStatus: props.expand.expandStatus ?? false
680
728
  };
681
729
  });
682
730
  const showExpandToggle = ref(false);
683
731
  const expandStatus = ref(true);
684
- const { formRef, getFormData } = __props.form;
685
732
  const updateHeights = () => {
686
- var _a, _b, _c, _d, _e, _f;
687
- if (!__props.expand || !formRef.value) return;
688
- const proFormEl = (_a = formRef.value) == null ? void 0 : _a.$el;
733
+ var _a, _b, _c, _d, _e, _f, _g, _h;
734
+ if (!props.expand || !((_b = (_a = props.form) == null ? void 0 : _a.formRef) == null ? void 0 : _b.value)) return;
735
+ const proFormEl = (_c = props.form.formRef.value) == null ? void 0 : _c.$el;
689
736
  if (!proFormEl) return;
690
- 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;
737
+ 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;
691
738
  if (itemHeight && itemHeight > 0) {
692
739
  rowHeight.value = itemHeight;
693
740
  }
694
- const naturalHeight = proFormEl.scrollHeight || ((_f = (_e = proFormEl.getBoundingClientRect) == null ? void 0 : _e.call(proFormEl)) == null ? void 0 : _f.height) || 0;
741
+ const naturalHeight = proFormEl.scrollHeight || ((_h = (_g = proFormEl.getBoundingClientRect) == null ? void 0 : _g.call(proFormEl)) == null ? void 0 : _h.height) || 0;
695
742
  if (naturalHeight > 0) {
696
743
  proFormHeight.value = naturalHeight;
697
744
  }
698
745
  };
746
+ const isManualToggle = ref(false);
699
747
  const changeExpandStatus = () => {
748
+ isManualToggle.value = true;
700
749
  expandStatus.value = !expandStatus.value;
701
- nextTick(() => {
702
- updateHeights();
703
- });
704
750
  };
705
751
  const hasFieldValue = (val) => val !== null && val !== void 0 && val !== "" && !(Array.isArray(val) && val.length === 0) && !(typeof val === "object" && Object.keys(val).length === 0);
706
752
  const setInitExpandStatus = () => {
707
- var _a;
708
- expandStatus.value = false;
709
- if (formRef.value && __props.expand) {
710
- const formEl = formRef.value.$el;
711
- const formItemsEl = (_a = formEl == null ? void 0 : formEl.querySelectorAll) == null ? void 0 : _a.call(
753
+ var _a, _b, _c;
754
+ if (isManualToggle.value) return;
755
+ const initStatus = computedExpand.value ? computedExpand.value.expandStatus : false;
756
+ expandStatus.value = initStatus;
757
+ if (((_b = (_a = props.form) == null ? void 0 : _a.formRef) == null ? void 0 : _b.value) && computedExpand.value) {
758
+ const formEl = props.form.formRef.value.$el;
759
+ const formItemsEl = (_c = formEl == null ? void 0 : formEl.querySelectorAll) == null ? void 0 : _c.call(
712
760
  formEl,
713
761
  "[class*='-form-item'] > [path]"
714
762
  );
@@ -718,13 +766,15 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
718
766
  }
719
767
  intersectionObserver = new IntersectionObserver(
720
768
  (entries) => {
769
+ if (isManualToggle.value) return;
721
770
  expandStatus.value = entries.some((e) => {
771
+ var _a2, _b2;
722
772
  if (e.intersectionRatio === 0) {
723
773
  const path = e.target.getAttribute("path");
724
- const searchFieldValue = path ? getFormData == null ? void 0 : getFormData(path) : void 0;
774
+ const searchFieldValue = path ? (_b2 = (_a2 = props.form) == null ? void 0 : _a2.getFormData) == null ? void 0 : _b2.call(_a2, path) : void 0;
725
775
  return hasFieldValue(searchFieldValue);
726
776
  }
727
- return __props.expand.expandStatus;
777
+ return computedExpand.value ? computedExpand.value.expandStatus : false;
728
778
  });
729
779
  intersectionObserver == null ? void 0 : intersectionObserver.disconnect();
730
780
  },
@@ -739,10 +789,13 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
739
789
  [
740
790
  () => {
741
791
  var _a, _b, _c;
742
- 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;
792
+ 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;
793
+ },
794
+ () => {
795
+ var _a, _b;
796
+ return (_b = (_a = props.form) == null ? void 0 : _a.formRef) == null ? void 0 : _b.value;
743
797
  },
744
- () => formRef.value,
745
- () => __props.expand
798
+ () => props.expand
746
799
  ],
747
800
  () => {
748
801
  updateHeights();
@@ -750,7 +803,10 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
750
803
  { flush: "post", immediate: true }
751
804
  );
752
805
  watch(
753
- () => formRef.value,
806
+ () => {
807
+ var _a, _b;
808
+ return (_b = (_a = props.form) == null ? void 0 : _a.formRef) == null ? void 0 : _b.value;
809
+ },
754
810
  (val) => {
755
811
  if (resizeObserver) {
756
812
  resizeObserver.disconnect();
@@ -769,10 +825,10 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
769
825
  watchEffect(
770
826
  () => {
771
827
  if (typeof proFormHeight.value !== "number") return;
772
- if (__props.layout === "grid" && computedExpand.value) {
828
+ if (props.layout === "grid" && computedExpand.value) {
773
829
  const { minExpandRows } = computedExpand.value;
774
830
  collapseHeight.value = Math.min(
775
- minExpandRows * rowHeight.value + (minExpandRows - 1) * __props.rowGap,
831
+ minExpandRows * rowHeight.value + (minExpandRows - 1) * props.rowGap,
776
832
  +proFormHeight.value
777
833
  );
778
834
  showExpandToggle.value = +proFormHeight.value - collapseHeight.value > 1;
@@ -785,23 +841,21 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
785
841
  },
786
842
  { flush: "post" }
787
843
  );
788
- const layoutProps = computed(
789
- () => __props.layout === "grid" ? {
844
+ const layoutProps = computed(() => {
845
+ const currentHeight = expandStatus.value ? proFormHeight.value : collapseHeight.value;
846
+ const heightStyle = currentHeight !== "unset" && currentHeight !== void 0 ? `${currentHeight}px` : void 0;
847
+ return props.layout === "grid" ? {
790
848
  grid: {
791
- gutter: [__props.columnGap, __props.rowGap],
849
+ gutter: [props.columnGap, props.rowGap],
792
850
  style: { flex: 1, marginRight: "12px" }
793
851
  },
794
- style: {
795
- display: "flex",
796
- overflow: "hidden",
797
- height: `${expandStatus.value ? proFormHeight.value : collapseHeight.value}px`
798
- }
852
+ style: { display: "flex", overflow: "hidden", height: heightStyle }
799
853
  } : {
800
854
  layout: "inline",
801
- style: { gap: `${__props.rowGap}px ${__props.columnGap}px` },
855
+ style: { gap: `${props.rowGap}px ${props.columnGap}px` },
802
856
  grid: false
803
- }
804
- );
857
+ };
858
+ });
805
859
  const onReset = () => {
806
860
  emit("reset");
807
861
  };
@@ -810,7 +864,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
810
864
  };
811
865
  return (_ctx, _cache) => {
812
866
  return openBlock(), createBlock(unref(_sfc_main$a), mergeProps(layoutProps.value, {
813
- form: __props.form,
867
+ form: props.form,
814
868
  class: "pro-table_search-form transition"
815
869
  }), {
816
870
  default: withCtx(() => [
@@ -819,9 +873,9 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
819
873
  class: "pro-table_search-form_button-group"
820
874
  }, {
821
875
  default: withCtx(() => [
822
- renderSlot(_ctx.$slots, "reset-button", { onClick: onReset }, () => [
823
- __props.resetButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
824
- __props.resetButton ? (openBlock(), createBlock(resolveDynamicComponent(__props.resetButton), {
876
+ renderSlot(_ctx.$slots, "reset-button", { onReset }, () => [
877
+ props.resetButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
878
+ props.resetButton ? (openBlock(), createBlock(resolveDynamicComponent(props.resetButton), {
825
879
  key: 0,
826
880
  onClick: onReset
827
881
  })) : (openBlock(), createBlock(unref(Button), {
@@ -836,9 +890,9 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
836
890
  }))
837
891
  ], 64)) : createCommentVNode("", true)
838
892
  ], true),
839
- renderSlot(_ctx.$slots, "search-button", { onClick: onSearch }, () => [
840
- __props.searchButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
841
- __props.searchButton ? (openBlock(), createBlock(resolveDynamicComponent(__props.searchButton), {
893
+ renderSlot(_ctx.$slots, "search-button", { onSearch }, () => [
894
+ props.searchButton !== false ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
895
+ props.searchButton ? (openBlock(), createBlock(resolveDynamicComponent(props.searchButton), {
842
896
  key: 0,
843
897
  onClick: onSearch
844
898
  })) : (openBlock(), createBlock(unref(Button), {
@@ -855,9 +909,12 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
855
909
  }))
856
910
  ], 64)) : createCommentVNode("", true)
857
911
  ], true),
858
- renderSlot(_ctx.$slots, "expand-button", { onClick: changeExpandStatus }, () => [
859
- __props.expandButton !== false && showExpandToggle.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
860
- __props.expandButton ? (openBlock(), createBlock(resolveDynamicComponent(__props.expandButton), {
912
+ renderSlot(_ctx.$slots, "expand-button", {
913
+ expandStatus: expandStatus.value,
914
+ changeExpandStatus
915
+ }, () => [
916
+ props.expandButton !== false && showExpandToggle.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
917
+ props.expandButton ? (openBlock(), createBlock(resolveDynamicComponent(props.expandButton), {
861
918
  key: 0,
862
919
  "expand-status": expandStatus.value,
863
920
  onClick: changeExpandStatus
@@ -887,7 +944,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
887
944
  };
888
945
  }
889
946
  });
890
- const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-7bd701e4"]]);
947
+ const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-9dca0a5d"]]);
891
948
  const _sfc_main$7 = /* @__PURE__ */ defineComponent({
892
949
  __name: "DefaultSearchFormContainer",
893
950
  setup(__props) {
@@ -942,11 +999,15 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
942
999
  },
943
1000
  emits: ["update:size"],
944
1001
  setup(__props) {
945
- var _a;
946
1002
  const { t } = useLocale();
947
1003
  const configContext = useConfigContextInject();
948
1004
  const size = useModel(__props, "size");
949
- size.value = size.value ?? ((_a = configContext.componentSize) == null ? void 0 : _a.value) ?? "large";
1005
+ const currentSize = computed(
1006
+ () => {
1007
+ var _a;
1008
+ return size.value ?? ((_a = configContext.componentSize) == null ? void 0 : _a.value) ?? "large";
1009
+ }
1010
+ );
950
1011
  const onSizeChange = (val) => {
951
1012
  size.value = val.key;
952
1013
  };
@@ -963,7 +1024,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
963
1024
  overlay: withCtx(() => [
964
1025
  createVNode(unref(Menu), {
965
1026
  style: { "width": "100px", "text-align": "center" },
966
- "selected-keys": size.value ? [size.value] : [],
1027
+ "selected-keys": [currentSize.value],
967
1028
  items: sizeOptions.value,
968
1029
  onClick: onSizeChange
969
1030
  }, null, 8, ["selected-keys", "items"])
@@ -984,7 +1045,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
984
1045
  };
985
1046
  }
986
1047
  });
987
- const SizeControl = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-a718ce24"]]);
1048
+ const SizeControl = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-2ac95d3b"]]);
988
1049
  const _sfc_main$3 = {};
989
1050
  const _hoisted_1$1 = {
990
1051
  focusable: "false",
@@ -1005,23 +1066,25 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1005
1066
  __name: "ColumnControl",
1006
1067
  props: {
1007
1068
  columns: {},
1008
- table: { default: () => void 0 },
1009
- columnControl: { default: () => void 0 }
1069
+ table: { default: void 0 },
1070
+ columnControl: { default: void 0 }
1010
1071
  },
1011
1072
  setup(__props) {
1073
+ const props = __props;
1012
1074
  const { t } = useLocale();
1013
1075
  const open = ref(false);
1014
1076
  const checkAll = ref(false);
1015
1077
  const indeterminate = ref(false);
1016
1078
  const checkedColumnsOptions = computed(
1017
- () => __props.columns.flatMap((item) => {
1079
+ () => props.columns.flatMap((item) => {
1018
1080
  var _a, _b, _c, _d, _e, _f;
1019
1081
  const rawKey = item.key ?? (Array.isArray(item.dataIndex) ? item.dataIndex.join(".") : item.dataIndex);
1020
1082
  if (!rawKey || !item.title) return [];
1021
1083
  const key = String(rawKey);
1022
- if ((_b = (_a = __props.columnControl) == null ? void 0 : _a.excludedKeys) == null ? void 0 : _b.some((ek) => String(ek) === key)) return [];
1023
- const disabled = ((_d = (_c = __props.columnControl) == null ? void 0 : _c.disabledKeys) == null ? void 0 : _d.some((dk) => String(dk) === key)) ?? false;
1024
- const label = ((_f = (_e = __props.columnControl) == null ? void 0 : _e.labels) == null ? void 0 : _f[key]) ?? (typeof item.title === "string" ? item.title : key);
1084
+ if ((_b = (_a = props.columnControl) == null ? void 0 : _a.excludedKeys) == null ? void 0 : _b.some((ek) => String(ek) === key))
1085
+ return [];
1086
+ const disabled = ((_d = (_c = props.columnControl) == null ? void 0 : _c.disabledKeys) == null ? void 0 : _d.some((dk) => String(dk) === key)) ?? false;
1087
+ const label = ((_f = (_e = props.columnControl) == null ? void 0 : _e.labels) == null ? void 0 : _f[key]) ?? (typeof item.title === "string" ? item.title : key);
1025
1088
  return {
1026
1089
  label,
1027
1090
  value: key,
@@ -1043,7 +1106,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1043
1106
  checkedColumnsOptions.value.forEach((item) => {
1044
1107
  var _a, _b;
1045
1108
  if (item.disabled) return;
1046
- (_b = (_a = __props.table) == null ? void 0 : _a.setColumn) == null ? void 0 : _b.call(_a, item.value, {
1109
+ (_b = (_a = props.table) == null ? void 0 : _a.setColumn) == null ? void 0 : _b.call(_a, item.value, {
1047
1110
  hidden: !val.includes(item.value)
1048
1111
  });
1049
1112
  });
@@ -1077,20 +1140,20 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1077
1140
  );
1078
1141
  onMounted(() => {
1079
1142
  var _a, _b;
1080
- (_b = (_a = __props.columnControl) == null ? void 0 : _a.disabledKeys) == null ? void 0 : _b.forEach((key) => {
1143
+ (_b = (_a = props.columnControl) == null ? void 0 : _a.disabledKeys) == null ? void 0 : _b.forEach((key) => {
1081
1144
  var _a2, _b2;
1082
- (_b2 = (_a2 = __props.table) == null ? void 0 : _a2.setColumn) == null ? void 0 : _b2.call(_a2, String(key), { hidden: false });
1145
+ (_b2 = (_a2 = props.table) == null ? void 0 : _a2.setColumn) == null ? void 0 : _b2.call(_a2, String(key), { hidden: false });
1083
1146
  });
1084
1147
  });
1085
1148
  watch(
1086
1149
  () => {
1087
1150
  var _a;
1088
- return (_a = __props.columnControl) == null ? void 0 : _a.disabledKeys;
1151
+ return (_a = props.columnControl) == null ? void 0 : _a.disabledKeys;
1089
1152
  },
1090
1153
  (keys) => {
1091
1154
  keys == null ? void 0 : keys.forEach((key) => {
1092
1155
  var _a, _b;
1093
- (_b = (_a = __props.table) == null ? void 0 : _a.setColumn) == null ? void 0 : _b.call(_a, String(key), { hidden: false });
1156
+ (_b = (_a = props.table) == null ? void 0 : _a.setColumn) == null ? void 0 : _b.call(_a, String(key), { hidden: false });
1094
1157
  });
1095
1158
  },
1096
1159
  { deep: true }
@@ -1110,7 +1173,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1110
1173
  default: withCtx(() => {
1111
1174
  var _a, _b;
1112
1175
  return [
1113
- !((_a = __props.columnControl) == null ? void 0 : _a.disableCheckAll) ? (openBlock(), createBlock(unref(MenuItem), {
1176
+ !((_a = props.columnControl) == null ? void 0 : _a.disableCheckAll) ? (openBlock(), createBlock(unref(MenuItem), {
1114
1177
  key: 0,
1115
1178
  onClick: onCheckAllChange
1116
1179
  }, {
@@ -1170,7 +1233,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1170
1233
  };
1171
1234
  }
1172
1235
  });
1173
- const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-9899456e"]]);
1236
+ const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-04235d0e"]]);
1174
1237
  const _hoisted_1 = { class: "pro-table_header" };
1175
1238
  const _hoisted_2 = {
1176
1239
  key: 0,
@@ -1192,32 +1255,36 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1192
1255
  ...{ name: "ProTable", inheritAttrs: false },
1193
1256
  __name: "ProTable",
1194
1257
  props: /* @__PURE__ */ mergeModels({
1195
- table: { default: () => void 0 },
1258
+ table: { default: void 0 },
1196
1259
  search: { type: Function, default: void 0 },
1197
- addIndexColumn: { type: Boolean, default: () => void 0 },
1198
- immediateSearch: { type: Boolean, default: () => void 0 },
1199
- control: { type: [Boolean, Object], default: () => void 0 },
1200
- searchFormConfig: { default: () => void 0 },
1260
+ addIndexColumn: { type: Boolean, default: void 0 },
1261
+ immediateSearch: { type: Boolean, default: void 0 },
1262
+ control: { type: [Boolean, Object], default: void 0 },
1263
+ searchFormConfig: { default: void 0 },
1201
1264
  tableContainer: { type: [Object, Function, Boolean], default: void 0 }
1202
1265
  }, {
1203
1266
  "size": {},
1204
1267
  "sizeModifiers": {},
1205
- "loading": { type: Boolean },
1268
+ "loading": { type: Boolean, ...{ default: false } },
1206
1269
  "loadingModifiers": {}
1207
1270
  }),
1208
1271
  emits: ["update:size", "update:loading"],
1209
1272
  setup(__props) {
1273
+ const props = __props;
1210
1274
  const { t } = useLocale();
1211
1275
  const config = INJECT_CONFIG["pro-table"];
1212
- const injectProps = inject(config.injectionKey, config.default);
1276
+ const injectPropsRaw = inject(config.injectionKey, config.default);
1277
+ const injectProps = computed(() => toValue(injectPropsRaw) || {});
1213
1278
  const tableProperties = Object.keys(tableProps());
1214
- const injectAttrs = pick(injectProps, tableProperties);
1279
+ const injectAttrs = computed(
1280
+ () => pick(injectProps.value, tableProperties)
1281
+ );
1215
1282
  const computedSearchFormConfig = computed(() => {
1216
1283
  var _a, _b;
1217
- const container = ((_a = __props.searchFormConfig) == null ? void 0 : _a.container) ?? ((_b = injectProps.searchFormConfig) == null ? void 0 : _b.container) ?? DefaultSearchFormContainer;
1284
+ const container = ((_a = props.searchFormConfig) == null ? void 0 : _a.container) ?? ((_b = injectProps.value.searchFormConfig) == null ? void 0 : _b.container) ?? DefaultSearchFormContainer;
1218
1285
  return {
1219
- ...injectProps.searchFormConfig,
1220
- ...getObject(__props.searchFormConfig),
1286
+ ...injectProps.value.searchFormConfig,
1287
+ ...getObject(props.searchFormConfig),
1221
1288
  container: container ? container : void 0
1222
1289
  };
1223
1290
  });
@@ -1225,21 +1292,23 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1225
1292
  const tableAttrs = computed(() => {
1226
1293
  return pick(camelizeProperties(attrs), tableProperties);
1227
1294
  });
1228
- const { columns, dataSource, searchForm, pageParam, setPageParam } = __props.table || {};
1229
1295
  const size = useModel(__props, "size");
1230
1296
  const loading = useModel(__props, "loading");
1231
1297
  const _search = async () => {
1232
1298
  var _a;
1233
- try {
1299
+ const searchPromise = (_a = props.search || attrs.onSearch) == null ? void 0 : _a();
1300
+ if (isPromise(searchPromise)) {
1234
1301
  loading.value = true;
1235
- await ((_a = __props.search) == null ? void 0 : _a.call(__props));
1236
- } finally {
1237
- loading.value = false;
1302
+ try {
1303
+ await searchPromise;
1304
+ } finally {
1305
+ loading.value = false;
1306
+ }
1238
1307
  }
1239
1308
  };
1240
1309
  const reset = () => {
1241
- var _a;
1242
- (_a = __props.table) == null ? void 0 : _a.resetQueryParams();
1310
+ var _a, _b;
1311
+ (_b = (_a = props.table) == null ? void 0 : _a.resetQueryParams) == null ? void 0 : _b.call(_a);
1243
1312
  nextTick(() => {
1244
1313
  _search();
1245
1314
  });
@@ -1254,75 +1323,93 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1254
1323
  ...tableSlots
1255
1324
  } = slots;
1256
1325
  const searchPage1st = () => {
1257
- setPageParam == null ? void 0 : setPageParam({ current: 1 });
1326
+ var _a, _b;
1327
+ (_b = (_a = props.table) == null ? void 0 : _a.setPageParam) == null ? void 0 : _b.call(_a, { current: 1 });
1258
1328
  _search();
1259
1329
  };
1260
1330
  const computedTableProps = computed(() => {
1261
1331
  return {
1262
- ...injectAttrs,
1332
+ ...injectAttrs.value,
1263
1333
  ...tableAttrs.value,
1264
1334
  pagination: void 0,
1265
1335
  onChange: void 0
1266
1336
  };
1267
1337
  });
1268
1338
  const computedTableContainer = computed(() => {
1269
- const container = __props.tableContainer ?? injectProps.tableContainer ?? DefaultTableContainer;
1339
+ const container = props.tableContainer ?? injectProps.value.tableContainer ?? DefaultTableContainer;
1270
1340
  return container ? container : void 0;
1271
1341
  });
1272
- const indexColumn = () => ({
1342
+ const renderIndex = ({ index: index2 }) => index2 + 1;
1343
+ const indexColumn = computed(() => ({
1273
1344
  title: t("table.index"),
1274
1345
  dataIndex: "_index",
1346
+ key: "_index",
1275
1347
  width: 80,
1276
- customRender: ({ index: index2 }) => index2 + 1
1348
+ customRender: renderIndex
1349
+ }));
1350
+ const computedColumns = computed(() => {
1351
+ var _a;
1352
+ const cols = tableAttrs.value.columns ?? toValue((_a = props.table) == null ? void 0 : _a.columns) ?? [];
1353
+ const needIndex = props.addIndexColumn ?? injectProps.value.addIndexColumn;
1354
+ return needIndex ? [indexColumn.value, ...cols] : cols;
1277
1355
  });
1278
- const computedColumns = computed(
1279
- () => [
1280
- ...__props.addIndexColumn ?? injectProps.addIndexColumn ? [indexColumn()] : [],
1281
- ...tableAttrs.value.columns ?? (columns == null ? void 0 : columns.value) ?? []
1282
- ]
1283
- );
1284
1356
  const visibleComputedColumns = computed(() => {
1285
1357
  return computedColumns.value.filter((item) => !item.hidden);
1286
1358
  });
1287
1359
  const computedDataSource = computed(() => {
1288
- return tableAttrs.value.dataSource ?? (dataSource == null ? void 0 : dataSource.value);
1360
+ var _a;
1361
+ return tableAttrs.value.dataSource ?? toValue((_a = props.table) == null ? void 0 : _a.dataSource) ?? [];
1289
1362
  });
1290
1363
  const computedPagination = computed(() => {
1291
- var _a, _b;
1364
+ var _a, _b, _c, _d;
1292
1365
  if (tableAttrs.value.pagination === false) return false;
1366
+ if (isPlainObject(tableAttrs.value.pagination)) {
1367
+ const globalPagination = injectAttrs.value.pagination === false ? {} : injectAttrs.value.pagination;
1368
+ return {
1369
+ ...globalPagination,
1370
+ ...(_a = props.table) == null ? void 0 : _a.pageParam,
1371
+ ...tableAttrs.value.pagination,
1372
+ showTotal: ((_b = tableAttrs.value.pagination) == null ? void 0 : _b.showTotal) ?? (globalPagination == null ? void 0 : globalPagination.showTotal) ?? ((total) => t("pagination.total", { total }))
1373
+ };
1374
+ }
1375
+ if (injectAttrs.value.pagination === false) return false;
1293
1376
  return {
1294
- ...injectAttrs.pagination,
1295
- ...pageParam,
1296
- ...tableAttrs.value.pagination,
1297
- showTotal: ((_a = tableAttrs.value.pagination) == null ? void 0 : _a.showTotal) ?? (injectAttrs.pagination === false ? void 0 : (_b = injectAttrs.pagination) == null ? void 0 : _b.showTotal) ?? ((total) => t("pagination.total", { total }))
1377
+ ...injectAttrs.value.pagination,
1378
+ ...(_c = props.table) == null ? void 0 : _c.pageParam,
1379
+ showTotal: ((_d = injectAttrs.value.pagination) == null ? void 0 : _d.showTotal) ?? ((total) => t("pagination.total", { total }))
1298
1380
  };
1299
1381
  });
1300
1382
  const onTableChange = (...args) => {
1301
- var _a;
1302
- setPageParam == null ? void 0 : setPageParam(args[0]);
1303
- (_a = attrs.onChange) == null ? void 0 : _a.call(attrs, ...args);
1383
+ var _a, _b, _c;
1384
+ (_b = (_a = props.table) == null ? void 0 : _a.setPageParam) == null ? void 0 : _b.call(_a, args[0]);
1385
+ (_c = attrs.onChange) == null ? void 0 : _c.call(attrs, ...args);
1304
1386
  _search();
1305
1387
  };
1306
1388
  const showSearch = computed(() => {
1307
- var _a, _b;
1308
- 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);
1389
+ var _a, _b, _c, _d;
1390
+ const searchFields = (_b = (_a = props.table) == null ? void 0 : _a.searchForm) == null ? void 0 : _b.fields;
1391
+ const fieldList = (Array.isArray(searchFields) ? searchFields : searchFields == null ? void 0 : searchFields.value) ?? [];
1392
+ return !!(searchFormSlot || ((_c = computedSearchFormConfig.value) == null ? void 0 : _c.hidden) !== true && ((_d = props.table) == null ? void 0 : _d.searchForm) && fieldList.filter((item) => !item.hidden).length > 0);
1309
1393
  });
1310
1394
  const computedControl = computed(() => {
1311
- const mergedControl = __props.control ?? injectProps.control;
1312
- if (typeof mergedControl === "boolean") {
1313
- return { sizeControl: mergedControl, columnControl: mergedControl };
1395
+ const controlConfig = props.control ?? injectProps.value.control;
1396
+ if (controlConfig === true) {
1397
+ return { sizeControl: true, columnControl: true };
1314
1398
  }
1315
- const c = mergedControl;
1316
- const sizeControl = c.sizeControl ?? true;
1317
- const columnControl = c.columnControl ?? true;
1318
- return { sizeControl: !!sizeControl, columnControl };
1399
+ if (controlConfig === false) {
1400
+ return { sizeControl: false, columnControl: false };
1401
+ }
1402
+ return {
1403
+ sizeControl: !!(controlConfig == null ? void 0 : controlConfig.sizeControl),
1404
+ columnControl: (controlConfig == null ? void 0 : controlConfig.columnControl) ?? false
1405
+ };
1319
1406
  });
1320
1407
  const columnControlConfig = computed(() => {
1321
1408
  const cc = computedControl.value.columnControl;
1322
1409
  return typeof cc === "object" ? cc : void 0;
1323
1410
  });
1324
1411
  onMounted(() => {
1325
- if (__props.immediateSearch ?? injectProps.immediateSearch) {
1412
+ if (props.immediateSearch ?? injectProps.value.immediateSearch) {
1326
1413
  _search();
1327
1414
  }
1328
1415
  });
@@ -1336,15 +1423,18 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1336
1423
  component: computedSearchFormConfig.value.container
1337
1424
  }, {
1338
1425
  default: withCtx(() => [
1339
- renderSlot(_ctx.$slots, "search-form", {}, () => [
1340
- unref(searchForm) ? (openBlock(), createBlock(SearchForm, mergeProps({
1341
- key: 0,
1342
- form: unref(searchForm)
1343
- }, computedSearchFormConfig.value, {
1344
- onSearch: searchPage1st,
1345
- onReset: reset
1346
- }), null, 16, ["form"])) : createCommentVNode("", true)
1347
- ], true)
1426
+ renderSlot(_ctx.$slots, "search-form", {}, () => {
1427
+ var _a;
1428
+ return [
1429
+ ((_a = props.table) == null ? void 0 : _a.searchForm) ? (openBlock(), createBlock(SearchForm, mergeProps({
1430
+ key: 0,
1431
+ form: props.table.searchForm
1432
+ }, computedSearchFormConfig.value, {
1433
+ onSearch: searchPage1st,
1434
+ onReset: reset
1435
+ }), null, 16, ["form"])) : createCommentVNode("", true)
1436
+ ];
1437
+ }, true)
1348
1438
  ]),
1349
1439
  _: 3
1350
1440
  }, 8, ["component"])) : createCommentVNode("", true),
@@ -1366,7 +1456,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1366
1456
  computedControl.value.columnControl ? (openBlock(), createElementBlock("div", _hoisted_5, [
1367
1457
  createVNode(unref(ColumnControl), {
1368
1458
  columns: computedColumns.value,
1369
- table: __props.table,
1459
+ table: props.table,
1370
1460
  "column-control": columnControlConfig.value
1371
1461
  }, null, 8, ["columns", "table", "column-control"])
1372
1462
  ])) : createCommentVNode("", true)
@@ -1397,7 +1487,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1397
1487
  };
1398
1488
  }
1399
1489
  });
1400
- const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-ff6f01f4"]]);
1490
+ const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-5ce28f7b"]]);
1401
1491
  function useTable(params) {
1402
1492
  return useTable$1(params);
1403
1493
  }
@@ -1408,16 +1498,42 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1408
1498
  },
1409
1499
  __name: "index",
1410
1500
  props: {
1411
- componentVars: {},
1412
- componentMap: {},
1413
- locale: {}
1501
+ componentVars: { default: void 0 },
1502
+ componentMap: { default: void 0 },
1503
+ locale: { default: void 0 }
1414
1504
  },
1415
1505
  setup(__props) {
1416
1506
  const props = __props;
1507
+ Object.keys(INJECT_CONFIG).forEach(
1508
+ (key) => {
1509
+ const config = INJECT_CONFIG[key];
1510
+ provide(
1511
+ config.injectionKey,
1512
+ computed(() => {
1513
+ var _a;
1514
+ return {
1515
+ ...config.default,
1516
+ ...getObject((_a = props.componentVars) == null ? void 0 : _a[key])
1517
+ };
1518
+ })
1519
+ );
1520
+ }
1521
+ );
1417
1522
  if (props.componentVars) {
1418
- Object.entries(props.componentVars).forEach(([key, val]) => {
1419
- const config = ensureInjectConfig(key);
1420
- provide(config.injectionKey, { ...config.default, ...getObject(val) });
1523
+ Object.keys(props.componentVars).forEach((key) => {
1524
+ if (!(key in INJECT_CONFIG)) {
1525
+ const config = ensureInjectConfig(key);
1526
+ provide(
1527
+ config.injectionKey,
1528
+ computed(() => {
1529
+ var _a;
1530
+ return {
1531
+ ...config.default,
1532
+ ...getObject((_a = props.componentVars) == null ? void 0 : _a[key])
1533
+ };
1534
+ })
1535
+ );
1536
+ }
1421
1537
  });
1422
1538
  }
1423
1539
  if (props.componentMap) {