@qin-ui/antd-vue-pro 2.4.4 → 2.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import "./antd-vue-pro.css";
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, normalizeStyle, useModel, watch, mergeModels, onMounted, normalizeClass, nextTick } from "vue";
2
+ import { defineComponent, createBlock, renderSlot, openBlock, resolveDynamicComponent, normalizeProps, mergeProps, withCtx, createElementBlock, isVNode, Fragment, createTextVNode, toDisplayString, inject, computed, toValue, ref, useAttrs, createCommentVNode, createSlots, renderList, createVNode, resolveComponent, unref, toRaw, provide, useSlots, shallowRef, onUpdated, triggerRef, createElementVNode, normalizeStyle, useModel, watch, mergeModels, onMounted, normalizeClass, nextTick } from "vue";
3
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";
4
- import { isPlainObject, getObject, toPath, useForm as useForm$1, resolveLocaleName, zhTW, enUS, zhCN, format, cloneDeep, InjectionFormSlotsKey, createFormProxy, InjectionFormKey, camelizeProperties, useFields as useFields$1, useFormRef as useFormRef$1, useSearchFormExpand, pick, isPromise, useTable as useTable$1 } from "@qin-ui/pro-components-core";
4
+ import { useForm as useForm$1, resolveLocaleName, zhTW, enUS, zhCN, format, cloneDeep, InjectionFormSlotsKey, isPlainObject, getObject, toPath, createFormProxy, InjectionFormKey, camelizeProperties, useFields as useFields$1, useFormRef as useFormRef$1, useSearchFormExpand, pick, isPromise, useTable as useTable$1 } from "@qin-ui/pro-components-core";
5
5
  import { enUS as enUS2, useFormData, zhCN as zhCN2, zhTW as zhTW2 } from "@qin-ui/pro-components-core";
6
- import { colProps } from "ant-design-vue/es/grid/Col";
7
- import { formItemProps, useInjectFormItemContext } from "ant-design-vue/es/form";
8
6
  import { useConfigContextInject } from "ant-design-vue/es/config-provider/context";
9
- import { useProviderDisabled, useInjectDisabled } from "ant-design-vue/es/config-provider/DisabledContext";
7
+ import { useInjectFormItemContext, formItemProps } from "ant-design-vue/es/form";
8
+ import { useInjectDisabled, useProviderDisabled } from "ant-design-vue/es/config-provider/DisabledContext";
9
+ import { colProps } from "ant-design-vue/es/grid/Col";
10
10
  import { tableProps } from "ant-design-vue/es/table";
