@qin-ui/antd-vue-pro 1.1.17 → 1.1.19

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.
@@ -15191,7 +15191,7 @@ function getPropByPath(obj, path, strict) {
15191
15191
  isValid: tempObj && keyArr[i2] in tempObj
15192
15192
  };
15193
15193
  }
15194
- function useForm$1(modelRef) {
15194
+ function useForm$2(modelRef) {
15195
15195
  let rulesRef = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ref({});
15196
15196
  let options = arguments.length > 2 ? arguments[2] : void 0;
15197
15197
  const initialModel = cloneDeep(unref(modelRef));
@@ -15463,7 +15463,7 @@ const Form = defineComponent({
15463
15463
  colon: true
15464
15464
  }),
15465
15465
  Item: FormItem,
15466
- useForm: useForm$1,
15466
+ useForm: useForm$2,
15467
15467
  // emits: ['finishFailed', 'submit', 'finish', 'validate'],
15468
15468
  setup(props, _ref) {
15469
15469
  let {
@@ -15752,8 +15752,6 @@ const FORM_DATA = Symbol("formData");
15752
15752
  const UPDATE_FORM_DATA = Symbol(
15753
15753
  "updateFormData"
15754
15754
  );
15755
- const UPDATE_REFS = Symbol("updateRefs");
15756
- const GET_REF = Symbol("getRef");
15757
15755
  const COMMAND = Symbol("command");
15758
15756
  const UPDATE_ACTIVE_PATH = Symbol(
15759
15757
  "setActivePath"
@@ -15795,16 +15793,26 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15795
15793
  ];
15796
15794
  const props = __props;
15797
15795
  useProviderDisabled(computed(() => props.disabled));
15798
- const updateRefs = inject(UPDATE_REFS);
15799
15796
  const getPath = (field) => {
15800
15797
  const path = (field == null ? void 0 : field.name) ?? [props.path, field == null ? void 0 : field.key].filter(Boolean);
15801
15798
  return toPath(path).join(".");
15802
15799
  };
15800
+ const formItemRefs = ref();
15803
15801
  const setFormItemRef = (el, field) => {
15802
+ var _a;
15804
15803
  if (!el)
15805
15804
  return;
15806
- const path = getPath(field);
15807
- updateRefs == null ? void 0 : updateRefs("formItemRefs", path, el);
15805
+ if (((_a = field.getFormItemRef) == null ? void 0 : _a.call(field)) === el)
15806
+ return;
15807
+ Object.assign(field, { getFormItemRef: () => el });
15808
+ };
15809
+ const setComponentRef = (el, field) => {
15810
+ var _a;
15811
+ if (!el)
15812
+ return;
15813
+ if (((_a = field.getComponentRef) == null ? void 0 : _a.call(field)) === el)
15814
+ return;
15815
+ Object.assign(field, { getComponentRef: () => el });
15808
15816
  };
15809
15817
  const proFormPropKeys = computed(() => {
15810
15818
  return [
@@ -15869,12 +15877,17 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15869
15877
  default: withCtx(() => [
15870
15878
  createVNode(unref(FormItem$1), mergeProps({ ref_for: true }, withDefault(field), {
15871
15879
  ref_for: true,
15872
- ref: (el) => setFormItemRef(el, field),
15880
+ ref_key: "formItemRefs",
15881
+ ref: formItemRefs,
15873
15882
  class: field.className,
15874
15883
  style: field.style,
15875
15884
  "hide-feedback": field.hideFeedback,
15876
15885
  name: unref(toPath)(getPath(field)),
15877
- path: getPath(field)
15886
+ path: getPath(field),
15887
+ onVnodeMounted: () => {
15888
+ var _a;
15889
+ return setFormItemRef((_a = formItemRefs.value) == null ? void 0 : _a[index2], field);
15890
+ }
15878
15891
  }), createSlots({
15879
15892
  default: withCtx(() => [
15880
15893
  field.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
@@ -15890,8 +15903,17 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15890
15903
  ref_for: true
15891
15904
  }, unref(omitFormItemProps)(field), {
15892
15905
  label: field.label,
15893
- path: getPath(field)
15894
- }), null, 16, ["label", "path"]))
15906
+ path: getPath(field),
15907
+ onSetComponentRef: (el) => setComponentRef(el, field),
15908
+ onFieldChange: () => {
15909
+ var _a;
15910
+ return (_a = formItemRefs.value) == null ? void 0 : _a[index2].onFieldChange();
15911
+ },
15912
+ onFieldBlur: () => {
15913
+ var _a;
15914
+ return (_a = formItemRefs.value) == null ? void 0 : _a[index2].onFieldBlur();
15915
+ }
15916
+ }), null, 16, ["label", "path", "onSetComponentRef", "onFieldChange", "onFieldBlur"]))
15895
15917
  ]),
15896
15918
  _: 2
15897
15919
  }, [
@@ -15908,7 +15930,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
15908
15930
  ])
15909
15931
  };
15910
15932
  })
