@oneblink/apps-react 4.1.0-beta.7 → 4.1.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 (177) hide show
  1. package/README.md +2 -8
  2. package/dist/OneBlinkAutoSaveForm.d.ts +25 -5
  3. package/dist/OneBlinkAutoSaveForm.js +12 -0
  4. package/dist/OneBlinkAutoSaveForm.js.map +1 -1
  5. package/dist/OneBlinkForm.d.ts +558 -8
  6. package/dist/OneBlinkForm.js +546 -0
  7. package/dist/OneBlinkForm.js.map +1 -1
  8. package/dist/OneBlinkFormBase.d.ts +53 -8
  9. package/dist/OneBlinkFormBase.js +49 -25
  10. package/dist/OneBlinkFormBase.js.map +1 -1
  11. package/dist/OneBlinkReadOnlyForm.d.ts +83 -6
  12. package/dist/OneBlinkReadOnlyForm.js +80 -1
  13. package/dist/OneBlinkReadOnlyForm.js.map +1 -1
  14. package/dist/PaymentReceipt.d.ts +59 -0
  15. package/dist/PaymentReceipt.js +61 -6
  16. package/dist/PaymentReceipt.js.map +1 -1
  17. package/dist/components/formStore/FormStoreTableProvider.js +23 -1
  18. package/dist/components/formStore/FormStoreTableProvider.js.map +1 -1
  19. package/dist/components/formStore/OneBlinkFormStoreClearFiltersButton.d.ts +5 -0
  20. package/dist/components/formStore/OneBlinkFormStoreClearFiltersButton.js +5 -0
  21. package/dist/components/formStore/OneBlinkFormStoreClearFiltersButton.js.map +1 -1
  22. package/dist/components/formStore/OneBlinkFormStoreColumnsButton.d.ts +5 -0
  23. package/dist/components/formStore/OneBlinkFormStoreColumnsButton.js +5 -0
  24. package/dist/components/formStore/OneBlinkFormStoreColumnsButton.js.map +1 -1
  25. package/dist/components/formStore/OneBlinkFormStoreDownloadButton.d.ts +5 -0
  26. package/dist/components/formStore/OneBlinkFormStoreDownloadButton.js +5 -0
  27. package/dist/components/formStore/OneBlinkFormStoreDownloadButton.js.map +1 -1
  28. package/dist/components/formStore/OneBlinkFormStoreProvider.d.ts +5 -0
  29. package/dist/components/formStore/OneBlinkFormStoreProvider.js +5 -0
  30. package/dist/components/formStore/OneBlinkFormStoreProvider.js.map +1 -1
  31. package/dist/components/formStore/OneBlinkFormStoreRefreshButton.d.ts +5 -0
  32. package/dist/components/formStore/OneBlinkFormStoreRefreshButton.js +5 -0
  33. package/dist/components/formStore/OneBlinkFormStoreRefreshButton.js.map +1 -1
  34. package/dist/components/formStore/OneBlinkFormStoreTable.d.ts +4 -0
  35. package/dist/components/formStore/OneBlinkFormStoreTable.js +4 -0
  36. package/dist/components/formStore/OneBlinkFormStoreTable.js.map +1 -1
  37. package/dist/components/formStore/table/ColumnFilters.js.map +1 -1
  38. package/dist/components/pickers/V4CompatibleDatePicker.d.ts +5 -0
  39. package/dist/components/pickers/V4CompatibleDatePicker.js +5 -0
  40. package/dist/components/pickers/V4CompatibleDatePicker.js.map +1 -1
  41. package/dist/components/pickers/V4CompatibleDateTimePicker.d.ts +5 -0
  42. package/dist/components/pickers/V4CompatibleDateTimePicker.js +5 -0
  43. package/dist/components/pickers/V4CompatibleDateTimePicker.js.map +1 -1
  44. package/dist/components/pickers/V4CompatibleTimePicker.d.ts +5 -0
  45. package/dist/components/pickers/V4CompatibleTimePicker.js +5 -0
  46. package/dist/components/pickers/V4CompatibleTimePicker.js.map +1 -1
  47. package/dist/components/renderer/LookupButton.d.ts +3 -1
  48. package/dist/components/renderer/LookupButton.js +7 -5
  49. package/dist/components/renderer/LookupButton.js.map +1 -1
  50. package/dist/components/renderer/LookupNotification.js +60 -15
  51. package/dist/components/renderer/LookupNotification.js.map +1 -1
  52. package/dist/components/renderer/OneBlinkFormElements.d.ts +3 -3
  53. package/dist/components/renderer/OneBlinkFormElements.js.map +1 -1
  54. package/dist/components/renderer/PageFormElements.d.ts +3 -3
  55. package/dist/components/renderer/PageFormElements.js.map +1 -1
  56. package/dist/components/renderer/ProgressBar.d.ts +7 -3
  57. package/dist/components/renderer/ProgressBar.js +5 -0
  58. package/dist/components/renderer/ProgressBar.js.map +1 -1
  59. package/dist/form-elements/FormElementABN.js +1 -1
  60. package/dist/form-elements/FormElementABN.js.map +1 -1
  61. package/dist/form-elements/FormElementBSB.js +1 -1
  62. package/dist/form-elements/FormElementBSB.js.map +1 -1
  63. package/dist/form-elements/FormElementBarcodeScanner.js +3 -3
  64. package/dist/form-elements/FormElementBarcodeScanner.js.map +1 -1
  65. package/dist/form-elements/FormElementCalculation.js.map +1 -1
  66. package/dist/form-elements/FormElementCheckBoxes.js +1 -1
  67. package/dist/form-elements/FormElementCheckBoxes.js.map +1 -1
  68. package/dist/form-elements/FormElementDate.js +1 -1
  69. package/dist/form-elements/FormElementDate.js.map +1 -1
  70. package/dist/form-elements/FormElementDateTime.js +1 -1
  71. package/dist/form-elements/FormElementDateTime.js.map +1 -1
  72. package/dist/form-elements/FormElementEmail.js +1 -1
  73. package/dist/form-elements/FormElementEmail.js.map +1 -1
  74. package/dist/form-elements/FormElementForm.d.ts +4 -4
  75. package/dist/form-elements/FormElementForm.js.map +1 -1
  76. package/dist/form-elements/FormElementNumber.js +1 -1
  77. package/dist/form-elements/FormElementNumber.js.map +1 -1
  78. package/dist/form-elements/FormElementRepeatableSet.d.ts +4 -4
  79. package/dist/form-elements/FormElementRepeatableSet.js.map +1 -1
  80. package/dist/form-elements/FormElementSelect.js +1 -1
  81. package/dist/form-elements/FormElementSelect.js.map +1 -1
  82. package/dist/form-elements/FormElementSummary.js.map +1 -1
  83. package/dist/form-elements/FormElementTelephone.js +1 -1
  84. package/dist/form-elements/FormElementTelephone.js.map +1 -1
  85. package/dist/form-elements/FormElementText.js +1 -1
  86. package/dist/form-elements/FormElementText.js.map +1 -1
  87. package/dist/form-elements/FormElementTextarea.js +1 -1
  88. package/dist/form-elements/FormElementTextarea.js.map +1 -1
  89. package/dist/form-elements/FormElementTime.js +1 -1
  90. package/dist/form-elements/FormElementTime.js.map +1 -1
  91. package/dist/hooks/useAuth.d.ts +81 -6
  92. package/dist/hooks/useAuth.js +54 -0
  93. package/dist/hooks/useAuth.js.map +1 -1
  94. package/dist/hooks/useBooleanState.d.ts +42 -5
  95. package/dist/hooks/useBooleanState.js +36 -0
  96. package/dist/hooks/useBooleanState.js.map +1 -1
  97. package/dist/hooks/useClickOutsideElement.d.ts +40 -0
  98. package/dist/hooks/useClickOutsideElement.js +40 -0
  99. package/dist/hooks/useClickOutsideElement.js.map +1 -1
  100. package/dist/hooks/useConditionalLogic.d.ts +2 -3
  101. package/dist/hooks/useConditionalLogic.js.map +1 -1
  102. package/dist/hooks/useDrafts.d.ts +82 -0
  103. package/dist/hooks/useDrafts.js +204 -0
  104. package/dist/hooks/useDrafts.js.map +1 -0
  105. package/dist/hooks/useFormSubmissionAutoSaveState.d.ts +18 -5
  106. package/dist/hooks/useFormSubmissionAutoSaveState.js +10 -0
  107. package/dist/hooks/useFormSubmissionAutoSaveState.js.map +1 -1
  108. package/dist/hooks/useFormSubmissionModelContext.d.ts +4 -4
  109. package/dist/hooks/useFormSubmissionModelContext.js.map +1 -1
  110. package/dist/hooks/useFormSubmissionState.d.ts +45 -5
  111. package/dist/hooks/useFormSubmissionState.js +37 -0
  112. package/dist/hooks/useFormSubmissionState.js.map +1 -1
  113. package/dist/hooks/useFormValidation.d.ts +3 -3
  114. package/dist/hooks/useFormValidation.js.map +1 -1
  115. package/dist/hooks/useInjectPages.d.ts +2 -3
  116. package/dist/hooks/useInjectPages.js.map +1 -1
  117. package/dist/hooks/useIsMounted.d.ts +20 -0
  118. package/dist/hooks/useIsMounted.js +19 -0
  119. package/dist/hooks/useIsMounted.js.map +1 -1
  120. package/dist/hooks/useIsOffline.d.ts +54 -0
  121. package/dist/hooks/useIsOffline.js +54 -0
  122. package/dist/hooks/useIsOffline.js.map +1 -1
  123. package/dist/hooks/useLoadDataState.d.ts +46 -3
  124. package/dist/hooks/useLoadDataState.js +41 -0
  125. package/dist/hooks/useLoadDataState.js.map +1 -1
  126. package/dist/hooks/useLogin.d.ts +400 -13
  127. package/dist/hooks/useLogin.js +300 -0
  128. package/dist/hooks/useLogin.js.map +1 -1
  129. package/dist/hooks/useLookupNotification.d.ts +11 -4
  130. package/dist/hooks/useLookupNotification.js +42 -3
  131. package/dist/hooks/useLookupNotification.js.map +1 -1
  132. package/dist/hooks/useLookups.d.ts +3 -3
  133. package/dist/hooks/useLookups.js.map +1 -1
  134. package/dist/hooks/useNullableState.d.ts +46 -1
  135. package/dist/hooks/useNullableState.js +42 -1
  136. package/dist/hooks/useNullableState.js.map +1 -1
  137. package/dist/hooks/usePendingSubmissions.d.ts +103 -0
  138. package/dist/hooks/usePendingSubmissions.js +195 -0
  139. package/dist/hooks/usePendingSubmissions.js.map +1 -0
  140. package/dist/hooks/useReplaceableText.js +2 -1
  141. package/dist/hooks/useReplaceableText.js.map +1 -1
  142. package/dist/hooks/useSignUp.d.ts +5 -0
  143. package/dist/hooks/useSignUp.js +5 -0
  144. package/dist/hooks/useSignUp.js.map +1 -1
  145. package/dist/index.d.ts +7 -4
  146. package/dist/index.js +5 -2
  147. package/dist/index.js.map +1 -1
  148. package/dist/services/checkBsbsAreInvalid.d.ts +2 -3
  149. package/dist/services/checkBsbsAreInvalid.js.map +1 -1
  150. package/dist/services/checkIfAttachmentsExist.d.ts +2 -3
  151. package/dist/services/checkIfAttachmentsExist.js.map +1 -1
  152. package/dist/services/checkIfBsbsAreValidating.d.ts +2 -3
  153. package/dist/services/checkIfBsbsAreValidating.js.map +1 -1
  154. package/dist/services/cleanFormSubmissionModel.d.ts +4 -4
  155. package/dist/services/cleanFormSubmissionModel.js +2 -1
  156. package/dist/services/cleanFormSubmissionModel.js.map +1 -1
  157. package/dist/services/form-validation.d.ts +3 -3
  158. package/dist/services/form-validation.js.map +1 -1
  159. package/dist/services/generate-default-data.d.ts +2 -3
  160. package/dist/services/generate-default-data.js +3 -1
  161. package/dist/services/generate-default-data.js.map +1 -1
  162. package/dist/services/generateFreshdeskDependentFieldElements.js.map +1 -1
  163. package/dist/services/getDateRangeConfiguration.d.ts +2 -3
  164. package/dist/services/getDateRangeConfiguration.js.map +1 -1
  165. package/dist/services/getRepeatableSetEntriesConfiguration.d.ts +2 -3
  166. package/dist/services/getRepeatableSetEntriesConfiguration.js.map +1 -1
  167. package/dist/styles/receipt.scss +1 -1
  168. package/dist/styles/repeatable-set.scss +2 -2
  169. package/dist/typedoc.d.ts +2 -0
  170. package/dist/typedoc.js +3 -0
  171. package/dist/typedoc.js.map +1 -0
  172. package/dist/types/form.d.ts +5 -6
  173. package/dist/types/form.js.map +1 -1
  174. package/package.json +10 -4
  175. package/dist/services/determineIsInfoPage.d.ts +0 -2
  176. package/dist/services/determineIsInfoPage.js +0 -17
  177. package/dist/services/determineIsInfoPage.js.map +0 -1
