@taxbit/react-sdk 1.0.0-beta.5 → 1.0.0-beta.7

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.
package/README.md CHANGED
@@ -125,6 +125,7 @@ The `useTaxbit` hook can be used to get the data from the server or the account
125
125
  const {
126
126
  statusData,
127
127
  serverData,
128
+ error,
128
129
  canGetDocumentUrl,
129
130
  generateDocumentUrl,
130
131
  isGeneratingDocumentUrl,
@@ -200,11 +201,27 @@ or for W-Form status
200
201
  }
201
202
  ```
202
203
 
204
+ #### useTaxbit hook `error` object
205
+
206
+ The useTaxbit hook also contains an `error` object which can be `undefined`, or an `Error`. If there is an error fetching or with the bearer token, the error property will be populated, and also logged to the console. If an `onError` callback is provided to the hook, the error will _not_ be logged to the console.
207
+
203
208
  ### CSS and Style Customization
204
209
 
205
210
  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
211
  Classnames are namespaced with "taxbit-" to reduce the chance of conflict.
207
212
 
213
+ #### Loading Component
214
+
215
+ 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.
216
+
217
+ ```jsx
218
+ <TaxbitQuestionnaire
219
+ bearerToken="bearer token goes here"
220
+ questionnaire="W-FORM"
221
+ loadingComponent={<div>Loading...</div>}
222
+ />
223
+ ```
224
+
208
225
  ### Callbacks
209
226
 
210
227
  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.
@@ -294,6 +311,16 @@ type QuestionnaireType = 'DPS' | 'W-FORM';
294
311
 
295
312
  ## Changelog
296
313
 
314
+ ### Version 1.0.0-beta.7
315
+
316
+ 1. BearerToken and Fetch errors are now sent only to the console, no longer thrown and bubbled up.
317
+ 2. 2Added an `error` object to the 'useTaxbit' hook.
318
+
319
+ ### Version 1.0.0-beta.6
320
+
321
+ 1. Bugs fixed related to the country drop-downs.
322
+ 2. Added a `loadingComponent` prop to the TaxbitQuestionnaire component.
323
+
297
324
  ### Version 1.0.0-beta.5
298
325
 
299
326
  1. Document Generation modifications. Renamed from "getDocumentUrl" to "generateDocumentUrl".
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare const ErrorAlert: ({ message }: {
3
+ message?: string | undefined;
4
+ }) => React.JSX.Element;
@@ -0,0 +1 @@
1
+ export * from './ErrorAlert';
@@ -1,4 +1,5 @@
1
1
  export * from './Address';
2
+ export * from './ErrorAlert';
2
3
  export * from './ErrorBoundary';
3
4
  export * from './ErrorMessage';
4
5
  export * from './Form';
@@ -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,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ClientTaxDocumentation } from '@taxbit/utilities';
3
2
  import type { InputStep, Locale, Progress, Questionnaire, TaxDocumentation } from 'types';
4
3
  import type { StepId } from 'types/StepId';
@@ -32,8 +31,8 @@ export declare const useTaxDocumentation: ({ data: startingData, language: initi
32
31
  data: TaxDocumentation;
33
32
  originalClientData: TaxDocumentation;
34
33
  initialStep: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary";
35
- 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">>;
36
- 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";
34
+ setLanguage: (lang: Locale) => void;
35
+ language: Locale;
37
36
  questionnaire: Questionnaire;
38
37
  externalValidations: ExternalValidations | undefined;
39
38
  config: InterviewConfig | undefined;
@@ -15,8 +15,8 @@ export declare const useTaxDocumentationContext: () => {
15
15
  data: import("../../types").TaxDocumentation;
16
16
  originalClientData: import("../../types").TaxDocumentation;
17
17
  initialStep: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary";
18
- 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">>;
19
- 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";
18
+ setLanguage: (lang: import("../../types").Locale) => void;
19
+ language: import("../../types").Locale;
20
20
  questionnaire: import("../../types").Questionnaire;
21
21
  externalValidations: import("../../types/client").ExternalValidations | undefined;
22
22
  config: {
@@ -39,8 +39,8 @@ export declare const useTaxDocumentationContext: () => {
39
39
  data: import("../../types").TaxDocumentation;
40
40
  originalClientData: import("../../types").TaxDocumentation;
41
41
  initialStep: "AccountHolderClassification" | "AccountHolderContact" | "AccountHolderTax" | "AccountHolderTaxClarification" | "Exemptions" | "RegardedOwnerContact" | "RegardedOwnerTax" | "Summary";
42
- 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">>;
43
- 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
+ setLanguage: (lang: import("../../types").Locale) => void;
43
+ language: import("../../types").Locale;
44
44
  questionnaire: import("../../types").Questionnaire;
45
45
  externalValidations: import("../../types/client").ExternalValidations | undefined;
46
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,3 +1,4 @@
1
- export declare const useHandleError: (onError?: ((error: Error) => void | Promise<void>) | undefined) => {
1
+ import { Dispatch, SetStateAction } from 'react';
2
+ export declare const useHandleError: (onError: ((error: Error) => void | Promise<void>) | undefined, setError?: Dispatch<SetStateAction<Error | undefined>>) => {
2
3
  handleError: (error: Error) => void;
3
4
  };
@@ -12,5 +12,6 @@ export declare const useTaxbit: ({ bearerToken, questionnaire, staging, onError,
12
12
  generateDocumentUrl: () => void;
13
13
  isGeneratingDocumentUrl: boolean;
14
14
  documentUrl: string | undefined;
15
+ error: Error | undefined;
15
16
  };
16
17
  export {};
@@ -11,5 +11,6 @@ export declare const useTaxbitStatus: ({ bearerToken, questionnaire, staging, on
11
11
  serverData: SignedClientTaxDocumentation | undefined;
12
12
  statusData: ClientTaxDocumentationStatus | undefined;
13
13
  isLoading: boolean;
14
+ error: Error | undefined;
14
15
  };
15
16
  export {};
@@ -0,0 +1,2 @@
1
+ import { Locale, Questionnaire } from '../types';
2
+ export declare const getLanguage: (language: string | undefined, questionnaire: Questionnaire) => Locale;
@@ -5,6 +5,7 @@ export * from './formatUsTin';
5
5
  export * from './getFieldsState';
6
6
  export * from './getFormStatus';
7
7
  export * from './getHeaders';
8
+ export * from './getLanguage';
8
9
  export * from './getMaskedContent';
9
10
  export * from './getMonthlyDayCount';
10
11
  export * from './getPromptKeyMap';
@@ -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;
@@ -11,10 +11,11 @@ export type UseTaxbitPersistProps = {
11
11
  onError?: (error: Error) => void | Promise<void>;
12
12
  onSubmit?: (data: ClientTaxDocumentation) => void | Promise<void>;
13
13
  };
14
- export declare const useTaxbitPersist: ({ bearerToken, data, onSubmit, onSuccess, onSettled, onError, staging, questionnaire, }: UseTaxbitPersistProps) => {
14
+ export declare const useTaxbitPersist: ({ bearerToken, data, onError, onSettled, onSubmit, onSuccess, questionnaire, staging, }: UseTaxbitPersistProps) => {
15
15
  handleOnSubmit: (data: SignedClientTaxDocumentation) => Promise<void>;
16
16
  externalValidations: ExternalValidations;
17
17
  formData: ClientTaxDocumentation;
18
18
  isComplete: boolean;
19
19
  isLoading: boolean;
20
+ error: Error | undefined;
20
21
  };