@oneblink/apps-react 4.0.0-beta.6 → 4.0.0-beta.8

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 (93) hide show
  1. package/dist/OneBlinkAutoSaveForm.d.ts +1 -0
  2. package/dist/OneBlinkAutoSaveForm.js +1 -0
  3. package/dist/OneBlinkAutoSaveForm.js.map +1 -1
  4. package/dist/OneBlinkForm.d.ts +2 -0
  5. package/dist/OneBlinkForm.js +2 -0
  6. package/dist/OneBlinkForm.js.map +1 -1
  7. package/dist/OneBlinkReadOnlyForm.d.ts +1 -0
  8. package/dist/OneBlinkReadOnlyForm.js +1 -0
  9. package/dist/OneBlinkReadOnlyForm.js.map +1 -1
  10. package/dist/PaymentReceipt.d.ts +4 -0
  11. package/dist/PaymentReceipt.js +4 -0
  12. package/dist/PaymentReceipt.js.map +1 -1
  13. package/dist/components/formStore/OneBlinkFormStoreClearFiltersButton.d.ts +5 -0
  14. package/dist/components/formStore/OneBlinkFormStoreClearFiltersButton.js +5 -0
  15. package/dist/components/formStore/OneBlinkFormStoreClearFiltersButton.js.map +1 -1
  16. package/dist/components/formStore/OneBlinkFormStoreColumnsButton.d.ts +5 -0
  17. package/dist/components/formStore/OneBlinkFormStoreColumnsButton.js +5 -0
  18. package/dist/components/formStore/OneBlinkFormStoreColumnsButton.js.map +1 -1
  19. package/dist/components/formStore/OneBlinkFormStoreDownloadButton.d.ts +5 -0
  20. package/dist/components/formStore/OneBlinkFormStoreDownloadButton.js +5 -0
  21. package/dist/components/formStore/OneBlinkFormStoreDownloadButton.js.map +1 -1
  22. package/dist/components/formStore/OneBlinkFormStoreProvider.d.ts +5 -0
  23. package/dist/components/formStore/OneBlinkFormStoreProvider.js +5 -0
  24. package/dist/components/formStore/OneBlinkFormStoreProvider.js.map +1 -1
  25. package/dist/components/formStore/OneBlinkFormStoreRefreshButton.d.ts +5 -0
  26. package/dist/components/formStore/OneBlinkFormStoreRefreshButton.js +5 -0
  27. package/dist/components/formStore/OneBlinkFormStoreRefreshButton.js.map +1 -1
  28. package/dist/components/formStore/OneBlinkFormStoreTable.d.ts +4 -0
  29. package/dist/components/formStore/OneBlinkFormStoreTable.js +4 -0
  30. package/dist/components/formStore/OneBlinkFormStoreTable.js.map +1 -1
  31. package/dist/components/pickers/V4CompatibleDatePicker.d.ts +5 -0
  32. package/dist/components/pickers/V4CompatibleDatePicker.js +5 -0
  33. package/dist/components/pickers/V4CompatibleDatePicker.js.map +1 -1
  34. package/dist/components/pickers/V4CompatibleDateTimePicker.d.ts +5 -0
  35. package/dist/components/pickers/V4CompatibleDateTimePicker.js +5 -0
  36. package/dist/components/pickers/V4CompatibleDateTimePicker.js.map +1 -1
  37. package/dist/components/pickers/V4CompatibleTimePicker.d.ts +5 -0
  38. package/dist/components/pickers/V4CompatibleTimePicker.js +5 -0
  39. package/dist/components/pickers/V4CompatibleTimePicker.js.map +1 -1
  40. package/dist/components/renderer/LookupButton.js +2 -2
  41. package/dist/components/renderer/LookupButton.js.map +1 -1
  42. package/dist/components/renderer/LookupNotification.js +26 -22
  43. package/dist/components/renderer/LookupNotification.js.map +1 -1
  44. package/dist/components/renderer/ProgressBar.d.ts +5 -0
  45. package/dist/components/renderer/ProgressBar.js +5 -0
  46. package/dist/components/renderer/ProgressBar.js.map +1 -1
  47. package/dist/form-elements/FormElementBarcodeScanner.js +2 -2
  48. package/dist/form-elements/FormElementBarcodeScanner.js.map +1 -1
  49. package/dist/hooks/useAuth.d.ts +3 -1
  50. package/dist/hooks/useAuth.js +3 -1
  51. package/dist/hooks/useAuth.js.map +1 -1
  52. package/dist/hooks/useBooleanState.d.ts +1 -0
  53. package/dist/hooks/useBooleanState.js +1 -0
  54. package/dist/hooks/useBooleanState.js.map +1 -1
  55. package/dist/hooks/useClickOutsideElement.d.ts +1 -0
  56. package/dist/hooks/useClickOutsideElement.js +1 -0
  57. package/dist/hooks/useClickOutsideElement.js.map +1 -1
  58. package/dist/hooks/useDrafts.d.ts +3 -1
  59. package/dist/hooks/useDrafts.js +3 -1
  60. package/dist/hooks/useDrafts.js.map +1 -1
  61. package/dist/hooks/useFormSubmissionAutoSaveState.d.ts +1 -0
  62. package/dist/hooks/useFormSubmissionAutoSaveState.js +1 -0
  63. package/dist/hooks/useFormSubmissionAutoSaveState.js.map +1 -1
  64. package/dist/hooks/useFormSubmissionState.d.ts +1 -0
  65. package/dist/hooks/useFormSubmissionState.js +1 -0
  66. package/dist/hooks/useFormSubmissionState.js.map +1 -1
  67. package/dist/hooks/useIsMounted.d.ts +1 -0
  68. package/dist/hooks/useIsMounted.js +1 -0
  69. package/dist/hooks/useIsMounted.js.map +1 -1
  70. package/dist/hooks/useIsOffline.d.ts +5 -0
  71. package/dist/hooks/useIsOffline.js +5 -0
  72. package/dist/hooks/useIsOffline.js.map +1 -1
  73. package/dist/hooks/useLoadDataState.d.ts +2 -0
  74. package/dist/hooks/useLoadDataState.js +2 -0
  75. package/dist/hooks/useLoadDataState.js.map +1 -1
  76. package/dist/hooks/useLogin.d.ts +4 -2
  77. package/dist/hooks/useLogin.js +1 -0
  78. package/dist/hooks/useLogin.js.map +1 -1
  79. package/dist/hooks/useLookupNotification.d.ts +6 -2
  80. package/dist/hooks/useLookupNotification.js +29 -3
  81. package/dist/hooks/useLookupNotification.js.map +1 -1
  82. package/dist/hooks/useNullableState.d.ts +2 -0
  83. package/dist/hooks/useNullableState.js +2 -0
  84. package/dist/hooks/useNullableState.js.map +1 -1
  85. package/dist/hooks/usePendingSubmissions.d.ts +9 -1
  86. package/dist/hooks/usePendingSubmissions.js +17 -14
  87. package/dist/hooks/usePendingSubmissions.js.map +1 -1
  88. package/dist/hooks/useSignUp.d.ts +5 -0
  89. package/dist/hooks/useSignUp.js +5 -0
  90. package/dist/hooks/useSignUp.js.map +1 -1
  91. package/dist/index.d.ts +1 -1
  92. package/dist/index.js.map +1 -1
  93. package/package.json +1 -1
