knt-shared 1.10.1 → 1.10.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../../src/components/Form/useForm.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAkB,MAAM,SAAS,CAAC;AAEzF;;;;;GAKG;AACH,wBAAgB,OAAO,CACrB,OAAO,GAAE,cAAmB,GAC3B,CAAC,CAAC,YAAY,EAAE,GAAG,KAAK,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC,CAiWhE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,CAKpE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,OAAO,EAAE,UAAU,EAAE,EAAE,GAAG,UAAU,EAAE,CAEzE"}
1
+ {"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../../src/components/Form/useForm.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAkB,MAAM,SAAS,CAAC;AAEzF;;;;;GAKG;AACH,wBAAgB,OAAO,CACrB,OAAO,GAAE,cAAmB,GAC3B,CAAC,CAAC,YAAY,EAAE,GAAG,KAAK,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC,CAwXhE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,CAKpE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,OAAO,EAAE,UAAU,EAAE,EAAE,GAAG,UAAU,EAAE,CAEzE"}
package/dist/index.cjs.js CHANGED
@@ -5544,6 +5544,7 @@ function useForm(options = {}) {
5544
5544
  });
5545
5545
  };
5546
5546
  const register = async (formInstance) => {
5547
+ var _a;
5547
5548
  await vue.nextTick();
5548
5549
  if (unwatchFormRef) {
5549
5550
  unwatchFormRef();
@@ -5551,8 +5552,9 @@ function useForm(options = {}) {
5551
5552
  }
5552
5553
  formRef.value = formInstance;
5553
5554
  loadedRef.value = true;
5554
- if (options && Object.keys(options).length > 0) {
5555
- await setProps(options);
5555
+ const mergedProps = { ...options, ...propsRef.value };
5556
+ if (Object.keys(mergedProps).length > 0) {
5557
+ await setProps(mergedProps);
5556
5558
  }
5557
5559
  initFormModel();
5558
5560
  if (formInstance.formRef) {
@@ -5573,8 +5575,12 @@ function useForm(options = {}) {
5573
5575
  );
5574
5576
  }
5575
5577
  if (pendingValues.value) {
5576
- await setFieldsValue(pendingValues.value);
5577
- pendingValues.value = null;
5578
+ const registeredSchemas = (_a = formInstance.getSchema) == null ? void 0 : _a.call(formInstance);
5579
+ if (Array.isArray(registeredSchemas) && registeredSchemas.length > 0) {
5580
+ const pending = pendingValues.value;
5581
+ pendingValues.value = null;
5582
+ await setFieldsValue(pending);
5583
+ }
5578
5584
  }
5579
5585
  };
5580
5586
  const getForm = () => {
@@ -5606,11 +5612,18 @@ function useForm(options = {}) {
5606
5612
  return { ...formModel };
5607
5613
  };
5608
5614
  const setFieldsValue = async (values) => {
5615
+ var _a;
5609
5616
  const form = getFormSafe();
5610
5617
  if (!form) {
5611
5618
  pendingValues.value = { ...pendingValues.value, ...values };
5612
5619
  return;
5613
5620
  }
5621
+ const currentSchemas = (_a = form.getSchema) == null ? void 0 : _a.call(form);
5622
+ const hasSchemas = Array.isArray(currentSchemas) && currentSchemas.length > 0;
5623
+ if (!hasSchemas) {
5624
+ pendingValues.value = { ...pendingValues.value, ...values };
5625
+ return;
5626
+ }
5614
5627
  if (form.setFieldsValue) {
5615
5628
  await form.setFieldsValue(values);
5616
5629
  } else {
@@ -5738,6 +5751,11 @@ function useForm(options = {}) {
5738
5751
  if (form.setProps) {
5739
5752
  await form.setProps(formProps);
5740
5753
  }
5754
+ if (formProps.schemas && pendingValues.value) {
5755
+ const pending = pendingValues.value;
5756
+ pendingValues.value = null;
5757
+ await setFieldsValue(pending);
5758
+ }
5741
5759
  };
5742
5760
  const scrollToField = async (name, options2) => {
5743
5761
  const form = getFormSafe();