@vulcanjs/react-ui 0.7.2-alpha.5 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. package/dist/components/Datatable/Datatable.d.ts +39 -0
  2. package/dist/components/Datatable/DatatableCell.d.ts +26 -0
  3. package/dist/components/Datatable/DatatableContents.d.ts +53 -0
  4. package/dist/components/Datatable/DatatableFilter.d.ts +33 -0
  5. package/dist/components/Datatable/DatatableHeader.d.ts +23 -0
  6. package/dist/components/Datatable/DatatableRow.d.ts +25 -0
  7. package/dist/components/Datatable/DatatableSelect.d.ts +11 -0
  8. package/dist/components/Datatable/DatatableSorter.d.ts +8 -0
  9. package/dist/components/Datatable/DatatableSubmitSelected.d.ts +6 -0
  10. package/dist/components/Datatable/others/DeleteButton.d.ts +13 -0
  11. package/dist/components/Datatable/others/EditButton.d.ts +20 -0
  12. package/dist/components/Datatable/others/NewButton.d.ts +20 -0
  13. package/dist/components/HeadTags.d.ts +13 -0
  14. package/dist/components/LoadingButton.d.ts +11 -0
  15. package/dist/components/MutationButton.d.ts +20 -0
  16. package/dist/components/VulcanComponents/Context.d.ts.map +1 -1
  17. package/dist/components/VulcanComponents/defaultVulcanComponents/cellComponents.d.ts +3 -0
  18. package/dist/components/VulcanComponents/defaultVulcanComponents/coreComponents.d.ts +3 -0
  19. package/dist/components/VulcanComponents/defaultVulcanComponents/datatableComponents.d.ts +3 -0
  20. package/dist/components/VulcanComponents/defaultVulcanComponents/formComponents.d.ts +3 -0
  21. package/dist/components/bootstrap/Dropdown.d.ts +24 -0
  22. package/dist/components/bootstrap/Modal.d.ts +25 -0
  23. package/dist/components/bootstrap/ModalTrigger.d.ts +18 -0
  24. package/dist/components/bootstrap/TooltipTrigger.d.ts +6 -0
  25. package/dist/components/cell/CardItem.d.ts +14 -0
  26. package/dist/components/cell/CardItemArray.d.ts +6 -0
  27. package/dist/components/cell/CardItemDate.d.ts +5 -0
  28. package/dist/components/cell/CardItemDefault.d.ts +5 -0
  29. package/dist/components/cell/CardItemHTML.d.ts +5 -0
  30. package/dist/components/cell/CardItemImage.d.ts +6 -0
  31. package/dist/components/cell/CardItemNumber.d.ts +5 -0
  32. package/dist/components/cell/CardItemObject.d.ts +3 -0
  33. package/dist/components/cell/CardItemRelationHasMany.d.ts +3 -0
  34. package/dist/components/cell/CardItemRelationHasOne.d.ts +3 -0
  35. package/dist/components/cell/CardItemRelationItem.d.ts +15 -0
  36. package/dist/components/cell/CardItemString.d.ts +5 -0
  37. package/dist/components/cell/CardItemURL.d.ts +6 -0
  38. package/dist/components/core/Button.d.ts +4 -0
  39. package/dist/components/core/Loading.d.ts +3 -0
  40. package/dist/components/form/FieldErrors.d.ts +6 -0
  41. package/dist/components/form/Form/Form.d.ts +4 -0
  42. package/dist/components/form/Form/fields.d.ts +22 -0
  43. package/dist/components/form/Form/index.d.ts +3 -0
  44. package/dist/components/form/Form/typings.d.ts +76 -0
  45. package/dist/components/form/Form/utils.d.ts +2 -0
  46. package/dist/components/form/FormComponent.d.ts +31 -0
  47. package/dist/components/form/FormComponentInner.d.ts +32 -0
  48. package/dist/components/form/FormComponentLoader.d.ts +15 -0
  49. package/dist/components/form/FormContainer.d.ts +18 -0
  50. package/dist/components/form/FormContext.d.ts +25 -0
  51. package/dist/components/form/FormElement.d.ts +4 -0
  52. package/dist/components/form/FormError.d.ts +11 -0
  53. package/dist/components/form/FormErrors.d.ts +3 -0
  54. package/dist/components/form/FormGroup.d.ts +30 -0
  55. package/dist/components/form/FormIntl.d.ts +15 -0
  56. package/dist/components/form/FormLayout.d.ts +10 -0
  57. package/dist/components/form/FormNestedArray.d.ts +26 -0
  58. package/dist/components/form/FormNestedArrayLayout.d.ts +18 -0
  59. package/dist/components/form/FormNestedDivider.d.ts +13 -0
  60. package/dist/components/form/FormNestedItem.d.ts +52 -0
  61. package/dist/components/form/FormNestedObject.d.ts +35 -0
  62. package/dist/components/form/FormOptionLabel.d.ts +5 -0
  63. package/dist/components/form/FormSubmit.d.ts +38 -0
  64. package/dist/components/form/core/Button.d.ts +4 -0
  65. package/dist/components/form/core/Form/Form.d.ts.map +1 -1
  66. package/dist/components/form/core/Form/hooks.d.ts +16 -0
  67. package/dist/components/form/core/Form/hooks.d.ts.map +1 -0
  68. package/dist/components/form/core/FormComponent.d.ts +31 -0
  69. package/dist/components/form/core/FormComponentInner.d.ts +32 -0
  70. package/dist/components/form/core/FormComponentLoader.d.ts +15 -0
  71. package/dist/components/form/core/FormContainer.d.ts.map +1 -1
  72. package/dist/components/form/core/FormContext.d.ts +4 -7
  73. package/dist/components/form/core/FormContext.d.ts.map +1 -1
  74. package/dist/components/form/core/FormGroup.d.ts +30 -0
  75. package/dist/components/form/core/Loading.d.ts +3 -0
  76. package/dist/components/form/elements/FieldErrors.d.ts +5 -0
  77. package/dist/components/form/elements/FormElement.d.ts +4 -0
  78. package/dist/components/form/elements/FormError.d.ts +11 -0
  79. package/dist/components/form/elements/FormErrors.d.ts +3 -0
  80. package/dist/components/form/elements/FormLayout.d.ts +10 -0
  81. package/dist/components/form/elements/FormSubmit.d.ts +38 -0
  82. package/dist/components/form/elements/index.d.ts +7 -0
  83. package/dist/components/form/inputs/AutocompleteMultiple.d.ts +6 -0
  84. package/dist/components/form/inputs/BasicInputs.d.ts +16 -0
  85. package/dist/components/form/inputs/Checkboxgroup.d.ts +9 -0
  86. package/dist/components/form/inputs/FormItem.d.ts +4 -0
  87. package/dist/components/form/inputs/FormOptionLabel.d.ts +7 -0
  88. package/dist/components/form/inputs/RadioGroup.d.ts +4 -0
  89. package/dist/components/form/inputs/SelectInputs.d.ts +5 -0
  90. package/dist/components/form/inputs/consts.d.ts +9 -0
  91. package/dist/components/form/inputs/index.d.ts +8 -0
  92. package/dist/components/form/intl/FormIntl.d.ts +15 -0
  93. package/dist/components/form/modules/formFragments.d.ts +16 -0
  94. package/dist/components/form/modules/path_utils.d.ts +6 -0
  95. package/dist/components/form/modules/schema_utils.d.ts +14 -0
  96. package/dist/components/form/modules/utils.d.ts +17 -0
  97. package/dist/components/form/nested/FormNestedArray.d.ts +26 -0
  98. package/dist/components/form/nested/FormNestedArrayLayout.d.ts +18 -0
  99. package/dist/components/form/nested/FormNestedDivider.d.ts +13 -0
  100. package/dist/components/form/nested/FormNestedItem.d.ts +52 -0
  101. package/dist/components/form/nested/FormNestedObject.d.ts +35 -0
  102. package/dist/components/form/nested/index.d.ts +6 -0
  103. package/dist/components/form/ui_utils.d.ts +3 -0
  104. package/dist/components/form/useBlockTransition/block.d.ts +4 -0
  105. package/dist/components/form/useBlockTransition/useBlockTransition.d.ts +5 -0
  106. package/dist/components/form/useWarnOnUnsaved/index.d.ts +2 -0
  107. package/dist/components/form/useWarnOnUnsaved/useWarnOnUnsaved.d.ts +5 -0
  108. package/dist/decorators/autocomplete.d.ts +8 -0
  109. package/dist/decorators/index.d.ts +4 -0
  110. package/dist/index.d.ts +5 -5
  111. package/dist/index.d.ts.map +1 -1
  112. package/dist/index.js +125 -99
  113. package/dist/index.js.map +1 -1
  114. package/package.json +11 -11
