@taxbit/react-sdk 1.0.0-beta.4 → 1.0.0-beta.6

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 (32) hide show
  1. package/README.md +31 -5
  2. package/dist/src/components/ErrorBoundary/ErrorBoundary.d.ts +16 -0
  3. package/dist/src/components/ErrorBoundary/index.d.ts +1 -0
  4. package/dist/src/components/index.d.ts +1 -0
  5. package/dist/src/contexts/QuestionnaireUI/useQuestionnaireUI.d.ts +1 -1
  6. package/dist/src/contexts/QuestionnaireUI/useQuestionnaireUIContext.d.ts +2 -2
  7. package/dist/src/contexts/TaxDocumentation/useTaxDocumentation.d.ts +7 -9
  8. package/dist/src/contexts/TaxDocumentation/useTaxDocumentationContext.d.ts +16 -18
  9. package/dist/src/entry/TaxbitQuestionnaire/TaxbitQuestionnaire.d.ts +7 -5
  10. package/dist/src/entry/index.d.ts +1 -1
  11. package/dist/src/hooks/index.d.ts +1 -0
  12. package/dist/src/hooks/useHandleError.d.ts +3 -0
  13. package/dist/src/hooks/useTaxbit/index.d.ts +1 -0
  14. package/dist/src/hooks/useTaxbit/useTaxbit.d.ts +10 -3
  15. package/dist/src/hooks/useTaxbit/useTaxbitStatus.d.ts +9 -2
  16. package/dist/src/types/InputStep.d.ts +2 -2
  17. package/dist/src/utils/bearerTokenIsRequiredError.d.ts +1 -0
  18. package/dist/src/utils/getFormStatus.d.ts +2 -0
  19. package/dist/src/utils/getHeaders.d.ts +3 -0
  20. package/dist/src/utils/getLanguage.d.ts +2 -0
  21. package/dist/src/utils/handleFetch.d.ts +7 -0
  22. package/dist/src/utils/index.d.ts +5 -0
  23. package/dist/src/widgets/TaxbitQuestionnairePersist/TaxbitQuestionnairePersist.d.ts +4 -2
  24. package/dist/src/widgets/TaxbitQuestionnairePersist/__tests__/TaxbitQuestionnairePersist.missingBearerToken.test.d.ts +0 -0
  25. package/dist/src/widgets/TaxbitQuestionnairePersist/useTaxbitPersist.d.ts +7 -11
  26. package/dist/src/wizard/TaxbitQuestionnaireUI/steps.d.ts +0 -1
  27. package/dist/taxbit-react-sdk.js +2296 -2255
  28. package/dist/taxbit-react-sdk.umd.cjs +10 -10
  29. package/package.json +4 -4
  30. package/dist/src/hooks/useTaxbit/useTaxbitConnect.d.ts +0 -8
  31. package/dist/src/wizard/TaxbitQuestionnaireUI/Confirmation/Confirmation.d.ts +0 -2
  32. package/dist/src/wizard/TaxbitQuestionnaireUI/Confirmation/index.d.ts +0 -1
