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

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../components/VulcanComponents/Context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAiB1D,eAAO,MAAM,uBAAuB,yCASjC,CAAC"}
1
+ {"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../components/VulcanComponents/Context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAgB1D,eAAO,MAAM,uBAAuB,yCASjC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../../../components/form/core/Form/Form.tsx"],"names":[],"mappings":"AAmDA,OAAO,EAEL,SAAS,EAGV,MAAM,WAAW,CAAC;AA+PnB,eAAO,MAAM,IAAI,UAAW,SAAS,QAokBpC,CAAC;AAeF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../../../components/form/core/Form/Form.tsx"],"names":[],"mappings":"AAmDA,OAAO,EAEL,SAAS,EAGV,MAAM,WAAW,CAAC;AAwQnB,eAAO,MAAM,IAAI,UAAW,SAAS,QA6hBpC,CAAC;AAeF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,16 @@
1
+ export interface AddSubmitCallbacks {
2
+ addToSubmitForm: (cb: any) => void;
3
+ addToSuccessForm: (cb: any) => void;
4
+ addToFailureForm: (cb: any) => void;
5
+ }
6
+ export declare const useSubmitCallbacks: () => {
7
+ callbacks: {
8
+ submitFormCallbacks: Array<any>;
9
+ successFormCallbacks: Array<any>;
10
+ failureFormCallbacks: Array<any>;
11
+ };
12
+ addToSuccessForm: (callback: any) => void;
13
+ addToSubmitForm: (callback: any) => void;
14
+ addToFailureForm: (callback: any) => void;
15
+ };
16
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../../../components/form/core/Form/hooks.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,kBAAkB;IAMjC,eAAe,EAAE,CAAC,EAAE,EAAE,GAAG,KAAK,IAAI,CAAC;IAMnC,gBAAgB,EAAE,CAAC,EAAE,EAAE,GAAG,KAAK,IAAI,CAAC;IAMpC,gBAAgB,EAAE,CAAC,EAAE,EAAE,GAAG,KAAK,IAAI,CAAC;CACrC;AAID,eAAO,MAAM,kBAAkB;;6BAEN,MAAM,GAAG,CAAC;8BACT,MAAM,GAAG,CAAC;8BACV,MAAM,GAAG,CAAC;;;;;CAiCnC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"FormContainer.d.ts","sourceRoot":"","sources":["../../../../components/form/core/FormContainer.tsx"],"names":[],"mappings":";AAiDA,OAAO,EAAE,kBAAkB,EAAmB,MAAM,mBAAmB,CAAC;AAiBxE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAmBrD,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC7D,KAAK,EAAE,kBAAkB,CAAC;IAE1B,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,IAAI,CAAC,EAAE,MAAM,CAAC;IAId,MAAM,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAIvB,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAU1B,WAAW,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AACD,oBAAY,cAAc,GAAG,kBAAkB,CAAC;AA4FhD,eAAO,MAAM,aAAa,UAAW,kBAAkB,gBAkLtD,CAAC;AAqDF,eAAO,MAAM,SAAS,UAvOe,kBAAkB,gBAuOjB,CAAC;AAEvC,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"FormContainer.d.ts","sourceRoot":"","sources":["../../../../components/form/core/FormContainer.tsx"],"names":[],"mappings":";AAiDA,OAAO,EAAE,kBAAkB,EAAmB,MAAM,mBAAmB,CAAC;AAiBxE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAmBrD,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC7D,KAAK,EAAE,kBAAkB,CAAC;IAE1B,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,IAAI,CAAC,EAAE,MAAM,CAAC;IAId,MAAM,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAIvB,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAU1B,WAAW,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AACD,oBAAY,cAAc,GAAG,kBAAkB,CAAC;AA4FhD,eAAO,MAAM,aAAa,UAAW,kBAAkB,gBAuKtD,CAAC;AAqDF,eAAO,MAAM,SAAS,UA5Ne,kBAAkB,gBA4NjB,CAAC;AAEvC,eAAe,aAAa,CAAC"}
@@ -1,11 +1,7 @@
1
1
  import React from "react";