package/dist/index.js CHANGED
@@ -665,11 +665,14 @@ var LoadingButton = /* @__PURE__ */ __name((_a) => {
665
665
  className: `loading-button ${loading ? "loading-button-loading" : "loading-button-notloading"} ${className}`,
666
666
  onClick
667
667
  }, rest), /* @__PURE__ */ React4.createElement("span", {
668
- style: wrapperStyle
668
+ style: wrapperStyle,
669
+ className: "loading-button-inner"
669
670
  }, /* @__PURE__ */ React4.createElement("span", {
670
- style: labelStyle
671
+ style: labelStyle,
672
+ className: "loading-button-label"
671
673
  }, label || children), /* @__PURE__ */ React4.createElement("span", {
672
- style: loadingStyle
674
+ style: loadingStyle,
675
+ className: "loading-button-loader"
673
676
  }, /* @__PURE__ */ React4.createElement(Components2.Loading, null))));
674
677
  }, "LoadingButton");
675
678
 
@@ -899,7 +902,7 @@ var useFormContext = /* @__PURE__ */ __name(() => {
899
902
  }, "useFormContext");
900
903
 
901
904
  // components/form/core/Form/Form.tsx
902
- import React7, { useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
905
+ import React7, { useEffect as useEffect2, useRef as useRef2, useState as useState3 } from "react";
903
906
  import { runCallbacks, getErrors } from "@vulcanjs/core";
904
907
  import { useIntlContext as useIntlContext2 } from "@vulcanjs/react-i18n";
905
908
  import { removeProperty } from "@vulcanjs/utils";
@@ -1553,6 +1556,46 @@ var useWarnOnUnsaved = /* @__PURE__ */ __name(({ isChanged, warnUnsavedChanges }
1553
1556
  });
1554
1557
  }, "useWarnOnUnsaved");