package/README.md CHANGED
@@ -126,13 +126,13 @@ const {
126
126
  statusData,
127
127
  serverData,
128
128
  canGetDocumentUrl,
129
- getNewDocumentUrl,
130
- isGettingDocumentUrl,
129
+ generateDocumentUrl,
130
+ isGeneratingDocumentUrl,
131
131
  documentUrl,
132
- } = useTaxbit(bearerToken, questionnaire);
132
+ } = useTaxbit({ bearerToken, questionnaire, onError });
133
133
  ```
134
134
 
135
- It can also be used to get the document URL for the user's tax documentation. The `getNewDocumentUrl` function will trigger a temporary URL generation. The `documentUrl` will be the URL of the document if it is available. `isGettingDocumentUrl` will be true while the URL is being generated. `canGetDocumentUrl` will be true if the user has submitted the questionnaire and a PDF tax document is available to this user. Note, `DPS` data does not generate a PDF document.
135
+ It can also be used to get the document URL for the user's tax documentation. The `generateDocumentUrl` function will trigger a temporary URL generation. The `documentUrl` will be the URL of the document if it is available. `isGeneratingDocumentUrl` will be true while the URL is being generated. `canGetDocumentUrl` will be true if the user has submitted the questionnaire and a PDF tax document is available to this user. Note, `DPS` data does not generate a PDF document.
136
136
 
137
137
  ### Server Data
138
138
 
@@ -205,6 +205,18 @@ or for W-Form status
205
205
  The Taxbit React SDK renders a form for collecting user data. The form is structured with fairly semantic HTML and CSS classes and can be easily customized to closely match your client's style.
206
206
  Classnames are namespaced with "taxbit-" to reduce the chance of conflict.
207
207
 
208
+ #### Loading Component
209
+
210
+ When the TaxbitQuestionnaire component is fetching the status and tax documentation from the server, the TaxbitQuestionnaire component will display a text message my default "Retrieving interview status...". This can be customized by supplying a `loadingComponent` as a prop.
211
+
212
+ ```jsx
213
+ <TaxbitQuestionnaire
214
+ bearerToken="bearer token goes here"
215
+ questionnaire="W-FORM"
216
+ loadingComponent={<div>Loading...</div>}
217
+ />
218
+ ```
219
+
208
220
  ### Callbacks
209
221
 
210
222
  The Taxbit React SDK provides callbacks for the following events on the `TaxbitQuestionnaire` component. These callbacks can be passed in to the Component and used to trigger other actions in your application.
@@ -215,9 +227,13 @@ The Taxbit React SDK provides callbacks for the following events on the `TaxbitQ
215
227
  - `onSettled` - called after `onError` or `onSuccess` is called.
216
228
  - `onProgress` - called when the user loads and navigates within the Taxbit UI. The function passed here will be passed a Progress object (see below for the type definition):
217
229
 
230
+ #### Error Boundary
231
+
232
+ A basic React Error Boundary is in place and when an error is thrown, the TaxbitQuestionnaire component will display errors on screen and throw an error in console. The exceptions that are possible are related to fetching data from the server, such as authentication (401 Unauthorized) or network problems (Failed to fetch). An error is also thrown if the bearer token is missing (Bearer Token is required). If the `onError` callback is provided to the component or the hook, these errors will be caught not and the error boundary will not be displayed.
233
+
218
234
  The DPS sequence, for example, can have a total of 3, 4, or 5 steps, each with a localized `stepTitle` and `stepId`. The `stepNumber` is the current step (1 based), and `percentComplete` is the percentage of the steps that have been completed.
219
235
 
220
- ### Types
236
+ ## Types
221
237
 
222
238
  The Taxbit React SDK provides a type for the status of the most recent tax documentation submitted by the user, referred to as `ClientTaxDocumentationStatus`. The data passed to the component and returned to the callback is typed as `ClientTaxDocumentation`.
223
239
 
@@ -290,6 +306,16 @@ type QuestionnaireType = 'DPS' | 'W-FORM';
290
306
 
291
307
  ## Changelog
292
308
 
309
+ ### Version 1.0.0-beta.6
310
+
311
+ 1. Bugs fixed related to the country drop-downs.
312
+ 2. Added a `loadingComponent` prop to the TaxbitQuestionnaire component.
313
+
314
+ ### Version 1.0.0-beta.5
315
+
316
+ 1. Document Generation modifications. Renamed from "getDocumentUrl" to "generateDocumentUrl".
317
+ 2. `onError` callback is now exposed in both the TaxbitQuestionnaire component and the useTaxbit hook.
318
+
293
319
  ### Version 1.0.0-beta.4
294
320
 
295
321
  1. More explicit typing for TaxbitQuestionnaire component props