2
- interface FormContextValue {
3
- addToDeletedValues: Function;
4
- addToFailureForm: Function;
5
- addToSubmitForm: Function;
6
- addToSuccessForm: Function;
2
+ import { AddSubmitCallbacks } from "./Form/hooks";
3
+ interface FormContextValue extends AddSubmitCallbacks {
7
4
  clearForm: Function;
8
- clearFormCallbacks: Function;
9
5
  clearFieldErrors: Function;
10
6
  currentValues: object;
11
7
  deletedValues: Array<any>;
@@ -19,6 +15,7 @@ interface FormContextValue {
19
15
  throwError: Function;
20
16
  updateCurrentValues: Function;
21
17
  disabled: boolean;
18
+ addToDeletedValues: Function;
22
19
  }
23
20
  export declare const FormContext: React.Context<FormContextValue | undefined>;
24
21
  export declare const useFormContext: () => FormContextValue;
@@ -1 +1 @@
1
- {"version":3,"file":"FormContext.d.ts","sourceRoot":"","sources":["../../../../components/form/core/FormContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,UAAU,gBAAgB;IACxB,kBAAkB,EAAE,QAAQ,CAAC;IAC7B,gBAAgB,EAAE,QAAQ,CAAC;IAC3B,eAAe,EAAE,QAAQ,CAAC;IAC1B,gBAAgB,EAAE,QAAQ,CAAC;IAC3B,SAAS,EAAE,QAAQ,CAAC;IACpB,kBAAkB,EAAE,QAAQ,CAAC;IAC7B,gBAAgB,EAAE,QAAQ,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAC1B,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,WAAW,EAAE,QAAQ,CAAC;IACtB,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9D,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,QAAQ,CAAC;IAItB,UAAU,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,UAAU,EAAE,QAAQ,CAAC;IACrB,mBAAmB,EAAE,QAAQ,CAAC;IAC9B,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,WAAW,6CAEvB,CAAC;AAEF,eAAO,MAAM,cAAc,wBAS1B,CAAC"}
1
+ {"version":3,"file":"FormContext.d.ts","sourceRoot":"","sources":["../../../../components/form/core/FormContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,UAAU,gBAAiB,SAAQ,kBAAkB;IACnD,SAAS,EAAE,QAAQ,CAAC;IACpB,gBAAgB,EAAE,QAAQ,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAC1B,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,WAAW,EAAE,QAAQ,CAAC;IACtB,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9D,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,QAAQ,CAAC;IAItB,UAAU,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,UAAU,EAAE,QAAQ,CAAC;IACrB,mBAAmB,EAAE,QAAQ,CAAC;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE,QAAQ,CAAC;CAC9B;AAED,eAAO,MAAM,WAAW,6CAEvB,CAAC;AAEF,eAAO,MAAM,cAAc,wBAS1B,CAAC"}
package/dist/index.js CHANGED
@@ -902,7 +902,7 @@ var useFormContext = /* @__PURE__ */ __name(() => {
902
902
  }, "useFormContext");
903
903
 
904
904
  // components/form/core/Form/Form.tsx
905
- 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";
906
906
  import { runCallbacks, getErrors } from "@vulcanjs/core";
907
907
  import { useIntlContext as useIntlContext2 } from "@vulcanjs/react-i18n";
908
908
  import { removeProperty } from "@vulcanjs/utils";
@@ -1556,6 +1556,46 @@ var useWarnOnUnsaved = /* @__PURE__ */ __name(({ isChanged, warnUnsavedChanges }
1556
1556
  });
1557
1557
  }, "useWarnOnUnsaved");
1558
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
+
1559
1599
  // components/form/core/Form/Form.tsx
1560
1600
  function _extends4() {
1561
1601
  _extends4 = Object.assign || function(target) {
@@ -1572,6 +1612,8 @@ function _extends4() {
1572
1612
  return _extends4.apply(this, arguments);
1573
1613
  }
1574
1614
  __name(_extends4, "_extends");
1615
+ var NEW_FORM_TYPE = "new";
1616
+ var EDIT_FORM_TYPE = "edit";
1575
1617
  var compactParent = /* @__PURE__ */ __name((object, path) => {
1576
1618
  const parentPath = getParentPath(path);
1577
1619
  const compactIfArray = /* @__PURE__ */ __name((x) => Array.isArray(x) ? compact2(x) : x, "compactIfArray");
@@ -1584,8 +1626,8 @@ var compactObject = /* @__PURE__ */ __name((o) => omitBy(o, (f) => f === null ||
1584
1626
  var getInitialStateFromProps = /* @__PURE__ */ __name((nextProps) => {
1585
1627
  const schema = nextProps.schema || nextProps.model.schema;
1586
1628
  const convertedSchema = convertSchema(schema);
1587
- const formType = nextProps.document ? "edit" : "new";
1588
- 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) : {};
1589
1631
  const initialDocument = merge2({}, defaultValues, nextProps.prefilledProps, compactObject(nextProps.document));
1590
1632
  Object.keys(convertedSchema).forEach((key) => {
1591
1633
  let minCount = convertedSchema[key].minCount;
@@ -1648,7 +1690,7 @@ var getChildrenProps = /* @__PURE__ */ __name((props, state, options, callbacks)
1648
1690
  cancelCallback,
1649
1691
  revertCallback,
1650
1692
  document: currentDocument,
1651
- deleteDocument: formType === "edit" && showRemove && showDelete && deleteDocument || null
1693
+ deleteDocument: formType === EDIT_FORM_TYPE && showRemove && showDelete && deleteDocument || null
1652
1694
  };
1653
1695
  const formLayoutProps = {
1654
1696
  formProps,
@@ -1722,11 +1764,10 @@ var Form = /* @__PURE__ */ __name((props) => {
1722
1764
  };
1723
1765
  const allProps = __spreadValues(__spreadValues({}, defaultProps), props);
1724
1766
  const defaultValues = {};
1725
- const submitFormCallbacks = [];
1726
- const successFormCallbacks = [];
1727
- const failureFormCallbacks = [];
1728
1767
  const intl = useIntlContext2();
1729
- const [errors, setErrors] = useState2([]);
1768
+ const { callbacks, addToFailureForm, addToSubmitForm, addToSuccessForm } = useSubmitCallbacks();
1769
+ const { submitFormCallbacks, successFormCallbacks, failureFormCallbacks } = callbacks;
1770
+ const [errors, setErrors] = useState3([]);
1730
1771
  const throwError = /* @__PURE__ */ __name((error) => {
1731
1772
  let formErrors = getErrors(error);
1732
1773
  console.log(formErrors);
@@ -1738,49 +1779,18 @@ var Form = /* @__PURE__ */ __name((props) => {
1738
1779
  const clearFieldErrors = /* @__PURE__ */ __name((path) => {
1739
1780
  setErrors((prevErrors) => prevErrors.filter((error) => error.path !== path));
1740
1781
  }, "clearFieldErrors");
1741
- const [deletedValues, setDeletedValues] = useState2([]);
1782
+ const [deletedValues, setDeletedValues] = useState3([]);
1742
1783
  const addToDeletedValues = /* @__PURE__ */ __name((name) => {
1743
1784
  setDeletedValues((prevDeletedValues) => [
1744
1785
  ...prevDeletedValues,
1745
1786
  name
1746
1787
  ]);
1747
1788
  }, "addToDeletedValues");
1748
- const [callbacks, setCallbacks] = useState2({
1749
- submitFormCallbacks: [],
1750
- successFormCallbacks: [],
1751
- failureFormCallbacks: []
1752
- });
1753
- const addToSubmitForm = /* @__PURE__ */ __name((callback) => {
1754
- setCallbacks((cbs) => __spreadValues({}, cbs));
1755
- }, "addToSubmitForm");
1756
- const addToSuccessForm = /* @__PURE__ */ __name((callback) => {
1757
- setCallbacks((cbs) => __spreadProps(__spreadValues({}, cbs), {
1758
- successFormCallbacks: [
1759
- ...cbs.successFormCallbacks,
1760
- callback
1761
- ]
1762
- }));
1763
- }, "addToSuccessForm");
1764
- const addToFailureForm = /* @__PURE__ */ __name((callback) => {
1765
- setCallbacks((cbs) => __spreadProps(__spreadValues({}, cbs), {
1766
- failureFormCallbacks: [
1767
- ...cbs.failureFormCallbacks,
1768
- callback
1769
- ]
1770
- }));
1771
- }, "addToFailureForm");
1772
- const clearFormCallbacks = /* @__PURE__ */ __name(() => {
1773
- setCallbacks({
1774
- submitFormCallbacks: [],
1775
- successFormCallbacks: [],
1776
- failureFormCallbacks: []
1777
- });
1778
- }, "clearFormCallbacks");
1779
- const [currentValues, setCurrentValues] = useState2({});
1789
+ const [currentValues, setCurrentValues] = useState3({});
1780
1790
  const submitFormContext = /* @__PURE__ */ __name(async (event) => {
1781
1791
  await submitForm(event);
1782
1792
  }, "submitFormContext");
1783
- const [currentDocument, setCurrentDocument] = useState2(initialDocument);
1793
+ const [currentDocument, setCurrentDocument] = useState3(initialDocument);
1784
1794
  const updateCurrentValues = /* @__PURE__ */ __name((newValues, options = {}) => {
1785
1795
  const { mode = "overwrite" } = options;
1786
1796
  const { changeCallback } = props;
@@ -1821,8 +1831,8 @@ var Form = /* @__PURE__ */ __name((props) => {
1821
1831
  props.refetch();
1822
1832
  }
1823
1833
  }, "refetchForm");
1824
- const [disabled, setDisabled] = useState2(!!props.disabled);
1825
- const [success, setSuccess] = useState2(false);
1834
+ const [disabled, setDisabled] = useState3(!!props.disabled);
1835
+ const [success, setSuccess] = useState3(false);
1826
1836
  const clearForm = /* @__PURE__ */ __name((options = {}) => {
1827
1837
  const { document: optionsDocument } = options;
1828
1838
  const document = optionsDocument ? merge2({}, props.prefilledProps, optionsDocument) : null;
@@ -1833,21 +1843,21 @@ var Form = /* @__PURE__ */ __name((props) => {
1833
1843
  setDisabled(false);
1834
1844
  }, "clearForm");
1835
1845
  const newMutationSuccessCallback = /* @__PURE__ */ __name(function(result) {
1836
- mutationSuccessCallback(result, "new");
1846
+ mutationSuccessCallback(result, NEW_FORM_TYPE);
1837
1847
  }, "newMutationSuccessCallback");
1838
1848
  const editMutationSuccessCallback = /* @__PURE__ */ __name(function(result) {
1839
- mutationSuccessCallback(result, "edit");
1849
+ mutationSuccessCallback(result, EDIT_FORM_TYPE);
1840
1850
  }, "editMutationSuccessCallback");
1841
1851
  const formRef = useRef2(null);
1842
1852
  const mutationSuccessCallback = /* @__PURE__ */ __name(function(result, mutationType) {
1843
1853
  setDisabled(false);
1844
1854
  setSuccess(true);
1845
- if (mutationType === "new")
1855
+ if (mutationType === NEW_FORM_TYPE)
1846
1856
  refetchForm();
1847
1857
  let { document } = result;
1848
1858
  if (formRef.current) {
1849
1859
  clearForm({
1850
- document: mutationType === "edit" ? document : void 0
1860
+ document: mutationType === EDIT_FORM_TYPE ? document : void 0
1851
1861
  });
1852
1862
  }
1853
1863
  document = runCallbacks({
@@ -1987,9 +1997,9 @@ var Form = /* @__PURE__ */ __name((props) => {
1987
1997
  }, "deleteDocumentWithConfirm");
1988
1998
  const { successComponent, document: document1, currentUser, model, warnUnsavedChanges } = props;
1989
1999
  const FormComponents = useVulcanComponents();
1990
- const formType = document1 ? "edit" : "new";
1991
- const submitForm = formType === "new" ? submitFormCreate : submitFormUpdate;
1992
- const mutableFields = formType === "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);
1993
2003
  const { formLayoutProps, formGroupProps } = getChildrenProps(props, {
1994
2004
  disabled,
1995
2005
  currentDocument
@@ -2017,7 +2027,6 @@ var Form = /* @__PURE__ */ __name((props) => {
2017
2027
  addToSubmitForm,
2018
2028
  addToSuccessForm,
2019
2029
  addToFailureForm,
2020
- clearFormCallbacks,
2021
2030
  errors,
2022
2031
  currentValues,
2023
2032
  deletedValues,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../node_modules/tslib/tslib.js","../components/core/LoadingButton.tsx","../components/VulcanComponents/Consumer.tsx","../components/VulcanComponents/Context.ts","../components/VulcanComponents/Dummy.tsx","../components/core/MutationButton.tsx","../../../node_modules/tslib/modules/index.js","../../../node_modules/graphql-tag/lib/index.js","../components/form/core/FormContext.tsx","../components/form/core/Form/Form.tsx","../components/form/utils/schema_utils.ts","../components/form/utils/utils.ts","../components/form/utils/path_utils.ts","../components/form/core/Form/fields.ts","../components/form/core/Form/utils.ts","../components/form/hooks/useBlockTransition/useBlockTransition.ts","../components/form/hooks/useBlockTransition/block.ts","../components/form/hooks/useWarnOnUnsaved/useWarnOnUnsaved.ts","../components/form/core/FormContainer.tsx","../components/form/utils/formFragments.ts","../components/VulcanCurrentUser/Consumer.tsx","../components/VulcanCurrentUser/Context.ts","../components/VulcanCurrentUser/Provider.tsx","../components/form/utils/ui_utils.ts","../components/VulcanComponents/Provider.tsx","../components/VulcanComponents/defaultVulcanComponents/index.ts","../componentsHelpers.tsx"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global global, define, System, Reflect, Promise */\r\nvar __extends;\r\nvar __assign;\r\nvar __rest;\r\nvar __decorate;\r\nvar __param;\r\nvar __metadata;\r\nvar __awaiter;\r\nvar __generator;\r\nvar __exportStar;\r\nvar __values;\r\nvar __read;\r\nvar __spread;\r\nvar __spreadArrays;\r\nvar __spreadArray;\r\nvar __await;\r\nvar __asyncGenerator;\r\nvar __asyncDelegator;\r\nvar __asyncValues;\r\nvar __makeTemplateObject;\r\nvar __importStar;\r\nvar __importDefault;\r\nvar __classPrivateFieldGet;\r\nvar __classPrivateFieldSet;\r\nvar __classPrivateFieldIn;\r\nvar __createBinding;\r\n(function (factory) {\r\n var root = typeof global === \"object\" ? global : typeof self === \"object\" ? self : typeof this === \"object\" ? this : {};\r\n if (typeof define === \"function\" && define.amd) {\r\n define(\"tslib\", [\"exports\"], function (exports) { factory(createExporter(root, createExporter(exports))); });\r\n }\r\n else if (typeof module === \"object\" && typeof module.exports === \"object\") {\r\n factory(createExporter(root, createExporter(module.exports)));\r\n }\r\n else {\r\n factory(createExporter(root));\r\n }\r\n function createExporter(exports, previous) {\r\n if (exports !== root) {\r\n if (typeof Object.create === \"function\") {\r\n Object.defineProperty(exports, \"__esModule\", { value: true });\r\n }\r\n else {\r\n exports.__esModule = true;\r\n }\r\n }\r\n return function (id, v) { return exports[id] = previous ? previous(id, v) : v; };\r\n }\r\n})\r\n(function (exporter) {\r\n var extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n\r\n __extends = function (d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n\r\n __assign = Object.assign || function (t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n\r\n __rest = function (s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n };\r\n\r\n __decorate = function (decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n };\r\n\r\n __param = function (paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n };\r\n\r\n __metadata = function (metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n };\r\n\r\n __awaiter = function (thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n };\r\n\r\n __generator = function (thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n };\r\n\r\n __exportStar = function(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n };\r\n\r\n __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n }) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n });\r\n\r\n __values = function (o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n };\r\n\r\n __read = function (o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n };\r\n\r\n /** @deprecated */\r\n __spread = function () {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n };\r\n\r\n /** @deprecated */\r\n __spreadArrays = function () {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n };\r\n\r\n __spreadArray = function (to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n };\r\n\r\n __await = function (v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n };\r\n\r\n __asyncGenerator = function (thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n };\r\n\r\n __asyncDelegator = function (o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n };\r\n\r\n __asyncValues = function (o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n };\r\n\r\n __makeTemplateObject = function (cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n };\r\n\r\n var __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n }) : function(o, v) {\r\n o[\"default\"] = v;\r\n };\r\n\r\n __importStar = function (mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n };\r\n\r\n __importDefault = function (mod) {\r\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\r\n };\r\n\r\n __classPrivateFieldGet = function (receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n };\r\n\r\n __classPrivateFieldSet = function (receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n };\r\n\r\n __classPrivateFieldIn = function (state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n };\r\n\r\n exporter(\"__extends\", __extends);\r\n exporter(\"__assign\", __assign);\r\n exporter(\"__rest\", __rest);\r\n exporter(\"__decorate\", __decorate);\r\n exporter(\"__param\", __param);\r\n exporter(\"__metadata\", __metadata);\r\n exporter(\"__awaiter\", __awaiter);\r\n exporter(\"__generator\", __generator);\r\n exporter(\"__exportStar\", __exportStar);\r\n exporter(\"__createBinding\", __createBinding);\r\n exporter(\"__values\", __values);\r\n exporter(\"__read\", __read);\r\n exporter(\"__spread\", __spread);\r\n exporter(\"__spreadArrays\", __spreadArrays);\r\n exporter(\"__spreadArray\", __spreadArray);\r\n exporter(\"__await\", __await);\r\n exporter(\"__asyncGenerator\", __asyncGenerator);\r\n exporter(\"__asyncDelegator\", __asyncDelegator);\r\n exporter(\"__asyncValues\", __asyncValues);\r\n exporter(\"__makeTemplateObject\", __makeTemplateObject);\r\n exporter(\"__importStar\", __importStar);\r\n exporter(\"__importDefault\", __importDefault);\r\n exporter(\"__classPrivateFieldGet\", __classPrivateFieldGet);\r\n exporter(\"__classPrivateFieldSet\", __classPrivateFieldSet);\r\n exporter(\"__classPrivateFieldIn\", __classPrivateFieldIn);\r\n});\r\n","import React, { CSSProperties } from \"react\";\nimport { useVulcanComponents } from \"../VulcanComponents/Consumer\";\nimport type { ButtonProps } from \"./typings\";\nexport interface LoadingButtonProps extends ButtonProps {\n loading?: boolean;\n label?: string | React.ReactNode;\n onClick?: any;\n children?: React.ReactNode;\n className?: string;\n}\nexport const LoadingButton = ({\n loading,\n label,\n onClick,\n children,\n className = \"\",\n ...rest\n}: LoadingButtonProps & any) => {\n const Components = useVulcanComponents();\n\n const wrapperStyle: CSSProperties = {\n position: \"relative\",\n };\n\n const labelStyle = loading ? { opacity: 0.5 } : {};\n\n const loadingStyle: CSSProperties = loading\n ? {\n position: \"absolute\",\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n }\n : { display: \"none\" };\n\n return (\n <Components.Button\n className={`loading-button ${loading ? \"loading-button-loading\" : \"loading-button-notloading\"\n } ${className}`}\n onClick={onClick}\n {...rest}\n >\n <span style={wrapperStyle} className=\"loading-button-inner\">\n <span style={labelStyle} className=\"loading-button-label\">{label || children}</span>\n <span style={loadingStyle} className=\"loading-button-loader\">\n <Components.Loading />\n </span>\n </span>\n </Components.Button>\n );\n};\n","import { deprecate } from \"@vulcanjs/utils\";\nimport React, { useContext, useEffect } from \"react\";\nimport { VulcanComponentsContext } from \"./Context\";\n\nexport const VulcanComponentsConsumer = VulcanComponentsContext.Consumer;\n\nexport const useVulcanComponents = () => {\n const val = useContext(VulcanComponentsContext);\n return val;\n};\n\nexport const withVulcanComponents = (C) => (props) => {\n const vulcanComponents = useVulcanComponents();\n deprecate(\n \"0.0.0\",\n \"Using withVulcanComponents HOC => prefer useVulcanComponents with hooks\"\n );\n return <C vulcanComponents={vulcanComponents} {...props} />;\n};\n","import React from \"react\";\nimport type { PossibleVulcanComponents } from \"./typings\";\nimport { Dummy } from \"./Dummy\";\n\nconst dummyHandler = {\n get(target, property) {\n //console.log(\"target\", property);\n if (property in target) {\n return target[property];\n }\n console.log(\n `Property ${property} not in possible Vulcan components, returning Dummy`\n );\n return Dummy;\n },\n};\n// We need this to shut TypeScript up\n// You should use the Provider to get the right default values\nexport const VulcanComponentsContext =\n React.createContext<PossibleVulcanComponents>(\n // @ts-ignore\n new Proxy(\n {\n __not_initialized: true,\n },\n dummyHandler\n )\n );\n\n// Needed to guarantee that the exports stays named\nVulcanComponentsContext.displayName = \"VulcanComponentsContext\";\n","import React from \"react\";\nexport interface DummyProps { }\n\nexport const Dummy = () => (\n <span>\n You have not setup VulcanComponentsProvider. Please add following code in\n your app:{\" \"}\n <code>{`import { VulcanComponentsProvider } from \"@vulcanjs/react-ui\"; const YourApp = <VulcanComponentsProvider>{/* your app */}</VulcanComponentsProvider>;}`}</code>\n </span>\n);\n","/*\n\nExample Usage\n\n<Components.MutationButton\n label=\"Cancel Subscription\"\n variant=\"primary\"\n mutationOptions={{\n name: 'cancelSubscription',\n args: { bookingId: 'String' },\n fragmentName: 'BookingsStripeDataFragment',\n }}\n mutationArguments={{ bookingId: booking._id }}\n submitCallback={() => {}}\n successCallback={result => { console.log(result) }}\n/>\n\n*/\nimport React, { useState } from \"react\";\nimport { DocumentNode } from \"graphql\";\nimport { MutationHookOptions, useMutation } from \"@apollo/client\";\nimport gql from \"graphql-tag\";\nimport { useVulcanComponents } from \"../VulcanComponents/Consumer\";\nimport { LoadingButtonProps } from \"./LoadingButton\";\n// import withMutation from '../containers/registeredMutation';\n\n// TODO:\n/**\n * Difference with Vulcan Meteor: there is no\n * registered mutation anymore,\n * so you need to pass your mutations explicitely, using graphql\n */\n/*\nexport class MutationButton extends PureComponent {\n constructor(props) {\n super(props);\n this.button = withMutation(props.mutationOptions)(MutationButtonInner);\n }\n\n render() {\n const Component = this.button;\n return <Component {...this.props} />;\n }\n}*/\n\nexport interface MutationButtonProps {\n /**\n * NOTE: in Vulcan Meteor you had to write:\n * mutationOptions: { name: \"foobar\", mutationOptions: {refetchQueries:[\"hello\"]}}\n *\n * In Vulcan Next, you can only pass the \"mutationOptions\" object:\n * mutationOptions: { refetchQueries:[\"hello\"]}\n * and the mutation is provided via the new \"mutation\" prop\n */\n mutationOptions?: MutationHookOptions;\n /**\n * @example\n mutation: gql`\n mutation sampleMutation($input: Input) {\n hello\n }\n `,\n */\n mutation: string | DocumentNode;\n /** Variables passed to the mutation (NOTE: we can't pass other options at the moment) */\n mutationArguments?: MutationHookOptions<any>[\"variables\"];\n /** Callback run before submitting. Can optionnaly return mutationArguments that will override current ones. */\n submitCallback?: (\n mutationArgumentsFromProps: MutationHookOptions<any>[\"variables\"]\n ) =>\n | void\n | { mutationArguments: MutationHookOptions<any>[\"variables\"] }\n | Promise<void | {\n mutationArguments: MutationHookOptions<any>[\"variables\"];\n }>;\n successCallback?: (res: any) => void | Promise<void>;\n errorCallback?: (err: any) => void | Promise<void>;\n /** Now isolated into their own object to avoid needed to explicitely pick/omit */\n loadingButtonProps?: LoadingButtonProps;\n /** Shortcut for loadingButtonProps.label */\n label?: string | React.ReactNode;\n}\nexport const MutationButton = (props: MutationButtonProps) => {\n const Components = useVulcanComponents();\n const [loading, setLoading] = useState<boolean>(false);\n const [error, setError] = useState<any | undefined>();\n\n const {\n //mutationOptions,\n mutation,\n loadingButtonProps = {},\n label,\n } = props;\n let { mutationArguments } = props;\n const mutationAsNode =\n typeof mutation === \"string\"\n ? gql`\n ${mutation}\n `\n : mutation;\n const [mutationFunc] = useMutation(mutationAsNode);\n\n const handleClick = async (e) => {\n e.preventDefault();\n setLoading(true);\n setError(undefined);\n const {\n //mutationOptions,\n submitCallback,\n successCallback,\n errorCallback,\n } = props;\n //const mutationName = mutationOptions.name;\n //const mutation = this.props[mutationName];\n\n try {\n if (submitCallback) {\n const callbackReturn = await submitCallback(mutationArguments);\n if (callbackReturn && callbackReturn.mutationArguments) {\n mutationArguments = callbackReturn.mutationArguments;\n }\n }\n const result = await mutationFunc({ variables: mutationArguments });\n if (successCallback) {\n await successCallback(result);\n }\n } catch (error) {\n // TODO: may not work because the mutationFunc may not throw in case of error\n setError(error);\n if (errorCallback) {\n await errorCallback(error);\n }\n } finally {\n setLoading(false);\n }\n\n // mutation(mutationArguments)\n // .then(result => {\n // this.setState({ loading: false });\n // if (successCallback) {\n // successCallback(result);\n // }\n // })\n // .catch(error => {\n // this.setState({ loading: false });\n // if (errorCallback) {\n // errorCallback(error);\n // }\n // });\n };\n\n //const mutationName = this.props.mutationOptions.name;\n\n const loadingButton = (\n <Components.LoadingButton\n loading={loading}\n onClick={handleClick}\n label={label}\n {...loadingButtonProps}\n />\n );\n\n if (error) {\n return (\n <Components.TooltipTrigger trigger={loadingButton} defaultShow={true}>\n {error.message.replace(\"GraphQL error: \", \"\")}\n </Components.TooltipTrigger>\n );\n }\n return loadingButton;\n};\n","import tslib from '../tslib.js';\r\nconst {\r\n __extends,\r\n __assign,\r\n __rest,\r\n __decorate,\r\n __param,\r\n __metadata,\r\n __awaiter,\r\n __generator,\r\n __exportStar,\r\n __createBinding,\r\n __values,\r\n __read,\r\n __spread,\r\n __spreadArrays,\r\n __spreadArray,\r\n __await,\r\n __asyncGenerator,\r\n __asyncDelegator,\r\n __asyncValues,\r\n __makeTemplateObject,\r\n __importStar,\r\n __importDefault,\r\n __classPrivateFieldGet,\r\n __classPrivateFieldSet,\r\n __classPrivateFieldIn,\r\n} = tslib;\r\nexport {\r\n __extends,\r\n __assign,\r\n __rest,\r\n __decorate,\r\n __param,\r\n __metadata,\r\n __awaiter,\r\n __generator,\r\n __exportStar,\r\n __createBinding,\r\n __values,\r\n __read,\r\n __spread,\r\n __spreadArrays,\r\n __spreadArray,\r\n __await,\r\n __asyncGenerator,\r\n __asyncDelegator,\r\n __asyncValues,\r\n __makeTemplateObject,\r\n __importStar,\r\n __importDefault,\r\n __classPrivateFieldGet,\r\n __classPrivateFieldSet,\r\n __classPrivateFieldIn,\r\n};\r\n","import { __assign } from \"tslib\";\nimport { parse } from 'graphql';\nvar docCache = new Map();\nvar fragmentSourceMap = new Map();\nvar printFragmentWarnings = true;\nvar experimentalFragmentVariables = false;\nfunction normalize(string) {\n return string.replace(/[\\s,]+/g, ' ').trim();\n}\nfunction cacheKeyFromLoc(loc) {\n return normalize(loc.source.body.substring(loc.start, loc.end));\n}\nfunction processFragments(ast) {\n var seenKeys = new Set();\n var definitions = [];\n ast.definitions.forEach(function (fragmentDefinition) {\n if (fragmentDefinition.kind === 'FragmentDefinition') {\n var fragmentName = fragmentDefinition.name.value;\n var sourceKey = cacheKeyFromLoc(fragmentDefinition.loc);\n var sourceKeySet = fragmentSourceMap.get(fragmentName);\n if (sourceKeySet && !sourceKeySet.has(sourceKey)) {\n if (printFragmentWarnings) {\n console.warn(\"Warning: fragment with name \" + fragmentName + \" already exists.\\n\"\n + \"graphql-tag enforces all fragment names across your application to be unique; read more about\\n\"\n + \"this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names\");\n }\n }\n else if (!sourceKeySet) {\n fragmentSourceMap.set(fragmentName, sourceKeySet = new Set);\n }\n sourceKeySet.add(sourceKey);\n if (!seenKeys.has(sourceKey)) {\n seenKeys.add(sourceKey);\n definitions.push(fragmentDefinition);\n }\n }\n else {\n definitions.push(fragmentDefinition);\n }\n });\n return __assign(__assign({}, ast), { definitions: definitions });\n}\nfunction stripLoc(doc) {\n var workSet = new Set(doc.definitions);\n workSet.forEach(function (node) {\n if (node.loc)\n delete node.loc;\n Object.keys(node).forEach(function (key) {\n var value = node[key];\n if (value && typeof value === 'object') {\n workSet.add(value);\n }\n });\n });\n var loc = doc.loc;\n if (loc) {\n delete loc.startToken;\n delete loc.endToken;\n }\n return doc;\n}\nfunction parseDocument(source) {\n var cacheKey = normalize(source);\n if (!docCache.has(cacheKey)) {\n var parsed = parse(source, {\n experimentalFragmentVariables: experimentalFragmentVariables,\n allowLegacyFragmentVariables: experimentalFragmentVariables\n });\n if (!parsed || parsed.kind !== 'Document') {\n throw new Error('Not a valid GraphQL document.');\n }\n docCache.set(cacheKey, stripLoc(processFragments(parsed)));\n }\n return docCache.get(cacheKey);\n}\nexport function gql(literals) {\n var args = [];\n for (var _i = 1; _i < arguments.length; _i++) {\n args[_i - 1] = arguments[_i];\n }\n if (typeof literals === 'string') {\n literals = [literals];\n }\n var result = literals[0];\n args.forEach(function (arg, i) {\n if (arg && arg.kind === 'Document') {\n result += arg.loc.source.body;\n }\n else {\n result += arg;\n }\n result += literals[i + 1];\n });\n return parseDocument(result);\n}\nexport function resetCaches() {\n docCache.clear();\n fragmentSourceMap.clear();\n}\nexport function disableFragmentWarnings() {\n printFragmentWarnings = false;\n}\nexport function enableExperimentalFragmentVariables() {\n experimentalFragmentVariables = true;\n}\nexport function disableExperimentalFragmentVariables() {\n experimentalFragmentVariables = false;\n}\nvar extras = {\n gql: gql,\n resetCaches: resetCaches,\n disableFragmentWarnings: disableFragmentWarnings,\n enableExperimentalFragmentVariables: enableExperimentalFragmentVariables,\n disableExperimentalFragmentVariables: disableExperimentalFragmentVariables\n};\n(function (gql_1) {\n gql_1.gql = extras.gql, gql_1.resetCaches = extras.resetCaches, gql_1.disableFragmentWarnings = extras.disableFragmentWarnings, gql_1.enableExperimentalFragmentVariables = extras.enableExperimentalFragmentVariables, gql_1.disableExperimentalFragmentVariables = extras.disableExperimentalFragmentVariables;\n})(gql || (gql = {}));\ngql[\"default\"] = gql;\nexport default gql;\n//# sourceMappingURL=index.js.map","import React, { useContext } from \"react\";\n\ninterface FormContextValue {\n addToDeletedValues: Function;\n addToFailureForm: Function;\n addToSubmitForm: Function;\n addToSuccessForm: Function;\n clearForm: Function;\n clearFormCallbacks: Function;\n clearFieldErrors: Function;\n currentValues: object;\n deletedValues: Array<any>;\n errors: Array<any>;\n getDocument: Function;\n getLabel: (fieldName: string, fieldLocale?: string) => string;\n initialDocument: object;\n isChanged: boolean;\n refetchForm: Function;\n // TODO: we deprecate this, it doesn't make sense to allow a child to setState this way\n // setFormState: Function;\n // FIXME: this type doesn't work, it doesn't necessarily have the event + it has to be defined\n submitForm: (evt?: any) => Promise<void>; //React.HTMLAttributes<HTMLFormElement>[\"onSubmit\"];\n throwError: Function;\n updateCurrentValues: Function;\n disabled: boolean;\n}\n\nexport const FormContext = React.createContext<FormContextValue | undefined>(\n undefined\n);\n\nexport const useFormContext = () => {\n const formContext = useContext(FormContext);\n if (!formContext)\n throw new Error(\n `A component is trying to access form context but it is undefined. Please wrap your component with a <Form>.\n You may be importing \"FormContext\" from different packages or have accidentaly made a copy of it?\n FormContext is exposed by \"@vulcanjs/react-ui\".`\n );\n return formContext;\n};\n","/*\n\nMain form component.\n\nThis component expects:\n\n### All Forms:\n\n- collection\n- currentUser\n- client (Apollo client)\n\n*/\n\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { runCallbacks, getErrors } from \"@vulcanjs/core\";\nimport { useIntlContext } from \"@vulcanjs/react-i18n\";\nimport { removeProperty } from \"@vulcanjs/utils\";\nimport _filter from \"lodash/filter.js\";\nimport cloneDeep from \"lodash/cloneDeep.js\";\nimport compact from \"lodash/compact.js\";\nimport get from \"lodash/get.js\";\nimport isObject from \"lodash/isObject.js\";\nimport mapValues from \"lodash/mapValues.js\";\nimport merge from \"lodash/merge.js\";\nimport omit from \"lodash/omit.js\";\nimport omitBy from \"lodash/omitBy.js\";\nimport pick from \"lodash/pick.js\";\nimport pickBy from \"lodash/pickBy.js\";\nimport set from \"lodash/set.js\";\nimport unset from \"lodash/unset.js\";\nimport update from \"lodash/update.js\";\nimport without from \"lodash/without.js\";\nimport isEmpty from \"lodash/isEmpty.js\";\n//import type { FormLayoutProps } from \"../../elements/FormLayout\";\n//import type { FormSubmitProps } from \"../../elements/FormSubmit\";\n\nimport {\n convertSchema,\n getEditableFields,\n getInsertableFields,\n} from \"../../utils/schema_utils\";\nimport { isEmptyValue } from \"../../utils/utils\";\nimport { getParentPath } from \"../../utils/path_utils\";\n// import withCollectionProps from \"./withCollectionProps\";\nimport { FormContext } from \"../FormContext\";\nimport { getFieldGroups, getFieldNames, getLabel } from \"./fields\";\nimport { isNotSameDocument } from \"./utils\";\nimport { useWarnOnUnsaved } from \"../../hooks/useWarnOnUnsaved\";\n\nimport type { FormType } from \"../../typings\";\nimport {\n CreateDocumentResult,\n FormProps,\n FormState,\n UpdateDocumentResult,\n} from \"./typings\";\nimport { MutationResult } from \"@apollo/client\";\nimport { useVulcanComponents } from \"../../../VulcanComponents/Consumer\";\n\n// props that should trigger a form reset\nconst RESET_PROPS = [\n \"model\",\n // \"collection\",\n // \"collectionName\",\n \"document\",\n \"schema\",\n \"currentUser\",\n \"fields\",\n \"removeFields\",\n \"prefilledProps\", // TODO: prefilledProps should be merged instead?\n];\n\nconst compactParent = (object, path) => {\n const parentPath = getParentPath(path);\n\n // note: we only want to compact arrays, not objects\n const compactIfArray = (x) => (Array.isArray(x) ? compact(x) : x);\n\n update(object, parentPath, compactIfArray);\n};\n\nconst getDefaultValues = (convertedSchema) => {\n // TODO: make this work with nested schemas, too\n return pickBy(\n mapValues(convertedSchema, (field) => field.defaultValue),\n (value) => value\n );\n};\n\nconst compactObject = (o) => omitBy(o, (f) => f === null || f === undefined);\n\nconst getInitialStateFromProps = (nextProps: FormProps): FormState => {\n const schema = nextProps.schema || nextProps.model.schema;\n const convertedSchema = convertSchema(schema);\n const formType: FormType = nextProps.document ? \"edit\" : \"new\";\n // for new document forms, add default values to initial document\n const defaultValues =\n formType === \"new\" ? getDefaultValues(convertedSchema) : {};\n // note: we remove null/undefined values from the loaded document so they don't overwrite possible prefilledProps\n const initialDocument = merge(\n {},\n defaultValues,\n nextProps.prefilledProps,\n compactObject(nextProps.document)\n );\n\n //if minCount is specified, go ahead and create empty nested documents\n Object.keys(convertedSchema).forEach((key) => {\n let minCount = convertedSchema[key].minCount;\n if (minCount) {\n initialDocument[key] = initialDocument[key] || [];\n while (initialDocument[key].length < minCount)\n initialDocument[key].push({});\n }\n });\n\n // remove all instances of the `__typename` property from document\n removeProperty(initialDocument, \"__typename\");\n\n return {\n disabled: nextProps.disabled,\n errors: [],\n deletedValues: [],\n currentValues: {},\n originalSchema: convertSchema(schema, { removeArrays: false }),\n // convert SimpleSchema schema into JSON object\n schema: convertedSchema,\n // Also store all field schemas (including nested schemas) in a flat structure\n flatSchema: convertSchema(schema, { flatten: true }),\n // the initial document passed as props\n initialDocument,\n // initialize the current document to be the same as the initial document\n currentDocument: initialDocument,\n };\n};\n\nconst getChildrenProps = (\n props: FormProps,\n state: Pick<FormState, \"disabled\" | \"currentDocument\">,\n options: { formType: FormType },\n // TODO: that belongs to the context instead\n callbacks: { deleteDocument: Function }\n): {\n formLayoutProps: any; //FormLayoutProps;\n formGroupProps: Function;\n commonProps: any;\n formSubmitProps: any; // FormSubmitProps;\n} => {\n const {\n currentUser,\n repeatErrors,\n submitLabel,\n cancelLabel,\n revertLabel,\n cancelCallback,\n revertCallback,\n id,\n model,\n prefilledProps,\n itemProperties,\n contextName,\n showRemove,\n showDelete,\n } = props;\n const { disabled, currentDocument } = state;\n const { formType } = options;\n const { deleteDocument } = callbacks;\n const commonProps = {\n document: currentDocument,\n formType,\n currentUser,\n disabled,\n prefilledProps,\n itemProperties,\n contextName,\n };\n\n const docClassName = `document-${formType}`;\n const modelName = model.name.toLowerCase();\n const formProps = {\n className: `${docClassName} ${docClassName}-${modelName}`,\n id: id,\n // It's the form element responsibility to get submitForm from context\n // onSubmit: this.submitForm(formType),\n // TODO: update to useRef\n //ref: (e) => {\n // this.form = e;\n //},\n };\n\n const formGroupProps = (group) => ({\n key: group.name,\n ...group,\n group: omit(group, [\"fields\"]),\n ...commonProps,\n });\n\n const formSubmitProps = {\n model,\n currentUser,\n submitLabel,\n cancelLabel,\n revertLabel,\n cancelCallback,\n revertCallback,\n document: currentDocument,\n // TODO: should probably be passed through context\n deleteDocument:\n (formType === \"edit\" && showRemove && showDelete && deleteDocument) ||\n null,\n };\n\n const formLayoutProps = {\n formProps: formProps,\n repeatErrors: repeatErrors,\n submitProps: formSubmitProps,\n commonProps,\n };\n return {\n commonProps,\n formSubmitProps,\n formGroupProps,\n formLayoutProps,\n };\n};\n\n// component form until we go stateless\nconst FormWarnUnsaved = ({\n isChanged,\n warnUnsavedChanges,\n children,\n}: {\n isChanged: boolean;\n warnUnsavedChanges?: boolean;\n children: React.ReactNode;\n}) => {\n useWarnOnUnsaved({\n isChanged,\n warnUnsavedChanges,\n });\n return <>{children}</>;\n};\n\n/*\n\n Like getDocument, but cross-reference with getFieldNames()\n to only return fields that actually need to be submitted\n\n Also remove any deleted values.\n\n */\nconst getData = (\n customArgs,\n props: FormProps,\n state: Pick<FormState, \"currentDocument\" | \"deletedValues\">,\n // previously from \"this\" object\n { submitFormCallbacks, form }: any\n) => {\n const { currentDocument } = state;\n const { model, prefilledProps } = props;\n // we want to keep prefilled data even for hidden/removed fields\n let data = prefilledProps || {};\n\n // omit prefilled props for nested fields\n data = omitBy(data, (value, key) => key.endsWith(\".$\"));\n\n const args = {\n schema: model.schema,\n excludeRemovedFields: false,\n excludeHiddenFields: false,\n replaceIntlFields: true,\n addExtraFields: false,\n ...customArgs,\n };\n\n // only keep relevant fields\n // for intl fields, make sure we look in foo_intl and not foo\n const fields = getFieldNames(props, currentDocument, args);\n data = { ...data, ...pick(currentDocument, ...fields) };\n\n // compact deleted values\n state.deletedValues.forEach((path) => {\n if (path.includes(\".\")) {\n /*\n\n If deleted field is a nested field, nested array, or nested array item, try to compact its parent array\n\n - Nested field: 'address.city'\n - Nested array: 'addresses.1'\n - Nested array item: 'addresses.1.city'\n\n */\n compactParent(data, path);\n }\n });\n\n // run data object through submitForm callbacks\n data = runCallbacks({\n callbacks: submitFormCallbacks,\n iterator: data,\n args: [\n {\n /*form: this*/\n },\n ],\n });\n\n return data;\n};\n\nexport const Form = (props: FormProps) => {\n const { initCallback, createDocument, updateDocument, deleteDocument } =\n props;\n const initialState = getInitialStateFromProps(props);\n const { schema, originalSchema, flatSchema, initialDocument } = initialState;\n const isFirstRender = useRef(true);\n useEffect(() => {\n if (isFirstRender.current) {\n isFirstRender.current = false; // toggle flag after first render/mounting\n return;\n }\n if (initCallback) initCallback(initialState.currentDocument);\n }, [initCallback]);\n const defaultProps = {\n layout: \"horizontal\",\n prefilledProps: {},\n repeatErrors: false,\n showRemove: true,\n showDelete: true,\n };\n const allProps = { ...defaultProps, ...props };\n const defaultValues = {};\n const submitFormCallbacks: Array<Function> = [];\n const successFormCallbacks: Array<Function> = [];\n const failureFormCallbacks: Array<Function> = [];\n const intl = useIntlContext();\n\n // --------------------------------------------------------------------- //\n // ------------------------------- Errors ------------------------------ //\n // --------------------------------------------------------------------- //\n\n /*\n\n Add error to form state\n\n Errors can have the following properties:\n - id: used as an internationalization key, for example `errors.required`\n - path: for field-specific errors, the path of the field with the issue\n - properties: additional data. Will be passed to vulcan-i18n as values\n - message: if id cannot be used as i81n key, message will be used\n\n */\n const [errors, setErrors] = useState<Array<any>>([]);\n const throwError = (error) => {\n let formErrors = getErrors(error);\n\n // eslint-disable-next-line no-console\n console.log(formErrors);\n\n // add error(s) to state\n setErrors((prevErrors) => [...prevErrors, ...formErrors]);\n };\n\n /*\n\n Clear errors for a field\n\n */\n const clearFieldErrors = (path) => {\n setErrors((prevErrors) =>\n prevErrors.filter((error) => error.path !== path)\n );\n };\n\n // --------------------------------------------------------------------- //\n // ------------------------------- Context ----------------------------- //\n // --------------------------------------------------------------------- //\n\n const [deletedValues, setDeletedValues] = useState<Array<any>>([]);\n\n // add something to deleted values\n const addToDeletedValues = (name) => {\n setDeletedValues((prevDeletedValues) => [...prevDeletedValues, name]);\n };\n\n interface Callbacks {\n submitFormCallbacks: Array<any>;\n successFormCallbacks: Array<any>;\n failureFormCallbacks: Array<any>;\n }\n const [callbacks, setCallbacks] = useState<Callbacks>({\n submitFormCallbacks: [],\n successFormCallbacks: [],\n failureFormCallbacks: [],\n });\n // add a callback to the form submission\n const addToSubmitForm = (callback) => {\n setCallbacks((cbs) => ({\n ...cbs,\n // submitFormCallbacks: [...cbs.submitFormCallbacks, callback],\n }));\n };\n\n // add a callback to form submission success\n const addToSuccessForm = (callback) => {\n setCallbacks((cbs) => ({\n ...cbs,\n successFormCallbacks: [...cbs.successFormCallbacks, callback],\n }));\n };\n\n // add a callback to form submission failure\n const addToFailureForm = (callback) => {\n setCallbacks((cbs) => ({\n ...cbs,\n failureFormCallbacks: [...cbs.failureFormCallbacks, callback],\n }));\n };\n\n const clearFormCallbacks = () => {\n setCallbacks({\n submitFormCallbacks: [],\n successFormCallbacks: [],\n failureFormCallbacks: [],\n });\n };\n\n /*\n setFormState = (fn) => {\n this.setState(fn);\n };\n */\n\n const [currentValues, setCurrentValues] = useState<Object>({});\n\n const submitFormContext = async (event /*newValues*/) => {\n /*\n TODO: previously this callback was updating the current values with new values after this call\n Need to check how this worked in Vulcan initially\n setCurrentValues((prevCurrentValues) => ({\n ...prevCurrentValues,\n ...newValues,\n }));\n */\n // TODO: previously, this was using a callback from setCurrentValues\n // this needs to be rearchitectured to work without, will need some check\n // https://stackoverflow.com/questions/56247433/how-to-use-setstate-callback-on-react-hooks\n await submitForm(event);\n };\n\n // --------------------------------------------------------------------- //\n // ------------------------------ Lifecycle ---------------------------- //\n // --------------------------------------------------------------------- //\n\n /*\n\n When props change, reinitialize the form state\n Triggered only for data related props (collection, document, currentUser etc.)\n\n @see https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html\n\n */\n /*\n UNSAFE_componentWillReceiveProps(nextProps) {\n const needReset = !!RESET_PROPS.find(\n (prop) => !isEqual(this.props[prop], nextProps[prop])\n );\n if (needReset) {\n const newState = getInitialStateFromProps(nextProps);\n this.setState(newState);\n if (nextProps.initCallback)\n nextProps.initCallback(newState.currentDocument);\n }\n }*/\n\n const [currentDocument, setCurrentDocument] = useState<{\n title?: string;\n _id?: string;\n name?: string;\n }>(initialDocument);\n\n /*\n\n Manually update the current values of one or more fields(i.e. on change or blur).\n\n */\n const updateCurrentValues = (newValues, options: { mode?: string } = {}) => {\n // default to overwriting old value with new\n const { mode = \"overwrite\" } = options;\n const { changeCallback } = props;\n\n // keep the previous ones and extend (with possible replacement) with new ones\n // keep only the relevant properties\n const newState = {\n currentValues: cloneDeep(currentValues),\n currentDocument: cloneDeep(currentDocument),\n deletedValues: cloneDeep(deletedValues),\n };\n\n Object.keys(newValues).forEach((key) => {\n const path = key;\n let value = newValues[key];\n\n if (isEmptyValue(value)) {\n // delete value\n unset(newState.currentValues, path);\n set(newState.currentDocument, path, null);\n newState.deletedValues = [...newState.deletedValues, path];\n } else {\n // 1. update currentValues\n set(newState.currentValues, path, value);\n\n // 2. update currentDocument\n // For arrays and objects, give option to merge instead of overwrite\n if (mode === \"merge\" && (Array.isArray(value) || isObject(value))) {\n const oldValue = get(newState.currentDocument, path);\n set(newState.currentDocument, path, merge(oldValue, value));\n } else {\n set(newState.currentDocument, path, value);\n }\n\n // 3. in case value had previously been deleted, \"undelete\" it\n newState.deletedValues = without(newState.deletedValues, path);\n }\n });\n if (changeCallback) changeCallback(newState.currentDocument);\n\n // TODO: prefer a reducer\n setCurrentValues(newState.currentValues);\n setCurrentDocument(newState.currentDocument);\n setDeletedValues(newState.deletedValues);\n };\n\n /*\n\n Refetch the document from the database (in case it was updated by another process or to reset the form)\n\n */\n const refetchForm = () => {\n if (props.refetch) {\n props.refetch();\n }\n };\n\n const [disabled, setDisabled] = useState<boolean>(!!props.disabled);\n const [success, setSuccess] = useState<boolean>(false); // TODO\n /**\n * Clears form errors and values.\n *\n * @example Clear form\n * // form will be fully emptied, with exception of prefilled values\n * clearForm({ document: {} });\n *\n * @example Reset/revert form\n * // form will be reverted to its initial state\n * clearForm();\n *\n * @example Clear with new values\n * // form will be cleared but initialized with the new document\n * const document = {\n * // ... some values\n * };\n * clearForm({ document });\n *\n * @param {Object=} options\n * @param {Object=} options.document\n * Document to use as new initial document when values are cleared instead of\n * the existing one. Note that prefilled props will be merged\n */\n const clearForm = (options: { document?: any } = {}) => {\n const { document: optionsDocument } = options;\n const document = optionsDocument\n ? merge({}, props.prefilledProps, optionsDocument)\n : null;\n // TODO: prefer a reducer\n setErrors([]);\n setCurrentValues({});\n setDeletedValues([]);\n setCurrentDocument(document || initialDocument);\n // setInitialDocument(document || initialDocument);\n setDisabled(false);\n };\n\n const newMutationSuccessCallback = function <TModel = Object>(\n result: CreateDocumentResult<TModel>\n ) {\n mutationSuccessCallback(result, \"new\");\n };\n\n const editMutationSuccessCallback = function <TModel = Object>(\n result: UpdateDocumentResult<TModel>\n ) {\n mutationSuccessCallback(result, \"edit\");\n };\n\n const formRef = useRef(null);\n const mutationSuccessCallback = function <TModel = Object>(\n // must be called only on valid results\n result: CreateDocumentResult<TModel>,\n mutationType: FormType\n ) {\n // TODO: use a reducer\n setDisabled(false);\n setSuccess(true);\n // for new mutation, run refetch function if it exists\n // TODO: the create mutation should already return the freshest value, do we really need that?\n // instead we might want to update currentResult with the result of the creation\n if (mutationType === \"new\") refetchForm();\n let { document } = result;\n\n // call the clear form method (i.e. trigger setState) only if the form has not been unmounted\n // (we are in an async callback, everything can happen!)\n // TODO: this should rely on a ref\n if (formRef.current) {\n clearForm({\n document: mutationType === \"edit\" ? document : undefined,\n });\n }\n\n // run document through mutation success callbacks\n document = runCallbacks({\n callbacks: successFormCallbacks,\n iterator: document,\n args: [{ form: formRef.current }],\n });\n\n // run success callback if it exists\n if (props.successCallback) props.successCallback(document, { form: this });\n };\n\n // catch graphql errors\n const mutationErrorCallback = (document, error) => {\n setDisabled(false);\n\n // eslint-disable-next-line no-console\n console.error(\"// graphQL Error\");\n // eslint-disable-next-line no-console\n console.error(error);\n\n // run mutation failure callbacks on error, we do not allow the callbacks to change the error\n runCallbacks({\n callbacks: failureFormCallbacks,\n iterator: error,\n args: [{ error, form: formRef.current }],\n });\n\n if (!isEmpty(error)) {\n // add error to state\n throwError(error);\n }\n\n // run error callback if it exists\n if (props.errorCallback)\n props.errorCallback(document, error, { form: this });\n\n // scroll back up to show error messages\n // TODO: migrate this to scroll on top of the form\n //Utils.scrollIntoView(\".flash-message\");\n };\n\n const getSubmitData = () => {\n // complete the data with values from custom components\n // note: it follows the same logic as SmartForm's getDocument method\n let data = getData(\n { replaceIntlFields: true, addExtraFields: false, mutableFields },\n props,\n {\n currentDocument,\n deletedValues,\n },\n { form: formRef.current, submitFormCallbacks }\n );\n\n // if there's a submit callback, run it\n if (props.submitCallback) {\n data = props.submitCallback(data) || data;\n }\n return data;\n };\n /** \n\n Submit form handler\n\n On success/failure, will call the relevant callbacks\n\n */\n const submitFormCreate = async (event?: Event) => {\n event && event.preventDefault();\n event && event.stopPropagation();\n const { contextName } = props;\n // if form is disabled (there is already a submit handler running) don't do anything\n if (disabled) {\n return;\n }\n // clear errors and disable form while it's submitting\n setErrors([]);\n setDisabled(true);\n\n const data = getSubmitData();\n\n // create document form\n try {\n const result = await createDocument({\n input: {\n data,\n contextName,\n },\n });\n if (result.errors?.length) {\n // TODO: previously got from meta, we could have more than 1 error\n mutationErrorCallback(document, result.errors[0]);\n } else {\n newMutationSuccessCallback(result);\n }\n } catch (error) {\n mutationErrorCallback(document, error);\n }\n };\n /** \n\n Submit form handler\n\n On success/failure, will call the relevant callbacks\n\n */\n const submitFormUpdate = async (event?: Event) => {\n event && event.preventDefault();\n event && event.stopPropagation();\n\n const { contextName } = props;\n\n // if form is disabled (there is already a submit handler running) don't do anything\n if (disabled) {\n return;\n }\n\n // clear errors and disable form while it's submitting\n setErrors([]);\n setDisabled(true);\n\n // complete the data with values from custom components\n // note: it follows the same logic as SmartForm's getDocument method\n const data = getSubmitData();\n\n // update document form\n try {\n const documentId = currentDocument._id;\n const result = await updateDocument({\n input: {\n id: documentId,\n data,\n contextName,\n },\n });\n // TODO: handle more than 1 error\n if (result.errors?.length) {\n mutationErrorCallback(document, result.errors[0]);\n } else {\n editMutationSuccessCallback(result);\n }\n } catch (error) {\n mutationErrorCallback(document, error);\n }\n };\n\n /*\n\n Delete document handler\n\n */\n const deleteDocumentWithConfirm = () => {\n const document = currentDocument;\n const documentId = props.document._id;\n const documentTitle = document.title || document.name || \"\";\n\n const deleteDocumentConfirm = intl.formatMessage(\n { id: \"forms.delete_confirm\" },\n { title: documentTitle }\n );\n\n if (window.confirm(deleteDocumentConfirm)) {\n deleteDocument({ input: { id: documentId } })\n .then((mutationResult) => {\n // the mutation result looks like {data:{collectionRemove: null}} if succeeded\n if (props.removeSuccessCallback)\n props.removeSuccessCallback({ documentId, documentTitle });\n refetchForm();\n })\n .catch((error) => {\n // eslint-disable-next-line no-console\n console.log(error);\n });\n }\n };\n\n // --------------------------------------------------------------------- //\n // ------------------------- Props to Pass ----------------------------- //\n // --------------------------------------------------------------------- //\n\n // --------------------------------------------------------------------- //\n // ----------------------------- Render -------------------------------- //\n // --------------------------------------------------------------------- //\n\n const { successComponent, document, currentUser, model, warnUnsavedChanges } =\n props;\n const FormComponents = useVulcanComponents();\n\n const formType: \"edit\" | \"new\" = document ? \"edit\" : \"new\";\n\n /** \n\n Submit form handler\n\n On success/failure, will call the relevant callbacks\n\n */\n const submitForm = formType === \"new\" ? submitFormCreate : submitFormUpdate;\n\n // Fields computation\n const mutableFields =\n formType === \"edit\"\n ? getEditableFields(schema, currentUser, initialDocument)\n : getInsertableFields(schema, currentUser);\n\n const { formLayoutProps, formGroupProps } = getChildrenProps(\n props,\n { disabled, currentDocument },\n {\n formType,\n },\n {\n deleteDocument: deleteDocumentWithConfirm,\n }\n );\n const isChanged = isNotSameDocument(initialDocument, currentDocument);\n\n return success && successComponent ? (\n successComponent\n ) : (\n <FormWarnUnsaved\n isChanged={isChanged}\n warnUnsavedChanges={warnUnsavedChanges}\n >\n <FormContext.Provider\n value={{\n throwError,\n clearForm,\n refetchForm,\n isChanged,\n submitForm: submitFormContext, //Change in name because we already have a function\n // called submitForm, but no reason for the user to know\n // about that\n addToDeletedValues: addToDeletedValues,\n updateCurrentValues: updateCurrentValues,\n getDocument: () => currentDocument,\n getLabel: (fieldName, fieldLocale) =>\n getLabel(model, flatSchema, intl, fieldName, fieldLocale),\n initialDocument: initialDocument,\n // TODO BAD: check where used\n //setFormState: this.setFormState,\n addToSubmitForm,\n addToSuccessForm,\n addToFailureForm,\n clearFormCallbacks,\n errors,\n currentValues,\n deletedValues,\n clearFieldErrors,\n disabled,\n }}\n >\n <FormComponents.FormLayout {...formLayoutProps}>\n {getFieldGroups(\n props,\n {\n currentDocument,\n schema,\n flatSchema,\n originalSchema,\n },\n intl,\n mutableFields,\n intl.formatMessage\n ).map((group, i) => (\n <FormComponents.FormGroup key={i} {...formGroupProps(group)} />\n ))}\n </FormComponents.FormLayout>\n </FormContext.Provider>\n </FormWarnUnsaved>\n );\n};\n\n// Mutation that yield a success result\ntype SuccessfulMutationResult<TData = Object> = MutationResult<TData> & {\n data: TData;\n};\n/**\n * Typeguared to allow considering the request as successful\n */\nconst isSuccessful = function <T = any>(\n result: MutationResult<T> | undefined\n): result is SuccessfulMutationResult<T> {\n return !!result?.data;\n};\n\nexport default Form;\n","/*\n * Schema converter/getters\n */\nimport { canCreateField, canUpdateField } from \"@vulcanjs/permissions\";\nimport { VulcanFieldSchema, VulcanSchema } from \"@vulcanjs/schema\";\nimport { getFieldType } from \"./utils\";\n\n/* getters */\n// filter out fields with \".\" or \"$\"\nexport const getValidFields = (schema) => {\n return Object.keys(schema).filter(\n (fieldName) => !fieldName.includes(\"$\") && !fieldName.includes(\".\")\n );\n};\n\n/*\n\nConvert a nested SimpleSchema schema into a JSON object\nIf flatten = true, will create a flat object instead of nested tree\n\n/* permissions */\n\n/**\n * @method Mongo.Collection.getInsertableFields\n * Get an array of all fields editable by a specific user for a given collection\n * @param {Object} user – the user for which to check field permissions\n */\nexport const getInsertableFields = function (schema, user) {\n const fields = Object.keys(schema).filter(function (fieldName) {\n var field = schema[fieldName];\n return canCreateField(user, field);\n });\n return fields;\n};\n\n/**\n * @method Mongo.Collection.getEditableFields\n * Get an array of all fields editable by a specific user for a given collection (and optionally document)\n * @param {Object} user – the user for which to check field permissions\n */\nexport const getEditableFields = function (schema, user, document) {\n const fields = Object.keys(schema).filter(function (fieldName) {\n var field = schema[fieldName];\n return canUpdateField(user, field, document);\n });\n return fields;\n};\n\nconst isNestedSchema = (schema: any): schema is VulcanSchema => {\n return typeof schema === \"object\";\n};\n\n/**\n * Vulcan Schema => Form Schema\n * TODO: type this better\n * @param schema\n * @param options\n * @returns\n */\nexport const convertSchema = (\n schema: VulcanSchema,\n options: { flatten?: boolean; removeArrays?: boolean } = {}\n) => {\n const { flatten = false, removeArrays = true } = options;\n\n let jsonSchema = {};\n\n Object.keys(schema).forEach((fieldName) => {\n // exclude array fields\n if (removeArrays && fieldName.includes(\"$\")) {\n return;\n }\n\n // extract schema\n jsonSchema[fieldName] = getFieldSchema(fieldName, schema);\n\n // check for existence of nested field\n // and get its schema if possible or its type otherwise\n const subSchemaOrType = getNestedFieldSchemaOrType(fieldName, schema);\n if (subSchemaOrType) {\n // remember the subschema if it exists, allow to customize labels for each group of items for arrays of objects\n jsonSchema[fieldName].arrayFieldSchema = getFieldSchema(\n `${fieldName}.$`,\n schema\n );\n\n // nested schema can be a field schema ({type, canRead, etc.}) (convertedSchema will be null)\n // or a schema on its own with subfields (convertedSchema will return smth)\n if (isNestedSchema(subSchemaOrType)) {\n // call convertSchema recursively on the subSchema\n const convertedSubSchema = convertSchema(subSchemaOrType, options);\n // subSchema is a full schema with multiple fields (eg array of objects)\n if (flatten) {\n jsonSchema = { ...jsonSchema, ...convertedSubSchema };\n } else {\n jsonSchema[fieldName].schema = convertedSubSchema;\n }\n } else {\n // subSchema is a simple field in this case (eg array of numbers)\n jsonSchema[fieldName].isSimpleArrayField = true; //getFieldSchema(`${fieldName}.$`, schema);\n }\n }\n });\n return jsonSchema;\n};\n\n/*\n\nGet a JSON object representing a field's schema\n\n*/\nexport const getFieldSchema = (fieldName: string, schema: VulcanSchema) => {\n let fieldSchema = {};\n schemaProperties.forEach((property) => {\n const propertyValue = schema[fieldName]?.[property];\n if (propertyValue) {\n fieldSchema[property] = propertyValue;\n }\n });\n return fieldSchema;\n};\n\n// type is an array due to the possibility of using SimpleSchema.oneOf\n// right now we support only fields with one type\nexport const getSchemaType = (fieldSchema: VulcanFieldSchema) =>\n getFieldType(fieldSchema);\n\nconst getArrayNestedSchema = (fieldName: string, schema: VulcanSchema) => {\n const arrayItemSchema = schema[`${fieldName}.$`];\n const nestedSchema = arrayItemSchema && getSchemaType(arrayItemSchema);\n return nestedSchema;\n};\n\n// TODO: not 100% it's valid with current implementation\nconst isNestedSchemaField = (fieldSchema: VulcanFieldSchema) => {\n const fieldType = getSchemaType(fieldSchema);\n return fieldType && typeof fieldType === \"object\";\n};\nconst getObjectNestedSchema = (fieldName: string, schema: VulcanSchema) => {\n const fieldSchema = schema[fieldName];\n if (!isNestedSchemaField(fieldSchema)) return null;\n const nestedSchema = fieldSchema && getSchemaType(fieldSchema);\n return nestedSchema;\n};\n/*\n\nGiven an array field, get its nested schema\nIf the field is not an object, this will return the subfield type instead\n*/\nexport const getNestedFieldSchemaOrType = (fieldName, schema) => {\n const arrayItemSchema = getArrayNestedSchema(fieldName, schema);\n if (!arrayItemSchema) {\n // look for an object schema\n const objectItemSchema = getObjectNestedSchema(fieldName, schema);\n // no schema was found\n if (!objectItemSchema) return null;\n return objectItemSchema;\n }\n return arrayItemSchema;\n};\n\nexport const schemaProperties = [\n \"type\",\n \"label\",\n \"optional\",\n \"required\",\n \"min\",\n \"max\",\n \"exclusiveMin\",\n \"exclusiveMax\",\n \"minCount\",\n \"maxCount\",\n \"allowedValues\",\n \"regEx\",\n \"blackbox\",\n \"trim\",\n \"custom\",\n \"defaultValue\",\n \"autoValue\",\n \"hidden\", // hidden: true means the field is never shown in a form no matter what\n \"mustComplete\", // mustComplete: true means the field is required to have a complete profile\n \"form\", // form placeholder\n \"inputProperties\", // form placeholder\n \"itemProperties\",\n \"control\", // SmartForm control (String or React component)\n \"input\", // SmartForm control (String or React component)\n \"autoform\", // legacy form placeholder; backward compatibility (not used anymore)\n \"order\", // position in the form\n \"group\", // form fieldset group\n \"onCreate\", // field insert callback\n \"onUpdate\", // field edit callback\n \"onDelete\", // field remove callback\n \"onInsert\", // OpenCRUD backwards compatibility\n \"onEdit\", // OpenCRUD backwards compatibility\n \"onRemove\", // OpenCRUD backwards compatibility\n \"canRead\",\n \"canCreate\",\n \"canUpdate\",\n \"viewableBy\", // OpenCRUD backwards compatibility\n \"insertableBy\", // OpenCRUD backwards compatibility\n \"editableBy\", // OpenCRUD backwards compatibility\n \"resolveAs\",\n \"searchable\",\n \"description\",\n \"beforeComponent\",\n \"afterComponent\",\n \"placeholder\",\n \"options\",\n \"query\",\n \"queryWaitsForValue\",\n \"autocompleteQuery\",\n \"fieldProperties\",\n \"intl\",\n \"intlId\",\n];\n\nexport const formProperties = [\n \"optional\",\n \"required\",\n \"min\",\n \"max\",\n \"exclusiveMin\",\n \"exclusiveMax\",\n \"minCount\",\n \"maxCount\",\n \"allowedValues\",\n \"regEx\",\n \"blackbox\",\n \"trim\",\n \"custom\",\n \"defaultValue\",\n \"autoValue\",\n \"mustComplete\", // mustComplete: true means the field is required to have a complete profile\n \"form\", // form placeholder\n \"inputProperties\", // form placeholder\n \"itemProperties\",\n \"control\", // SmartForm control (String or React component)\n \"input\", // SmartForm control (String or React component)\n \"order\", // position in the form\n \"group\", // form fieldset group\n \"description\",\n \"beforeComponent\",\n \"afterComponent\",\n \"placeholder\",\n \"options\",\n \"query\",\n \"queryWaitsForValue\",\n \"autocompleteQuery\",\n \"fieldProperties\",\n];\n","import merge from \"lodash/merge.js\";\nimport find from \"lodash/find.js\";\nimport isPlainObject from \"lodash/isPlainObject.js\";\nimport set from \"lodash/set.js\";\nimport size from \"lodash/size.js\";\n\nimport { removePrefix, filterPathsByPrefix } from \"./path_utils\";\nimport { VulcanFieldSchema } from \"@vulcanjs/schema\";\n\n// add support for nested properties\nexport const deepValue = function (obj, path) {\n const pathArray = path.split(\".\");\n\n for (var i = 0; i < pathArray.length; i++) {\n obj = obj[pathArray[i]];\n }\n\n return obj;\n};\n\n// see http://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objects\nexport const flatten = function (data) {\n var result = {};\n function recurse(cur, prop) {\n if (Object.prototype.toString.call(cur) !== \"[object Object]\") {\n result[prop] = cur;\n } else if (Array.isArray(cur)) {\n for (var i = 0, l = cur.length; i < l; i++)\n recurse(cur[i], prop + \"[\" + i + \"]\");\n if (l == 0) result[prop] = [];\n } else {\n var isEmpty = true;\n for (var p in cur) {\n isEmpty = false;\n recurse(cur[p], prop ? prop + \".\" + p : p);\n }\n if (isEmpty && prop) result[prop] = {};\n }\n }\n recurse(data, \"\");\n return result;\n};\n\nexport const isEmptyValue = (value) =>\n typeof value === \"undefined\" ||\n value === null ||\n value === \"\" ||\n (Array.isArray(value) && value.length === 0);\n\n/**\n * Merges values. It takes into account the current, original and deleted values,\n * and the merge produces the proper type for simple objects or arrays.\n *\n * @param {Object} props\n * Form component props. Only specific properties for this function are documented.\n * @param {*} props.currentValue\n * Current value of the field\n * @param {*} props.documentValue\n * Original value of the field\n * @return {*|undefined}\n * Merged value or undefined if no merge was performed\n */\nexport const mergeValue = ({\n currentValue,\n documentValue,\n deletedValues: deletedFields,\n path,\n locale,\n datatype,\n}) => {\n if (locale) {\n // note: intl fields are of type Object but should be treated as Strings\n return currentValue || documentValue || \"\";\n }\n\n // note: retrieve nested deleted values is performed here to avoid skipping\n // the merge in case the current field is not in `currentValues` but a nested\n // property has been removed directly by path\n const deletedValues = getNestedDeletedValues(path, deletedFields);\n const hasDeletedValues = !!size(deletedValues);\n if (\n (Array.isArray(currentValue) || hasDeletedValues) &&\n find(datatype, [\"type\", Array])\n ) {\n return merge([], documentValue, currentValue, deletedValues);\n } else if (\n (isPlainObject(currentValue) || hasDeletedValues) &&\n find(datatype, [\"type\", Object])\n ) {\n return merge({}, documentValue, currentValue, deletedValues);\n }\n return undefined;\n};\n\n/**\n * Converts a list of field names to an object of deleted values.\n *\n * @param {string[]|Object.<string|string>} deletedFields\n * List of deleted field names or paths\n * @param {Object|Array=} accumulator={}\n * Value to reduce the values to\n * @return {Object|Array}\n * Deleted values, with the structure defined by taking the received deleted\n * fields as paths\n * @example\n * const deletedFields = [\n * 'field.subField',\n * 'field.subFieldArray[0]',\n * 'fieldArray[0]',\n * 'fieldArray[2].name',\n * ];\n * getNestedDeletedValues(deletedFields);\n * // => { 'field': { 'subField': null, 'subFieldArray': [null] }, 'fieldArray': [null, undefined, { name: null } }\n */\nexport const getDeletedValues = (deletedFields, accumulator = {}) =>\n deletedFields.reduce(\n (deletedValues, path) => set(deletedValues, path, null),\n accumulator\n );\n\n/**\n * Filters the given field names by prefix, removes it from each one of them\n * and convert the list to an object of deleted values.\n *\n * @param {string=} prefix\n * Prefix to filter and remove from deleted fields\n * @param {string[]|Object.<string|string>} deletedFields\n * List of deleted field names or paths\n * @param {Object|Array=} accumulator={}\n * Value to reduce the values to\n * @return {Object.<string, null>}\n * Object keyed with the given deleted fields, valued with `null`\n * @example\n * const deletedFields = [\n * 'field.subField',\n * 'field.subFieldArray[0]',\n * 'fieldArray[0]',\n * 'fieldArray[2].name',\n * ];\n * getNestedDeletedValues('field', deletedFields);\n * // => { 'subField': null, 'subFieldArray': [null] }\n * getNestedDeletedValues('fieldArray', deletedFields);\n * // => { '0': null, '2': { 'name': null } }\n * getNestedDeletedValues('fieldArray', deletedFields, []);\n * // => [null, undefined, { 'name': null } ]\n */\nexport const getNestedDeletedValues = (\n prefix,\n deletedFields,\n accumulator = {}\n) =>\n getDeletedValues(\n removePrefix(prefix, filterPathsByPrefix(prefix, deletedFields)),\n accumulator\n );\n\n//TODO: check if it still works as expected\n// previously was dataType[0].type\nexport const getFieldType = (fieldSchema: VulcanFieldSchema) =>\n fieldSchema.type;\n/**\n * Get appropriate null value for various field types\n *\n * @param {Array} datatype\n * Field's datatype property\n */\nexport const getNullValue = (datatype) => {\n const fieldType = getFieldType(datatype);\n if (fieldType === Array) {\n return [];\n } else if (fieldType === Boolean) {\n return false;\n } else if (fieldType === String) {\n return \"\";\n } else if (fieldType === Number) {\n return \"\";\n } else {\n // normalize to null\n return null;\n }\n};\n","import toPath from \"lodash/toPath.js\";\nimport initial from \"lodash/initial.js\";\nimport flow from \"lodash/fp/flow.js\";\nimport takeRight from \"lodash/takeRight.js\";\n\n/**\n * Splits a path in string format into an array.\n */\nexport const splitPath = (string: string) => toPath(string);\n\n/**\n * Joins a path in array format into a string.\n */\nexport const joinPath = (array: Array<string | number>): string =>\n array.reduce<string>(\n (string, item) =>\n string +\n (Number.isNaN(Number(item))\n ? `${string === \"\" ? \"\" : \".\"}${item}`\n : `[${item}]`),\n \"\"\n );\n\n/**\n * Retrieves parent path from the given one.\n *\n * @param {String} string\n * Path in string format\n * @return {String}\n */\nexport const getParentPath = flow(splitPath, initial, joinPath);\n\n/**\n * Removes prefix from the given paths.\n *\n * @param {String} prefix\n * @param {String[]} paths\n * @return {String[]}\n */\nexport const removePrefix = (\n prefix: string,\n paths: Array<string>\n): Array<string> => {\n const explodedPrefix = splitPath(prefix);\n return paths.map((path) => {\n if (path === prefix) {\n return path;\n }\n const explodedPath = splitPath(path);\n const explodedSuffix = takeRight(\n explodedPath,\n explodedPath.length - explodedPrefix.length\n );\n return joinPath(explodedSuffix);\n });\n};\n\n/**\n * Filters paths that have the given prefix.\n *\n * @param {String} prefix\n * @param {String[]} paths\n * @return {String[]}\n */\nexport const filterPathsByPrefix = (prefix: string, paths: Array<string>) =>\n paths.filter(\n (path) =>\n path === prefix ||\n path.startsWith(`${prefix}.`) ||\n path.startsWith(`${prefix}[`)\n );\n","/**\n * Field processing functions that computes groups and add relevant props for i18n\n */\nimport { formProperties } from \"../../utils/schema_utils\";\nimport { FieldGroup } from \"@vulcanjs/schema\";\nimport { FormField } from \"../../typings\";\nimport { FormProps, FormState } from \"./typings\";\n\n/**\n * Field related functions\n */\n\nimport { VulcanSchema } from \"@vulcanjs/schema\";\nimport uniq from \"lodash/uniq.js\";\nimport compact from \"lodash/compact.js\";\nimport get from \"lodash/get.js\";\nimport pick from \"lodash/pick.js\";\nimport {\n isIntlField,\n formatLabel,\n getIntlKeys,\n getIntlLabel,\n} from \"@vulcanjs/i18n\";\n\nimport { IntlProviderContextValue } from \"@vulcanjs/react-i18n\";\nimport map from \"lodash/map.js\";\nimport sortBy from \"lodash/sortBy.js\";\nimport uniqBy from \"lodash/uniqBy.js\";\nimport difference from \"lodash/difference.js\";\nimport reject from \"lodash/reject.js\";\nimport intersection from \"lodash/intersection.js\";\nimport _filter from \"lodash/filter.js\";\nimport { capitalize } from \"@vulcanjs/utils\";\nimport { VulcanFieldSchema } from \"@vulcanjs/schema\";\nimport { VulcanModel } from \"@vulcanjs/model\";\n\n/*\n\n Get a field's intl keys (useful for debugging)\n\n */\nconst getModelIntlKeys = (\n model: VulcanModel,\n flatSchema: any,\n fieldName: string\n) => {\n return getIntlKeys({\n fieldName: fieldName,\n modelName: model.name,\n schema: flatSchema,\n });\n};\n\n/*\n\n Get a field's label\n\n */\nexport const getLabel = (\n model: VulcanModel,\n flatSchema: any,\n context: IntlProviderContextValue,\n fieldName: string,\n fieldLocale?: string\n) => {\n const collectionName = model.name.toLowerCase();\n const label = formatLabel({\n intl: context,\n fieldName: fieldName,\n collectionName: collectionName,\n schema: flatSchema,\n });\n if (fieldLocale) {\n const intlFieldLocale = context.formatMessage({\n id: `locales.${fieldLocale}`,\n defaultMessage: fieldLocale,\n });\n return `${label} (${intlFieldLocale})`;\n } else {\n return label;\n }\n};\n\n/*\n\n Get a field's description\n\n (Same as getLabel but pass isDescription: true )\n */\nconst getDescription = (\n model: VulcanModel,\n flatSchema: any,\n context: any,\n fieldName: string\n) => {\n const collectionName = model.name.toLowerCase();\n const description = getIntlLabel({\n intl: context,\n fieldName: fieldName,\n collectionName: collectionName,\n schema: flatSchema,\n isDescription: true,\n });\n return description || null;\n};\n\n/*\n\n Get a field option's label\n\n */\nconst getOptionLabel = (\n model: VulcanModel,\n context: { formatMessage: Function },\n fieldName: string,\n option: { intlId?: string; label: string; value?: any }\n) => {\n const collectionName = model.name.toLowerCase();\n const intlId =\n option.intlId || `${collectionName}.${fieldName}.${option.value}`;\n return context.formatMessage({\n id: intlId,\n defaultMessage: option.label,\n });\n};\n\n/*\n\n Get a list of the fields to be included in the current form\n\n Note: when submitting the form (getData()), do not include any extra fields.\n\n */\nexport const getFieldNames = (\n props: Pick<FormProps, \"fields\" | \"addFields\" | \"removeFields\">,\n currentDocument,\n optionsFromArgs: {\n excludeHiddenFields?: boolean;\n excludeRemovedFields?: boolean;\n replaceIntlFields?: boolean;\n addExtraFields?: boolean;\n schema?: VulcanSchema;\n mutableFields?: Array<any>;\n }\n) => {\n const { fields, addFields, removeFields } = props;\n const defaultOptions = {\n excludeHiddenFields: true,\n excludeRemovedFields: true,\n replaceIntlFields: false,\n addExtraFields: false,\n };\n const options = {\n ...defaultOptions,\n ...optionsFromArgs,\n };\n const {\n schema,\n mutableFields,\n excludeRemovedFields,\n excludeHiddenFields,\n addExtraFields,\n replaceIntlFields,\n } = options;\n\n // get all editable/insertable fields (depending on current form type)\n let relevantFields = mutableFields;\n\n // if \"fields\" prop is specified, restrict list of fields to it\n if (typeof fields !== \"undefined\" && fields.length > 0) {\n relevantFields = intersection(relevantFields, fields);\n }\n\n // if \"hideFields\" prop is specified, remove its fields\n if (excludeRemovedFields) {\n // OpenCRUD backwards compatibility\n //const removeFields = removeFields || hideFields;\n if (typeof removeFields !== \"undefined\" && removeFields.length > 0) {\n relevantFields = difference(relevantFields, removeFields);\n }\n }\n\n // if \"addFields\" prop is specified, add its fields\n if (\n addExtraFields &&\n typeof addFields !== \"undefined\" &&\n addFields.length > 0\n ) {\n relevantFields = relevantFields?.concat(addFields);\n }\n\n // remove all hidden fields\n if (excludeHiddenFields) {\n const document = currentDocument;\n relevantFields = reject(relevantFields, (fieldName) => {\n const hidden = schema?.[fieldName].hidden;\n return typeof hidden === \"function\"\n ? hidden({ props, document })\n : hidden;\n });\n }\n\n // replace intl fields\n if (replaceIntlFields) {\n relevantFields = relevantFields?.map((fieldName) =>\n isIntlField(schema?.[fieldName]) ? `${fieldName}_intl` : fieldName\n );\n }\n\n // remove any duplicates\n relevantFields = uniq(relevantFields);\n\n return relevantFields;\n};\n\n// --------------------------------------------------------------------- //\n// -------------------------------- Fields ----------------------------- //\n// --------------------------------------------------------------------- //\n\nconst initField = (\n props: { model: VulcanModel; layout?: \"horizontal\" | \"vertical\" },\n state: Pick<FormState, \"currentDocument\" | \"flatSchema\" | \"originalSchema\">,\n context: any,\n fieldName: string,\n fieldSchema: VulcanFieldSchema\n) => {\n const { model } = props;\n const { currentDocument, flatSchema } = state;\n const isArray = fieldSchema.type === Array;\n\n // intialize properties\n let field: Partial<FormField> = {\n ...pick(fieldSchema, formProperties),\n name: fieldName,\n datatype: fieldSchema.type,\n layout: props.layout, // A layout property used to control how the form fields are displayed. Defaults to horizontal.\n input: fieldSchema.input || fieldSchema.control, // TODO\n };\n\n // if this is an array field also store its array item type\n if (isArray) {\n const itemFieldSchema = state.originalSchema[`${fieldName}.$`];\n field.itemDatatype = get(itemFieldSchema, \"type.0.type\");\n }\n\n field.label = getLabel(model, flatSchema, context, fieldName);\n field.intlKeys = getIntlKeys({\n fieldName,\n modelName: model.name,\n schema: model.schema,\n });\n // // replace value by prefilled value if value is empty\n // const prefill = fieldSchema.prefill || (fieldSchema.form && fieldSchema.form.prefill);\n // if (prefill) {\n // const prefilledValue = typeof prefill === 'function' ? prefill.call(fieldSchema) : prefill;\n // if (!!prefilledValue && !field.value) {\n // field.prefilledValue = prefilledValue;\n // field.value = prefilledValue;\n // }\n // }\n\n const document = currentDocument;\n field.document = document;\n\n // internationalize field options labels\n if (field.options && Array.isArray(field.options)) {\n field.options = field.options.map((option) => ({\n ...option,\n label: getOptionLabel(model, context, fieldName, option),\n }));\n }\n\n // if this an intl'd field, use a special intlInput\n if (isIntlField(fieldSchema)) {\n field.intlInput = true;\n }\n\n // add any properties specified in fieldSchema.form as extra props passed on\n // to the form component, calling them if they are functions\n const inputProperties = fieldSchema.form || fieldSchema.inputProperties || {};\n for (const prop in inputProperties) {\n const property = inputProperties[prop];\n field[prop] =\n typeof property === \"function\"\n ? property.call(fieldSchema, {\n ...props,\n fieldName,\n document,\n intl: context,\n })\n : property;\n }\n\n // add description as help prop\n const description = getDescription(model, flatSchema, context, fieldName);\n if (description) {\n field.help = description;\n }\n\n return field as FormField;\n};\nconst handleFieldPath = (\n field: FormField,\n fieldName: string,\n parentPath?: string\n) => {\n const fieldPath = parentPath ? `${parentPath}.${fieldName}` : fieldName;\n field.path = fieldPath;\n // TODO: reintroduce this side effect to correctly set the default values\n // (previously was in Form.tsx)\n // Note sure if this is actually needed\n // if (field.defaultValue) {\n // set(this.defaultValues, fieldPath, field.defaultValue);\n // }\n return field;\n};\nconst handleFieldParent = (field: FormField, parentFieldName?: string) => {\n // if field has a parent field, pass it on\n if (parentFieldName) {\n field.parentFieldName = parentFieldName;\n }\n\n return field;\n};\nconst handlePermissions = (\n field: FormField,\n fieldName: string,\n mutableFields: Array<any>\n) => {\n // if field is not creatable/updatable, disable it\n if (!mutableFields.includes(fieldName)) {\n field.disabled = true;\n }\n return field;\n};\nconst handleFieldChildren = (\n props: FormProps,\n state: Pick<FormState, \"currentDocument\" | \"flatSchema\" | \"originalSchema\">,\n context: any,\n field: FormField,\n fieldName: string,\n fieldSchema: any, // TODO: not a VulcanField, more a FormField\n schema: VulcanSchema,\n mutableFields: Array<any>\n) => {\n const { currentDocument } = state;\n // array field\n if (fieldSchema.arrayFieldSchema) {\n field.arrayFieldSchema = fieldSchema.arrayFieldSchema;\n // create a field that can be exploited by the form\n field.arrayField = createArraySubField(\n props,\n state,\n context,\n fieldName,\n field.arrayFieldSchema,\n schema,\n mutableFields\n );\n //field.nestedInput = true\n }\n // nested fields: set input to \"nested\"\n if (fieldSchema.schema) {\n field.nestedSchema = fieldSchema.schema;\n field.nestedInput = true;\n\n // get nested schema\n // for each nested field, get field object by calling createField recursively\n field.nestedFields = getFieldNames(props, currentDocument, {\n schema: field.nestedSchema,\n addExtraFields: false,\n }).map((subFieldName) => {\n return createField(\n props,\n state,\n context,\n subFieldName,\n field.nestedSchema,\n mutableFields,\n fieldName,\n field.path\n );\n });\n }\n return field;\n};\n\n/*\n Given a field's name, the containing schema, and parent, create the\n complete field object to be passed to the component\n\n */\nconst createField = (\n props: FormProps,\n state: Pick<FormState, \"currentDocument\" | \"flatSchema\" | \"originalSchema\">,\n context: any,\n fieldName: string,\n schema: any,\n mutableFields: Array<any>,\n parentFieldName?: string,\n parentPath?: string\n): FormField => {\n const fieldSchema = schema[fieldName];\n let field = initField(props, state, context, fieldName, fieldSchema);\n field = handleFieldPath(field, fieldName, parentPath);\n field = handleFieldParent(field, parentFieldName);\n field = handlePermissions(field, fieldName, mutableFields);\n field = handleFieldChildren(\n props,\n state,\n context,\n field,\n fieldName,\n fieldSchema,\n schema,\n mutableFields\n );\n return field;\n};\nconst createArraySubField = (\n props: FormProps,\n state: Pick<FormState, \"currentDocument\" | \"flatSchema\" | \"originalSchema\">,\n context: any,\n fieldName: string,\n subFieldSchema: VulcanFieldSchema,\n schema: VulcanSchema,\n mutableFields: Array<string>\n) => {\n const subFieldName = `${fieldName}.$`;\n let subField = initField(props, state, context, subFieldName, subFieldSchema);\n // array subfield has the same path and permissions as its parent\n // so we use parent name (fieldName) and not subfieldName\n subField = handleFieldPath(subField, fieldName);\n subField = handlePermissions(subField, fieldName, mutableFields /*schema*/);\n // we do not allow nesting yet\n //subField = this.handleFieldChildren(field, fieldSchema)\n return subField;\n};\n\n// Group of multiple fields (obtained by parsing the whole schema)\ninterface GroupWithFields extends FieldGroup {\n fields: Array<FormField>;\n}\n\ntype FormSchemaState = Pick<\n FormState,\n \"currentDocument\" | \"schema\" | \"flatSchema\" | \"originalSchema\"\n>;\n\n/*\n\n Get all field groups\n\n */\nexport const getFieldGroups = (\n props: FormProps,\n state: FormSchemaState,\n context: IntlProviderContextValue,\n mutableFields: Array<string>,\n formatMessage: any\n) => {\n const { schema, currentDocument } = state;\n // build fields array by iterating over the list of field names\n let fields = getFieldNames(props, currentDocument, {\n mutableFields,\n schema,\n }).map((fieldName) => {\n // get schema for the current field\n return createField(props, state, context, fieldName, schema, mutableFields);\n });\n\n fields = sortBy(fields, \"order\");\n\n // get list of all unique groups (based on their name) used in current fields, remove \"empty\" group\n let groups = compact(uniqBy(map(fields, \"group\"), (g) => (g ? g.name : \"\")));\n\n // for each group, add relevant fields\n let groupsWithFields = groups.map((group) => {\n const label =\n group.label ||\n //this.context.formatMessage({ id: group.name }) ||\n capitalize(group.name);\n const groupFields = _filter<FormField>(fields, (field) => {\n return field.group && field.group.name === group.name;\n });\n const groupWithFields: GroupWithFields = {\n ...group,\n label,\n fields: groupFields,\n };\n return groupWithFields;\n });\n\n // add default group if necessary\n const defaultGroupFields = _filter(fields, (field) => !field.group);\n if (defaultGroupFields.length) {\n const defaultGroup: GroupWithFields = {\n name: \"default\",\n label: \"default\",\n order: 0,\n fields: defaultGroupFields,\n };\n groupsWithFields = [defaultGroup].concat(groupsWithFields);\n }\n\n // sort by order\n groupsWithFields = sortBy(groupsWithFields, \"order\");\n\n // console.log(groups);\n\n return groupsWithFields;\n};\n","import find from \"lodash/find.js\";\nimport isEqualWith from \"lodash/isEqualWith.js\";\nexport const isNotSameDocument = (initialDocument, changedDocument) => {\n const changedValue = find(changedDocument, (value, key, collection) => {\n return !isEqualWith(value, initialDocument[key], (objValue, othValue) => {\n if (!objValue && !othValue) return true;\n });\n });\n return typeof changedValue !== \"undefined\";\n};\n","import { useEffect, useRef } from \"react\";\nimport { block } from \"./block\";\nimport debug from \"debug\";\nconst debugTransitions = debug(\"vn:router-transitions\");\n\n/**\n * Can trigger an alert on unsaved changes\n *\n * Triggers event so you can also block SPA transition (implementation is NOT provided by this hook, you\n * need listeners whose implementation depends on your router (React Router, Next Router...), see block.ts)\n *\n * @see https://github.com/ReactTraining/history/blob/master/docs/blocking-transitions.md\n *\n * @param param0\n */\nexport const useBlockTransition = ({\n shouldBlock,\n getBlockedMessage,\n}: {\n shouldBlock: boolean;\n getBlockedMessage: (evt?: BeforeUnloadEvent) => string;\n}) => {\n // function to unblock the form\n const unblockRef = useRef<Function | undefined>();\n\n useEffect(() => {\n const isBlocking = !!unblockRef.current;\n debugTransitions(\n \"running effect\",\n \"should block\",\n shouldBlock,\n \"currently blocked\",\n isBlocking\n );\n\n const onUnblock = () => {\n debugTransitions(\"running unblock from effect\");\n if (!shouldBlock) {\n if (unblockRef.current) {\n unblockRef.current();\n }\n }\n };\n // block\n const onBlocked = (evt?: BeforeUnloadEvent): string => {\n const message = getBlockedMessage(evt);\n debugTransitions(\n \"user is being blocked after trying to leave the page, with message: \" +\n message\n );\n if (evt) {\n evt.returnValue = message;\n }\n return message;\n };\n if (shouldBlock) {\n debugTransitions(\n \"should block transition, setting up relevant event listener\"\n );\n unblockRef.current = block(onBlocked, onUnblock);\n }\n // unblock if not blocking anymore and was blocking previously\n if (!shouldBlock && isBlocking) {\n debugTransitions(\"should unblock (state has been reinitialized)\");\n if (unblockRef.current) {\n unblockRef.current();\n }\n }\n // trigger the potentially registered unblock function when component unmounts\n //return onUnblock;\n }, [shouldBlock]);\n};\n","import debug from \"debug\";\nconst debugTransitions = debug(\"vn:route-transition\");\nconst BeforeUnloadEventType = \"beforeunload\";\n/**\n * Event triggered when a warning on unsaved changes is necessary\n * The app should listen for this event to setup relevant blocking methods depending on the framework\n *\n * For instance with React Router:\n *\n * let unblock\n * window.addEventListener(\"blocktransition\", () => {\n * unblock = router.history.block(...)\n * })\n * window.addEventListener(\"unblocktransition\", () => {\n * unblock()\n * })\n *\n * For Next.js, you would do something similar\n * Check https://github.com/vercel/next.js/discussions/12348\n *\n */\nexport const BLOCK_TRANSITION_EVENT_TYPE = \"blocktransition\";\n/**\n * Called when blocking is not necessary anymore:\n * - there are no unsaved changes anymore\n * - user has confirmed they want to leave\n */\nexport const UNBLOCK_TRANSITION_EVENT_TYPE = \"unblocktransition\";\n/**\n * Intercepts the beforeunload event\n *\n * Code taken from React Router history feature\n * @see https://github.com/ReactTraining/history/blob/master/docs/blocking-transitions.md\n */\nfunction blockBeforeUnload(event: BeforeUnloadEvent) {\n // Cancel the event.\n event.preventDefault();\n // Chrome (and legacy IE) requires returnValue to be set.\n event.returnValue = \"\";\n}\n\n/**\n * Blocks transition\n *\n * /!\\ In order to catch SPA transition, you need to implement\n * an event listener in your own app.\n *\n *\n * @param onUnblock Callback to call on unblock, for custom behaviour\n * @returns A function to unblock the transition (eg if the form is back to\n * its original state)\n */\nexport const block = (\n setConfirmationMessage: (event?: BeforeUnloadEvent) => string,\n onUnblock?: Function\n) => {\n debugTransitions(\"running block function\");\n // trigger a block event, to be handled at the framework level\n // TODO: setConfirmationMessage should be passed as well\n const blockEvent = new Event(BLOCK_TRANSITION_EVENT_TYPE);\n window.dispatchEvent(blockEvent);\n // block at browser level\n window.addEventListener(BeforeUnloadEventType, blockBeforeUnload);\n window.addEventListener(BeforeUnloadEventType, setConfirmationMessage);\n // return an unblock function to cancel\n const unblock = () => {\n debugTransitions(\"running unblock function\");\n if (onUnblock) {\n debugTransitions(\"running user defined function\");\n onUnblock(); // callback from user land\n }\n // trigger an unblock event, to be handled at the framework level\n const unblockEvent = new Event(UNBLOCK_TRANSITION_EVENT_TYPE);\n window.dispatchEvent(unblockEvent);\n // remove the browser level events\n window.removeEventListener(BeforeUnloadEventType, blockBeforeUnload);\n window.removeEventListener(BeforeUnloadEventType, setConfirmationMessage);\n // unblock browser change\n // @ts-ignore\n window.onbeforeunload = undefined; //undefined instead of null to support IE\n };\n return unblock;\n};\n","import { useBlockTransition } from \"../useBlockTransition/useBlockTransition\";\nimport debug from \"debug\";\nimport { useIntlContext } from \"@vulcanjs/react-i18n\";\nconst debugTransitions = debug(\"vn:route-transitions\");\n\n/**\n * Can trigger an alert on unsaved changes\n *\n * Triggers event so you can also block SPA transition (implementation is NOT provided by this hook, you\n * need listeners whose implementation depends on your router (React Router, Next Router...), see block.ts)\n *\n * @see https://github.com/ReactTraining/history/blob/master/docs/blocking-transitions.md\n *\n * @param param0\n */\nexport const useWarnOnUnsaved = ({\n isChanged,\n warnUnsavedChanges,\n}: {\n isChanged: boolean;\n warnUnsavedChanges?: boolean;\n}) => {\n const context = useIntlContext();\n /**\n * To be passed to onbeforeunload event. The returned message will be displayed\n * by the prompt.\n *\n * see https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload\n * the message returned is actually ignored by most browsers and a default message 'Are you sure you want to leave this page? You might have unsaved changes' is displayed. See the Notes section on the mozilla docs above\n */\n const getBlockedMessage = (event?: BeforeUnloadEvent) => {\n debugTransitions(\"running handlePageLeave\", event);\n const message = context.formatMessage({\n id: \"forms.confirm_discard\",\n defaultMessage: \"Are you sure you want to discard your changes?\",\n });\n return message;\n };\n useBlockTransition({\n shouldBlock: !!(warnUnsavedChanges && isChanged),\n getBlockedMessage: getBlockedMessage,\n });\n};\n","/*\n\nFormContainer aka SmartForm\n\nChanges compared to Vulcan Meteor:\n\n- previously was named FormWrapper\n- accepts a model instead of collection\n- no queryFragmentName (resp. mutation name), instead you need to pass the fragment explicitely\n\nTechnically, this is a GraphqlSmartForm, while Form.tsx is the more\ngeneric SmartForm, or a \"ModelForm\".\n\n\n---\n\nGenerate the appropriate fragment for the current form, then\nwrap the main Form component with the necessary HoCs while passing\nthem the fragment.\n\nThis component is itself wrapped with:\n\n- withCurrentUser\n- withApollo (used to access the Apollo client for form pre-population)\n\nAnd wraps the Form component with:\n\n- withNew\n\nOr:\n\n- withSingle\n- withUpdate\n- withDelete\n\n(When wrapping with withSingle, withUpdate, and withDelete, a special Loader\ncomponent is also added to wait for withSingle's loading prop to be false)\n\n*/\nimport React, { useRef } from \"react\";\n// import // withCurrentUser,\n// Utils,\n// getFragment,\n//\"meteor/vulcan:core\";\nimport { DocumentNode } from \"@apollo/client\";\nimport gql from \"graphql-tag\";\n\nimport getFormFragments from \"../utils/formFragments\";\n// import { VulcanModel } from \"@vulcanjs/model\";\nimport { VulcanGraphqlModel, getFragmentName } from \"@vulcanjs/graphql\";\nimport type {\n CreateVariables,\n UpdateVariables,\n DeleteVariables,\n} from \"@vulcanjs/crud\";\nimport { capitalize } from \"@vulcanjs/utils\";\nimport {\n useSingle,\n useCreate,\n useUpdate,\n useDelete,\n UseSingleOptions,\n} from \"@vulcanjs/react-hooks\";\nimport { FetchResult } from \"@apollo/client\";\n// import { FormType } from \"./typings\";\nimport { debugVulcan } from \"@vulcanjs/utils\";\nimport { VulcanUser } from \"@vulcanjs/permissions\";\nimport { PassedDownFormProps } from \"./Form/typings\";\n// Be careful to import from the Consumer!\nimport { useVulcanComponents } from \"../../VulcanComponents/Consumer\";\nimport { useVulcanCurrentUser } from \"../../VulcanCurrentUser\";\nconst debugForm = debugVulcan(\"form\");\n\n// Mutation that yield a success result\ntype SuccessfulFetchResult<TData = Object> = FetchResult<TData> & {\n data: TData;\n};\n/**\n * Typeguared to allow considering the request as successful\n */\nconst isSuccessful = function <T = any>(\n result: FetchResult<T> | undefined\n): result is SuccessfulFetchResult<T> {\n return !!result?.data;\n};\n\nexport interface FormContainerProps extends PassedDownFormProps {\n model: VulcanGraphqlModel;\n /** Document id for edition mode, will automatically fetch the document */\n documentId?: string;\n /** Slug (= human readable unique id) for edition mode, will automatically fetch the document */\n slug?: string;\n /**\n * List only those fields in the form\n */\n fields?: Array<string>;\n /**\n * List default fields + those additional fields as well\n */\n addFields?: Array<string>;\n /**\n * Force a currentUser, overriding the currentUser obtained\n * via Context\n *\n * If you use many forms in your app,\n * it might be better to set VulcanCurrentUserContext\n * at the top-level of your app\n * (eg in \"pages/_app.js\" for Next.js)\n */\n currentUser?: VulcanUser | null;\n loadingCurrentUser?: boolean;\n}\nexport type SmartFormProps = FormContainerProps;\n\nconst useFragments = (\n props: Pick<\n FormContainerProps,\n | \"mutationFragment\"\n | \"mutationFragmentName\"\n | \"queryFragment\"\n | \"queryFragmentName\"\n // for auto generation\n | \"model\"\n | \"fields\"\n | \"addFields\"\n >,\n formType: \"edit\" | \"new\"\n) => {\n // get fragment used to decide what data to load from the server to populate the form,\n // as well as what data to ask for as return value for the mutation\n // TODO: move out of the component\n //const getFragments = () => {\n let queryFragment: DocumentNode | undefined;\n let queryFragmentName: string | undefined;\n let mutationFragment: DocumentNode | undefined;\n let mutationFragmentName: string | undefined;\n\n // if queryFragment or mutationFragment props are specified, accept either fragment object or fragment string\n // TODO: not sure we actually need that, gApollo accepts fragments or string normally\n if (props.queryFragment) {\n if (typeof props.queryFragment === \"string\") {\n queryFragment = gql`\n ${props.queryFragment}\n `;\n if (!props.queryFragmentName)\n throw new Error(\n \"When using a string queryFragment, queryFragmentName is mandatory\"\n );\n queryFragmentName = props.queryFragmentName;\n } else {\n // DocumentNode\n queryFragment = props.queryFragment;\n // automatically compute the fragment name\n queryFragmentName =\n props.queryFragmentName || getFragmentName(props.queryFragment);\n }\n }\n if (props.mutationFragment) {\n if (typeof props.mutationFragment === \"string\") {\n mutationFragment = gql`\n ${props.mutationFragment}\n `;\n if (!props.mutationFragmentName)\n throw new Error(\n \"When using a string mutationFragment, mutationFragmentName is mandatory\"\n );\n queryFragmentName = props.mutationFragmentName;\n } else {\n // DocumentNode\n mutationFragment = props.mutationFragment;\n // automatically compute the fragment name\n mutationFragmentName =\n props.mutationFragmentName || getFragmentName(props.mutationFragment);\n }\n }\n // auto generate fragments\n let autoFormFragments;\n if (!props.queryFragment || !props.mutationFragment) {\n const { model, fields, addFields } = props;\n // autogenerated fragments\n autoFormFragments = getFormFragments({\n formType,\n model,\n fields,\n addFields,\n });\n }\n // use autogenerated value if necessary\n if (!props.queryFragment) {\n queryFragment = autoFormFragments.queryFragment;\n queryFragmentName = autoFormFragments.queryFragmentName;\n }\n if (!props.mutationFragment) {\n mutationFragment = autoFormFragments.mutationFragment;\n mutationFragmentName = autoFormFragments.mutationFragmentName;\n }\n return {\n mutationFragment: mutationFragment as DocumentNode,\n mutationFragmentName: mutationFragmentName as string,\n queryFragment: queryFragment as DocumentNode,\n queryFragmentName: queryFragmentName as string,\n };\n};\n// Fonctionnal version to be able to use hooks\nexport const FormContainer = (props: FormContainerProps) => {\n const {\n model,\n documentId,\n slug,\n fields,\n addFields,\n currentUser: currentUserFromProps,\n loadingCurrentUser: loadingCurrentUserFromProps,\n } = props;\n const { schema } = model;\n // if a document is being passed, this is an edit form\n const isEdit = documentId || slug;\n const selector = {\n documentId,\n slug,\n };\n const formType = isEdit ? \"edit\" : \"new\";\n const VulcanComponents = useVulcanComponents();\n\n // get query & mutation fragments from props or else default to same as generatedFragment\n //return {\n // queryFragment,\n // mutationFragment,\n //};\n //}\n\n const prefix = `${model.name}${capitalize(formType)}`;\n // props to pass on to child component (i.e. <Form />)\n const childProps = {\n formType,\n schema,\n };\n\n const {\n mutationFragment,\n mutationFragmentName,\n queryFragment,\n queryFragmentName,\n } = useFragments(props, formType);\n\n // options for useCreate, useUpdate and useDelete\n const mutationOptions = {\n model,\n // collection: this.props.collection,\n fragment: mutationFragment,\n fragmentName: mutationFragmentName,\n };\n\n const queryOptions: UseSingleOptions<any> = {\n model,\n // TODO: what this option does?\n // queryName: `${prefix}FormQuery`,\n fragment: queryFragment,\n fragmentName: queryFragmentName,\n // fragmentName?\n input: {\n id: documentId,\n enableCache: false,\n // TODO: support slug\n },\n queryOptions: {\n // we always want to load a fresh copy of the document\n fetchPolicy: \"network-only\" as const,\n pollInterval: 0, // no polling, only load data once\n skip: formType === \"new\",\n },\n };\n /* debug\n console.log(\n \"MUT\",\n (mutationFragment as any).loc.source.body,\n mutationFragmentName\n );\n console.log(\n \"QUERY\",\n (queryFragment as any).loc.source.body,\n queryFragmentName\n );*/\n const { data, document, loading, refetch } = useSingle(queryOptions);\n if (formType !== \"new\") {\n debugForm(\n \"useSingle result\",\n \"data\",\n data,\n \"document\",\n document,\n \"loading\",\n loading\n );\n }\n // TODO: pass the creation functions down to the Form\n const [createDocument] = useCreate(mutationOptions);\n const [updateDocument] = useUpdate(mutationOptions);\n const [deleteDocument] = useDelete(mutationOptions);\n\n const {\n currentUser: currentUserFromContext,\n loading: loadingCurrentUserFromContext,\n } = useVulcanCurrentUser();\n const shouldGetCurrentUserFromProps =\n typeof currentUserFromProps !== \"undefined\";\n const currentUser = shouldGetCurrentUserFromProps\n ? currentUserFromProps\n : currentUserFromContext;\n const loadingCurrentUser = shouldGetCurrentUserFromProps\n ? loadingCurrentUserFromProps\n : loadingCurrentUserFromContext;\n\n // callbacks\n /*\n const formRef = useRef(null);\n const newMutationSuccessCallback = function <TData = Object>(\n result: SuccessfulFetchResult<TData>\n ) {\n getDocumentFromResult(result, \"new\");\n };\n const editMutationSuccessCallback = function <TData = Object>(\n result: SuccessfulFetchResult<TData>\n ) {\n getDocumentFromResult(result, \"edit\");\n };\n */\n\n /*\n The create hook already creates a document prop in a more stable way\n const getDocumentFromResult = function <TData = Object>(\n // must be called only on valid results\n result: SuccessfulFetchResult<TData> | undefined\n ) {\n if (!result) return undefined;\n // TODO: quite risky... we should have a better way to get the document\n let document = result.data[Object.keys(result.data)[0]].data; // document is always on first property\n\n return document;\n };*/\n // for new mutation, run refetch function if it exists\n /*\n if (mutationType === \"new\" && refetch) refetch();\n */\n\n const createAndReturnDocument = async (variables: CreateVariables) => {\n const result = await createDocument(variables);\n const { errors, document } = result;\n return {\n document,\n errors,\n };\n };\n const updateAndReturnDocument = async (variables: UpdateVariables) => {\n const result = await updateDocument(variables);\n const { errors, document } = result;\n return {\n document,\n errors,\n };\n };\n\n const deleteDocumentAndRefetch = async (variables: DeleteVariables) => {\n await deleteDocument(variables as any);\n };\n\n if (isEdit && loading) {\n return <VulcanComponents.Loading />;\n }\n return (\n <VulcanComponents.Form\n document={document}\n loading={loading || loadingCurrentUser}\n createDocument={createAndReturnDocument /*createDocument*/}\n updateDocument={updateAndReturnDocument}\n deleteDocument={deleteDocumentAndRefetch}\n refetch={refetch}\n currentUser={currentUser}\n {...childProps}\n {...props}\n />\n );\n};\n\n/*\nFormContainer.propTypes = {\n // main options\n documentId: PropTypes.string, // if a document is passed, this will be an edit form\n mutationFragment: PropTypes.object,\n mutationFragmentName: PropTypes.string,\n\n // graphQL\n // createFoo, deleteFoo, updateFoo\n // newMutation: PropTypes.func, // the new mutation\n // editMutation: PropTypes.func, // the edit mutation\n // removeMutation: PropTypes.func, // the remove mutation\n\n // form\n prefilledProps: PropTypes.object,\n layout: PropTypes.string,\n fields: PropTypes.arrayOf(PropTypes.string),\n hideFields: PropTypes.arrayOf(PropTypes.string),\n addFields: PropTypes.arrayOf(PropTypes.string),\n showRemove: PropTypes.bool,\n submitLabel: PropTypes.node,\n cancelLabel: PropTypes.node,\n revertLabel: PropTypes.node,\n repeatErrors: PropTypes.bool,\n warnUnsavedChanges: PropTypes.bool,\n formComponents: PropTypes.object,\n disabled: PropTypes.bool,\n itemProperties: PropTypes.object,\n successComponent: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n contextName: PropTypes.string,\n\n // callbacks\n ...callbackProps,\n\n currentUser: PropTypes.object,\n client: PropTypes.object,\n};\n\nFormContainer.defaultProps = {\n layout: \"horizontal\",\n};\n*/\n\n/*\nregisterComponent({\n name: 'SmartForm',\n component: FormContainer,\n hocs: [withCurrentUser, withApollo, withRouter, withCollectionProps],\n});\n*/\n\nexport const SmartForm = FormContainer;\n\nexport default FormContainer;\n","/**\n * Generate mutation and query fragments for a form based on the schema\n * TODO: refactor to mutualize more code with vulcan-core defaultFragment functions\n * TODO: move to lib when refactored\n */\nimport _uniq from \"lodash/uniq.js\";\nimport _intersection from \"lodash/intersection.js\";\nimport gql from \"graphql-tag\";\nimport {\n getCreateableFields,\n getUpdateableFields,\n getFragmentFieldNames,\n //isBlackbox,\n} from \"@vulcanjs/schema\";\nimport {\n getFieldFragment,\n VulcanGraphqlModel,\n //isBlackbox,\n} from \"@vulcanjs/graphql\";\nimport { capitalize } from \"@vulcanjs/utils\";\nimport type { FormType } from \"../typings\";\nimport compact from \"lodash/compact.js\";\n// getFieldFragment,\nconst intlSuffix = \"_intl\";\n\n// PostsEditFormQueryFragment/PostsNewFormMutationFragment/etc.\nconst getFragmentName = (\n formType: FormType,\n multiTypeName: string,\n fragmentType: \"mutation\" | \"query\"\n) =>\n [multiTypeName, formType, \"form\", fragmentType, \"fragment\"]\n .map(capitalize)\n .join(\"\");\n\n// get modifiable fields in the query either for update or create operations\nconst getQueryFieldNames = ({ schema, options }) => {\n const queryFields =\n options.formType === \"new\"\n ? getCreateableFields(schema)\n : getUpdateableFields(schema);\n return queryFields;\n};\n// add readable fields to mutation fields\nconst getMutationFieldNames = ({ readableFieldNames, queryFieldNames }) => {\n return _uniq(queryFieldNames.concat(readableFieldNames));\n};\n\n/*\nconst getFieldFragment = ({ schema, fieldName, options }) => {\n let fieldFragment = fieldName;\n const field = schema[fieldName];\n if (!(field && field.type)) return fieldName;\n const fieldType = field.type.singleType;\n const fieldTypeName =\n typeof fieldType === 'object'\n ? 'Object'\n : typeof fieldType === 'function'\n ? fieldType.name\n : fieldType;\n\n if (fieldName.slice(-5) === intlSuffix) {\n fieldFragment = `${fieldName}{ locale value }`;\n } else {\n switch (fieldTypeName) {\n // recursive call for nested arrays and objects\n case 'Object':\n if (!isBlackbox(field) && fieldType._schema) {\n fieldFragment =\n getSchemaFragment({\n fragmentName: fieldName,\n schema: fieldType._schema,\n options,\n }) || null;\n }\n break;\n case 'Array':\n const arrayItemFieldName = `${fieldName}.$`;\n const arrayItemField = schema[arrayItemFieldName];\n // note: make sure field has an associated array item field\n if (arrayItemField) {\n // child will either be native value or a an object (first case)\n const arrayItemFieldType = arrayItemField.type.singleType;\n if (!arrayItemField.blackbox && arrayItemFieldType._schema) {\n fieldFragment =\n getSchemaFragment({\n fragmentName: fieldName,\n schema: arrayItemFieldType._schema,\n options,\n }) || null;\n }\n }\n break;\n default:\n // handle intl or return fieldName\n fieldFragment = fieldName;\n break;\n }\n }\n return fieldFragment;\n};\n*/\n\n// get fragment for a whole schema (root schema or nested schema of an object or an array)\nconst getSchemaFragment = ({\n schema,\n fragmentName,\n options,\n fieldNames: providedFieldNames,\n}) => {\n // differentiate mutation/query and create/update cases\n // respect provided fieldNames if any (needed for the root schema)\n const fieldNames =\n providedFieldNames ||\n (options.isMutation\n ? getMutationFieldNames({\n queryFieldNames: getQueryFieldNames({ schema, options }),\n readableFieldNames: getFragmentFieldNames({\n schema,\n options: { onlyViewable: true },\n }),\n })\n : getQueryFieldNames({ schema, options }));\n\n const childFragments =\n fieldNames.length &&\n fieldNames\n .map((fieldName) =>\n getFieldFragment({\n schema,\n fieldName,\n options,\n getObjectFragment: getSchemaFragment, // allow to reuse the code from defaultFragment with another behaviour\n })\n )\n // remove empty values\n .filter((f) => !!f);\n if (childFragments.length) {\n return `${fragmentName} { ${childFragments.join(\"\\n\")} }`;\n }\n return null;\n};\n\n/**\n * Generate query and mutation fragments for forms, dynamically based on the selected fields\n */\nconst getFormFragments = ({\n formType = \"new\",\n model,\n fields, // restrict on certain fields\n addFields, // add additional fields (eg to display static fields)\n}: {\n model: VulcanGraphqlModel;\n formType: FormType;\n fields?: Array<string>; // restrict on certain fields\n addFields?: Array<string>; // add additional fields (eg to display static fields)\n}) => {\n const { schema, name, graphql } = model;\n const { typeName, multiTypeName } = graphql;\n // get the root schema fieldNames\n let queryFieldNames = getQueryFieldNames({ schema, options: { formType } });\n let mutationFieldNames = getMutationFieldNames({\n queryFieldNames,\n readableFieldNames: getFragmentFieldNames({\n schema,\n options: { onlyViewable: true },\n }),\n });\n\n // if \"fields\" prop is specified, restrict list of fields to it\n if (fields && fields?.length > 0) {\n // add \"_intl\" suffix to all fields in case some of them are intl fields\n const fieldsWithIntlSuffix = fields.map((field) => `${field}${intlSuffix}`);\n const allFields = [...fields, ...fieldsWithIntlSuffix];\n queryFieldNames = _intersection(queryFieldNames, allFields);\n mutationFieldNames = _intersection(mutationFieldNames, allFields);\n }\n\n // add \"addFields\" prop contents to list of fields\n if (addFields?.length) {\n queryFieldNames = queryFieldNames.concat(addFields);\n mutationFieldNames = mutationFieldNames.concat(addFields);\n }\n\n // userId is used to check for permissions, so add it to fragments if possible\n if (schema.userId) {\n queryFieldNames.unshift(\"userId\");\n mutationFieldNames.unshift(\"userId\");\n }\n\n if (schema._id) {\n queryFieldNames.unshift(\"_id\");\n mutationFieldNames.unshift(\"_id\");\n }\n\n // check unicity (_id can be added twice)\n queryFieldNames = _uniq(queryFieldNames);\n mutationFieldNames = _uniq(mutationFieldNames);\n\n if (queryFieldNames.length === 0)\n // NOTE: in theory, you could have no queriable fields, but mutable fields =>\n // a form for data that you can create but can never see...\n // Since that doesn't make much sense, we throw an error to secure the end user\n throw new Error(\n `Model \"${model.name}\" has no queryable fields, cannot create a form for it. Please add readable/createable/updateable fields to the model schema.`\n );\n if (mutationFieldNames.length === 0)\n throw new Error(\n `Model \"${model.name}\" has no mutable fields, cannot create a form for it. Please add createable/updateable fields to model schema.`\n );\n\n const queryFragmentName = getFragmentName(\n formType,\n multiTypeName, // previously collectionName //name,\n \"query\"\n );\n // generate query fragment based on the fields that can be edited. Note: always add _id, and userId if possible.\n // TODO: support nesting\n const queryFragmentText = getSchemaFragment({\n schema,\n fragmentName: `fragment ${queryFragmentName} on ${typeName}`,\n options: { formType, isMutation: false },\n fieldNames: queryFieldNames,\n });\n if (!queryFragmentText) {\n // NOTE: this should never happen if we don't have an empty array for field names\n throw new Error(\n `Model ${model.name} with fields ${queryFieldNames} yield an empty query fragment.`\n );\n }\n const generatedQueryFragment = gql(queryFragmentText);\n\n const mutationFragmentName = getFragmentName(\n formType,\n multiTypeName, // previously collectionName,\n \"mutation\"\n );\n const mutationFragmentText = getSchemaFragment({\n schema,\n fragmentName: `fragment ${mutationFragmentName} on ${typeName}`,\n options: { formType, isMutation: true },\n fieldNames: mutationFieldNames,\n });\n if (!mutationFragmentText) {\n // NOTE: this should never happen if we don't have an empty array for field names\n throw new Error(\n `Model ${model.name} with fields ${mutationFieldNames} yield an empty mutation fragment.`\n );\n }\n // generate mutation fragment based on the fields that can be edited and/or viewed. Note: always add _id, and userId if possible.\n // TODO: support nesting\n const generatedMutationFragment = gql(mutationFragmentText);\n\n // if any field specifies extra queries, add them\n const extraQueries = compact(\n getQueryFieldNames({ schema, options: { formType } }).map((fieldName) => {\n const field = schema[fieldName];\n return field.query;\n })\n );\n // get query & mutation fragments from props or else default to same as generatedFragment\n return {\n queryFragment: generatedQueryFragment,\n mutationFragment: generatedMutationFragment,\n queryFragmentName,\n mutationFragmentName,\n extraQueries,\n };\n};\n\nexport default getFormFragments;\n","import { useContext } from \"react\";\nimport { VulcanCurrentUserContext } from \"./Context\";\n\nexport const VulcanCurrentUserConsumer = VulcanCurrentUserContext.Consumer;\n\nexport const useVulcanCurrentUser = () => useContext(VulcanCurrentUserContext);\n","import React from \"react\";\nimport type { VulcanUser } from \"@vulcanjs/permissions\";\n\nexport type VulcanCurrentUserContextType =\n | { currentUser: VulcanUser | null; loading: false }\n | { loading: true; currentUser: any };\n// We need this to shut TypeScript up\n// You should use the Provider to get the right default values\nexport const VulcanCurrentUserContext =\n React.createContext<VulcanCurrentUserContextType>({\n currentUser: null,\n loading: false,\n });\n","/**\n * NOTE: KEEP SEPARATED FROM THE HOOKS TO CONSUME THE CONTEXT\n * otherwise you'll end up with circular dependencies because of the default components\n */\n// TODO: we might need to adapt the provider to merge its value with a potentially higher up context\nimport React from \"react\";\n\nimport {\n VulcanCurrentUserContext,\n VulcanCurrentUserContextType,\n} from \"./Context\";\n\n// So that you can override only some components by adding an additional context while keeping the defaults\nexport const VulcanCurrentUserProvider = ({\n value,\n ...props\n}: {\n value: VulcanCurrentUserContextType;\n children: React.ReactNode;\n}) => (\n <VulcanCurrentUserContext.Provider\n value={value} // merge provided components so the user can provide only a partial replacement\n {...props}\n />\n);\n","import pick from \"lodash/pick.js\";\n\n/**\n * Extract input props for the FormComponentInner\n * @param {*} props All component props\n * @returns Initial props + props specific to the HTML input in an inputProperties object\n */\nexport const getHtmlInputProps = (props) => {\n const { name, path, options, label, onChange, onBlur, value, disabled } =\n props;\n\n // these properties are whitelisted so that they can be safely passed to the actual form input\n // and avoid https://facebook.github.io/react/warnings/unknown-prop.html warnings\n const inputProperties = {\n ...props.inputProperties,\n name,\n path,\n options,\n label,\n onChange,\n onBlur,\n value,\n disabled,\n };\n\n return {\n ...props,\n inputProperties,\n };\n};\n\n/**\n * Extract input props for the FormComponentInner\n * @param {*} props All component props\n * @returns Initial props + props specific to the HTML input in an inputProperties object\n */\nexport const whitelistInputProps = (\n props: any\n): React.HTMLProps<HTMLInputElement> => {\n const whitelist = [\n \"name\",\n \"path\",\n \"options\",\n \"label\",\n \"onChange\",\n \"onBlur\",\n \"value\",\n \"disabled\",\n \"placeholder\",\n ];\n const value = props.value;\n let safeValue = value;\n // No null values in HTML inputs\n if (value === null) safeValue = undefined;\n // if value is null, return undefined\n return { ...pick(props, whitelist), value: safeValue };\n};\n","/**\n * NOTE: KEEP SEPARATED FROM THE HOOKS TO CONSUME THE CONTEXT\n * otherwise you'll end up with circular dependencies because of the default components\n */\n// TODO: we might need to adapt the provider to merge its value with a potentially higher up context\nimport React from \"react\";\n\nimport { PossibleVulcanComponents } from \"./typings\";\nimport { VulcanComponentsContext } from \"./Context\";\nimport { useVulcanComponents } from \"./Consumer\";\nimport { debugVulcan } from \"@vulcanjs/utils\";\nconst debugComponents = debugVulcan(\"components\"); //console.log;\n\n/**\n *\n * @param options.value An object of Vulcan components to be overriden.\n */\nexport const VulcanComponentsProvider = ({\n value,\n ...props\n}: {\n value?: Partial<PossibleVulcanComponents>;\n children: React.ReactNode;\n}) => {\n const currentComponents = useVulcanComponents();\n debugComponents(\n \"Current components __not_initialized?\",\n currentComponents.__not_initialized\n );\n const mergedComponents = {\n // merge with a parent Provider if needed\n ...(currentComponents?.__not_initialized ? {} : currentComponents || {}),\n ...(value || {}),\n };\n debugComponents(\"Merged components\", mergedComponents);\n // For preserving displayName, that is lost after build somehow\n Object.keys(mergedComponents).forEach((componentName) => {\n if (mergedComponents[componentName]) {\n mergedComponents[componentName].displayName = \"Vulcan.\" + componentName;\n } else {\n console.warn(`Encountered an undefined component: ${componentName}.\n The component may not be registered, or import failed.\n For instance due to an infinite import loop when importing\n \"useVulcanComponents\" from index instead of Consumer.`);\n }\n });\n return (\n <VulcanComponentsContext.Provider\n // We make the assumption that all components are there, user is responsible\n // for adding them correctly in the context where necessary\n value={mergedComponents as PossibleVulcanComponents} // merge provided components so the user can provide only a partial replacement\n {...props}\n />\n );\n};\n","import { LoadingButton } from \"../../core/LoadingButton\";\nimport { MutationButton } from \"../../core/MutationButton\";\nimport { Form, FormContainer } from \"../../form/core\";\nimport { PossibleFormComponents } from \"../typings\";\n\nexport const defaultFormComponents: Partial<PossibleFormComponents> = {\n Form,\n SmartForm: FormContainer,\n};\n// All those components are defined in each relevant package instead\nexport const defaultDatatableComponents = {};\nexport const defaultCellComponents = {};\nexport const defaultCoreComponents = {\n MutationButton,\n LoadingButton,\n};\n","// import { compose } from \"recompose\";\nimport React from \"react\";\n\nexport const Components = {}; // will be populated on startup\nexport const ComponentsTable = {}; // storage for infos about components\n\nexport const coreComponents = [\n \"Alert\",\n \"Button\",\n \"Modal\",\n \"ModalTrigger\",\n \"Table\",\n \"FormComponentCheckbox\",\n \"FormComponentCheckboxGroup\",\n \"FormComponentDate\",\n \"FormComponentDate2\",\n \"FormComponentDateTime\",\n \"FormComponentDefault\",\n \"FormComponentText\",\n \"FormComponentEmail\",\n \"FormComponentNumber\",\n \"FormComponentRadioGroup\",\n \"FormComponentSelect\",\n \"FormComponentSelectMultiple\",\n \"FormComponentStaticText\",\n \"FormComponentTextarea\",\n \"FormComponentTime\",\n \"FormComponentUrl\",\n \"FormComponentInner\",\n \"FormControl\",\n \"FormElement\",\n];\n\n/**\n * Register a Vulcan component with a name, a raw component than can be extended\n * and one or more optional higher order components.\n *\n * @param {String} name The name of the component to register.\n * @param {Component} rawComponent Interchangeable/extendable react component.\n * @param {...(Function|Array)} hocs The HOCs to compose with the raw component.\n *\n * Note: when a component is registered without higher order component, `hocs` will be\n * an empty array, and it's ok!\n * See https://github.com/reactjs/redux/blob/master/src/compose.js#L13-L15\n *\n * @returns Structure of a component in the list:\n *\n * ComponentsTable.Foo = {\n * name: 'Foo',\n * hocs: [fn1, fn2],\n * rawComponent: React.Component,\n * call: () => compose(...hocs)(rawComponent),\n * }\n *\n */\n/*\nexport function registerComponent(name, rawComponent, ...hocs) {\n // support single-argument syntax\n if (typeof arguments[0] === \"object\") {\n // note: cannot use `const` because name, components, hocs are already defined\n // as arguments so destructuring cannot work\n // eslint-disable-next-line no-redeclare\n var {\n name,\n component,\n // @ts-ignore\n hocs = [],\n } = arguments[0];\n rawComponent = component;\n }\n // store the component in the table\n ComponentsTable[name] = {\n name,\n rawComponent,\n hocs,\n };\n}\n*/\n\n/**\n * Returns true if a component with the given name has been registered with\n * registerComponent(name, component, ...hocs).\n *\n * @param {String} name The name of the component to get.\n * @returns {Boolean}\n */\nexport const componentExists = (name) => {\n const component = ComponentsTable[name];\n return !!component;\n};\n\n/**\n * Get a component registered with registerComponent(name, component, ...hocs).\n *\n * @param {String} name The name of the component to get.\n * @returns {Function|React Component} A (wrapped) React component\n */\n/*\nexport const getComponent = (name) => {\n const component = ComponentsTable[name];\n if (!component) {\n throw new Error(`Component ${name} not registered.`);\n }\n if (component.hocs && component.hocs.length) {\n const hocs = component.hocs.map((hoc) => {\n if (!Array.isArray(hoc)) {\n if (typeof hoc !== \"function\") {\n throw new Error(\n `In registered component ${name}, an hoc is of type ${typeof hoc}`\n );\n }\n return hoc;\n }\n const [actualHoc, ...args] = hoc;\n if (typeof actualHoc !== \"function\") {\n throw new Error(\n `In registered component ${name}, an hoc is of type ${typeof actualHoc}`\n );\n }\n return actualHoc(...args);\n });\n return compose(...hocs)(component.rawComponent);\n } else {\n return component.rawComponent;\n }\n};\n*/\n\n/**\n * Populate the lookup table for components to be callable\n * ℹ️ Called once on app startup\n **/\n/*\nexport const populateComponentsApp = () => {\n const registeredComponents = Object.keys(ComponentsTable);\n\n // loop over each component in the list\n registeredComponents.map((name) => {\n // populate an entry in the lookup table\n Components[name] = getComponent(name);\n\n // uncomment for debug\n // console.log('init component:', name);\n });\n\n const missingComponents = difference(coreComponents, registeredComponents);\n\n if (missingComponents.length) {\n // eslint-disable-next-line no-console\n console.warn(\n `Found the following missing core components: ${missingComponents.join(\n \", \"\n )}. Include a UI package such as vulcan:ui-bootstrap to add them.`\n );\n }\n};\n*/\n/**\n * Get the **raw** (original) component registered with registerComponent\n * without the possible HOCs wrapping it.\n *\n * @param {String} name The name of the component to get.\n * @returns {Function|React Component} An interchangeable/extendable React component\n */\nexport const getRawComponent = (name) => {\n return ComponentsTable[name].rawComponent;\n};\n\n/**\n * Replace a Vulcan component with the same name with a new component or\n * an extension of the raw component and one or more optional higher order components.\n * This function keeps track of the previous HOCs and wrap the new HOCs around previous ones\n *\n * @param {String} name The name of the component to register.\n * @param {React Component} newComponent Interchangeable/extendable component.\n * @param {...Function} newHocs The HOCs to compose with the raw component.\n * @returns {Function|React Component} A component callable with Components[name]\n *\n * Note: when a component is registered without higher order component, `hocs` will be\n * an empty array, and it's ok!\n * See https://github.com/reactjs/redux/blob/master/src/compose.js#L13-L15\n */\n/*\nexport function replaceComponent(name, newComponent, ...newHocs) {\n // support single argument syntax\n if (typeof arguments[0] === \"object\") {\n // eslint-disable-next-line no-redeclare\n var { name, component, hocs = [] } = arguments[0];\n newComponent = component;\n newHocs = hocs;\n }\n\n const previousComponent = ComponentsTable[name];\n const previousHocs = (previousComponent && previousComponent.hocs) || [];\n\n if (!previousComponent) {\n // eslint-disable-next-line no-console\n console.warn(\n `Trying to replace non-registered component ${name}. The component is ` +\n \"being registered. If you were trying to replace a component defined by \" +\n \"another package, make sure that you haven't misspelled the name. Check \" +\n \"also if the original component is still being registered or that it \" +\n \"hasn't been renamed.\"\n );\n }\n\n return registerComponent(name, newComponent, ...newHocs, ...previousHocs);\n}\n*/\n\n/*\nexport const copyHoCs = (sourceComponent, targetComponent) => {\n return compose(...sourceComponent.hocs)(targetComponent);\n};\n*/\n\n/**\n * Returns an instance of the given component name of function\n * @param {string|function} component A component, the name of a component, or a react element\n * @param {Object} [props] Optional properties to pass to the component\n */\n//eslint-disable-next-line react/display-name\n// legacy\nexport const instantiateComponent = (\n component?: React.ComponentType | Function | any,\n props?: any\n) => {\n if (!component) {\n return null;\n } /*else if (typeof component === \"string\") {\n const Component = Components[component];\n return <Component {...props} />;\n } */ else if (React.isValidElement(component)) {\n return React.cloneElement(component, props);\n } else if (\n typeof component === \"function\" &&\n component.prototype &&\n component.prototype.isReactComponent\n ) {\n const Component = component as React.ComponentType<any>;\n return <Component {...props} />;\n } else if (typeof component === \"function\") {\n return component(props);\n } else if (\n typeof component === \"object\" &&\n component.$$typeof &&\n component.render\n ) {\n const Component = component as React.ComponentType<any>;\n return <Component {...props} />;\n } else {\n return component;\n }\n};\n\n/**\n * Creates a component that will render the registered component with the given name.\n *\n * This function may be useful when in need for some registered component, but in contexts\n * where they have not yet been initialized, for example at compile time execution. In other\n * words, when using `Components.ComponentName` is not allowed (because it has not yet been\n * populated, hence would be `undefined`), then `delayedComponent('ComponentName')` can be\n * used instead.\n *\n * @example Create a container for a registered component\n * // SomeContainer.js\n * import compose from 'recompose/compose';\n * import { delayedComponent } from 'meteor/vulcan:core';\n *\n * export default compose(\n * // ...some hocs with container logic\n * )(delayedComponent('ComponentName')); // cannot use Components.ComponentName in this context!\n *\n * @example {@link dynamicLoader}\n * @param {String} name Component name\n * @return {Function}\n * Functional component that will render the given registered component\n */\nexport const delayedComponent = (name) => {\n return (props) => {\n const Component = Components[name] || null;\n return Component && <Component {...props} />;\n };\n};\n\n// Example with Proxy (might be unstable/hard to reason about)\n//const mergeWithComponents = (myComponents = {}) => {\n// const handler = {\n// get: function(target, name) {\n// return name in target ? target[name] : Components[name];\n// }\n// };\n// const proxy = new Proxy(myComponents, handler);\n// return proxy;\n//};\nexport const mergeWithComponents = (myComponents) =>\n myComponents ? { ...Components, ...myComponents } : Components;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AA4BkB,Q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M,cAAc,OAAO;AAC3B,MAAI,CAAC,oBAAoB,WAAW;AAAG,WAAO;AAC9C,QAAM,eAAe,eAAe,cAAc,WAAW;AAC7D,SAAO;GAJqB;AAWvB,IAAM,6BAA6B,wBAAC,WAAW,WAAW;AAC/D,QAAM,kBAAkB,qBAAqB,WAAW,MAAM;AAC9D,MAAI,CAAC,iBAAiB;AAEpB,UAAM,mBAAmB,sBAAsB,WAAW,MAAM;AAEhE,QAAI,CAAC;AAAkB,aAAO;AAC9B,WAAO;;AAET,SAAO;GATiC;AAYnC,IAAM,mBAAmB;EAC9B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGK,IAAM,iBAAiB;EAC5B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;;AG3OF;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA0BO,IAAM,WAAW,wBACtB,OACA,YACA,SACA,WACA,gBACG;AACH,QAAM,iBAAiB,MAAM,KAAK,YAAW;AAC7C,QAAM,QAAQ,YAAY;IACxB,MAAM;IACN;IACA;IACA,QAAQ;GACT;AACD,MAAI,aAAa;AACf,UAAM,kBAAkB,QAAQ,cAAc;MAC5C,IAAI,WAAW;MACf,gBAAgB;KACjB;AACD,WAAO,GAAG,UAAU;SACf;AACL,WAAO;;GArBa;AA+BxB,IAAM,iBAAiB,wBACrB,OACA,YACA,SACA,cACG;AACH,QAAM,iBAAiB,MAAM,KAAK,YAAW;A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AAmB,wBAAC,SAAS;AACxC,SAAO,CAAC,UAAU;AAChB,UAAM,YAAY,WAAW,SAAS;AACtC,WAAO,aAAa,wBAAA,cAAC,WAAS,UAAA,CAAA,GAAK,KAAK,CAAA;;GAHZ;AAiBzB,IAAM,sBAAsB,wBAAC,iBAClC,eAAe,kCAAK,aAAe,gBAAiB,YADnB;","names":[]}
1
+ {"version":3,"sources":["../../../node_modules/tslib/tslib.js","../components/core/LoadingButton.tsx","../components/VulcanComponents/Consumer.tsx","../components/VulcanComponents/Context.ts","../components/VulcanComponents/Dummy.tsx","../components/core/MutationButton.tsx","../../../node_modules/tslib/modules/index.js","../../../node_modules/graphql-tag/lib/index.js","../components/form/core/FormContext.tsx","../components/form/core/Form/Form.tsx","../components/form/utils/schema_utils.ts","../components/form/utils/utils.ts","../components/form/utils/path_utils.ts","../components/form/core/Form/fields.ts","../components/form/core/Form/utils.ts","../components/form/hooks/useBlockTransition/useBlockTransition.ts","../components/form/hooks/useBlockTransition/block.ts","../components/form/hooks/useWarnOnUnsaved/useWarnOnUnsaved.ts","../components/form/core/Form/hooks.ts","../components/form/core/FormContainer.tsx","../components/form/utils/formFragments.ts","../components/VulcanCurrentUser/Consumer.tsx","../components/VulcanCurrentUser/Context.ts","../components/VulcanCurrentUser/Provider.tsx","../components/form/utils/ui_utils.ts","../components/VulcanComponents/Provider.tsx","../components/VulcanComponents/defaultVulcanComponents/index.ts","../componentsHelpers.tsx"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global global, define, System, Reflect, Promise */\r\nvar __extends;\r\nvar __assign;\r\nvar __rest;\r\nvar __decorate;\r\nvar __param;\r\nvar __metadata;\r\nvar __awaiter;\r\nvar __generator;\r\nvar __exportStar;\r\nvar __values;\r\nvar __read;\r\nvar __spread;\r\nvar __spreadArrays;\r\nvar __spreadArray;\r\nvar __await;\r\nvar __asyncGenerator;\r\nvar __asyncDelegator;\r\nvar __asyncValues;\r\nvar __makeTemplateObject;\r\nvar __importStar;\r\nvar __importDefault;\r\nvar __classPrivateFieldGet;\r\nvar __classPrivateFieldSet;\r\nvar __classPrivateFieldIn;\r\nvar __createBinding;\r\n(function (factory) {\r\n var root = typeof global === \"object\" ? global : typeof self === \"object\" ? self : typeof this === \"object\" ? this : {};\r\n if (typeof define === \"function\" && define.amd) {\r\n define(\"tslib\", [\"exports\"], function (exports) { factory(createExporter(root, createExporter(exports))); });\r\n }\r\n else if (typeof module === \"object\" && typeof module.exports === \"object\") {\r\n factory(createExporter(root, createExporter(module.exports)));\r\n }\r\n else {\r\n factory(createExporter(root));\r\n }\r\n function createExporter(exports, previous) {\r\n if (exports !== root) {\r\n if (typeof Object.create === \"function\") {\r\n Object.defineProperty(exports, \"__esModule\", { value: true });\r\n }\r\n else {\r\n exports.__esModule = true;\r\n }\r\n }\r\n return function (id, v) { return exports[id] = previous ? previous(id, v) : v; };\r\n }\r\n})\r\n(function (exporter) {\r\n var extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n\r\n __extends = function (d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n\r\n __assign = Object.assign || function (t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n\r\n __rest = function (s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n };\r\n\r\n __decorate = function (decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n };\r\n\r\n __param = function (paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n };\r\n\r\n __metadata = function (metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n };\r\n\r\n __awaiter = function (thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n };\r\n\r\n __generator = function (thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n };\r\n\r\n __exportStar = function(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n };\r\n\r\n __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n }) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n });\r\n\r\n __values = function (o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n };\r\n\r\n __read = function (o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n };\r\n\r\n /** @deprecated */\r\n __spread = function () {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n };\r\n\r\n /** @deprecated */\r\n __spreadArrays = function () {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n };\r\n\r\n __spreadArray = function (to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n };\r\n\r\n __await = function (v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n };\r\n\r\n __asyncGenerator = function (thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n };\r\n\r\n __asyncDelegator = function (o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n };\r\n\r\n __asyncValues = function (o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n };\r\n\r\n __makeTemplateObject = function (cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n };\r\n\r\n var __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n }) : function(o, v) {\r\n o[\"default\"] = v;\r\n };\r\n\r\n __importStar = function (mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n };\r\n\r\n __importDefault = function (mod) {\r\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\r\n };\r\n\r\n __classPrivateFieldGet = function (receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n };\r\n\r\n __classPrivateFieldSet = function (receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n };\r\n\r\n __classPrivateFieldIn = function (state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n };\r\n\r\n exporter(\"__extends\", __extends);\r\n exporter(\"__assign\", __assign);\r\n exporter(\"__rest\", __rest);\r\n exporter(\"__decorate\", __decorate);\r\n exporter(\"__param\", __param);\r\n exporter(\"__metadata\", __metadata);\r\n exporter(\"__awaiter\", __awaiter);\r\n exporter(\"__generator\", __generator);\r\n exporter(\"__exportStar\", __exportStar);\r\n exporter(\"__createBinding\", __createBinding);\r\n exporter(\"__values\", __values);\r\n exporter(\"__read\", __read);\r\n exporter(\"__spread\", __spread);\r\n exporter(\"__spreadArrays\", __spreadArrays);\r\n exporter(\"__spreadArray\", __spreadArray);\r\n exporter(\"__await\", __await);\r\n exporter(\"__asyncGenerator\", __asyncGenerator);\r\n exporter(\"__asyncDelegator\", __asyncDelegator);\r\n exporter(\"__asyncValues\", __asyncValues);\r\n exporter(\"__makeTemplateObject\", __makeTemplateObject);\r\n exporter(\"__importStar\", __importStar);\r\n exporter(\"__importDefault\", __importDefault);\r\n exporter(\"__classPrivateFieldGet\", __classPrivateFieldGet);\r\n exporter(\"__classPrivateFieldSet\", __classPrivateFieldSet);\r\n exporter(\"__classPrivateFieldIn\", __classPrivateFieldIn);\r\n});\r\n","import React, { CSSProperties } from \"react\";\nimport { useVulcanComponents } from \"../VulcanComponents/Consumer\";\nimport type { ButtonProps } from \"./typings\";\nexport interface LoadingButtonProps extends ButtonProps {\n loading?: boolean;\n label?: string | React.ReactNode;\n onClick?: any;\n children?: React.ReactNode;\n className?: string;\n}\nexport const LoadingButton = ({\n loading,\n label,\n onClick,\n children,\n className = \"\",\n ...rest\n}: LoadingButtonProps & any) => {\n const Components = useVulcanComponents();\n\n const wrapperStyle: CSSProperties = {\n position: \"relative\",\n };\n\n const labelStyle = loading ? { opacity: 0.5 } : {};\n\n const loadingStyle: CSSProperties = loading\n ? {\n position: \"absolute\",\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n }\n : { display: \"none\" };\n\n return (\n <Components.Button\n className={`loading-button ${loading ? \"loading-button-loading\" : \"loading-button-notloading\"\n } ${className}`}\n onClick={onClick}\n {...rest}\n >\n <span style={wrapperStyle} className=\"loading-button-inner\">\n <span style={labelStyle} className=\"loading-button-label\">{label || children}</span>\n <span style={loadingStyle} className=\"loading-button-loader\">\n <Components.Loading />\n </span>\n </span>\n </Components.Button>\n );\n};\n","import { deprecate } from \"@vulcanjs/utils\";\nimport React, { useContext, useEffect } from \"react\";\nimport { VulcanComponentsContext } from \"./Context\";\n\nexport const VulcanComponentsConsumer = VulcanComponentsContext.Consumer;\n\nexport const useVulcanComponents = () => {\n const val = useContext(VulcanComponentsContext);\n return val;\n};\n\nexport const withVulcanComponents = (C) => (props) => {\n const vulcanComponents = useVulcanComponents();\n deprecate(\n \"0.0.0\",\n \"Using withVulcanComponents HOC => prefer useVulcanComponents with hooks\"\n );\n return <C vulcanComponents={vulcanComponents} {...props} />;\n};\n","import React from \"react\";\nimport type { PossibleVulcanComponents } from \"./typings\";\nimport { Dummy } from \"./Dummy\";\n\nconst dummyHandler = {\n get(target, property) {\n if (property in target) {\n return target[property];\n }\n console.log(\n `Property ${property} not in possible Vulcan components, returning Dummy`\n );\n return Dummy;\n },\n};\n// We need this to shut TypeScript up\n// You should use the Provider to get the right default values\nexport const VulcanComponentsContext =\n React.createContext<PossibleVulcanComponents>(\n // @ts-ignore\n new Proxy(\n {\n __not_initialized: true,\n },\n dummyHandler\n )\n );\n\n// Needed to guarantee that the exports stays named\nVulcanComponentsContext.displayName = \"VulcanComponentsContext\";\n","import React from \"react\";\nexport interface DummyProps { }\n\nexport const Dummy = () => (\n <span>\n You have not setup VulcanComponentsProvider. Please add following code in\n your app:{\" \"}\n <code>{`import { VulcanComponentsProvider } from \"@vulcanjs/react-ui\"; const YourApp = <VulcanComponentsProvider>{/* your app */}</VulcanComponentsProvider>;}`}</code>\n </span>\n);\n","/*\n\nExample Usage\n\n<Components.MutationButton\n label=\"Cancel Subscription\"\n variant=\"primary\"\n mutationOptions={{\n name: 'cancelSubscription',\n args: { bookingId: 'String' },\n fragmentName: 'BookingsStripeDataFragment',\n }}\n mutationArguments={{ bookingId: booking._id }}\n submitCallback={() => {}}\n successCallback={result => { console.log(result) }}\n/>\n\n*/\nimport React, { useState } from \"react\";\nimport { DocumentNode } from \"graphql\";\nimport { MutationHookOptions, useMutation } from \"@apollo/client\";\nimport gql from \"graphql-tag\";\nimport { useVulcanComponents } from \"../VulcanComponents/Consumer\";\nimport { LoadingButtonProps } from \"./LoadingButton\";\n// import withMutation from '../containers/registeredMutation';\n\n// TODO:\n/**\n * Difference with Vulcan Meteor: there is no\n * registered mutation anymore,\n * so you need to pass your mutations explicitely, using graphql\n */\n/*\nexport class MutationButton extends PureComponent {\n constructor(props) {\n super(props);\n this.button = withMutation(props.mutationOptions)(MutationButtonInner);\n }\n\n render() {\n const Component = this.button;\n return <Component {...this.props} />;\n }\n}*/\n\nexport interface MutationButtonProps {\n /**\n * NOTE: in Vulcan Meteor you had to write:\n * mutationOptions: { name: \"foobar\", mutationOptions: {refetchQueries:[\"hello\"]}}\n *\n * In Vulcan Next, you can only pass the \"mutationOptions\" object:\n * mutationOptions: { refetchQueries:[\"hello\"]}\n * and the mutation is provided via the new \"mutation\" prop\n */\n mutationOptions?: MutationHookOptions;\n /**\n * @example\n mutation: gql`\n mutation sampleMutation($input: Input) {\n hello\n }\n `,\n */\n mutation: string | DocumentNode;\n /** Variables passed to the mutation (NOTE: we can't pass other options at the moment) */\n mutationArguments?: MutationHookOptions<any>[\"variables\"];\n /** Callback run before submitting. Can optionnaly return mutationArguments that will override current ones. */\n submitCallback?: (\n mutationArgumentsFromProps: MutationHookOptions<any>[\"variables\"]\n ) =>\n | void\n | { mutationArguments: MutationHookOptions<any>[\"variables\"] }\n | Promise<void | {\n mutationArguments: MutationHookOptions<any>[\"variables\"];\n }>;\n successCallback?: (res: any) => void | Promise<void>;\n errorCallback?: (err: any) => void | Promise<void>;\n /** Now isolated into their own object to avoid needed to explicitely pick/omit */\n loadingButtonProps?: LoadingButtonProps;\n /** Shortcut for loadingButtonProps.label */\n label?: string | React.ReactNode;\n}\nexport const MutationButton = (props: MutationButtonProps) => {\n const Components = useVulcanComponents();\n const [loading, setLoading] = useState<boolean>(false);\n const [error, setError] = useState<any | undefined>();\n\n const {\n //mutationOptions,\n mutation,\n loadingButtonProps = {},\n label,\n } = props;\n let { mutationArguments } = props;\n const mutationAsNode =\n typeof mutation === \"string\"\n ? gql`\n ${mutation}\n `\n : mutation;\n const [mutationFunc] = useMutation(mutationAsNode);\n\n const handleClick = async (e) => {\n e.preventDefault();\n setLoading(true);\n setError(undefined);\n const {\n //mutationOptions,\n submitCallback,\n successCallback,\n errorCallback,\n } = props;\n //const mutationName = mutationOptions.name;\n //const mutation = this.props[mutationName];\n\n try {\n if (submitCallback) {\n const callbackReturn = await submitCallback(mutationArguments);\n if (callbackReturn && callbackReturn.mutationArguments) {\n mutationArguments = callbackReturn.mutationArguments;\n }\n }\n const result = await mutationFunc({ variables: mutationArguments });\n if (successCallback) {\n await successCallback(result);\n }\n } catch (error) {\n // TODO: may not work because the mutationFunc may not throw in case of error\n setError(error);\n if (errorCallback) {\n await errorCallback(error);\n }\n } finally {\n setLoading(false);\n }\n\n // mutation(mutationArguments)\n // .then(result => {\n // this.setState({ loading: false });\n // if (successCallback) {\n // successCallback(result);\n // }\n // })\n // .catch(error => {\n // this.setState({ loading: false });\n // if (errorCallback) {\n // errorCallback(error);\n // }\n // });\n };\n\n //const mutationName = this.props.mutationOptions.name;\n\n const loadingButton = (\n <Components.LoadingButton\n loading={loading}\n onClick={handleClick}\n label={label}\n {...loadingButtonProps}\n />\n );\n\n if (error) {\n return (\n <Components.TooltipTrigger trigger={loadingButton} defaultShow={true}>\n {error.message.replace(\"GraphQL error: \", \"\")}\n </Components.TooltipTrigger>\n );\n }\n return loadingButton;\n};\n","import tslib from '../tslib.js';\r\nconst {\r\n __extends,\r\n __assign,\r\n __rest,\r\n __decorate,\r\n __param,\r\n __metadata,\r\n __awaiter,\r\n __generator,\r\n __exportStar,\r\n __createBinding,\r\n __values,\r\n __read,\r\n __spread,\r\n __spreadArrays,\r\n __spreadArray,\r\n __await,\r\n __asyncGenerator,\r\n __asyncDelegator,\r\n __asyncValues,\r\n __makeTemplateObject,\r\n __importStar,\r\n __importDefault,\r\n __classPrivateFieldGet,\r\n __classPrivateFieldSet,\r\n __classPrivateFieldIn,\r\n} = tslib;\r\nexport {\r\n __extends,\r\n __assign,\r\n __rest,\r\n __decorate,\r\n __param,\r\n __metadata,\r\n __awaiter,\r\n __generator,\r\n __exportStar,\r\n __createBinding,\r\n __values,\r\n __read,\r\n __spread,\r\n __spreadArrays,\r\n __spreadArray,\r\n __await,\r\n __asyncGenerator,\r\n __asyncDelegator,\r\n __asyncValues,\r\n __makeTemplateObject,\r\n __importStar,\r\n __importDefault,\r\n __classPrivateFieldGet,\r\n __classPrivateFieldSet,\r\n __classPrivateFieldIn,\r\n};\r\n","import { __assign } from \"tslib\";\nimport { parse } from 'graphql';\nvar docCache = new Map();\nvar fragmentSourceMap = new Map();\nvar printFragmentWarnings = true;\nvar experimentalFragmentVariables = false;\nfunction normalize(string) {\n return string.replace(/[\\s,]+/g, ' ').trim();\n}\nfunction cacheKeyFromLoc(loc) {\n return normalize(loc.source.body.substring(loc.start, loc.end));\n}\nfunction processFragments(ast) {\n var seenKeys = new Set();\n var definitions = [];\n ast.definitions.forEach(function (fragmentDefinition) {\n if (fragmentDefinition.kind === 'FragmentDefinition') {\n var fragmentName = fragmentDefinition.name.value;\n var sourceKey = cacheKeyFromLoc(fragmentDefinition.loc);\n var sourceKeySet = fragmentSourceMap.get(fragmentName);\n if (sourceKeySet && !sourceKeySet.has(sourceKey)) {\n if (printFragmentWarnings) {\n console.warn(\"Warning: fragment with name \" + fragmentName + \" already exists.\\n\"\n + \"graphql-tag enforces all fragment names across your application to be unique; read more about\\n\"\n + \"this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names\");\n }\n }\n else if (!sourceKeySet) {\n fragmentSourceMap.set(fragmentName, sourceKeySet = new Set);\n }\n sourceKeySet.add(sourceKey);\n if (!seenKeys.has(sourceKey)) {\n seenKeys.add(sourceKey);\n definitions.push(fragmentDefinition);\n }\n }\n else {\n definitions.push(fragmentDefinition);\n }\n });\n return __assign(__assign({}, ast), { definitions: definitions });\n}\nfunction stripLoc(doc) {\n var workSet = new Set(doc.definitions);\n workSet.forEach(function (node) {\n if (node.loc)\n delete node.loc;\n Object.keys(node).forEach(function (key) {\n var value = node[key];\n if (value && typeof value === 'object') {\n workSet.add(value);\n }\n });\n });\n var loc = doc.loc;\n if (loc) {\n delete loc.startToken;\n delete loc.endToken;\n }\n return doc;\n}\nfunction parseDocument(source) {\n var cacheKey = normalize(source);\n if (!docCache.has(cacheKey)) {\n var parsed = parse(source, {\n experimentalFragmentVariables: experimentalFragmentVariables,\n allowLegacyFragmentVariables: experimentalFragmentVariables\n });\n if (!parsed || parsed.kind !== 'Document') {\n throw new Error('Not a valid GraphQL document.');\n }\n docCache.set(cacheKey, stripLoc(processFragments(parsed)));\n }\n return docCache.get(cacheKey);\n}\nexport function gql(literals) {\n var args = [];\n for (var _i = 1; _i < arguments.length; _i++) {\n args[_i - 1] = arguments[_i];\n }\n if (typeof literals === 'string') {\n literals = [literals];\n }\n var result = literals[0];\n args.forEach(function (arg, i) {\n if (arg && arg.kind === 'Document') {\n result += arg.loc.source.body;\n }\n else {\n result += arg;\n }\n result += literals[i + 1];\n });\n return parseDocument(result);\n}\nexport function resetCaches() {\n docCache.clear();\n fragmentSourceMap.clear();\n}\nexport function disableFragmentWarnings() {\n printFragmentWarnings = false;\n}\nexport function enableExperimentalFragmentVariables() {\n experimentalFragmentVariables = true;\n}\nexport function disableExperimentalFragmentVariables() {\n experimentalFragmentVariables = false;\n}\nvar extras = {\n gql: gql,\n resetCaches: resetCaches,\n disableFragmentWarnings: disableFragmentWarnings,\n enableExperimentalFragmentVariables: enableExperimentalFragmentVariables,\n disableExperimentalFragmentVariables: disableExperimentalFragmentVariables\n};\n(function (gql_1) {\n gql_1.gql = extras.gql, gql_1.resetCaches = extras.resetCaches, gql_1.disableFragmentWarnings = extras.disableFragmentWarnings, gql_1.enableExperimentalFragmentVariables = extras.enableExperimentalFragmentVariables, gql_1.disableExperimentalFragmentVariables = extras.disableExperimentalFragmentVariables;\n})(gql || (gql = {}));\ngql[\"default\"] = gql;\nexport default gql;\n//# sourceMappingURL=index.js.map","import React, { useContext } from \"react\";\nimport { AddSubmitCallbacks } from \"./Form/hooks\";\n\ninterface FormContextValue extends AddSubmitCallbacks {\n clearForm: Function;\n clearFieldErrors: Function;\n currentValues: object;\n deletedValues: Array<any>;\n errors: Array<any>;\n getDocument: Function;\n getLabel: (fieldName: string, fieldLocale?: string) => string;\n initialDocument: object;\n isChanged: boolean;\n refetchForm: Function;\n // TODO: we deprecate this, it doesn't make sense to allow a child to setState this way\n // setFormState: Function;\n // FIXME: this type doesn't work, it doesn't necessarily have the event + it has to be defined\n submitForm: (evt?: any) => Promise<void>; //React.HTMLAttributes<HTMLFormElement>[\"onSubmit\"];\n throwError: Function;\n updateCurrentValues: Function;\n disabled: boolean;\n addToDeletedValues: Function;\n}\n\nexport const FormContext = React.createContext<FormContextValue | undefined>(\n undefined\n);\n\nexport const useFormContext = () => {\n const formContext = useContext(FormContext);\n if (!formContext)\n throw new Error(\n `A component is trying to access form context but it is undefined. Please wrap your component with a <Form>.\n You may be importing \"FormContext\" from different packages or have accidentaly made a copy of it?\n FormContext is exposed by \"@vulcanjs/react-ui\".`\n );\n return formContext;\n};\n","/*\n\nMain form component.\n\nThis component expects:\n\n### All Forms:\n\n- collection\n- currentUser\n- client (Apollo client)\n\n*/\n\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { runCallbacks, getErrors } from \"@vulcanjs/core\";\nimport { useIntlContext } from \"@vulcanjs/react-i18n\";\nimport { removeProperty } from \"@vulcanjs/utils\";\nimport _filter from \"lodash/filter.js\";\nimport cloneDeep from \"lodash/cloneDeep.js\";\nimport compact from \"lodash/compact.js\";\nimport get from \"lodash/get.js\";\nimport isObject from \"lodash/isObject.js\";\nimport mapValues from \"lodash/mapValues.js\";\nimport merge from \"lodash/merge.js\";\nimport omit from \"lodash/omit.js\";\nimport omitBy from \"lodash/omitBy.js\";\nimport pick from \"lodash/pick.js\";\nimport pickBy from \"lodash/pickBy.js\";\nimport set from \"lodash/set.js\";\nimport unset from \"lodash/unset.js\";\nimport update from \"lodash/update.js\";\nimport without from \"lodash/without.js\";\nimport isEmpty from \"lodash/isEmpty.js\";\n//import type { FormLayoutProps } from \"../../elements/FormLayout\";\n//import type { FormSubmitProps } from \"../../elements/FormSubmit\";\n\nimport {\n convertSchema,\n getEditableFields,\n getInsertableFields,\n} from \"../../utils/schema_utils\";\nimport { isEmptyValue } from \"../../utils/utils\";\nimport { getParentPath } from \"../../utils/path_utils\";\n// import withCollectionProps from \"./withCollectionProps\";\nimport { FormContext } from \"../FormContext\";\nimport { getFieldGroups, getFieldNames, getLabel } from \"./fields\";\nimport { isNotSameDocument } from \"./utils\";\nimport { useWarnOnUnsaved } from \"../../hooks/useWarnOnUnsaved\";\n\nimport type { FormType } from \"../../typings\";\nimport {\n CreateDocumentResult,\n FormProps,\n FormState,\n UpdateDocumentResult,\n} from \"./typings\";\nimport { MutationResult } from \"@apollo/client\";\nimport { useVulcanComponents } from \"../../../VulcanComponents/Consumer\";\nimport { useSubmitCallbacks } from \"./hooks\";\n\nconst NEW_FORM_TYPE = \"new\";\nconst EDIT_FORM_TYPE = \"edit\";\n\n// props that should trigger a form reset\nconst RESET_PROPS = [\n \"model\",\n // \"collection\",\n // \"collectionName\",\n \"document\",\n \"schema\",\n \"currentUser\",\n \"fields\",\n \"removeFields\",\n \"prefilledProps\", // TODO: prefilledProps should be merged instead?\n];\n\nconst compactParent = (object, path) => {\n const parentPath = getParentPath(path);\n\n // note: we only want to compact arrays, not objects\n const compactIfArray = (x) => (Array.isArray(x) ? compact(x) : x);\n\n update(object, parentPath, compactIfArray);\n};\n\nconst getDefaultValues = (convertedSchema) => {\n // TODO: make this work with nested schemas, too\n return pickBy(\n mapValues(convertedSchema, (field) => field.defaultValue),\n (value) => value\n );\n};\n\nconst compactObject = (o) => omitBy(o, (f) => f === null || f === undefined);\n\nconst getInitialStateFromProps = (nextProps: FormProps): FormState => {\n const schema = nextProps.schema || nextProps.model.schema;\n const convertedSchema = convertSchema(schema);\n const formType: FormType = nextProps.document\n ? EDIT_FORM_TYPE\n : NEW_FORM_TYPE;\n // for new document forms, add default values to initial document\n const defaultValues =\n formType === NEW_FORM_TYPE ? getDefaultValues(convertedSchema) : {};\n // note: we remove null/undefined values from the loaded document so they don't overwrite possible prefilledProps\n const initialDocument = merge(\n {},\n defaultValues,\n nextProps.prefilledProps,\n compactObject(nextProps.document)\n );\n\n //if minCount is specified, go ahead and create empty nested documents\n Object.keys(convertedSchema).forEach((key) => {\n let minCount = convertedSchema[key].minCount;\n if (minCount) {\n initialDocument[key] = initialDocument[key] || [];\n while (initialDocument[key].length < minCount)\n initialDocument[key].push({});\n }\n });\n\n // remove all instances of the `__typename` property from document\n removeProperty(initialDocument, \"__typename\");\n\n return {\n disabled: nextProps.disabled,\n errors: [],\n deletedValues: [],\n currentValues: {},\n originalSchema: convertSchema(schema, { removeArrays: false }),\n // convert SimpleSchema schema into JSON object\n schema: convertedSchema,\n // Also store all field schemas (including nested schemas) in a flat structure\n flatSchema: convertSchema(schema, { flatten: true }),\n // the initial document passed as props\n initialDocument,\n // initialize the current document to be the same as the initial document\n currentDocument: initialDocument,\n };\n};\n\nconst getChildrenProps = (\n props: FormProps,\n state: Pick<FormState, \"disabled\" | \"currentDocument\">,\n options: { formType: FormType },\n // TODO: that belongs to the context instead\n callbacks: { deleteDocument: Function }\n): {\n formLayoutProps: any; //FormLayoutProps;\n formGroupProps: Function;\n commonProps: any;\n formSubmitProps: any; // FormSubmitProps;\n} => {\n const {\n currentUser,\n repeatErrors,\n submitLabel,\n cancelLabel,\n revertLabel,\n cancelCallback,\n revertCallback,\n id,\n model,\n prefilledProps,\n itemProperties,\n contextName,\n showRemove,\n showDelete,\n } = props;\n const { disabled, currentDocument } = state;\n const { formType } = options;\n const { deleteDocument } = callbacks;\n const commonProps = {\n document: currentDocument,\n formType,\n currentUser,\n disabled,\n prefilledProps,\n itemProperties,\n contextName,\n };\n\n const docClassName = `document-${formType}`;\n const modelName = model.name.toLowerCase();\n const formProps = {\n className: `${docClassName} ${docClassName}-${modelName}`,\n id: id,\n // It's the form element responsibility to get submitForm from context\n // onSubmit: this.submitForm(formType),\n // TODO: update to useRef\n //ref: (e) => {\n // this.form = e;\n //},\n };\n\n const formGroupProps = (group) => ({\n key: group.name,\n ...group,\n group: omit(group, [\"fields\"]),\n ...commonProps,\n });\n\n const formSubmitProps = {\n model,\n currentUser,\n submitLabel,\n cancelLabel,\n revertLabel,\n cancelCallback,\n revertCallback,\n document: currentDocument,\n // TODO: should probably be passed through context\n deleteDocument:\n (formType === EDIT_FORM_TYPE &&\n showRemove &&\n showDelete &&\n deleteDocument) ||\n null,\n };\n\n const formLayoutProps = {\n formProps: formProps,\n repeatErrors: repeatErrors,\n submitProps: formSubmitProps,\n commonProps,\n };\n return {\n commonProps,\n formSubmitProps,\n formGroupProps,\n formLayoutProps,\n };\n};\n\n// component form until we go stateless\nconst FormWarnUnsaved = ({\n isChanged,\n warnUnsavedChanges,\n children,\n}: {\n isChanged: boolean;\n warnUnsavedChanges?: boolean;\n children: React.ReactNode;\n}) => {\n useWarnOnUnsaved({\n isChanged,\n warnUnsavedChanges,\n });\n return <>{children}</>;\n};\n\n/*\n\n Like getDocument, but cross-reference with getFieldNames()\n to only return fields that actually need to be submitted\n\n Also remove any deleted values.\n\n */\nconst getData = (\n customArgs,\n props: FormProps,\n state: Pick<FormState, \"currentDocument\" | \"deletedValues\">,\n // previously from \"this\" object\n { submitFormCallbacks, form }: any\n) => {\n const { currentDocument } = state;\n const { model, prefilledProps } = props;\n // we want to keep prefilled data even for hidden/removed fields\n let data = prefilledProps || {};\n\n // omit prefilled props for nested fields\n data = omitBy(data, (value, key) => key.endsWith(\".$\"));\n\n const args = {\n schema: model.schema,\n excludeRemovedFields: false,\n excludeHiddenFields: false,\n replaceIntlFields: true,\n addExtraFields: false,\n ...customArgs,\n };\n\n // only keep relevant fields\n // for intl fields, make sure we look in foo_intl and not foo\n const fields = getFieldNames(props, currentDocument, args);\n data = { ...data, ...pick(currentDocument, ...fields) };\n\n // compact deleted values\n state.deletedValues.forEach((path) => {\n if (path.includes(\".\")) {\n /*\n\n If deleted field is a nested field, nested array, or nested array item, try to compact its parent array\n\n - Nested field: 'address.city'\n - Nested array: 'addresses.1'\n - Nested array item: 'addresses.1.city'\n\n */\n compactParent(data, path);\n }\n });\n\n // run data object through submitForm callbacks\n data = runCallbacks({\n callbacks: submitFormCallbacks,\n iterator: data,\n args: [\n {\n /*form: this*/\n },\n ],\n });\n\n return data;\n};\n\nexport const Form = (props: FormProps) => {\n const { initCallback, createDocument, updateDocument, deleteDocument } =\n props;\n const initialState = getInitialStateFromProps(props);\n const { schema, originalSchema, flatSchema, initialDocument } = initialState;\n const isFirstRender = useRef(true);\n useEffect(() => {\n if (isFirstRender.current) {\n isFirstRender.current = false; // toggle flag after first render/mounting\n return;\n }\n if (initCallback) initCallback(initialState.currentDocument);\n }, [initCallback]);\n const defaultProps = {\n layout: \"horizontal\",\n prefilledProps: {},\n repeatErrors: false,\n showRemove: true,\n showDelete: true,\n };\n const allProps = { ...defaultProps, ...props };\n const defaultValues = {};\n const intl = useIntlContext();\n\n const { callbacks, addToFailureForm, addToSubmitForm, addToSuccessForm } =\n useSubmitCallbacks();\n\n const { submitFormCallbacks, successFormCallbacks, failureFormCallbacks } =\n callbacks;\n\n // --------------------------------------------------------------------- //\n // ------------------------------- Errors ------------------------------ //\n // --------------------------------------------------------------------- //\n\n /*\n\n Add error to form state\n\n Errors can have the following properties:\n - id: used as an internationalization key, for example `errors.required`\n - path: for field-specific errors, the path of the field with the issue\n - properties: additional data. Will be passed to vulcan-i18n as values\n - message: if id cannot be used as i81n key, message will be used\n\n */\n const [errors, setErrors] = useState<Array<any>>([]);\n const throwError = (error) => {\n let formErrors = getErrors(error);\n\n // eslint-disable-next-line no-console\n console.log(formErrors);\n\n // add error(s) to state\n setErrors((prevErrors) => [...prevErrors, ...formErrors]);\n };\n\n /*\n\n Clear errors for a field\n\n */\n const clearFieldErrors = (path) => {\n setErrors((prevErrors) =>\n prevErrors.filter((error) => error.path !== path)\n );\n };\n\n // --------------------------------------------------------------------- //\n // ------------------------------- Context ----------------------------- //\n // --------------------------------------------------------------------- //\n\n const [deletedValues, setDeletedValues] = useState<Array<any>>([]);\n\n // add something to deleted values\n const addToDeletedValues = (name) => {\n setDeletedValues((prevDeletedValues) => [...prevDeletedValues, name]);\n };\n\n /*\n setFormState = (fn) => {\n this.setState(fn);\n };\n */\n\n const [currentValues, setCurrentValues] = useState<Object>({});\n\n const submitFormContext = async (event /*newValues*/) => {\n /*\n TODO: previously this callback was updating the current values with new values after this call\n Need to check how this worked in Vulcan initially\n setCurrentValues((prevCurrentValues) => ({\n ...prevCurrentValues,\n ...newValues,\n }));\n */\n // TODO: previously, this was using a callback from setCurrentValues\n // this needs to be rearchitectured to work without, will need some check\n // https://stackoverflow.com/questions/56247433/how-to-use-setstate-callback-on-react-hooks\n await submitForm(event);\n };\n\n // --------------------------------------------------------------------- //\n // ------------------------------ Lifecycle ---------------------------- //\n // --------------------------------------------------------------------- //\n\n /*\n\n When props change, reinitialize the form state\n Triggered only for data related props (collection, document, currentUser etc.)\n\n @see https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html\n\n */\n /*\n UNSAFE_componentWillReceiveProps(nextProps) {\n const needReset = !!RESET_PROPS.find(\n (prop) => !isEqual(this.props[prop], nextProps[prop])\n );\n if (needReset) {\n const newState = getInitialStateFromProps(nextProps);\n this.setState(newState);\n if (nextProps.initCallback)\n nextProps.initCallback(newState.currentDocument);\n }\n }*/\n\n const [currentDocument, setCurrentDocument] = useState<{\n title?: string;\n _id?: string;\n name?: string;\n }>(initialDocument);\n\n /*\n\n Manually update the current values of one or more fields(i.e. on change or blur).\n\n */\n const updateCurrentValues = (newValues, options: { mode?: string } = {}) => {\n // default to overwriting old value with new\n const { mode = \"overwrite\" } = options;\n const { changeCallback } = props;\n\n // keep the previous ones and extend (with possible replacement) with new ones\n // keep only the relevant properties\n const newState = {\n currentValues: cloneDeep(currentValues),\n currentDocument: cloneDeep(currentDocument),\n deletedValues: cloneDeep(deletedValues),\n };\n\n Object.keys(newValues).forEach((key) => {\n const path = key;\n let value = newValues[key];\n\n if (isEmptyValue(value)) {\n // delete value\n unset(newState.currentValues, path);\n set(newState.currentDocument, path, null);\n newState.deletedValues = [...newState.deletedValues, path];\n } else {\n // 1. update currentValues\n set(newState.currentValues, path, value);\n\n // 2. update currentDocument\n // For arrays and objects, give option to merge instead of overwrite\n if (mode === \"merge\" && (Array.isArray(value) || isObject(value))) {\n const oldValue = get(newState.currentDocument, path);\n set(newState.currentDocument, path, merge(oldValue, value));\n } else {\n set(newState.currentDocument, path, value);\n }\n\n // 3. in case value had previously been deleted, \"undelete\" it\n newState.deletedValues = without(newState.deletedValues, path);\n }\n });\n if (changeCallback) changeCallback(newState.currentDocument);\n\n // TODO: prefer a reducer\n setCurrentValues(newState.currentValues);\n setCurrentDocument(newState.currentDocument);\n setDeletedValues(newState.deletedValues);\n };\n\n /*\n\n Refetch the document from the database (in case it was updated by another process or to reset the form)\n\n */\n const refetchForm = () => {\n if (props.refetch) {\n props.refetch();\n }\n };\n\n const [disabled, setDisabled] = useState<boolean>(!!props.disabled);\n const [success, setSuccess] = useState<boolean>(false); // TODO\n /**\n * Clears form errors and values.\n *\n * @example Clear form\n * // form will be fully emptied, with exception of prefilled values\n * clearForm({ document: {} });\n *\n * @example Reset/revert form\n * // form will be reverted to its initial state\n * clearForm();\n *\n * @example Clear with new values\n * // form will be cleared but initialized with the new document\n * const document = {\n * // ... some values\n * };\n * clearForm({ document });\n *\n * @param {Object=} options\n * @param {Object=} options.document\n * Document to use as new initial document when values are cleared instead of\n * the existing one. Note that prefilled props will be merged\n */\n const clearForm = (options: { document?: any } = {}) => {\n const { document: optionsDocument } = options;\n const document = optionsDocument\n ? merge({}, props.prefilledProps, optionsDocument)\n : null;\n // TODO: prefer a reducer\n setErrors([]);\n setCurrentValues({});\n setDeletedValues([]);\n setCurrentDocument(document || initialDocument);\n // setInitialDocument(document || initialDocument);\n setDisabled(false);\n };\n\n const newMutationSuccessCallback = function <TModel = Object>(\n result: CreateDocumentResult<TModel>\n ) {\n mutationSuccessCallback(result, NEW_FORM_TYPE);\n };\n\n const editMutationSuccessCallback = function <TModel = Object>(\n result: UpdateDocumentResult<TModel>\n ) {\n mutationSuccessCallback(result, EDIT_FORM_TYPE);\n };\n\n const formRef = useRef(null);\n const mutationSuccessCallback = function <TModel = Object>(\n // must be called only on valid results\n result: CreateDocumentResult<TModel>,\n mutationType: FormType\n ) {\n // TODO: use a reducer\n setDisabled(false);\n setSuccess(true);\n // for new mutation, run refetch function if it exists\n // TODO: the create mutation should already return the freshest value, do we really need that?\n // instead we might want to update currentResult with the result of the creation\n if (mutationType === NEW_FORM_TYPE) refetchForm();\n let { document } = result;\n\n // call the clear form method (i.e. trigger setState) only if the form has not been unmounted\n // (we are in an async callback, everything can happen!)\n // TODO: this should rely on a ref\n if (formRef.current) {\n clearForm({\n document: mutationType === EDIT_FORM_TYPE ? document : undefined,\n });\n }\n\n // run document through mutation success callbacks\n document = runCallbacks({\n callbacks: successFormCallbacks,\n iterator: document,\n args: [{ form: formRef.current }],\n });\n\n // run success callback if it exists\n if (props.successCallback) props.successCallback(document, { form: this });\n };\n\n // catch graphql errors\n const mutationErrorCallback = (document, error) => {\n setDisabled(false);\n\n // eslint-disable-next-line no-console\n console.error(\"// graphQL Error\");\n // eslint-disable-next-line no-console\n console.error(error);\n\n // run mutation failure callbacks on error, we do not allow the callbacks to change the error\n runCallbacks({\n callbacks: failureFormCallbacks,\n iterator: error,\n args: [{ error, form: formRef.current }],\n });\n\n if (!isEmpty(error)) {\n // add error to state\n throwError(error);\n }\n\n // run error callback if it exists\n if (props.errorCallback)\n props.errorCallback(document, error, { form: this });\n\n // scroll back up to show error messages\n // TODO: migrate this to scroll on top of the form\n //Utils.scrollIntoView(\".flash-message\");\n };\n\n const getSubmitData = () => {\n // complete the data with values from custom components\n // note: it follows the same logic as SmartForm's getDocument method\n let data = getData(\n { replaceIntlFields: true, addExtraFields: false, mutableFields },\n props,\n {\n currentDocument,\n deletedValues,\n },\n { form: formRef.current, submitFormCallbacks }\n );\n\n // if there's a submit callback, run it\n if (props.submitCallback) {\n data = props.submitCallback(data) || data;\n }\n return data;\n };\n /** \n\n Submit form handler\n\n On success/failure, will call the relevant callbacks\n\n */\n const submitFormCreate = async (event?: Event) => {\n event && event.preventDefault();\n event && event.stopPropagation();\n const { contextName } = props;\n // if form is disabled (there is already a submit handler running) don't do anything\n if (disabled) {\n return;\n }\n // clear errors and disable form while it's submitting\n setErrors([]);\n setDisabled(true);\n\n const data = getSubmitData();\n\n // create document form\n try {\n const result = await createDocument({\n input: {\n data,\n contextName,\n },\n });\n if (result.errors?.length) {\n // TODO: previously got from meta, we could have more than 1 error\n mutationErrorCallback(document, result.errors[0]);\n } else {\n newMutationSuccessCallback(result);\n }\n } catch (error) {\n mutationErrorCallback(document, error);\n }\n };\n /** \n\n Submit form handler\n\n On success/failure, will call the relevant callbacks\n\n */\n const submitFormUpdate = async (event?: Event) => {\n event && event.preventDefault();\n event && event.stopPropagation();\n\n const { contextName } = props;\n\n // if form is disabled (there is already a submit handler running) don't do anything\n if (disabled) {\n return;\n }\n\n // clear errors and disable form while it's submitting\n setErrors([]);\n setDisabled(true);\n\n // complete the data with values from custom components\n // note: it follows the same logic as SmartForm's getDocument method\n const data = getSubmitData();\n\n // update document form\n try {\n const documentId = currentDocument._id;\n const result = await updateDocument({\n input: {\n id: documentId,\n data,\n contextName,\n },\n });\n // TODO: handle more than 1 error\n if (result.errors?.length) {\n mutationErrorCallback(document, result.errors[0]);\n } else {\n editMutationSuccessCallback(result);\n }\n } catch (error) {\n mutationErrorCallback(document, error);\n }\n };\n\n /*\n\n Delete document handler\n\n */\n const deleteDocumentWithConfirm = () => {\n const document = currentDocument;\n const documentId = props.document._id;\n const documentTitle = document.title || document.name || \"\";\n\n const deleteDocumentConfirm = intl.formatMessage(\n { id: \"forms.delete_confirm\" },\n { title: documentTitle }\n );\n\n if (window.confirm(deleteDocumentConfirm)) {\n deleteDocument({ input: { id: documentId } })\n .then((mutationResult) => {\n // the mutation result looks like {data:{collectionRemove: null}} if succeeded\n if (props.removeSuccessCallback)\n props.removeSuccessCallback({ documentId, documentTitle });\n refetchForm();\n })\n .catch((error) => {\n // eslint-disable-next-line no-console\n console.log(error);\n });\n }\n };\n\n // --------------------------------------------------------------------- //\n // ------------------------- Props to Pass ----------------------------- //\n // --------------------------------------------------------------------- //\n\n // --------------------------------------------------------------------- //\n // ----------------------------- Render -------------------------------- //\n // --------------------------------------------------------------------- //\n\n const { successComponent, document, currentUser, model, warnUnsavedChanges } =\n props;\n const FormComponents = useVulcanComponents();\n\n const formType: FormType = document ? EDIT_FORM_TYPE : NEW_FORM_TYPE;\n\n /** \n\n Submit form handler\n\n On success/failure, will call the relevant callbacks\n\n */\n const submitForm =\n formType === NEW_FORM_TYPE ? submitFormCreate : submitFormUpdate;\n\n // Fields computation\n const mutableFields =\n formType === EDIT_FORM_TYPE\n ? getEditableFields(schema, currentUser, initialDocument)\n : getInsertableFields(schema, currentUser);\n\n const { formLayoutProps, formGroupProps } = getChildrenProps(\n props,\n { disabled, currentDocument },\n {\n formType,\n },\n {\n deleteDocument: deleteDocumentWithConfirm,\n }\n );\n const isChanged = isNotSameDocument(initialDocument, currentDocument);\n\n return success && successComponent ? (\n successComponent\n ) : (\n <FormWarnUnsaved\n isChanged={isChanged}\n warnUnsavedChanges={warnUnsavedChanges}\n >\n <FormContext.Provider\n value={{\n throwError,\n clearForm,\n refetchForm,\n isChanged,\n submitForm: submitFormContext, //Change in name because we already have a function\n // called submitForm, but no reason for the user to know\n // about that\n addToDeletedValues: addToDeletedValues,\n updateCurrentValues: updateCurrentValues,\n getDocument: () => currentDocument,\n getLabel: (fieldName, fieldLocale) =>\n getLabel(model, flatSchema, intl, fieldName, fieldLocale),\n initialDocument: initialDocument,\n // TODO BAD: check where used\n //setFormState: this.setFormState,\n addToSubmitForm,\n addToSuccessForm,\n addToFailureForm,\n errors,\n currentValues,\n deletedValues,\n clearFieldErrors,\n disabled,\n }}\n >\n <FormComponents.FormLayout {...formLayoutProps}>\n {getFieldGroups(\n props,\n {\n currentDocument,\n schema,\n flatSchema,\n originalSchema,\n },\n intl,\n mutableFields,\n intl.formatMessage\n ).map((group, i) => (\n <FormComponents.FormGroup key={i} {...formGroupProps(group)} />\n ))}\n </FormComponents.FormLayout>\n </FormContext.Provider>\n </FormWarnUnsaved>\n );\n};\n\n// Mutation that yield a success result\ntype SuccessfulMutationResult<TData = Object> = MutationResult<TData> & {\n data: TData;\n};\n/**\n * Typeguared to allow considering the request as successful\n */\nconst isSuccessful = function <T = any>(\n result: MutationResult<T> | undefined\n): result is SuccessfulMutationResult<T> {\n return !!result?.data;\n};\n\nexport default Form;\n","/*\n * Schema converter/getters\n */\nimport { canCreateField, canUpdateField } from \"@vulcanjs/permissions\";\nimport { VulcanFieldSchema, VulcanSchema } from \"@vulcanjs/schema\";\nimport { getFieldType } from \"./utils\";\n\n/* getters */\n// filter out fields with \".\" or \"$\"\nexport const getValidFields = (schema) => {\n return Object.keys(schema).filter(\n (fieldName) => !fieldName.includes(\"$\") && !fieldName.includes(\".\")\n );\n};\n\n/*\n\nConvert a nested SimpleSchema schema into a JSON object\nIf flatten = true, will create a flat object instead of nested tree\n\n/* permissions */\n\n/**\n * @method Mongo.Collection.getInsertableFields\n * Get an array of all fields editable by a specific user for a given collection\n * @param {Object} user – the user for which to check field permissions\n */\nexport const getInsertableFields = function (schema, user) {\n const fields = Object.keys(schema).filter(function (fieldName) {\n var field = schema[fieldName];\n return canCreateField(user, field);\n });\n return fields;\n};\n\n/**\n * @method Mongo.Collection.getEditableFields\n * Get an array of all fields editable by a specific user for a given collection (and optionally document)\n * @param {Object} user – the user for which to check field permissions\n */\nexport const getEditableFields = function (schema, user, document) {\n const fields = Object.keys(schema).filter(function (fieldName) {\n var field = schema[fieldName];\n return canUpdateField(user, field, document);\n });\n return fields;\n};\n\nconst isNestedSchema = (schema: any): schema is VulcanSchema => {\n return typeof schema === \"object\";\n};\n\n/**\n * Vulcan Schema => Form Schema\n * TODO: type this better\n * @param schema\n * @param options\n * @returns\n */\nexport const convertSchema = (\n schema: VulcanSchema,\n options: { flatten?: boolean; removeArrays?: boolean } = {}\n) => {\n const { flatten = false, removeArrays = true } = options;\n\n let jsonSchema = {};\n\n Object.keys(schema).forEach((fieldName) => {\n // exclude array fields\n if (removeArrays && fieldName.includes(\"$\")) {\n return;\n }\n\n // extract schema\n jsonSchema[fieldName] = getFieldSchema(fieldName, schema);\n\n // check for existence of nested field\n // and get its schema if possible or its type otherwise\n const subSchemaOrType = getNestedFieldSchemaOrType(fieldName, schema);\n if (subSchemaOrType) {\n // remember the subschema if it exists, allow to customize labels for each group of items for arrays of objects\n jsonSchema[fieldName].arrayFieldSchema = getFieldSchema(\n `${fieldName}.$`,\n schema\n );\n\n // nested schema can be a field schema ({type, canRead, etc.}) (convertedSchema will be null)\n // or a schema on its own with subfields (convertedSchema will return smth)\n if (isNestedSchema(subSchemaOrType)) {\n // call convertSchema recursively on the subSchema\n const convertedSubSchema = convertSchema(subSchemaOrType, options);\n // subSchema is a full schema with multiple fields (eg array of objects)\n if (flatten) {\n jsonSchema = { ...jsonSchema, ...convertedSubSchema };\n } else {\n jsonSchema[fieldName].schema = convertedSubSchema;\n }\n } else {\n // subSchema is a simple field in this case (eg array of numbers)\n jsonSchema[fieldName].isSimpleArrayField = true; //getFieldSchema(`${fieldName}.$`, schema);\n }\n }\n });\n return jsonSchema;\n};\n\n/*\n\nGet a JSON object representing a field's schema\n\n*/\nexport const getFieldSchema = (fieldName: string, schema: VulcanSchema) => {\n let fieldSchema = {};\n schemaProperties.forEach((property) => {\n const propertyValue = schema[fieldName]?.[property];\n if (propertyValue) {\n fieldSchema[property] = propertyValue;\n }\n });\n return fieldSchema;\n};\n\n// type is an array due to the possibility of using SimpleSchema.oneOf\n// right now we support only fields with one type\nexport const getSchemaType = (fieldSchema: VulcanFieldSchema) =>\n getFieldType(fieldSchema);\n\nconst getArrayNestedSchema = (fieldName: string, schema: VulcanSchema) => {\n const arrayItemSchema = schema[`${fieldName}.$`];\n const nestedSchema = arrayItemSchema && getSchemaType(arrayItemSchema);\n return nestedSchema;\n};\n\n// TODO: not 100% it's valid with current implementation\nconst isNestedSchemaField = (fieldSchema: VulcanFieldSchema) => {\n const fieldType = getSchemaType(fieldSchema);\n return fieldType && typeof fieldType === \"object\";\n};\nconst getObjectNestedSchema = (fieldName: string, schema: VulcanSchema) => {\n const fieldSchema = schema[fieldName];\n if (!isNestedSchemaField(fieldSchema)) return null;\n const nestedSchema = fieldSchema && getSchemaType(fieldSchema);\n return nestedSchema;\n};\n/*\n\nGiven an array field, get its nested schema\nIf the field is not an object, this will return the subfield type instead\n*/\nexport const getNestedFieldSchemaOrType = (fieldName, schema) => {\n const arrayItemSchema = getArrayNestedSchema(fieldName, schema);\n if (!arrayItemSchema) {\n // look for an object schema\n const objectItemSchema = getObjectNestedSchema(fieldName, schema);\n // no schema was found\n if (!objectItemSchema) return null;\n return objectItemSchema;\n }\n return arrayItemSchema;\n};\n\nexport const schemaProperties = [\n \"type\",\n \"label\",\n \"optional\",\n \"required\",\n \"min\",\n \"max\",\n \"exclusiveMin\",\n \"exclusiveMax\",\n \"minCount\",\n \"maxCount\",\n \"allowedValues\",\n \"regEx\",\n \"blackbox\",\n \"trim\",\n \"custom\",\n \"defaultValue\",\n \"autoValue\",\n \"hidden\", // hidden: true means the field is never shown in a form no matter what\n \"mustComplete\", // mustComplete: true means the field is required to have a complete profile\n \"form\", // form placeholder\n \"inputProperties\", // form placeholder\n \"itemProperties\",\n \"control\", // SmartForm control (String or React component)\n \"input\", // SmartForm control (String or React component)\n \"autoform\", // legacy form placeholder; backward compatibility (not used anymore)\n \"order\", // position in the form\n \"group\", // form fieldset group\n \"onCreate\", // field insert callback\n \"onUpdate\", // field edit callback\n \"onDelete\", // field remove callback\n \"onInsert\", // OpenCRUD backwards compatibility\n \"onEdit\", // OpenCRUD backwards compatibility\n \"onRemove\", // OpenCRUD backwards compatibility\n \"canRead\",\n \"canCreate\",\n \"canUpdate\",\n \"viewableBy\", // OpenCRUD backwards compatibility\n \"insertableBy\", // OpenCRUD backwards compatibility\n \"editableBy\", // OpenCRUD backwards compatibility\n \"resolveAs\",\n \"searchable\",\n \"description\",\n \"beforeComponent\",\n \"afterComponent\",\n \"placeholder\",\n \"options\",\n \"query\",\n \"queryWaitsForValue\",\n \"autocompleteQuery\",\n \"fieldProperties\",\n \"intl\",\n \"intlId\",\n];\n\nexport const formProperties = [\n \"optional\",\n \"required\",\n \"min\",\n \"max\",\n \"exclusiveMin\",\n \"exclusiveMax\",\n \"minCount\",\n \"maxCount\",\n \"allowedValues\",\n \"regEx\",\n \"blackbox\",\n \"trim\",\n \"custom\",\n \"defaultValue\",\n \"autoValue\",\n \"mustComplete\", // mustComplete: true means the field is required to have a complete profile\n \"form\", // form placeholder\n \"inputProperties\", // form placeholder\n \"itemProperties\",\n \"control\", // SmartForm control (String or React component)\n \"input\", // SmartForm control (String or React component)\n \"order\", // position in the form\n \"group\", // form fieldset group\n \"description\",\n \"beforeComponent\",\n \"afterComponent\",\n \"placeholder\",\n \"options\",\n \"query\",\n \"queryWaitsForValue\",\n \"autocompleteQuery\",\n \"fieldProperties\",\n];\n","import merge from \"lodash/merge.js\";\nimport find from \"lodash/find.js\";\nimport isPlainObject from \"lodash/isPlainObject.js\";\nimport set from \"lodash/set.js\";\nimport size from \"lodash/size.js\";\n\nimport { removePrefix, filterPathsByPrefix } from \"./path_utils\";\nimport { VulcanFieldSchema } from \"@vulcanjs/schema\";\n\n// add support for nested properties\nexport const deepValue = function (obj, path) {\n const pathArray = path.split(\".\");\n\n for (var i = 0; i < pathArray.length; i++) {\n obj = obj[pathArray[i]];\n }\n\n return obj;\n};\n\n// see http://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objects\nexport const flatten = function (data) {\n var result = {};\n function recurse(cur, prop) {\n if (Object.prototype.toString.call(cur) !== \"[object Object]\") {\n result[prop] = cur;\n } else if (Array.isArray(cur)) {\n for (var i = 0, l = cur.length; i < l; i++)\n recurse(cur[i], prop + \"[\" + i + \"]\");\n if (l == 0) result[prop] = [];\n } else {\n var isEmpty = true;\n for (var p in cur) {\n isEmpty = false;\n recurse(cur[p], prop ? prop + \".\" + p : p);\n }\n if (isEmpty && prop) result[prop] = {};\n }\n }\n recurse(data, \"\");\n return result;\n};\n\nexport const isEmptyValue = (value) =>\n typeof value === \"undefined\" ||\n value === null ||\n value === \"\" ||\n (Array.isArray(value) && value.length === 0);\n\n/**\n * Merges values. It takes into account the current, original and deleted values,\n * and the merge produces the proper type for simple objects or arrays.\n *\n * @param {Object} props\n * Form component props. Only specific properties for this function are documented.\n * @param {*} props.currentValue\n * Current value of the field\n * @param {*} props.documentValue\n * Original value of the field\n * @return {*|undefined}\n * Merged value or undefined if no merge was performed\n */\nexport const mergeValue = ({\n currentValue,\n documentValue,\n deletedValues: deletedFields,\n path,\n locale,\n datatype,\n}) => {\n if (locale) {\n // note: intl fields are of type Object but should be treated as Strings\n return currentValue || documentValue || \"\";\n }\n\n // note: retrieve nested deleted values is performed here to avoid skipping\n // the merge in case the current field is not in `currentValues` but a nested\n // property has been removed directly by path\n const deletedValues = getNestedDeletedValues(path, deletedFields);\n const hasDeletedValues = !!size(deletedValues);\n if (\n (Array.isArray(currentValue) || hasDeletedValues) &&\n find(datatype, [\"type\", Array])\n ) {\n return merge([], documentValue, currentValue, deletedValues);\n } else if (\n (isPlainObject(currentValue) || hasDeletedValues) &&\n find(datatype, [\"type\", Object])\n ) {\n return merge({}, documentValue, currentValue, deletedValues);\n }\n return undefined;\n};\n\n/**\n * Converts a list of field names to an object of deleted values.\n *\n * @param {string[]|Object.<string|string>} deletedFields\n * List of deleted field names or paths\n * @param {Object|Array=} accumulator={}\n * Value to reduce the values to\n * @return {Object|Array}\n * Deleted values, with the structure defined by taking the received deleted\n * fields as paths\n * @example\n * const deletedFields = [\n * 'field.subField',\n * 'field.subFieldArray[0]',\n * 'fieldArray[0]',\n * 'fieldArray[2].name',\n * ];\n * getNestedDeletedValues(deletedFields);\n * // => { 'field': { 'subField': null, 'subFieldArray': [null] }, 'fieldArray': [null, undefined, { name: null } }\n */\nexport const getDeletedValues = (deletedFields, accumulator = {}) =>\n deletedFields.reduce(\n (deletedValues, path) => set(deletedValues, path, null),\n accumulator\n );\n\n/**\n * Filters the given field names by prefix, removes it from each one of them\n * and convert the list to an object of deleted values.\n *\n * @param {string=} prefix\n * Prefix to filter and remove from deleted fields\n * @param {string[]|Object.<string|string>} deletedFields\n * List of deleted field names or paths\n * @param {Object|Array=} accumulator={}\n * Value to reduce the values to\n * @return {Object.<string, null>}\n * Object keyed with the given deleted fields, valued with `null`\n * @example\n * const deletedFields = [\n * 'field.subField',\n * 'field.subFieldArray[0]',\n * 'fieldArray[0]',\n * 'fieldArray[2].name',\n * ];\n * getNestedDeletedValues('field', deletedFields);\n * // => { 'subField': null, 'subFieldArray': [null] }\n * getNestedDeletedValues('fieldArray', deletedFields);\n * // => { '0': null, '2': { 'name': null } }\n * getNestedDeletedValues('fieldArray', deletedFields, []);\n * // => [null, undefined, { 'name': null } ]\n */\nexport const getNestedDeletedValues = (\n prefix,\n deletedFields,\n accumulator = {}\n) =>\n getDeletedValues(\n removePrefix(prefix, filterPathsByPrefix(prefix, deletedFields)),\n accumulator\n );\n\n//TODO: check if it still works as expected\n// previously was dataType[0].type\nexport const getFieldType = (fieldSchema: VulcanFieldSchema) =>\n fieldSchema.type;\n/**\n * Get appropriate null value for various field types\n *\n * @param {Array} datatype\n * Field's datatype property\n */\nexport const getNullValue = (datatype) => {\n const fieldType = getFieldType(datatype);\n if (fieldType === Array) {\n return [];\n } else if (fieldType === Boolean) {\n return false;\n } else if (fieldType === String) {\n return \"\";\n } else if (fieldType === Number) {\n return \"\";\n } else {\n // normalize to null\n return null;\n }\n};\n","import toPath from \"lodash/toPath.js\";\nimport initial from \"lodash/initial.js\";\nimport flow from \"lodash/fp/flow.js\";\nimport takeRight from \"lodash/takeRight.js\";\n\n/**\n * Splits a path in string format into an array.\n */\nexport const splitPath = (string: string) => toPath(string);\n\n/**\n * Joins a path in array format into a string.\n */\nexport const joinPath = (array: Array<string | number>): string =>\n array.reduce<string>(\n (string, item) =>\n string +\n (Number.isNaN(Number(item))\n ? `${string === \"\" ? \"\" : \".\"}${item}`\n : `[${item}]`),\n \"\"\n );\n\n/**\n * Retrieves parent path from the given one.\n *\n * @param {String} string\n * Path in string format\n * @return {String}\n */\nexport const getParentPath = flow(splitPath, initial, joinPath);\n\n/**\n * Removes prefix from the given paths.\n *\n * @param {String} prefix\n * @param {String[]} paths\n * @return {String[]}\n */\nexport const removePrefix = (\n prefix: string,\n paths: Array<string>\n): Array<string> => {\n const explodedPrefix = splitPath(prefix);\n return paths.map((path) => {\n if (path === prefix) {\n return path;\n }\n const explodedPath = splitPath(path);\n const explodedSuffix = takeRight(\n explodedPath,\n explodedPath.length - explodedPrefix.length\n );\n return joinPath(explodedSuffix);\n });\n};\n\n/**\n * Filters paths that have the given prefix.\n *\n * @param {String} prefix\n * @param {String[]} paths\n * @return {String[]}\n */\nexport const filterPathsByPrefix = (prefix: string, paths: Array<string>) =>\n paths.filter(\n (path) =>\n path === prefix ||\n path.startsWith(`${prefix}.`) ||\n path.startsWith(`${prefix}[`)\n );\n","/**\n * Field processing functions that computes groups and add relevant props for i18n\n */\nimport { formProperties } from \"../../utils/schema_utils\";\nimport { FieldGroup } from \"@vulcanjs/schema\";\nimport { FormField } from \"../../typings\";\nimport { FormProps, FormState } from \"./typings\";\n\n/**\n * Field related functions\n */\n\nimport { VulcanSchema } from \"@vulcanjs/schema\";\nimport uniq from \"lodash/uniq.js\";\nimport compact from \"lodash/compact.js\";\nimport get from \"lodash/get.js\";\nimport pick from \"lodash/pick.js\";\nimport {\n isIntlField,\n formatLabel,\n getIntlKeys,\n getIntlLabel,\n} from \"@vulcanjs/i18n\";\n\nimport { IntlProviderContextValue } from \"@vulcanjs/react-i18n\";\nimport map from \"lodash/map.js\";\nimport sortBy from \"lodash/sortBy.js\";\nimport uniqBy from \"lodash/uniqBy.js\";\nimport difference from \"lodash/difference.js\";\nimport reject from \"lodash/reject.js\";\nimport intersection from \"lodash/intersection.js\";\nimport _filter from \"lodash/filter.js\";\nimport { capitalize } from \"@vulcanjs/utils\";\nimport { VulcanFieldSchema } from \"@vulcanjs/schema\";\nimport { VulcanModel } from \"@vulcanjs/model\";\n\n/*\n\n Get a field's intl keys (useful for debugging)\n\n */\nconst getModelIntlKeys = (\n model: VulcanModel,\n flatSchema: any,\n fieldName: string\n) => {\n return getIntlKeys({\n fieldName: fieldName,\n modelName: model.name,\n schema: flatSchema,\n });\n};\n\n/*\n\n Get a field's label\n\n */\nexport const getLabel = (\n model: VulcanModel,\n flatSchema: any,\n context: IntlProviderContextValue,\n fieldName: string,\n fieldLocale?: string\n) => {\n const collectionName = model.name.toLowerCase();\n const label = formatLabel({\n intl: context,\n fieldName: fieldName,\n collectionName: collectionName,\n schema: flatSchema,\n });\n if (fieldLocale) {\n const intlFieldLocale = context.formatMessage({\n id: `locales.${fieldLocale}`,\n defaultMessage: fieldLocale,\n });\n return `${label} (${intlFieldLocale})`;\n } else {\n return label;\n }\n};\n\n/*\n\n Get a field's description\n\n (Same as getLabel but pass isDescription: true )\n */\nconst getDescription = (\n model: VulcanModel,\n flatSchema: any,\n context: any,\n fieldName: string\n) => {\n const collectionName = model.name.toLowerCase();\n const description = getIntlLabel({\n intl: context,\n fieldName: fieldName,\n collectionName: collectionName,\n schema: flatSchema,\n isDescription: true,\n });\n return description || null;\n};\n\n/*\n\n Get a field option's label\n\n */\nconst getOptionLabel = (\n model: VulcanModel,\n context: { formatMessage: Function },\n fieldName: string,\n option: { intlId?: string; label: string; value?: any }\n) => {\n const collectionName = model.name.toLowerCase();\n const intlId =\n option.intlId || `${collectionName}.${fieldName}.${option.value}`;\n return context.formatMessage({\n id: intlId,\n defaultMessage: option.label,\n });\n};\n\n/*\n\n Get a list of the fields to be included in the current form\n\n Note: when submitting the form (getData()), do not include any extra fields.\n\n */\nexport const getFieldNames = (\n props: Pick<FormProps, \"fields\" | \"addFields\" | \"removeFields\">,\n currentDocument,\n optionsFromArgs: {\n excludeHiddenFields?: boolean;\n excludeRemovedFields?: boolean;\n replaceIntlFields?: boolean;\n addExtraFields?: boolean;\n schema?: VulcanSchema;\n mutableFields?: Array<any>;\n }\n) => {\n const { fields, addFields, removeFields } = props;\n const defaultOptions = {\n excludeHiddenFields: true,\n excludeRemovedFields: true,\n replaceIntlFields: false,\n addExtraFields: false,\n };\n const options = {\n ...defaultOptions,\n ...optionsFromArgs,\n };\n const {\n schema,\n mutableFields,\n excludeRemovedFields,\n excludeHiddenFields,\n addExtraFields,\n replaceIntlFields,\n } = options;\n\n // get all editable/insertable fields (depending on current form type)\n let relevantFields = mutableFields;\n\n // if \"fields\" prop is specified, restrict list of fields to it\n if (typeof fields !== \"undefined\" && fields.length > 0) {\n relevantFields = intersection(relevantFields, fields);\n }\n\n // if \"hideFields\" prop is specified, remove its fields\n if (excludeRemovedFields) {\n // OpenCRUD backwards compatibility\n //const removeFields = removeFields || hideFields;\n if (typeof removeFields !== \"undefined\" && removeFields.length > 0) {\n relevantFields = difference(relevantFields, removeFields);\n }\n }\n\n // if \"addFields\" prop is specified, add its fields\n if (\n addExtraFields &&\n typeof addFields !== \"undefined\" &&\n addFields.length > 0\n ) {\n relevantFields = relevantFields?.concat(addFields);\n }\n\n // remove all hidden fields\n if (excludeHiddenFields) {\n const document = currentDocument;\n relevantFields = reject(relevantFields, (fieldName) => {\n const hidden = schema?.[fieldName].hidden;\n return typeof hidden === \"function\"\n ? hidden({ props, document })\n : hidden;\n });\n }\n\n // replace intl fields\n if (replaceIntlFields) {\n relevantFields = relevantFields?.map((fieldName) =>\n isIntlField(schema?.[fieldName]) ? `${fieldName}_intl` : fieldName\n );\n }\n\n // remove any duplicates\n relevantFields = uniq(relevantFields);\n\n return relevantFields;\n};\n\n// --------------------------------------------------------------------- //\n// -------------------------------- Fields ----------------------------- //\n// --------------------------------------------------------------------- //\n\nconst initField = (\n props: { model: VulcanModel; layout?: \"horizontal\" | \"vertical\" },\n state: Pick<FormState, \"currentDocument\" | \"flatSchema\" | \"originalSchema\">,\n context: any,\n fieldName: string,\n fieldSchema: VulcanFieldSchema\n) => {\n const { model } = props;\n const { currentDocument, flatSchema } = state;\n const isArray = fieldSchema.type === Array;\n\n // intialize properties\n let field: Partial<FormField> = {\n ...pick(fieldSchema, formProperties),\n name: fieldName,\n datatype: fieldSchema.type,\n layout: props.layout, // A layout property used to control how the form fields are displayed. Defaults to horizontal.\n input: fieldSchema.input || fieldSchema.control, // TODO\n };\n\n // if this is an array field also store its array item type\n if (isArray) {\n const itemFieldSchema = state.originalSchema[`${fieldName}.$`];\n field.itemDatatype = get(itemFieldSchema, \"type.0.type\");\n }\n\n field.label = getLabel(model, flatSchema, context, fieldName);\n field.intlKeys = getIntlKeys({\n fieldName,\n modelName: model.name,\n schema: model.schema,\n });\n // // replace value by prefilled value if value is empty\n // const prefill = fieldSchema.prefill || (fieldSchema.form && fieldSchema.form.prefill);\n // if (prefill) {\n // const prefilledValue = typeof prefill === 'function' ? prefill.call(fieldSchema) : prefill;\n // if (!!prefilledValue && !field.value) {\n // field.prefilledValue = prefilledValue;\n // field.value = prefilledValue;\n // }\n // }\n\n const document = currentDocument;\n field.document = document;\n\n // internationalize field options labels\n if (field.options && Array.isArray(field.options)) {\n field.options = field.options.map((option) => ({\n ...option,\n label: getOptionLabel(model, context, fieldName, option),\n }));\n }\n\n // if this an intl'd field, use a special intlInput\n if (isIntlField(fieldSchema)) {\n field.intlInput = true;\n }\n\n // add any properties specified in fieldSchema.form as extra props passed on\n // to the form component, calling them if they are functions\n const inputProperties = fieldSchema.form || fieldSchema.inputProperties || {};\n for (const prop in inputProperties) {\n const property = inputProperties[prop];\n field[prop] =\n typeof property === \"function\"\n ? property.call(fieldSchema, {\n ...props,\n fieldName,\n document,\n intl: context,\n })\n : property;\n }\n\n // add description as help prop\n const description = getDescription(model, flatSchema, context, fieldName);\n if (description) {\n field.help = description;\n }\n\n return field as FormField;\n};\nconst handleFieldPath = (\n field: FormField,\n fieldName: string,\n parentPath?: string\n) => {\n const fieldPath = parentPath ? `${parentPath}.${fieldName}` : fieldName;\n field.path = fieldPath;\n // TODO: reintroduce this side effect to correctly set the default values\n // (previously was in Form.tsx)\n // Note sure if this is actually needed\n // if (field.defaultValue) {\n // set(this.defaultValues, fieldPath, field.defaultValue);\n // }\n return field;\n};\nconst handleFieldParent = (field: FormField, parentFieldName?: string) => {\n // if field has a parent field, pass it on\n if (parentFieldName) {\n field.parentFieldName = parentFieldName;\n }\n\n return field;\n};\nconst handlePermissions = (\n field: FormField,\n fieldName: string,\n mutableFields: Array<any>\n) => {\n // if field is not creatable/updatable, disable it\n if (!mutableFields.includes(fieldName)) {\n field.disabled = true;\n }\n return field;\n};\nconst handleFieldChildren = (\n props: FormProps,\n state: Pick<FormState, \"currentDocument\" | \"flatSchema\" | \"originalSchema\">,\n context: any,\n field: FormField,\n fieldName: string,\n fieldSchema: any, // TODO: not a VulcanField, more a FormField\n schema: VulcanSchema,\n mutableFields: Array<any>\n) => {\n const { currentDocument } = state;\n // array field\n if (fieldSchema.arrayFieldSchema) {\n field.arrayFieldSchema = fieldSchema.arrayFieldSchema;\n // create a field that can be exploited by the form\n field.arrayField = createArraySubField(\n props,\n state,\n context,\n fieldName,\n field.arrayFieldSchema,\n schema,\n mutableFields\n );\n //field.nestedInput = true\n }\n // nested fields: set input to \"nested\"\n if (fieldSchema.schema) {\n field.nestedSchema = fieldSchema.schema;\n field.nestedInput = true;\n\n // get nested schema\n // for each nested field, get field object by calling createField recursively\n field.nestedFields = getFieldNames(props, currentDocument, {\n schema: field.nestedSchema,\n addExtraFields: false,\n }).map((subFieldName) => {\n return createField(\n props,\n state,\n context,\n subFieldName,\n field.nestedSchema,\n mutableFields,\n fieldName,\n field.path\n );\n });\n }\n return field;\n};\n\n/*\n Given a field's name, the containing schema, and parent, create the\n complete field object to be passed to the component\n\n */\nconst createField = (\n props: FormProps,\n state: Pick<FormState, \"currentDocument\" | \"flatSchema\" | \"originalSchema\">,\n context: any,\n fieldName: string,\n schema: any,\n mutableFields: Array<any>,\n parentFieldName?: string,\n parentPath?: string\n): FormField => {\n const fieldSchema = schema[fieldName];\n let field = initField(props, state, context, fieldName, fieldSchema);\n field = handleFieldPath(field, fieldName, parentPath);\n field = handleFieldParent(field, parentFieldName);\n field = handlePermissions(field, fieldName, mutableFields);\n field = handleFieldChildren(\n props,\n state,\n context,\n field,\n fieldName,\n fieldSchema,\n schema,\n mutableFields\n );\n return field;\n};\nconst createArraySubField = (\n props: FormProps,\n state: Pick<FormState, \"currentDocument\" | \"flatSchema\" | \"originalSchema\">,\n context: any,\n fieldName: string,\n subFieldSchema: VulcanFieldSchema,\n schema: VulcanSchema,\n mutableFields: Array<string>\n) => {\n const subFieldName = `${fieldName}.$`;\n let subField = initField(props, state, context, subFieldName, subFieldSchema);\n // array subfield has the same path and permissions as its parent\n // so we use parent name (fieldName) and not subfieldName\n subField = handleFieldPath(subField, fieldName);\n subField = handlePermissions(subField, fieldName, mutableFields /*schema*/);\n // we do not allow nesting yet\n //subField = this.handleFieldChildren(field, fieldSchema)\n return subField;\n};\n\n// Group of multiple fields (obtained by parsing the whole schema)\ninterface GroupWithFields extends FieldGroup {\n fields: Array<FormField>;\n}\n\ntype FormSchemaState = Pick<\n FormState,\n \"currentDocument\" | \"schema\" | \"flatSchema\" | \"originalSchema\"\n>;\n\n/*\n\n Get all field groups\n\n */\nexport const getFieldGroups = (\n props: FormProps,\n state: FormSchemaState,\n context: IntlProviderContextValue,\n mutableFields: Array<string>,\n formatMessage: any\n) => {\n const { schema, currentDocument } = state;\n // build fields array by iterating over the list of field names\n let fields = getFieldNames(props, currentDocument, {\n mutableFields,\n schema,\n }).map((fieldName) => {\n // get schema for the current field\n return createField(props, state, context, fieldName, schema, mutableFields);\n });\n\n fields = sortBy(fields, \"order\");\n\n // get list of all unique groups (based on their name) used in current fields, remove \"empty\" group\n let groups = compact(uniqBy(map(fields, \"group\"), (g) => (g ? g.name : \"\")));\n\n // for each group, add relevant fields\n let groupsWithFields = groups.map((group) => {\n const label =\n group.label ||\n //this.context.formatMessage({ id: group.name }) ||\n capitalize(group.name);\n const groupFields = _filter<FormField>(fields, (field) => {\n return field.group && field.group.name === group.name;\n });\n const groupWithFields: GroupWithFields = {\n ...group,\n label,\n fields: groupFields,\n };\n return groupWithFields;\n });\n\n // add default group if necessary\n const defaultGroupFields = _filter(fields, (field) => !field.group);\n if (defaultGroupFields.length) {\n const defaultGroup: GroupWithFields = {\n name: \"default\",\n label: \"default\",\n order: 0,\n fields: defaultGroupFields,\n };\n groupsWithFields = [defaultGroup].concat(groupsWithFields);\n }\n\n // sort by order\n groupsWithFields = sortBy(groupsWithFields, \"order\");\n\n // console.log(groups);\n\n return groupsWithFields;\n};\n","import find from \"lodash/find.js\";\nimport isEqualWith from \"lodash/isEqualWith.js\";\nexport const isNotSameDocument = (initialDocument, changedDocument) => {\n const changedValue = find(changedDocument, (value, key, collection) => {\n return !isEqualWith(value, initialDocument[key], (objValue, othValue) => {\n if (!objValue && !othValue) return true;\n });\n });\n return typeof changedValue !== \"undefined\";\n};\n","import { useEffect, useRef } from \"react\";\nimport { block } from \"./block\";\nimport debug from \"debug\";\nconst debugTransitions = debug(\"vn:router-transitions\");\n\n/**\n * Can trigger an alert on unsaved changes\n *\n * Triggers event so you can also block SPA transition (implementation is NOT provided by this hook, you\n * need listeners whose implementation depends on your router (React Router, Next Router...), see block.ts)\n *\n * @see https://github.com/ReactTraining/history/blob/master/docs/blocking-transitions.md\n *\n * @param param0\n */\nexport const useBlockTransition = ({\n shouldBlock,\n getBlockedMessage,\n}: {\n shouldBlock: boolean;\n getBlockedMessage: (evt?: BeforeUnloadEvent) => string;\n}) => {\n // function to unblock the form\n const unblockRef = useRef<Function | undefined>();\n\n useEffect(() => {\n const isBlocking = !!unblockRef.current;\n debugTransitions(\n \"running effect\",\n \"should block\",\n shouldBlock,\n \"currently blocked\",\n isBlocking\n );\n\n const onUnblock = () => {\n debugTransitions(\"running unblock from effect\");\n if (!shouldBlock) {\n if (unblockRef.current) {\n unblockRef.current();\n }\n }\n };\n // block\n const onBlocked = (evt?: BeforeUnloadEvent): string => {\n const message = getBlockedMessage(evt);\n debugTransitions(\n \"user is being blocked after trying to leave the page, with message: \" +\n message\n );\n if (evt) {\n evt.returnValue = message;\n }\n return message;\n };\n if (shouldBlock) {\n debugTransitions(\n \"should block transition, setting up relevant event listener\"\n );\n unblockRef.current = block(onBlocked, onUnblock);\n }\n // unblock if not blocking anymore and was blocking previously\n if (!shouldBlock && isBlocking) {\n debugTransitions(\"should unblock (state has been reinitialized)\");\n if (unblockRef.current) {\n unblockRef.current();\n }\n }\n // trigger the potentially registered unblock function when component unmounts\n //return onUnblock;\n }, [shouldBlock]);\n};\n","import debug from \"debug\";\nconst debugTransitions = debug(\"vn:route-transition\");\nconst BeforeUnloadEventType = \"beforeunload\";\n/**\n * Event triggered when a warning on unsaved changes is necessary\n * The app should listen for this event to setup relevant blocking methods depending on the framework\n *\n * For instance with React Router:\n *\n * let unblock\n * window.addEventListener(\"blocktransition\", () => {\n * unblock = router.history.block(...)\n * })\n * window.addEventListener(\"unblocktransition\", () => {\n * unblock()\n * })\n *\n * For Next.js, you would do something similar\n * Check https://github.com/vercel/next.js/discussions/12348\n *\n */\nexport const BLOCK_TRANSITION_EVENT_TYPE = \"blocktransition\";\n/**\n * Called when blocking is not necessary anymore:\n * - there are no unsaved changes anymore\n * - user has confirmed they want to leave\n */\nexport const UNBLOCK_TRANSITION_EVENT_TYPE = \"unblocktransition\";\n/**\n * Intercepts the beforeunload event\n *\n * Code taken from React Router history feature\n * @see https://github.com/ReactTraining/history/blob/master/docs/blocking-transitions.md\n */\nfunction blockBeforeUnload(event: BeforeUnloadEvent) {\n // Cancel the event.\n event.preventDefault();\n // Chrome (and legacy IE) requires returnValue to be set.\n event.returnValue = \"\";\n}\n\n/**\n * Blocks transition\n *\n * /!\\ In order to catch SPA transition, you need to implement\n * an event listener in your own app.\n *\n *\n * @param onUnblock Callback to call on unblock, for custom behaviour\n * @returns A function to unblock the transition (eg if the form is back to\n * its original state)\n */\nexport const block = (\n setConfirmationMessage: (event?: BeforeUnloadEvent) => string,\n onUnblock?: Function\n) => {\n debugTransitions(\"running block function\");\n // trigger a block event, to be handled at the framework level\n // TODO: setConfirmationMessage should be passed as well\n const blockEvent = new Event(BLOCK_TRANSITION_EVENT_TYPE);\n window.dispatchEvent(blockEvent);\n // block at browser level\n window.addEventListener(BeforeUnloadEventType, blockBeforeUnload);\n window.addEventListener(BeforeUnloadEventType, setConfirmationMessage);\n // return an unblock function to cancel\n const unblock = () => {\n debugTransitions(\"running unblock function\");\n if (onUnblock) {\n debugTransitions(\"running user defined function\");\n onUnblock(); // callback from user land\n }\n // trigger an unblock event, to be handled at the framework level\n const unblockEvent = new Event(UNBLOCK_TRANSITION_EVENT_TYPE);\n window.dispatchEvent(unblockEvent);\n // remove the browser level events\n window.removeEventListener(BeforeUnloadEventType, blockBeforeUnload);\n window.removeEventListener(BeforeUnloadEventType, setConfirmationMessage);\n // unblock browser change\n // @ts-ignore\n window.onbeforeunload = undefined; //undefined instead of null to support IE\n };\n return unblock;\n};\n","import { useBlockTransition } from \"../useBlockTransition/useBlockTransition\";\nimport debug from \"debug\";\nimport { useIntlContext } from \"@vulcanjs/react-i18n\";\nconst debugTransitions = debug(\"vn:route-transitions\");\n\n/**\n * Can trigger an alert on unsaved changes\n *\n * Triggers event so you can also block SPA transition (implementation is NOT provided by this hook, you\n * need listeners whose implementation depends on your router (React Router, Next Router...), see block.ts)\n *\n * @see https://github.com/ReactTraining/history/blob/master/docs/blocking-transitions.md\n *\n * @param param0\n */\nexport const useWarnOnUnsaved = ({\n isChanged,\n warnUnsavedChanges,\n}: {\n isChanged: boolean;\n warnUnsavedChanges?: boolean;\n}) => {\n const context = useIntlContext();\n /**\n * To be passed to onbeforeunload event. The returned message will be displayed\n * by the prompt.\n *\n * see https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload\n * the message returned is actually ignored by most browsers and a default message 'Are you sure you want to leave this page? You might have unsaved changes' is displayed. See the Notes section on the mozilla docs above\n */\n const getBlockedMessage = (event?: BeforeUnloadEvent) => {\n debugTransitions(\"running handlePageLeave\", event);\n const message = context.formatMessage({\n id: \"forms.confirm_discard\",\n defaultMessage: \"Are you sure you want to discard your changes?\",\n });\n return message;\n };\n useBlockTransition({\n shouldBlock: !!(warnUnsavedChanges && isChanged),\n getBlockedMessage: getBlockedMessage,\n });\n};\n","import { useState } from \"react\";\n\n/**\n * TODO: should be props of the Forms as well for initialization\n * TODO: those callbacks aren't even called in the Form, so they do nothing yet...\n */\nexport interface AddSubmitCallbacks {\n /**\n * To be called in a useEffect on component mount\n * Used to clean advanced input values on submit events,\n * eg UploadInput\n */\n addToSubmitForm: (cb: any) => void;\n /**\n * To be called in a useEffect on component mount\n * Used to clean advanced input values on submit events,\n * eg UploadInput\n */\n addToSuccessForm: (cb: any) => void;\n /**\n * To be called in a useEffect on component mount\n * Used to clean advanced input values on submit events,\n * eg UploadInput\n */\n addToFailureForm: (cb: any) => void;\n}\n/**\n * Advanced callbacks that lets an input hook some logic on submit/success/failure\n */\nexport const useSubmitCallbacks = () => {\n const [callbacks, setCallbacks] = useState<{\n submitFormCallbacks: Array<any>;\n successFormCallbacks: Array<any>;\n failureFormCallbacks: Array<any>;\n }>({\n submitFormCallbacks: [],\n successFormCallbacks: [],\n failureFormCallbacks: [],\n });\n // add a callback to the form submission\n const addToSubmitForm = (callback) => {\n setCallbacks((cbs) => ({\n ...cbs,\n submitFormCallbacks: [...cbs.submitFormCallbacks, callback],\n }));\n };\n // add a callback to form submission success\n const addToSuccessForm = (callback) => {\n setCallbacks((cbs) => ({\n ...cbs,\n successFormCallbacks: [...cbs.successFormCallbacks, callback],\n }));\n };\n // add a callback to form submission failure\n const addToFailureForm = (callback) => {\n setCallbacks((cbs) => ({\n ...cbs,\n failureFormCallbacks: [...cbs.failureFormCallbacks, callback],\n }));\n };\n return {\n callbacks,\n addToSuccessForm,\n addToSubmitForm,\n addToFailureForm,\n };\n};\n","/*\n\nFormContainer aka SmartForm\n\nChanges compared to Vulcan Meteor:\n\n- previously was named FormWrapper\n- accepts a model instead of collection\n- no queryFragmentName (resp. mutation name), instead you need to pass the fragment explicitely\n\nTechnically, this is a GraphqlSmartForm, while Form.tsx is the more\ngeneric SmartForm, or a \"ModelForm\".\n\n\n---\n\nGenerate the appropriate fragment for the current form, then\nwrap the main Form component with the necessary HoCs while passing\nthem the fragment.\n\nThis component is itself wrapped with:\n\n- withCurrentUser\n- withApollo (used to access the Apollo client for form pre-population)\n\nAnd wraps the Form component with:\n\n- withNew\n\nOr:\n\n- withSingle\n- withUpdate\n- withDelete\n\n(When wrapping with withSingle, withUpdate, and withDelete, a special Loader\ncomponent is also added to wait for withSingle's loading prop to be false)\n\n*/\nimport React, { useRef } from \"react\";\n// import // withCurrentUser,\n// Utils,\n// getFragment,\n//\"meteor/vulcan:core\";\nimport { DocumentNode } from \"@apollo/client\";\nimport gql from \"graphql-tag\";\n\nimport getFormFragments from \"../utils/formFragments\";\n// import { VulcanModel } from \"@vulcanjs/model\";\nimport { VulcanGraphqlModel, getFragmentName } from \"@vulcanjs/graphql\";\nimport type {\n CreateVariables,\n UpdateVariables,\n DeleteVariables,\n} from \"@vulcanjs/crud\";\nimport { capitalize } from \"@vulcanjs/utils\";\nimport {\n useSingle,\n useCreate,\n useUpdate,\n useDelete,\n UseSingleOptions,\n} from \"@vulcanjs/react-hooks\";\nimport { FetchResult } from \"@apollo/client\";\n// import { FormType } from \"./typings\";\nimport { debugVulcan } from \"@vulcanjs/utils\";\nimport { VulcanUser } from \"@vulcanjs/permissions\";\nimport { PassedDownFormProps } from \"./Form/typings\";\n// Be careful to import from the Consumer!\nimport { useVulcanComponents } from \"../../VulcanComponents/Consumer\";\nimport { useVulcanCurrentUser } from \"../../VulcanCurrentUser\";\nconst debugForm = debugVulcan(\"form\");\n\n// Mutation that yield a success result\ntype SuccessfulFetchResult<TData = Object> = FetchResult<TData> & {\n data: TData;\n};\n/**\n * Typeguared to allow considering the request as successful\n */\nconst isSuccessful = function <T = any>(\n result: FetchResult<T> | undefined\n): result is SuccessfulFetchResult<T> {\n return !!result?.data;\n};\n\nexport interface FormContainerProps extends PassedDownFormProps {\n model: VulcanGraphqlModel;\n /** Document id for edition mode, will automatically fetch the document */\n documentId?: string;\n /** Slug (= human readable unique id) for edition mode, will automatically fetch the document */\n slug?: string;\n /**\n * List only those fields in the form\n */\n fields?: Array<string>;\n /**\n * List default fields + those additional fields as well\n */\n addFields?: Array<string>;\n /**\n * Force a currentUser, overriding the currentUser obtained\n * via Context\n *\n * If you use many forms in your app,\n * it might be better to set VulcanCurrentUserContext\n * at the top-level of your app\n * (eg in \"pages/_app.js\" for Next.js)\n */\n currentUser?: VulcanUser | null;\n loadingCurrentUser?: boolean;\n}\nexport type SmartFormProps = FormContainerProps;\n\nconst useFragments = (\n props: Pick<\n FormContainerProps,\n | \"mutationFragment\"\n | \"mutationFragmentName\"\n | \"queryFragment\"\n | \"queryFragmentName\"\n // for auto generation\n | \"model\"\n | \"fields\"\n | \"addFields\"\n >,\n formType: \"edit\" | \"new\"\n) => {\n // get fragment used to decide what data to load from the server to populate the form,\n // as well as what data to ask for as return value for the mutation\n // TODO: move out of the component\n //const getFragments = () => {\n let queryFragment: DocumentNode | undefined;\n let queryFragmentName: string | undefined;\n let mutationFragment: DocumentNode | undefined;\n let mutationFragmentName: string | undefined;\n\n // if queryFragment or mutationFragment props are specified, accept either fragment object or fragment string\n // TODO: not sure we actually need that, gApollo accepts fragments or string normally\n if (props.queryFragment) {\n if (typeof props.queryFragment === \"string\") {\n queryFragment = gql`\n ${props.queryFragment}\n `;\n if (!props.queryFragmentName)\n throw new Error(\n \"When using a string queryFragment, queryFragmentName is mandatory\"\n );\n queryFragmentName = props.queryFragmentName;\n } else {\n // DocumentNode\n queryFragment = props.queryFragment;\n // automatically compute the fragment name\n queryFragmentName =\n props.queryFragmentName || getFragmentName(props.queryFragment);\n }\n }\n if (props.mutationFragment) {\n if (typeof props.mutationFragment === \"string\") {\n mutationFragment = gql`\n ${props.mutationFragment}\n `;\n if (!props.mutationFragmentName)\n throw new Error(\n \"When using a string mutationFragment, mutationFragmentName is mandatory\"\n );\n queryFragmentName = props.mutationFragmentName;\n } else {\n // DocumentNode\n mutationFragment = props.mutationFragment;\n // automatically compute the fragment name\n mutationFragmentName =\n props.mutationFragmentName || getFragmentName(props.mutationFragment);\n }\n }\n // auto generate fragments\n let autoFormFragments;\n if (!props.queryFragment || !props.mutationFragment) {\n const { model, fields, addFields } = props;\n // autogenerated fragments\n autoFormFragments = getFormFragments({\n formType,\n model,\n fields,\n addFields,\n });\n }\n // use autogenerated value if necessary\n if (!props.queryFragment) {\n queryFragment = autoFormFragments.queryFragment;\n queryFragmentName = autoFormFragments.queryFragmentName;\n }\n if (!props.mutationFragment) {\n mutationFragment = autoFormFragments.mutationFragment;\n mutationFragmentName = autoFormFragments.mutationFragmentName;\n }\n return {\n mutationFragment: mutationFragment as DocumentNode,\n mutationFragmentName: mutationFragmentName as string,\n queryFragment: queryFragment as DocumentNode,\n queryFragmentName: queryFragmentName as string,\n };\n};\n// Fonctionnal version to be able to use hooks\nexport const FormContainer = (props: FormContainerProps) => {\n const {\n model,\n documentId,\n slug,\n fields,\n addFields,\n currentUser: currentUserFromProps,\n loadingCurrentUser: loadingCurrentUserFromProps,\n } = props;\n const { schema } = model;\n // if a document is being passed, this is an edit form\n const isEdit = documentId || slug;\n const selector = {\n documentId,\n slug,\n };\n const formType = isEdit ? \"edit\" : \"new\";\n const VulcanComponents = useVulcanComponents();\n\n // get query & mutation fragments from props or else default to same as generatedFragment\n //return {\n // queryFragment,\n // mutationFragment,\n //};\n //}\n\n const prefix = `${model.name}${capitalize(formType)}`;\n // props to pass on to child component (i.e. <Form />)\n const childProps = {\n formType,\n schema,\n };\n\n const {\n mutationFragment,\n mutationFragmentName,\n queryFragment,\n queryFragmentName,\n } = useFragments(props, formType);\n\n // options for useCreate, useUpdate and useDelete\n const mutationOptions = {\n model,\n // collection: this.props.collection,\n fragment: mutationFragment,\n fragmentName: mutationFragmentName,\n };\n\n const queryOptions: UseSingleOptions<any> = {\n model,\n // TODO: what this option does?\n // queryName: `${prefix}FormQuery`,\n fragment: queryFragment,\n fragmentName: queryFragmentName,\n // fragmentName?\n input: {\n id: documentId,\n enableCache: false,\n // TODO: support slug\n },\n queryOptions: {\n // we always want to load a fresh copy of the document\n fetchPolicy: \"network-only\" as const,\n pollInterval: 0, // no polling, only load data once\n skip: formType === \"new\",\n },\n };\n const { data, document, loading, refetch } = useSingle(queryOptions);\n if (formType !== \"new\") {\n debugForm(\n \"useSingle result\",\n \"data\",\n data,\n \"document\",\n document,\n \"loading\",\n loading\n );\n }\n // TODO: pass the creation functions down to the Form\n const [createDocument] = useCreate(mutationOptions);\n const [updateDocument] = useUpdate(mutationOptions);\n const [deleteDocument] = useDelete(mutationOptions);\n\n const {\n currentUser: currentUserFromContext,\n loading: loadingCurrentUserFromContext,\n } = useVulcanCurrentUser();\n const shouldGetCurrentUserFromProps =\n typeof currentUserFromProps !== \"undefined\";\n const currentUser = shouldGetCurrentUserFromProps\n ? currentUserFromProps\n : currentUserFromContext;\n const loadingCurrentUser = shouldGetCurrentUserFromProps\n ? loadingCurrentUserFromProps\n : loadingCurrentUserFromContext;\n\n // callbacks\n /*\n const formRef = useRef(null);\n const newMutationSuccessCallback = function <TData = Object>(\n result: SuccessfulFetchResult<TData>\n ) {\n getDocumentFromResult(result, \"new\");\n };\n const editMutationSuccessCallback = function <TData = Object>(\n result: SuccessfulFetchResult<TData>\n ) {\n getDocumentFromResult(result, \"edit\");\n };\n */\n\n /*\n The create hook already creates a document prop in a more stable way\n const getDocumentFromResult = function <TData = Object>(\n // must be called only on valid results\n result: SuccessfulFetchResult<TData> | undefined\n ) {\n if (!result) return undefined;\n // TODO: quite risky... we should have a better way to get the document\n let document = result.data[Object.keys(result.data)[0]].data; // document is always on first property\n\n return document;\n };*/\n // for new mutation, run refetch function if it exists\n /*\n if (mutationType === \"new\" && refetch) refetch();\n */\n\n const createAndReturnDocument = async (variables: CreateVariables) => {\n const result = await createDocument(variables);\n const { errors, document } = result;\n return {\n document,\n errors,\n };\n };\n const updateAndReturnDocument = async (variables: UpdateVariables) => {\n const result = await updateDocument(variables);\n const { errors, document } = result;\n return {\n document,\n errors,\n };\n };\n\n const deleteDocumentAndRefetch = async (variables: DeleteVariables) => {\n await deleteDocument(variables as any);\n };\n\n if (isEdit && loading) {\n return <VulcanComponents.Loading />;\n }\n return (\n <VulcanComponents.Form\n document={document}\n loading={loading || loadingCurrentUser}\n createDocument={createAndReturnDocument /*createDocument*/}\n updateDocument={updateAndReturnDocument}\n deleteDocument={deleteDocumentAndRefetch}\n refetch={refetch}\n currentUser={currentUser}\n {...childProps}\n {...props}\n />\n );\n};\n\n/*\nFormContainer.propTypes = {\n // main options\n documentId: PropTypes.string, // if a document is passed, this will be an edit form\n mutationFragment: PropTypes.object,\n mutationFragmentName: PropTypes.string,\n\n // graphQL\n // createFoo, deleteFoo, updateFoo\n // newMutation: PropTypes.func, // the new mutation\n // editMutation: PropTypes.func, // the edit mutation\n // removeMutation: PropTypes.func, // the remove mutation\n\n // form\n prefilledProps: PropTypes.object,\n layout: PropTypes.string,\n fields: PropTypes.arrayOf(PropTypes.string),\n hideFields: PropTypes.arrayOf(PropTypes.string),\n addFields: PropTypes.arrayOf(PropTypes.string),\n showRemove: PropTypes.bool,\n submitLabel: PropTypes.node,\n cancelLabel: PropTypes.node,\n revertLabel: PropTypes.node,\n repeatErrors: PropTypes.bool,\n warnUnsavedChanges: PropTypes.bool,\n formComponents: PropTypes.object,\n disabled: PropTypes.bool,\n itemProperties: PropTypes.object,\n successComponent: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n contextName: PropTypes.string,\n\n // callbacks\n ...callbackProps,\n\n currentUser: PropTypes.object,\n client: PropTypes.object,\n};\n\nFormContainer.defaultProps = {\n layout: \"horizontal\",\n};\n*/\n\n/*\nregisterComponent({\n name: 'SmartForm',\n component: FormContainer,\n hocs: [withCurrentUser, withApollo, withRouter, withCollectionProps],\n});\n*/\n\nexport const SmartForm = FormContainer;\n\nexport default FormContainer;\n","/**\n * Generate mutation and query fragments for a form based on the schema\n * TODO: refactor to mutualize more code with vulcan-core defaultFragment functions\n * TODO: move to lib when refactored\n */\nimport _uniq from \"lodash/uniq.js\";\nimport _intersection from \"lodash/intersection.js\";\nimport gql from \"graphql-tag\";\nimport {\n getCreateableFields,\n getUpdateableFields,\n getFragmentFieldNames,\n //isBlackbox,\n} from \"@vulcanjs/schema\";\nimport {\n getFieldFragment,\n VulcanGraphqlModel,\n //isBlackbox,\n} from \"@vulcanjs/graphql\";\nimport { capitalize } from \"@vulcanjs/utils\";\nimport type { FormType } from \"../typings\";\nimport compact from \"lodash/compact.js\";\n// getFieldFragment,\nconst intlSuffix = \"_intl\";\n\n// PostsEditFormQueryFragment/PostsNewFormMutationFragment/etc.\nconst getFragmentName = (\n formType: FormType,\n multiTypeName: string,\n fragmentType: \"mutation\" | \"query\"\n) =>\n [multiTypeName, formType, \"form\", fragmentType, \"fragment\"]\n .map(capitalize)\n .join(\"\");\n\n// get modifiable fields in the query either for update or create operations\nconst getQueryFieldNames = ({ schema, options }) => {\n const queryFields =\n options.formType === \"new\"\n ? getCreateableFields(schema)\n : getUpdateableFields(schema);\n return queryFields;\n};\n// add readable fields to mutation fields\nconst getMutationFieldNames = ({ readableFieldNames, queryFieldNames }) => {\n return _uniq(queryFieldNames.concat(readableFieldNames));\n};\n\n/*\nconst getFieldFragment = ({ schema, fieldName, options }) => {\n let fieldFragment = fieldName;\n const field = schema[fieldName];\n if (!(field && field.type)) return fieldName;\n const fieldType = field.type.singleType;\n const fieldTypeName =\n typeof fieldType === 'object'\n ? 'Object'\n : typeof fieldType === 'function'\n ? fieldType.name\n : fieldType;\n\n if (fieldName.slice(-5) === intlSuffix) {\n fieldFragment = `${fieldName}{ locale value }`;\n } else {\n switch (fieldTypeName) {\n // recursive call for nested arrays and objects\n case 'Object':\n if (!isBlackbox(field) && fieldType._schema) {\n fieldFragment =\n getSchemaFragment({\n fragmentName: fieldName,\n schema: fieldType._schema,\n options,\n }) || null;\n }\n break;\n case 'Array':\n const arrayItemFieldName = `${fieldName}.$`;\n const arrayItemField = schema[arrayItemFieldName];\n // note: make sure field has an associated array item field\n if (arrayItemField) {\n // child will either be native value or a an object (first case)\n const arrayItemFieldType = arrayItemField.type.singleType;\n if (!arrayItemField.blackbox && arrayItemFieldType._schema) {\n fieldFragment =\n getSchemaFragment({\n fragmentName: fieldName,\n schema: arrayItemFieldType._schema,\n options,\n }) || null;\n }\n }\n break;\n default:\n // handle intl or return fieldName\n fieldFragment = fieldName;\n break;\n }\n }\n return fieldFragment;\n};\n*/\n\n// get fragment for a whole schema (root schema or nested schema of an object or an array)\nconst getSchemaFragment = ({\n schema,\n fragmentName,\n options,\n fieldNames: providedFieldNames,\n}) => {\n // differentiate mutation/query and create/update cases\n // respect provided fieldNames if any (needed for the root schema)\n const fieldNames =\n providedFieldNames ||\n (options.isMutation\n ? getMutationFieldNames({\n queryFieldNames: getQueryFieldNames({ schema, options }),\n readableFieldNames: getFragmentFieldNames({\n schema,\n options: { onlyViewable: true },\n }),\n })\n : getQueryFieldNames({ schema, options }));\n\n const childFragments =\n fieldNames.length &&\n fieldNames\n .map((fieldName) =>\n getFieldFragment({\n schema,\n fieldName,\n options,\n getObjectFragment: getSchemaFragment, // allow to reuse the code from defaultFragment with another behaviour\n })\n )\n // remove empty values\n .filter((f) => !!f);\n if (childFragments.length) {\n return `${fragmentName} { ${childFragments.join(\"\\n\")} }`;\n }\n return null;\n};\n\n/**\n * Generate query and mutation fragments for forms, dynamically based on the selected fields\n */\nconst getFormFragments = ({\n formType = \"new\",\n model,\n fields, // restrict on certain fields\n addFields, // add additional fields (eg to display static fields)\n}: {\n model: VulcanGraphqlModel;\n formType: FormType;\n fields?: Array<string>; // restrict on certain fields\n addFields?: Array<string>; // add additional fields (eg to display static fields)\n}) => {\n const { schema, name, graphql } = model;\n const { typeName, multiTypeName } = graphql;\n // get the root schema fieldNames\n let queryFieldNames = getQueryFieldNames({ schema, options: { formType } });\n let mutationFieldNames = getMutationFieldNames({\n queryFieldNames,\n readableFieldNames: getFragmentFieldNames({\n schema,\n options: { onlyViewable: true },\n }),\n });\n\n // if \"fields\" prop is specified, restrict list of fields to it\n if (fields && fields?.length > 0) {\n // add \"_intl\" suffix to all fields in case some of them are intl fields\n const fieldsWithIntlSuffix = fields.map((field) => `${field}${intlSuffix}`);\n const allFields = [...fields, ...fieldsWithIntlSuffix];\n queryFieldNames = _intersection(queryFieldNames, allFields);\n mutationFieldNames = _intersection(mutationFieldNames, allFields);\n }\n\n // add \"addFields\" prop contents to list of fields\n if (addFields?.length) {\n queryFieldNames = queryFieldNames.concat(addFields);\n mutationFieldNames = mutationFieldNames.concat(addFields);\n }\n\n // userId is used to check for permissions, so add it to fragments if possible\n if (schema.userId) {\n queryFieldNames.unshift(\"userId\");\n mutationFieldNames.unshift(\"userId\");\n }\n\n if (schema._id) {\n queryFieldNames.unshift(\"_id\");\n mutationFieldNames.unshift(\"_id\");\n }\n\n // check unicity (_id can be added twice)\n queryFieldNames = _uniq(queryFieldNames);\n mutationFieldNames = _uniq(mutationFieldNames);\n\n if (queryFieldNames.length === 0)\n // NOTE: in theory, you could have no queriable fields, but mutable fields =>\n // a form for data that you can create but can never see...\n // Since that doesn't make much sense, we throw an error to secure the end user\n throw new Error(\n `Model \"${model.name}\" has no queryable fields, cannot create a form for it. Please add readable/createable/updateable fields to the model schema.`\n );\n if (mutationFieldNames.length === 0)\n throw new Error(\n `Model \"${model.name}\" has no mutable fields, cannot create a form for it. Please add createable/updateable fields to model schema.`\n );\n\n const queryFragmentName = getFragmentName(\n formType,\n multiTypeName, // previously collectionName //name,\n \"query\"\n );\n // generate query fragment based on the fields that can be edited. Note: always add _id, and userId if possible.\n // TODO: support nesting\n const queryFragmentText = getSchemaFragment({\n schema,\n fragmentName: `fragment ${queryFragmentName} on ${typeName}`,\n options: { formType, isMutation: false },\n fieldNames: queryFieldNames,\n });\n if (!queryFragmentText) {\n // NOTE: this should never happen if we don't have an empty array for field names\n throw new Error(\n `Model ${model.name} with fields ${queryFieldNames} yield an empty query fragment.`\n );\n }\n const generatedQueryFragment = gql(queryFragmentText);\n\n const mutationFragmentName = getFragmentName(\n formType,\n multiTypeName, // previously collectionName,\n \"mutation\"\n );\n const mutationFragmentText = getSchemaFragment({\n schema,\n fragmentName: `fragment ${mutationFragmentName} on ${typeName}`,\n options: { formType, isMutation: true },\n fieldNames: mutationFieldNames,\n });\n if (!mutationFragmentText) {\n // NOTE: this should never happen if we don't have an empty array for field names\n throw new Error(\n `Model ${model.name} with fields ${mutationFieldNames} yield an empty mutation fragment.`\n );\n }\n // generate mutation fragment based on the fields that can be edited and/or viewed. Note: always add _id, and userId if possible.\n // TODO: support nesting\n const generatedMutationFragment = gql(mutationFragmentText);\n\n // if any field specifies extra queries, add them\n const extraQueries = compact(\n getQueryFieldNames({ schema, options: { formType } }).map((fieldName) => {\n const field = schema[fieldName];\n return field.query;\n })\n );\n // get query & mutation fragments from props or else default to same as generatedFragment\n return {\n queryFragment: generatedQueryFragment,\n mutationFragment: generatedMutationFragment,\n queryFragmentName,\n mutationFragmentName,\n extraQueries,\n };\n};\n\nexport default getFormFragments;\n","import { useContext } from \"react\";\nimport { VulcanCurrentUserContext } from \"./Context\";\n\nexport const VulcanCurrentUserConsumer = VulcanCurrentUserContext.Consumer;\n\nexport const useVulcanCurrentUser = () => useContext(VulcanCurrentUserContext);\n","import React from \"react\";\nimport type { VulcanUser } from \"@vulcanjs/permissions\";\n\nexport type VulcanCurrentUserContextType =\n | { currentUser: VulcanUser | null; loading: false }\n | { loading: true; currentUser: any };\n// We need this to shut TypeScript up\n// You should use the Provider to get the right default values\nexport const VulcanCurrentUserContext =\n React.createContext<VulcanCurrentUserContextType>({\n currentUser: null,\n loading: false,\n });\n","/**\n * NOTE: KEEP SEPARATED FROM THE HOOKS TO CONSUME THE CONTEXT\n * otherwise you'll end up with circular dependencies because of the default components\n */\n// TODO: we might need to adapt the provider to merge its value with a potentially higher up context\nimport React from \"react\";\n\nimport {\n VulcanCurrentUserContext,\n VulcanCurrentUserContextType,\n} from \"./Context\";\n\n// So that you can override only some components by adding an additional context while keeping the defaults\nexport const VulcanCurrentUserProvider = ({\n value,\n ...props\n}: {\n value: VulcanCurrentUserContextType;\n children: React.ReactNode;\n}) => (\n <VulcanCurrentUserContext.Provider\n value={value} // merge provided components so the user can provide only a partial replacement\n {...props}\n />\n);\n","import pick from \"lodash/pick.js\";\n\n/**\n * Extract input props for the FormComponentInner\n * @param {*} props All component props\n * @returns Initial props + props specific to the HTML input in an inputProperties object\n */\nexport const getHtmlInputProps = (props) => {\n const { name, path, options, label, onChange, onBlur, value, disabled } =\n props;\n\n // these properties are whitelisted so that they can be safely passed to the actual form input\n // and avoid https://facebook.github.io/react/warnings/unknown-prop.html warnings\n const inputProperties = {\n ...props.inputProperties,\n name,\n path,\n options,\n label,\n onChange,\n onBlur,\n value,\n disabled,\n };\n\n return {\n ...props,\n inputProperties,\n };\n};\n\n/**\n * Extract input props for the FormComponentInner\n * @param {*} props All component props\n * @returns Initial props + props specific to the HTML input in an inputProperties object\n */\nexport const whitelistInputProps = (\n props: any\n): React.HTMLProps<HTMLInputElement> => {\n const whitelist = [\n \"name\",\n \"path\",\n \"options\",\n \"label\",\n \"onChange\",\n \"onBlur\",\n \"value\",\n \"disabled\",\n \"placeholder\",\n ];\n const value = props.value;\n let safeValue = value;\n // No null values in HTML inputs\n if (value === null) safeValue = undefined;\n // if value is null, return undefined\n return { ...pick(props, whitelist), value: safeValue };\n};\n","/**\n * NOTE: KEEP SEPARATED FROM THE HOOKS TO CONSUME THE CONTEXT\n * otherwise you'll end up with circular dependencies because of the default components\n */\n// TODO: we might need to adapt the provider to merge its value with a potentially higher up context\nimport React from \"react\";\n\nimport { PossibleVulcanComponents } from \"./typings\";\nimport { VulcanComponentsContext } from \"./Context\";\nimport { useVulcanComponents } from \"./Consumer\";\nimport { debugVulcan } from \"@vulcanjs/utils\";\nconst debugComponents = debugVulcan(\"components\"); //console.log;\n\n/**\n *\n * @param options.value An object of Vulcan components to be overriden.\n */\nexport const VulcanComponentsProvider = ({\n value,\n ...props\n}: {\n value?: Partial<PossibleVulcanComponents>;\n children: React.ReactNode;\n}) => {\n const currentComponents = useVulcanComponents();\n debugComponents(\n \"Current components __not_initialized?\",\n currentComponents.__not_initialized\n );\n const mergedComponents = {\n // merge with a parent Provider if needed\n ...(currentComponents?.__not_initialized ? {} : currentComponents || {}),\n ...(value || {}),\n };\n debugComponents(\"Merged components\", mergedComponents);\n // For preserving displayName, that is lost after build somehow\n Object.keys(mergedComponents).forEach((componentName) => {\n if (mergedComponents[componentName]) {\n mergedComponents[componentName].displayName = \"Vulcan.\" + componentName;\n } else {\n console.warn(`Encountered an undefined component: ${componentName}.\n The component may not be registered, or import failed.\n For instance due to an infinite import loop when importing\n \"useVulcanComponents\" from index instead of Consumer.`);\n }\n });\n return (\n <VulcanComponentsContext.Provider\n // We make the assumption that all components are there, user is responsible\n // for adding them correctly in the context where necessary\n value={mergedComponents as PossibleVulcanComponents} // merge provided components so the user can provide only a partial replacement\n {...props}\n />\n );\n};\n","import { LoadingButton } from \"../../core/LoadingButton\";\nimport { MutationButton } from \"../../core/MutationButton\";\nimport { Form, FormContainer } from \"../../form/core\";\nimport { PossibleFormComponents } from \"../typings\";\n\nexport const defaultFormComponents: Partial<PossibleFormComponents> = {\n Form,\n SmartForm: FormContainer,\n};\n// All those components are defined in each relevant package instead\nexport const defaultDatatableComponents = {};\nexport const defaultCellComponents = {};\nexport const defaultCoreComponents = {\n MutationButton,\n LoadingButton,\n};\n","// import { compose } from \"recompose\";\nimport React from \"react\";\n\nexport const Components = {}; // will be populated on startup\nexport const ComponentsTable = {}; // storage for infos about components\n\nexport const coreComponents = [\n \"Alert\",\n \"Button\",\n \"Modal\",\n \"ModalTrigger\",\n \"Table\",\n \"FormComponentCheckbox\",\n \"FormComponentCheckboxGroup\",\n \"FormComponentDate\",\n \"FormComponentDate2\",\n \"FormComponentDateTime\",\n \"FormComponentDefault\",\n \"FormComponentText\",\n \"FormComponentEmail\",\n \"FormComponentNumber\",\n \"FormComponentRadioGroup\",\n \"FormComponentSelect\",\n \"FormComponentSelectMultiple\",\n \"FormComponentStaticText\",\n \"FormComponentTextarea\",\n \"FormComponentTime\",\n \"FormComponentUrl\",\n \"FormComponentInner\",\n \"FormControl\",\n \"FormElement\",\n];\n\n/**\n * Register a Vulcan component with a name, a raw component than can be extended\n * and one or more optional higher order components.\n *\n * @param {String} name The name of the component to register.\n * @param {Component} rawComponent Interchangeable/extendable react component.\n * @param {...(Function|Array)} hocs The HOCs to compose with the raw component.\n *\n * Note: when a component is registered without higher order component, `hocs` will be\n * an empty array, and it's ok!\n * See https://github.com/reactjs/redux/blob/master/src/compose.js#L13-L15\n *\n * @returns Structure of a component in the list:\n *\n * ComponentsTable.Foo = {\n * name: 'Foo',\n * hocs: [fn1, fn2],\n * rawComponent: React.Component,\n * call: () => compose(...hocs)(rawComponent),\n * }\n *\n */\n/*\nexport function registerComponent(name, rawComponent, ...hocs) {\n // support single-argument syntax\n if (typeof arguments[0] === \"object\") {\n // note: cannot use `const` because name, components, hocs are already defined\n // as arguments so destructuring cannot work\n // eslint-disable-next-line no-redeclare\n var {\n name,\n component,\n // @ts-ignore\n hocs = [],\n } = arguments[0];\n rawComponent = component;\n }\n // store the component in the table\n ComponentsTable[name] = {\n name,\n rawComponent,\n hocs,\n };\n}\n*/\n\n/**\n * Returns true if a component with the given name has been registered with\n * registerComponent(name, component, ...hocs).\n *\n * @param {String} name The name of the component to get.\n * @returns {Boolean}\n */\nexport const componentExists = (name) => {\n const component = ComponentsTable[name];\n return !!component;\n};\n\n/**\n * Get a component registered with registerComponent(name, component, ...hocs).\n *\n * @param {String} name The name of the component to get.\n * @returns {Function|React Component} A (wrapped) React component\n */\n/*\nexport const getComponent = (name) => {\n const component = ComponentsTable[name];\n if (!component) {\n throw new Error(`Component ${name} not registered.`);\n }\n if (component.hocs && component.hocs.length) {\n const hocs = component.hocs.map((hoc) => {\n if (!Array.isArray(hoc)) {\n if (typeof hoc !== \"function\") {\n throw new Error(\n `In registered component ${name}, an hoc is of type ${typeof hoc}`\n );\n }\n return hoc;\n }\n const [actualHoc, ...args] = hoc;\n if (typeof actualHoc !== \"function\") {\n throw new Error(\n `In registered component ${name}, an hoc is of type ${typeof actualHoc}`\n );\n }\n return actualHoc(...args);\n });\n return compose(...hocs)(component.rawComponent);\n } else {\n return component.rawComponent;\n }\n};\n*/\n\n/**\n * Populate the lookup table for components to be callable\n * ℹ️ Called once on app startup\n **/\n/*\nexport const populateComponentsApp = () => {\n const registeredComponents = Object.keys(ComponentsTable);\n\n // loop over each component in the list\n registeredComponents.map((name) => {\n // populate an entry in the lookup table\n Components[name] = getComponent(name);\n\n // uncomment for debug\n // console.log('init component:', name);\n });\n\n const missingComponents = difference(coreComponents, registeredComponents);\n\n if (missingComponents.length) {\n // eslint-disable-next-line no-console\n console.warn(\n `Found the following missing core components: ${missingComponents.join(\n \", \"\n )}. Include a UI package such as vulcan:ui-bootstrap to add them.`\n );\n }\n};\n*/\n/**\n * Get the **raw** (original) component registered with registerComponent\n * without the possible HOCs wrapping it.\n *\n * @param {String} name The name of the component to get.\n * @returns {Function|React Component} An interchangeable/extendable React component\n */\nexport const getRawComponent = (name) => {\n return ComponentsTable[name].rawComponent;\n};\n\n/**\n * Replace a Vulcan component with the same name with a new component or\n * an extension of the raw component and one or more optional higher order components.\n * This function keeps track of the previous HOCs and wrap the new HOCs around previous ones\n *\n * @param {String} name The name of the component to register.\n * @param {React Component} newComponent Interchangeable/extendable component.\n * @param {...Function} newHocs The HOCs to compose with the raw component.\n * @returns {Function|React Component} A component callable with Components[name]\n *\n * Note: when a component is registered without higher order component, `hocs` will be\n * an empty array, and it's ok!\n * See https://github.com/reactjs/redux/blob/master/src/compose.js#L13-L15\n */\n/*\nexport function replaceComponent(name, newComponent, ...newHocs) {\n // support single argument syntax\n if (typeof arguments[0] === \"object\") {\n // eslint-disable-next-line no-redeclare\n var { name, component, hocs = [] } = arguments[0];\n newComponent = component;\n newHocs = hocs;\n }\n\n const previousComponent = ComponentsTable[name];\n const previousHocs = (previousComponent && previousComponent.hocs) || [];\n\n if (!previousComponent) {\n // eslint-disable-next-line no-console\n console.warn(\n `Trying to replace non-registered component ${name}. The component is ` +\n \"being registered. If you were trying to replace a component defined by \" +\n \"another package, make sure that you haven't misspelled the name. Check \" +\n \"also if the original component is still being registered or that it \" +\n \"hasn't been renamed.\"\n );\n }\n\n return registerComponent(name, newComponent, ...newHocs, ...previousHocs);\n}\n*/\n\n/*\nexport const copyHoCs = (sourceComponent, targetComponent) => {\n return compose(...sourceComponent.hocs)(targetComponent);\n};\n*/\n\n/**\n * Returns an instance of the given component name of function\n * @param {string|function} component A component, the name of a component, or a react element\n * @param {Object} [props] Optional properties to pass to the component\n */\n//eslint-disable-next-line react/display-name\n// legacy\nexport const instantiateComponent = (\n component?: React.ComponentType | Function | any,\n props?: any\n) => {\n if (!component) {\n return null;\n } /*else if (typeof component === \"string\") {\n const Component = Components[component];\n return <Component {...props} />;\n } */ else if (React.isValidElement(component)) {\n return React.cloneElement(component, props);\n } else if (\n typeof component === \"function\" &&\n component.prototype &&\n component.prototype.isReactComponent\n ) {\n const Component = component as React.ComponentType<any>;\n return <Component {...props} />;\n } else if (typeof component === \"function\") {\n return component(props);\n } else if (\n typeof component === \"object\" &&\n component.$$typeof &&\n component.render\n ) {\n const Component = component as React.ComponentType<any>;\n return <Component {...props} />;\n } else {\n return component;\n }\n};\n\n/**\n * Creates a component that will render the registered component with the given name.\n *\n * This function may be useful when in need for some registered component, but in contexts\n * where they have not yet been initialized, for example at compile time execution. In other\n * words, when using `Components.ComponentName` is not allowed (because it has not yet been\n * populated, hence would be `undefined`), then `delayedComponent('ComponentName')` can be\n * used instead.\n *\n * @example Create a container for a registered component\n * // SomeContainer.js\n * import compose from 'recompose/compose';\n * import { delayedComponent } from 'meteor/vulcan:core';\n *\n * export default compose(\n * // ...some hocs with container logic\n * )(delayedComponent('ComponentName')); // cannot use Components.ComponentName in this context!\n *\n * @example {@link dynamicLoader}\n * @param {String} name Component name\n * @return {Function}\n * Functional component that will render the given registered component\n */\nexport const delayedComponent = (name) => {\n return (props) => {\n const Component = Components[name] || null;\n return Component && <Component {...props} />;\n };\n};\n\n// Example with Proxy (might be unstable/hard to reason about)\n//const mergeWithComponents = (myComponents = {}) => {\n// const handler = {\n// get: function(target, name) {\n// return name in target ? target[name] : Components[name];\n// }\n// };\n// const proxy = new Proxy(myComponents, handler);\n// return proxy;\n//};\nexport const mergeWithComponents = (myComponents) =>\n myComponents ? { ...Components, ...myComponents } : Components;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AA4BkB,QAAA;AAClB,QAAI;AACJ,QAAI;AACJ,QAAI;AACJ,QAAI;AACJ,QAAI;AACJ,QAAI;AACJ,QAAI;AACJ,QA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C7D,SAAO;GAJqB;AAWvB,IAAM,6BAA6B,wBAAC,WAAW,WAAW;AAC/D,QAAM,kBAAkB,qBAAqB,WAAW,MAAM;AAC9D,MAAI,CAAC,iBAAiB;AAEpB,UAAM,mBAAmB,sBAAsB,WAAW,MAAM;AAEhE,QAAI,CAAC;AAAkB,aAAO;AAC9B,WAAO;;AAET,SAAO;GATiC;AAYnC,IAAM,mBAAmB;EAC9B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGK,IAAM,iBAAiB;EAC5B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;;AG3OF;AACA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA0BO,IAAM,WAAW,wBACtB,OACA,YACA,SACA,WACA,gBACG;AACH,QAAM,iBAAiB,MAAM,KAAK,YAAW;AAC7C,QAAM,QAAQ,YAAY;IACxB,MAAM;IACN;IACA;IACA,QAAQ;GACT;AACD,MAAI,aAAa;AACf,UAAM,kBAAkB,QAAQ,cAAc;MAC5C,IAAI,WAAW;MACf,gBAAgB;KACjB;AACD,WAAO,GAAG,UAAU;SACf;AACL,WAAO;;GArBa;AA+BxB,IAAM,iBAAiB,wBACrB,OACA,YACA,SACA,cACG;AACH,QAAM,iBAAiB,MAAM,KAAK,YAAW;AAC7C,QAAM,cAAc,aAAa;IAC/B,MAAM;IACN;IACA;IACA,QAAQ;IACR,eAAe;GAChB;AACD,SAAO,eAAe;GAdD;A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AU;AAChB,UAAM,YAAY,WAAW,SAAS;AACtC,WAAO,aAAa,wBAAA,cAAC,WAAS,UAAA,CAAA,GAAK,KAAK,CAAA;;GAHZ;AAiBzB,IAAM,sBAAsB,wBAAC,iBAClC,eAAe,kCAAK,aAAe,gBAAiB,YADnB;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vulcanjs/react-ui",
3
- "version": "0.7.2-alpha.8",
3
+ "version": "0.8.0",
4
4
  "description": "Vulcan UI components for React",
5
5
  "main": "./dist/index.js",
6
6
  "files": [
@@ -56,5 +56,5 @@
56
56
  "publishConfig": {
57
57
  "access": "public"
58
58
  },
59
- "gitHead": "11175c232e4155762cffc40ac1509dae0519afe3"
59
+ "gitHead": "5652c5b76efc47bc962987bac33c12384e9574ae"
60
60
  }