@@ -1,15 +1,90 @@
1
1
  import * as React from 'react';
2
- import { authService } from '@oneblink/apps';
3
- type AuthContextValue = {
4
- isLoggedIn: ReturnType<typeof authService.isLoggedIn>;
5
- userProfile: ReturnType<typeof authService.getUserProfile>;
6
- userFriendlyName: ReturnType<typeof authService.getUserFriendlyName>;
2
+ import { UserProfile } from '@oneblink/types/typescript/misc';
3
+ export type AuthContextValue = {
4
+ /** `true` if the current user is logged in */
5
+ isLoggedIn: boolean;
6
+ /**
7
+ * See
8
+ * [auth-service.getUserProfile()](https://oneblink.github.io/apps/modules/authService.html#getUserProfile)
9
+ */
10
+ userProfile: UserProfile | null;
11
+ /**
12
+ * See
13
+ * [auth-service.getUserFriendlyName()](https://oneblink.github.io/apps/modules/authService.html#getUserFriendlyName)
14
+ */
15
+ userFriendlyName: string | undefined;
16
+ /**
17
+ * `true` if [`<AuthContextProvider />`](#AuthContextProvider) was passed the
18
+ * `formsKeyToken` prop
19
+ */
7
20
  isUsingFormsKey: boolean;
8
21
  };
22
+ /**
23
+ * `<AuthContextProvider />` is a React Component that provides the context for
24
+ * the `useAuth()` hook to be used by components further down your component
25
+ * tree. **It should only be included in your component tree once and ideally at
26
+ * the root of the application.**
27
+ *
28
+ * #### Example
29
+ *
30
+ * ```jsx
31
+ * import * as React from 'react'
32
+ * import { AuthContextProvider, useAuth } from '@oneblink/apps-react'
33
+ *
34
+ * function Component() {
35
+ * const auth = useAuth()
36
+ * // use auth here
37
+ * }
38
+ *
39
+ * function App() {
40
+ * return (
41
+ * <AuthContextProvider>
42
+ * <Component />
43
+ * </AuthContextProvider>
44
+ * )
45
+ * }
46
+ *
47
+ * const root = document.getElementById('root')
48
+ * if (root) {
49
+ * ReactDOM.render(<App />, root)
50
+ * }
51
+ * ```
52
+ *
53
+ * @param props
54
+ * @returns
55
+ * @group Components
56
+ */
9
57
  export declare function AuthContextProvider({ children, formsKeyToken, userToken, }: {
58
+ /** Your application components */
10
59
  children: React.ReactNode;
60
+ /**
61
+ * A Forms Key token being used to make requests to the OneBlink API on behalf
62
+ * of the user
63
+ */
11
64
  formsKeyToken?: string;
65
+ /**
66
+ * An encrypted user token that will be used included in the submission on
67
+ * behalf of the user
68
+ */
12
69
  userToken?: string;
13
70
  }): JSX.Element;
71
+ /**
72
+ * A React hook for containing state associated the current user. **This hook
73
+ * requires [`<AuthContextProvider />`](./AuthContextProvider.html) to be
74
+ * present in your component tree.**
75
+ *
76
+ * Example
77
+ *
78
+ * ```js
79
+ * import { useAuth } from '@oneblink/apps-react'
80
+ *
81
+ * function Component() {
82
+ * const { isLoggedIn, userProfile, userFriendlyName, isUsingFormsKey } =
83
+ * useAuth()
84
+ * }
85
+ * ```
86
+ *
87
+ * @returns
88
+ * @group Hooks
89
+ */
14
90
  export default function useAuth(): AuthContextValue;
15
- export {};
@@ -6,6 +6,41 @@ const AuthContext = React.createContext({
6
6
  userFriendlyName: undefined,
7
7
  isUsingFormsKey: false,
8
8
  });
9
+ /**
10
+ * `<AuthContextProvider />` is a React Component that provides the context for
11
+ * the `useAuth()` hook to be used by components further down your component
12
+ * tree. **It should only be included in your component tree once and ideally at
13
+ * the root of the application.**
14
+ *
15
+ * #### Example
16
+ *
17
+ * ```jsx
18
+ * import * as React from 'react'
19
+ * import { AuthContextProvider, useAuth } from '@oneblink/apps-react'
20
+ *
21
+ * function Component() {
22
+ * const auth = useAuth()
23
+ * // use auth here
24
+ * }
25
+ *
26
+ * function App() {
27
+ * return (
28
+ * <AuthContextProvider>
29
+ * <Component />
30
+ * </AuthContextProvider>
31
+ * )
32
+ * }
33
+ *
34
+ * const root = document.getElementById('root')
35
+ * if (root) {
36
+ * ReactDOM.render(<App />, root)
37
+ * }
38
+ * ```
39
+ *
40
+ * @param props
41
+ * @returns
42
+ * @group Components
43
+ */
9
44
  export function AuthContextProvider({ children, formsKeyToken, userToken, }) {
10
45
  const [value, setValue] = React.useState(() => {
11
46
  authService.setFormsKeyToken(formsKeyToken);
@@ -37,6 +72,25 @@ export function AuthContextProvider({ children, formsKeyToken, userToken, }) {
37
72
  }, []);
38
73
  return React.createElement(AuthContext.Provider, { value: value }, children);
39
74
  }
75
+ /**
76
+ * A React hook for containing state associated the current user. **This hook
77
+ * requires [`<AuthContextProvider />`](./AuthContextProvider.html) to be
78
+ * present in your component tree.**
79
+ *
80
+ * Example
81
+ *
82
+ * ```js
83
+ * import { useAuth } from '@oneblink/apps-react'
84
+ *
85
+ * function Component() {
86
+ * const { isLoggedIn, userProfile, userFriendlyName, isUsingFormsKey } =
87
+ * useAuth()
88
+ * }
89
+ * ```
90
+ *
91
+ * @returns
92
+ * @group Hooks
93
+ */
40
94
  export default function useAuth() {
41
95
  return React.useContext(AuthContext);
42
96
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useAuth.js","sourceRoot":"","sources":["../../src/hooks/useAuth.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAS5C,MAAM,WAAW,GAAG,KAAK,CAAC,aAAa,CAAmB;IACxD,UAAU,EAAE,KAAK;IACjB,WAAW,EAAE,IAAI;IACjB,gBAAgB,EAAE,SAAS;IAC3B,eAAe,EAAE,KAAK;CACvB,CAAC,CAAA;AAEF,MAAM,UAAU,mBAAmB,CAAC,EAClC,QAAQ,EACR,aAAa,EACb,SAAS,GAKV;IACC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE;QAC5C,WAAW,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAA;QAC3C,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;QACnC,OAAO;YACL,UAAU,EAAE,WAAW,CAAC,UAAU,EAAE;YACpC,WAAW,EAAE,WAAW,CAAC,cAAc,EAAE;YACzC,gBAAgB,EAAE,WAAW,CAAC,mBAAmB,EAAE;YACnD,eAAe,EAAE,CAAC,CAAC,aAAa;SACjC,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,WAAW,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAA;QAC3C,QAAQ,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;YAC1B,GAAG,YAAY;YACf,eAAe,EAAE,CAAC,CAAC,aAAa;SACjC,CAAC,CAAC,CAAA;IACL,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAA;IAEnB,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;IACrC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;IAEf,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,OAAO,WAAW,CAAC,oBAAoB,CAAC,GAAG,EAAE,CAC3C,QAAQ,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACrB,GAAG,OAAO;YACV,UAAU,EAAE,WAAW,CAAC,UAAU,EAAE;YACpC,WAAW,EAAE,WAAW,CAAC,cAAc,EAAE;YACzC,gBAAgB,EAAE,WAAW,CAAC,mBAAmB,EAAE;SACpD,CAAC,CAAC,CACJ,CAAA;IACH,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,oBAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAAG,QAAQ,CAAwB,CAAA;AAC9E,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,OAAO;IAC7B,OAAO,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAA;AACtC,CAAC","sourcesContent":["import * as React from 'react'\nimport { authService } from '@oneblink/apps'\n\ntype AuthContextValue = {\n isLoggedIn: ReturnType<typeof authService.isLoggedIn>\n userProfile: ReturnType<typeof authService.getUserProfile>\n userFriendlyName: ReturnType<typeof authService.getUserFriendlyName>\n isUsingFormsKey: boolean\n}\n\nconst AuthContext = React.createContext<AuthContextValue>({\n isLoggedIn: false,\n userProfile: null,\n userFriendlyName: undefined,\n isUsingFormsKey: false,\n})\n\nexport function AuthContextProvider({\n children,\n formsKeyToken,\n userToken,\n}: {\n children: React.ReactNode\n formsKeyToken?: string\n userToken?: string\n}) {\n const [value, setValue] = React.useState(() => {\n authService.setFormsKeyToken(formsKeyToken)\n authService.setUserToken(userToken)\n return {\n isLoggedIn: authService.isLoggedIn(),\n userProfile: authService.getUserProfile(),\n userFriendlyName: authService.getUserFriendlyName(),\n isUsingFormsKey: !!formsKeyToken,\n }\n })\n\n React.useEffect(() => {\n authService.setFormsKeyToken(formsKeyToken)\n setValue((currentValue) => ({\n ...currentValue,\n isUsingFormsKey: !!formsKeyToken,\n }))\n }, [formsKeyToken])\n\n React.useEffect(() => {\n authService.setUserToken(userToken)\n }, [userToken])\n\n React.useEffect(() => {\n return authService.registerAuthListener(() =>\n setValue((current) => ({\n ...current,\n isLoggedIn: authService.isLoggedIn(),\n userProfile: authService.getUserProfile(),\n userFriendlyName: authService.getUserFriendlyName(),\n })),\n )\n }, [])\n\n return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>\n}\n\nexport default function useAuth() {\n return React.useContext(AuthContext)\n}\n"]}
1
+ {"version":3,"file":"useAuth.js","sourceRoot":"","sources":["../../src/hooks/useAuth.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAuB5C,MAAM,WAAW,GAAG,KAAK,CAAC,aAAa,CAAmB;IACxD,UAAU,EAAE,KAAK;IACjB,WAAW,EAAE,IAAI;IACjB,gBAAgB,EAAE,SAAS;IAC3B,eAAe,EAAE,KAAK;CACvB,CAAC,CAAA;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAClC,QAAQ,EACR,aAAa,EACb,SAAS,GAcV;IACC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE;QAC5C,WAAW,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAA;QAC3C,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;QACnC,OAAO;YACL,UAAU,EAAE,WAAW,CAAC,UAAU,EAAE;YACpC,WAAW,EAAE,WAAW,CAAC,cAAc,EAAE;YACzC,gBAAgB,EAAE,WAAW,CAAC,mBAAmB,EAAE;YACnD,eAAe,EAAE,CAAC,CAAC,aAAa;SACjC,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,WAAW,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAA;QAC3C,QAAQ,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;YAC1B,GAAG,YAAY;YACf,eAAe,EAAE,CAAC,CAAC,aAAa;SACjC,CAAC,CAAC,CAAA;IACL,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAA;IAEnB,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;IACrC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;IAEf,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,OAAO,WAAW,CAAC,oBAAoB,CAAC,GAAG,EAAE,CAC3C,QAAQ,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACrB,GAAG,OAAO;YACV,UAAU,EAAE,WAAW,CAAC,UAAU,EAAE;YACpC,WAAW,EAAE,WAAW,CAAC,cAAc,EAAE;YACzC,gBAAgB,EAAE,WAAW,CAAC,mBAAmB,EAAE;SACpD,CAAC,CAAC,CACJ,CAAA;IACH,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,oBAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAAG,QAAQ,CAAwB,CAAA;AAC9E,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO;IAC7B,OAAO,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAA;AACtC,CAAC","sourcesContent":["import * as React from 'react'\nimport { authService } from '@oneblink/apps'\nimport { UserProfile } from '@oneblink/types/typescript/misc'\n\nexport type AuthContextValue = {\n /** `true` if the current user is logged in */\n isLoggedIn: boolean\n /**\n * See\n * [auth-service.getUserProfile()](https://oneblink.github.io/apps/modules/authService.html#getUserProfile)\n */\n userProfile: UserProfile | null\n /**\n * See\n * [auth-service.getUserFriendlyName()](https://oneblink.github.io/apps/modules/authService.html#getUserFriendlyName)\n */\n userFriendlyName: string | undefined\n /**\n * `true` if [`<AuthContextProvider />`](#AuthContextProvider) was passed the\n * `formsKeyToken` prop\n */\n isUsingFormsKey: boolean\n}\n\nconst AuthContext = React.createContext<AuthContextValue>({\n isLoggedIn: false,\n userProfile: null,\n userFriendlyName: undefined,\n isUsingFormsKey: false,\n})\n/**\n * `<AuthContextProvider />` is a React Component that provides the context for\n * the `useAuth()` hook to be used by components further down your component\n * tree. **It should only be included in your component tree once and ideally at\n * the root of the application.**\n *\n * #### Example\n *\n * ```jsx\n * import * as React from 'react'\n * import { AuthContextProvider, useAuth } from '@oneblink/apps-react'\n *\n * function Component() {\n * const auth = useAuth()\n * // use auth here\n * }\n *\n * function App() {\n * return (\n * <AuthContextProvider>\n * <Component />\n * </AuthContextProvider>\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 function AuthContextProvider({\n children,\n formsKeyToken,\n userToken,\n}: {\n /** Your application components */\n children: React.ReactNode\n /**\n * A Forms Key token being used to make requests to the OneBlink API on behalf\n * of the user\n */\n formsKeyToken?: string\n /**\n * An encrypted user token that will be used included in the submission on\n * behalf of the user\n */\n userToken?: string\n}) {\n const [value, setValue] = React.useState(() => {\n authService.setFormsKeyToken(formsKeyToken)\n authService.setUserToken(userToken)\n return {\n isLoggedIn: authService.isLoggedIn(),\n userProfile: authService.getUserProfile(),\n userFriendlyName: authService.getUserFriendlyName(),\n isUsingFormsKey: !!formsKeyToken,\n }\n })\n\n React.useEffect(() => {\n authService.setFormsKeyToken(formsKeyToken)\n setValue((currentValue) => ({\n ...currentValue,\n isUsingFormsKey: !!formsKeyToken,\n }))\n }, [formsKeyToken])\n\n React.useEffect(() => {\n authService.setUserToken(userToken)\n }, [userToken])\n\n React.useEffect(() => {\n return authService.registerAuthListener(() =>\n setValue((current) => ({\n ...current,\n isLoggedIn: authService.isLoggedIn(),\n userProfile: authService.getUserProfile(),\n userFriendlyName: authService.getUserFriendlyName(),\n })),\n )\n }, [])\n\n return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>\n}\n\n/**\n * A React hook for containing state associated the current user. **This hook\n * requires [`<AuthContextProvider />`](./AuthContextProvider.html) to be\n * present in your component tree.**\n *\n * Example\n *\n * ```js\n * import { useAuth } from '@oneblink/apps-react'\n *\n * function Component() {\n * const { isLoggedIn, userProfile, userFriendlyName, isUsingFormsKey } =\n * useAuth()\n * }\n * ```\n *\n * @returns\n * @group Hooks\n */\nexport default function useAuth() {\n return React.useContext(AuthContext)\n}\n"]}
@@ -1,5 +1,42 @@
1
- type setTrue = () => void;
2
- type setFalse = () => void;
3
- type toggle = () => void;
4
- export default function useBooleanState(defaultValue: boolean): [boolean, setTrue, setFalse, toggle];
5
- export {};
1
+ /**
2
+ * This function is a react hook for boolean state that comes with
3
+ * `useCallback`s for 'turning on', 'turning off' and toggling the state.
4
+ *
5
+ * ## Return
6
+ *
7
+ * The return type of `useBooleanState(true)` is an array where:
8
+ *
9
+ * - The first item is a `boolean` (the state).
10
+ * - The second item is `() => void` (a function that sets the state to true).
11
+ * - The third item is `() => void` (a function that sets the state to false).
12
+ * - The fourth item is `() => void` (a function that toggles the state to the
13
+ * opposite of what it currently is).
14
+ *
15
+ * As such, the items in the array can be destructured and named whatever you
16
+ * like:
17
+ *
18
+ * ```js
19
+ * import { useBooleanState } from '@oneblink/apps-react'
20
+ *
21
+ * const [dialogIsOpen, openDialog, closeDialog, toggleDialog] =
22
+ * useBooleanState(true)
23
+ * ```
24
+ *
25
+ * These properties can then be used like:
26
+ *
27
+ * ```js
28
+ * openDialog()
29
+ * closeDialog()
30
+ * toggleDialog()
31
+ * ```
32
+ *
33
+ * @param defaultValue
34
+ * @returns
35
+ * @group Hooks
36
+ */
37
+ export default function useBooleanState(defaultValue: boolean): [
38
+ state: boolean,
39
+ setTrue: () => void,
40
+ setFalse: () => void,
41
+ toggle: () => void
42
+ ];
@@ -1,4 +1,40 @@
1
1
  import * as React from 'react';
2
+ /**
3
+ * This function is a react hook for boolean state that comes with
4
+ * `useCallback`s for 'turning on', 'turning off' and toggling the state.
5
+ *
6
+ * ## Return
7
+ *
8
+ * The return type of `useBooleanState(true)` is an array where:
9
+ *
10
+ * - The first item is a `boolean` (the state).
11
+ * - The second item is `() => void` (a function that sets the state to true).
12
+ * - The third item is `() => void` (a function that sets the state to false).
13
+ * - The fourth item is `() => void` (a function that toggles the state to the
14
+ * opposite of what it currently is).
15
+ *
16
+ * As such, the items in the array can be destructured and named whatever you
17
+ * like:
18
+ *
19
+ * ```js
20
+ * import { useBooleanState } from '@oneblink/apps-react'
21
+ *
22
+ * const [dialogIsOpen, openDialog, closeDialog, toggleDialog] =
23
+ * useBooleanState(true)
24
+ * ```
25
+ *
26
+ * These properties can then be used like:
27
+ *
28
+ * ```js
29
+ * openDialog()
30
+ * closeDialog()
31
+ * toggleDialog()
32
+ * ```
33
+ *
34
+ * @param defaultValue
35
+ * @returns
36
+ * @group Hooks
37
+ */
2
38
  export default function useBooleanState(defaultValue) {
3
39
  const [state, setState] = React.useState(defaultValue);
4
40
  const turnOn = React.useCallback(() => setState(true), []);
@@ -1 +1 @@
1
- {"version":3,"file":"useBooleanState.js","sourceRoot":"","sources":["../../src/hooks/useBooleanState.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,YAAqB;IAErB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAA;IACtD,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;IAC1D,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAA;IAC5D,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAA;IAC3E,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;AACzC,CAAC","sourcesContent":["import * as React from 'react'\n\ntype setTrue = () => void\ntype setFalse = () => void\ntype toggle = () => void\n\nexport default function useBooleanState(\n defaultValue: boolean,\n): [boolean, setTrue, setFalse, toggle] {\n const [state, setState] = React.useState(defaultValue)\n const turnOn = React.useCallback(() => setState(true), [])\n const turnOff = React.useCallback(() => setState(false), [])\n const toggle = React.useCallback(() => setState((current) => !current), [])\n return [state, turnOn, turnOff, toggle]\n}\n"]}
1
+ {"version":3,"file":"useBooleanState.js","sourceRoot":"","sources":["../../src/hooks/useBooleanState.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,YAAqB;IAOrB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAA;IACtD,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;IAC1D,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAA;IAC5D,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAA;IAC3E,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;AACzC,CAAC","sourcesContent":["import * as React from 'react'\n\n/**\n * This function is a react hook for boolean state that comes with\n * `useCallback`s for 'turning on', 'turning off' and toggling the state.\n *\n * ## Return\n *\n * The return type of `useBooleanState(true)` is an array where:\n *\n * - The first item is a `boolean` (the state).\n * - The second item is `() => void` (a function that sets the state to true).\n * - The third item is `() => void` (a function that sets the state to false).\n * - The fourth item is `() => void` (a function that toggles the state to the\n * opposite of what it currently is).\n *\n * As such, the items in the array can be destructured and named whatever you\n * like:\n *\n * ```js\n * import { useBooleanState } from '@oneblink/apps-react'\n *\n * const [dialogIsOpen, openDialog, closeDialog, toggleDialog] =\n * useBooleanState(true)\n * ```\n *\n * These properties can then be used like:\n *\n * ```js\n * openDialog()\n * closeDialog()\n * toggleDialog()\n * ```\n *\n * @param defaultValue\n * @returns\n * @group Hooks\n */\nexport default function useBooleanState(\n defaultValue: boolean,\n): [\n state: boolean,\n setTrue: () => void,\n setFalse: () => void,\n toggle: () => void,\n] {\n const [state, setState] = React.useState(defaultValue)\n const turnOn = React.useCallback(() => setState(true), [])\n const turnOff = React.useCallback(() => setState(false), [])\n const toggle = React.useCallback(() => setState((current) => !current), [])\n return [state, turnOn, turnOff, toggle]\n}\n"]}
@@ -1,3 +1,43 @@
1
+ /**
2
+ * This function is a react hook for watching for click events outside of a
3
+ * particular element. The hook will add and remove its own `eventListener`.
4
+ *
5
+ * - For performance reasons, it is important to pass a memoised function as the
6
+ * callback argument, eg:
7
+ *
8
+ * ```js
9
+ * React.useCallback(() => {}, [])
10
+ * ```
11
+ *
12
+ * ## Example
13
+ *
14
+ * ```js
15
+ * import * as React from 'react'
16
+ * import { useClickOutsideElement } from '@oneblink/apps-react'
17
+ *
18
+ * const MyComponent = () => {
19
+ * const narrowDivRef = React.useRef(null)
20
+ * useClickOutsideElement(
21
+ * narrowDivRef,
22
+ * React.useCallback(() => {
23
+ * console.log('Wide Div was clicked outside of narrow div...')
24
+ * }, []),
25
+ * )
26
+ *
27
+ * return (
28
+ * <div className="wide-div">
29
+ * <div ref={narrowDivRef} className="narrow-div"></div>
30
+ * </div>
31
+ * )
32
+ * }
33
+ *
34
+ * export default MyComponent
35
+ * ```
36
+ *
37
+ * @param ref
38
+ * @param callback
39
+ * @group Hooks
40
+ */
1
41
  export default function useClickOutsideElement(ref: {
2
42
  current: HTMLElement | null;
3
43
  }, callback: () => void): void;
@@ -1,4 +1,44 @@
1
1
  import * as React from 'react';
2
+ /**
3
+ * This function is a react hook for watching for click events outside of a
4
+ * particular element. The hook will add and remove its own `eventListener`.
5
+ *
6
+ * - For performance reasons, it is important to pass a memoised function as the
7
+ * callback argument, eg:
8
+ *
9
+ * ```js
10
+ * React.useCallback(() => {}, [])
11
+ * ```
12
+ *
13
+ * ## Example
14
+ *
15
+ * ```js
16
+ * import * as React from 'react'
17
+ * import { useClickOutsideElement } from '@oneblink/apps-react'
18
+ *
19
+ * const MyComponent = () => {
20
+ * const narrowDivRef = React.useRef(null)
21
+ * useClickOutsideElement(
22
+ * narrowDivRef,
23
+ * React.useCallback(() => {
24
+ * console.log('Wide Div was clicked outside of narrow div...')
25
+ * }, []),
26
+ * )
27
+ *
28
+ * return (
29
+ * <div className="wide-div">
30
+ * <div ref={narrowDivRef} className="narrow-div"></div>
31
+ * </div>
32
+ * )
33
+ * }
34
+ *
35
+ * export default MyComponent
36
+ * ```
37
+ *
38
+ * @param ref
39
+ * @param callback
40
+ * @group Hooks
41
+ */
2
42
  export default function useClickOutsideElement(ref, callback) {
3
43
  const handleClickOutside = React.useCallback((event) => {
4
44
  if (ref.current && !ref.current.contains(event.target)) {
@@ -1 +1 @@
1
- {"version":3,"file":"useClickOutsideElement.js","sourceRoot":"","sources":["../../src/hooks/useClickOutsideElement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,GAAoC,EACpC,QAAoB;IAEpB,MAAM,kBAAkB,GAAG,KAAK,CAAC,WAAW,CAC1C,CAAC,KAAY,EAAE,EAAE;QACf,IAAI,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAc,CAAC,EAAE;YAC9D,QAAQ,EAAE,CAAA;SACX;IACH,CAAC,EACD,CAAC,QAAQ,EAAE,GAAG,CAAC,CAChB,CAAA;IACD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAA;QAC1D,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAA;QAC/D,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAA;AAC1B,CAAC","sourcesContent":["import * as React from 'react'\n\nexport default function useClickOutsideElement(\n ref: { current: HTMLElement | null },\n callback: () => void,\n) {\n const handleClickOutside = React.useCallback(\n (event: Event) => {\n if (ref.current && !ref.current.contains(event.target as Node)) {\n callback()\n }\n },\n [callback, ref],\n )\n React.useEffect(() => {\n document.addEventListener('mousedown', handleClickOutside)\n return () => {\n document.removeEventListener('mousedown', handleClickOutside)\n }\n }, [handleClickOutside])\n}\n"]}
1
+ {"version":3,"file":"useClickOutsideElement.js","sourceRoot":"","sources":["../../src/hooks/useClickOutsideElement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,GAAoC,EACpC,QAAoB;IAEpB,MAAM,kBAAkB,GAAG,KAAK,CAAC,WAAW,CAC1C,CAAC,KAAY,EAAE,EAAE;QACf,IAAI,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAc,CAAC,EAAE;YAC9D,QAAQ,EAAE,CAAA;SACX;IACH,CAAC,EACD,CAAC,QAAQ,EAAE,GAAG,CAAC,CAChB,CAAA;IACD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAA;QAC1D,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAA;QAC/D,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAA;AAC1B,CAAC","sourcesContent":["import * as React from 'react'\n\n/**\n * This function is a react hook for watching for click events outside of a\n * particular element. The hook will add and remove its own `eventListener`.\n *\n * - For performance reasons, it is important to pass a memoised function as the\n * callback argument, eg:\n *\n * ```js\n * React.useCallback(() => {}, [])\n * ```\n *\n * ## Example\n *\n * ```js\n * import * as React from 'react'\n * import { useClickOutsideElement } from '@oneblink/apps-react'\n *\n * const MyComponent = () => {\n * const narrowDivRef = React.useRef(null)\n * useClickOutsideElement(\n * narrowDivRef,\n * React.useCallback(() => {\n * console.log('Wide Div was clicked outside of narrow div...')\n * }, []),\n * )\n *\n * return (\n * <div className=\"wide-div\">\n * <div ref={narrowDivRef} className=\"narrow-div\"></div>\n * </div>\n * )\n * }\n *\n * export default MyComponent\n * ```\n *\n * @param ref\n * @param callback\n * @group Hooks\n */\nexport default function useClickOutsideElement(\n ref: { current: HTMLElement | null },\n callback: () => void,\n) {\n const handleClickOutside = React.useCallback(\n (event: Event) => {\n if (ref.current && !ref.current.contains(event.target as Node)) {\n callback()\n }\n },\n [callback, ref],\n )\n React.useEffect(() => {\n document.addEventListener('mousedown', handleClickOutside)\n return () => {\n document.removeEventListener('mousedown', handleClickOutside)\n }\n }, [handleClickOutside])\n}\n"]}
@@ -1,7 +1,6 @@
1
- import { FormTypes } from '@oneblink/types';
1
+ import { FormTypes, SubmissionTypes } from '@oneblink/types';
2
2
  import { conditionalLogicService } from '@oneblink/sdk-core';
3
- import { FormSubmissionModel } from '../types/form';
4
- export default function useConditionalLogic(definition: FormTypes.Form, submission: FormSubmissionModel): {
3
+ export default function useConditionalLogic(definition: FormTypes.Form, submission: SubmissionTypes.S3SubmissionData['submission']): {
5
4
  conditionalLogicError: Error | undefined;
6
5
  formElementsConditionallyShown: conditionalLogicService.FormElementsConditionallyShown;
7
6
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useConditionalLogic.js","sourceRoot":"","sources":["../../src/hooks/useConditionalLogic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEvC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AAO5D,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,UAA0B,EAC1B,UAA+B;IAE/B,MAAM,CAAC,qBAAqB,EAAE,wBAAwB,CAAC,GAAG,KAAK,CAAC,QAAQ,EAErE,CAAA;IAEH,MAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,KAAY,EAAE,EAAE;QACvD,OAAO,CAAC,IAAI,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAA;QAC7D,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;QAC9B,wBAAwB,CAAC,KAAK,CAAC,CAAA;IACjC,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,MAAM,8BAA8B,GAClC,KAAK,CAAC,OAAO,CAAiC,GAAG,EAAE;QACjD,OAAO,uBAAuB,CAAC,sCAAsC,CAAC;YACpE,YAAY,EAAE,UAAU,CAAC,QAAQ;YACjC,UAAU;YACV,aAAa;SACd,CAAC,CAAA;IACJ,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAA;IAEtD,OAAO;QACL,qBAAqB;QACrB,8BAA8B;KAC/B,CAAA;AACH,CAAC","sourcesContent":["import { Sentry } from '@oneblink/apps'\nimport { FormTypes } from '@oneblink/types'\nimport * as React from 'react'\nimport { conditionalLogicService } from '@oneblink/sdk-core'\n\nimport {\n FormElementsConditionallyShown,\n FormSubmissionModel,\n} from '../types/form'\n\nexport default function useConditionalLogic(\n definition: FormTypes.Form,\n submission: FormSubmissionModel,\n) {\n const [conditionalLogicError, setConditionalLogicError] = React.useState<\n Error | undefined\n >()\n\n const errorCallback = React.useCallback((error: Error) => {\n console.warn('Error while checking conditional logic', error)\n Sentry.captureException(error)\n setConditionalLogicError(error)\n }, [])\n\n const formElementsConditionallyShown =\n React.useMemo<FormElementsConditionallyShown>(() => {\n return conditionalLogicService.generateFormElementsConditionallyShown({\n formElements: definition.elements,\n submission,\n errorCallback,\n })\n }, [definition.elements, submission, errorCallback])\n\n return {\n conditionalLogicError,\n formElementsConditionallyShown,\n }\n}\n"]}
1
+ {"version":3,"file":"useConditionalLogic.js","sourceRoot":"","sources":["../../src/hooks/useConditionalLogic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEvC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AAI5D,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,UAA0B,EAC1B,UAA0D;IAE1D,MAAM,CAAC,qBAAqB,EAAE,wBAAwB,CAAC,GAAG,KAAK,CAAC,QAAQ,EAErE,CAAA;IAEH,MAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,KAAY,EAAE,EAAE;QACvD,OAAO,CAAC,IAAI,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAA;QAC7D,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;QAC9B,wBAAwB,CAAC,KAAK,CAAC,CAAA;IACjC,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,MAAM,8BAA8B,GAClC,KAAK,CAAC,OAAO,CAAiC,GAAG,EAAE;QACjD,OAAO,uBAAuB,CAAC,sCAAsC,CAAC;YACpE,YAAY,EAAE,UAAU,CAAC,QAAQ;YACjC,UAAU;YACV,aAAa;SACd,CAAC,CAAA;IACJ,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAA;IAEtD,OAAO;QACL,qBAAqB;QACrB,8BAA8B;KAC/B,CAAA;AACH,CAAC","sourcesContent":["import { Sentry } from '@oneblink/apps'\nimport { FormTypes, SubmissionTypes } from '@oneblink/types'\nimport * as React from 'react'\nimport { conditionalLogicService } from '@oneblink/sdk-core'\n\nimport { FormElementsConditionallyShown } from '../types/form'\n\nexport default function useConditionalLogic(\n definition: FormTypes.Form,\n submission: SubmissionTypes.S3SubmissionData['submission'],\n) {\n const [conditionalLogicError, setConditionalLogicError] = React.useState<\n Error | undefined\n >()\n\n const errorCallback = React.useCallback((error: Error) => {\n console.warn('Error while checking conditional logic', error)\n Sentry.captureException(error)\n setConditionalLogicError(error)\n }, [])\n\n const formElementsConditionallyShown =\n React.useMemo<FormElementsConditionallyShown>(() => {\n return conditionalLogicService.generateFormElementsConditionallyShown({\n formElements: definition.elements,\n submission,\n errorCallback,\n })\n }, [definition.elements, submission, errorCallback])\n\n return {\n conditionalLogicError,\n formElementsConditionallyShown,\n }\n}\n"]}
@@ -0,0 +1,82 @@
1
+ import * as React from 'react';
2
+ import { SubmissionTypes } from '@oneblink/types';
3
+ /** The value returned from `useDrafts()` hook */
4
+ export type DraftsContextValue = {
5
+ /** `true` drafts are currently loading. */
6
+ isLoading: boolean;
7
+ /** An Error object if loading drafts fails */
8
+ loadError: Error | null;
9
+ /** The incomplete submissions that were saved for later */
10
+ drafts: SubmissionTypes.FormsAppDraft[];
11
+ /** A function to trigger loading of the drafts */
12
+ reloadDrafts: () => unknown;
13
+ /** A function to clear Error object from loading drafts */
14
+ clearLoadError: () => void;
15
+ /** `true` drafts are syncing with other devices */
16
+ isSyncing: boolean;
17
+ /** A function to trigger syncing of the drafts */
18
+ syncDrafts: () => unknown;
19
+ /** An Error object if syncing drafts fails */
20
+ syncError: Error | null;
21
+ /** A function to clear Error object from syncing drafts */
22
+ clearSyncError: () => void;
23
+ /** A function to remove a draft */
24
+ deleteDraft: (draftId: string) => Promise<void>;
25
+ };
26
+ /**
27
+ * React Component that provides the context for the `useDrafts()` hook to be
28
+ * used by components further down your component tree. **It should only be
29
+ * included in your component tree once and ideally at the root of the
30
+ * application.**
31
+ *
32
+ * #### Example
33
+ *
34
+ * ```jsx
35
+ * import * as React from 'react'
36
+ * import { DraftsContextProvider, useDrafts } from '@oneblink/apps-react'
37
+ *
38
+ * function Component() {
39
+ * const draftsContext = useDrafts()
40
+ * // use drafts here
41
+ * }
42
+ *
43
+ * function App() {
44
+ * return (
45
+ * <DraftsContextProvider>
46
+ * <Component />
47
+ * </DraftsContextProvider>
48
+ * )
49
+ * }
50
+ *
51
+ * const root = document.getElementById('root')
52
+ * if (root) {
53
+ * ReactDOM.render(<App />, root)
54
+ * }
55
+ * ```
56
+ *
57
+ * @param props
58
+ * @returns
59
+ * @group Components
60
+ */
61
+ export declare function DraftsContextProvider({
62
+ /** The identifier for the forms app associated with the user's drafts */
63
+ formsAppId,
64
+ /**
65
+ * `true` if drafts are enabled, otherwise `false`. Can be used for account
66
+ * tier validation.
67
+ */
68
+ isDraftsEnabled,
69
+ /** Your application components */
70
+ children, }: {
71
+ formsAppId: number;
72
+ isDraftsEnabled: boolean;
73
+ children: React.ReactNode;
74
+ }): JSX.Element;
75
+ /**
76
+ * React hook to get the context value for Drafts. Will throw an Error if used
77
+ * outside of the `<DraftsContextProvider />` component.
78
+ *
79
+ * @returns
80
+ * @group Hooks
81
+ */
82
+ export default function useDrafts(): DraftsContextValue;