11
11
  const getPopupContainer = (triggerNode) => {
12
12
  var _a;
@@ -148,6 +148,39 @@ const ensureInjectConfig = (key) => {
148
148
  DYNAMIC_INJECT_CONFIG[key] = created;
149
149
  return created;
150
150
  };
151
+ const _sfc_main$e = /* @__PURE__ */ defineComponent({
152
+ ...{ name: "ContainerFragment", inheritAttrs: false },
153
+ __name: "index",
154
+ props: {
155
+ component: { type: [Object, Function], default: void 0 }
156
+ },
157
+ setup(__props) {
158
+ const props = __props;
159
+ return (_ctx, _cache) => {
160
+ return props.component ? (openBlock(), createBlock(resolveDynamicComponent(props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), {
161
+ default: withCtx(() => [
162
+ renderSlot(_ctx.$slots, "default")
163
+ ]),
164
+ _: 3
165
+ }, 16)) : renderSlot(_ctx.$slots, "default", { key: 1 });
166
+ };
167
+ }
168
+ });
169
+ const _sfc_main$d = /* @__PURE__ */ defineComponent({
170
+ ...{ name: "SlotComponent", inheritAttrs: false },
171
+ __name: "index",
172
+ props: {
173
+ component: { type: [Object, Function, String, Number, Boolean, null], default: void 0 }
174
+ },
175
+ setup(__props) {
176
+ const props = __props;
177
+ return (_ctx, _cache) => {
178
+ 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 }, [
179
+ createTextVNode(toDisplayString(props.component), 1)
180
+ ], 64));
181
+ };
182
+ }
183
+ });
151
184
  const FORM_ITEM_SLOT_KEYS = [
152
185
  "label",
153
186
  "extra",
@@ -172,216 +205,6 @@ const componentMap = {
172
205
  "tree-select": TreeSelect,
173
206
  "transfer": Transfer
174
207
  };
175
- const formItemPropKeys = Object.keys(formItemProps()).concat([
176
- "formItemContainer"
177
- ]);
178
- const gridItemPropKeys = Object.keys(colProps());
179
- const gridItemPropKeySet = new Set(gridItemPropKeys);
180
- const formItemPropKeySet = new Set(formItemPropKeys);
181
- const formItemSlotKeySet = new Set(FORM_ITEM_SLOT_KEYS);
182
- function useGroupFieldAttrs(validFields) {
183
- const config = INJECT_CONFIG["pro-form-item"];
184
- const injectFormItemProps = inject(config.injectionKey, config.default);
185
- return computed(() => {
186
- const rawInject = toValue(injectFormItemProps) || {};
187
- return validFields.value.map((field) => {
188
- let gridItemProps2 = {};
189
- let formItemProps2 = {};
190
- const componentProps = { slots: {} };
191
- const formItemSlots = {};
192
- if (isPlainObject(field)) {
193
- const { path, name, fields, formItemClass, formItemStyle, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, formItemContainer, ...rest } = field;
194
- const {
195
- class: injectClassName,
196
- style: injectStyle,
197
- span: injectSpan,
198
- xs,
199
- sm,
200
- md,
201
- lg,
202
- xl,
203
- xxl,
204
- formItemContainer: injectFormItemContainer,
205
- ...injectRest
206
- } = rawInject;
207
- const initGridItemProps = span || span === 0 ? { span } : { xs, sm, md, lg, xl, xxl, span: injectSpan };
208
- gridItemProps2 = fields ? { span: span ?? 24 } : initGridItemProps;
209
- const container = formItemContainer ?? injectFormItemContainer;
210
- formItemProps2 = mergeProps(
211
- injectRest,
212
- { class: injectClassName, style: injectStyle },
213
- { class: toValue(formItemClass), style: toValue(formItemStyle) },
214
- formItemDataAttrs
215
- );
216
- Object.keys(rest).forEach((k) => {
217
- if (gridItemPropKeySet.has(k)) {
218
- gridItemProps2[k] = rest[k];
219
- } else if (formItemPropKeySet.has(k)) {
220
- formItemProps2[k] = rest[k];
221
- } else {
222
- componentProps[k] = rest[k];
223
- }
224
- });
225
- Object.assign(componentProps, componentDataAttrs);
226
- Object.keys(slots).forEach((k) => {
227
- if (formItemSlotKeySet.has(k)) {
228
- formItemSlots[k] = slots[k];
229
- } else {
230
- componentProps.slots[k] = slots[k];
231
- }
232
- });
233
- const raw2 = toValue(name) ?? toValue(path);
234
- return {
235
- path: Array.isArray(raw2) ? raw2.join(".") : raw2 || "",
236
- gridItemProps: gridItemProps2,
237
- formItemProps: formItemProps2,
238
- formItemSlots,
239
- componentProps,
240
- formItemContainer: container,
241
- rawField: field
242
- };
243
- }
244
- const raw = toValue(field == null ? void 0 : field.name) ?? toValue(field == null ? void 0 : field.path);
245
- return {
246
- path: Array.isArray(raw) ? raw.join(".") : raw || "",
247
- gridItemProps: gridItemProps2,
248
- formItemProps: formItemProps2,
249
- formItemSlots,
250
- componentProps,
251
- rawField: field
252
- };
253
- });
254
- });
255
- }
256
- const _sfc_main$e = /* @__PURE__ */ defineComponent({
257
- ...{ name: "BaseFormItem", inheritAttrs: false },
258
- __name: "index",
259
- props: {
260
- grid: { type: [Boolean, Object], default: void 0 },
261
- fields: { default: () => [] },
262
- disabled: { type: Boolean, default: void 0 }
263
- },
264
- setup(__props) {
265
- const props = __props;
266
- const validFields = computed(
267
- () => (
268
- // hidden 支持 Ref/ComputedRef/getter 等响应式形态(统一使用 toValue 取值)
269
- (props.fields ?? []).filter((field) => !toValue(field.hidden))
270
- )
271
- );
272
- useProviderDisabled(computed(() => props.disabled));
273
- const config = INJECT_CONFIG["pro-form"];
274
- const injectFormConfig = inject(config.injectionKey, config.default);
275
- const injectGrid = computed(() => {
276
- var _a;
277
- return (_a = toValue(injectFormConfig)) == null ? void 0 : _a.grid;
278
- });
279
- const enableGrid = computed(() => {
280
- if (props.grid !== void 0) return !!props.grid;
281
- return !!injectGrid.value;
282
- });
283
- const computedGridProps = computed(() => {
284
- return enableGrid.value ? { ...getObject(injectGrid.value), ...getObject(props.grid) } : {};
285
- });
286
- const formItemInstanceMap = /* @__PURE__ */ new WeakMap();
287
- const componentInstanceMap = /* @__PURE__ */ new WeakMap();
288
- const setFormItemRef = (field, el, formItemProps2) => {
289
- if (!field || typeof field !== "object") return;
290
- const raw = toRaw(field);
291
- if (el) {
292
- formItemInstanceMap.set(raw, el);
293
- raw.getFormItemRef = () => formItemInstanceMap.get(raw);
294
- raw.getFormItemComputedProps = () => formItemProps2;
295
- } else {
296
- formItemInstanceMap.delete(raw);
297
- delete raw.getFormItemRef;
298
- delete raw.getFormItemComputedProps;
299
- }
300
- };
301
- const setComponentRef = (field, el) => {
302
- if (!field || typeof field !== "object") return;
303
- const raw = toRaw(field);
304
- if (el) {
305
- componentInstanceMap.set(raw, el);
306
- raw.getComponentRef = () => {
307
- var _a;
308
- return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentRef();
309
- };
310
- raw.getComponentComputedProps = () => {
311
- var _a;
312
- return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentComputedProps();
313
- };
314
- } else {
315
- componentInstanceMap.delete(raw);
316
- delete raw.getComponentRef;
317
- delete raw.getComponentComputedProps;
318
- }
319
- };
320
- const groupedFields = useGroupFieldAttrs(validFields);
321
- return (_ctx, _cache) => {
322
- const _component_BaseFormItem = resolveComponent("BaseFormItem");
323
- return openBlock(), createBlock(unref(_sfc_main$c), mergeProps({
324
- component: enableGrid.value ? unref(Row) : void 0
325
- }, computedGridProps.value), {
326
- default: withCtx(() => [
327
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(groupedFields), (item, index2) => {
328
- return openBlock(), createBlock(unref(_sfc_main$c), mergeProps({
329
- key: item.path || index2,
330
- component: enableGrid.value ? unref(Col) : void 0
331
- }, { ref_for: true }, item.gridItemProps), {
332
- default: withCtx(() => [
333
- createVNode(unref(_sfc_main$c), {
334
- component: item.formItemContainer,
335
- path: item.path
336
- }, {
337
- default: withCtx(() => [
338
- createVNode(unref(FormItem), mergeProps({ ref_for: true }, item.formItemProps, {
339
- ref_for: true,
340
- ref: (el) => setFormItemRef(item.rawField, el, item.formItemProps),
341
- name: unref(toPath)(item.path),
342
- path: item.path
343
- }), createSlots({
344
- default: withCtx(() => [
345
- item.rawField.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
346
- key: 0,
347
- grid: item.rawField.grid ?? props.grid,
348
- fields: item.rawField.fields,
349
- disabled: toValue(item.rawField.disabled)
350
- }, null, 8, ["grid", "fields", "disabled"])) : (openBlock(), createBlock(unref(_sfc_main$d), mergeProps({
351
- key: 1,
352
- ref_for: true,
353
- ref: (el) => setComponentRef(item.rawField, el)
354
- }, { ref_for: true }, item.componentProps, {
355
- path: item.path
356
- }), null, 16, ["path"]))
357
- ]),
358
- _: 2
359
- }, [
360
- renderList(item.formItemSlots, (slot, name) => {
361
- return {
362
- name,
363
- fn: withCtx((scoped) => [
364
- createVNode(unref(_sfc_main$b), mergeProps({
365
- path: item.path,
366
- component: slot
367
- }, { ref_for: true }, scoped), null, 16, ["path", "component"])
368
- ])
369
- };
370
- })
371
- ]), 1040, ["name", "path"])
372
- ]),
373
- _: 2
374
- }, 1032, ["component", "path"])
375
- ]),
376
- _: 2
377
- }, 1040, ["component"]);
378
- }), 128))
379
- ]),
380
- _: 1
381
- }, 16, ["component"]);
382
- };
383
- }
384
- });
385
208
  function useForm(...args) {
386
209
  return useForm$1(...args);
387
210
  }
