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.
package/dist/index.esm.js CHANGED
@@ -5542,6 +5542,7 @@ function useForm(options = {}) {
5542
5542
  });
5543
5543
  };
5544
5544
  const register = async (formInstance) => {
5545
+ var _a;
5545
5546
  await nextTick();
5546
5547
  if (unwatchFormRef) {
5547
5548
  unwatchFormRef();
@@ -5549,8 +5550,9 @@ function useForm(options = {}) {
5549
5550
  }
5550
5551
  formRef.value = formInstance;
5551
5552
  loadedRef.value = true;
5552
- if (options && Object.keys(options).length > 0) {
5553
- await setProps(options);
5553
+ const mergedProps = { ...options, ...propsRef.value };
5554
+ if (Object.keys(mergedProps).length > 0) {
5555
+ await setProps(mergedProps);
5554
5556
  }
5555
5557
  initFormModel();
5556
5558
  if (formInstance.formRef) {
@@ -5571,8 +5573,12 @@ function useForm(options = {}) {
5571
5573
  );
5572
5574
  }
5573
5575
  if (pendingValues.value) {
5574
- await setFieldsValue(pendingValues.value);
5575
- pendingValues.value = null;
5576
+ const registeredSchemas = (_a = formInstance.getSchema) == null ? void 0 : _a.call(formInstance);
5577
+ if (Array.isArray(registeredSchemas) && registeredSchemas.length > 0) {
5578
+ const pending = pendingValues.value;
5579
+ pendingValues.value = null;
5580
+ await setFieldsValue(pending);
5581
+ }
5576
5582
  }
5577
5583
  };
5578
5584
  const getForm = () => {
@@ -5604,11 +5610,18 @@ function useForm(options = {}) {
5604
5610
  return { ...formModel };
5605
5611
  };
5606
5612
  const setFieldsValue = async (values) => {
5613
+ var _a;
5607
5614
  const form = getFormSafe();
5608
5615
  if (!form) {
5609
5616
  pendingValues.value = { ...pendingValues.value, ...values };
5610
5617
  return;
5611
5618
  }
5619
+ const currentSchemas = (_a = form.getSchema) == null ? void 0 : _a.call(form);
5620
+ const hasSchemas = Array.isArray(currentSchemas) && currentSchemas.length > 0;
5621
+ if (!hasSchemas) {
5622
+ pendingValues.value = { ...pendingValues.value, ...values };
5623
+ return;
5624
+ }
5612
5625
  if (form.setFieldsValue) {
5613
5626
  await form.setFieldsValue(values);
5614
5627
  } else {
@@ -5736,6 +5749,11 @@ function useForm(options = {}) {
5736
5749
  if (form.setProps) {
5737
5750
  await form.setProps(formProps);
5738
5751
  }
5752
+ if (formProps.schemas && pendingValues.value) {
5753
+ const pending = pendingValues.value;
5754
+ pendingValues.value = null;
5755
+ await setFieldsValue(pending);
5756
+ }
5739
5757
  };
5740
5758
  const scrollToField = async (name, options2) => {
5741
5759
  const form = getFormSafe();