@gusto/embedded-react-sdk 0.10.5 → 0.10.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.
- package/CHANGELOG.md +7 -0
- package/dist/components/Base/Base.js +18 -19
- package/dist/components/Base/Base.js.map +1 -1
- package/dist/components/Common/OnboardingStatusBadge/index.d.ts +1 -1
- package/dist/components/Common/OnboardingStatusBadge/index.js.map +1 -1
- package/dist/components/Common/SignatureForm/SignatureForm.js +4 -6
- package/dist/components/Common/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Common/SignatureForm/SignatureFormActions.js +6 -7
- package/dist/components/Common/SignatureForm/SignatureFormActions.js.map +1 -1
- package/dist/components/Common/SignatureForm/SignatureFormFields.js +7 -8
- package/dist/components/Common/SignatureForm/SignatureFormFields.js.map +1 -1
- package/dist/components/Common/TaxInputs/TaxInputs.d.ts +1 -0
- package/dist/components/Common/TaxInputs/TaxInputs.js +100 -80
- package/dist/components/Common/TaxInputs/TaxInputs.js.map +1 -1
- package/dist/components/Company/AssignSignatory/AssignSignatory.js +11 -13
- package/dist/components/Company/AssignSignatory/AssignSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/AssignSignatorySelection.js +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/Actions.js +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatory.js +0 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.js +2 -3
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/Actions.js +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatory.js +3 -4
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.js +9 -10
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +1 -1
- package/dist/components/Company/AssignSignatory/TitleSelect.js +7 -8
- package/dist/components/Company/AssignSignatory/TitleSelect.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/Actions.js +8 -9
- package/dist/components/Company/BankAccount/BankAccountForm/Actions.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/Form.js +7 -8
- package/dist/components/Company/BankAccount/BankAccountForm/Form.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +1 -1
- package/dist/components/Company/BankAccount/BankAccountList/Actions.js +1 -1
- package/dist/components/Company/BankAccount/BankAccountVerify/Actions.js +1 -1
- package/dist/components/Company/BankAccount/BankAccountVerify/Form.js +4 -5
- package/dist/components/Company/BankAccount/BankAccountVerify/Form.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/Actions.js +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/DocumentList.js +15 -17
- package/dist/components/Company/DocumentSigner/DocumentList/DocumentList.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +1 -1
- package/dist/components/Company/DocumentSigner/DocumentSigner.js +24 -22
- package/dist/components/Company/DocumentSigner/DocumentSigner.js.map +1 -1
- package/dist/components/Company/DocumentSigner/SignatureForm/SignatureForm.js +7 -9
- package/dist/components/Company/DocumentSigner/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js +1 -1
- package/dist/components/Company/FederalTaxes/Actions.js +1 -1
- package/dist/components/Company/FederalTaxes/FederalTaxes.js +15 -17
- package/dist/components/Company/FederalTaxes/FederalTaxes.js.map +1 -1
- package/dist/components/Company/FederalTaxes/Form.js +2 -3
- package/dist/components/Company/FederalTaxes/Form.js.map +1 -1
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +1 -1
- package/dist/components/Company/Industry/Actions.js +1 -1
- package/dist/components/Company/Industry/Context.js +1 -1
- package/dist/components/Company/Industry/Edit.js +1 -1
- package/dist/components/Company/Locations/LocationForm/Actions.js +1 -1
- package/dist/components/Company/Locations/LocationForm/Form.js +4 -5
- package/dist/components/Company/Locations/LocationForm/Form.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/LocationForm.js +7 -9
- package/dist/components/Company/Locations/LocationForm/LocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +1 -1
- package/dist/components/Company/Locations/LocationsList/Actions.js +1 -1
- package/dist/components/Company/Locations/LocationsList/List.js +1 -1
- package/dist/components/Company/Locations/LocationsList/LocationsList.js +9 -11
- package/dist/components/Company/Locations/LocationsList/LocationsList.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js +1 -1
- package/dist/components/Company/OnboardingOverview/Completed.js +5 -6
- package/dist/components/Company/OnboardingOverview/Completed.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/MissingRequirements.js +2 -3
- package/dist/components/Company/OnboardingOverview/MissingRequirements.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/OnboardingOverview.js +2 -4
- package/dist/components/Company/OnboardingOverview/OnboardingOverview.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +1 -1
- package/dist/components/Company/PaySchedule/PaySchedule.js +16 -18
- package/dist/components/Company/PaySchedule/PaySchedule.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/Actions.js +1 -1
- package/dist/components/Company/PaySchedule/_parts/Edit.js +25 -26
- package/dist/components/Company/PaySchedule/_parts/Edit.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/Head.js +2 -3
- package/dist/components/Company/PaySchedule/_parts/Head.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/List.js +5 -6
- package/dist/components/Company/PaySchedule/_parts/List.js.map +1 -1
- package/dist/components/Company/PaySchedule/usePaySchedule.js +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/Actions.js +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js +14 -14
- package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/Actions.js +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/List.js +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +1 -1
- package/dist/components/Contractor/Address/Address.js +0 -2
- package/dist/components/Contractor/Address/Address.js.map +1 -1
- package/dist/components/Contractor/Address/Form.js +6 -7
- package/dist/components/Contractor/Address/Form.js.map +1 -1
- package/dist/components/Contractor/Address/useAddress.js +1 -1
- package/dist/components/Contractor/List/index.js +2 -3
- package/dist/components/Contractor/List/index.js.map +1 -1
- package/dist/components/Contractor/NewHireReport/NewHireReport.js +16 -17
- package/dist/components/Contractor/NewHireReport/NewHireReport.js.map +1 -1
- package/dist/components/Contractor/PaymentMethod/BankAccountForm.js +1 -1
- package/dist/components/Contractor/PaymentMethod/PaymentMethod.js +2 -3
- package/dist/components/Contractor/PaymentMethod/PaymentMethod.js.map +1 -1
- package/dist/components/Contractor/PaymentMethod/PaymentTypeForm.js +2 -3
- package/dist/components/Contractor/PaymentMethod/PaymentTypeForm.js.map +1 -1
- package/dist/components/Employee/Compensation/Actions.js +5 -6
- package/dist/components/Employee/Compensation/Actions.js.map +1 -1
- package/dist/components/Employee/Compensation/Edit.js +2 -3
- package/dist/components/Employee/Compensation/Edit.js.map +1 -1
- package/dist/components/Employee/Compensation/List.js +1 -1
- package/dist/components/Employee/Deductions/Actions.js +1 -1
- package/dist/components/Employee/Deductions/DeductionForm.js +1 -1
- package/dist/components/Employee/Deductions/DeductionsList.js +1 -1
- package/dist/components/Employee/Deductions/IncludeDeductionsForm.js +1 -1
- package/dist/components/Employee/Deductions/useDeductions.js +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/Actions.js +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/DocumentList.js +10 -12
- package/dist/components/Employee/DocumentSigner/DocumentList/DocumentList.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/List.js +2 -3
- package/dist/components/Employee/DocumentSigner/DocumentList/List.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/SignatureForm.js +8 -10
- package/dist/components/Employee/DocumentSigner/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js +1 -1
- package/dist/components/Employee/EmployeeList/Actions.js +1 -1
- package/dist/components/Employee/EmployeeList/EmployeeList.js +9 -11
- package/dist/components/Employee/EmployeeList/EmployeeList.js.map +1 -1
- package/dist/components/Employee/EmployeeList/Head.js +2 -3
- package/dist/components/Employee/EmployeeList/Head.js.map +1 -1
- package/dist/components/Employee/EmployeeList/List.js +14 -15
- package/dist/components/Employee/EmployeeList/List.js.map +1 -1
- package/dist/components/Employee/EmployeeList/useEmployeeList.js +1 -1
- package/dist/components/Employee/Landing/Landing.js +6 -7
- package/dist/components/Employee/Landing/Landing.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/Actions.js +1 -1
- package/dist/components/Employee/PaymentMethod/BankAccountEdit.js +2 -3
- package/dist/components/Employee/PaymentMethod/BankAccountEdit.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/BankAccountsList.js +1 -1
- package/dist/components/Employee/PaymentMethod/PaymentTypeForm.js +2 -3
- package/dist/components/Employee/PaymentMethod/PaymentTypeForm.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/Split.js +3 -4
- package/dist/components/Employee/PaymentMethod/Split.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +1 -1
- package/dist/components/Employee/Profile/Actions.js +1 -1
- package/dist/components/Employee/Profile/AdminPersonalDetails.js +9 -10
- package/dist/components/Employee/Profile/AdminPersonalDetails.js.map +1 -1
- package/dist/components/Employee/Profile/HomeAddress.js +4 -5
- package/dist/components/Employee/Profile/HomeAddress.js.map +1 -1
- package/dist/components/Employee/Profile/PersonalDetailsInputs.js +1 -1
- package/dist/components/Employee/Profile/useProfile.js +1 -1
- package/dist/components/Employee/Taxes/Actions.js +1 -1
- package/dist/components/Employee/Taxes/FederalForm.js +1 -1
- package/dist/components/Employee/Taxes/useTaxes.js +1 -1
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +1 -1
- package/dist/shared/constants.js +1 -1
- package/dist/shared/constants.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -10,40 +10,39 @@ import { FadeIn as _ } from "../Common/FadeIn/FadeIn.js";
|
|
|
10
10
|
import { BaseContext as j } from "./useBase.js";
|
|
11
11
|
import { componentEvents as F } from "../../shared/constants.js";
|
|
12
12
|
import { useAsyncError as K } from "../Common/hooks/useAsyncError.js";
|
|
13
|
-
import "classnames";
|
|
14
13
|
import { InternalError as P } from "../Common/InternalError/InternalError.js";
|
|
15
14
|
import { snakeCaseToCamelCase as w } from "../../helpers/formattedStrings.js";
|
|
16
15
|
import { useComponentContext as M } from "../../contexts/ComponentAdapter/useComponentContext.js";
|
|
17
16
|
import { useLoadingIndicator as O } from "../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
18
|
-
const U = (
|
|
17
|
+
const U = (e) => e.map((n) => n.message ? /* @__PURE__ */ o("li", { children: n.message }, n.key) : null), k = (e, n) => {
|
|
19
18
|
const m = n ? n + "." : "";
|
|
20
|
-
if (
|
|
19
|
+
if (e.category === "invalid_attribute_value" || e.category === "invalid_operation")
|
|
21
20
|
return [
|
|
22
21
|
{
|
|
23
|
-
key: w(m +
|
|
24
|
-
message:
|
|
22
|
+
key: w(m + e.errorKey),
|
|
23
|
+
message: e.message ?? ""
|
|
25
24
|
}
|
|
26
25
|
];
|
|
27
|
-
if (
|
|
26
|
+
if (e.category === "nested_errors" && e.errors !== void 0) {
|
|
28
27
|
let s = "";
|
|
29
|
-
return
|
|
28
|
+
return e.metadata?.key && typeof e.metadata.key == "string" ? s = e.metadata.key : e.metadata?.state && typeof e.metadata.state == "string" ? s = e.metadata.state : e.errorKey && (s = e.errorKey), e.errors.flatMap((r) => k(r, m + s));
|
|
30
29
|
}
|
|
31
30
|
return [];
|
|
32
|
-
},
|
|
33
|
-
children:
|
|
31
|
+
}, re = ({
|
|
32
|
+
children: e,
|
|
34
33
|
FallbackComponent: n = P,
|
|
35
34
|
LoaderComponent: m,
|
|
36
35
|
onEvent: s
|
|
37
36
|
}) => {
|
|
38
|
-
const [r, l] = y(null), [c, f] = y(null), p = K(), { t: x } = B(), d = M(), { LoadingIndicator: b } = O(), v = m ?? b, I = E((
|
|
39
|
-
l(
|
|
40
|
-
}, []), A = (
|
|
41
|
-
l(
|
|
37
|
+
const [r, l] = y(null), [c, f] = y(null), p = K(), { t: x } = B(), d = M(), { LoadingIndicator: b } = O(), v = m ?? b, I = E((t) => {
|
|
38
|
+
l(t), t || f(null);
|
|
39
|
+
}, []), A = (t) => {
|
|
40
|
+
l(t), t instanceof h && Array.isArray(t.errors) && f(t.errors.flatMap((a) => k(a)));
|
|
42
41
|
}, L = E(
|
|
43
|
-
async (
|
|
42
|
+
async (t, a) => {
|
|
44
43
|
l(null), f(null);
|
|
45
44
|
try {
|
|
46
|
-
await a(
|
|
45
|
+
await a(t);
|
|
47
46
|
} catch (i) {
|
|
48
47
|
i instanceof g || i instanceof C || i instanceof h ? A(i) : p(i);
|
|
49
48
|
}
|
|
@@ -60,11 +59,11 @@ const U = (t) => t.map((n) => n.message ? /* @__PURE__ */ o("li", { children: n.
|
|
|
60
59
|
throwError: p,
|
|
61
60
|
baseSubmitHandler: L
|
|
62
61
|
},
|
|
63
|
-
children: /* @__PURE__ */ o(T, { children: ({ reset:
|
|
62
|
+
children: /* @__PURE__ */ o(T, { children: ({ reset: t }) => /* @__PURE__ */ u(
|
|
64
63
|
S,
|
|
65
64
|
{
|
|
66
65
|
FallbackComponent: n,
|
|
67
|
-
onReset:
|
|
66
|
+
onReset: t,
|
|
68
67
|
onError: (a) => {
|
|
69
68
|
s(F.ERROR, a);
|
|
70
69
|
},
|
|
@@ -74,7 +73,7 @@ const U = (t) => t.map((n) => n.message ? /* @__PURE__ */ o("li", { children: n.
|
|
|
74
73
|
r && r instanceof g && /* @__PURE__ */ o(d.Text, { children: r.message }),
|
|
75
74
|
r && r instanceof C && /* @__PURE__ */ o(d.Text, { as: "pre", children: r.pretty() })
|
|
76
75
|
] }),
|
|
77
|
-
/* @__PURE__ */ o(R, { fallback: /* @__PURE__ */ o(v, {}), children: /* @__PURE__ */ o(_, { children:
|
|
76
|
+
/* @__PURE__ */ o(R, { fallback: /* @__PURE__ */ o(v, {}), children: /* @__PURE__ */ o(_, { children: e }) })
|
|
78
77
|
]
|
|
79
78
|
}
|
|
80
79
|
) })
|
|
@@ -82,6 +81,6 @@ const U = (t) => t.map((n) => n.message ? /* @__PURE__ */ o("li", { children: n.
|
|
|
82
81
|
);
|
|
83
82
|
};
|
|
84
83
|
export {
|
|
85
|
-
|
|
84
|
+
re as BaseComponent
|
|
86
85
|
};
|
|
87
86
|
//# sourceMappingURL=Base.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Base.js","sources":["../../../src/components/Base/Base.tsx"],"sourcesContent":["import type { ReactNode, JSX } from 'react'\nimport { Suspense, useState, useCallback } from 'react'\nimport type { FallbackProps } from 'react-error-boundary'\nimport { ErrorBoundary } from 'react-error-boundary'\nimport { useTranslation } from 'react-i18next'\nimport { APIError } from '@gusto/embedded-api/models/errors/apierror'\nimport { SDKValidationError } from '@gusto/embedded-api/models/errors/sdkvalidationerror'\nimport { UnprocessableEntityErrorObject } from '@gusto/embedded-api/models/errors/unprocessableentityerrorobject'\nimport type { EntityErrorObject } from '@gusto/embedded-api/models/components/entityerrorobject'\nimport { QueryErrorResetBoundary } from '@tanstack/react-query'\nimport { FadeIn } from '../Common/FadeIn/FadeIn'\nimport { BaseContext, type FieldError, type KnownErrors, type OnEventType } from './useBase'\nimport { componentEvents, type EventType } from '@/shared/constants'\nimport { InternalError, useAsyncError } from '@/components/Common'\nimport { snakeCaseToCamelCase } from '@/helpers/formattedStrings'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport type { ResourceDictionary, Resources } from '@/types/Helpers'\nimport { useLoadingIndicator } from '@/contexts/LoadingIndicatorProvider/useLoadingIndicator'\nimport type { LoadingIndicatorContextProps } from '@/contexts/LoadingIndicatorProvider/useLoadingIndicator'\n\nexport interface CommonComponentInterface<TResourceKey extends keyof Resources = keyof Resources> {\n children?: ReactNode\n className?: string\n defaultValues?: unknown\n dictionary?: ResourceDictionary<TResourceKey>\n}\n\n// Base component wrapper with error and suspense handling\nexport interface BaseComponentInterface<TResourceKey extends keyof Resources = keyof Resources>\n extends CommonComponentInterface<TResourceKey> {\n FallbackComponent?: (props: FallbackProps) => JSX.Element\n LoaderComponent?: LoadingIndicatorContextProps['LoadingIndicator']\n onEvent: OnEventType<EventType, unknown>\n}\n\n/**Traverses errorList and finds items with message properties */\nconst renderErrorList = (errorList: FieldError[]): React.ReactNode[] => {\n return errorList.map(errorFromList => {\n if (errorFromList.message) {\n return <li key={errorFromList.key}>{errorFromList.message}</li>\n }\n return null\n })\n}\n/**Recuresively parses error list and constructs an array of objects containing attribute value error messages associated with form fields. Nested errors construct '.' separated keys\n * metadata.state is a special case for state taxes validation errors\n */\nconst getFieldErrors = (\n error: EntityErrorObject,\n parentKey?: string,\n): { key: string; message: string }[] => {\n const keyPrefix = parentKey ? parentKey + '.' : ''\n if (error.category === 'invalid_attribute_value' || error.category === 'invalid_operation') {\n return [\n {\n key: snakeCaseToCamelCase(keyPrefix + error.errorKey),\n message: error.message ?? '',\n },\n ]\n }\n if (error.category === 'nested_errors' && error.errors !== undefined) {\n //TODO: clean this up once Metadata type is fixed in openapi spec\n let keySuffix = ''\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n if (error.metadata?.key && typeof error.metadata.key === 'string') {\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n keySuffix = error.metadata.key as string\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n } else if (error.metadata?.state && typeof error.metadata.state === 'string') {\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n keySuffix = error.metadata.state as string\n } else if (error.errorKey) {\n keySuffix = error.errorKey\n }\n return error.errors.flatMap(err => getFieldErrors(err, keyPrefix + keySuffix))\n }\n return []\n}\n\ntype SubmitHandler<T> = (data: T) => Promise<void>\n\nexport const BaseComponent = <TResourceKey extends keyof Resources = keyof Resources>({\n children,\n FallbackComponent = InternalError,\n LoaderComponent: LoadingIndicatorFromProps,\n onEvent,\n}: BaseComponentInterface<TResourceKey>) => {\n const [error, setError] = useState<KnownErrors | null>(null)\n const [fieldErrors, setFieldErrors] = useState<FieldError[] | null>(null)\n const throwError = useAsyncError()\n const { t } = useTranslation()\n const Components = useComponentContext()\n\n const { LoadingIndicator: LoadingIndicatorFromContext } = useLoadingIndicator()\n\n const LoaderComponent = LoadingIndicatorFromProps ?? LoadingIndicatorFromContext\n\n // Enhanced setError that also clears fieldErrors when error is cleared\n const setErrorWithFieldsClear = useCallback((error: KnownErrors | null) => {\n setError(error)\n if (!error) {\n setFieldErrors(null)\n }\n }, [])\n\n const processError = (error: KnownErrors) => {\n setError(error)\n //422\tapplication/json - content relaited error\n if (error instanceof UnprocessableEntityErrorObject && Array.isArray(error.errors)) {\n setFieldErrors(error.errors.flatMap(err => getFieldErrors(err)))\n }\n }\n\n const baseSubmitHandler = useCallback(\n async <T,>(data: T, componentHandler: SubmitHandler<T>) => {\n setError(null)\n setFieldErrors(null)\n try {\n await componentHandler(data)\n } catch (err) {\n if (\n err instanceof APIError ||\n err instanceof SDKValidationError ||\n err instanceof UnprocessableEntityErrorObject\n ) {\n processError(err)\n } else throwError(err)\n }\n },\n [setError, throwError],\n )\n\n return (\n <BaseContext.Provider\n value={{\n fieldErrors,\n setError: setErrorWithFieldsClear,\n onEvent,\n throwError,\n baseSubmitHandler,\n }}\n >\n <QueryErrorResetBoundary>\n {({ reset: resetQueries }) => (\n <ErrorBoundary\n FallbackComponent={FallbackComponent}\n onReset={resetQueries}\n onError={err => {\n onEvent(componentEvents.ERROR, err)\n }}\n >\n {(error || fieldErrors) && (\n <Components.Alert label={t('status.errorEncountered')} status=\"error\">\n {fieldErrors && <Components.UnorderedList items={renderErrorList(fieldErrors)} />}\n {error && error instanceof APIError && (\n <Components.Text>{error.message}</Components.Text>\n )}\n {error && error instanceof SDKValidationError && (\n <Components.Text as=\"pre\">{error.pretty()}</Components.Text>\n )}\n </Components.Alert>\n )}\n <Suspense fallback={<LoaderComponent />}>\n <FadeIn>{children}</FadeIn>\n </Suspense>\n </ErrorBoundary>\n )}\n </QueryErrorResetBoundary>\n </BaseContext.Provider>\n )\n}\n"],"names":["renderErrorList","errorList","errorFromList","jsx","getFieldErrors","error","parentKey","keyPrefix","snakeCaseToCamelCase","keySuffix","err","BaseComponent","children","FallbackComponent","InternalError","LoadingIndicatorFromProps","onEvent","setError","useState","fieldErrors","setFieldErrors","throwError","useAsyncError","t","useTranslation","Components","useComponentContext","LoadingIndicatorFromContext","useLoadingIndicator","LoaderComponent","setErrorWithFieldsClear","useCallback","processError","UnprocessableEntityErrorObject","baseSubmitHandler","data","componentHandler","APIError","SDKValidationError","BaseContext","QueryErrorResetBoundary","resetQueries","jsxs","ErrorBoundary","componentEvents","Suspense","FadeIn"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"Base.js","sources":["../../../src/components/Base/Base.tsx"],"sourcesContent":["import type { ReactNode, JSX } from 'react'\nimport { Suspense, useState, useCallback } from 'react'\nimport type { FallbackProps } from 'react-error-boundary'\nimport { ErrorBoundary } from 'react-error-boundary'\nimport { useTranslation } from 'react-i18next'\nimport { APIError } from '@gusto/embedded-api/models/errors/apierror'\nimport { SDKValidationError } from '@gusto/embedded-api/models/errors/sdkvalidationerror'\nimport { UnprocessableEntityErrorObject } from '@gusto/embedded-api/models/errors/unprocessableentityerrorobject'\nimport type { EntityErrorObject } from '@gusto/embedded-api/models/components/entityerrorobject'\nimport { QueryErrorResetBoundary } from '@tanstack/react-query'\nimport { FadeIn } from '../Common/FadeIn/FadeIn'\nimport { BaseContext, type FieldError, type KnownErrors, type OnEventType } from './useBase'\nimport { componentEvents, type EventType } from '@/shared/constants'\nimport { InternalError, useAsyncError } from '@/components/Common'\nimport { snakeCaseToCamelCase } from '@/helpers/formattedStrings'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport type { ResourceDictionary, Resources } from '@/types/Helpers'\nimport { useLoadingIndicator } from '@/contexts/LoadingIndicatorProvider/useLoadingIndicator'\nimport type { LoadingIndicatorContextProps } from '@/contexts/LoadingIndicatorProvider/useLoadingIndicator'\n\nexport interface CommonComponentInterface<TResourceKey extends keyof Resources = keyof Resources> {\n children?: ReactNode\n className?: string\n defaultValues?: unknown\n dictionary?: ResourceDictionary<TResourceKey>\n}\n\n// Base component wrapper with error and suspense handling\nexport interface BaseComponentInterface<TResourceKey extends keyof Resources = keyof Resources>\n extends CommonComponentInterface<TResourceKey> {\n FallbackComponent?: (props: FallbackProps) => JSX.Element\n LoaderComponent?: LoadingIndicatorContextProps['LoadingIndicator']\n onEvent: OnEventType<EventType, unknown>\n}\n\n/**Traverses errorList and finds items with message properties */\nconst renderErrorList = (errorList: FieldError[]): React.ReactNode[] => {\n return errorList.map(errorFromList => {\n if (errorFromList.message) {\n return <li key={errorFromList.key}>{errorFromList.message}</li>\n }\n return null\n })\n}\n/**Recuresively parses error list and constructs an array of objects containing attribute value error messages associated with form fields. Nested errors construct '.' separated keys\n * metadata.state is a special case for state taxes validation errors\n */\nconst getFieldErrors = (\n error: EntityErrorObject,\n parentKey?: string,\n): { key: string; message: string }[] => {\n const keyPrefix = parentKey ? parentKey + '.' : ''\n if (error.category === 'invalid_attribute_value' || error.category === 'invalid_operation') {\n return [\n {\n key: snakeCaseToCamelCase(keyPrefix + error.errorKey),\n message: error.message ?? '',\n },\n ]\n }\n if (error.category === 'nested_errors' && error.errors !== undefined) {\n //TODO: clean this up once Metadata type is fixed in openapi spec\n let keySuffix = ''\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n if (error.metadata?.key && typeof error.metadata.key === 'string') {\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n keySuffix = error.metadata.key as string\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n } else if (error.metadata?.state && typeof error.metadata.state === 'string') {\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n keySuffix = error.metadata.state as string\n } else if (error.errorKey) {\n keySuffix = error.errorKey\n }\n return error.errors.flatMap(err => getFieldErrors(err, keyPrefix + keySuffix))\n }\n return []\n}\n\ntype SubmitHandler<T> = (data: T) => Promise<void>\n\nexport const BaseComponent = <TResourceKey extends keyof Resources = keyof Resources>({\n children,\n FallbackComponent = InternalError,\n LoaderComponent: LoadingIndicatorFromProps,\n onEvent,\n}: BaseComponentInterface<TResourceKey>) => {\n const [error, setError] = useState<KnownErrors | null>(null)\n const [fieldErrors, setFieldErrors] = useState<FieldError[] | null>(null)\n const throwError = useAsyncError()\n const { t } = useTranslation()\n const Components = useComponentContext()\n\n const { LoadingIndicator: LoadingIndicatorFromContext } = useLoadingIndicator()\n\n const LoaderComponent = LoadingIndicatorFromProps ?? LoadingIndicatorFromContext\n\n // Enhanced setError that also clears fieldErrors when error is cleared\n const setErrorWithFieldsClear = useCallback((error: KnownErrors | null) => {\n setError(error)\n if (!error) {\n setFieldErrors(null)\n }\n }, [])\n\n const processError = (error: KnownErrors) => {\n setError(error)\n //422\tapplication/json - content relaited error\n if (error instanceof UnprocessableEntityErrorObject && Array.isArray(error.errors)) {\n setFieldErrors(error.errors.flatMap(err => getFieldErrors(err)))\n }\n }\n\n const baseSubmitHandler = useCallback(\n async <T,>(data: T, componentHandler: SubmitHandler<T>) => {\n setError(null)\n setFieldErrors(null)\n try {\n await componentHandler(data)\n } catch (err) {\n if (\n err instanceof APIError ||\n err instanceof SDKValidationError ||\n err instanceof UnprocessableEntityErrorObject\n ) {\n processError(err)\n } else throwError(err)\n }\n },\n [setError, throwError],\n )\n\n return (\n <BaseContext.Provider\n value={{\n fieldErrors,\n setError: setErrorWithFieldsClear,\n onEvent,\n throwError,\n baseSubmitHandler,\n }}\n >\n <QueryErrorResetBoundary>\n {({ reset: resetQueries }) => (\n <ErrorBoundary\n FallbackComponent={FallbackComponent}\n onReset={resetQueries}\n onError={err => {\n onEvent(componentEvents.ERROR, err)\n }}\n >\n {(error || fieldErrors) && (\n <Components.Alert label={t('status.errorEncountered')} status=\"error\">\n {fieldErrors && <Components.UnorderedList items={renderErrorList(fieldErrors)} />}\n {error && error instanceof APIError && (\n <Components.Text>{error.message}</Components.Text>\n )}\n {error && error instanceof SDKValidationError && (\n <Components.Text as=\"pre\">{error.pretty()}</Components.Text>\n )}\n </Components.Alert>\n )}\n <Suspense fallback={<LoaderComponent />}>\n <FadeIn>{children}</FadeIn>\n </Suspense>\n </ErrorBoundary>\n )}\n </QueryErrorResetBoundary>\n </BaseContext.Provider>\n )\n}\n"],"names":["renderErrorList","errorList","errorFromList","jsx","getFieldErrors","error","parentKey","keyPrefix","snakeCaseToCamelCase","keySuffix","err","BaseComponent","children","FallbackComponent","InternalError","LoadingIndicatorFromProps","onEvent","setError","useState","fieldErrors","setFieldErrors","throwError","useAsyncError","t","useTranslation","Components","useComponentContext","LoadingIndicatorFromContext","useLoadingIndicator","LoaderComponent","setErrorWithFieldsClear","useCallback","processError","UnprocessableEntityErrorObject","baseSubmitHandler","data","componentHandler","APIError","SDKValidationError","BaseContext","QueryErrorResetBoundary","resetQueries","jsxs","ErrorBoundary","componentEvents","Suspense","FadeIn"],"mappings":"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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./types/i18next.d.ts"
|
|
2
2
|
import { ContractorOnboardingStatus1 } from '@gusto/embedded-api/models/components/contractor';
|
|
3
|
-
import { OnboardingStatus } from '@gusto/embedded-api/models/
|
|
3
|
+
import { OnboardingStatus } from '@gusto/embedded-api/models/operations/putv1employeesemployeeidonboardingstatus';
|
|
4
4
|
type OnboardingStatuses = ContractorOnboardingStatus1 | OnboardingStatus;
|
|
5
5
|
interface OnboardingStatusBadgeProps<T extends OnboardingStatuses> {
|
|
6
6
|
onboarded?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/Common/OnboardingStatusBadge/index.tsx"],"sourcesContent":["import type { ContractorOnboardingStatus1 } from '@gusto/embedded-api/models/components/contractor'\nimport type { OnboardingStatus } from '@gusto/embedded-api/models/
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/Common/OnboardingStatusBadge/index.tsx"],"sourcesContent":["import type { ContractorOnboardingStatus1 } from '@gusto/embedded-api/models/components/contractor'\nimport type { OnboardingStatus } from '@gusto/embedded-api/models/operations/putv1employeesemployeeidonboardingstatus'\nimport { useTranslation } from 'react-i18next'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\ntype OnboardingStatuses = ContractorOnboardingStatus1 | OnboardingStatus\n\ninterface OnboardingStatusBadgeProps<T extends OnboardingStatuses> {\n onboarded?: boolean\n onboardingEntity: 'contractor' | 'employee'\n onboardingStatus?: T | null\n}\nexport const OnboardingStatusBadge = <T extends OnboardingStatuses>({\n onboarded,\n onboardingEntity,\n onboardingStatus,\n}: OnboardingStatusBadgeProps<T>) => {\n const { Badge } = useComponentContext()\n const { t } = useTranslation()\n\n //HACK: `never` should instead be a better type\n return (\n <Badge status={onboarded ? 'success' : 'warning'}>\n {t(`onboardingStatus.${onboardingEntity}.${onboardingStatus ?? 'undefined'}` as never)}\n </Badge>\n )\n}\n\ninterface ContractorOnboardingStatusBadgeProps {\n onboarded?: boolean\n onboardingStatus?: ContractorOnboardingStatus1 | null\n}\nexport const ContractorOnboardingStatusBadge = (props: ContractorOnboardingStatusBadgeProps) => (\n <OnboardingStatusBadge {...props} onboardingEntity=\"contractor\" />\n)\n\ninterface EmployeeOnboardingStatusBadgeProps {\n onboarded?: boolean\n onboardingStatus?: OnboardingStatus | null\n}\nexport const EmployeeOnboardingStatusBadge = (props: EmployeeOnboardingStatusBadgeProps) => (\n <OnboardingStatusBadge {...props} onboardingEntity=\"employee\" />\n)\n"],"names":["OnboardingStatusBadge","onboarded","onboardingEntity","onboardingStatus","Badge","useComponentContext","t","useTranslation","jsx","ContractorOnboardingStatusBadge","props","EmployeeOnboardingStatusBadge"],"mappings":";;;AAYO,MAAMA,IAAwB,CAA+B;AAAA,EAClE,WAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,kBAAAC;AACF,MAAqC;AAC7B,QAAA,EAAE,OAAAC,EAAM,IAAIC,EAAoB,GAChC,EAAE,GAAAC,EAAE,IAAIC,EAAe;AAG7B,SACG,gBAAAC,EAAAJ,GAAA,EAAM,QAAQH,IAAY,YAAY,WACpC,UAAEK,EAAA,oBAAoBJ,CAAgB,IAAIC,KAAoB,WAAW,EAAW,GACvF;AAEJ,GAMaM,IAAkC,CAACC,MAC9C,gBAAAF,EAACR,KAAuB,GAAGU,GAAO,kBAAiB,aAAa,CAAA,GAOrDC,IAAgC,CAACD,MAC5C,gBAAAF,EAACR,KAAuB,GAAGU,GAAO,kBAAiB,WAAW,CAAA;"}
|
|
@@ -5,24 +5,22 @@ import { zodResolver as l } from "@hookform/resolvers/zod";
|
|
|
5
5
|
import t from "./SignatureForm.module.scss.js";
|
|
6
6
|
import { Form as u } from "../Form/Form.js";
|
|
7
7
|
import { Flex as c } from "../Flex/Flex.js";
|
|
8
|
-
import "react-i18next";
|
|
9
|
-
import "classnames";
|
|
10
8
|
const f = o.object({
|
|
11
9
|
signature: o.string().min(1),
|
|
12
10
|
confirmSignature: o.literal(!0)
|
|
13
|
-
}),
|
|
11
|
+
}), d = {
|
|
14
12
|
signature: ""
|
|
15
13
|
};
|
|
16
|
-
function
|
|
14
|
+
function b({ onSubmit: m, children: i, formProps: n }) {
|
|
17
15
|
const e = s({
|
|
18
16
|
resolver: l(f),
|
|
19
|
-
defaultValues:
|
|
17
|
+
defaultValues: d,
|
|
20
18
|
...n
|
|
21
19
|
});
|
|
22
20
|
return /* @__PURE__ */ r(a, { ...e, children: /* @__PURE__ */ r(u, { onSubmit: e.handleSubmit(m), className: t.container, children: /* @__PURE__ */ r("div", { className: t.formFields, children: /* @__PURE__ */ r(c, { flexDirection: "column", gap: 20, children: i }) }) }) });
|
|
23
21
|
}
|
|
24
22
|
export {
|
|
25
|
-
|
|
23
|
+
b as SignatureForm,
|
|
26
24
|
f as SignatureFormSchema
|
|
27
25
|
};
|
|
28
26
|
//# sourceMappingURL=SignatureForm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignatureForm.js","sources":["../../../../src/components/Common/SignatureForm/SignatureForm.tsx"],"sourcesContent":["import { z } from 'zod'\nimport { FormProvider, useForm, type UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport styles from './SignatureForm.module.scss'\nimport { Form } from '@/components/Common/Form'\nimport { Flex } from '@/components/Common'\n\nexport const SignatureFormSchema = z.object({\n signature: z.string().min(1),\n confirmSignature: z.literal(true),\n})\n\nconst signatureFormDefaultValues = {\n signature: '',\n}\n\nexport type SignatureFormInputs = z.infer<typeof SignatureFormSchema>\n\ninterface SignatureFormProps {\n onSubmit: (data: SignatureFormInputs) => void | Promise<void>\n children?: React.ReactNode\n formProps?: Partial<UseFormProps<SignatureFormInputs>>\n}\n\nexport function SignatureForm({ onSubmit, children, formProps }: SignatureFormProps) {\n const methods = useForm<SignatureFormInputs>({\n resolver: zodResolver(SignatureFormSchema),\n defaultValues: signatureFormDefaultValues,\n ...formProps,\n })\n\n return (\n <FormProvider {...methods}>\n <Form onSubmit={methods.handleSubmit(onSubmit)} className={styles.container}>\n <div className={styles.formFields}>\n <Flex flexDirection=\"column\" gap={20}>\n {children}\n </Flex>\n </div>\n </Form>\n </FormProvider>\n )\n}\n"],"names":["SignatureFormSchema","z","signatureFormDefaultValues","SignatureForm","onSubmit","children","formProps","methods","useForm","zodResolver","jsx","FormProvider","Form","styles","Flex"],"mappings":"
|
|
1
|
+
{"version":3,"file":"SignatureForm.js","sources":["../../../../src/components/Common/SignatureForm/SignatureForm.tsx"],"sourcesContent":["import { z } from 'zod'\nimport { FormProvider, useForm, type UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport styles from './SignatureForm.module.scss'\nimport { Form } from '@/components/Common/Form'\nimport { Flex } from '@/components/Common'\n\nexport const SignatureFormSchema = z.object({\n signature: z.string().min(1),\n confirmSignature: z.literal(true),\n})\n\nconst signatureFormDefaultValues = {\n signature: '',\n}\n\nexport type SignatureFormInputs = z.infer<typeof SignatureFormSchema>\n\ninterface SignatureFormProps {\n onSubmit: (data: SignatureFormInputs) => void | Promise<void>\n children?: React.ReactNode\n formProps?: Partial<UseFormProps<SignatureFormInputs>>\n}\n\nexport function SignatureForm({ onSubmit, children, formProps }: SignatureFormProps) {\n const methods = useForm<SignatureFormInputs>({\n resolver: zodResolver(SignatureFormSchema),\n defaultValues: signatureFormDefaultValues,\n ...formProps,\n })\n\n return (\n <FormProvider {...methods}>\n <Form onSubmit={methods.handleSubmit(onSubmit)} className={styles.container}>\n <div className={styles.formFields}>\n <Flex flexDirection=\"column\" gap={20}>\n {children}\n </Flex>\n </div>\n </Form>\n </FormProvider>\n )\n}\n"],"names":["SignatureFormSchema","z","signatureFormDefaultValues","SignatureForm","onSubmit","children","formProps","methods","useForm","zodResolver","jsx","FormProvider","Form","styles","Flex"],"mappings":";;;;;;;AAOa,MAAAA,IAAsBC,EAAE,OAAO;AAAA,EAC1C,WAAWA,EAAE,SAAS,IAAI,CAAC;AAAA,EAC3B,kBAAkBA,EAAE,QAAQ,EAAI;AAClC,CAAC,GAEKC,IAA6B;AAAA,EACjC,WAAW;AACb;AAUO,SAASC,EAAc,EAAE,UAAAC,GAAU,UAAAC,GAAU,WAAAC,KAAiC;AACnF,QAAMC,IAAUC,EAA6B;AAAA,IAC3C,UAAUC,EAAYT,CAAmB;AAAA,IACzC,eAAeE;AAAA,IACf,GAAGI;AAAA,EAAA,CACJ;AAED,SACG,gBAAAI,EAAAC,GAAA,EAAc,GAAGJ,GAChB,UAAC,gBAAAG,EAAAE,GAAA,EAAK,UAAUL,EAAQ,aAAaH,CAAQ,GAAG,WAAWS,EAAO,WAChE,UAAC,gBAAAH,EAAA,OAAA,EAAI,WAAWG,EAAO,YACrB,UAAA,gBAAAH,EAACI,GAAK,EAAA,eAAc,UAAS,KAAK,IAC/B,UAAAT,EACH,CAAA,EACF,CAAA,EACF,CAAA,GACF;AAEJ;"}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { jsxs as m, jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import "
|
|
3
|
-
import "classnames";
|
|
2
|
+
import "../../../shared/constants.js";
|
|
4
3
|
import { ActionsLayout as s } from "../ActionsLayout/ActionsLayout.js";
|
|
5
4
|
import { useComponentContext as p } from "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
6
|
-
function
|
|
5
|
+
function l({
|
|
7
6
|
onBack: t,
|
|
8
7
|
backLabel: r,
|
|
9
|
-
submitLabel:
|
|
10
|
-
isLoading:
|
|
8
|
+
submitLabel: e,
|
|
9
|
+
isLoading: i = !1
|
|
11
10
|
}) {
|
|
12
11
|
const o = p();
|
|
13
12
|
return /* @__PURE__ */ m(s, { children: [
|
|
14
13
|
t && /* @__PURE__ */ n(o.Button, { variant: "secondary", type: "button", onClick: t, children: r }),
|
|
15
|
-
/* @__PURE__ */ n(o.Button, { type: "submit", isLoading:
|
|
14
|
+
/* @__PURE__ */ n(o.Button, { type: "submit", isLoading: i, children: e })
|
|
16
15
|
] });
|
|
17
16
|
}
|
|
18
17
|
export {
|
|
19
|
-
|
|
18
|
+
l as SignatureFormActions
|
|
20
19
|
};
|
|
21
20
|
//# sourceMappingURL=SignatureFormActions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignatureFormActions.js","sources":["../../../../src/components/Common/SignatureForm/SignatureFormActions.tsx"],"sourcesContent":["import { ActionsLayout } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\ninterface SignatureFormActionsProps {\n onBack?: () => void\n backLabel: string\n submitLabel: string\n isLoading?: boolean\n}\n\nexport function SignatureFormActions({\n onBack,\n backLabel,\n submitLabel,\n isLoading = false,\n}: SignatureFormActionsProps) {\n const Components = useComponentContext()\n\n return (\n <ActionsLayout>\n {onBack && (\n <Components.Button variant=\"secondary\" type=\"button\" onClick={onBack}>\n {backLabel}\n </Components.Button>\n )}\n <Components.Button type=\"submit\" isLoading={isLoading}>\n {submitLabel}\n </Components.Button>\n </ActionsLayout>\n )\n}\n"],"names":["SignatureFormActions","onBack","backLabel","submitLabel","isLoading","Components","useComponentContext","ActionsLayout","jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"SignatureFormActions.js","sources":["../../../../src/components/Common/SignatureForm/SignatureFormActions.tsx"],"sourcesContent":["import { ActionsLayout } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\ninterface SignatureFormActionsProps {\n onBack?: () => void\n backLabel: string\n submitLabel: string\n isLoading?: boolean\n}\n\nexport function SignatureFormActions({\n onBack,\n backLabel,\n submitLabel,\n isLoading = false,\n}: SignatureFormActionsProps) {\n const Components = useComponentContext()\n\n return (\n <ActionsLayout>\n {onBack && (\n <Components.Button variant=\"secondary\" type=\"button\" onClick={onBack}>\n {backLabel}\n </Components.Button>\n )}\n <Components.Button type=\"submit\" isLoading={isLoading}>\n {submitLabel}\n </Components.Button>\n </ActionsLayout>\n )\n}\n"],"names":["SignatureFormActions","onBack","backLabel","submitLabel","isLoading","Components","useComponentContext","ActionsLayout","jsx"],"mappings":";;;;AAUO,SAASA,EAAqB;AAAA,EACnC,QAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC,IAAY;AACd,GAA8B;AAC5B,QAAMC,IAAaC,EAAoB;AAEvC,2BACGC,GACE,EAAA,UAAA;AAAA,IACCN,KAAA,gBAAAO,EAACH,EAAW,QAAX,EAAkB,SAAQ,aAAY,MAAK,UAAS,SAASJ,GAC3D,UACHC,EAAA,CAAA;AAAA,sBAEDG,EAAW,QAAX,EAAkB,MAAK,UAAS,WAAAD,GAC9B,UACHD,EAAA,CAAA;AAAA,EAAA,GACF;AAEJ;"}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import "
|
|
3
|
-
import "classnames";
|
|
1
|
+
import { jsxs as m, Fragment as s, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import "../../../shared/constants.js";
|
|
4
3
|
import { TextInputField as a } from "../Fields/TextInputField/TextInputField.js";
|
|
5
4
|
import { CheckboxField as u } from "../Fields/CheckboxField/CheckboxField.js";
|
|
6
|
-
function
|
|
5
|
+
function c({
|
|
7
6
|
signatureLabel: r,
|
|
8
7
|
signatureDescription: i = "",
|
|
9
8
|
signatureError: t = "",
|
|
10
9
|
confirmationLabel: o,
|
|
11
|
-
confirmationError:
|
|
10
|
+
confirmationError: n = ""
|
|
12
11
|
}) {
|
|
13
|
-
return /* @__PURE__ */
|
|
12
|
+
return /* @__PURE__ */ m(s, { children: [
|
|
14
13
|
/* @__PURE__ */ e(
|
|
15
14
|
a,
|
|
16
15
|
{
|
|
@@ -27,12 +26,12 @@ function f({
|
|
|
27
26
|
name: "confirmSignature",
|
|
28
27
|
isRequired: !0,
|
|
29
28
|
label: o,
|
|
30
|
-
errorMessage:
|
|
29
|
+
errorMessage: n
|
|
31
30
|
}
|
|
32
31
|
)
|
|
33
32
|
] });
|
|
34
33
|
}
|
|
35
34
|
export {
|
|
36
|
-
|
|
35
|
+
c as SignatureFormFields
|
|
37
36
|
};
|
|
38
37
|
//# sourceMappingURL=SignatureFormFields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignatureFormFields.js","sources":["../../../../src/components/Common/SignatureForm/SignatureFormFields.tsx"],"sourcesContent":["import { TextInputField, CheckboxField } from '@/components/Common'\n\ninterface SignatureFormFieldsProps {\n signatureLabel: string\n signatureDescription?: string\n signatureError?: string\n confirmationLabel: string\n confirmationError?: string\n}\n\nexport function SignatureFormFields({\n signatureLabel,\n signatureDescription = '',\n signatureError = '',\n confirmationLabel,\n confirmationError = '',\n}: SignatureFormFieldsProps) {\n return (\n <>\n <TextInputField\n name=\"signature\"\n label={signatureLabel}\n description={signatureDescription}\n errorMessage={signatureError}\n isRequired\n />\n <CheckboxField\n name=\"confirmSignature\"\n isRequired\n label={confirmationLabel}\n errorMessage={confirmationError}\n />\n </>\n )\n}\n"],"names":["SignatureFormFields","signatureLabel","signatureDescription","signatureError","confirmationLabel","confirmationError","jsxs","Fragment","jsx","TextInputField","CheckboxField"],"mappings":"
|
|
1
|
+
{"version":3,"file":"SignatureFormFields.js","sources":["../../../../src/components/Common/SignatureForm/SignatureFormFields.tsx"],"sourcesContent":["import { TextInputField, CheckboxField } from '@/components/Common'\n\ninterface SignatureFormFieldsProps {\n signatureLabel: string\n signatureDescription?: string\n signatureError?: string\n confirmationLabel: string\n confirmationError?: string\n}\n\nexport function SignatureFormFields({\n signatureLabel,\n signatureDescription = '',\n signatureError = '',\n confirmationLabel,\n confirmationError = '',\n}: SignatureFormFieldsProps) {\n return (\n <>\n <TextInputField\n name=\"signature\"\n label={signatureLabel}\n description={signatureDescription}\n errorMessage={signatureError}\n isRequired\n />\n <CheckboxField\n name=\"confirmSignature\"\n isRequired\n label={confirmationLabel}\n errorMessage={confirmationError}\n />\n </>\n )\n}\n"],"names":["SignatureFormFields","signatureLabel","signatureDescription","signatureError","confirmationLabel","confirmationError","jsxs","Fragment","jsx","TextInputField","CheckboxField"],"mappings":";;;;AAUO,SAASA,EAAoB;AAAA,EAClC,gBAAAC;AAAA,EACA,sBAAAC,IAAuB;AAAA,EACvB,gBAAAC,IAAiB;AAAA,EACjB,mBAAAC;AAAA,EACA,mBAAAC,IAAoB;AACtB,GAA6B;AAC3B,SAEI,gBAAAC,EAAAC,GAAA,EAAA,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,OAAOR;AAAA,QACP,aAAaC;AAAA,QACb,cAAcC;AAAA,QACd,YAAU;AAAA,MAAA;AAAA,IACZ;AAAA,IACA,gBAAAK;AAAA,MAACE;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,YAAU;AAAA,QACV,OAAON;AAAA,QACP,cAAcC;AAAA,MAAA;AAAA,IAAA;AAAA,EAChB,GACF;AAEJ;"}
|
|
@@ -22,4 +22,5 @@ export declare function TextInput({ question, requirement, isDisabled }: EmpQ |
|
|
|
22
22
|
export declare function NumberInput({ question, requirement, isCurrency, isPercent, isDisabled, }: (EmpQ | CompR) & NumberFieldProps): import("react/jsx-runtime").JSX.Element | null;
|
|
23
23
|
export declare function RadioInput({ question, requirement, isDisabled }: EmpQ | CompR): import("react/jsx-runtime").JSX.Element | null;
|
|
24
24
|
export declare function DateField({ question, requirement, isDisabled, }: (EmpQ | CompR) & NumberFieldProps): import("react/jsx-runtime").JSX.Element | null;
|
|
25
|
+
export declare function TaxRateInput({ requirement, question, ...props }: EmpQ | CompR): import("react/jsx-runtime").JSX.Element;
|
|
25
26
|
export {};
|
|
@@ -1,118 +1,118 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { useTranslation as
|
|
4
|
-
import { SelectField as
|
|
5
|
-
import { TextInputField as
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import b from "dompurify";
|
|
3
|
+
import { useTranslation as y } from "react-i18next";
|
|
4
|
+
import { SelectField as m } from "../Fields/SelectField/SelectField.js";
|
|
5
|
+
import { TextInputField as w } from "../Fields/TextInputField/TextInputField.js";
|
|
6
6
|
import { NumberInputField as k } from "../Fields/NumberInputField/NumberInputField.js";
|
|
7
|
-
import { RadioGroupField as
|
|
8
|
-
import { DatePickerField as
|
|
9
|
-
import { useComponentContext as
|
|
10
|
-
import { useMaskedTransform as
|
|
11
|
-
const
|
|
12
|
-
function
|
|
13
|
-
questionType:
|
|
14
|
-
...
|
|
7
|
+
import { RadioGroupField as R } from "../Fields/RadioGroupField/RadioGroupField.js";
|
|
8
|
+
import { DatePickerField as _ } from "../Fields/DatePickerField/DatePickerField.js";
|
|
9
|
+
import { useComponentContext as D } from "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
10
|
+
import { useMaskedTransform as T } from "../../../helpers/mask.js";
|
|
11
|
+
const h = { ALLOWED_TAGS: ["a", "b", "strong"], ALLOWED_ATTR: ["target", "href"] };
|
|
12
|
+
function M({
|
|
13
|
+
questionType: e,
|
|
14
|
+
...t
|
|
15
15
|
}) {
|
|
16
|
-
switch (
|
|
16
|
+
switch (e.toLowerCase()) {
|
|
17
17
|
case "date":
|
|
18
|
-
return /* @__PURE__ */
|
|
18
|
+
return /* @__PURE__ */ a(I, { ...t });
|
|
19
19
|
case "radio":
|
|
20
|
-
return /* @__PURE__ */
|
|
20
|
+
return /* @__PURE__ */ a(C, { ...t });
|
|
21
21
|
case "text":
|
|
22
22
|
case "account_number":
|
|
23
|
-
return /* @__PURE__ */
|
|
23
|
+
return /* @__PURE__ */ a(f, { ...t });
|
|
24
24
|
case "select":
|
|
25
|
-
return /* @__PURE__ */
|
|
25
|
+
return /* @__PURE__ */ a(x, { ...t });
|
|
26
26
|
case "number":
|
|
27
|
-
return /* @__PURE__ */
|
|
27
|
+
return /* @__PURE__ */ a(d, { ...t });
|
|
28
28
|
case "workers_compensation_rate":
|
|
29
|
-
return /* @__PURE__ */
|
|
29
|
+
return /* @__PURE__ */ a(d, { ...t, isPercent: t.requirement?.metadata?.rateType === "percent" });
|
|
30
30
|
case "percent":
|
|
31
31
|
case "tax_rate":
|
|
32
|
-
return /* @__PURE__ */
|
|
32
|
+
return /* @__PURE__ */ a(g, { ...t });
|
|
33
33
|
case "currency":
|
|
34
|
-
return /* @__PURE__ */
|
|
34
|
+
return /* @__PURE__ */ a(d, { ...t, isCurrency: !0 });
|
|
35
35
|
default:
|
|
36
|
-
return /* @__PURE__ */
|
|
36
|
+
return /* @__PURE__ */ a(f, { ...t });
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
const { key:
|
|
39
|
+
function x({ question: e, requirement: t, isDisabled: l = !1 }) {
|
|
40
|
+
const { key: r, label: u, description: i } = e || t, n = e ? e.answers[0]?.value : t.value, o = e ? e.inputQuestionFormat : t.metadata;
|
|
41
41
|
if (!o?.options) throw new Error("Select input must have options");
|
|
42
|
-
return
|
|
43
|
-
|
|
42
|
+
return r ? /* @__PURE__ */ a(
|
|
43
|
+
m,
|
|
44
44
|
{
|
|
45
45
|
isRequired: !0,
|
|
46
|
-
name:
|
|
46
|
+
name: r,
|
|
47
47
|
defaultValue: n,
|
|
48
|
-
label:
|
|
49
|
-
description:
|
|
50
|
-
isDisabled:
|
|
51
|
-
options: o.options.map((
|
|
52
|
-
value:
|
|
53
|
-
label:
|
|
48
|
+
label: u,
|
|
49
|
+
description: i,
|
|
50
|
+
isDisabled: r.includes("fileNewHireReport") ? n !== void 0 : l,
|
|
51
|
+
options: o.options.map((s, c) => ({
|
|
52
|
+
value: s.value,
|
|
53
|
+
label: s.label
|
|
54
54
|
}))
|
|
55
55
|
}
|
|
56
56
|
) : null;
|
|
57
57
|
}
|
|
58
|
-
function f({ question:
|
|
59
|
-
const { key:
|
|
60
|
-
return
|
|
61
|
-
|
|
58
|
+
function f({ question: e, requirement: t, isDisabled: l = !1 }) {
|
|
59
|
+
const { key: r, label: u, description: i } = e || t, n = e ? e.answers[0]?.value : t.value, o = t?.metadata?.mask ?? null, s = T(o);
|
|
60
|
+
return r ? /* @__PURE__ */ a(
|
|
61
|
+
w,
|
|
62
62
|
{
|
|
63
63
|
isRequired: !0,
|
|
64
|
-
name:
|
|
65
|
-
label:
|
|
64
|
+
name: r,
|
|
65
|
+
label: u,
|
|
66
66
|
defaultValue: n,
|
|
67
|
-
description:
|
|
68
|
-
isDisabled:
|
|
69
|
-
transform: o ?
|
|
67
|
+
description: i,
|
|
68
|
+
isDisabled: l,
|
|
69
|
+
transform: o ? s : void 0,
|
|
70
70
|
placeholder: o || void 0
|
|
71
71
|
}
|
|
72
72
|
) : null;
|
|
73
73
|
}
|
|
74
74
|
function d({
|
|
75
|
-
question:
|
|
76
|
-
requirement:
|
|
77
|
-
isCurrency:
|
|
78
|
-
isPercent:
|
|
79
|
-
isDisabled:
|
|
75
|
+
question: e,
|
|
76
|
+
requirement: t,
|
|
77
|
+
isCurrency: l,
|
|
78
|
+
isPercent: r,
|
|
79
|
+
isDisabled: u = !1
|
|
80
80
|
}) {
|
|
81
|
-
const { t:
|
|
81
|
+
const { t: i } = y("common"), { key: n, label: o, description: s } = e || t, c = e ? e.answers[0]?.value : t.value;
|
|
82
82
|
if (!n) return null;
|
|
83
|
-
const
|
|
84
|
-
return /* @__PURE__ */
|
|
83
|
+
const p = t?.metadata?.type === "workers_compensation_rate" && t.metadata.riskClassCode !== void 0 ? `${t.metadata.riskClassCode}: ${t.metadata.riskClassDescription}` : null, v = t?.metadata?.rateType === "currency_per_hour" ? i("inputs.workersCompensationRatePerHourAdornment") : void 0;
|
|
84
|
+
return /* @__PURE__ */ a(
|
|
85
85
|
k,
|
|
86
86
|
{
|
|
87
87
|
isRequired: !0,
|
|
88
88
|
name: n,
|
|
89
89
|
label: o,
|
|
90
|
-
description:
|
|
90
|
+
description: s ?? p,
|
|
91
91
|
defaultValue: typeof c < "u" ? Number(c) : void 0,
|
|
92
|
-
format:
|
|
93
|
-
isDisabled:
|
|
94
|
-
maximumFractionDigits:
|
|
95
|
-
adornmentEnd:
|
|
92
|
+
format: l ? "currency" : r ? "percent" : "decimal",
|
|
93
|
+
isDisabled: u,
|
|
94
|
+
maximumFractionDigits: r ? 4 : void 0,
|
|
95
|
+
adornmentEnd: v
|
|
96
96
|
}
|
|
97
97
|
);
|
|
98
98
|
}
|
|
99
|
-
function
|
|
100
|
-
const { key:
|
|
101
|
-
if (!
|
|
102
|
-
return
|
|
103
|
-
|
|
99
|
+
function C({ question: e, requirement: t, isDisabled: l = !1 }) {
|
|
100
|
+
const { key: r, label: u, description: i } = e || t, n = e ? e.answers[0]?.value : t.value, { Text: o } = D(), s = e ? e.inputQuestionFormat : t.metadata;
|
|
101
|
+
if (!s?.options) throw new Error(`RadioInput must have options:${JSON.stringify(e)}`);
|
|
102
|
+
return r ? /* @__PURE__ */ a(
|
|
103
|
+
R,
|
|
104
104
|
{
|
|
105
105
|
isRequired: !0,
|
|
106
|
-
name:
|
|
107
|
-
isDisabled:
|
|
108
|
-
description:
|
|
106
|
+
name: r,
|
|
107
|
+
isDisabled: r.includes("fileNewHireReport") ? n !== void 0 : l,
|
|
108
|
+
description: i && /* @__PURE__ */ a(o, { as: "span", children: /* @__PURE__ */ a(
|
|
109
109
|
"span",
|
|
110
110
|
{
|
|
111
|
-
dangerouslySetInnerHTML: { __html:
|
|
111
|
+
dangerouslySetInnerHTML: { __html: b.sanitize(i, h) }
|
|
112
112
|
}
|
|
113
113
|
) }),
|
|
114
|
-
label:
|
|
115
|
-
options:
|
|
114
|
+
label: u,
|
|
115
|
+
options: s.options.map((c) => ({
|
|
116
116
|
value: c.value,
|
|
117
117
|
label: c.label
|
|
118
118
|
}))
|
|
@@ -120,31 +120,51 @@ function x({ question: t, requirement: e, isDisabled: s = !1 }) {
|
|
|
120
120
|
) : null;
|
|
121
121
|
}
|
|
122
122
|
function I({
|
|
123
|
-
question:
|
|
124
|
-
requirement:
|
|
125
|
-
isDisabled:
|
|
123
|
+
question: e,
|
|
124
|
+
requirement: t,
|
|
125
|
+
isDisabled: l = !1
|
|
126
126
|
}) {
|
|
127
|
-
const { key:
|
|
127
|
+
const { key: r, label: u, description: i } = e || t, n = e ? e.answers[0]?.value : t.value;
|
|
128
128
|
if (typeof n != "string" && typeof n < "u")
|
|
129
129
|
throw new Error("Expecting value to be string for DateInput");
|
|
130
|
-
return
|
|
131
|
-
|
|
130
|
+
return r ? /* @__PURE__ */ a(
|
|
131
|
+
_,
|
|
132
132
|
{
|
|
133
133
|
isRequired: !0,
|
|
134
|
-
name:
|
|
134
|
+
name: r,
|
|
135
135
|
defaultValue: n ? new Date(n) : null,
|
|
136
|
-
label:
|
|
137
|
-
description:
|
|
138
|
-
isDisabled:
|
|
136
|
+
label: u,
|
|
137
|
+
description: i,
|
|
138
|
+
isDisabled: l
|
|
139
139
|
}
|
|
140
140
|
) : null;
|
|
141
141
|
}
|
|
142
|
+
function g({ requirement: e, question: t, ...l }) {
|
|
143
|
+
if (e) {
|
|
144
|
+
const { key: r, metadata: u, label: i, description: n } = e, { validation: o } = u || {};
|
|
145
|
+
return o?.type === "one_of" ? /* @__PURE__ */ a(
|
|
146
|
+
m,
|
|
147
|
+
{
|
|
148
|
+
isRequired: !0,
|
|
149
|
+
name: r || "",
|
|
150
|
+
label: i || "",
|
|
151
|
+
description: n,
|
|
152
|
+
options: o.rates?.map((s) => ({
|
|
153
|
+
value: s,
|
|
154
|
+
label: s
|
|
155
|
+
})) || []
|
|
156
|
+
}
|
|
157
|
+
) : /* @__PURE__ */ a(d, { requirement: e, ...l, isPercent: !0 });
|
|
158
|
+
}
|
|
159
|
+
return /* @__PURE__ */ a(d, { question: t, ...l, isPercent: !0 });
|
|
160
|
+
}
|
|
142
161
|
export {
|
|
143
162
|
I as DateField,
|
|
144
163
|
d as NumberInput,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
164
|
+
M as QuestionInput,
|
|
165
|
+
C as RadioInput,
|
|
166
|
+
x as SelectInput,
|
|
167
|
+
g as TaxRateInput,
|
|
148
168
|
f as TextInput
|
|
149
169
|
};
|
|
150
170
|
//# sourceMappingURL=TaxInputs.js.map
|