@oneblink/apps-react 13.4.0 → 13.5.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/OneBlinkFormBase.js +6 -2
  2. package/dist/OneBlinkFormBase.js.map +1 -1
  3. package/dist/apps/services/api/drafts.js +5 -2
  4. package/dist/apps/services/api/drafts.js.map +1 -1
  5. package/dist/apps/services/prepareSubmissionData.d.ts +14 -0
  6. package/dist/apps/services/prepareSubmissionData.js +27 -0
  7. package/dist/apps/services/prepareSubmissionData.js.map +1 -1
  8. package/dist/components/renderer/OneBlinkFormElements.js +2 -2
  9. package/dist/components/renderer/OneBlinkFormElements.js.map +1 -1
  10. package/dist/form-elements/FormElementLookupButton.js +7 -2
  11. package/dist/form-elements/FormElementLookupButton.js.map +1 -1
  12. package/dist/form-elements/FormElementRepeatableSet.js +17 -7
  13. package/dist/form-elements/FormElementRepeatableSet.js.map +1 -1
  14. package/dist/form-elements/FormElementSection.js +2 -1
  15. package/dist/form-elements/FormElementSection.js.map +1 -1
  16. package/dist/hooks/useConditionalLogic.js +3 -1
  17. package/dist/hooks/useConditionalLogic.js.map +1 -1
  18. package/dist/hooks/useFormElementOptions.js +13 -2
  19. package/dist/hooks/useFormElementOptions.js.map +1 -1
  20. package/dist/hooks/useFormSubmissionModelContext.d.ts +19 -1
  21. package/dist/hooks/useFormSubmissionModelContext.js +60 -14
  22. package/dist/hooks/useFormSubmissionModelContext.js.map +1 -1
  23. package/dist/hooks/useStructuralSharing.d.ts +9 -0
  24. package/dist/hooks/useStructuralSharing.js +20 -0
  25. package/dist/hooks/useStructuralSharing.js.map +1 -0
  26. package/dist/services/form-validation/validators.js +3 -0
  27. package/dist/services/form-validation/validators.js.map +1 -1
  28. package/dist/types/form.d.ts +4 -0
  29. package/dist/types/form.js.map +1 -1
  30. package/dist/utils/replaceEqualDeep.d.ts +14 -0
  31. package/dist/utils/replaceEqualDeep.js +58 -0
  32. package/dist/utils/replaceEqualDeep.js.map +1 -0
  33. package/package.json +5 -3
@@ -1,32 +1,78 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
+ import { weakMapMemoize } from 'reselect';
3
4
  import cleanFormSubmissionModel from '../services/cleanFormSubmissionModel';
5
+ // The local value is kept separate from the context that includes `parent` so
6
+ // that consumers inside a repeatable set entry do not re-render whenever a value
7
+ // outside of the entry changes. A separate context is used for each level of
8
+ // nesting because React re-renders every consumer of a context below a provider
9
+ // whose value changed, even consumers below a nested provider of the same
10
+ // context.
11
+ const LocalFormSubmissionModelContexts = [];
12
+ function getLocalFormSubmissionModelContext(depth) {
13
+ let context = LocalFormSubmissionModelContexts[depth];
14
+ if (!context) {
15
+ context = React.createContext(undefined);
16
+ LocalFormSubmissionModelContexts[depth] = context;
17
+ }
18
+ return context;
19
+ }
20
+ const FormSubmissionModelDepthContext = React.createContext(-1);
21
+ function useLocalFormSubmissionModelContext() {
22
+ const depth = React.useContext(FormSubmissionModelDepthContext);
23
+ return getLocalFormSubmissionModelContext(depth);
24
+ }
4
25
  const FormSubmissionModelContext = React.createContext(undefined);
26
+ // Every page and section provider cleans the same root submission, so the
27
+ // result is shared between providers rendered with the same arguments. This
28
+ // relies on nothing mutating the submission, elements or cleaned models in
29
+ // place.
30
+ const getCleanFormSubmissionModel = weakMapMemoize((model, elements, formElementsConditionallyShown) => cleanFormSubmissionModel(model, elements, formElementsConditionallyShown, true).model);
5
31
  export function FormSubmissionModelContextProvider({ children, model, elements, formElementsConditionallyShown, }) {
6
32
  const formSubmissionModelContext = React.useContext(FormSubmissionModelContext);
33
+ const depth = React.useContext(FormSubmissionModelDepthContext) + 1;
34
+ const LocalFormSubmissionModelContext = getLocalFormSubmissionModelContext(depth);
35
+ const localValue = React.useMemo(() => {
36
+ return {
37
+ formSubmissionModel: getCleanFormSubmissionModel(model, elements, formElementsConditionallyShown),
38
+ elements,
39
+ };
40
+ }, [model, elements, formElementsConditionallyShown]);
7
41
  const value = React.useMemo(() => {
8
42
  return {
9
- formSubmissionModel: cleanFormSubmissionModel(model, elements, formElementsConditionallyShown, true).model,
43
+ ...localValue,
10
44
  parent: formSubmissionModelContext,
11
- elements,
12
45
  };
13
- }, [
14
- model,
15
- elements,
16
- formElementsConditionallyShown,
17
- formSubmissionModelContext,
18
- ]);
19
- return (_jsx(FormSubmissionModelContext.Provider, { value: value, children: children }));
46
+ }, [localValue, formSubmissionModelContext]);
47
+ return (_jsx(FormSubmissionModelContext.Provider, { value: value, children: _jsx(FormSubmissionModelDepthContext.Provider, { value: depth, children: _jsx(LocalFormSubmissionModelContext.Provider, { value: localValue, children: children }) }) }));
20
48
  }