@@ -435,7 +258,7 @@ const useLocale = () => {
435
258
  };
436
259
  return { t, lang };
437
260
  };
438
- const _sfc_main$d = /* @__PURE__ */ defineComponent({
261
+ const _sfc_main$c = /* @__PURE__ */ defineComponent({
439
262
  ...{ name: "BaseField", inheritAttrs: false },
440
263
  __name: "index",
441
264
  props: {
@@ -443,6 +266,10 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
443
266
  path: { default: "" }
444
267
  },
445
268
  setup(__props, { expose: __expose }) {
269
+ const cloneDeepIfObject = (val) => (
270
+ // 原始值直接传递,引用值克隆快照
271
+ typeof val === "object" && val !== null ? cloneDeep(val) : val
272
+ );
446
273
  const props = __props;
447
274
  const { t } = useLocale();
448
275
  const form = useForm(false);
@@ -472,7 +299,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
472
299
  const { valueFormatter } = groupedAttrs.value;
473
300
  const setFormatter = typeof valueFormatter === "function" ? valueFormatter : typeof valueFormatter === "object" && typeof (valueFormatter == null ? void 0 : valueFormatter.set) === "function" ? valueFormatter.set : void 0;
474
301
  if (setFormatter) {
475
- const oldVal = setFormatter.length > 1 ? cloneDeep((_a = form.getFormData) == null ? void 0 : _a.call(form, props.path)) : void 0;
302
+ const oldVal = setFormatter.length > 1 ? cloneDeepIfObject((_a = form.getFormData) == null ? void 0 : _a.call(form, props.path)) : void 0;
476
303
  newVal = setFormatter(val, oldVal);
477
304
  }
478
305
  (_b = form.setFormData) == null ? void 0 : _b.call(form, props.path, newVal);
@@ -511,14 +338,14 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
511
338
  onUpdateValue
512
339
  };
513
340
  });
514
- const formSlots = inject(InjectionFormSlotsKey, void 0);
341
+ const injectedFormSlots = inject(InjectionFormSlotsKey, void 0);
515
342
  const customComponents = inject(INJECT_COMPONENTS, {});
516
343
  const is = computed(() => {
517
- var _a;
518
- const teleportSlot = props.path && (formSlots == null ? void 0 : formSlots[props.path]);
344
+ var _a, _b;
345
+ const teleportSlot = props.path && ((_a = injectedFormSlots == null ? void 0 : injectedFormSlots.value) == null ? void 0 : _a[props.path]);
519
346
  if (teleportSlot) return teleportSlot;
520
347
  if (typeof props.component === "string") {
521
- const resolved = ((_a = toValue(customComponents)) == null ? void 0 : _a[props.component]) || componentMap[props.component];
348
+ const resolved = ((_b = toValue(customComponents)) == null ? void 0 : _b[props.component]) || componentMap[props.component];
522
349
  if (resolved) return resolved;
523
350
  warnUnknownComponent(props.component);
524
351
  return props.component;
@@ -530,7 +357,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
530
357
  getComponentComputedProps: () => groupedAttrs.value.attrs
531
358
  });
532
359
  return (_ctx, _cache) => {
533
- return openBlock(), createBlock(unref(_sfc_main$c), {
360
+ return openBlock(), createBlock(_sfc_main$e, {
534
361
  component: groupedAttrs.value.componentContainer,
535
362
  path: props.path
536
363
  }, {
@@ -546,7 +373,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
546
373
  return {
547
374
  name,
548
375
  fn: withCtx((scoped) => [
549
- createVNode(unref(_sfc_main$b), mergeProps({
376
+ createVNode(_sfc_main$d, mergeProps({
550
377
  path: props.path
551
378
  }, scoped, { component: slot }), null, 16, ["path", "component"])
552
379
  ])
@@ -559,36 +386,236 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
559
386
  };
560
387
  }
561
388
  });
562
- const _sfc_main$c = /* @__PURE__ */ defineComponent({
563
- ...{ name: "ContainerFragment", inheritAttrs: false },
389
+ const formItemPropKeys = Object.keys(formItemProps()).concat([
390
+ "formItemContainer"
391
+ ]);
392
+ const gridItemPropKeys = Object.keys(colProps());
393
+ const gridItemPropKeySet = new Set(gridItemPropKeys);
394
+ const formItemPropKeySet = new Set(formItemPropKeys);
395
+ const formItemSlotKeySet = new Set(FORM_ITEM_SLOT_KEYS);
396
+ function useGroupFieldAttrs(validFields) {
397
+ const config = INJECT_CONFIG["pro-form-item"];
398
+ const injectFormItemProps = inject(config.injectionKey, config.default);
399
+ return computed(() => {
400
+ const rawInject = toValue(injectFormItemProps) || {};
401
+ return validFields.value.map((field) => {
402
+ let gridItemProps2 = {};
403
+ let formItemProps2 = {};
404
+ const componentProps = { slots: {} };
405
+ const formItemSlots = {};
406
+ if (isPlainObject(field)) {
407
+ const { path, name, fields, formItemClass, formItemStyle, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, formItemContainer, ...rest } = field;
408
+ const { class: injectClassName, style: injectStyle, span: injectSpan, xs, sm, md, lg, xl, xxl, formItemContainer: injectFormItemContainer, ...injectRest } = rawInject;
409
+ const initGridItemProps = span || span === 0 ? { span } : { xs, sm, md, lg, xl, xxl, span: injectSpan };
410
+ gridItemProps2 = fields ? { ...initGridItemProps, span: span ?? 24 } : initGridItemProps;
411
+ const container = formItemContainer ?? injectFormItemContainer;
412
+ formItemProps2 = mergeProps(
413
+ injectRest,
414
+ { class: injectClassName, style: injectStyle },
415
+ { class: toValue(formItemClass), style: toValue(formItemStyle) },
416
+ formItemDataAttrs
417
+ );
418
+ Object.keys(rest).forEach((k) => {
419
+ if (gridItemPropKeySet.has(k)) {
420
+ gridItemProps2[k] = rest[k];
421
+ } else if (formItemPropKeySet.has(k)) {
422
+ formItemProps2[k] = rest[k];
423
+ } else {
424
+ componentProps[k] = rest[k];
425
+ }
426
+ });
427
+ Object.assign(componentProps, componentDataAttrs);
428
+ Object.keys(slots).forEach((k) => {
429
+ if (formItemSlotKeySet.has(k)) {
430
+ formItemSlots[k] = slots[k];
431
+ } else {
432
+ componentProps.slots[k] = slots[k];
433
+ }
434
+ });
435
+ const raw2 = toValue(name) ?? toValue(path);
436
+ return {
437
+ path: Array.isArray(raw2) ? raw2.join(".") : raw2 || "",
438
+ gridItemProps: gridItemProps2,
439
+ formItemProps: formItemProps2,
440
+ formItemSlots,
441
+ componentProps,
442
+ formItemContainer: container,
443
+ rawField: field
444
+ };
445
+ }
446
+ const raw = toValue(field == null ? void 0 : field.name) ?? toValue(field == null ? void 0 : field.path);
447
+ return {
448
+ path: Array.isArray(raw) ? raw.join(".") : raw || "",
449
+ gridItemProps: gridItemProps2,
450
+ formItemProps: formItemProps2,
451
+ formItemSlots,
452
+ componentProps,
453
+ rawField: field
454
+ };
455
+ });
456
+ });
457
+ }
458
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
459
+ ...{ name: "BaseFormItem", inheritAttrs: false },
564
460
  __name: "index",
565
461
  props: {
566
- component: { type: [Object, Function], default: void 0 }
462
+ grid: { type: [Boolean, Object], default: void 0 },
463
+ fields: { default: () => [] },
464
+ disabled: { type: Boolean, default: void 0 }
567
465
  },
568
466
  setup(__props) {
467
+ let fieldKeySeed = 0;
468
+ const fieldKeyMap = /* @__PURE__ */ new WeakMap();
469
+ const getFieldKey = (field) => {
470
+ const raw = toRaw(field);
471
+ let key = fieldKeyMap.get(raw);
472
+ if (key === void 0) {
473
+ key = ++fieldKeySeed;
474
+ fieldKeyMap.set(raw, key);
475
+ }
476
+ return key;
477
+ };
569
478
  const props = __props;
479
+ const validFields = computed(
480
+ () => (
481
+ // hidden 支持 Ref/ComputedRef/getter 等响应式形态(统一使用 toValue 取值)
482
+ (props.fields ?? []).filter((field) => !toValue(field.hidden))
483
+ )
484
+ );
485
+ useProviderDisabled(computed(() => props.disabled));
486
+ const config = INJECT_CONFIG["pro-form"];
487
+ const injectFormConfig = inject(config.injectionKey, config.default);
488
+ const injectGrid = computed(() => {
489
+ var _a;
490
+ return (_a = toValue(injectFormConfig)) == null ? void 0 : _a.grid;
491
+ });
492
+ const enableGrid = computed(() => {
493
+ if (props.grid !== void 0) return !!props.grid;
494
+ return !!injectGrid.value;
495
+ });
496
+ const computedGridProps = computed(() => {
497
+ return enableGrid.value ? { ...getObject(injectGrid.value), ...getObject(props.grid) } : {};
498
+ });
499
+ const formItemInstanceMap = /* @__PURE__ */ new WeakMap();
500
+ const componentInstanceMap = /* @__PURE__ */ new WeakMap();
501
+ const warnedFrozenFields = /* @__PURE__ */ new WeakSet();
502
+ const defineFieldAccessors = (raw, accessors) => {
503
+ try {
504
+ for (const [key, getter] of Object.entries(accessors)) {
505
+ Object.defineProperty(raw, key, {
506
+ value: getter,
507
+ enumerable: false,
508
+ configurable: true,
509
+ writable: true
510
+ });
511
+ }
512
+ } catch {
513
+ if (!warnedFrozenFields.has(raw)) {
514
+ warnedFrozenFields.add(raw);
515
+ console.warn(
516
+ "[pro-components] 字段配置对象不可写(如被 Object.freeze),getFormItemRef / getComponentRef 等实例访问器挂载失败。"
517
+ );
518
+ }
519
+ }
520
+ };
521
+ const setFormItemRef = (field, el, formItemProps2) => {
522
+ if (!field || typeof field !== "object") return;
523
+ const raw = toRaw(field);
524
+ if (el) {
525
+ formItemInstanceMap.set(raw, el);
526
+ defineFieldAccessors(raw, {
527
+ getFormItemRef: () => formItemInstanceMap.get(raw),
528
+ getFormItemComputedProps: () => formItemProps2
529
+ });
530
+ } else {
531
+ formItemInstanceMap.delete(raw);
532
+ delete raw.getFormItemRef;
533
+ delete raw.getFormItemComputedProps;
534
+ }
535
+ };
536
+ const setComponentRef = (field, el) => {
537
+ if (!field || typeof field !== "object") return;
538
+ const raw = toRaw(field);
539
+ if (el) {
540
+ componentInstanceMap.set(raw, el);
541
+ defineFieldAccessors(raw, {
542
+ getComponentRef: () => {
543
+ var _a;
544
+ return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentRef();
545
+ },
546
+ getComponentComputedProps: () => {
547
+ var _a;
548
+ return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentComputedProps();
549
+ }
550
+ });
551
+ } else {
552
+ componentInstanceMap.delete(raw);
553
+ delete raw.getComponentRef;
554
+ delete raw.getComponentComputedProps;
555
+ }
556
+ };
557
+ const groupedFields = useGroupFieldAttrs(validFields);
570
558
  return (_ctx, _cache) => {
571
- return props.component ? (openBlock(), createBlock(resolveDynamicComponent(props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), {
559
+ const _component_BaseFormItem = resolveComponent("BaseFormItem");
560
+ return openBlock(), createBlock(_sfc_main$e, mergeProps({
561
+ component: enableGrid.value ? unref(Row) : void 0
562
+ }, computedGridProps.value), {
572
563
  default: withCtx(() => [
573
- renderSlot(_ctx.$slots, "default")
564
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(groupedFields), (item) => {
565
+ return openBlock(), createBlock(_sfc_main$e, mergeProps({
566
+ key: item.path || getFieldKey(item.rawField),
567
+ component: enableGrid.value ? unref(Col) : void 0
568
+ }, { ref_for: true }, item.gridItemProps), {
569
+ default: withCtx(() => [
570
+ createVNode(_sfc_main$e, {
571
+ component: item.formItemContainer,
572
+ path: item.path
573
+ }, {
574
+ default: withCtx(() => [
575
+ createVNode(unref(FormItem), mergeProps({ ref_for: true }, item.formItemProps, {
576
+ ref_for: true,
577
+ ref: (el) => setFormItemRef(item.rawField, el, item.formItemProps),
578
+ name: unref(toPath)(item.path),
579
+ path: item.path
580
+ }), createSlots({
581
+ default: withCtx(() => [
582
+ item.rawField.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
583
+ key: 0,
584
+ grid: item.rawField.grid ?? props.grid,
585
+ fields: item.rawField.fields,
586
+ disabled: toValue(item.rawField.disabled)
587
+ }, null, 8, ["grid", "fields", "disabled"])) : (openBlock(), createBlock(_sfc_main$c, mergeProps({
588
+ key: 1,
589
+ ref_for: true,
590
+ ref: (el) => setComponentRef(item.rawField, el)
591
+ }, { ref_for: true }, item.componentProps, {
592
+ path: item.path
593
+ }), null, 16, ["path"]))
594
+ ]),
595
+ _: 2
596
+ }, [
597
+ renderList(item.formItemSlots, (slot, name) => {
598
+ return {
599
+ name,
600
+ fn: withCtx((scoped) => [
601
+ createVNode(_sfc_main$d, mergeProps({
602
+ path: item.path,
603
+ component: slot
604
+ }, { ref_for: true }, scoped), null, 16, ["path", "component"])
605
+ ])
606
+ };
607
+ })
608
+ ]), 1040, ["name", "path"])
609
+ ]),
610
+ _: 2
611
+ }, 1032, ["component", "path"])
612
+ ]),
613
+ _: 2
614
+ }, 1040, ["component"]);
615
+ }), 128))
574
616
  ]),
575
- _: 3
576
- }, 16)) : renderSlot(_ctx.$slots, "default", { key: 1 });
577
- };
578
- }
579
- });
580
- const _sfc_main$b = /* @__PURE__ */ defineComponent({
581
- ...{ name: "SlotComponent", inheritAttrs: false },
582
- __name: "index",
583
- props: {
584
- component: { type: [Object, Function, String, Number, Boolean, null], default: void 0 }
585
- },
586
- setup(__props) {
587
- const props = __props;
588
- return (_ctx, _cache) => {
589
- 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 }, [
590
- createTextVNode(toDisplayString(props.component), 1)
591
- ], 64));
617
+ _: 1
618
+ }, 16, ["component"]);
592
619
  };
593
620
  }
594
621
  });