1555
1558
 
1559
+ // components/form/core/Form/hooks.ts
1560
+ import { useState as useState2 } from "react";
1561
+ var useSubmitCallbacks = /* @__PURE__ */ __name(() => {
1562
+ const [callbacks, setCallbacks] = useState2({
1563
+ submitFormCallbacks: [],
1564
+ successFormCallbacks: [],
1565
+ failureFormCallbacks: []
1566
+ });
1567
+ const addToSubmitForm = /* @__PURE__ */ __name((callback) => {
1568
+ setCallbacks((cbs) => __spreadProps(__spreadValues({}, cbs), {
1569
+ submitFormCallbacks: [
1570
+ ...cbs.submitFormCallbacks,
1571
+ callback
1572
+ ]
1573
+ }));
1574
+ }, "addToSubmitForm");
1575
+ const addToSuccessForm = /* @__PURE__ */ __name((callback) => {
1576
+ setCallbacks((cbs) => __spreadProps(__spreadValues({}, cbs), {
1577
+ successFormCallbacks: [
1578
+ ...cbs.successFormCallbacks,
1579
+ callback
1580
+ ]
1581
+ }));
1582
+ }, "addToSuccessForm");
1583
+ const addToFailureForm = /* @__PURE__ */ __name((callback) => {
1584
+ setCallbacks((cbs) => __spreadProps(__spreadValues({}, cbs), {
1585
+ failureFormCallbacks: [
1586
+ ...cbs.failureFormCallbacks,
1587
+ callback
1588
+ ]
1589
+ }));
1590
+ }, "addToFailureForm");
1591
+ return {
1592
+ callbacks,
1593
+ addToSuccessForm,
1594
+ addToSubmitForm,
1595
+ addToFailureForm
1596
+ };
1597
+ }, "useSubmitCallbacks");
1598
+
1556
1599
  // components/form/core/Form/Form.tsx