15911
- ]), 1040, ["class", "style", "hide-feedback", "name", "path"])
15933
+ ]), 1040, ["class", "style", "hide-feedback", "name", "path", "onVnodeMounted"])
15912
15934
  ]),
15913
15935
  _: 2
15914
15936
  }, 1032, ["component", "path"])
@@ -16047,6 +16069,7 @@ const useFields = (initFields) => {
16047
16069
  getParentFields
16048
16070
  };
16049
16071
  };
16072
+ const useFields$1 = useFields;
16050
16073
  const useFormData = (initFormData) => {
16051
16074
  const formData = ref(initFormData);
16052
16075
  const activePath = ref();
@@ -16082,6 +16105,7 @@ const useFormData = (initFormData) => {
16082
16105
  };
16083
16106
  return { formData, getFormData, setFormData, activePath, setActivePath };
16084
16107
  };
16108
+ const useFormData$1 = useFormData;
16085
16109
  const useFormRef = () => {
16086
16110
  const formRef = ref();
16087
16111
  const setFormRef = (val) => {
@@ -16089,13 +16113,15 @@ const useFormRef = () => {
16089
16113
  };
16090
16114
  return { formRef, setFormRef };
16091
16115
  };
16116
+ const useFormRef$1 = useFormRef;
16092
16117
  const useForm = (initFormData = {}, initFields = []) => {
16093
16118
  return {
16094
- ...useFormData(initFormData),
16095
- ...useFields(initFields),
16096
- ...useFormRef()
16119
+ ...useFormData$1(initFormData),
16120
+ ...useFields$1(initFields),
16121
+ ...useFormRef$1()
16097
16122
  };
16098
16123
  };
16124
+ const useForm$1 = useForm;
16099
16125
  const isFunctionString = (param) => {
16100
16126
  FunctionRegexp.lastIndex = 0;
16101
16127
  ArrowFunctionRegexp.lastIndex = 0;
@@ -16212,7 +16238,7 @@ async function validateConditions(conditions, baseParam) {
16212
16238
  return result;
16213
16239
  }
16214
16240
  async function runRules(rules2, baseParam) {
16215
- const { form, run, refs, message: message2, logQueue } = baseParam;
16241
+ const { form, run, message: message2, logQueue } = baseParam;
16216
16242
  logQueue.push([[`逻辑执行规则: `, ["purple", "indent2"]]]);
16217
16243
  for (let ruleIndex = 0; ruleIndex < rules2.length; ruleIndex += 1) {
16218
16244
  const rule = rules2[ruleIndex];
@@ -16351,7 +16377,7 @@ const runCommands = async ({ path, trigger, ...baseParam }) => {
16351
16377
  ]);
16352
16378
  }
16353
16379
  };
16354
- const useCommand = ({ refs, form }) => {
16380
+ const useCommand = (form) => {
16355
16381
  let message$1;
16356
16382
  try {
16357
16383
  message$1 = message;
@@ -16365,7 +16391,6 @@ const useCommand = ({ refs, form }) => {
16365
16391
  path,
16366
16392
  trigger,
16367
16393
  form,
16368
- refs,
16369
16394
  message: message$1,
16370
16395
  run,
16371
16396
  logQueue
@@ -16384,6 +16409,7 @@ const useCommand = ({ refs, form }) => {
16384
16409
  };
16385
16410
  return { run };
16386
16411
  };
16412
+ const useCommand$1 = useCommand;
16387
16413
  const useInitProps = () => {
16388
16414
  const initPropsMap = /* @__PURE__ */ new Map();
16389
16415
  INIT_PROPS_MAP.forEach((val, key) => {
@@ -16400,6 +16426,7 @@ const useInitProps = () => {
16400
16426
  };
16401
16427
  return { getInitProps };
16402
16428
  };
16429
+ const useInitProps$1 = useInitProps;
16403
16430
  const _sfc_main$3 = /* @__PURE__ */ defineComponent({
16404
16431
  ...{
16405
16432
  name: "BaseField"
@@ -16410,20 +16437,23 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
16410
16437
  path: { default: "" },
16411
16438
  label: { default: "" }
16412
16439
  },
16413
- setup(__props) {
16440
+ emits: ["setComponentRef", "fieldChange", "fieldBlur"],
16441
+ setup(__props, { emit: __emit }) {
16414
16442
  const props = __props;
16443
+ const emit = __emit;
16415
16444
  const formData = inject(FORM_DATA);
16416
16445
  const updateFormData = inject(UPDATE_FORM_DATA);
16417
- const updateRefs = inject(UPDATE_REFS);
16418
- const getRef = inject(GET_REF);
16419
16446
  const command = inject(COMMAND);
16420
16447
  const updateActivePath = inject(UPDATE_ACTIVE_PATH);
16421
- const { getInitProps } = useInitProps();
16422
- const triggerRefChange = () => {
16448
+ const { getInitProps } = useInitProps$1();
16449
+ const componentRef = ref();
16450
+ const componentMounted = () => {
16451
+ emit("setComponentRef", componentRef.value);
16452
+ };
16453
+ const triggerFormItemChange = () => {
16423
16454
  if (typeof props.component === "string" && COMPONENT_MAP.has(props.component))
16424
16455
  return;
16425
- const formItemRef = getRef == null ? void 0 : getRef("formItemRefs", props.path);
16426
- formItemRef == null ? void 0 : formItemRef.onFieldChange();
16456
+ emit("fieldChange");
16427
16457
  };
16428
16458
  const value = computed({
16429
16459
  get() {
@@ -16436,7 +16466,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
16436
16466
  return;
16437
16467
  }
16438
16468
  updateFormData == null ? void 0 : updateFormData(props.path, val);
16439
- triggerRefChange();
16469
+ triggerFormItemChange();
16440
16470
  }
16441
16471
  });
16442
16472
  const forceUpdateKey = ref(0);
@@ -16497,11 +16527,6 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
16497
16527
  const is = computed(() => {
16498
16528
  return COMPONENT_MAP.get(props.component) ?? props.component;
16499
16529
  });
16500
- const setComponentRef = (el) => {
16501
- if (!el)
16502
- return;
16503
- updateRefs == null ? void 0 : updateRefs("fieldRefs", props.path, el);
16504
- };
16505
16530
  function handleFocus(...args) {
16506
16531
  var _a;
16507
16532
  updateActivePath == null ? void 0 : updateActivePath(props.path);
@@ -16514,12 +16539,14 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
16514
16539
  }, {
16515
16540
  default: withCtx(() => [
16516
16541
  (openBlock(), createBlock(resolveDynamicComponent(is.value), mergeProps({ key: forceUpdateKey.value }, unref(omit$1)(mergedAttrs.value, "componentContainer"), {
16517
- ref: setComponentRef,
16542
+ ref_key: "componentRef",
16543
+ ref: componentRef,
16518
16544
  [modelName.value]: value.value,
16519
16545
  ["onUpdate:" + modelName.value]: _cache[0] || (_cache[0] = ($event) => value.value = $event),
16520
16546
  class: [unref(attrs).componentClassName, "field-component"],
16521
16547
  style: unref(attrs).componentStyle,
16522
16548
  path: _ctx.path,
16549
+ onVnodeMounted: componentMounted,
16523
16550
  onFocus: handleFocus
16524
16551
  }), createSlots({ _: 2 }, [
16525
16552
  renderList(unref(attrs).slots, (slot, name) => {
@@ -16540,7 +16567,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
16540
16567
  };
16541
16568
  }
16542
16569
  });
16543
- const index_vue_vue_type_style_index_0_scoped_5475a3b8_lang = "";
16570
+ const index_vue_vue_type_style_index_0_scoped_aebf904c_lang = "";
16544
16571
  const _export_sfc = (sfc, props) => {
16545
16572
  const target = sfc.__vccOpts || sfc;
16546
16573
  for (const [key, val] of props) {
@@ -16548,7 +16575,7 @@ const _export_sfc = (sfc, props) => {
16548
16575
  }
16549
16576
  return target;
16550
16577
  };
16551
- const BaseField = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-5475a3b8"]]);
16578
+ const BaseField = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-aebf904c"]]);
16552
16579
  const _sfc_main$2 = /* @__PURE__ */ defineComponent({
16553
16580
  ...{
16554
16581
  name: "ContainerFragment",
@@ -16605,19 +16632,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
16605
16632
  const injectProps = useInjectProps(INJECT_KEYS["pro-form"]);
16606
16633
  const injectAttrs = omit$1(injectProps, Object.keys(props));
16607
16634
  const emit = __emit;
16608
- const refs = {
16609
- formItemRefs: {},
16610
- fieldRefs: {}
16611
- };
16612
- const updateRefs = (type4, path, childRef) => {
16613
- if (!path)
16614
- return;
16615
- refs[type4][path] = childRef;
16616
- };
16617
- const getRef = (type4, path) => {
16618
- return refs[type4][path];
16619
- };
16620
- const exposed = shallowReactive({ refs, getRef });
16621
16635
  const updateActivePath = (path) => {
16622
16636
  var _a, _b;
16623
16637
  if (props.form) {
@@ -16650,8 +16664,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
16650
16664
  updateActivePath(path);
16651
16665
  };
16652
16666
  const command = computed(() => {
16653
- return props.form && !props.autoCommandDisabled ? useCommand({ refs: exposed.refs, form: props.form }) : null;
16667
+ return props.form && !props.autoCommandDisabled ? useCommand$1(props.form) : null;
16654
16668
  });
16669
+ const exposed = shallowReactive({});
16655
16670
  const formInstanceRef = ref(null);
16656
16671
  onMounted(() => {
16657
16672
  var _a;
@@ -16664,8 +16679,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
16664
16679
  });
16665
16680
  provide(FORM_DATA, _formData);
16666
16681
  provide(UPDATE_FORM_DATA, updateFormData);
16667
- provide(UPDATE_REFS, updateRefs);
16668
- provide(GET_REF, getRef);
16669
16682
  provide(COMMAND, command);
16670
16683
  provide(UPDATE_ACTIVE_PATH, updateActivePath);
16671
16684
  __expose(exposed);
@@ -16693,7 +16706,6 @@ export {
16693
16706
  BaseField as B,
16694
16707
  COMPONENT_MAP as C,
16695
16708
  FORM_ITEM_SLOT_KEYS as F,
16696
- GET_REF as G,
16697
16709
  RULE_TYPE_MAP as R,
16698
16710
  UPDATE_FORM_DATA as U,
16699
16711
  _sfc_main as _,
@@ -16704,18 +16716,17 @@ export {
16704
16716
  _sfc_main$1 as e,
16705
16717
  FORM_DATA as f,
16706
16718
  get$1 as g,
16707
- UPDATE_REFS as h,
16708
- COMMAND as i,
16709
- UPDATE_ACTIVE_PATH as j,
16710
- FunctionRegexp as k,
16711
- ArrowFunctionRegexp as l,
16712
- isFunctionString as m,
16713
- jsonStringifyReplacer as n,
16719
+ COMMAND as h,
16720
+ UPDATE_ACTIVE_PATH as i,
16721
+ FunctionRegexp as j,
16722
+ ArrowFunctionRegexp as k,
16723
+ isFunctionString as l,
16724
+ jsonStringifyReplacer as m,
16725
+ jsonParseReviver as n,
16714
16726
  omit$1 as o,
16715
- jsonParseReviver as p,
16716
- useFields as q,
16717
- useFormData as r,
16718
- useCommand as s,
16719
- useInitProps as t,
16720
- useForm as u
16727
+ useFields$1 as p,
16728
+ useFormData$1 as q,
16729
+ useCommand$1 as r,
16730
+ useInitProps$1 as s,
16731
+ useForm$1 as u
16721
16732
  };
package/es/form/index.js CHANGED
@@ -1,30 +1,28 @@
1
- import { l, B, d, i, C, b, f, F, k, G, R, e, j, U, h, _, m, p, n, s, q, u, r, t } from "./index-7ee4d75c.js";
1
+ import { k, B, d, h, C, b, f, F, j, R, e, i, U, _, l, n, m, r, p, u, q, s } from "./index-e6fc6e90.js";
2
2
  import "vue";
3
3
  import "ant-design-vue";
4
4
  import "../component-provider/index.js";
5
5
  export {
6
- l as ArrowFunctionRegexp,
6
+ k as ArrowFunctionRegexp,
7
7
  B as BaseField,
8
8
  d as BaseFormItem,
9
- i as COMMAND,
9
+ h as COMMAND,
10
10
  C as COMPONENT_MAP,
11
11
  b as ContainerFragment,
12
12
  f as FORM_DATA,
13
13
  F as FORM_ITEM_SLOT_KEYS,
14
- k as FunctionRegexp,
15
- G as GET_REF,
14
+ j as FunctionRegexp,
16
15
  R as RULE_TYPE_MAP,
17
16
  e as SlotComponent,
18
- j as UPDATE_ACTIVE_PATH,
17
+ i as UPDATE_ACTIVE_PATH,
19
18
  U as UPDATE_FORM_DATA,
20
- h as UPDATE_REFS,
21
19
  _ as default,
22
- m as isFunctionString,
23
- p as jsonParseReviver,
24
- n as jsonStringifyReplacer,
25
- s as useCommand,
26
- q as useFields,
20
+ l as isFunctionString,
21
+ n as jsonParseReviver,
22
+ m as jsonStringifyReplacer,
23
+ r as useCommand,
24
+ p as useFields,
27
25
  u as useForm,
28
- r as useFormData,
29
- t as useInitProps
26
+ q as useFormData,
27
+ s as useInitProps
30
28
  };