21
- export default function useFormSubmissionModel() {
22
- const formSubmissionModelContext = React.useContext(FormSubmissionModelContext);
23
- if (!formSubmissionModelContext) {
49
+ function assertContextValue(value) {
50
+ if (!value) {
24
51
  throw new Error('"FormSubmissionModelContext" does not have a value in this context');
25
52
  }
26
- return formSubmissionModelContext;
53
+ return value;
54
+ }
55
+ /**
56
+ * The cleaned submission model and elements for the closest
57
+ * `FormSubmissionModelContextProvider`, without access to parent models.
58
+ */
59
+ export default function useFormSubmissionModel() {
60
+ const LocalFormSubmissionModelContext = useLocalFormSubmissionModelContext();
61
+ return assertContextValue(React.use(LocalFormSubmissionModelContext));
62
+ }
63
+ /**
64
+ * The same as `useFormSubmissionModel()`, but also includes the parent models.
65
+ * Pass `includeParent: false` to avoid re-rendering when values outside of the
66
+ * closest `FormSubmissionModelContextProvider` change.
67
+ */
68
+ export function useFormSubmissionModelWithParent(includeParent) {
69
+ const LocalFormSubmissionModelContext = useLocalFormSubmissionModelContext();
70
+ return assertContextValue(React.use(includeParent
71
+ ? FormSubmissionModelContext
72
+ : LocalFormSubmissionModelContext));
27
73
  }
28
74
  export function useFormSubmissionModelParent() {
29
- let formSubmissionModelContext = useFormSubmissionModel();
75
+ let formSubmissionModelContext = assertContextValue(React.useContext(FormSubmissionModelContext));
30
76
  while (formSubmissionModelContext.parent) {
31
77
  formSubmissionModelContext = formSubmissionModelContext.parent;
32
78
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useFormSubmissionModelContext.js","sourceRoot":"","sources":["../../src/hooks/useFormSubmissionModelContext.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,wBAAwB,MAAM,sCAAsC,CAAA;AAS3E,MAAM,0BAA0B,GAAG,KAAK,CAAC,aAAa,CAEpD,SAAS,CAAC,CAAA;AAEZ,MAAM,UAAU,kCAAkC,CAAC,EACjD,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,8BAA8B,GAM/B;IACC,MAAM,0BAA0B,GAAG,KAAK,CAAC,UAAU,CACjD,0BAA0B,CAC3B,CAAA;IACD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAC/B,OAAO;YACL,mBAAmB,EAAE,wBAAwB,CAC3C,KAAK,EACL,QAAQ,EACR,8BAA8B,EAC9B,IAAI,CACL,CAAC,KAAK;YACP,MAAM,EAAE,0BAA0B;YAClC,QAAQ;SACT,CAAA;IACH,CAAC,EAAE;QACD,KAAK;QACL,QAAQ;QACR,8BAA8B;QAC9B,0BAA0B;KAC3B,CAAC,CAAA;IACF,OAAO,CACL,KAAC,0BAA0B,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAC9C,QAAQ,GAC2B,CACvC,CAAA;AACH,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,sBAAsB;IAC5C,MAAM,0BAA0B,GAAG,KAAK,CAAC,UAAU,CACjD,0BAA0B,CAC3B,CAAA;IACD,IAAI,CAAC,0BAA0B,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CACb,oEAAoE,CACrE,CAAA;IACH,CAAC;IACD,OAAO,0BAA0B,CAAA;AACnC,CAAC;AAED,MAAM,UAAU,4BAA4B;IAC1C,IAAI,0BAA0B,GAAG,sBAAsB,EAAE,CAAA;IACzD,OAAO,0BAA0B,CAAC,MAAM,EAAE,CAAC;QACzC,0BAA0B,GAAG,0BAA0B,CAAC,MAAM,CAAA;IAChE,CAAC;IACD,OAAO,0BAA0B,CAAA;AACnC,CAAC","sourcesContent":["import { FormTypes, SubmissionTypes } from '@oneblink/types'\nimport { FormElement } from '@oneblink/types/typescript/forms'\nimport * as React from 'react'\nimport cleanFormSubmissionModel from '../services/cleanFormSubmissionModel'\nimport { FormElementsConditionallyShown } from '../types/form'\n\nexport type FormSubmissionModelContextValue = {\n formSubmissionModel: SubmissionTypes.S3SubmissionData['submission']\n parent?: FormSubmissionModelContextValue\n elements: FormElement[]\n}\n\nconst FormSubmissionModelContext = React.createContext<\n FormSubmissionModelContextValue | undefined\n>(undefined)\n\nexport function FormSubmissionModelContextProvider({\n children,\n model,\n elements,\n formElementsConditionallyShown,\n}: {\n model: SubmissionTypes.S3SubmissionData['submission']\n elements: FormTypes.FormElement[]\n formElementsConditionallyShown: FormElementsConditionallyShown | undefined\n children: React.ReactNode\n}) {\n const formSubmissionModelContext = React.useContext(\n FormSubmissionModelContext,\n )\n const value = React.useMemo(() => {\n return {\n formSubmissionModel: cleanFormSubmissionModel(\n model,\n elements,\n formElementsConditionallyShown,\n true,\n ).model,\n parent: formSubmissionModelContext,\n elements,\n }\n }, [\n model,\n elements,\n formElementsConditionallyShown,\n formSubmissionModelContext,\n ])\n return (\n <FormSubmissionModelContext.Provider value={value}>\n {children}\n </FormSubmissionModelContext.Provider>\n )\n}\n\nexport default function useFormSubmissionModel() {\n const formSubmissionModelContext = React.useContext(\n FormSubmissionModelContext,\n )\n if (!formSubmissionModelContext) {\n throw new Error(\n '\"FormSubmissionModelContext\" does not have a value in this context',\n )\n }\n return formSubmissionModelContext\n}\n\nexport function useFormSubmissionModelParent() {\n let formSubmissionModelContext = useFormSubmissionModel()\n while (formSubmissionModelContext.parent) {\n formSubmissionModelContext = formSubmissionModelContext.parent\n }\n return formSubmissionModelContext\n}\n"]}
1
+ {"version":3,"file":"useForm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C;AAED;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAC9C,aAAsB;IAItB,MAAM,+BAA+B,GAAG,kCAAkC,EAAE,CAAA;IAC5E,OAAO,kBAAkB,CACvB,KAAK,CAAC,GAAG,CACP,aAAa;QACX,CAAC,CAAC,0BAA0B;QAC5B,CAAC,CAAC,+BAA+B,CACpC,CACF,CAAA;AACH,CAAC;AAED,MAAM,UAAU,4BAA4B;IAC1C,IAAI,0BAA0B,GAAG,kBAAkB,CACjD,KAAK,CAAC,UAAU,CAAC,0BAA0B,CAAC,CAC7C,CAAA;IACD,OAAO,0BAA0B,CAAC,MAAM,EAAE,CAAC;QACzC,0BAA0B,GAAG,0BAA0B,CAAC,MAAM,CAAA;IAChE,CAAC;IACD,OAAO,0BAA0B,CAAA;AACnC,CAAC","sourcesContent":["import { FormTypes, SubmissionTypes } from '@oneblink/types'\nimport { FormElement } from '@oneblink/types/typescript/forms'\nimport * as React from 'react'\nimport { weakMapMemoize } from 'reselect'\nimport cleanFormSubmissionModel from '../services/cleanFormSubmissionModel'\nimport { FormElementsConditionallyShown } from '../types/form'\n\nexport type FormSubmissionModelContextValue = {\n /**\n * Must not be mutated in place, the same object is cached and shared between\n * every provider and consumer rendered with the same submission.\n */\n formSubmissionModel: SubmissionTypes.S3SubmissionData['submission']\n parent?: FormSubmissionModelContextValue\n elements: FormElement[]\n}\n\ntype LocalFormSubmissionModelContextValue = Omit<\n FormSubmissionModelContextValue,\n 'parent'\n>\n\n// The local value is kept separate from the context that includes `parent` so\n// that consumers inside a repeatable set entry do not re-render whenever a value\n// outside of the entry changes. A separate context is used for each level of\n// nesting because React re-renders every consumer of a context below a provider\n// whose value changed, even consumers below a nested provider of the same\n// context.\nconst LocalFormSubmissionModelContexts: Array<\n React.Context<LocalFormSubmissionModelContextValue | undefined>\n> = []\nfunction getLocalFormSubmissionModelContext(depth: number) {\n let context = LocalFormSubmissionModelContexts[depth]\n if (!context) {\n context = React.createContext<\n LocalFormSubmissionModelContextValue | undefined\n >(undefined)\n LocalFormSubmissionModelContexts[depth] = context\n }\n return context\n}\nconst FormSubmissionModelDepthContext = React.createContext(-1)\n\nfunction useLocalFormSubmissionModelContext() {\n const depth = React.useContext(FormSubmissionModelDepthContext)\n return getLocalFormSubmissionModelContext(depth)\n}\n\nconst FormSubmissionModelContext = React.createContext<\n FormSubmissionModelContextValue | undefined\n>(undefined)\n\n// Every page and section provider cleans the same root submission, so the\n// result is shared between providers rendered with the same arguments. This\n// relies on nothing mutating the submission, elements or cleaned models in\n// place.\nconst getCleanFormSubmissionModel = weakMapMemoize(\n (\n model: SubmissionTypes.S3SubmissionData['submission'],\n elements: FormTypes.FormElement[],\n formElementsConditionallyShown: FormElementsConditionallyShown | undefined,\n ) =>\n cleanFormSubmissionModel(\n model,\n elements,\n formElementsConditionallyShown,\n true,\n ).model,\n)\n\nexport function FormSubmissionModelContextProvider({\n children,\n model,\n elements,\n formElementsConditionallyShown,\n}: {\n model: SubmissionTypes.S3SubmissionData['submission']\n elements: FormTypes.FormElement[]\n formElementsConditionallyShown: FormElementsConditionallyShown | undefined\n children: React.ReactNode\n}) {\n const formSubmissionModelContext = React.useContext(\n FormSubmissionModelContext,\n )\n const depth = React.useContext(FormSubmissionModelDepthContext) + 1\n const LocalFormSubmissionModelContext =\n getLocalFormSubmissionModelContext(depth)\n const localValue = React.useMemo(() => {\n return {\n formSubmissionModel: getCleanFormSubmissionModel(\n model,\n elements,\n formElementsConditionallyShown,\n ),\n elements,\n }\n }, [model, elements, formElementsConditionallyShown])\n const value = React.useMemo(() => {\n return {\n ...localValue,\n parent: formSubmissionModelContext,\n }\n }, [localValue, formSubmissionModelContext])\n return (\n <FormSubmissionModelContext.Provider value={value}>\n <FormSubmissionModelDepthContext.Provider value={depth}>\n <LocalFormSubmissionModelContext.Provider value={localValue}>\n {children}\n </LocalFormSubmissionModelContext.Provider>\n </FormSubmissionModelDepthContext.Provider>\n </FormSubmissionModelContext.Provider>\n )\n}\n\nfunction assertContextValue<T>(value: T | undefined): T {\n if (!value) {\n throw new Error(\n '\"FormSubmissionModelContext\" does not have a value in this context',\n )\n }\n return value\n}\n\n/**\n * The cleaned submission model and elements for the closest\n * `FormSubmissionModelContextProvider`, without access to parent models.\n */\nexport default function useFormSubmissionModel() {\n const LocalFormSubmissionModelContext = useLocalFormSubmissionModelContext()\n return assertContextValue(React.use(LocalFormSubmissionModelContext))\n}\n\n/**\n * The same as `useFormSubmissionModel()`, but also includes the parent models.\n * Pass `includeParent: false` to avoid re-rendering when values outside of the\n * closest `FormSubmissionModelContextProvider` change.\n */\nexport function useFormSubmissionModelWithParent(\n includeParent: boolean,\n): LocalFormSubmissionModelContextValue & {\n parent?: FormSubmissionModelContextValue\n} {\n const LocalFormSubmissionModelContext = useLocalFormSubmissionModelContext()\n return assertContextValue(\n React.use(\n includeParent\n ? FormSubmissionModelContext\n : LocalFormSubmissionModelContext,\n ),\n )\n}\n\nexport function useFormSubmissionModelParent() {\n let formSubmissionModelContext = assertContextValue(\n React.useContext(FormSubmissionModelContext),\n )\n while (formSubmissionModelContext.parent) {\n formSubmissionModelContext = formSubmissionModelContext.parent\n }\n return formSubmissionModelContext\n}\n"]}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Returns a value deeply equal to `value` that reuses object instances from the
3
+ * previously returned value wherever they are deeply equal.
4
+ *
5
+ * The returned value must never be mutated in place: unchanged objects are
6
+ * reused on later renders, and memoised components skip rendering when they
7
+ * receive the same object, so a mutation would leave them showing stale data.
8
+ */
9
+ export default function useStructuralSharing<T>(value: T): T;
@@ -0,0 +1,20 @@
1
+ import * as React from 'react';
2
+ import replaceEqualDeep from '../utils/replaceEqualDeep';
3
+ /**
4
+ * Returns a value deeply equal to `value` that reuses object instances from the
5
+ * previously returned value wherever they are deeply equal.
6
+ *
7
+ * The returned value must never be mutated in place: unchanged objects are
8
+ * reused on later renders, and memoised components skip rendering when they
9
+ * receive the same object, so a mutation would leave them showing stale data.
10
+ */
11
+ export default function useStructuralSharing(value) {
12
+ const [state, setState] = React.useState({ value, sharedValue: value });
13
+ if (state.value === value) {
14
+ return state.sharedValue;
15
+ }
16
+ const sharedValue = replaceEqualDeep(state.sharedValue, value);
17
+ setState({ value, sharedValue });
18
+ return sharedValue;
19
+ }
20
+ //# sourceMappingURL=useStructuralSharing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStructuralSharing.js","sourceRoot":"","sources":["../../src/hooks/useStructuralSharing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,gBAAgB,MAAM,2BAA2B,CAAA;AAExD;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAI,KAAQ;IACtD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAA;IACvE,IAAI,KAAK,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC,WAAW,CAAA;IAC1B,CAAC;IACD,MAAM,WAAW,GAAG,gBAAgB,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;IAC9D,QAAQ,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAA;IAChC,OAAO,WAAW,CAAA;AACpB,CAAC","sourcesContent":["import * as React from 'react'\nimport replaceEqualDeep from '../utils/replaceEqualDeep'\n\n/**\n * Returns a value deeply equal to `value` that reuses object instances from the\n * previously returned value wherever they are deeply equal.\n *\n * The returned value must never be mutated in place: unchanged objects are\n * reused on later renders, and memoised components skip rendering when they\n * receive the same object, so a mutation would leave them showing stale data.\n */\nexport default function useStructuralSharing<T>(value: T): T {\n const [state, setState] = React.useState({ value, sharedValue: value })\n if (state.value === value) {\n return state.sharedValue\n }\n const sharedValue = replaceEqualDeep(state.sharedValue, value)\n setState({ value, sharedValue })\n return sharedValue\n}\n"]}
@@ -10,6 +10,9 @@ export function getCleanDateRangeConfiguration(options, elements, submission, fo
10
10
  return [options.date, options.daysOffset];
11
11
  }
12
12
  export function getCleanRepeatableSetConfiguration(setEntries, elements, submission, formElementsConditionallyShown) {
13
+ if (typeof setEntries !== 'object') {
14
+ return getRepeatableSetEntriesConfiguration(setEntries, elements, {});
15
+ }
13
16
  if (submission) {
14
17
  const { model } = cleanFormSubmissionModel(submission, elements, formElementsConditionallyShown, true);
15
18
  return getRepeatableSetEntriesConfiguration(setEntries, elements, model);
@@ -1 +1 @@
1
- {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../src/services/form-validation/validators.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,yBAEN,MAAM,8BAA8B,CAAA;AAKrC,OAAO,wBAAwB,MAAM,6BAA6B,CAAA;AAClE,OAAO,oCAAoC,MAAM,yCAAyC,CAAA;AAI1F,MAAM,UAAU,8BAA8B,CAC5C,OAAsC,EACtC,QAAiC,EACjC,UAAsE,EACtE,8BAA0E;IAE1E,IAAI,OAAO,CAAC,sBAAsB,IAAI,UAAU,EAAE,CAAC;QACjD,MAAM,EAAE,KAAK,EAAE,GAAG,wBAAwB,CACxC,UAAU,EACV,QAAQ,EACR,8BAA8B,EAC9B,IAAI,CACL,CAAA;QACD,OAAO,yBAAyB,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAA;IAC5D,CAAC;IACD,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,CAAA;AAC3C,CAAC;AAED,MAAM,UAAU,kCAAkC,CAChD,UAA2D,EAC3D,QAAiC,EACjC,UAAsE,EACtE,8BAA0E;IAE1E,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,EAAE,KAAK,EAAE,GAAG,wBAAwB,CACxC,UAAU,EACV,QAAQ,EACR,8BAA8B,EAC9B,IAAI,CACL,CAAA;QACD,OAAO,oCAAoC,CA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sB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;YAC7C,CAAC;YACD,OAAO,sBAAsB,CAAA;QAC/B,CAAC,EACD,EAAE,CACH,CAAA;QACD,IAAI,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,MAAM,EAAE,CAAC;YACnC,OAAO,CAAC,GAAG,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAA;QACxE,CAAC;QACD,OAAO,EAAE,CAAA;IACX,CAAC;IACD,IAAI,YAAY,CAAA;IAChB,IAAI,kBAAkB,EAAE,CAAC;QACvB,YAAY,GAAG,2DAA2D,CAAA;IAC5E,CAAC;IACD,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,YAAY,GAAG,qCAAqC,CAAA;QAC1D,YAAY,GAAG,YAAY;YACzB,CAAC,CAAC,GAAG,YAAY,IAAI,YAAY,EAAE;YACnC,CAAC,CAAC,YAAY,CAAA;IAClB,CAAC;IACD,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,CAAC,YAAY,CAAC,CAAA;IACvB,CAAC;IAED,OAAO,EAAE,CAAA;AACX,CAAC;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAC7C,kBAAoE,EACpE,eAAmC,EACnC,EAAE;IACF,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO,eAAe,CAAA;IACxB,CAAC;IACD,IAAI,kBAAkB,IAAI,kBAAkB,CAAC,KAAK,EAAE,CAAC;QACnD,OAAO,GAAG,kBAAkB,CAAC,KAAK,cAAc,CAAA;IAClD,CAAC;IACD,OAAO,oBAAoB,CAAA;AAC7B,CAAC,CAAA","sourcesContent":["import { EnvironmentTypes, FormTypes, SubmissionTypes } from '@oneblink/types'\nimport { fileUploadService } from '@oneblink/sdk-core'\nimport getDateRangeConfiguration, {\n DateRangeConfigurationOptions,\n} from '../getDateRangeConfiguration'\nimport {\n FormElementsConditionallyShown,\n FormElementsValidation,\n} from '../../types/form'\nimport cleanFormSubmissionModel from '../cleanFormSubmissionModel'\nimport getRepeatableSetEntriesConfiguration from '../getRepeatableSetEntriesConfiguration'\nimport { attachmentsService } from '../../apps'\nimport { FormElementBinaryStorageValue } from '../../types/attachments'\n\nexport function getCleanDateRangeConfiguration(\n options: DateRangeConfigurationOptions,\n elements: FormTypes.FormElement[],\n submission: SubmissionTypes.S3SubmissionData['submission'] | undefined,\n formElementsConditionallyShown: FormElementsConditionallyShown | undefined,\n): ReturnType<typeof getDateRangeConfiguration> {\n if (options.referenceFormElementId && submission) {\n const { model } = cleanFormSubmissionModel(\n submission,\n elements,\n formElementsConditionallyShown,\n true,\n )\n return getDateRangeConfiguration(options, elements, model)\n }\n return [options.date, options.daysOffset]\n}\n\nexport function getCleanRepeatableSetConfiguration(\n setEntries: FormTypes.RepeatableSetElement['minSetEntries'],\n elements: FormTypes.FormElement[],\n submission: SubmissionTypes.S3SubmissionData['submission'] | undefined,\n formElementsConditionallyShown: FormElementsConditionallyShown | undefined,\n) {\n if (submission) {\n const { model } = cleanFormSubmissionModel(\n submission,\n elements,\n formElementsConditionallyShown,\n true,\n )\n return getRepeatableSetEntriesConfiguration(setEntries, elements, model)\n }\n}\n\nexport function checkFileNameIsValid(\n formElement: FormTypes.FilesElement,\n fileName: string,\n) {\n const extension = fileName.split('.').pop()\n return (\n formElement.restrictedFileTypes || fileUploadService.restrictedFileTypes\n ).some((fileType) => fileType.toLowerCase() === extension?.toLowerCase())\n}\n\nexport function checkFileNameExtensionIsValid(\n formElement: FormTypes.FilesElement,\n fileName: string,\n) {\n return (\n formElement.allowExtensionlessAttachments || fileName.split('.').length >= 2\n )\n}\n\nexport function checkSectionValidity(\n element: FormTypes.PageElement | FormTypes.SectionElement,\n formElementsValidation: FormElementsValidation | undefined,\n): boolean {\n // If everything is valid, no need to check elements\n if (!formElementsValidation) {\n return false\n }\n\n // If there is no elements on the page that are invalid, we will treat as valid\n return element.elements.some((formElement) => {\n switch (formElement.type) {\n case 'page':\n case 'section': {\n return checkSectionValidity(formElement, formElementsValidation)\n }\n default: {\n return formElementsValidation[formElement.name]\n }\n }\n })\n}\n\nexport function getInvalidAttachment(\n value: unknown,\n): attachmentsService.AttachmentError | undefined {\n if (\n value &&\n typeof value === 'object' &&\n 'type' in value &&\n value.type === 'ERROR'\n ) {\n return value as attachmentsService.AttachmentError\n }\n}\n\nexport function validateAttachments(\n value: FormElementBinaryStorageValue[] | undefined,\n): string[] {\n const exceedsMaximumSize = value?.some((att) => {\n const invalidAttachment = getInvalidAttachment(att)\n if (\n invalidAttachment?.fileName &&\n invalidAttachment?.errorType === 'EXCEEDS_MAX_SIZE'\n ) {\n return true\n }\n })\n const emptyFiles = value?.some((att) => {\n const invalidAttachment = getInvalidAttachment(att)\n if (\n invalidAttachment?.fileName &&\n invalidAttachment?.errorType === 'EMPTY_FILE'\n ) {\n return true\n }\n })\n if (!exceedsMaximumSize && !emptyFiles) {\n const invalidAttachmentNames = value?.reduce(\n (invalidAttachmentNames: string[], att) => {\n const attachmentName = getInvalidAttachment(att)?.fileName\n if (attachmentName) {\n invalidAttachmentNames.push(attachmentName)\n }\n return invalidAttachmentNames\n },\n [],\n )\n if (invalidAttachmentNames?.length) {\n return [`${invalidAttachmentNames.join(', ')} could not be uploaded.`]\n }\n return []\n }\n let errorMessage\n if (exceedsMaximumSize) {\n errorMessage = 'One or more of the files exceed the maximum size allowed.'\n }\n if (emptyFiles) {\n const emptyMessage = 'One or more of the files are empty.'\n errorMessage = errorMessage\n ? `${errorMessage} ${emptyMessage}`\n : emptyMessage\n }\n if (errorMessage) {\n return [errorMessage]\n }\n\n return []\n}\n\nexport const generateLookupValidationMessage = (\n lookupButtonConfig: EnvironmentTypes.ButtonConfiguration | undefined,\n overrideMessage: string | undefined,\n) => {\n if (overrideMessage) {\n return overrideMessage\n }\n if (lookupButtonConfig && lookupButtonConfig.label) {\n return `${lookupButtonConfig.label} is required`\n }\n return 'Lookup is required'\n}\n"]}
1
+ {"version":3,"file":"validators.js","sourceRoot":"","sources":["../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AI,CAAC,yBAAyB,CAAC,CAAA;QACxE,CAAC;QACD,OAAO,EAAE,CAAA;IACX,CAAC;IACD,IAAI,YAAY,CAAA;IAChB,IAAI,kBAAkB,EAAE,CAAC;QACvB,YAAY,GAAG,2DAA2D,CAAA;IAC5E,CAAC;IACD,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,YAAY,GAAG,qCAAqC,CAAA;QAC1D,YAAY,GAAG,YAAY;YACzB,CAAC,CAAC,GAAG,YAAY,IAAI,YAAY,EAAE;YACnC,CAAC,CAAC,YAAY,CAAA;IAClB,CAAC;IACD,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,CAAC,YAAY,CAAC,CAAA;IACvB,CAAC;IAED,OAAO,EAAE,CAAA;AACX,CAAC;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAC7C,kBAAoE,EACpE,eAAmC,EACnC,EAAE;IACF,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO,eAAe,CAAA;IACxB,CAAC;IACD,IAAI,kBAAkB,IAAI,kBAAkB,CAAC,KAAK,EAAE,CAAC;QACnD,OAAO,GAAG,kBAAkB,CAAC,KAAK,cAAc,CAAA;IAClD,CAAC;IACD,OAAO,oBAAoB,CAAA;AAC7B,CAAC,CAAA","sourcesContent":["import { EnvironmentTypes, FormTypes, SubmissionTypes } from '@oneblink/types'\nimport { fileUploadService } from '@oneblink/sdk-core'\nimport getDateRangeConfiguration, {\n DateRangeConfigurationOptions,\n} from '../getDateRangeConfiguration'\nimport {\n FormElementsConditionallyShown,\n FormElementsValidation,\n} from '../../types/form'\nimport cleanFormSubmissionModel from '../cleanFormSubmissionModel'\nimport getRepeatableSetEntriesConfiguration from '../getRepeatableSetEntriesConfiguration'\nimport { attachmentsService } from '../../apps'\nimport { FormElementBinaryStorageValue } from '../../types/attachments'\n\nexport function getCleanDateRangeConfiguration(\n options: DateRangeConfigurationOptions,\n elements: FormTypes.FormElement[],\n submission: SubmissionTypes.S3SubmissionData['submission'] | undefined,\n formElementsConditionallyShown: FormElementsConditionallyShown | undefined,\n): ReturnType<typeof getDateRangeConfiguration> {\n if (options.referenceFormElementId && submission) {\n const { model } = cleanFormSubmissionModel(\n submission,\n elements,\n formElementsConditionallyShown,\n true,\n )\n return getDateRangeConfiguration(options, elements, model)\n }\n return [options.date, options.daysOffset]\n}\n\nexport function getCleanRepeatableSetConfiguration(\n setEntries: FormTypes.RepeatableSetElement['minSetEntries'],\n elements: FormTypes.FormElement[],\n submission: SubmissionTypes.S3SubmissionData['submission'] | undefined,\n formElementsConditionallyShown: FormElementsConditionallyShown | undefined,\n) {\n if (typeof setEntries !== 'object') {\n return getRepeatableSetEntriesConfiguration(setEntries, elements, {})\n }\n if (submission) {\n const { model } = cleanFormSubmissionModel(\n submission,\n elements,\n formElementsConditionallyShown,\n true,\n )\n return getRepeatableSetEntriesConfiguration(setEntries, elements, model)\n }\n}\n\nexport function checkFileNameIsValid(\n formElement: FormTypes.FilesElement,\n fileName: string,\n) {\n const extension = fileName.split('.').pop()\n return (\n formElement.restrictedFileTypes || fileUploadService.restrictedFileTypes\n ).some((fileType) => fileType.toLowerCase() === extension?.toLowerCase())\n}\n\nexport function checkFileNameExtensionIsValid(\n formElement: FormTypes.FilesElement,\n fileName: string,\n) {\n return (\n formElement.allowExtensionlessAttachments || fileName.split('.').length >= 2\n )\n}\n\nexport function checkSectionValidity(\n element: FormTypes.PageElement | FormTypes.SectionElement,\n formElementsValidation: FormElementsValidation | undefined,\n): boolean {\n // If everything is valid, no need to check elements\n if (!formElementsValidation) {\n return false\n }\n\n // If there is no elements on the page that are invalid, we will treat as valid\n return element.elements.some((formElement) => {\n switch (formElement.type) {\n case 'page':\n case 'section': {\n return checkSectionValidity(formElement, formElementsValidation)\n }\n default: {\n return formElementsValidation[formElement.name]\n }\n }\n })\n}\n\nexport function getInvalidAttachment(\n value: unknown,\n): attachmentsService.AttachmentError | undefined {\n if (\n value &&\n typeof value === 'object' &&\n 'type' in value &&\n value.type === 'ERROR'\n ) {\n return value as attachmentsService.AttachmentError\n }\n}\n\nexport function validateAttachments(\n value: FormElementBinaryStorageValue[] | undefined,\n): string[] {\n const exceedsMaximumSize = value?.some((att) => {\n const invalidAttachment = getInvalidAttachment(att)\n if (\n invalidAttachment?.fileName &&\n invalidAttachment?.errorType === 'EXCEEDS_MAX_SIZE'\n ) {\n return true\n }\n })\n const emptyFiles = value?.some((att) => {\n const invalidAttachment = getInvalidAttachment(att)\n if (\n invalidAttachment?.fileName &&\n invalidAttachment?.errorType === 'EMPTY_FILE'\n ) {\n return true\n }\n })\n if (!exceedsMaximumSize && !emptyFiles) {\n const invalidAttachmentNames = value?.reduce(\n (invalidAttachmentNames: string[], att) => {\n const attachmentName = getInvalidAttachment(att)?.fileName\n if (attachmentName) {\n invalidAttachmentNames.push(attachmentName)\n }\n return invalidAttachmentNames\n },\n [],\n )\n if (invalidAttachmentNames?.length) {\n return [`${invalidAttachmentNames.join(', ')} could not be uploaded.`]\n }\n return []\n }\n let errorMessage\n if (exceedsMaximumSize) {\n errorMessage = 'One or more of the files exceed the maximum size allowed.'\n }\n if (emptyFiles) {\n const emptyMessage = 'One or more of the files are empty.'\n errorMessage = errorMessage\n ? `${errorMessage} ${emptyMessage}`\n : emptyMessage\n }\n if (errorMessage) {\n return [errorMessage]\n }\n\n return []\n}\n\nexport const generateLookupValidationMessage = (\n lookupButtonConfig: EnvironmentTypes.ButtonConfiguration | undefined,\n overrideMessage: string | undefined,\n) => {\n if (overrideMessage) {\n return overrideMessage\n }\n if (lookupButtonConfig && lookupButtonConfig.label) {\n return `${lookupButtonConfig.label} is required`\n }\n return 'Lookup is required'\n}\n"]}
@@ -3,6 +3,10 @@ import { NewS3SubmissionData } from '@oneblink/types/typescript/submissions';
3
3
  export { FormElementConditionallyShownElement, FormElementConditionallyShown, FormElementsConditionallyShown, } from '@oneblink/sdk-core/dist/conditionalLogicService';
4
4
  export type FormElementKey = string;
5
5
  export type RepeatableSetEntryIndex = string;
6
+ /**
7
+ * Must not be mutated in place, the same objects are shared between renders and
8
+ * with other components.
9
+ */
6
10
  export type FormElementsValidation = Record<FormElementKey, FormElementValidation>;
7
11
  export type FormElementValidation = undefined | string | {
8
12
  type: 'formElements';
@@ -1 +1 @@
1
- {"version":3,"file":"form.js","sourceRoot":"","sources":["../../src/types/form.ts"],"names":[],"mappings":"","sourcesContent":["import { FormTypes, SubmissionTypes, IntegrationTypes } from '@oneblink/types'\nimport { NewS3SubmissionData } from '@oneblink/types/typescript/submissions'\n\nexport {\n FormElementConditionallyShownElement,\n FormElementConditionallyShown,\n FormElementsConditionallyShown,\n} from '@oneblink/sdk-core/dist/conditionalLogicService'\n\nexport type FormElementKey = string\nexport type RepeatableSetEntryIndex = string\n\nexport type FormElementsValidation = Record<\n FormElementKey,\n FormElementValidation\n>\n\nexport type FormElementValidation =\n | undefined\n | string\n | {\n type: 'formElements'\n formElements: FormElementsValidation | undefined\n }\n | {\n type: 'repeatableSet'\n set: string | undefined\n entries: Record<\n RepeatableSetEntryIndex,\n FormElementsValidation | undefined\n >\n }\n\nexport type ExecutedLookups =\n | {\n [elementName: string]:\n | boolean\n | ExecutedLookups\n | ExecutedLookups[]\n | undefined\n }\n | undefined\n\nexport type ExecutedLookupValue = NonNullable<ExecutedLookups>[string]\n\ntype ValueChangeHandler<U extends Record<string, unknown>> = (\n element: FormTypes.FormElement,\n opts: U,\n idPrefix?: string,\n) => void\n\nexport type FormElementValueChangeHandler<T = unknown> = ValueChangeHandler<{\n value?: T | ((existingValue?: T) => T | undefined)\n /**\n * When true, the value is written without treating it as a user edit (no\n * unsaved-changes flag, last-element tracking, or auto-save).\n */\n isDerivedChange?: boolean\n}>\n\nexport type SectionState = NewS3SubmissionData['sectionState']\n\nexport type NestedFormElementValueChangeHandler<T = unknown> =\n ValueChangeHandler<{\n value?: T | ((existingValue?: T) => T | undefined)\n /**\n * The executed lookups to preserve when the nested element is changed,\n * setting to undefined indicate the lookup has not been executed.\n */\n executedLookups:\n | ExecutedLookupValue\n | ((currentExecutedLookups: ExecutedLookupValue) => ExecutedLookupValue)\n deleteSection?: boolean\n /**\n * The section state to preserve when the nested element is changed, setting\n * to undefined will not update the section state\n */\n sectionState:\n | SectionState\n | ((currentSectionState: SectionState) => SectionState)\n /**\n * When true, the value is written without treating it as a user edit (no\n * unsaved-changes flag, last-element tracking, or auto-save).\n */\n isDerivedChange?: boolean\n }>\n\nexport type SetFormSubmissionOptions = {\n isDerivedChange?: boolean\n}\n\nexport type FormElementLookupHandler = (\n setter: (data: {\n submission: SubmissionTypes.S3SubmissionData['submission']\n elements: FormTypes.FormElement[]\n lastElementUpdated: FormTypes.FormElement | undefined\n executedLookups: ExecutedLookups\n sectionState: SectionState | undefined\n }) => {\n submission: SubmissionTypes.S3SubmissionData['submission']\n elements: FormTypes.FormElement[]\n executedLookups: ExecutedLookups\n },\n options?: SetFormSubmissionOptions,\n) => void\n\nexport type UpdateFormElementsHandler = (\n setter: (element: FormTypes.FormElement[]) => FormTypes.FormElement[],\n) => void\n\nexport type FormSubmissionState = {\n definition: FormTypes.Form\n submission: SubmissionTypes.S3SubmissionData['submission']\n lastElementUpdated: FormTypes.FormElement | undefined\n executedLookups: ExecutedLookups\n sectionState: SectionState | undefined\n}\n\nexport type SetFormSubmission = (\n value: React.SetStateAction<FormSubmissionState>,\n options?: SetFormSubmissionOptions,\n) => void\n\nexport type IsDirtyProps = {\n isDirty: boolean\n setIsDirty: () => void\n}\n\nexport type CaptchaType = NonNullable<\n IntegrationTypes.IntegrationRecaptcha['configuration']['domains'][number]['type']\n>\n"]}
1
+ {"version":3,"file":"form.js","sourceRoot":"","sources":["../../src/types/form.ts"],"names":[],"mappings":"","sourcesContent":["import { FormTypes, SubmissionTypes, IntegrationTypes } from '@oneblink/types'\nimport { NewS3SubmissionData } from '@oneblink/types/typescript/submissions'\n\n// Conditionally shown and validation results are structurally shared between\n// renders (see `useStructuralSharing()`), so they must never be mutated in\n// place. Create new objects instead.\nexport {\n FormElementConditionallyShownElement,\n FormElementConditionallyShown,\n FormElementsConditionallyShown,\n} from '@oneblink/sdk-core/dist/conditionalLogicService'\n\nexport type FormElementKey = string\nexport type RepeatableSetEntryIndex = string\n\n/**\n * Must not be mutated in place, the same objects are shared between renders and\n * with other components.\n */\nexport type FormElementsValidation = Record<\n FormElementKey,\n FormElementValidation\n>\n\nexport type FormElementValidation =\n | undefined\n | string\n | {\n type: 'formElements'\n formElements: FormElementsValidation | undefined\n }\n | {\n type: 'repeatableSet'\n set: string | undefined\n entries: Record<\n RepeatableSetEntryIndex,\n FormElementsValidation | undefined\n >\n }\n\nexport type ExecutedLookups =\n | {\n [elementName: string]:\n | boolean\n | ExecutedLookups\n | ExecutedLookups[]\n | undefined\n }\n | undefined\n\nexport type ExecutedLookupValue = NonNullable<ExecutedLookups>[string]\n\ntype ValueChangeHandler<U extends Record<string, unknown>> = (\n element: FormTypes.FormElement,\n opts: U,\n idPrefix?: string,\n) => void\n\nexport type FormElementValueChangeHandler<T = unknown> = ValueChangeHandler<{\n value?: T | ((existingValue?: T) => T | undefined)\n /**\n * When true, the value is written without treating it as a user edit (no\n * unsaved-changes flag, last-element tracking, or auto-save).\n */\n isDerivedChange?: boolean\n}>\n\nexport type SectionState = NewS3SubmissionData['sectionState']\n\nexport type NestedFormElementValueChangeHandler<T = unknown> =\n ValueChangeHandler<{\n value?: T | ((existingValue?: T) => T | undefined)\n /**\n * The executed lookups to preserve when the nested element is changed,\n * setting to undefined indicate the lookup has not been executed.\n */\n executedLookups:\n | ExecutedLookupValue\n | ((currentExecutedLookups: ExecutedLookupValue) => ExecutedLookupValue)\n deleteSection?: boolean\n /**\n * The section state to preserve when the nested element is changed, setting\n * to undefined will not update the section state\n */\n sectionState:\n | SectionState\n | ((currentSectionState: SectionState) => SectionState)\n /**\n * When true, the value is written without treating it as a user edit (no\n * unsaved-changes flag, last-element tracking, or auto-save).\n */\n isDerivedChange?: boolean\n }>\n\nexport type SetFormSubmissionOptions = {\n isDerivedChange?: boolean\n}\n\nexport type FormElementLookupHandler = (\n setter: (data: {\n submission: SubmissionTypes.S3SubmissionData['submission']\n elements: FormTypes.FormElement[]\n lastElementUpdated: FormTypes.FormElement | undefined\n executedLookups: ExecutedLookups\n sectionState: SectionState | undefined\n }) => {\n submission: SubmissionTypes.S3SubmissionData['submission']\n elements: FormTypes.FormElement[]\n executedLookups: ExecutedLookups\n },\n options?: SetFormSubmissionOptions,\n) => void\n\nexport type UpdateFormElementsHandler = (\n setter: (element: FormTypes.FormElement[]) => FormTypes.FormElement[],\n) => void\n\nexport type FormSubmissionState = {\n definition: FormTypes.Form\n submission: SubmissionTypes.S3SubmissionData['submission']\n lastElementUpdated: FormTypes.FormElement | undefined\n executedLookups: ExecutedLookups\n sectionState: SectionState | undefined\n}\n\nexport type SetFormSubmission = (\n value: React.SetStateAction<FormSubmissionState>,\n options?: SetFormSubmissionOptions,\n) => void\n\nexport type IsDirtyProps = {\n isDirty: boolean\n setIsDirty: () => void\n}\n\nexport type CaptchaType = NonNullable<\n IntegrationTypes.IntegrationRecaptcha['configuration']['domains'][number]['type']\n>\n"]}
@@ -0,0 +1,14 @@
1
+ export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
2
+ /**
3
+ * Returns `next`, but with any arrays or plain objects that are deeply equal to
4
+ * the matching value in `previous` replaced by the instance from `previous`. If
5
+ * `next` is deeply equal to `previous`, `previous` is returned. This keeps
6
+ * object identities stable across renders so memoised components can bail out
7
+ * of rendering when their slice of a large computed object has not changed.
8
+ *
9
+ * The name, borrowed from TanStack Query's equivalent function, reads as
10
+ * "replace equal values, deeply": it is not an equality check, it returns a
11
+ * value in which unchanged parts are replaced by their previous instances
12
+ * (structural sharing).
13
+ */
14
+ export default function replaceEqualDeep<T>(previous: unknown, next: T): T;
@@ -0,0 +1,58 @@
1
+ export function isPlainObject(value) {
2
+ if (typeof value !== 'object' || value === null) {
3
+ return false;
4
+ }
5
+ const prototype = Object.getPrototypeOf(value);
6
+ return prototype === Object.prototype || prototype === null;
7
+ }
8
+ /**
9
+ * Returns `next`, but with any arrays or plain objects that are deeply equal to
10
+ * the matching value in `previous` replaced by the instance from `previous`. If
11
+ * `next` is deeply equal to `previous`, `previous` is returned. This keeps
12
+ * object identities stable across renders so memoised components can bail out
13
+ * of rendering when their slice of a large computed object has not changed.
14
+ *
15
+ * The name, borrowed from TanStack Query's equivalent function, reads as
16
+ * "replace equal values, deeply": it is not an equality check, it returns a
17
+ * value in which unchanged parts are replaced by their previous instances
18
+ * (structural sharing).
19
+ */
20
+ export default function replaceEqualDeep(previous, next) {
21
+ if (previous === next) {
22
+ return previous;
23
+ }
24
+ if (Array.isArray(previous) && Array.isArray(next)) {
25
+ let equalItems = 0;
26
+ const result = next.map((item, index) => {
27
+ const sharedItem = replaceEqualDeep(previous[index], item);
28
+ if (sharedItem === previous[index]) {
29
+ equalItems++;
30
+ }
31
+ return sharedItem;
32
+ });
33
+ if (previous.length === next.length && equalItems === next.length) {
34
+ return previous;
35
+ }
36
+ return result;
37
+ }
38
+ if (isPlainObject(previous) && isPlainObject(next)) {
39
+ const previousKeys = Object.keys(previous);
40
+ const nextKeys = Object.keys(next);
41
+ let equalItems = 0;
42
+ const result = {};
43
+ for (const key of nextKeys) {
44
+ const sharedItem = replaceEqualDeep(previous[key], next[key]);
45
+ if (sharedItem === previous[key] && key in previous) {
46
+ equalItems++;
47
+ }
48
+ result[key] = sharedItem;
49
+ }
50
+ if (previousKeys.length === nextKeys.length &&
51
+ equalItems === nextKeys.length) {
52
+ return previous;
53
+ }
54
+ return result;
55
+ }
56
+ return next;
57
+ }
58
+ //# sourceMappingURL=replaceEqualDeep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replaceEqualDeep.js","sourceRoot":"","sources":["../../src/utils/replaceEqualDeep.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,aAAa,CAC3B,KAAc;IAEd,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAA;IACd,CAA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AA;QAC1C,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;YAC3B,MAAM,UAAU,GAAG,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;YAC7D,IAAI,UAAU,KAAK,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;gBACpD,UAAU,EAAE,CAAA;YACd,CAAC;YACD,MAAM,CAAC,GAAG,CAAC,GAAG,UAAU,CAAA;QAC1B,CAAC;QACD,IACE,YAAY,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM;YACvC,UAAU,KAAK,QAAQ,CAAC,MAAM,EAC9B,CAAC;YACD,OAAO,QAAa,CAAA;QACtB,CAAC;QACD,OAAO,MAAW,CAAA;IACpB,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["export function isPlainObject(\n value: unknown,\n): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null) {\n return false\n }\n const prototype = Object.getPrototypeOf(value)\n return prototype === Object.prototype || prototype === null\n}\n\n/**\n * Returns `next`, but with any arrays or plain objects that are deeply equal to\n * the matching value in `previous` replaced by the instance from `previous`. If\n * `next` is deeply equal to `previous`, `previous` is returned. This keeps\n * object identities stable across renders so memoised components can bail out\n * of rendering when their slice of a large computed object has not changed.\n *\n * The name, borrowed from TanStack Query's equivalent function, reads as\n * \"replace equal values, deeply\": it is not an equality check, it returns a\n * value in which unchanged parts are replaced by their previous instances\n * (structural sharing).\n */\nexport default function replaceEqualDeep<T>(previous: unknown, next: T): T {\n if (previous === next) {\n return previous as T\n }\n\n if (Array.isArray(previous) && Array.isArray(next)) {\n let equalItems = 0\n const result = next.map((item, index) => {\n const sharedItem = replaceEqualDeep(previous[index], item)\n if (sharedItem === previous[index]) {\n equalItems++\n }\n return sharedItem\n })\n if (previous.length === next.length && equalItems === next.length) {\n return previous as T\n }\n return result as T\n }\n\n if (isPlainObject(previous) && isPlainObject(next)) {\n const previousKeys = Object.keys(previous)\n const nextKeys = Object.keys(next)\n let equalItems = 0\n const result: Record<string, unknown> = {}\n for (const key of nextKeys) {\n const sharedItem = replaceEqualDeep(previous[key], next[key])\n if (sharedItem === previous[key] && key in previous) {\n equalItems++\n }\n result[key] = sharedItem\n }\n if (\n previousKeys.length === nextKeys.length &&\n equalItems === nextKeys.length\n ) {\n return previous as T\n }\n return result as T\n }\n\n return next\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oneblink/apps-react",
3
3
  "description": "Helper functions for OneBlink apps in ReactJS.",
4
- "version": "13.4.0",
4
+ "version": "13.5.0-beta.1",
5
5
  "author": "OneBlink <developers@oneblink.io> (https://oneblink.io)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/oneblink/apps-react/issues"
@@ -12,7 +12,7 @@
12
12
  "@emotion/react": "^11.14.0",
13
13
  "@emotion/styled": "^11.14.1",
14
14
  "@nylas/react": "^3.1.2",
15
- "@oneblink/sdk-core": "^10.1.0-beta.9",
15
+ "@oneblink/sdk-core": "^10.2.0-beta.1",
16
16
  "@oneblink/storage": "^9.0.0-beta.4",
17
17
  "@react-google-maps/api": "^2.20.8",
18
18
  "@react-input/mask": "^2.0.4",
@@ -43,6 +43,7 @@
43
43
  "react-google-recaptcha": "^3.1.0",
44
44
  "react-image-crop": "^11.0.10",
45
45
  "react-signature-canvas": "^1.1.0-alpha.2",
46
+ "reselect": "^5.3.0",
46
47
  "sanitize-html": "^2.17.0",
47
48
  "ua-parser-js": "^1.0.41",
48
49
  "usehooks-ts": "^3.1.1",
@@ -125,6 +126,7 @@
125
126
  "url": "git+https://github.com/oneblink/apps-react.git"
126
127
  },
127
128
  "scripts": {
129
+ "bench": "vitest bench --run --outputJson bench-results.json && node tests/performance/check-limits.mjs bench-results.json",
128
130
  "build": "tsc && npm run build:css",
129
131
  "build:css": "npm run copy:sass && npm run copy:styles && sass ./dist/styles.scss ./dist/styles.css --load-path ./node_modules --no-source-map",
130
132
  "copy:sass": "copyfiles -u 1 ./src/styles.scss ./dist",
@@ -137,7 +139,7 @@
137
139
  "pretest": "npm run fixpack && npm run eslint && npm run typescript",
138
140
  "release": "oneblink-release repository --no-name --update-dependents --force-update-dependency",
139
141
  "start": "tsc-watch",
140
- "test": "vitest",
142
+ "test": "vitest run",
141
143
  "types": "npm i -D github:oneblink/types",
142
144
  "typescript": "tsc --noEmit",
143
145
  "update-dependents": "oneblink-release update-dependents --force-update-dependency"