1557
1600
  function _extends4() {
1558
1601
  _extends4 = Object.assign || function(target) {
@@ -1569,6 +1612,8 @@ function _extends4() {
1569
1612
  return _extends4.apply(this, arguments);
1570
1613
  }
1571
1614
  __name(_extends4, "_extends");
1615
+ var NEW_FORM_TYPE = "new";
1616
+ var EDIT_FORM_TYPE = "edit";
1572
1617
  var compactParent = /* @__PURE__ */ __name((object, path) => {
1573
1618
  const parentPath = getParentPath(path);
1574
1619
  const compactIfArray = /* @__PURE__ */ __name((x) => Array.isArray(x) ? compact2(x) : x, "compactIfArray");
@@ -1581,8 +1626,8 @@ var compactObject = /* @__PURE__ */ __name((o) => omitBy(o, (f) => f === null ||
1581
1626
  var getInitialStateFromProps = /* @__PURE__ */ __name((nextProps) => {
1582
1627
  const schema = nextProps.schema || nextProps.model.schema;
1583
1628
  const convertedSchema = convertSchema(schema);
1584
- const formType = nextProps.document ? "edit" : "new";
1585
- const defaultValues = formType === "new" ? getDefaultValues(convertedSchema) : {};
1629
+ const formType = nextProps.document ? EDIT_FORM_TYPE : NEW_FORM_TYPE;
1630
+ const defaultValues = formType === NEW_FORM_TYPE ? getDefaultValues(convertedSchema) : {};
1586
1631
  const initialDocument = merge2({}, defaultValues, nextProps.prefilledProps, compactObject(nextProps.document));
1587
1632
  Object.keys(convertedSchema).forEach((key) => {
1588
1633
  let minCount = convertedSchema[key].minCount;
@@ -1645,7 +1690,7 @@ var getChildrenProps = /* @__PURE__ */ __name((props, state, options, callbacks)
1645
1690
  cancelCallback,
1646
1691
  revertCallback,
1647
1692
  document: currentDocument,
1648
- deleteDocument: formType === "edit" && showRemove && showDelete && deleteDocument || null
1693
+ deleteDocument: formType === EDIT_FORM_TYPE && showRemove && showDelete && deleteDocument || null
1649
1694
  };
1650
1695
  const formLayoutProps = {
1651
1696
  formProps,
@@ -1719,11 +1764,10 @@ var Form = /* @__PURE__ */ __name((props) => {
1719
1764
  };
1720
1765
  const allProps = __spreadValues(__spreadValues({}, defaultProps), props);
1721
1766
  const defaultValues = {};
1722
- const submitFormCallbacks = [];
1723
- const successFormCallbacks = [];
1724
- const failureFormCallbacks = [];
1725
1767
  const intl = useIntlContext2();
1726
- const [errors, setErrors] = useState2([]);
1768
+ const { callbacks, addToFailureForm, addToSubmitForm, addToSuccessForm } = useSubmitCallbacks();
1769
+ const { submitFormCallbacks, successFormCallbacks, failureFormCallbacks } = callbacks;
1770
+ const [errors, setErrors] = useState3([]);
1727
1771
  const throwError = /* @__PURE__ */ __name((error) => {
1728
1772
  let formErrors = getErrors(error);
1729
1773
  console.log(formErrors);
@@ -1735,49 +1779,18 @@ var Form = /* @__PURE__ */ __name((props) => {
1735
1779
  const clearFieldErrors = /* @__PURE__ */ __name((path) => {
1736
1780
  setErrors((prevErrors) => prevErrors.filter((error) => error.path !== path));
1737
1781
  }, "clearFieldErrors");
1738
- const [deletedValues, setDeletedValues] = useState2([]);
1782
+ const [deletedValues, setDeletedValues] = useState3([]);
1739
1783
  const addToDeletedValues = /* @__PURE__ */ __name((name) => {
1740
1784
  setDeletedValues((prevDeletedValues) => [
1741
1785
  ...prevDeletedValues,
1742
1786
  name
1743
1787
  ]);
1744
1788
  }, "addToDeletedValues");
1745
- const [callbacks, setCallbacks] = useState2({
1746
- submitFormCallbacks: [],
1747
- successFormCallbacks: [],
1748
- failureFormCallbacks: []
1749
- });
1750
- const addToSubmitForm = /* @__PURE__ */ __name((callback) => {
1751
- setCallbacks((cbs) => __spreadValues({}, cbs));
1752
- }, "addToSubmitForm");
1753
- const addToSuccessForm = /* @__PURE__ */ __name((callback) => {
1754
- setCallbacks((cbs) => __spreadProps(__spreadValues({}, cbs), {
1755
- successFormCallbacks: [
1756
- ...cbs.successFormCallbacks,
1757
- callback
1758
- ]
1759
- }));
1760
- }, "addToSuccessForm");
1761
- const addToFailureForm = /* @__PURE__ */ __name((callback) => {
1762
- setCallbacks((cbs) => __spreadProps(__spreadValues({}, cbs), {
1763
- failureFormCallbacks: [
1764
- ...cbs.failureFormCallbacks,
1765
- callback
1766
- ]
1767
- }));
1768
- }, "addToFailureForm");
1769
- const clearFormCallbacks = /* @__PURE__ */ __name(() => {
1770
- setCallbacks({
1771
- submitFormCallbacks: [],
1772
- successFormCallbacks: [],
1773
- failureFormCallbacks: []
1774
- });
1775
- }, "clearFormCallbacks");
1776
- const [currentValues, setCurrentValues] = useState2({});
1777
- const submitFormContext = /* @__PURE__ */ __name((formType) => (event) => {
1778
- submitForm(formType)(event);
1789
+ const [currentValues, setCurrentValues] = useState3({});
1790
+ const submitFormContext = /* @__PURE__ */ __name(async (event) => {
1791
+ await submitForm(event);
1779
1792
  }, "submitFormContext");
1780
- const [currentDocument, setCurrentDocument] = useState2(initialDocument);
1793
+ const [currentDocument, setCurrentDocument] = useState3(initialDocument);
1781
1794
  const updateCurrentValues = /* @__PURE__ */ __name((newValues, options = {}) => {
1782
1795
  const { mode = "overwrite" } = options;
1783
1796
  const { changeCallback } = props;
@@ -1818,8 +1831,8 @@ var Form = /* @__PURE__ */ __name((props) => {
1818
1831
  props.refetch();
1819
1832
  }
1820
1833
  }, "refetchForm");
1821
- const [disabled, setDisabled] = useState2(!!props.disabled);
1822
- const [success, setSuccess] = useState2(false);
1834
+ const [disabled, setDisabled] = useState3(!!props.disabled);
1835
+ const [success, setSuccess] = useState3(false);
1823
1836
  const clearForm = /* @__PURE__ */ __name((options = {}) => {
1824
1837
  const { document: optionsDocument } = options;
1825
1838
  const document = optionsDocument ? merge2({}, props.prefilledProps, optionsDocument) : null;
@@ -1830,21 +1843,21 @@ var Form = /* @__PURE__ */ __name((props) => {
1830
1843
  setDisabled(false);
1831
1844
  }, "clearForm");
1832
1845
  const newMutationSuccessCallback = /* @__PURE__ */ __name(function(result) {
1833
- mutationSuccessCallback(result, "new");
1846
+ mutationSuccessCallback(result, NEW_FORM_TYPE);
1834
1847
  }, "newMutationSuccessCallback");
1835
1848
  const editMutationSuccessCallback = /* @__PURE__ */ __name(function(result) {
1836
- mutationSuccessCallback(result, "edit");
1849
+ mutationSuccessCallback(result, EDIT_FORM_TYPE);
1837
1850
  }, "editMutationSuccessCallback");
1838
1851
  const formRef = useRef2(null);
1839
1852
  const mutationSuccessCallback = /* @__PURE__ */ __name(function(result, mutationType) {
1840
1853
  setDisabled(false);
1841
1854
  setSuccess(true);
1842
- if (mutationType === "new")
1855
+ if (mutationType === NEW_FORM_TYPE)
1843
1856
  refetchForm();
1844
1857
  let { document } = result;
1845
1858
  if (formRef.current) {
1846
1859
  clearForm({
1847
- document: mutationType === "edit" ? document : void 0
1860
+ document: mutationType === EDIT_FORM_TYPE ? document : void 0
1848
1861
  });
1849
1862
  }
1850
1863
  document = runCallbacks({
@@ -1883,16 +1896,7 @@ var Form = /* @__PURE__ */ __name((props) => {
1883
1896
  form: void 0
1884
1897
  });
1885
1898
  }, "mutationErrorCallback");
1886
- const submitForm = /* @__PURE__ */ __name((formType) => async (event) => {
1887
- var _a, _b;
1888
- event && event.preventDefault();
1889
- event && event.stopPropagation();
1890
- const { contextName } = props;
1891
- if (disabled) {
1892
- return;
1893
- }
1894
- setErrors([]);
1895
- setDisabled(true);
1899
+ const getSubmitData = /* @__PURE__ */ __name(() => {
1896
1900
  let data = getData({
1897
1901
  replaceIntlFields: true,
1898
1902
  addExtraFields: false,
@@ -1907,42 +1911,64 @@ var Form = /* @__PURE__ */ __name((props) => {
1907
1911
  if (props.submitCallback) {
1908
1912
  data = props.submitCallback(data) || data;
1909
1913
  }
1910
- if (formType === "new") {
1911
- try {
1912
- const result = await createDocument({
1913
- input: {
1914
- data,
1915
- contextName
1916
- }
1917
- });
1918
- if ((_a = result.errors) == null ? void 0 : _a.length) {
1919
- mutationErrorCallback(document1, result.errors[0]);
1920
- } else {
1921
- newMutationSuccessCallback(result);
1914
+ return data;
1915
+ }, "getSubmitData");
1916
+ const submitFormCreate = /* @__PURE__ */ __name(async (event) => {
1917
+ var _a;
1918
+ event && event.preventDefault();
1919
+ event && event.stopPropagation();
1920
+ const { contextName } = props;
1921
+ if (disabled) {
1922
+ return;
1923
+ }
1924
+ setErrors([]);
1925
+ setDisabled(true);
1926
+ const data = getSubmitData();
1927
+ try {
1928
+ const result = await createDocument({
1929
+ input: {
1930
+ data,
1931
+ contextName
1922
1932
  }
1923
- } catch (error) {
1924
- mutationErrorCallback(document1, error);
1933
+ });
1934
+ if ((_a = result.errors) == null ? void 0 : _a.length) {
1935
+ mutationErrorCallback(document1, result.errors[0]);
1936
+ } else {
1937
+ newMutationSuccessCallback(result);
1925
1938
  }
1926
- } else {
1927
- try {
1928
- const documentId = currentDocument._id;
1929
- const result = await updateDocument({
1930
- input: {
1931
- id: documentId,
1932
- data,
1933
- contextName
1934
- }
1935
- });
1936
- if ((_b = result.errors) == null ? void 0 : _b.length) {
1937
- mutationErrorCallback(document1, result.errors[0]);
1938
- } else {
1939
- editMutationSuccessCallback(result);
1939
+ } catch (error) {
1940
+ mutationErrorCallback(document1, error);
1941
+ }
1942
+ }, "submitFormCreate");
1943
+ const submitFormUpdate = /* @__PURE__ */ __name(async (event) => {
1944
+ var _a;
1945
+ event && event.preventDefault();
1946
+ event && event.stopPropagation();
1947
+ const { contextName } = props;
1948
+ if (disabled) {
1949
+ return;
1950
+ }
1951
+ setErrors([]);
1952
+ setDisabled(true);
1953
+ const data = getSubmitData();
1954
+ try {
1955
+ const documentId = currentDocument._id;
1956
+ const result = await updateDocument({
1957
+ input: {
1958
+ id: documentId,
1959
+ data,
1960
+ contextName
1940
1961
  }
1941
- } catch (error) {
1942
- mutationErrorCallback(document1, error);
1962
+ });
1963
+ if ((_a = result.errors) == null ? void 0 : _a.length) {
1964
+ mutationErrorCallback(document1, result.errors[0]);
1965
+ } else {
1966
+ editMutationSuccessCallback(result);
1943
1967
  }
1968
+ } catch (error) {
1969
+ mutationErrorCallback(document1, error);
1944
1970
  }
1945
- }, "submitForm");
1971
+ }, "submitFormUpdate");
1946
1972
  const deleteDocumentWithConfirm = /* @__PURE__ */ __name(() => {
1947
1973
  const document = currentDocument;
1948
1974
  const documentId = props.document._id;
@@ -1971,13 +1997,14 @@ var Form = /* @__PURE__ */ __name((props) => {
1971
1997
  }, "deleteDocumentWithConfirm");
1972
1998
  const { successComponent, document: document1, currentUser, model, warnUnsavedChanges } = props;
1973
1999
  const FormComponents = useVulcanComponents();
1974
- const formType1 = document1 ? "edit" : "new";
1975
- const mutableFields = formType1 === "edit" ? getEditableFields(schema, currentUser, initialDocument) : getInsertableFields(schema, currentUser);
2000
+ const formType = document1 ? EDIT_FORM_TYPE : NEW_FORM_TYPE;
2001
+ const submitForm = formType === NEW_FORM_TYPE ? submitFormCreate : submitFormUpdate;
2002
+ const mutableFields = formType === EDIT_FORM_TYPE ? getEditableFields(schema, currentUser, initialDocument) : getInsertableFields(schema, currentUser);
1976
2003
  const { formLayoutProps, formGroupProps } = getChildrenProps(props, {
1977
2004
  disabled,
1978
2005
  currentDocument
1979
2006
  }, {
1980
- formType: formType1
2007
+ formType
1981
2008
  }, {
1982
2009
  deleteDocument: deleteDocumentWithConfirm
1983
2010
  });
@@ -1991,7 +2018,7 @@ var Form = /* @__PURE__ */ __name((props) => {
1991
2018
  clearForm,
1992
2019
  refetchForm,
1993
2020
  isChanged,
1994
- submitForm: submitFormContext(formType1),
2021
+ submitForm: submitFormContext,
1995
2022
  addToDeletedValues,
1996
2023
  updateCurrentValues,
1997
2024
  getDocument: () => currentDocument,
@@ -2000,7 +2027,6 @@ var Form = /* @__PURE__ */ __name((props) => {
2000
2027
  addToSubmitForm,
2001
2028
  addToSuccessForm,
2002
2029
  addToFailureForm,
2003
- clearFormCallbacks,
2004
2030
  errors,
2005
2031
  currentValues,
2006
2032
  deletedValues,