@@ -601,9 +628,9 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
601
628
  },
602
629
  setup(__props) {
603
630
  const props = __props;
604
- const fallbackForm = props.form ? void 0 : useForm();
631
+ let fallbackForm;
605
632
  const currentForm = computed(
606
- () => props.form ?? fallbackForm
633
+ () => props.form ?? (fallbackForm ?? (fallbackForm = useForm()))
607
634
  );
608
635
  const formProxy = createFormProxy(() => currentForm.value);
609
636
  provide(InjectionFormKey, formProxy);
@@ -623,6 +650,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
623
650
  let formInstanceCounter = 0;
624
651
  const formInstanceKeyMap = /* @__PURE__ */ new WeakMap();
625
652
  const getFormKey = (f) => {
653
+ if (f == null) return 0;
626
654
  if (!formInstanceKeyMap.has(f)) {
627
655
  formInstanceKeyMap.set(f, ++formInstanceCounter);
628
656
  }
@@ -641,7 +669,11 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
641
669
  return mergeProps(injectAttrs.value, camelizeProperties(attrs));
642
670
  });
643
671
  const slots = useSlots();
644
- provide(InjectionFormSlotsKey, slots);
672
+ const formSlotsRef = shallowRef(slots);
673
+ onUpdated(() => {
674
+ triggerRef(formSlotsRef);
675
+ });
676
+ provide(InjectionFormSlotsKey, formSlotsRef);
645
677
  return (_ctx, _cache) => {
646
678
  return openBlock(), createBlock(unref(Form), mergeProps({
647
679
  key: formKey.value,
@@ -649,7 +681,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
649
681
  model: formData.value
650
682
  }, formAttrs.value, { class: "pro-form" }), {
651
683
  default: withCtx(() => [
652
- createVNode(unref(_sfc_main$e), {
684
+ createVNode(_sfc_main$b, {
653
685
  fields: fields.value,
654
686
  grid: props.grid
655
687
  }, null, 8, ["fields", "grid"]),
@@ -734,7 +766,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
734
766
  emit("search");
735
767
  };
736
768
  return (_ctx, _cache) => {
737
- return openBlock(), createBlock(unref(_sfc_main$a), mergeProps(layoutProps.value, {
769
+ return openBlock(), createBlock(_sfc_main$a, mergeProps(layoutProps.value, {
738
770
  form: props.form,
739
771
  class: "pro-table_search-form transition"
740
772
  }), {
@@ -815,7 +847,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
815
847
  };
816
848
  }
817
849
  });
818
- const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-66c80dec"]]);
850
+ const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-2272aa98"]]);
819
851
  const _sfc_main$7 = /* @__PURE__ */ defineComponent({
820
852
  __name: "DefaultSearchFormContainer",
821
853
  setup(__props) {
@@ -974,11 +1006,12 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
974
1006
  );
975
1007
  },
976
1008
  set(val) {
1009
+ const checkedSet = new Set(val);
977
1010
  checkedColumnsOptions.value.forEach((item) => {
978
1011
  var _a, _b;
979
- if (item.disabled) return;
1012
+ if (item.disabled || item.checked === checkedSet.has(item.value)) return;
980
1013
  (_b = (_a = props.table) == null ? void 0 : _a.setColumn) == null ? void 0 : _b.call(_a, item.value, {
981
- hidden: !val.includes(item.value)
1014
+ hidden: !checkedSet.has(item.value)
982
1015
  });
983
1016
  });
984
1017
  }
@@ -1097,7 +1130,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1097
1130
  };
1098
1131
  }
1099
1132
  });
1100
- const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-f3a7a234"]]);
1133
+ const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-9152f113"]]);
1101
1134
  const _hoisted_1 = { class: "pro-table_header" };
1102
1135
  const _hoisted_2 = {
1103
1136
  key: 0,
@@ -1159,11 +1192,27 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1159
1192
  const size = useModel(__props, "size");
1160
1193
  const loading = useModel(__props, "loading");
1161
1194
  let searchSequence = 0;
1195
+ let warnedSearchConfig = false;
1196
+ const warnSearchConfig = (reason) => {
1197
+ if (warnedSearchConfig) return;
1198
+ warnedSearchConfig = true;
1199
+ console.warn(`[ProTable] ${reason}`);
1200
+ };
1162
1201
  const _search = async () => {
1163
1202
  var _a;
1164
- const seq = ++searchSequence;
1203
+ if (props.search && attrs.onSearch) {
1204
+ warnSearchConfig(
1205
+ "同时配置了 :search prop 与 @search 监听,@search 监听不会被执行,请仅保留其一。"
1206
+ );
1207
+ }
1165
1208
  const searchPromise = (_a = props.search || attrs.onSearch) == null ? void 0 : _a();
1166
- if (!isPromise(searchPromise)) return;
1209
+ if (!isPromise(searchPromise)) {
1210
+ warnSearchConfig(
1211
+ "search 未返回 Promise,本次查询不参与 loading 竞态管理(在途请求的 loading 状态保持不变)。"
1212
+ );
1213
+ return;
1214
+ }
1215
+ const seq = ++searchSequence;
1167
1216
  loading.value = true;
1168
1217
  try {
1169
1218
  await searchPromise;
@@ -1311,7 +1360,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1311
1360
  class: normalizeClass(["pro-table", unref(attrs).class]),
1312
1361
  style: normalizeStyle(unref(attrs).style)
1313
1362
  }, [
1314
- searchFormVisible.value || _ctx.$slots["search-form"] ? (openBlock(), createBlock(unref(_sfc_main$c), {
1363
+ searchFormVisible.value || _ctx.$slots["search-form"] ? (openBlock(), createBlock(_sfc_main$e, {
1315
1364
  key: 0,
1316
1365
  component: computedSearchFormConfig.value.container
1317
1366
  }, {
@@ -1331,7 +1380,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1331
1380
  ]),
1332
1381
  _: 3
1333
1382
  }, 8, ["component"])) : createCommentVNode("", true),
1334
- createVNode(unref(_sfc_main$c), { component: computedTableContainer.value }, {
1383
+ createVNode(_sfc_main$e, { component: computedTableContainer.value }, {
1335
1384
  default: withCtx(() => [
1336
1385
  createElementVNode("div", _hoisted_1, [
1337
1386
  _ctx.$slots["button-bar"] ? (openBlock(), createElementBlock("div", _hoisted_2, [
@@ -1341,13 +1390,13 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1341
1390
  renderSlot(_ctx.$slots, "toolbar", {}, void 0, true)
1342
1391
  ])) : createCommentVNode("", true),
1343
1392
  computedControl.value.sizeControl ? (openBlock(), createElementBlock("div", _hoisted_4, [
1344
- createVNode(unref(SizeControl), {
1393
+ createVNode(SizeControl, {
1345
1394
  size: size.value,
1346
1395
  "onUpdate:size": _cache[0] || (_cache[0] = ($event) => size.value = $event)
1347
1396
  }, null, 8, ["size"])
1348
1397
  ])) : createCommentVNode("", true),
1349
1398
  computedControl.value.columnControl ? (openBlock(), createElementBlock("div", _hoisted_5, [
1350
- createVNode(unref(ColumnControl), {
1399
+ createVNode(ColumnControl, {
1351
1400
  columns: computedColumns.value,
1352
1401
  table: props.table,
1353
1402
  "column-control": columnControlConfig.value
@@ -1380,7 +1429,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1380
1429
  };
1381
1430
  }
1382
1431
  });
1383
- const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-1e72e302"]]);
1432
+ const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-a75a38c5"]]);
1384
1433
  function useTable(params) {
1385
1434
  return useTable$1(params);
1386
1435
  }
@@ -1464,12 +1513,12 @@ const index = {
1464
1513
  }
1465
1514
  };
1466
1515
  export {
1467
- _sfc_main$c as ContainerFragment,
1516
+ _sfc_main$e as ContainerFragment,
1468
1517
  LOCALE_INJECT_KEY,
1469
1518
  _sfc_main as ProComponentProvider,
1470
1519
  _sfc_main$a as ProForm,
1471
1520
  ProTable,
1472
- _sfc_main$b as SlotComponent,
1521
+ _sfc_main$d as SlotComponent,
1473
1522
  index as default,
1474
1523
  enUS2 as enUS,
1475
1524
  useFields,