@@ -26,6 +26,7 @@ declare function OneBlinkAutoSaveForm({ form, initialSubmission, resumeAtElement
26
26
  *
27
27
  * @param props
28
28
  * @returns
29
+ * @group Components
29
30
  */
30
31
  declare const _default: React.MemoExoticComponent<typeof OneBlinkAutoSaveForm>;
31
32
  export default _default;
@@ -36,6 +36,7 @@ function OneBlinkAutoSaveForm({ form, initialSubmission, resumeAtElement, autoSa
36
36
  *
37
37
  * @param props
38
38
  * @returns
39
+ * @group Components
39
40
  */
40
41
  export default React.memo(OneBlinkAutoSaveForm);
41
42
  //# sourceMappingURL=OneBlinkAutoSaveForm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OneBlinkAutoSaveForm.js","sourceRoot":"","sources":["../src/OneBlinkAutoSaveForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,SAAS,MAAM,iCAAiC,CAAA;AACvD,OAAO,KAAK,MAAM,6BAA6B,CAAA;AAC/C,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,8BAA8B,MAAM,wCAAwC,CAAA;AAGnF,SAAS,oBAAoB,CAAC,EAC5B,IAAI,EACJ,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,8BAA8B,EAC9B,iCAAiC,EACjC,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,GAAG,KAAK,EAgBT;IACC,MAAM,EACJ,UAAU,EACV,UAAU,EACV,2BAA2B,EAC3B,6BAA6B,EAC7B,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,GACnB,GAAG,8BAA8B,CAAC;QACjC,IAAI;QACJ,iBAAiB;QACjB,eAAe;QACf,WAAW;QACX,8BAA8B;QAC9B,iCAAiC;QACjC,QAAQ;QACR,QAAQ;QACR,WAAW;KACZ,CAAC,CAAA;IAEF,IAAI,2BAA2B,EAAE;QAC/B,OAAO,CACL,6BAAK,SAAS,EAAC,mCAAmC;YAChD,oBAAC,SAAS,IAAC,SAAS,EAAC,mBAAmB,GAAa,CACjD,CACP,CAAA;KACF;IAED,IAAI,6BAA6B,EAAE;QACjC,OAAO,CACL,oBAAC,KAAK,IACJ,MAAM,QACN,KAAK,EAAC,WAAW,EACjB,aAAa,EAAC,4BAA4B,EAC1C,OAAO,EACL;gBACE,gCACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,yEAAyE,EACnF,OAAO,EAAE,kBAAkB,kBAGpB;gBACT,gCACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,wEAAwE,EAClF,OAAO,EAAE,0BAA0B,eAG5B,CACR,uGAKC,CACT,CAAA;KACF;IAED,OAAO,CACL,oBAAC,gBAAgB,OACX,KAAK,EACT,UAAU,EAAE,KAAK,EACjB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,YAAY,EACtB,WAAW,EAAE,eAAe,EAC5B,iBAAiB,EAAE,iBAAiB,EACpC,kBAAkB,EAAE,kBAAkB,EACtC,kBAAkB,EAAE,kBAAkB,GACtC,CACH,CAAA;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,eAAe,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport OnLoading from './components/renderer/OnLoading'\nimport Modal from './components/renderer/Modal'\nimport OneBlinkFormBase from './OneBlinkFormBase'\nimport useFormSubmissionAutoSaveState from './hooks/useFormSubmissionAutoSaveState'\nimport { OneBlinkFormUncontrolled } from './OneBlinkForm'\n\nfunction OneBlinkAutoSaveForm({\n form,\n initialSubmission,\n resumeAtElement,\n autoSaveKey,\n removeAutoSaveDataBeforeSubmit,\n removeAutoSaveDataBeforeSaveDraft,\n onCancel,\n onSubmit,\n onSaveDraft,\n ...props\n}: React.ComponentProps<typeof OneBlinkFormUncontrolled> & {\n /** Pass a unique key for this submission e.g. the `externalId` the parameter */\n autoSaveKey: string\n /**\n * By default, auto save data is removed when the user clicks Submit. If you\n * would like auto save data to persist and clean up the auto save data later,\n * pass `false`.\n */\n removeAutoSaveDataBeforeSubmit?: boolean\n /**\n * By default, auto save data is removed when the user clicks Save Draft. If\n * you would like auto save data to persist and clean up the auto save data\n * later, pass `false`.\n */\n removeAutoSaveDataBeforeSaveDraft?: boolean\n}) {\n const {\n definition,\n submission,\n isLoadingAutoSaveSubmission,\n isAutoSaveSubmissionAvailable,\n startNewSubmission,\n continueAutoSaveSubmission,\n handleSubmit,\n handleCancel,\n handleSaveDraft,\n setFormSubmission,\n handleNavigateAway,\n lastElementUpdated,\n } = useFormSubmissionAutoSaveState({\n form,\n initialSubmission,\n resumeAtElement,\n autoSaveKey,\n removeAutoSaveDataBeforeSubmit,\n removeAutoSaveDataBeforeSaveDraft,\n onCancel,\n onSubmit,\n onSaveDraft,\n })\n\n if (isLoadingAutoSaveSubmission) {\n return (\n <div className=\"cypress-loading has-text-centered\">\n <OnLoading className=\"has-text-centered\"></OnLoading>\n </div>\n )\n }\n\n if (isAutoSaveSubmissionAvailable) {\n return (\n <Modal\n isOpen\n title=\"Continue?\"\n cardClassName=\"cypress-continue-auto-save\"\n actions={\n <>\n <button\n type=\"button\"\n className=\"button ob-button is-light cypress-continue-auto-save-start-again-button\"\n onClick={startNewSubmission}\n >\n Start Again\n </button>\n <button\n type=\"button\"\n className=\"button ob-button is-primary cypress-continue-auto-save-continue-button\"\n onClick={continueAutoSaveSubmission}\n >\n Continue\n </button>\n </>\n }\n >\n We found an in progress submission, would you like to pick up where you\n left off or start again?\n </Modal>\n )\n }\n\n return (\n <OneBlinkFormBase\n {...props}\n isReadOnly={false}\n submission={submission}\n definition={definition}\n onCancel={handleCancel}\n onSubmit={handleSubmit}\n onSaveDraft={handleSaveDraft}\n setFormSubmission={setFormSubmission}\n handleNavigateAway={handleNavigateAway}\n lastElementUpdated={lastElementUpdated}\n />\n )\n}\n\n/**\n * This component is a drop in replacement for {@link OneBlinkForm} with the\n * addition of auto save happening periodically to prevent users from losing\n * submission data.\n *\n * If you need auto saving with a controlled form, see the\n * {@link OneBlinkFormControlled} component for a full example.\n *\n * @param props\n * @returns\n */\nexport default React.memo(OneBlinkAutoSaveForm)\n"]}
1
+ {"version":3,"file":"OneBlinkAutoSaveForm.js","sourceRoot":"","sources":["../src/OneBlinkAutoSaveForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,SAAS,MAAM,iCAAiC,CAAA;AACvD,OAAO,KAAK,MAAM,6BAA6B,CAAA;AAC/C,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,8BAA8B,MAAM,wCAAwC,CAAA;AAGnF,SAAS,oBAAoB,CAAC,EAC5B,IAAI,EACJ,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,8BAA8B,EAC9B,iCAAiC,EACjC,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,GAAG,KAAK,EAgBT;IACC,MAAM,EACJ,UAAU,EACV,UAAU,EACV,2BAA2B,EAC3B,6BAA6B,EAC7B,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,GACnB,GAAG,8BAA8B,CAAC;QACjC,IAAI;QACJ,iBAAiB;QACjB,eAAe;QACf,WAAW;QACX,8BAA8B;QAC9B,iCAAiC;QACjC,QAAQ;QACR,QAAQ;QACR,WAAW;KACZ,CAAC,CAAA;IAEF,IAAI,2BAA2B,EAAE;QAC/B,OAAO,CACL,6BAAK,SAAS,EAAC,mCAAmC;YAChD,oBAAC,SAAS,IAAC,SAAS,EAAC,mBAAmB,GAAa,CACjD,CACP,CAAA;KACF;IAED,IAAI,6BAA6B,EAAE;QACjC,OAAO,CACL,oBAAC,KAAK,IACJ,MAAM,QACN,KAAK,EAAC,WAAW,EACjB,aAAa,EAAC,4BAA4B,EAC1C,OAAO,EACL;gBACE,gCACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,yEAAyE,EACnF,OAAO,EAAE,kBAAkB,kBAGpB;gBACT,gCACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,wEAAwE,EAClF,OAAO,EAAE,0BAA0B,eAG5B,CACR,uGAKC,CACT,CAAA;KACF;IAED,OAAO,CACL,oBAAC,gBAAgB,OACX,KAAK,EACT,UAAU,EAAE,KAAK,EACjB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,YAAY,EACtB,WAAW,EAAE,eAAe,EAC5B,iBAAiB,EAAE,iBAAiB,EACpC,kBAAkB,EAAE,kBAAkB,EACtC,kBAAkB,EAAE,kBAAkB,GACtC,CACH,CAAA;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,eAAe,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport OnLoading from './components/renderer/OnLoading'\nimport Modal from './components/renderer/Modal'\nimport OneBlinkFormBase from './OneBlinkFormBase'\nimport useFormSubmissionAutoSaveState from './hooks/useFormSubmissionAutoSaveState'\nimport { OneBlinkFormUncontrolled } from './OneBlinkForm'\n\nfunction OneBlinkAutoSaveForm({\n form,\n initialSubmission,\n resumeAtElement,\n autoSaveKey,\n removeAutoSaveDataBeforeSubmit,\n removeAutoSaveDataBeforeSaveDraft,\n onCancel,\n onSubmit,\n onSaveDraft,\n ...props\n}: React.ComponentProps<typeof OneBlinkFormUncontrolled> & {\n /** Pass a unique key for this submission e.g. the `externalId` the parameter */\n autoSaveKey: string\n /**\n * By default, auto save data is removed when the user clicks Submit. If you\n * would like auto save data to persist and clean up the auto save data later,\n * pass `false`.\n */\n removeAutoSaveDataBeforeSubmit?: boolean\n /**\n * By default, auto save data is removed when the user clicks Save Draft. If\n * you would like auto save data to persist and clean up the auto save data\n * later, pass `false`.\n */\n removeAutoSaveDataBeforeSaveDraft?: boolean\n}) {\n const {\n definition,\n submission,\n isLoadingAutoSaveSubmission,\n isAutoSaveSubmissionAvailable,\n startNewSubmission,\n continueAutoSaveSubmission,\n handleSubmit,\n handleCancel,\n handleSaveDraft,\n setFormSubmission,\n handleNavigateAway,\n lastElementUpdated,\n } = useFormSubmissionAutoSaveState({\n form,\n initialSubmission,\n resumeAtElement,\n autoSaveKey,\n removeAutoSaveDataBeforeSubmit,\n removeAutoSaveDataBeforeSaveDraft,\n onCancel,\n onSubmit,\n onSaveDraft,\n })\n\n if (isLoadingAutoSaveSubmission) {\n return (\n <div className=\"cypress-loading has-text-centered\">\n <OnLoading className=\"has-text-centered\"></OnLoading>\n </div>\n )\n }\n\n if (isAutoSaveSubmissionAvailable) {\n return (\n <Modal\n isOpen\n title=\"Continue?\"\n cardClassName=\"cypress-continue-auto-save\"\n actions={\n <>\n <button\n type=\"button\"\n className=\"button ob-button is-light cypress-continue-auto-save-start-again-button\"\n onClick={startNewSubmission}\n >\n Start Again\n </button>\n <button\n type=\"button\"\n className=\"button ob-button is-primary cypress-continue-auto-save-continue-button\"\n onClick={continueAutoSaveSubmission}\n >\n Continue\n </button>\n </>\n }\n >\n We found an in progress submission, would you like to pick up where you\n left off or start again?\n </Modal>\n )\n }\n\n return (\n <OneBlinkFormBase\n {...props}\n isReadOnly={false}\n submission={submission}\n definition={definition}\n onCancel={handleCancel}\n onSubmit={handleSubmit}\n onSaveDraft={handleSaveDraft}\n setFormSubmission={setFormSubmission}\n handleNavigateAway={handleNavigateAway}\n lastElementUpdated={lastElementUpdated}\n />\n )\n}\n\n/**\n * This component is a drop in replacement for {@link OneBlinkForm} with the\n * addition of auto save happening periodically to prevent users from losing\n * submission data.\n *\n * If you need auto saving with a controlled form, see the\n * {@link OneBlinkFormControlled} component for a full example.\n *\n * @param props\n * @returns\n * @group Components\n */\nexport default React.memo(OneBlinkAutoSaveForm)\n"]}
@@ -325,6 +325,7 @@ export { OneBlinkFormBaseProps, OneBlinkFormControlledProps };
325
325
  *
326
326
  * @param props
327
327
  * @returns
328
+ * @group Components
328
329
  */
329
330
  declare const OneBlinkFormControlled: React.NamedExoticComponent<OneBlinkFormBaseProps & OneBlinkFormControlledProps>;
330
331
  /**
@@ -546,6 +547,7 @@ declare const OneBlinkFormControlled: React.NamedExoticComponent<OneBlinkFormBas
546
547
  *
547
548
  * @param props
548
549
  * @returns
550
+ * @group Components
549
551
  */
550
552
  declare const OneBlinkFormUncontrolled: React.NamedExoticComponent<OneBlinkFormBaseProps & {
551
553
  /** The OneBlink Form to render */
@@ -324,6 +324,7 @@ import useFormSubmissionState from './hooks/useFormSubmissionState';
324
324
  *
325
325
  * @param props
326
326
  * @returns
327
+ * @group Components
327
328
  */
328
329
  const OneBlinkFormControlled = React.memo(function OneBlinkFormControlled(props) {
329
330
  return React.createElement(OneBlinkFormBase, { ...props, isReadOnly: false });
@@ -547,6 +548,7 @@ const OneBlinkFormControlled = React.memo(function OneBlinkFormControlled(props)
547
548
  *
548
549
  * @param props
549
550
  * @returns
551
+ * @group Components
550
552
  */
551
553
  const OneBlinkFormUncontrolled = React.memo(function OneBlinkFormUncontrolled({ form, initialSubmission, resumeAtElement, ...props }) {
552
554
  const [{ definition, submission, lastElementUpdated }, setFormSubmission] = useFormSubmissionState(form, initialSubmission, resumeAtElement);
@@ -1 +1 @@
1
- {"version":3,"file":"OneBlinkForm.js","sourceRoot":"","sources":["../src/OneBlinkForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,gBAGN,MAAM,oBAAoB,CAAA;AAC3B,OAAO,sBAAsB,MAAM,gCAAgC,CAAA;AAInE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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{\n OneBlinkFormBaseProps,\n OneBlinkFormControlledProps,\n} from './OneBlinkFormBase'\nimport useFormSubmissionState from './hooks/useFormSubmissionState'\n\nexport { OneBlinkFormBaseProps, OneBlinkFormControlledProps }\n\n/**\n * Similar to {@link OneBlinkForm}, however requires props to control the\n * `definition` and `submission` values.\n *\n * #### Example\n *\n * ```tsx\n * import React from 'react'\n * import ReactDOM from 'react-dom'\n * import { FormTypes } from '@oneblink/types'\n * import {\n * OneBlinkAppsError,\n * draftService,\n * submissionService,\n * } from '@oneblink/apps'\n * import {\n * IsOfflineContextProvider,\n * OneBlinkFormControlled,\n * useIsMounted,\n * useFormSubmissionState,\n * } from '@oneblink/apps-react'\n * import '@oneblink/apps-react/dist/styles.css'\n *\n * const captchaSiteKey = 'ENTER_YOUR_SITE_KEY_HERE'\n * const googleMapsApiKey = 'ENTER_YOUR_MAPS_API_KEY_HERE'\n * const formsAppId = 1\n * const form: FormTypes.Form = {\n * id: 1,\n * name: 'Name of Form',\n * description: '',\n * organisationId: 'abc123',\n * formsAppEnvironmentId: 1,\n * formsAppIds: [],\n * elements: [],\n * isAuthenticated: false,\n * isMultiPage: false,\n * isInfoPage: false,\n * publishStartDate: null,\n * publishEndDate: null,\n * postSubmissionAction: 'FORMS_LIBRARY',\n * submissionEvents: [],\n * tags: [],\n * }\n * const initialSubmission: Record<string, unknown> = {\n * data: 1,\n * }\n *\n * function FormContainer() {\n * const isMounted = useIsMounted()\n *\n * const [{ definition, submission }, setFormSubmission] =\n * useFormSubmissionState(form, initialSubmission)\n *\n * const [{ isSavingDraft, saveDraftError }, setSaveDraftState] =\n * React.useState({\n * isSavingDraft: false,\n * saveDraftError: null,\n * })\n *\n * const [\n * { isSubmitting, submitError, formSubmissionResult },\n * setSubmitState,\n * ] = React.useState({\n * formSubmissionResult: null,\n * isSubmitting: false,\n * submitError: null,\n * })\n *\n * const handleSubmit = React.useCallback(\n * async (newFormSubmission: FormTypes.NewFormSubmission) => {\n * const formSubmission: FormSubmission = Object.assign(\n * {},\n * newFormSubmission,\n * {\n * formsAppId,\n * jobId: null,\n * externalId: null,\n * draftId: null,\n * preFillFormDataId: null,\n * },\n * )\n *\n * setSubmitState({\n * formSubmissionResult: null,\n * submitError: null,\n * isSubmitting: true,\n * })\n *\n * try {\n * const newFormSubmissionResult = await submissionService.submit({\n * formSubmission,\n * })\n * if (\n * newFormSubmissionResult.isOffline &&\n * !newFormSubmissionResult.isInPendingQueue\n * ) {\n * throw new OneBlinkAppsError(\n * 'You cannot submit this form while offline, please try again when connectivity is restored.',\n * {\n * isOffline: true,\n * },\n * )\n * }\n *\n * if (isMounted.current) {\n * setSubmitState({\n * formSubmissionResult: newFormSubmissionResult,\n * isSubmitting: false,\n * submitError: null,\n * })\n * }\n * } catch (error) {\n * if (isMounted.current) {\n * setSubmitState({\n * formSubmissionResult: null,\n * isSubmitting: false,\n * submitError: error,\n * })\n * }\n * }\n * },\n * [isMounted],\n * )\n *\n * const handleSaveDraft = React.useCallback(\n * async (newDraftSubmission: FormTypes.NewDraftSubmission) => {\n * const draftSubmission: FormTypes.DraftSubmission = {\n * ...newDraftSubmission,\n * formsAppId,\n * }\n * setSaveDraftState({\n * saveDraftError: null,\n * isSavingDraft: true,\n * })\n *\n * try {\n * await draftService.addDraft(\n * {\n * title: form.name,\n * formId: form.id,\n * externalId: null,\n * jobId: null,\n * },\n * draftSubmission,\n * )\n *\n * if (isMounted.current) {\n * setSaveDraftState({\n * saveDraftError: null,\n * isSavingDraft: false,\n * })\n * }\n * } catch (error) {\n * if (isMounted.current) {\n * setSaveDraftState({\n * saveDraftError: error,\n * isSavingDraft: false,\n * })\n * }\n * }\n * },\n * [isMounted],\n * )\n *\n * const handleCancel = React.useCallback(() => {\n * // handle cancel here...\n * }, [])\n *\n * if (isSubmitting) {\n * // Render submitting animation/loading\n * }\n *\n * if (submitError) {\n * // Render error while submitting\n * }\n *\n * if (isSavingDraft) {\n * // Render saving draft animation/loading\n * }\n *\n * if (saveDraftError) {\n * // Render error while saving draft\n * }\n *\n * if (formSubmissionResult) {\n * // Render submission success\n * }\n *\n * return (\n * <OneBlinkFormControlled\n * captchaSiteKey={captchaSiteKey}\n * googleMapsApiKey={googleMapsApiKey}\n * formsAppId={formsAppId}\n * definition={definition}\n * submission={submission}\n * setFormSubmission={setFormSubmission}\n * onCancel={handleCancel}\n * onSubmit={handleSubmit}\n * onSaveDraft={handleSaveDraft}\n * />\n * )\n * }\n *\n * function App() {\n * return (\n * <IsOfflineContextProvider>\n * <FormContainer />\n * </IsOfflineContextProvider>\n * )\n * }\n *\n * const root = document.getElementById('root')\n * if (root) {\n * ReactDOM.render(<App />, root)\n * }\n * ```\n *\n * #### Implementing Controlled Auto Save\n *\n * The {@link OneBlinkAutoSaveForm} component does not offer props to allow for a\n * controlled form (i.e. having access to `submission` and `definition` values).\n * To implement a controlled version of the `<OneBlinkAutoSaveForm />`\n * component, use the example component below.\n *\n * ```tsx\n * import * as React from 'react'\n * import {\n * OneBlinkAutoSaveForm,\n * OneBlinkFormControlled,\n * useFormSubmissionAutoSaveState,\n * } from '@oneblink/apps-react'\n *\n * function OneBlinkAutoSaveFormControlled({\n * form,\n * initialSubmission,\n * autoSaveKey,\n * onCancel,\n * onSubmit,\n * onSaveDraft,\n * ...props\n * }: React.ComponentProps<typeof OneBlinkAutoSaveForm>) {\n * const {\n * definition,\n * submission,\n * isLoadingAutoSaveSubmission,\n * isAutoSaveSubmissionAvailable,\n * startNewSubmission,\n * continueAutoSaveSubmission,\n * handleSubmit,\n * handleCancel,\n * handleSaveDraft,\n * setFormSubmission,\n * } = useFormSubmissionAutoSaveState({\n * form,\n * initialSubmission,\n * autoSaveKey,\n * onCancel,\n * onSubmit,\n * onSaveDraft,\n * })\n *\n * // This is just an example of how you could intercept\n * // the change event when a user enters/selects a value\n * // on the form.\n * const customSetFormSubmission = React.useCallback(\n * (formSubmission) => {\n * setFormSubmission((currentFormSubmission) => {\n * const newFormSubmission =\n * typeof formSubmission === 'function'\n * ? formSubmission(currentFormSubmission)\n * : formSubmission\n *\n * // This is where you can access the updated\n * // submission data or form definition.\n * // You could even change the form definition\n * // programmatically based on user inputs.\n * console.log(\n * 'A change has occurred to the submission',\n * newFormSubmission.submission,\n * )\n * newFormSubmission.definition.isInfoPage =\n * !newFormSubmission.submission.doesTheUserNeedToSubmit\n *\n * return newFormSubmission\n * })\n * },\n * [setFormSubmission],\n * )\n *\n * if (isLoadingAutoSaveSubmission) {\n * return <p>Checking for auto save data...</p>\n * }\n *\n * if (isAutoSaveSubmissionAvailable) {\n * return (\n * <>\n * <p>Do you want to use the auto save data?</p>\n * <button onClick={startNewSubmission}>No, start again</button>\n * <button onClick={continueAutoSaveSubmission}>\n * Yes, continue\n * </button>\n * </>\n * )\n * }\n *\n * return (\n * <OneBlinkFormControlled\n * {...props}\n * submission={submission}\n * definition={definition}\n * onCancel={handleCancel}\n * onSubmit={handleSubmit}\n * onSaveDraft={handleSaveDraft}\n * setFormSubmission={customSetFormSubmission}\n * />\n * )\n * }\n *\n * export default React.memo(OneBlinkAutoSaveFormControlled)\n * ```\n *\n * @param props\n * @returns\n */\nconst OneBlinkFormControlled = React.memo(function OneBlinkFormControlled(\n props: OneBlinkFormBaseProps & OneBlinkFormControlledProps,\n) {\n return <OneBlinkFormBase {...props} isReadOnly={false} />\n})\n\n/**\n * Component for rendering a OneBlink Form. This component will render the\n * submit, cancel and save draft buttons but it is up to the developer to\n * implement what happens when those buttons are clicked.\n *\n * It is also recommended to import the `css` from this library as well.\n *\n * ```js\n * import { OneBlinkForm } from '@oneblink/apps-react'\n * import '@oneblink/apps-react/dist/styles.css'\n * ```\n *\n * #### Example\n *\n * ```tsx\n * import React from 'react'\n * import ReactDOM from 'react-dom'\n * import { FormTypes } from '@oneblink/types'\n * import {\n * OneBlinkAppsError,\n * draftService,\n * submissionService,\n * } from '@oneblink/apps'\n * import {\n * IsOfflineContextProvider,\n * OneBlinkForm,\n * useIsMounted,\n * } from '@oneblink/apps-react'\n * import '@oneblink/apps-react/dist/styles.css'\n *\n * const captchaSiteKey = 'ENTER_YOUR_SITE_KEY_HERE'\n * const googleMapsApiKey = 'ENTER_YOUR_MAPS_API_KEY_HERE'\n * const formsAppId = 1\n * const form: FormTypes.Form = {\n * id: 1,\n * name: 'Name of Form',\n * description: '',\n * organisationId: 'abc123',\n * formsAppEnvironmentId: 1,\n * formsAppIds: [],\n * elements: [],\n * isAuthenticated: false,\n * isMultiPage: false,\n * isInfoPage: false,\n * publishStartDate: null,\n * publishEndDate: null,\n * postSubmissionAction: 'FORMS_LIBRARY',\n * submissionEvents: [],\n * tags: [],\n * }\n *\n * function FormContainer() {\n * const isMounted = useIsMounted()\n *\n * const [{ isSavingDraft, saveDraftError }, setSaveDraftState] =\n * React.useState({\n * isSavingDraft: false,\n * saveDraftError: null,\n * })\n *\n * const [\n * { isSubmitting, submitError, formSubmissionResult },\n * setSubmitState,\n * ] = React.useState({\n * formSubmissionResult: null,\n * isSubmitting: false,\n * submitError: null,\n * })\n *\n * const handleSubmit = React.useCallback(\n * async (newFormSubmission: FormTypes.NewFormSubmission) => {\n * const formSubmission: FormSubmission = Object.assign(\n * {},\n * newFormSubmission,\n * {\n * formsAppId,\n * jobId: null,\n * externalId: null,\n * draftId: null,\n * preFillFormDataId: null,\n * },\n * )\n *\n * setSubmitState({\n * formSubmissionResult: null,\n * submitError: null,\n * isSubmitting: true,\n * })\n *\n * try {\n * const newFormSubmissionResult = await submissionService.submit({\n * formSubmission,\n * })\n * if (\n * newFormSubmissionResult.isOffline &&\n * !newFormSubmissionResult.isInPendingQueue\n * ) {\n * throw new OneBlinkAppsError(\n * 'You cannot submit this form while offline, please try again when connectivity is restored.',\n * {\n * isOffline: true,\n * },\n * )\n * }\n *\n * if (isMounted.current) {\n * setSubmitState({\n * formSubmissionResult: newFormSubmissionResult,\n * isSubmitting: false,\n * submitError: null,\n * })\n * }\n * } catch (error) {\n * if (isMounted.current) {\n * setSubmitState({\n * formSubmissionResult: null,\n * isSubmitting: false,\n * submitError: error,\n * })\n * }\n * }\n * },\n * [isMounted],\n * )\n *\n * const handleSaveDraft = React.useCallback(\n * async (newDraftSubmission: FormTypes.NewDraftSubmission) => {\n * const draftSubmission: FormTypes.DraftSubmission = {\n * ...newDraftSubmission,\n * formsAppId,\n * }\n * setSaveDraftState({\n * saveDraftError: null,\n * isSavingDraft: true,\n * })\n *\n * try {\n * await draftService.addDraft(\n * {\n * title: form.name,\n * formId: form.id,\n * externalId: null,\n * jobId: null,\n * },\n * draftSubmission,\n * )\n *\n * if (isMounted.current) {\n * setSaveDraftState({\n * saveDraftError: null,\n * isSavingDraft: false,\n * })\n * }\n * } catch (error) {\n * if (isMounted.current) {\n * setSaveDraftState({\n * saveDraftError: error,\n * isSavingDraft: false,\n * })\n * }\n * }\n * },\n * [isMounted],\n * )\n *\n * const handleCancel = React.useCallback(() => {\n * // handle cancel here...\n * }, [isMounted])\n *\n * if (isSubmitting) {\n * // Render submitting animation/loading\n * }\n *\n * if (submitError) {\n * // Render error while submitting\n * }\n *\n * if (isSavingDraft) {\n * // Render saving draft animation/loading\n * }\n *\n * if (saveDraftError) {\n * // Render error while saving draft\n * }\n *\n * if (formSubmissionResult) {\n * // Render submission success\n * }\n *\n * return (\n * <OneBlinkForm\n * captchaSiteKey={captchaSiteKey}\n * googleMapsApiKey={googleMapsApiKey}\n * formsAppId={formsAppId}\n * form={form}\n * onCancel={handleCancel}\n * onSubmit={handleSubmit}\n * onSaveDraft={handleSaveDraft}\n * attachmentRetentionInDays={1}\n * />\n * )\n * }\n *\n * function App() {\n * return (\n * <IsOfflineContextProvider>\n * <FormContainer />\n * </IsOfflineContextProvider>\n * )\n * }\n *\n * const root = document.getElementById('root')\n * if (root) {\n * ReactDOM.render(<App />, root)\n * }\n * ```\n *\n * @param props\n * @returns\n */\nconst OneBlinkFormUncontrolled = React.memo(function OneBlinkFormUncontrolled({\n form,\n initialSubmission,\n resumeAtElement,\n ...props\n}: OneBlinkFormBaseProps & {\n /** The OneBlink Form to render */\n form: FormTypes.Form\n /** The initial submission data */\n initialSubmission?: SubmissionTypes.S3SubmissionData['submission']\n /** The element to resume the form at. */\n resumeAtElement?: FormTypes.FormElement\n}) {\n const [{ definition, submission, lastElementUpdated }, setFormSubmission] =\n useFormSubmissionState(form, initialSubmission, resumeAtElement)\n return (\n <OneBlinkFormBase\n {...props}\n isReadOnly={false}\n definition={definition}\n submission={submission}\n setFormSubmission={setFormSubmission}\n lastElementUpdated={lastElementUpdated}\n />\n )\n})\n\nexport { OneBlinkFormControlled, OneBlinkFormUncontrolled }\n"]}
1
+ {"version":3,"file":"OneBlinkForm.js","sourceRoot":"","sources":["../src/OneBlinkForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,gBAGN,MAAM,oBAAoB,CAAA;AAC3B,OAAO,sBAAsB,MAAM,gCAAgC,CAAA;AAInE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoUG;AACH,MAAM,sBAAsB,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,sBAAsB,CACvE,KAA0D;IAE1D,OAAO,oBAAC,gBAAgB,OAAK,KAAK,EAAE,UAAU,EAAE,KAAK,GAAI,CAAA;AAC3D,CAAC,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4NG;AACH,MAAM,wBAAwB,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,wBAAwB,CAAC,EAC5E,IAAI,EACJ,iBAAiB,EACjB,eAAe,EACf,GAAG,KAAK,EAQT;IACC,MAAM,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,EAAE,iBAAiB,CAAC,GACvE,sBAAsB,CAAC,IAAI,EAAE,iBAAiB,EAAE,eAAe,CAAC,CAAA;IAClE,OAAO,CACL,oBAAC,gBAAgB,OACX,KAAK,EACT,UAAU,EAAE,KAAK,EACjB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,iBAAiB,EAAE,iBAAiB,EACpC,kBAAkB,EAAE,kBAAkB,GACtC,CACH,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,CAAA","sourcesContent":["import * as React from 'react'\nimport { FormTypes, SubmissionTypes } from '@oneblink/types'\nimport OneBlinkFormBase, {\n OneBlinkFormBaseProps,\n OneBlinkFormControlledProps,\n} from './OneBlinkFormBase'\nimport useFormSubmissionState from './hooks/useFormSubmissionState'\n\nexport { OneBlinkFormBaseProps, OneBlinkFormControlledProps }\n\n/**\n * Similar to {@link OneBlinkForm}, however requires props to control the\n * `definition` and `submission` values.\n *\n * #### Example\n *\n * ```tsx\n * import React from 'react'\n * import ReactDOM from 'react-dom'\n * import { FormTypes } from '@oneblink/types'\n * import {\n * OneBlinkAppsError,\n * draftService,\n * submissionService,\n * } from '@oneblink/apps'\n * import {\n * IsOfflineContextProvider,\n * OneBlinkFormControlled,\n * useIsMounted,\n * useFormSubmissionState,\n * } from '@oneblink/apps-react'\n * import '@oneblink/apps-react/dist/styles.css'\n *\n * const captchaSiteKey = 'ENTER_YOUR_SITE_KEY_HERE'\n * const googleMapsApiKey = 'ENTER_YOUR_MAPS_API_KEY_HERE'\n * const formsAppId = 1\n * const form: FormTypes.Form = {\n * id: 1,\n * name: 'Name of Form',\n * description: '',\n * organisationId: 'abc123',\n * formsAppEnvironmentId: 1,\n * formsAppIds: [],\n * elements: [],\n * isAuthenticated: false,\n * isMultiPage: false,\n * isInfoPage: false,\n * publishStartDate: null,\n * publishEndDate: null,\n * postSubmissionAction: 'FORMS_LIBRARY',\n * submissionEvents: [],\n * tags: [],\n * }\n * const initialSubmission: Record<string, unknown> = {\n * data: 1,\n * }\n *\n * function FormContainer() {\n * const isMounted = useIsMounted()\n *\n * const [{ definition, submission }, setFormSubmission] =\n * useFormSubmissionState(form, initialSubmission)\n *\n * const [{ isSavingDraft, saveDraftError }, setSaveDraftState] =\n * React.useState({\n * isSavingDraft: false,\n * saveDraftError: null,\n * })\n *\n * const [\n * { isSubmitting, submitError, formSubmissionResult },\n * setSubmitState,\n * ] = React.useState({\n * formSubmissionResult: null,\n * isSubmitting: false,\n * submitError: null,\n * })\n *\n * const handleSubmit = React.useCallback(\n * async (newFormSubmission: FormTypes.NewFormSubmission) => {\n * const formSubmission: FormSubmission = Object.assign(\n * {},\n * newFormSubmission,\n * {\n * formsAppId,\n * jobId: null,\n * externalId: null,\n * draftId: null,\n * preFillFormDataId: null,\n * },\n * )\n *\n * setSubmitState({\n * formSubmissionResult: null,\n * submitError: null,\n * isSubmitting: true,\n * })\n *\n * try {\n * const newFormSubmissionResult = await submissionService.submit({\n * formSubmission,\n * })\n * if (\n * newFormSubmissionResult.isOffline &&\n * !newFormSubmissionResult.isInPendingQueue\n * ) {\n * throw new OneBlinkAppsError(\n * 'You cannot submit this form while offline, please try again when connectivity is restored.',\n * {\n * isOffline: true,\n * },\n * )\n * }\n *\n * if (isMounted.current) {\n * setSubmitState({\n * formSubmissionResult: newFormSubmissionResult,\n * isSubmitting: false,\n * submitError: null,\n * })\n * }\n * } catch (error) {\n * if (isMounted.current) {\n * setSubmitState({\n * formSubmissionResult: null,\n * isSubmitting: false,\n * submitError: error,\n * })\n * }\n * }\n * },\n * [isMounted],\n * )\n *\n * const handleSaveDraft = React.useCallback(\n * async (newDraftSubmission: FormTypes.NewDraftSubmission) => {\n * const draftSubmission: FormTypes.DraftSubmission = {\n * ...newDraftSubmission,\n * formsAppId,\n * }\n * setSaveDraftState({\n * saveDraftError: null,\n * isSavingDraft: true,\n * })\n *\n * try {\n * await draftService.addDraft(\n * {\n * title: form.name,\n * formId: form.id,\n * externalId: null,\n * jobId: null,\n * },\n * draftSubmission,\n * )\n *\n * if (isMounted.current) {\n * setSaveDraftState({\n * saveDraftError: null,\n * isSavingDraft: false,\n * })\n * }\n * } catch (error) {\n * if (isMounted.current) {\n * setSaveDraftState({\n * saveDraftError: error,\n * isSavingDraft: false,\n * })\n * }\n * }\n * },\n * [isMounted],\n * )\n *\n * const handleCancel = React.useCallback(() => {\n * // handle cancel here...\n * }, [])\n *\n * if (isSubmitting) {\n * // Render submitting animation/loading\n * }\n *\n * if (submitError) {\n * // Render error while submitting\n * }\n *\n * if (isSavingDraft) {\n * // Render saving draft animation/loading\n * }\n *\n * if (saveDraftError) {\n * // Render error while saving draft\n * }\n *\n * if (formSubmissionResult) {\n * // Render submission success\n * }\n *\n * return (\n * <OneBlinkFormControlled\n * captchaSiteKey={captchaSiteKey}\n * googleMapsApiKey={googleMapsApiKey}\n * formsAppId={formsAppId}\n * definition={definition}\n * submission={submission}\n * setFormSubmission={setFormSubmission}\n * onCancel={handleCancel}\n * onSubmit={handleSubmit}\n * onSaveDraft={handleSaveDraft}\n * />\n * )\n * }\n *\n * function App() {\n * return (\n * <IsOfflineContextProvider>\n * <FormContainer />\n * </IsOfflineContextProvider>\n * )\n * }\n *\n * const root = document.getElementById('root')\n * if (root) {\n * ReactDOM.render(<App />, root)\n * }\n * ```\n *\n * #### Implementing Controlled Auto Save\n *\n * The {@link OneBlinkAutoSaveForm} component does not offer props to allow for a\n * controlled form (i.e. having access to `submission` and `definition` values).\n * To implement a controlled version of the `<OneBlinkAutoSaveForm />`\n * component, use the example component below.\n *\n * ```tsx\n * import * as React from 'react'\n * import {\n * OneBlinkAutoSaveForm,\n * OneBlinkFormControlled,\n * useFormSubmissionAutoSaveState,\n * } from '@oneblink/apps-react'\n *\n * function OneBlinkAutoSaveFormControlled({\n * form,\n * initialSubmission,\n * autoSaveKey,\n * onCancel,\n * onSubmit,\n * onSaveDraft,\n * ...props\n * }: React.ComponentProps<typeof OneBlinkAutoSaveForm>) {\n * const {\n * definition,\n * submission,\n * isLoadingAutoSaveSubmission,\n * isAutoSaveSubmissionAvailable,\n * startNewSubmission,\n * continueAutoSaveSubmission,\n * handleSubmit,\n * handleCancel,\n * handleSaveDraft,\n * setFormSubmission,\n * } = useFormSubmissionAutoSaveState({\n * form,\n * initialSubmission,\n * autoSaveKey,\n * onCancel,\n * onSubmit,\n * onSaveDraft,\n * })\n *\n * // This is just an example of how you could intercept\n * // the change event when a user enters/selects a value\n * // on the form.\n * const customSetFormSubmission = React.useCallback(\n * (formSubmission) => {\n * setFormSubmission((currentFormSubmission) => {\n * const newFormSubmission =\n * typeof formSubmission === 'function'\n * ? formSubmission(currentFormSubmission)\n * : formSubmission\n *\n * // This is where you can access the updated\n * // submission data or form definition.\n * // You could even change the form definition\n * // programmatically based on user inputs.\n * console.log(\n * 'A change has occurred to the submission',\n * newFormSubmission.submission,\n * )\n * newFormSubmission.definition.isInfoPage =\n * !newFormSubmission.submission.doesTheUserNeedToSubmit\n *\n * return newFormSubmission\n * })\n * },\n * [setFormSubmission],\n * )\n *\n * if (isLoadingAutoSaveSubmission) {\n * return <p>Checking for auto save data...</p>\n * }\n *\n * if (isAutoSaveSubmissionAvailable) {\n * return (\n * <>\n * <p>Do you want to use the auto save data?</p>\n * <button onClick={startNewSubmission}>No, start again</button>\n * <button onClick={continueAutoSaveSubmission}>\n * Yes, continue\n * </button>\n * </>\n * )\n * }\n *\n * return (\n * <OneBlinkFormControlled\n * {...props}\n * submission={submission}\n * definition={definition}\n * onCancel={handleCancel}\n * onSubmit={handleSubmit}\n * onSaveDraft={handleSaveDraft}\n * setFormSubmission={customSetFormSubmission}\n * />\n * )\n * }\n *\n * export default React.memo(OneBlinkAutoSaveFormControlled)\n * ```\n *\n * @param props\n * @returns\n * @group Components\n */\nconst OneBlinkFormControlled = React.memo(function OneBlinkFormControlled(\n props: OneBlinkFormBaseProps & OneBlinkFormControlledProps,\n) {\n return <OneBlinkFormBase {...props} isReadOnly={false} />\n})\n\n/**\n * Component for rendering a OneBlink Form. This component will render the\n * submit, cancel and save draft buttons but it is up to the developer to\n * implement what happens when those buttons are clicked.\n *\n * It is also recommended to import the `css` from this library as well.\n *\n * ```js\n * import { OneBlinkForm } from '@oneblink/apps-react'\n * import '@oneblink/apps-react/dist/styles.css'\n * ```\n *\n * #### Example\n *\n * ```tsx\n * import React from 'react'\n * import ReactDOM from 'react-dom'\n * import { FormTypes } from '@oneblink/types'\n * import {\n * OneBlinkAppsError,\n * draftService,\n * submissionService,\n * } from '@oneblink/apps'\n * import {\n * IsOfflineContextProvider,\n * OneBlinkForm,\n * useIsMounted,\n * } from '@oneblink/apps-react'\n * import '@oneblink/apps-react/dist/styles.css'\n *\n * const captchaSiteKey = 'ENTER_YOUR_SITE_KEY_HERE'\n * const googleMapsApiKey = 'ENTER_YOUR_MAPS_API_KEY_HERE'\n * const formsAppId = 1\n * const form: FormTypes.Form = {\n * id: 1,\n * name: 'Name of Form',\n * description: '',\n * organisationId: 'abc123',\n * formsAppEnvironmentId: 1,\n * formsAppIds: [],\n * elements: [],\n * isAuthenticated: false,\n * isMultiPage: false,\n * isInfoPage: false,\n * publishStartDate: null,\n * publishEndDate: null,\n * postSubmissionAction: 'FORMS_LIBRARY',\n * submissionEvents: [],\n * tags: [],\n * }\n *\n * function FormContainer() {\n * const isMounted = useIsMounted()\n *\n * const [{ isSavingDraft, saveDraftError }, setSaveDraftState] =\n * React.useState({\n * isSavingDraft: false,\n * saveDraftError: null,\n * })\n *\n * const [\n * { isSubmitting, submitError, formSubmissionResult },\n * setSubmitState,\n * ] = React.useState({\n * formSubmissionResult: null,\n * isSubmitting: false,\n * submitError: null,\n * })\n *\n * const handleSubmit = React.useCallback(\n * async (newFormSubmission: FormTypes.NewFormSubmission) => {\n * const formSubmission: FormSubmission = Object.assign(\n * {},\n * newFormSubmission,\n * {\n * formsAppId,\n * jobId: null,\n * externalId: null,\n * draftId: null,\n * preFillFormDataId: null,\n * },\n * )\n *\n * setSubmitState({\n * formSubmissionResult: null,\n * submitError: null,\n * isSubmitting: true,\n * })\n *\n * try {\n * const newFormSubmissionResult = await submissionService.submit({\n * formSubmission,\n * })\n * if (\n * newFormSubmissionResult.isOffline &&\n * !newFormSubmissionResult.isInPendingQueue\n * ) {\n * throw new OneBlinkAppsError(\n * 'You cannot submit this form while offline, please try again when connectivity is restored.',\n * {\n * isOffline: true,\n * },\n * )\n * }\n *\n * if (isMounted.current) {\n * setSubmitState({\n * formSubmissionResult: newFormSubmissionResult,\n * isSubmitting: false,\n * submitError: null,\n * })\n * }\n * } catch (error) {\n * if (isMounted.current) {\n * setSubmitState({\n * formSubmissionResult: null,\n * isSubmitting: false,\n * submitError: error,\n * })\n * }\n * }\n * },\n * [isMounted],\n * )\n *\n * const handleSaveDraft = React.useCallback(\n * async (newDraftSubmission: FormTypes.NewDraftSubmission) => {\n * const draftSubmission: FormTypes.DraftSubmission = {\n * ...newDraftSubmission,\n * formsAppId,\n * }\n * setSaveDraftState({\n * saveDraftError: null,\n * isSavingDraft: true,\n * })\n *\n * try {\n * await draftService.addDraft(\n * {\n * title: form.name,\n * formId: form.id,\n * externalId: null,\n * jobId: null,\n * },\n * draftSubmission,\n * )\n *\n * if (isMounted.current) {\n * setSaveDraftState({\n * saveDraftError: null,\n * isSavingDraft: false,\n * })\n * }\n * } catch (error) {\n * if (isMounted.current) {\n * setSaveDraftState({\n * saveDraftError: error,\n * isSavingDraft: false,\n * })\n * }\n * }\n * },\n * [isMounted],\n * )\n *\n * const handleCancel = React.useCallback(() => {\n * // handle cancel here...\n * }, [isMounted])\n *\n * if (isSubmitting) {\n * // Render submitting animation/loading\n * }\n *\n * if (submitError) {\n * // Render error while submitting\n * }\n *\n * if (isSavingDraft) {\n * // Render saving draft animation/loading\n * }\n *\n * if (saveDraftError) {\n * // Render error while saving draft\n * }\n *\n * if (formSubmissionResult) {\n * // Render submission success\n * }\n *\n * return (\n * <OneBlinkForm\n * captchaSiteKey={captchaSiteKey}\n * googleMapsApiKey={googleMapsApiKey}\n * formsAppId={formsAppId}\n * form={form}\n * onCancel={handleCancel}\n * onSubmit={handleSubmit}\n * onSaveDraft={handleSaveDraft}\n * attachmentRetentionInDays={1}\n * />\n * )\n * }\n *\n * function App() {\n * return (\n * <IsOfflineContextProvider>\n * <FormContainer />\n * </IsOfflineContextProvider>\n * )\n * }\n *\n * const root = document.getElementById('root')\n * if (root) {\n * ReactDOM.render(<App />, root)\n * }\n * ```\n *\n * @param props\n * @returns\n * @group Components\n */\nconst OneBlinkFormUncontrolled = React.memo(function OneBlinkFormUncontrolled({\n form,\n initialSubmission,\n resumeAtElement,\n ...props\n}: OneBlinkFormBaseProps & {\n /** The OneBlink Form to render */\n form: FormTypes.Form\n /** The initial submission data */\n initialSubmission?: SubmissionTypes.S3SubmissionData['submission']\n /** The element to resume the form at. */\n resumeAtElement?: FormTypes.FormElement\n}) {\n const [{ definition, submission, lastElementUpdated }, setFormSubmission] =\n useFormSubmissionState(form, initialSubmission, resumeAtElement)\n return (\n <OneBlinkFormBase\n {...props}\n isReadOnly={false}\n definition={definition}\n submission={submission}\n setFormSubmission={setFormSubmission}\n lastElementUpdated={lastElementUpdated}\n />\n )\n})\n\nexport { OneBlinkFormControlled, OneBlinkFormUncontrolled }\n"]}
@@ -82,6 +82,7 @@ declare function OneBlinkReadOnlyForm({ form, initialSubmission, ...rest }: {
82
82
  *
83
83
  * @param props
84
84
  * @returns
85
+ * @group Components
85
86
  */
86
87
  declare const _default: React.MemoExoticComponent<typeof OneBlinkReadOnlyForm>;
87
88
  export default _default;
@@ -122,6 +122,7 @@ function OneBlinkReadOnlyForm({ form, initialSubmission, ...rest }) {
122
122
  *
123
123
  * @param props
124
124
  * @returns
125
+ * @group Components
125
126
  */
126
127
  export default React.memo(OneBlinkReadOnlyForm);
127
128
  //# sourceMappingURL=OneBlinkReadOnlyForm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OneBlinkReadOnlyForm.js","sourceRoot":"","sources":["../src/OneBlinkReadOnlyForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,sBAAsB,MAAM,gCAAgC,CAAA;AAEnE,SAAS,sBAAsB,CAC7B,QAAiC;IAEjC,MAAM,WAAW,GAAG,QAAQ;SACzB,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC;SAC/C,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACf,IACE,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM;YACtB,OAAO,CAAC,IAAI,KAAK,SAAS;YAC1B,OAAO,CAAC,IAAI,KAAK,MAAM;YACvB,OAAO,CAAC,IAAI,KAAK,eAAe,CAAC;YACnC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAC/B;YACA,OAAO;gBACL,GAAG,OAAO;gBACV,QAAQ,EAAE,sBAAsB,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE;aACzD,CAAA;SACF;QAED,IACE,OAAO,CAAC,IAAI,KAAK,SAAS;YAC1B,OAAO,CAAC,IAAI,KAAK,SAAS;YAC1B,OAAO,CAAC,IAAI,KAAK,MAAM;YACvB,OAAO,CAAC,IAAI,KAAK,MAAM;YACvB,OAAO,CAAC,IAAI,KAAK,S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;;;;;;GA6EG;AACH,eAAe,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport { FormTypes, SubmissionTypes } from '@oneblink/types'\nimport OneBlinkFormBase from './OneBlinkFormBase'\nimport useFormSubmissionState from './hooks/useFormSubmissionState'\n\nfunction recursivelySetReadOnly(\n elements: FormTypes.FormElement[],\n): FormTypes.FormElement[] {\n const newElements = elements\n .filter((element) => element.type !== 'captcha')\n .map((element) => {\n if (\n (element.type === 'form' ||\n element.type === 'section' ||\n element.type === 'page' ||\n element.type === 'repeatableSet') &&\n Array.isArray(element.elements)\n ) {\n return {\n ...element,\n elements: recursivelySetReadOnly(element.elements) || [],\n }\n }\n\n if (\n element.type !== 'section' &&\n element.type !== 'heading' &&\n element.type !== 'page' &&\n element.type !== 'html' &&\n element.type !== 'captcha' &&\n element.type !== 'image' &&\n element.type !== 'calculation' &&\n element.type !== 'summary' &&\n element.type !== 'form' &&\n element.type !== 'infoPage'\n ) {\n return {\n ...element,\n readOnly: true,\n }\n }\n\n return element\n })\n\n return newElements\n}\n\nfunction OneBlinkReadOnlyForm({\n form,\n initialSubmission,\n ...rest\n}: {\n form: FormTypes.Form\n initialSubmission?: SubmissionTypes.S3SubmissionData['submission']\n googleMapsApiKey?: string\n}) {\n const [{ submission, definition }, setFormSubmission] =\n useFormSubmissionState(form, initialSubmission)\n\n const readOnlyDefinition = React.useMemo(() => {\n return {\n ...definition,\n elements: recursivelySetReadOnly(definition.elements || []),\n }\n }, [definition])\n\n const noop = React.useCallback(() => {}, [])\n\n return (\n <OneBlinkFormBase\n definition={readOnlyDefinition}\n submission={submission}\n disabled={true}\n isReadOnly={true}\n onCancel={noop}\n onSubmit={noop}\n setFormSubmission={setFormSubmission}\n isPendingQueueEnabled={false}\n {...rest}\n />\n )\n}\n\n/**\n * Component for rendering a OneBlink Form in read-only mode. This component\n * will render the form with all inputs disabled but will **not** render the\n * submit, cancel and save draft buttons.\n *\n * It is also recommended to import the `css` from this library as well.\n *\n * ```js\n * import { OneBlinkReadOnlyForm } from '@oneblink/apps-react'\n * import '@oneblink/apps-react/dist/styles.css'\n * ```\n *\n * #### Example\n *\n * ```tsx\n * import React from 'react'\n * import ReactDOM from 'react-dom'\n * import { FormTypes } from '@oneblink/apps'\n * import {\n * IsOfflineContextProvider,\n * OneBlinkReadOnlyForm,\n * useIsMounted,\n * } from '@oneblink/apps-react'\n * import '@oneblink/apps-react/dist/styles.css'\n *\n * const googleMapsApiKey = 'ENTER_YOUR_MAPS_API_KEY_HERE'\n * const formsAppId = 1\n * const form: FormTypes.Form = {\n * id: 1,\n * name: 'Name of Form',\n * description: '',\n * organisationId: 'abc123',\n * formsAppEnvironmentId: 1,\n * formsAppIds: [],\n * elements: [],\n * isAuthenticated: false,\n * isMultiPage: false,\n * isInfoPage: false,\n * publishStartDate: null,\n * publishEndDate: null,\n * postSubmissionAction: 'FORMS_LIBRARY',\n * submissionEvents: [],\n * tags: [],\n * }\n *\n * function FormContainer() {\n * const isMounted = useIsMounted()\n *\n * const handleFormError = React.useCallback(() => {\n * // handle form rendering error caused by a misconfigured form here...\n * }, [isMounted])\n *\n * return (\n * <OneBlinkReadOnlyForm\n * googleMapsApiKey={googleMapsApiKey}\n * initialSubmission={null}\n * form={form}\n * />\n * )\n * }\n *\n * function App() {\n * return (\n * <IsOfflineContextProvider>\n * <FormContainer />\n * </IsOfflineContextProvider>\n * )\n * }\n *\n * const root = document.getElementById('root')\n * if (root) {\n * ReactDOM.render(<App />, root)\n * }\n * ```\n *\n * @param props\n * @returns\n */\nexport default React.memo(OneBlinkReadOnlyForm)\n"]}
1
+ {"version":3,"file":"OneBlinkReadOnlyForm.js","sourceRoot":"","sources":["../src/OneBlinkReadOnlyForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,sBAAsB,MAAM,gCAAgC,CAAA;AAEn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I,EAAE,iBAAiB,CAAC,CAAA;IAEjD,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAC5C,OAAO;YACL,GAAG,UAAU;YACb,QAAQ,EAAE,sBAAsB,CAAC,UAAU,CAAC,QAAQ,IAAI,EAAE,CAAC;SAC5D,CAAA;IACH,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAA;IAEhB,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAE,CAAC,EAAE,EAAE,CAAC,CAAA;IAE5C,OAAO,CACL,oBAAC,gBAAgB,IACf,UAAU,EAAE,kBAAkB,EAC9B,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,IAAI,EACd,UAAU,EAAE,IAAI,EAChB,QAAQ,EAAE,IAAI,EACd,QAAQ,EAAE,IAAI,EACd,iBAAiB,EAAE,iBAAiB,EACpC,qBAAqB,EAAE,KAAK,KACxB,IAAI,GACR,CACH,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AACH,eAAe,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport { FormTypes, SubmissionTypes } from '@oneblink/types'\nimport OneBlinkFormBase from './OneBlinkFormBase'\nimport useFormSubmissionState from './hooks/useFormSubmissionState'\n\nfunction recursivelySetReadOnly(\n elements: FormTypes.FormElement[],\n): FormTypes.FormElement[] {\n const newElements = elements\n .filter((element) => element.type !== 'captcha')\n .map((element) => {\n if (\n (element.type === 'form' ||\n element.type === 'section' ||\n element.type === 'page' ||\n element.type === 'repeatableSet') &&\n Array.isArray(element.elements)\n ) {\n return {\n ...element,\n elements: recursivelySetReadOnly(element.elements) || [],\n }\n }\n\n if (\n element.type !== 'section' &&\n element.type !== 'heading' &&\n element.type !== 'page' &&\n element.type !== 'html' &&\n element.type !== 'captcha' &&\n element.type !== 'image' &&\n element.type !== 'calculation' &&\n element.type !== 'summary' &&\n element.type !== 'form' &&\n element.type !== 'infoPage'\n ) {\n return {\n ...element,\n readOnly: true,\n }\n }\n\n return element\n })\n\n return newElements\n}\n\nfunction OneBlinkReadOnlyForm({\n form,\n initialSubmission,\n ...rest\n}: {\n form: FormTypes.Form\n initialSubmission?: SubmissionTypes.S3SubmissionData['submission']\n googleMapsApiKey?: string\n}) {\n const [{ submission, definition }, setFormSubmission] =\n useFormSubmissionState(form, initialSubmission)\n\n const readOnlyDefinition = React.useMemo(() => {\n return {\n ...definition,\n elements: recursivelySetReadOnly(definition.elements || []),\n }\n }, [definition])\n\n const noop = React.useCallback(() => {}, [])\n\n return (\n <OneBlinkFormBase\n definition={readOnlyDefinition}\n submission={submission}\n disabled={true}\n isReadOnly={true}\n onCancel={noop}\n onSubmit={noop}\n setFormSubmission={setFormSubmission}\n isPendingQueueEnabled={false}\n {...rest}\n />\n )\n}\n\n/**\n * Component for rendering a OneBlink Form in read-only mode. This component\n * will render the form with all inputs disabled but will **not** render the\n * submit, cancel and save draft buttons.\n *\n * It is also recommended to import the `css` from this library as well.\n *\n * ```js\n * import { OneBlinkReadOnlyForm } from '@oneblink/apps-react'\n * import '@oneblink/apps-react/dist/styles.css'\n * ```\n *\n * #### Example\n *\n * ```tsx\n * import React from 'react'\n * import ReactDOM from 'react-dom'\n * import { FormTypes } from '@oneblink/apps'\n * import {\n * IsOfflineContextProvider,\n * OneBlinkReadOnlyForm,\n * useIsMounted,\n * } from '@oneblink/apps-react'\n * import '@oneblink/apps-react/dist/styles.css'\n *\n * const googleMapsApiKey = 'ENTER_YOUR_MAPS_API_KEY_HERE'\n * const formsAppId = 1\n * const form: FormTypes.Form = {\n * id: 1,\n * name: 'Name of Form',\n * description: '',\n * organisationId: 'abc123',\n * formsAppEnvironmentId: 1,\n * formsAppIds: [],\n * elements: [],\n * isAuthenticated: false,\n * isMultiPage: false,\n * isInfoPage: false,\n * publishStartDate: null,\n * publishEndDate: null,\n * postSubmissionAction: 'FORMS_LIBRARY',\n * submissionEvents: [],\n * tags: [],\n * }\n *\n * function FormContainer() {\n * const isMounted = useIsMounted()\n *\n * const handleFormError = React.useCallback(() => {\n * // handle form rendering error caused by a misconfigured form here...\n * }, [isMounted])\n *\n * return (\n * <OneBlinkReadOnlyForm\n * googleMapsApiKey={googleMapsApiKey}\n * initialSubmission={null}\n * form={form}\n * />\n * )\n * }\n *\n * function App() {\n * return (\n * <IsOfflineContextProvider>\n * <FormContainer />\n * </IsOfflineContextProvider>\n * )\n * }\n *\n * const root = document.getElementById('root')\n * if (root) {\n * ReactDOM.render(<App />, root)\n * }\n * ```\n *\n * @param props\n * @returns\n * @group Components\n */\nexport default React.memo(OneBlinkReadOnlyForm)\n"]}
@@ -58,6 +58,10 @@ declare function PaymentReceipt({ onDone, onCancel, }: {
58
58
  * ReactDOM.render(<App />, root)
59
59
  * }
60
60
  * ```
61
+ *
62
+ * @param props
63
+ * @returns
64
+ * @group Components
61
65
  */
62
66
  declare const _default: React.MemoExoticComponent<typeof PaymentReceipt>;
63
67
  export default _default;
@@ -195,6 +195,10 @@ function PaymentReceipt({ onDone, onCancel, }) {
195
195
  * ReactDOM.render(<App />, root)
196
196
  * }
197
197
  * ```
198
+ *
199
+ * @param props
200
+ * @returns
201
+ * @group Components
198
202
  */
199
203
  export default React.memo(PaymentReceipt);
200
204
  //# sourceMappingURL=PaymentReceipt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PaymentReceipt.js","sourceRoot":"","sources":["../src/PaymentReceipt.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,mBAAmB,GAEpB,MAAM,gBAAgB,CAAA;AACvB,OAAO,YAAY,MAAM,sBAAsB,CAAA;AAE/C,OAAO,QAAQ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":["import * as React from 'react'\nimport { useHistory } from 'react-router-dom'\nimport {\n paymentService,\n submissionService,\n localisationService,\n OneBlinkAppsError,\n} from '@oneblink/apps'\nimport useIsMounted from './hooks/useIsMounted'\n\nimport useQuery from './hooks/useQuery'\nimport Modal from './components/renderer/Modal'\nimport OnLoading from './components/renderer/OnLoading'\nimport {\n Receipt,\n ReceiptList,\n ReceiptListItem,\n ReceiptButton,\n} from './components/receipts'\n\nconst { handlePaymentQuerystring, handlePaymentSubmissionEvent } =\n paymentService\n\nfunction PaymentReceipt({\n onDone,\n onCancel,\n}: {\n /**\n * The function to call when the user clicks 'Done'. See\n * [FormSubmissionResult](https://oneblink.github.io/apps/modules/submissionService.html#FormSubmissionResult)\n * for the structure of the argument.\n */\n onDone: (\n submissionResult: submissionService.FormSubmissionResult,\n ) => Promise<void>\n /**\n * The function to call when the user clicks 'Cancel'. See\n * [FormSubmissionResult](https://oneblink.github.io/apps/modules/submissionService.html#FormSubmissionResult)\n * for the structure of the argument.\n */\n onCancel: (\n submissionResult: submissionService.FormSubmissionResult,\n ) => Promise<void>\n}) {\n const isMounted = useIsMounted()\n const query = useQuery()\n const history = useHistory()\n\n const [\n { isLoading, loadError, transaction, submissionResult },\n setLoadState,\n ] = React.useState<{\n isLoading: boolean\n loadError: Error | null\n transaction: paymentService.HandlePaymentResult['transaction'] | null\n submissionResult: submissionService.FormSubmissionResult | null\n }>({\n isLoading: true,\n loadError: null,\n transaction: null,\n submissionResult: null,\n })\n const [\n { isRunningPostSubmissionAction, postSubmissionError },\n setPostSubmissionState,\n ] = React.useState<{\n isRunningPostSubmissionAction: boolean\n postSubmissionError: OneBlinkAppsError | null\n }>({\n isRunningPostSubmissionAction: false,\n postSubmissionError: null,\n })\n const clearPostSubmissionError = React.useCallback(() => {\n setPostSubmissionState((currentState) => ({\n ...currentState,\n postSubmissionError: null,\n }))\n }, [])\n const [{ isRetrying, retryError }, setRetryState] = React.useState<{\n isRetrying: boolean\n retryError: OneBlinkAppsError | null\n }>({\n isRetrying: false,\n retryError: null,\n })\n const clearRetryError = React.useCallback(() => {\n setRetryState((currentState) => ({\n ...currentState,\n retryError: null,\n }))\n }, [])\n\n React.useEffect(() => {\n let ignore = false\n\n const getTransaction = async () => {\n let newError = null\n let newTransaction = null\n let newSubmissionResult = null\n try {\n const result = await handlePaymentQuerystring(query)\n newTransaction = result.transaction\n newSubmissionResult = result.submissionResult\n } catch (error) {\n console.warn('Error while attempting to load transaction', error)\n newError = error as Error\n }\n\n if (!ignore) {\n setLoadState({\n isLoading: false,\n loadError: newError,\n transaction: newTransaction,\n submissionResult: newSubmissionResult,\n })\n }\n }\n getTransaction()\n\n return () => {\n ignore = true\n }\n }, [query])\n\n const executePostSubmissionAction = React.useCallback(\n async (\n action: (\n submissionRresult: submissionService.FormSubmissionResult,\n ) => Promise<void>,\n ) => {\n if (!submissionResult || !isMounted.current) {\n return\n }\n\n setPostSubmissionState({\n isRunningPostSubmissionAction: true,\n postSubmissionError: null,\n })\n\n let newError = null\n try {\n await action({ ...submissionResult, payment: null })\n } catch (error) {\n console.warn('Error while running post submission action', error)\n newError = error as OneBlinkAppsError\n }\n\n if (isMounted.current) {\n setPostSubmissionState({\n isRunningPostSubmissionAction: false,\n postSubmissionError: newError,\n })\n }\n },\n [isMounted, submissionResult],\n )\n\n const handleDone = React.useCallback(async () => {\n executePostSubmissionAction(onDone)\n }, [executePostSubmissionAction, onDone])\n\n const handleCancel = React.useCallback(() => {\n executePostSubmissionAction(onCancel)\n }, [executePostSubmissionAction, onCancel])\n\n const handleTryAgain = React.useCallback(async () => {\n if (!submissionResult || !submissionResult.payment) {\n return\n }\n const paymentSubmissionEvent = submissionResult.payment.submissionEvent\n\n if (isMounted.current) {\n setRetryState({\n isRetrying: true,\n retryError: null,\n })\n }\n\n let newError = null\n try {\n submissionResult.payment = await handlePaymentSubmissionEvent({\n amount: submissionResult.payment.amount,\n formSubmissionResult: submissionResult,\n paymentSubmissionEvent,\n paymentReceiptUrl: `${window.location.origin}${window.location.pathname}`,\n })\n await submissionService.executePostSubmissionAction(\n submissionResult,\n history.push,\n )\n } catch (error) {\n console.warn('Error while attempting to retry transaction', error)\n newError = error as OneBlinkAppsError\n }\n\n if (isMounted.current) {\n setRetryState({\n isRetrying: false,\n retryError: newError,\n })\n }\n }, [history.push, isMounted, submissionResult])\n\n return (\n <div>\n {isLoading && (\n <section>\n <div className=\"cypress-loading has-text-centered\">\n <OnLoading className=\"has-text-centered\"></OnLoading>\n <span>Retrieving transaction details...</span>\n </div>\n </section>\n )}\n\n {transaction && (\n <Receipt\n className=\"ob-payment-receipt\"\n containerClassName=\"ob-payment-receipt__container\"\n >\n <ReceiptList\n successIconClassName=\"ob-payment-receipt__success-icon\"\n warningIconClassName=\"ob-payment-receipt__warning-icon\"\n warningMessageClassName=\"ob-payment-receipt__warning-message cypress-payment-receipt-warning-message\"\n warningMessage={\n transaction.isSuccess\n ? undefined\n : transaction.errorMessage || undefined\n }\n >\n {submissionResult && submissionResult.submissionId && (\n <ReceiptListItem\n className=\"ob-payment-receipt__submission-id\"\n valueClassName=\"cypress-payment-receipt-submission-id\"\n icon=\"receipt\"\n label=\"Submission Id\"\n value={submissionResult.submissionId}\n allowCopyToClipboard\n />\n )}\n\n {!!transaction.id && (\n <ReceiptListItem\n className=\"ob-payment-receipt__transaction-id\"\n valueClassName=\"cypress-payment-receipt-transaction-id\"\n icon=\"shopping_cart\"\n label=\"Transaction Id\"\n value={transaction.id}\n allowCopyToClipboard\n />\n )}\n\n {!!transaction.creditCardMask && (\n <ReceiptListItem\n className=\"ob-payment-receipt__card-number\"\n valueClassName=\"cypress-payment-receipt-card-number\"\n icon=\"credit_card\"\n label=\"Card Number\"\n value={transaction.creditCardMask}\n />\n )}\n\n {!!transaction.amount && (\n <ReceiptListItem\n className=\"ob-payment-receipt__amount\"\n valueClassName=\"cypress-payment-receipt-amount\"\n icon=\"attach_money\"\n label=\"Amount\"\n value={localisationService.formatCurrency(transaction.amount)}\n />\n )}\n <ReceiptListItem\n className=\"ob-payment-receipt__warning\"\n valueClassName=\"cypress-payment-receipt-warning\"\n label=\"Warning\"\n value=\"Please do not click back in your browser, doing so will cause issues with your payment.\"\n />\n </ReceiptList>\n\n <div className=\"buttons\">\n {transaction.isSuccess ? (\n <ReceiptButton\n className=\"is-primary ob-payment-receipt__button ob-payment-receipt__okay-button cypress-payment-receipt-okay-button\"\n label=\"Done\"\n isLoading={isRunningPostSubmissionAction}\n onClick={handleDone}\n />\n ) : (\n <>\n <ReceiptButton\n className=\"ob-payment-receipt__button ob-payment-receipt__cancel-button cypress-payment-receipt-cancel-button\"\n label=\"Cancel\"\n isDisabled={isRetrying}\n isLoading={isRunningPostSubmissionAction}\n onClick={handleCancel}\n />\n <ReceiptButton\n className=\"is-primary ob-payment-receipt__button ob-payment-receipt__try-again-button cypress-payment-receipt-try-again-button\"\n label=\"Try Again\"\n isDisabled={isRunningPostSubmissionAction}\n isLoading={isRetrying}\n onClick={handleTryAgain}\n />\n </>\n )}\n </div>\n </Receipt>\n )}\n\n {loadError && (\n <section className=\"cypress-payment-receipt-loading-error-message\">\n <div className=\"ob-payment-receipt__error-icon-container has-text-centered has-margin-bottom-8\">\n <i className=\"ob-payment-receipt__error-icon material-icons has-text-danger icon-x-large\">\n error\n </i>\n </div>\n <p className=\"ob-payment-receipt__error-message has-text-centered has-margin-bottom-4\">\n {loadError.message}\n </p>\n </section>\n )}\n\n {retryError && (\n <Modal\n isOpen\n title={retryError.title || 'Whoops...'}\n bodyClassName=\"cypress-payment-receipt-retry-error-message\"\n actions={\n <button\n type=\"button\"\n className=\"button ob-button is-primary cypress-payment-receipt-retry-error-okay-button\"\n onClick={clearRetryError}\n >\n Okay\n </button>\n }\n >\n {retryError.message}\n </Modal>\n )}\n\n {postSubmissionError && (\n <Modal\n isOpen\n title={postSubmissionError.title || 'Whoops...'}\n bodyClassName=\"cypress-payment-receipt-retry-error-message\"\n actions={\n <button\n type=\"button\"\n className=\"button ob-button is-primary cypress-payment-receipt-retry-error-okay-button\"\n onClick={clearPostSubmissionError}\n >\n Okay\n </button>\n }\n >\n {postSubmissionError.message}\n </Modal>\n )}\n </div>\n )\n}\n\n/**\n * Component for rendering a OneBlink Form Payment Receipt. This component will\n * payment receipt but it is up to the developer to implement what happens when\n * the user clicks 'Done'.\n *\n * It is also recommended to import the `css` from this library as well.\n *\n * ```js\n * import { PaymentReceipt } from '@oneblink/apps-react'\n * import '@oneblink/apps-react/dist/styles.css'\n * ```\n *\n * #### Example\n *\n * ```tsx\n * import React from 'react'\n * import ReactDOM from 'react-dom'\n * import { PaymentReceipt } from '@oneblink/apps-react'\n * import '@oneblink/apps-react/dist/styles.css'\n *\n * function ReceiptContainer() {\n * const handleDone = React.useCallback(async () => {\n * console.log('All done!')\n * }, [])\n * const handleCancel = React.useCallback(async () => {\n * console.log('Cancelled!')\n * }, [])\n *\n * return <PaymentReceipt onDone={handleDone} onCancel={handleCancel} />\n * }\n *\n * function App() {\n * return (\n * <IsOfflineContextProvider>\n * <ReceiptContainer />\n * </IsOfflineContextProvider>\n * )\n * }\n *\n * const root = document.getElementById('root')\n * if (root) {\n * ReactDOM.render(<App />, root)\n * }\n * ```\n */\nexport default React.memo(PaymentReceipt)\n"]}
1
+ {"version":3,"file":"PaymentReceipt.js","sourceRoot":"","sources":["../src/PaymentReceipt.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,mBAAmB,GAEpB,MAAM,gBAAgB,CAAA;AACvB,OAAO,YAAY,MAAM,sBAAsB,CAAA;AAE/C,OAAO,QAAQ,MAAM,kBAAkB,CAAA;AACvC,OAAO,KAAK,MAAM,6BAA6B,CAAA;AAC/C,OAAO,SAAS,MAAM,iCAAiC,CAAA;AACvD,OAAO,EACL,OAAO,EACP,WAAW,EACX,eAAe,EACf,aAAa,GACd,MAAM,uBAA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ACrB;gBACF,oBAAC,aAAa,IACZ,SAAS,EAAC,qHAAqH,EAC/H,KAAK,EAAC,WAAW,EACjB,UAAU,EAAE,6BAA6B,EACzC,SAAS,EAAE,UAAU,EACrB,OAAO,EAAE,cAAc,GACvB,CACD,CACJ,CACG,CACE,CACX;QAEA,SAAS,IAAI,CACZ,iCAAS,SAAS,EAAC,+CAA+C;YAChE,6BAAK,SAAS,EAAC,gFAAgF;gBAC7F,2BAAG,SAAS,EAAC,4EAA4E,YAErF,CACA;YACN,2BAAG,SAAS,EAAC,yEAAyE,IACnF,SAAS,CAAC,OAAO,CAChB,CACI,CACX;QAEA,UAAU,IAAI,CACb,oBAAC,KAAK,IACJ,MAAM,QACN,KAAK,EAAE,UAAU,CAAC,KAAK,IAAI,WAAW,EACtC,aAAa,EAAC,6CAA6C,EAC3D,OAAO,EACL,gCACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,6EAA6E,EACvF,OAAO,EAAE,eAAe,WAGjB,IAGV,UAAU,CAAC,OAAO,CACb,CACT;QAEA,mBAAmB,IAAI,CACtB,oBAAC,KAAK,IACJ,MAAM,QACN,KAAK,EAAE,mBAAmB,CAAC,KAAK,IAAI,WAAW,EAC/C,aAAa,EAAC,6CAA6C,EAC3D,OAAO,EACL,gCACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,6EAA6E,EACvF,OAAO,EAAE,wBAAwB,WAG1B,IAGV,mBAAmB,CAAC,OAAO,CACtB,CACT,CACG,CACP,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,eAAe,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport { useHistory } from 'react-router-dom'\nimport {\n paymentService,\n submissionService,\n localisationService,\n OneBlinkAppsError,\n} from '@oneblink/apps'\nimport useIsMounted from './hooks/useIsMounted'\n\nimport useQuery from './hooks/useQuery'\nimport Modal from './components/renderer/Modal'\nimport OnLoading from './components/renderer/OnLoading'\nimport {\n Receipt,\n ReceiptList,\n ReceiptListItem,\n ReceiptButton,\n} from './components/receipts'\n\nconst { handlePaymentQuerystring, handlePaymentSubmissionEvent } =\n paymentService\n\nfunction PaymentReceipt({\n onDone,\n onCancel,\n}: {\n /**\n * The function to call when the user clicks 'Done'. See\n * [FormSubmissionResult](https://oneblink.github.io/apps/modules/submissionService.html#FormSubmissionResult)\n * for the structure of the argument.\n */\n onDone: (\n submissionResult: submissionService.FormSubmissionResult,\n ) => Promise<void>\n /**\n * The function to call when the user clicks 'Cancel'. See\n * [FormSubmissionResult](https://oneblink.github.io/apps/modules/submissionService.html#FormSubmissionResult)\n * for the structure of the argument.\n */\n onCancel: (\n submissionResult: submissionService.FormSubmissionResult,\n ) => Promise<void>\n}) {\n const isMounted = useIsMounted()\n const query = useQuery()\n const history = useHistory()\n\n const [\n { isLoading, loadError, transaction, submissionResult },\n setLoadState,\n ] = React.useState<{\n isLoading: boolean\n loadError: Error | null\n transaction: paymentService.HandlePaymentResult['transaction'] | null\n submissionResult: submissionService.FormSubmissionResult | null\n }>({\n isLoading: true,\n loadError: null,\n transaction: null,\n submissionResult: null,\n })\n const [\n { isRunningPostSubmissionAction, postSubmissionError },\n setPostSubmissionState,\n ] = React.useState<{\n isRunningPostSubmissionAction: boolean\n postSubmissionError: OneBlinkAppsError | null\n }>({\n isRunningPostSubmissionAction: false,\n postSubmissionError: null,\n })\n const clearPostSubmissionError = React.useCallback(() => {\n setPostSubmissionState((currentState) => ({\n ...currentState,\n postSubmissionError: null,\n }))\n }, [])\n const [{ isRetrying, retryError }, setRetryState] = React.useState<{\n isRetrying: boolean\n retryError: OneBlinkAppsError | null\n }>({\n isRetrying: false,\n retryError: null,\n })\n const clearRetryError = React.useCallback(() => {\n setRetryState((currentState) => ({\n ...currentState,\n retryError: null,\n }))\n }, [])\n\n React.useEffect(() => {\n let ignore = false\n\n const getTransaction = async () => {\n let newError = null\n let newTransaction = null\n let newSubmissionResult = null\n try {\n const result = await handlePaymentQuerystring(query)\n newTransaction = result.transaction\n newSubmissionResult = result.submissionResult\n } catch (error) {\n console.warn('Error while attempting to load transaction', error)\n newError = error as Error\n }\n\n if (!ignore) {\n setLoadState({\n isLoading: false,\n loadError: newError,\n transaction: newTransaction,\n submissionResult: newSubmissionResult,\n })\n }\n }\n getTransaction()\n\n return () => {\n ignore = true\n }\n }, [query])\n\n const executePostSubmissionAction = React.useCallback(\n async (\n action: (\n submissionRresult: submissionService.FormSubmissionResult,\n ) => Promise<void>,\n ) => {\n if (!submissionResult || !isMounted.current) {\n return\n }\n\n setPostSubmissionState({\n isRunningPostSubmissionAction: true,\n postSubmissionError: null,\n })\n\n let newError = null\n try {\n await action({ ...submissionResult, payment: null })\n } catch (error) {\n console.warn('Error while running post submission action', error)\n newError = error as OneBlinkAppsError\n }\n\n if (isMounted.current) {\n setPostSubmissionState({\n isRunningPostSubmissionAction: false,\n postSubmissionError: newError,\n })\n }\n },\n [isMounted, submissionResult],\n )\n\n const handleDone = React.useCallback(async () => {\n executePostSubmissionAction(onDone)\n }, [executePostSubmissionAction, onDone])\n\n const handleCancel = React.useCallback(() => {\n executePostSubmissionAction(onCancel)\n }, [executePostSubmissionAction, onCancel])\n\n const handleTryAgain = React.useCallback(async () => {\n if (!submissionResult || !submissionResult.payment) {\n return\n }\n const paymentSubmissionEvent = submissionResult.payment.submissionEvent\n\n if (isMounted.current) {\n setRetryState({\n isRetrying: true,\n retryError: null,\n })\n }\n\n let newError = null\n try {\n submissionResult.payment = await handlePaymentSubmissionEvent({\n amount: submissionResult.payment.amount,\n formSubmissionResult: submissionResult,\n paymentSubmissionEvent,\n paymentReceiptUrl: `${window.location.origin}${window.location.pathname}`,\n })\n await submissionService.executePostSubmissionAction(\n submissionResult,\n history.push,\n )\n } catch (error) {\n console.warn('Error while attempting to retry transaction', error)\n newError = error as OneBlinkAppsError\n }\n\n if (isMounted.current) {\n setRetryState({\n isRetrying: false,\n retryError: newError,\n })\n }\n }, [history.push, isMounted, submissionResult])\n\n return (\n <div>\n {isLoading && (\n <section>\n <div className=\"cypress-loading has-text-centered\">\n <OnLoading className=\"has-text-centered\"></OnLoading>\n <span>Retrieving transaction details...</span>\n </div>\n </section>\n )}\n\n {transaction && (\n <Receipt\n className=\"ob-payment-receipt\"\n containerClassName=\"ob-payment-receipt__container\"\n >\n <ReceiptList\n successIconClassName=\"ob-payment-receipt__success-icon\"\n warningIconClassName=\"ob-payment-receipt__warning-icon\"\n warningMessageClassName=\"ob-payment-receipt__warning-message cypress-payment-receipt-warning-message\"\n warningMessage={\n transaction.isSuccess\n ? undefined\n : transaction.errorMessage || undefined\n }\n >\n {submissionResult && submissionResult.submissionId && (\n <ReceiptListItem\n className=\"ob-payment-receipt__submission-id\"\n valueClassName=\"cypress-payment-receipt-submission-id\"\n icon=\"receipt\"\n label=\"Submission Id\"\n value={submissionResult.submissionId}\n allowCopyToClipboard\n />\n )}\n\n {!!transaction.id && (\n <ReceiptListItem\n className=\"ob-payment-receipt__transaction-id\"\n valueClassName=\"cypress-payment-receipt-transaction-id\"\n icon=\"shopping_cart\"\n label=\"Transaction Id\"\n value={transaction.id}\n allowCopyToClipboard\n />\n )}\n\n {!!transaction.creditCardMask && (\n <ReceiptListItem\n className=\"ob-payment-receipt__card-number\"\n valueClassName=\"cypress-payment-receipt-card-number\"\n icon=\"credit_card\"\n label=\"Card Number\"\n value={transaction.creditCardMask}\n />\n )}\n\n {!!transaction.amount && (\n <ReceiptListItem\n className=\"ob-payment-receipt__amount\"\n valueClassName=\"cypress-payment-receipt-amount\"\n icon=\"attach_money\"\n label=\"Amount\"\n value={localisationService.formatCurrency(transaction.amount)}\n />\n )}\n <ReceiptListItem\n className=\"ob-payment-receipt__warning\"\n valueClassName=\"cypress-payment-receipt-warning\"\n label=\"Warning\"\n value=\"Please do not click back in your browser, doing so will cause issues with your payment.\"\n />\n </ReceiptList>\n\n <div className=\"buttons\">\n {transaction.isSuccess ? (\n <ReceiptButton\n className=\"is-primary ob-payment-receipt__button ob-payment-receipt__okay-button cypress-payment-receipt-okay-button\"\n label=\"Done\"\n isLoading={isRunningPostSubmissionAction}\n onClick={handleDone}\n />\n ) : (\n <>\n <ReceiptButton\n className=\"ob-payment-receipt__button ob-payment-receipt__cancel-button cypress-payment-receipt-cancel-button\"\n label=\"Cancel\"\n isDisabled={isRetrying}\n isLoading={isRunningPostSubmissionAction}\n onClick={handleCancel}\n />\n <ReceiptButton\n className=\"is-primary ob-payment-receipt__button ob-payment-receipt__try-again-button cypress-payment-receipt-try-again-button\"\n label=\"Try Again\"\n isDisabled={isRunningPostSubmissionAction}\n isLoading={isRetrying}\n onClick={handleTryAgain}\n />\n </>\n )}\n </div>\n </Receipt>\n )}\n\n {loadError && (\n <section className=\"cypress-payment-receipt-loading-error-message\">\n <div className=\"ob-payment-receipt__error-icon-container has-text-centered has-margin-bottom-8\">\n <i className=\"ob-payment-receipt__error-icon material-icons has-text-danger icon-x-large\">\n error\n </i>\n </div>\n <p className=\"ob-payment-receipt__error-message has-text-centered has-margin-bottom-4\">\n {loadError.message}\n </p>\n </section>\n )}\n\n {retryError && (\n <Modal\n isOpen\n title={retryError.title || 'Whoops...'}\n bodyClassName=\"cypress-payment-receipt-retry-error-message\"\n actions={\n <button\n type=\"button\"\n className=\"button ob-button is-primary cypress-payment-receipt-retry-error-okay-button\"\n onClick={clearRetryError}\n >\n Okay\n </button>\n }\n >\n {retryError.message}\n </Modal>\n )}\n\n {postSubmissionError && (\n <Modal\n isOpen\n title={postSubmissionError.title || 'Whoops...'}\n bodyClassName=\"cypress-payment-receipt-retry-error-message\"\n actions={\n <button\n type=\"button\"\n className=\"button ob-button is-primary cypress-payment-receipt-retry-error-okay-button\"\n onClick={clearPostSubmissionError}\n >\n Okay\n </button>\n }\n >\n {postSubmissionError.message}\n </Modal>\n )}\n </div>\n )\n}\n\n/**\n * Component for rendering a OneBlink Form Payment Receipt. This component will\n * payment receipt but it is up to the developer to implement what happens when\n * the user clicks 'Done'.\n *\n * It is also recommended to import the `css` from this library as well.\n *\n * ```js\n * import { PaymentReceipt } from '@oneblink/apps-react'\n * import '@oneblink/apps-react/dist/styles.css'\n * ```\n *\n * #### Example\n *\n * ```tsx\n * import React from 'react'\n * import ReactDOM from 'react-dom'\n * import { PaymentReceipt } from '@oneblink/apps-react'\n * import '@oneblink/apps-react/dist/styles.css'\n *\n * function ReceiptContainer() {\n * const handleDone = React.useCallback(async () => {\n * console.log('All done!')\n * }, [])\n * const handleCancel = React.useCallback(async () => {\n * console.log('Cancelled!')\n * }, [])\n *\n * return <PaymentReceipt onDone={handleDone} onCancel={handleCancel} />\n * }\n *\n * function App() {\n * return (\n * <IsOfflineContextProvider>\n * <ReceiptContainer />\n * </IsOfflineContextProvider>\n * )\n * }\n *\n * const root = document.getElementById('root')\n * if (root) {\n * ReactDOM.render(<App />, root)\n * }\n * ```\n *\n * @param props\n * @returns\n * @group Components\n */\nexport default React.memo(PaymentReceipt)\n"]}
@@ -1,5 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import { Button } from '@mui/material';
3
3
  declare function OneBlinkFormStoreClearFiltersButton(props: React.ComponentProps<typeof Button>): JSX.Element;
4
+ /**
5
+ * @param props
6
+ * @returns
7
+ * @group Components
8
+ */
4
9
  declare const _default: React.MemoExoticComponent<typeof OneBlinkFormStoreClearFiltersButton>;
5
10
  export default _default;
@@ -16,5 +16,10 @@ function OneBlinkFormStoreClearFiltersButton(props) {
16
16
  // eslint-disable-next-line react/no-children-prop
17
17
  children: React.createElement(React.Fragment, null, "Clear Filters"), ...props }));
18
18
  }
19
+ /**
20
+ * @param props
21
+ * @returns
22
+ * @group Components
23
+ */
19
24
  export default React.memo(OneBlinkFormStoreClearFiltersButton);
20
25
  //# sourceMappingURL=OneBlinkFormStoreClearFiltersButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OneBlinkFormStoreClearFiltersButton.js","sourceRoot":"","sources":["../../../src/components/formStore/OneBlinkFormStoreClearFiltersButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,UAAU,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,wBAAwB,MAAM,4BAA4B,CAAA;AAEjE,SAAS,mCAAmC,CAC1C,KAA0C;IAE1C,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAE,GAAG,wBAAwB,EAAE,CAAA;IACrE,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACpC,OAAO,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,MAAM,CAAA;IACvE,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAA;IACxB,OAAO,CACL,oBAAC,MAAM,IACL,SAAS,EAAC,oCAAoC,EAC9C,SAAS,EAAE,oBAAC,UAAU,OAAG,EACzB,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,GAAG,EAAE;YACZ,kBAAkB,CAChB,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;gBACtB,GAAG,iBAAiB;gBACpB,OAAO,EAAE,SAAS;aACnB,CAAC,EACF,KAAK,CACN,CAAA;QACH,CAAC;QACD,kDAAkD;QAClD,QAAQ,EAAE,0DAAkB,KACxB,KAAK,GACT,CACH,CAAA;AACH,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport { Button } from '@mui/material'\nimport { FilterList as FilterIcon } from '@mui/icons-material'\nimport useFormStoreTableContext from './useFormStoreTableContext'\n\nfunction OneBlinkFormStoreClearFiltersButton(\n props: React.ComponentProps<typeof Button>,\n) {\n const { onChangeParameters, parameters } = useFormStoreTableContext()\n const isDisabled = React.useMemo(() => {\n return !parameters.filters || !Object.keys(parameters.filters).length\n }, [parameters.filters])\n return (\n <Button\n className=\"ob-form-store-clear-filters-button\"\n startIcon={<FilterIcon />}\n disabled={isDisabled}\n onClick={() => {\n onChangeParameters(\n (currentParameters) => ({\n ...currentParameters,\n filters: undefined,\n }),\n false,\n )\n }}\n // eslint-disable-next-line react/no-children-prop\n children={<>Clear Filters</>}\n {...props}\n />\n )\n}\n\nexport default React.memo(OneBlinkFormStoreClearFiltersButton)\n"]}
1
+ {"version":3,"file":"OneBlinkFormStoreClearFiltersButton.js","sourceRoot":"","sources":["../../../src/components/formStore/OneBlinkFormStoreClearFiltersButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,UAAU,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,wBAAwB,MAAM,4BAA4B,CAAA;AAEjE,SAAS,mCAAmC,CAC1C,KAA0C;IAE1C,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAE,GAAG,wBAAwB,EAAE,CAAA;IACrE,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACpC,OAAO,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,MAAM,CAAA;IACvE,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAA;IACxB,OAAO,CACL,oBAAC,MAAM,IACL,SAAS,EAAC,oCAAoC,EAC9C,SAAS,EAAE,oBAAC,UAAU,OAAG,EACzB,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,GAAG,EAAE;YACZ,kBAAkB,CAChB,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;gBACtB,GAAG,iBAAiB;gBACpB,OAAO,EAAE,SAAS;aACnB,CAAC,EACF,KAAK,CACN,CAAA;QACH,CAAC;QACD,kDAAkD;QAClD,QAAQ,EAAE,0DAAkB,KACxB,KAAK,GACT,CACH,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,eAAe,KAAK,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport { Button } from '@mui/material'\nimport { FilterList as FilterIcon } from '@mui/icons-material'\nimport useFormStoreTableContext from './useFormStoreTableContext'\n\nfunction OneBlinkFormStoreClearFiltersButton(\n props: React.ComponentProps<typeof Button>,\n) {\n const { onChangeParameters, parameters } = useFormStoreTableContext()\n const isDisabled = React.useMemo(() => {\n return !parameters.filters || !Object.keys(parameters.filters).length\n }, [parameters.filters])\n return (\n <Button\n className=\"ob-form-store-clear-filters-button\"\n startIcon={<FilterIcon />}\n disabled={isDisabled}\n onClick={() => {\n onChangeParameters(\n (currentParameters) => ({\n ...currentParameters,\n filters: undefined,\n }),\n false,\n )\n }}\n // eslint-disable-next-line react/no-children-prop\n children={<>Clear Filters</>}\n {...props}\n />\n )\n}\n\n/**\n * @param props\n * @returns\n * @group Components\n */\nexport default React.memo(OneBlinkFormStoreClearFiltersButton)\n"]}
@@ -1,5 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import { Button } from '@mui/material';
3
3
  declare function OneBlinkFormStoreColumnsButton(props: React.ComponentProps<typeof Button>): JSX.Element;
4
+ /**
5
+ * @param props
6
+ * @returns
7
+ * @group Components
8
+ */
4
9
  declare const _default: React.MemoExoticComponent<typeof OneBlinkFormStoreColumnsButton>;
5
10
  export default _default;
@@ -63,5 +63,10 @@ function OneBlinkFormStoreColumnsButton(props) {
63
63
  React.createElement(DialogActions, null,
64
64
  React.createElement(Button, { onClick: hideColumnConfiguration, color: "primary", variant: "contained" }, "Done")))));
65
65
  }
66
+ /**
67
+ * @param props
68
+ * @returns
69
+ * @group Components
70
+ */
66
71
  export default React.memo(OneBlinkFormStoreColumnsButton);
67
72
  //# sourceMappingURL=OneBlinkFormStoreColumnsButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OneBlinkFormStoreColumnsButton.js","sourceRoot":"","sources":["../../../src/components/formStore/OneBlinkFormStoreColumnsButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EACL,KAAK,EACL,UAAU,EACV,GAAG,EACH,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,aAAa,EACb,aAAa,EACb,WAAW,EACX,OAAO,EACP,gBAAgB,EAChB,SAAS,EACT,IAAI,EACJ,UAAU,EACV,UAAU,GACX,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,IAAI,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAA;AACpE,OAAO,eAAe,MAAM,6BAA6B,CAAA;AACzD,OAAO,wBAAwB,MAAM,4BAA4B,CAAA;AACjE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAElD,SAAS,8BAA8B,CACrC,KAA0C;IAE1C,MAAM,EACJ,4BAA4B,EAC5B,UAAU,EACV,UAAU,EACV,kBAAkB,GACnB,GAAG,wBAAwB,EAAE,CAAA;IAC9B,MAAM,CACJ,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACxB,GAAG,eAAe,CAAC,KAAK,CAAC,CAAA;IAC1B,MAAM,CAAC,UAAU,EAAE,AAAD,EAAG,AAAD,EAAG,UAAU,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,CAAA;IAE3D,MAAM,yBAAyB,GAAG,4BAA4B,EAAE,CAAA;IAEhE,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,CACrC,GAAG,EAAE,CACH,UAAU,CAAC,oBAAoB;QAC/B,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,KAAK,eAAe,CAAC,EAC/D,CAAC,UAAU,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAC9C,CAAA;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aAAa;gCACZ,oBAAC,QAAQ,sFAGE;gCACX,oBAAC,QAAQ,2EAGE;gCACX,oBAAC,QAAQ,qFAGE,CACG,CACV,CACC;oBACX,oBAAC,GAAG,IAAC,OAAO,EAAE,CAAC;wBACb,oBAAC,OAAO,OAAG,CACP,CACL,CACJ;gBACD,oBAAC,SAAS;oBACR,oBAAC,gBAAgB,IACf,OAAO,EACL,oBAAC,QAAQ,OACH,yBAAyB,EAC7B,aAAa,EAAE,CAAC,CAAC,yBAAyB,CAAC,aAAa,GACxD,EAEJ,KAAK,EAAE,4CAAiB,GACxB;oBACD,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;wBACzB,OAAO,CACL,oBAAC,KAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,MAAM,CAAC,EAAE;4BAC5B,oBAAC,gBAAgB,IACf,OAAO,EAAE,oBAAC,QAAQ,OAAK,MAAM,CAAC,oBAAoB,EAAE,GAAI,EACxD,KAAK,EACH;oCACG,MAAM,CAAC,UAAU;oCACjB,MAAM,CAAC,OAAO,IAAI,CACjB,oBAAC,UAAU,IAAC,SAAS,EAAC,MAAM,EAAC,KAAK,EAAC,eAAe;wCAC/C,GAAG;;wCACF,MAAM,CAAC,OAAO;4CACL,CACd,CACA,GAEL,CACa,CAClB,CAAA;oBACH,CAAC,CAAC,CACQ,CACE;YAChB,oBAAC,aAAa;gBACZ,oBAAC,MAAM,IACL,OAAO,EAAE,uBAAuB,EAChC,KAAK,EAAC,SAAS,EACf,OAAO,EAAC,WAAW,WAGZ,CACK,CACT,CACR,CACJ,CAAA;AACH,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport {\n Alert,\n AlertTitle,\n Box,\n Button,\n Checkbox,\n Collapse,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Divider,\n FormControlLabel,\n FormGroup,\n Grid,\n IconButton,\n Typography,\n} from '@mui/material'\nimport { Help, Settings as SettingsIcon } from '@mui/icons-material'\nimport useBooleanState from '../../hooks/useBooleanState'\nimport useFormStoreTableContext from './useFormStoreTableContext'\nimport { ListItem, UnorderedList } from '../Lists'\n\nfunction OneBlinkFormStoreColumnsButton(\n props: React.ComponentProps<typeof Button>,\n) {\n const {\n getToggleHideAllColumnsProps,\n allColumns,\n parameters,\n onChangeParameters,\n } = useFormStoreTableContext()\n const [\n isConfiguringColumns,\n showColumnConfiguration,\n hideColumnConfiguration,\n ] = useBooleanState(false)\n const [isHelpOpen, , , toggleHelp] = useBooleanState(false)\n\n const toggleHideAllColumnsProps = getToggleHideAllColumnsProps()\n\n const hasRepeatableSets = React.useMemo(\n () =>\n parameters.unwindRepeatableSets ||\n allColumns.some((c) => c.formElementType === 'repeatableSet'),\n [allColumns, parameters.unwindRepeatableSets],\n )\n\n return (\n <>\n <Button\n className=\"ob-form-store-columns-button\"\n startIcon={<SettingsIcon />}\n onClick={showColumnConfiguration}\n // eslint-disable-next-line react/no-children-prop\n children={<>Columns</>}\n {...props}\n />\n <Dialog\n open={isConfiguringColumns}\n maxWidth=\"sm\"\n fullWidth\n onClose={hideColumnConfiguration}\n >\n <DialogTitle>Column Configuration</DialogTitle>\n <DialogContent dividers>\n {hasRepeatableSets && (\n <>\n <Grid container>\n <Grid item>\n <FormGroup>\n <FormControlLabel\n control={\n <Checkbox checked={!!parameters.unwindRepeatableSets} />\n }\n onChange={(e, checked) => {\n onChangeParameters(\n (currentParameters) => ({\n ...currentParameters,\n sorting: checked\n ? currentParameters.sorting\n : [\n {\n property: 'dateTimeSubmitted',\n direction: 'descending',\n },\n ],\n unwindRepeatableSets: checked,\n }),\n false,\n )\n }}\n label=\"Output a row per repeatable set entry\"\n />\n </FormGroup>\n </Grid>\n <Grid item>\n <IconButton onClick={toggleHelp}>\n <Help />\n </IconButton>\n </Grid>\n </Grid>\n <Collapse in={isHelpOpen}>\n <Alert severity=\"info\">\n <AlertTitle>When this setting is enabled:</AlertTitle>\n <UnorderedList>\n <ListItem>\n Repeatable set columns will be expanded and create\n duplicate rows per entry\n </ListItem>\n <ListItem>\n Columns inside repeatable set entries can be sorted and\n filtered\n </ListItem>\n <ListItem>\n Columns inside repeatable set entries will be included in\n the CSV download\n </ListItem>\n </UnorderedList>\n </Alert>\n </Collapse>\n <Box marginY={2}>\n <Divider />\n </Box>\n </>\n )}\n <FormGroup>\n <FormControlLabel\n control={\n <Checkbox\n {...toggleHideAllColumnsProps}\n indeterminate={!!toggleHideAllColumnsProps.indeterminate}\n />\n }\n label={<b>Toggle All</b>}\n />\n {allColumns.map((column) => {\n return (\n <React.Fragment key={column.id}>\n <FormControlLabel\n control={<Checkbox {...column.getToggleHiddenProps()} />}\n label={\n <>\n {column.headerText}\n {column.tooltip && (\n <Typography component=\"span\" color=\"textSecondary\">\n {' '}\n ({column.tooltip})\n </Typography>\n )}\n </>\n }\n />\n </React.Fragment>\n )\n })}\n </FormGroup>\n </DialogContent>\n <DialogActions>\n <Button\n onClick={hideColumnConfiguration}\n color=\"primary\"\n variant=\"contained\"\n >\n Done\n </Button>\n </DialogActions>\n </Dialog>\n </>\n )\n}\n\nexport default React.memo(OneBlinkFormStoreColumnsButton)\n"]}
1
+ {"version":3,"file":"OneBlinkFormStoreColumnsButton.js","sourceRoot":"","sources":["../../../src/components/formStore/OneBlinkFormStoreColumnsButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EACL,KAAK,EACL,UAAU,EACV,GAAG,EACH,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,aAAa,EACb,aAAa,EACb,WAAW,EACX,OAAO,EACP,gBAAgB,EAChB,SAAS,EACT,IAAI,EACJ,UAAU,EACV,UAAU,GACX,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,IAAI,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAA;AACpE,OAAO,eAAe,MAAM,6BAA6B,CAAA;AAC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4BAC5B,oBAAC,gBAAgB,IACf,OAAO,EAAE,oBAAC,QAAQ,OAAK,MAAM,CAAC,oBAAoB,EAAE,GAAI,EACxD,KAAK,EACH;oCACG,MAAM,CAAC,UAAU;oCACjB,MAAM,CAAC,OAAO,IAAI,CACjB,oBAAC,UAAU,IAAC,SAAS,EAAC,MAAM,EAAC,KAAK,EAAC,eAAe;wCAC/C,GAAG;;wCACF,MAAM,CAAC,OAAO;4CACL,CACd,CACA,GAEL,CACa,CAClB,CAAA;oBACH,CAAC,CAAC,CACQ,CACE;YAChB,oBAAC,aAAa;gBACZ,oBAAC,MAAM,IACL,OAAO,EAAE,uBAAuB,EAChC,KAAK,EAAC,SAAS,EACf,OAAO,EAAC,WAAW,WAGZ,CACK,CACT,CACR,CACJ,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,eAAe,KAAK,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport {\n Alert,\n AlertTitle,\n Box,\n Button,\n Checkbox,\n Collapse,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Divider,\n FormControlLabel,\n FormGroup,\n Grid,\n IconButton,\n Typography,\n} from '@mui/material'\nimport { Help, Settings as SettingsIcon } from '@mui/icons-material'\nimport useBooleanState from '../../hooks/useBooleanState'\nimport useFormStoreTableContext from './useFormStoreTableContext'\nimport { ListItem, UnorderedList } from '../Lists'\n\nfunction OneBlinkFormStoreColumnsButton(\n props: React.ComponentProps<typeof Button>,\n) {\n const {\n getToggleHideAllColumnsProps,\n allColumns,\n parameters,\n onChangeParameters,\n } = useFormStoreTableContext()\n const [\n isConfiguringColumns,\n showColumnConfiguration,\n hideColumnConfiguration,\n ] = useBooleanState(false)\n const [isHelpOpen, , , toggleHelp] = useBooleanState(false)\n\n const toggleHideAllColumnsProps = getToggleHideAllColumnsProps()\n\n const hasRepeatableSets = React.useMemo(\n () =>\n parameters.unwindRepeatableSets ||\n allColumns.some((c) => c.formElementType === 'repeatableSet'),\n [allColumns, parameters.unwindRepeatableSets],\n )\n\n return (\n <>\n <Button\n className=\"ob-form-store-columns-button\"\n startIcon={<SettingsIcon />}\n onClick={showColumnConfiguration}\n // eslint-disable-next-line react/no-children-prop\n children={<>Columns</>}\n {...props}\n />\n <Dialog\n open={isConfiguringColumns}\n maxWidth=\"sm\"\n fullWidth\n onClose={hideColumnConfiguration}\n >\n <DialogTitle>Column Configuration</DialogTitle>\n <DialogContent dividers>\n {hasRepeatableSets && (\n <>\n <Grid container>\n <Grid item>\n <FormGroup>\n <FormControlLabel\n control={\n <Checkbox checked={!!parameters.unwindRepeatableSets} />\n }\n onChange={(e, checked) => {\n onChangeParameters(\n (currentParameters) => ({\n ...currentParameters,\n sorting: checked\n ? currentParameters.sorting\n : [\n {\n property: 'dateTimeSubmitted',\n direction: 'descending',\n },\n ],\n unwindRepeatableSets: checked,\n }),\n false,\n )\n }}\n label=\"Output a row per repeatable set entry\"\n />\n </FormGroup>\n </Grid>\n <Grid item>\n <IconButton onClick={toggleHelp}>\n <Help />\n </IconButton>\n </Grid>\n </Grid>\n <Collapse in={isHelpOpen}>\n <Alert severity=\"info\">\n <AlertTitle>When this setting is enabled:</AlertTitle>\n <UnorderedList>\n <ListItem>\n Repeatable set columns will be expanded and create\n duplicate rows per entry\n </ListItem>\n <ListItem>\n Columns inside repeatable set entries can be sorted and\n filtered\n </ListItem>\n <ListItem>\n Columns inside repeatable set entries will be included in\n the CSV download\n </ListItem>\n </UnorderedList>\n </Alert>\n </Collapse>\n <Box marginY={2}>\n <Divider />\n </Box>\n </>\n )}\n <FormGroup>\n <FormControlLabel\n control={\n <Checkbox\n {...toggleHideAllColumnsProps}\n indeterminate={!!toggleHideAllColumnsProps.indeterminate}\n />\n }\n label={<b>Toggle All</b>}\n />\n {allColumns.map((column) => {\n return (\n <React.Fragment key={column.id}>\n <FormControlLabel\n control={<Checkbox {...column.getToggleHiddenProps()} />}\n label={\n <>\n {column.headerText}\n {column.tooltip && (\n <Typography component=\"span\" color=\"textSecondary\">\n {' '}\n ({column.tooltip})\n </Typography>\n )}\n </>\n }\n />\n </React.Fragment>\n )\n })}\n </FormGroup>\n </DialogContent>\n <DialogActions>\n <Button\n onClick={hideColumnConfiguration}\n color=\"primary\"\n variant=\"contained\"\n >\n Done\n </Button>\n </DialogActions>\n </Dialog>\n </>\n )\n}\n\n/**\n * @param props\n * @returns\n * @group Components\n */\nexport default React.memo(OneBlinkFormStoreColumnsButton)\n"]}
@@ -1,5 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import { LoadingButton } from '@mui/lab';
3
3
  declare function OneBlinkFormStoreDownloadButton(props: React.ComponentProps<typeof LoadingButton>): JSX.Element;
4
+ /**
5
+ * @param props
6
+ * @returns
7
+ * @group Components
8
+ */
4
9
  declare const _default: React.MemoExoticComponent<typeof OneBlinkFormStoreDownloadButton>;
5
10
  export default _default;
@@ -83,5 +83,10 @@ function OneBlinkFormStoreDownloadButton(props) {
83
83
  React.createElement(Button, { onClick: cancelPromptDownloadCsv, variant: "text" }, "Cancel"),
84
84
  React.createElement(Button, { onClick: downloadCsv, startIcon: React.createElement(CsvIcon, null), color: "primary", variant: "contained" }, "Download")))));
85
85
  }
86
+ /**
87
+ * @param props
88
+ * @returns
89
+ * @group Components
90
+ */
86
91
  export default React.memo(OneBlinkFormStoreDownloadButton);
87
92
  //# sourceMappingURL=OneBlinkFormStoreDownloadButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OneBlinkFormStoreDownloadButton.js","sourceRoot":"","sources":["../../../src/components/formStore/OneBlinkFormStoreDownloadButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EACL,OAAO,EACP,MAAM,EACN,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,MAAM,GACP,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,OAAO,MAAM,8BAA8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ACtB,OAAO,EAAE,iBAAiB;gBAC1B,kDAAkD;gBAClD,QAAQ,EAAE,qDAAa,KACnB,KAAK,GACT,CACM;QAEV,oBAAC,aAAa,IAAC,IAAI,EAAE,CAAC,CAAC,mBAAmB,EAAE,OAAO,EAAE,UAAU;YAC7D,8CAAmB,2BAA2B,IAC3C,mBAAmB,IAAI,mBAAmB,CAAC,OAAO,CAC9C,CACO;QAEhB,oBAAC,MAAM,IACL,IAAI,EAAE,sBAAsB,EAC5B,QAAQ,EAAC,IAAI,EACb,SAAS,QACT,OAAO,EAAE,uBAAuB;YAEhC,oBAAC,WAAW,+BAAmC;YAC/C,oBAAC,aAAa;gBACZ,oBAAC,iBAAiB;;oBACqD,GAAG;oBACxE,uEAA4C;;oBACtC,sDAA2B;wBACf,CACN;YAChB,oBAAC,aAAa;gBACZ,oBAAC,MAAM,IAAC,OAAO,EAAE,uBAAuB,EAAE,OAAO,EAAC,MAAM,aAE/C;gBACT,oBAAC,MAAM,IACL,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,oBAAC,OAAO,OAAG,EACtB,KAAK,EAAC,SAAS,EACf,OAAO,EAAC,WAAW,eAGZ,CACK,CACT,CACR,CACJ,CAAA;AACH,CAAC;AACD,eAAe,KAAK,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport {\n Tooltip,\n Dialog,\n DialogTitle,\n DialogContent,\n DialogContentText,\n DialogActions,\n Button,\n} from '@mui/material'\nimport { LoadingButton } from '@mui/lab'\nimport CsvIcon from '@mui/icons-material/Download'\nimport ErrorSnackbar from '../ErrorSnackbar'\nimport { ColumnInstance } from 'react-table'\nimport { FormStoreRecord } from '@oneblink/types/typescript/submissions'\nimport { formStoreService } from '@oneblink/apps'\nimport useFormStoreTableContext from './useFormStoreTableContext'\n\nfunction OneBlinkFormStoreDownloadButton(\n props: React.ComponentProps<typeof LoadingButton>,\n) {\n const { visibleColumns, parameters, form } = useFormStoreTableContext()\n const [\n { isDownloadingCsv, isPromptingDownloadCsv, downloadingCsvError },\n setState,\n ] = React.useState<{\n isDownloadingCsv: boolean\n isPromptingDownloadCsv: boolean\n downloadingCsvError: Error | null\n }>({\n isDownloadingCsv: false,\n isPromptingDownloadCsv: false,\n downloadingCsvError: null,\n })\n\n const clearError = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n downloadingCsvError: null,\n }))\n }, [])\n\n const downloadCsv = React.useCallback(async () => {\n setState({\n isPromptingDownloadCsv: false,\n isDownloadingCsv: true,\n downloadingCsvError: null,\n })\n try {\n await formStoreService.exportFormStoreRecords(form.name, {\n formId: form.id,\n includeColumns: visibleColumns.map(\n (visibleColumn: ColumnInstance<FormStoreRecord>) => visibleColumn.id,\n ),\n ...parameters,\n })\n setState((currentState) => ({\n ...currentState,\n isDownloadingCsv: false,\n downloadingCsvError: null,\n }))\n } catch (error) {\n setState((currentState) => ({\n ...currentState,\n isDownloadingCsv: false,\n downloadingCsvError: error as Error,\n }))\n }\n }, [form, parameters, visibleColumns])\n\n const promptDownloadCsv = React.useCallback(() => {\n if (\n !parameters.unwindRepeatableSets &&\n visibleColumns.some((c) => c.formElementType === 'repeatableSet')\n ) {\n setState((currentState) => ({\n ...currentState,\n downloadingCsvError: null,\n isPromptingDownloadCsv: true,\n }))\n return\n }\n downloadCsv()\n }, [downloadCsv, parameters.unwindRepeatableSets, visibleColumns])\n\n const cancelPromptDownloadCsv = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n isPromptingDownloadCsv: false,\n }))\n }, [])\n\n return (\n <>\n <Tooltip title=\"Download submission data as a CSV file\">\n <LoadingButton\n className=\"ob-form-store-download-csv-button\"\n type=\"button\"\n loading={isDownloadingCsv}\n loadingPosition=\"start\"\n startIcon={<CsvIcon />}\n onClick={promptDownloadCsv}\n // eslint-disable-next-line react/no-children-prop\n children={<>Download</>}\n {...props}\n />\n </Tooltip>\n\n <ErrorSnackbar open={!!downloadingCsvError} onClose={clearError}>\n <span data-cypress=\"edit-dialog-error-message\">\n {downloadingCsvError && downloadingCsvError.message}\n </span>\n </ErrorSnackbar>\n\n <Dialog\n open={isPromptingDownloadCsv}\n maxWidth=\"sm\"\n fullWidth\n onClose={cancelPromptDownloadCsv}\n >\n <DialogTitle>Column Configuration</DialogTitle>\n <DialogContent>\n <DialogContentText>\n Repeatable set columns will not be included in the export unless the{' '}\n <b>Output a row per repeatable set entry</b> option is turned on\n under <b>Column Configuration</b>.\n </DialogContentText>\n </DialogContent>\n <DialogActions>\n <Button onClick={cancelPromptDownloadCsv} variant=\"text\">\n Cancel\n </Button>\n <Button\n onClick={downloadCsv}\n startIcon={<CsvIcon />}\n color=\"primary\"\n variant=\"contained\"\n >\n Download\n </Button>\n </DialogActions>\n </Dialog>\n </>\n )\n}\nexport default React.memo(OneBlinkFormStoreDownloadButton)\n"]}
1
+ {"version":3,"file":"OneBlinkFormStoreDownloadButton.js","sourceRoot":"","sources":["../../../src/components/formStore/OneBlinkFormStoreDownloadButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EACL,OAAO,EACP,MAAM,EACN,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,MAAM,GACP,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,OAAO,MAAM,8BAA8B,CAAA;AAClD,OAAO,aAAa,MAAM,kBAAkB,CAAA;AAG5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,wBAAwB,MAAM,4BAA4B,CAAA;AAEjE,SAAS,+BAA+B,CACtC,KAAiD;IAEjD,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,wBAAwB,EAAE,CAAA;IACvE,MAAM,CACJ,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,EACjE,QAAQ,EACT,GAAG,KAAK,CAAC,QAAQ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BAAC,WAAW,+BAAmC;YAC/C,oBAAC,aAAa;gBACZ,oBAAC,iBAAiB;;oBACqD,GAAG;oBACxE,uEAA4C;;oBACtC,sDAA2B;wBACf,CACN;YAChB,oBAAC,aAAa;gBACZ,oBAAC,MAAM,IAAC,OAAO,EAAE,uBAAuB,EAAE,OAAO,EAAC,MAAM,aAE/C;gBACT,oBAAC,MAAM,IACL,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,oBAAC,OAAO,OAAG,EACtB,KAAK,EAAC,SAAS,EACf,OAAO,EAAC,WAAW,eAGZ,CACK,CACT,CACR,CACJ,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,eAAe,KAAK,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport {\n Tooltip,\n Dialog,\n DialogTitle,\n DialogContent,\n DialogContentText,\n DialogActions,\n Button,\n} from '@mui/material'\nimport { LoadingButton } from '@mui/lab'\nimport CsvIcon from '@mui/icons-material/Download'\nimport ErrorSnackbar from '../ErrorSnackbar'\nimport { ColumnInstance } from 'react-table'\nimport { FormStoreRecord } from '@oneblink/types/typescript/submissions'\nimport { formStoreService } from '@oneblink/apps'\nimport useFormStoreTableContext from './useFormStoreTableContext'\n\nfunction OneBlinkFormStoreDownloadButton(\n props: React.ComponentProps<typeof LoadingButton>,\n) {\n const { visibleColumns, parameters, form } = useFormStoreTableContext()\n const [\n { isDownloadingCsv, isPromptingDownloadCsv, downloadingCsvError },\n setState,\n ] = React.useState<{\n isDownloadingCsv: boolean\n isPromptingDownloadCsv: boolean\n downloadingCsvError: Error | null\n }>({\n isDownloadingCsv: false,\n isPromptingDownloadCsv: false,\n downloadingCsvError: null,\n })\n\n const clearError = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n downloadingCsvError: null,\n }))\n }, [])\n\n const downloadCsv = React.useCallback(async () => {\n setState({\n isPromptingDownloadCsv: false,\n isDownloadingCsv: true,\n downloadingCsvError: null,\n })\n try {\n await formStoreService.exportFormStoreRecords(form.name, {\n formId: form.id,\n includeColumns: visibleColumns.map(\n (visibleColumn: ColumnInstance<FormStoreRecord>) => visibleColumn.id,\n ),\n ...parameters,\n })\n setState((currentState) => ({\n ...currentState,\n isDownloadingCsv: false,\n downloadingCsvError: null,\n }))\n } catch (error) {\n setState((currentState) => ({\n ...currentState,\n isDownloadingCsv: false,\n downloadingCsvError: error as Error,\n }))\n }\n }, [form, parameters, visibleColumns])\n\n const promptDownloadCsv = React.useCallback(() => {\n if (\n !parameters.unwindRepeatableSets &&\n visibleColumns.some((c) => c.formElementType === 'repeatableSet')\n ) {\n setState((currentState) => ({\n ...currentState,\n downloadingCsvError: null,\n isPromptingDownloadCsv: true,\n }))\n return\n }\n downloadCsv()\n }, [downloadCsv, parameters.unwindRepeatableSets, visibleColumns])\n\n const cancelPromptDownloadCsv = React.useCallback(() => {\n setState((currentState) => ({\n ...currentState,\n isPromptingDownloadCsv: false,\n }))\n }, [])\n\n return (\n <>\n <Tooltip title=\"Download submission data as a CSV file\">\n <LoadingButton\n className=\"ob-form-store-download-csv-button\"\n type=\"button\"\n loading={isDownloadingCsv}\n loadingPosition=\"start\"\n startIcon={<CsvIcon />}\n onClick={promptDownloadCsv}\n // eslint-disable-next-line react/no-children-prop\n children={<>Download</>}\n {...props}\n />\n </Tooltip>\n\n <ErrorSnackbar open={!!downloadingCsvError} onClose={clearError}>\n <span data-cypress=\"edit-dialog-error-message\">\n {downloadingCsvError && downloadingCsvError.message}\n </span>\n </ErrorSnackbar>\n\n <Dialog\n open={isPromptingDownloadCsv}\n maxWidth=\"sm\"\n fullWidth\n onClose={cancelPromptDownloadCsv}\n >\n <DialogTitle>Column Configuration</DialogTitle>\n <DialogContent>\n <DialogContentText>\n Repeatable set columns will not be included in the export unless the{' '}\n <b>Output a row per repeatable set entry</b> option is turned on\n under <b>Column Configuration</b>.\n </DialogContentText>\n </DialogContent>\n <DialogActions>\n <Button onClick={cancelPromptDownloadCsv} variant=\"text\">\n Cancel\n </Button>\n <Button\n onClick={downloadCsv}\n startIcon={<CsvIcon />}\n color=\"primary\"\n variant=\"contained\"\n >\n Download\n </Button>\n </DialogActions>\n </Dialog>\n </>\n )\n}\n\n/**\n * @param props\n * @returns\n * @group Components\n */\nexport default React.memo(OneBlinkFormStoreDownloadButton)\n"]}
@@ -2,6 +2,11 @@ import * as React from 'react';
2
2
  import { FormTypes } from '@oneblink/types';
3
3
  export type FormStoreElementsContextValue = FormTypes.FormElementWithName[];
4
4
  export declare const FormStoreElementsContext: React.Context<FormStoreElementsContextValue>;
5
+ /**
6
+ * @param props
7
+ * @returns
8
+ * @group Components
9
+ */
5
10
  export declare function OneBlinkFormStoreProvider({ form, children, }: {
6
11
  form: FormTypes.Form;
7
12
  children: React.ReactNode;
@@ -5,6 +5,11 @@ import { formStoreService } from '@oneblink/apps';
5
5
  import useLoadDataState from '../../hooks/useLoadDataState';
6
6
  import { FormStoreTableProvider } from './FormStoreTableProvider';
7
7
  export const FormStoreElementsContext = React.createContext([]);
8
+ /**
9
+ * @param props
10
+ * @returns
11
+ * @group Components
12
+ */
8
13
  export function OneBlinkFormStoreProvider({ form, children, }) {
9
14
  const fetchFormStoreDefinition = React.useCallback((abortSignal) => {
10
15
  return formStoreService.getFormStoreDefinition(form.id, abortSignal);
@@ -1 +1 @@
1
- {"version":3,"file":"OneBlinkFormStoreProvider.js","sourceRoot":"","sources":["../../../src/components/formStore/OneBlinkFormStoreProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,kBAAkB,MAAM,uBAAuB,CAAA;AACtD,OAAO,YAAY,MAAM,0BAA0B,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,gBAAgB,MAAM,8BAA8B,CAAA;AAE3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAIjE,MAAM,CAAC,MAAM,wBAAwB,GACnC,KAAK,CAAC,aAAa,CAAgC,EAAE,CAAC,CAAA;AAExD,MAAM,UAAU,yBAAyB,CAAC,EACxC,IAAI,EACJ,QAAQ,GAIT;IACC,MAAM,wBAAwB,GAAG,KAAK,CAAC,WAAW,CAChD,CAAC,WAAyB,EAAE,EAAE;QAC5B,OAAO,gBAAgB,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,EAAE,WAAW,CAAC,CAAA;IACtE,CAAC,EACD,CAAC,IAAI,CAAC,EAAE,CAAC,CACV,CAAA;IACD,MAAM,CAAC,wBAAwB,EAAE,UAAU,CAAC,GAAG,gBAAgB,CAC7D,wBAAwB,CACzB,CAAA;IAED,IAAI,wBAAwB,CAAC,MAAM,KAAK,SAAS,EAAE;QACjD,OAAO,oBAAC,kBAAkB,OAAG,CAAA;KAC9B;IAED,IAAI,wBAAwB,CAAC,MAAM,KAAK,OAAO,EAAE;QAC/C,OAAO,CACL;YACE,oBAAC,YAAY,IACX,KAAK,EAAC,kCAAkC,EACxC,SAAS,QACT,UAAU,EAAE,UAAU,IAErB,wBAAwB,CAAC,KAAK,CAAC,OAAO,CAC1B,CACd,CACJ,CAAA;KACF;IAED,OAAO,CACL,oBAAC,wBAAwB,CAAC,QAAQ,IAChC,KAAK,EAAE,wBAAwB,CAAC,MAAM,CAAC,YAAY;QAEnD,oBAAC,sBAAsB,IAAC,IAAI,EAAE,IAAI,IAAG,QAAQ,CAA0B,CACrC,CACrC,CAAA;AACH,CAAC","sourcesContent":["import * as React from 'react'\nimport LoadingWithMessage from '../LoadingWithMessage'\nimport ErrorMessage from '../messages/ErrorMessage'\nimport { formStoreService } from '@oneblink/apps'\nimport useLoadDataState from '../../hooks/useLoadDataState'\nimport { FormTypes } from '@oneblink/types'\nimport { FormStoreTableProvider } from './FormStoreTableProvider'\n\nexport type FormStoreElementsContextValue = FormTypes.FormElementWithName[]\n\nexport const FormStoreElementsContext =\n React.createContext<FormStoreElementsContextValue>([])\n\nexport function OneBlinkFormStoreProvider({\n form,\n children,\n}: {\n form: FormTypes.Form\n children: React.ReactNode\n}) {\n const fetchFormStoreDefinition = React.useCallback(\n (abortSignal?: AbortSignal) => {\n return formStoreService.getFormStoreDefinition(form.id, abortSignal)\n },\n [form.id],\n )\n const [formStoreDefinitionState, onTryAgain] = useLoadDataState(\n fetchFormStoreDefinition,\n )\n\n if (formStoreDefinitionState.status === 'LOADING') {\n return <LoadingWithMessage />\n }\n\n if (formStoreDefinitionState.status === 'ERROR') {\n return (\n <>\n <ErrorMessage\n title=\"Error Retrieving Form Definition\"\n gutterTop\n onTryAgain={onTryAgain}\n >\n {formStoreDefinitionState.error.message}\n </ErrorMessage>\n </>\n )\n }\n\n return (\n <FormStoreElementsContext.Provider\n value={formStoreDefinitionState.result.formElements}\n >\n <FormStoreTableProvider form={form}>{children}</FormStoreTableProvider>\n </FormStoreElementsContext.Provider>\n )\n}\n"]}
1
+ {"version":3,"file":"OneBlinkFormStoreProvider.js","sourceRoot":"","sources":["../../../src/components/formStore/OneBlinkFormStoreProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,kBAAkB,MAAM,uBAAuB,CAAA;AACtD,OAAO,YAAY,MAAM,0BAA0B,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,gBAAgB,MAAM,8BAA8B,CAAA;AAE3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAIjE,MAAM,CAAC,MAAM,wBAAwB,GACnC,KAAK,CAAC,aAAa,CAAgC,EAAE,CAAC,CAAA;AAExD;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,EACxC,IAAI,EACJ,QAAQ,GAIT;IACC,MAAM,wBAAwB,GAAG,KAAK,CAAC,WAAW,CAChD,CAAC,WAAyB,EAAE,EAAE;QAC5B,OAAO,gBAAgB,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,EAAE,WAAW,CAAC,CAAA;IACtE,CAAC,EACD,CAAC,IAAI,CAAC,EAAE,CAAC,CACV,CAAA;IACD,MAAM,CAAC,wBAAwB,EAAE,UAAU,CAAC,GAAG,gBAAgB,CAC7D,wBAAwB,CACzB,CAAA;IAED,IAAI,wBAAwB,CAAC,MAAM,KAAK,SAAS,EAAE;QACjD,OAAO,oBAAC,kBAAkB,OAAG,CAAA;KAC9B;IAED,IAAI,wBAAwB,CAAC,MAAM,KAAK,OAAO,EAAE;QAC/C,OAAO,CACL;YACE,oBAAC,YAAY,IACX,KAAK,EAAC,kCAAkC,EACxC,SAAS,QACT,UAAU,EAAE,UAAU,IAErB,wBAAwB,CAAC,KAAK,CAAC,OAAO,CAC1B,CACd,CACJ,CAAA;KACF;IAED,OAAO,CACL,oBAAC,wBAAwB,CAAC,QAAQ,IAChC,KAAK,EAAE,wBAAwB,CAAC,MAAM,CAAC,YAAY;QAEnD,oBAAC,sBAAsB,IAAC,IAAI,EAAE,IAAI,IAAG,QAAQ,CAA0B,CACrC,CACrC,CAAA;AACH,CAAC","sourcesContent":["import * as React from 'react'\nimport LoadingWithMessage from '../LoadingWithMessage'\nimport ErrorMessage from '../messages/ErrorMessage'\nimport { formStoreService } from '@oneblink/apps'\nimport useLoadDataState from '../../hooks/useLoadDataState'\nimport { FormTypes } from '@oneblink/types'\nimport { FormStoreTableProvider } from './FormStoreTableProvider'\n\nexport type FormStoreElementsContextValue = FormTypes.FormElementWithName[]\n\nexport const FormStoreElementsContext =\n React.createContext<FormStoreElementsContextValue>([])\n\n/**\n * @param props\n * @returns\n * @group Components\n */\nexport function OneBlinkFormStoreProvider({\n form,\n children,\n}: {\n form: FormTypes.Form\n children: React.ReactNode\n}) {\n const fetchFormStoreDefinition = React.useCallback(\n (abortSignal?: AbortSignal) => {\n return formStoreService.getFormStoreDefinition(form.id, abortSignal)\n },\n [form.id],\n )\n const [formStoreDefinitionState, onTryAgain] = useLoadDataState(\n fetchFormStoreDefinition,\n )\n\n if (formStoreDefinitionState.status === 'LOADING') {\n return <LoadingWithMessage />\n }\n\n if (formStoreDefinitionState.status === 'ERROR') {\n return (\n <>\n <ErrorMessage\n title=\"Error Retrieving Form Definition\"\n gutterTop\n onTryAgain={onTryAgain}\n >\n {formStoreDefinitionState.error.message}\n </ErrorMessage>\n </>\n )\n }\n\n return (\n <FormStoreElementsContext.Provider\n value={formStoreDefinitionState.result.formElements}\n >\n <FormStoreTableProvider form={form}>{children}</FormStoreTableProvider>\n </FormStoreElementsContext.Provider>\n )\n}\n"]}
@@ -1,5 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import { Button } from '@mui/material';
3
3
  declare function OneBlinkFormStoreRefreshButton(props: React.ComponentProps<typeof Button>): JSX.Element;
4
+ /**
5
+ * @param props
6
+ * @returns
7
+ * @group Components
8
+ */
4
9
  declare const _default: React.MemoExoticComponent<typeof OneBlinkFormStoreRefreshButton>;
5
10
  export default _default;
@@ -8,5 +8,10 @@ function OneBlinkFormStoreRefreshButton(props) {
8
8
  // eslint-disable-next-line react/no-children-prop
9
9
  children: React.createElement(React.Fragment, null, "Refresh"), ...props }));
10
10
  }
11
+ /**
12
+ * @param props
13
+ * @returns
14
+ * @group Components
15
+ */
11
16
  export default React.memo(OneBlinkFormStoreRefreshButton);
12
17
  //# sourceMappingURL=OneBlinkFormStoreRefreshButton.js.map