@@ -0,0 +1,16 @@
1
+ import React, { Component, ReactNode } from 'react';
2
+ interface Props {
3
+ children?: ReactNode;
4
+ }
5
+ interface State {
6
+ hasError: boolean;
7
+ errorMessage?: string;
8
+ }
9
+ export declare class ErrorBoundary extends Component<Props, State> {
10
+ state: State;
11
+ static getDerivedStateFromError(error: Error): State;
12
+ componentDidCatch(error: Error): void;
13
+ componentDidUpdate(): void;
14
+ render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
15
+ }
16
+ export {};
@@ -0,0 +1 @@
1
+ export * from './ErrorBoundary';
@@ -1,4 +1,5 @@
1
1
  export * from './Address';
2
+ export * from './ErrorBoundary';
2
3
  export * from './ErrorMessage';
3
4
  export * from './Form';
4
5
  export * from './InputStatus';
@@ -12,7 +12,7 @@ export declare const useQuestionnaireUI: () => {
12
12
  config: {
13
13
  minimumAge: number;
14
14
  } | undefined;
15
- language: "bg" | "cs" | "da" | "de" | "de-at" | "el" | "el-cy" | "en" | "en-gb" | "en-nz" | "en-us" | "es" | "et" | "fi" | "fr" | "fr-ca" | "fr-lu" | "ga" | "hr" | "hu" | "it" | "lt" | "lv" | "mt" | "nl" | "nl-be" | "no" | "pl" | "pt" | "ro" | "sk" | "sl" | "sv";
15
+ language: import("types").Locale;
16
16
  getLocalText: (key: import("i18n/types").TextKey) => string;
17
17
  getLocalTitle: (key: string) => string;
18
18
  getLocalSubTitle: (key: import("i18n/types").SubTitleKey) => string;
@@ -3,7 +3,7 @@ export declare const useQuestionnaireUIContext: () => {
3
3
  config: {
4
4
  minimumAge: number;
5
5
  } | undefined;
6
- language: "bg" | "cs" | "da" | "de" | "de-at" | "el" | "el-cy" | "en" | "en-gb" | "en-nz" | "en-us" | "es" | "et" | "fi" | "fr" | "fr-ca" | "fr-lu" | "ga" | "hr" | "hu" | "it" | "lt" | "lv" | "mt" | "nl" | "nl-be" | "no" | "pl" | "pt" | "ro" | "sk" | "sl" | "sv";
6
+ language: import("../../types").Locale;
7
7
  getLocalText: (key: import("../../i18n/types").TextKey) => string;
8
8
  getLocalTitle: (key: string) => string;
9
9
  getLocalSubTitle: (key: import("../../i18n/types").SubTitleKey) => string;
@@ -39,7 +39,7 @@ export declare const useQuestionnaireUIContext: () => {
39
39
  config: {
40
40
  minimumAge: number;
41
41
  } | undefined;
42
- language: "bg" | "cs" | "da" | "de" | "de-at" | "el" | "el-cy" | "en" | "en-gb" | "en-nz" | "en-us" | "es" | "et" | "fi" | "fr" | "fr-ca" | "fr-lu" | "ga" | "hr" | "hu" | "it" | "lt" | "lv" | "mt" | "nl" | "nl-be" | "no" | "pl" | "pt" | "ro" | "sk" | "sl" | "sv";
42
+ language: import("../../types").Locale;
43
43
  getLocalText: (key: import("../../i18n/types").TextKey) => string;
44
44
  getLocalTitle: (key: string) => string;
45
45
  getLocalSubTitle: (key: import("../../i18n/types").SubTitleKey) => string;
@@ -1,8 +1,7 @@
1
- /// <reference types="react" />
2
1
  import { ClientTaxDocumentation } from '@taxbit/utilities';
3
2
  import type { InputStep, Locale, Progress, Questionnaire, TaxDocumentation } from 'types';
4
- import { ExternalValidations } from 'types/client';
5
3
  import type { StepId } from 'types/StepId';
4
+ import { ExternalValidations } from 'types/client';
6
5
  type InterviewConfig = {
7
6
  minimumAge: number;
8
7
  };
@@ -10,7 +9,7 @@ export type UseTaxDocumentationProps = {
10
9
  data?: ClientTaxDocumentation;
11
10
  language?: Locale;
12
11
  externalValidations?: ExternalValidations;
13
- onSubmit?: (data?: ClientTaxDocumentation) => void | Promise<void>;
12
+ onSubmit?: (data: ClientTaxDocumentation) => void | Promise<void>;
14
13
  onProgress?: (progress: Progress) => void | Promise<void>;
15
14
  step?: InputStep;
16
15
  questionnaire: Questionnaire;
@@ -20,8 +19,7 @@ export declare const useTaxDocumentation: ({ data: startingData, language: initi
20
19
  isBuildingW9: boolean;
21
20
  isBuildingW8: boolean;
22
21
  onPersistCollectedData: (newData: TaxDocumentation) => void;
23
- onSubmitTaxDocumentation: (data: TaxDocumentation) => void;
24
- error: string | undefined;
22
+ onSubmitTaxDocumentation: (data: TaxDocumentation) => Promise<void>;
25
23
  editTo: (form: InputStep) => void;
26
24
  onCancel: (() => void) | undefined;
27
25
  getStepId: (key: InputStep) => StepId;
@@ -29,12 +27,12 @@ export declare const useTaxDocumentation: ({ data: startingData, language: initi
29
27
  goBack: (() => void) | undefined;
30
28
  goToNext: (data: TaxDocumentation) => void;
31
29
  progress: Progress | undefined;
32
- stepName: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Confirmation" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary";
30
+ stepName: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary";
33
31
  data: TaxDocumentation;
34
32
  originalClientData: TaxDocumentation;
35
- initialStep: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Confirmation" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary";
36
- setLanguage: import("react").Dispatch<import("react").SetStateAction<"bg" | "cs" | "da" | "de" | "de-at" | "el" | "el-cy" | "en" | "en-gb" | "en-nz" | "en-us" | "es" | "et" | "fi" | "fr" | "fr-ca" | "fr-lu" | "ga" | "hr" | "hu" | "it" | "lt" | "lv" | "mt" | "nl" | "nl-be" | "no" | "pl" | "pt" | "ro" | "sk" | "sl" | "sv">>;
37
- language: "bg" | "cs" | "da" | "de" | "de-at" | "el" | "el-cy" | "en" | "en-gb" | "en-nz" | "en-us" | "es" | "et" | "fi" | "fr" | "fr-ca" | "fr-lu" | "ga" | "hr" | "hu" | "it" | "lt" | "lv" | "mt" | "nl" | "nl-be" | "no" | "pl" | "pt" | "ro" | "sk" | "sl" | "sv";
33
+ initialStep: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary";
34
+ setLanguage: (lang: Locale) => void;
35
+ language: Locale;
38
36
  questionnaire: Questionnaire;
39
37
  externalValidations: ExternalValidations | undefined;
40
38
  config: InterviewConfig | undefined;
@@ -3,21 +3,20 @@ export declare const useTaxDocumentationContext: () => {
3
3
  isBuildingW9: boolean;
4
4
  isBuildingW8: boolean;
5
5
  onPersistCollectedData: (newData: import("../../types").TaxDocumentation) => void;
6
- onSubmitTaxDocumentation: (data: import("../../types").TaxDocumentation) => void;
7
- error: string | undefined;
8
- editTo: (form: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Confirmation" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary") => void;
6
+ onSubmitTaxDocumentation: (data: import("../../types").TaxDocumentation) => Promise<void>;
7
+ editTo: (form: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary") => void;
9
8
  onCancel: (() => void) | undefined;
10
- getStepId: (key: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Confirmation" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary") => import("../../types/StepId").StepId;
11
- goTo: (form: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Confirmation" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary") => void;
9
+ getStepId: (key: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary") => import("../../types/StepId").StepId;
10
+ goTo: (form: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary") => void;
12
11
  goBack: (() => void) | undefined;
13
12
  goToNext: (data: import("../../types").TaxDocumentation) => void;
14
13
  progress: import("../../types").Progress | undefined;
15
- stepName: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Confirmation" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary";
14
+ stepName: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary";
16
15
  data: import("../../types").TaxDocumentation;
17
16
  originalClientData: import("../../types").TaxDocumentation;
18
- initialStep: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Confirmation" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary";
19
- setLanguage: import("react").Dispatch<import("react").SetStateAction<"bg" | "cs" | "da" | "de" | "de-at" | "el" | "el-cy" | "en" | "en-gb" | "en-nz" | "en-us" | "es" | "et" | "fi" | "fr" | "fr-ca" | "fr-lu" | "ga" | "hr" | "hu" | "it" | "lt" | "lv" | "mt" | "nl" | "nl-be" | "no" | "pl" | "pt" | "ro" | "sk" | "sl" | "sv">>;
20
- language: "bg" | "cs" | "da" | "de" | "de-at" | "el" | "el-cy" | "en" | "en-gb" | "en-nz" | "en-us" | "es" | "et" | "fi" | "fr" | "fr-ca" | "fr-lu" | "ga" | "hr" | "hu" | "it" | "lt" | "lv" | "mt" | "nl" | "nl-be" | "no" | "pl" | "pt" | "ro" | "sk" | "sl" | "sv";
17
+ initialStep: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary";
18
+ setLanguage: (lang: import("../../types").Locale) => void;
19
+ language: import("../../types").Locale;
21
20
  questionnaire: import("../../types").Questionnaire;
22
21
  externalValidations: import("../../types/client").ExternalValidations | undefined;
23
22
  config: {
@@ -28,21 +27,20 @@ export declare const useTaxDocumentationContext: () => {
28
27
  isBuildingW9: boolean;
29
28
  isBuildingW8: boolean;
30
29
  onPersistCollectedData: (newData: import("../../types").TaxDocumentation) => void;
31
- onSubmitTaxDocumentation: (data: import("../../types").TaxDocumentation) => void;
32
- error: string | undefined;
33
- editTo: (form: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Confirmation" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary") => void;
30
+ onSubmitTaxDocumentation: (data: import("../../types").TaxDocumentation) => Promise<void>;
31
+ editTo: (form: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary") => void;
34
32
  onCancel: (() => void) | undefined;
35
- getStepId: (key: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Confirmation" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary") => import("../../types/StepId").StepId;
36
- goTo: (form: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Confirmation" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary") => void;
33
+ getStepId: (key: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary") => import("../../types/StepId").StepId;
34
+ goTo: (form: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary") => void;
37
35
  goBack: (() => void) | undefined;
38
36
  goToNext: (data: import("../../types").TaxDocumentation) => void;
39
37
  progress: import("../../types").Progress | undefined;
40
- stepName: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Confirmation" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary";
38
+ stepName: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary";
41
39
  data: import("../../types").TaxDocumentation;
42
40
  originalClientData: import("../../types").TaxDocumentation;
43
- initialStep: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Confirmation" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary";
44
- setLanguage: import("react").Dispatch<import("react").SetStateAction<"bg" | "cs" | "da" | "de" | "de-at" | "el" | "el-cy" | "en" | "en-gb" | "en-nz" | "en-us" | "es" | "et" | "fi" | "fr" | "fr-ca" | "fr-lu" | "ga" | "hr" | "hu" | "it" | "lt" | "lv" | "mt" | "nl" | "nl-be" | "no" | "pl" | "pt" | "ro" | "sk" | "sl" | "sv">>;
45
- language: "bg" | "cs" | "da" | "de" | "de-at" | "el" | "el-cy" | "en" | "en-gb" | "en-nz" | "en-us" | "es" | "et" | "fi" | "fr" | "fr-ca" | "fr-lu" | "ga" | "hr" | "hu" | "it" | "lt" | "lv" | "mt" | "nl" | "nl-be" | "no" | "pl" | "pt" | "ro" | "sk" | "sl" | "sv";
41
+ initialStep: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary";
42
+ setLanguage: (lang: import("../../types").Locale) => void;
43
+ language: import("../../types").Locale;
46
44
  questionnaire: import("../../types").Questionnaire;
47
45
  externalValidations: import("../../types/client").ExternalValidations | undefined;
48
46
  config: {
@@ -11,16 +11,18 @@ export type TaxbitQuestionnaireProps = {
11
11
  } & ({
12
12
  demoMode: true;
13
13
  bearerToken?: never;
14
- onSuccess?: never;
15
- onSettled?: never;
16
14
  onError?: never;
15
+ loadingComponent?: never;
16
+ onSettled?: never;
17
+ onSuccess?: never;
17
18
  staging?: never;
18
19
  } | {
19
20
  demoMode?: false | undefined;
20
21
  bearerToken: TaxbitQuestionnairePersistProps['bearerToken'];
21
- onSuccess?: TaxbitQuestionnairePersistProps['onSuccess'];
22
- onSettled?: TaxbitQuestionnairePersistProps['onSettled'];
23
22
  onError?: TaxbitQuestionnairePersistProps['onError'];
23
+ loadingComponent?: TaxbitQuestionnairePersistProps['loadingComponent'];
24
+ onSettled?: TaxbitQuestionnairePersistProps['onSettled'];
25
+ onSuccess?: TaxbitQuestionnairePersistProps['onSuccess'];
24
26
  staging?: TaxbitQuestionnairePersistProps['staging'];
25
27
  });
26
- export declare const TaxbitQuestionnaire: ({ questionnaire, data, onSubmit, onSuccess, onSettled, onError, language, onProgress, bearerToken, demoMode, staging, }: TaxbitQuestionnaireProps) => React.JSX.Element;
28
+ export declare const TaxbitQuestionnaire: ({ bearerToken, data, demoMode, language, onError, loadingComponent, onProgress, onSettled, onSubmit, onSuccess, questionnaire, staging, }: TaxbitQuestionnaireProps) => React.JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { ClientTaxDocumentation } from '@taxbit/utilities';
2
- export * from '../hooks/useTaxbit';
2
+ export * from '../hooks/useTaxbit/useTaxbit';
3
3
  export * from '../types/Locale';
4
4
  export * from '../types/Progress';
5
5
  export * from '../types/Questionnaire';
@@ -1 +1,2 @@
1
+ export * from './useHandleError';
1
2
  export * from './useTaxbit';
@@ -0,0 +1,3 @@
1
+ export declare const useHandleError: (onError?: ((error: Error) => void | Promise<void>) | undefined) => {
2
+ handleError: (error: Error) => void;
3
+ };
@@ -1 +1,2 @@
1
1
  export * from './useTaxbit';
2
+ export * from './useTaxbitStatus';
@@ -1,9 +1,16 @@
1
1
  import { Questionnaire } from 'types';
2
- export declare const useTaxbit: (bearerToken: string, questionnaire: Questionnaire, staging?: boolean) => {
2
+ type UseTaxbitProps = {
3
+ bearerToken: string;
4
+ questionnaire: Questionnaire;
5
+ staging?: boolean;
6
+ onError?: (error: Error) => void | Promise<void>;
7
+ };
8
+ export declare const useTaxbit: ({ bearerToken, questionnaire, staging, onError, }: UseTaxbitProps) => {
3
9
  serverData: import("@taxbit/utilities").SignedClientTaxDocumentation | undefined;
4
10
  statusData: import("../../entry").ClientTaxDocumentationStatus | undefined;
5
11
  canGetDocumentUrl: boolean;
6
- getNewDocumentUrl: () => void;
7
- isGettingDocumentUrl: boolean;
12
+ generateDocumentUrl: () => void;
13
+ isGeneratingDocumentUrl: boolean;
8
14
  documentUrl: string | undefined;
9
15
  };
16
+ export {};
@@ -1,8 +1,15 @@
1
1
  import type { SignedClientTaxDocumentation } from '@taxbit/utilities';
2
2
  import { Questionnaire } from '../../types';
3
3
  import type { ClientTaxDocumentationStatus } from '../../types/client';
4
- export declare const useTaxbitStatus: (bearerToken: string, questionnaire: Questionnaire, staging?: boolean) => {
5
- formStatus: "COMPLETE" | "INCOMPLETE" | undefined;
4
+ type UseTaxbitStatusProps = {
5
+ bearerToken?: string;
6
+ onError?: (error: Error) => void | Promise<void>;
7
+ questionnaire: Questionnaire;
8
+ staging?: boolean;
9
+ };
10
+ export declare const useTaxbitStatus: ({ bearerToken, questionnaire, staging, onError, }: UseTaxbitStatusProps) => {
6
11
  serverData: SignedClientTaxDocumentation | undefined;
7
12
  statusData: ClientTaxDocumentationStatus | undefined;
13
+ isLoading: boolean;
8
14
  };
15
+ export {};
@@ -1,5 +1,5 @@
1
- declare const inputSteps: readonly ["AccountHolderClassification", "AccountHolderContact", "AccountHolderTax", "AccountHolderTaxClarification", "Confirmation", "Exemptions", "RegardedOwnerContact", "RegardedOwnerTax", "Summary"];
1
+ declare const inputSteps: readonly ["AccountHolderClassification", "AccountHolderContact", "AccountHolderTax", "AccountHolderTaxClarification", "Exemptions", "RegardedOwnerContact", "RegardedOwnerTax", "Summary"];
2
2
  export type InputStep = (typeof inputSteps)[number];
3
- export declare const isInputStep: (step: string) => step is "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Confirmation" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary";
3
+ export declare const isInputStep: (step: string) => step is "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary";
4
4
  export declare const confirmInputStep: (step: string) => InputStep;
5
5
  export {};
@@ -0,0 +1 @@
1
+ export declare const bearerTokenIsRequiredError: Error;
@@ -0,0 +1,2 @@
1
+ import { ClientTaxDocumentationStatus } from '../types/client';
2
+ export declare const getFormStatus: (statusData: ClientTaxDocumentationStatus | undefined, questionnaire: string) => "COMPLETE" | "INCOMPLETE" | undefined;
@@ -0,0 +1,3 @@
1
+ export declare const getHeaders: ({ bearerToken }: {
2
+ bearerToken: string;
3
+ }) => Headers;
@@ -0,0 +1,2 @@
1
+ import { Locale, Questionnaire } from '../types';
2
+ export declare const getLanguage: (language: string | undefined, questionnaire: Questionnaire) => Locale;
@@ -0,0 +1,7 @@
1
+ type HandleFetchProps<T> = {
2
+ fetcher: Promise<Response>;
3
+ onSuccess?: (data: T) => void;
4
+ onError: (error: Error) => void;
5
+ };
6
+ export declare const handleFetch: <T>({ fetcher, onSuccess, onError, }: HandleFetchProps<T>) => Promise<void>;
7
+ export {};
@@ -1,10 +1,15 @@
1
+ export * from './bearerTokenIsRequiredError';
1
2
  export * from './camelCaseKeys';
2
3
  export * from './cx';
3
4
  export * from './formatUsTin';
4
5
  export * from './getFieldsState';
6
+ export * from './getFormStatus';
7
+ export * from './getHeaders';
8
+ export * from './getLanguage';
5
9
  export * from './getMaskedContent';
6
10
  export * from './getMonthlyDayCount';
7
11
  export * from './getPromptKeyMap';
12
+ export * from './handleFetch';
8
13
  export * from './isBlank';
9
14
  export * from './kebabCase';
10
15
  export * from './mergeClientTaxDocumentationData';
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { UseTaxDocumentationProps } from '../../contexts';
3
3
  import { UseTaxbitPersistProps } from './useTaxbitPersist';
4
- export type TaxbitQuestionnairePersistProps = UseTaxDocumentationProps & UseTaxbitPersistProps;
5
- export declare const TaxbitQuestionnairePersist: ({ staging, data, bearerToken, language, questionnaire, onProgress, onSubmit, onSettled, onSuccess, onError, }: TaxbitQuestionnairePersistProps) => React.JSX.Element;
4
+ export type TaxbitQuestionnairePersistProps = UseTaxDocumentationProps & UseTaxbitPersistProps & {
5
+ loadingComponent?: React.ReactNode;
6
+ };
7
+ export declare const TaxbitQuestionnairePersist: ({ staging, data, bearerToken, language, questionnaire, loadingComponent, onProgress, onSubmit, onSettled, onSuccess, onError, }: TaxbitQuestionnairePersistProps) => string | number | true | Iterable<React.ReactNode> | React.JSX.Element;
@@ -1,22 +1,18 @@
1
- import { ClientTaxDocumentation } from '@taxbit/utilities';
1
+ import { ClientTaxDocumentation, SignedClientTaxDocumentation } from '@taxbit/utilities';
2
2
  import { Questionnaire } from 'types';
3
3
  import { ExternalValidations } from 'types/client';
4
- export type TaxbitResponseError = {
5
- message: string;
6
- response: Response;
7
- };
8
4
  export type UseTaxbitPersistProps = {
9
5
  data?: ClientTaxDocumentation;
10
6
  staging?: boolean;
11
7
  bearerToken: string;
12
- questionnaire?: Questionnaire;
13
- onSuccess?: (data?: ClientTaxDocumentation) => void | Promise<void>;
14
- onSettled?: (data?: ClientTaxDocumentation) => void | Promise<void>;
15
- onError?: (error?: TaxbitResponseError) => void | Promise<void>;
16
- onSubmit?: (data?: ClientTaxDocumentation) => void | Promise<void>;
8
+ questionnaire: Questionnaire;
9
+ onSuccess?: (data: ClientTaxDocumentation) => void | Promise<void>;
10
+ onSettled?: (data: ClientTaxDocumentation) => void | Promise<void>;
11
+ onError?: (error: Error) => void | Promise<void>;
12
+ onSubmit?: (data: ClientTaxDocumentation) => void | Promise<void>;
17
13
  };
18
14
  export declare const useTaxbitPersist: ({ bearerToken, data, onSubmit, onSuccess, onSettled, onError, staging, questionnaire, }: UseTaxbitPersistProps) => {
19
- handleOnSubmit: (data?: ClientTaxDocumentation) => Promise<void>;
15
+ handleOnSubmit: (data: SignedClientTaxDocumentation) => Promise<void>;
20
16
  externalValidations: ExternalValidations;
21
17
  formData: ClientTaxDocumentation;
22
18
  isComplete: boolean;
@@ -2,7 +2,6 @@ export * from './AccountHolderClassification';
2
2
  export * from './AccountHolderContact';
3
3
  export * from './AccountHolderTax';
4
4
  export * from './AccountHolderTaxClarification';
5
- export * from './Confirmation';
6
5
  export * from './Exemptions';
7
6
  export * from './RegardedOwnerContact';
8
7
  export * from './RegardedOwnerTax';