@gusto/embedded-react-sdk 0.52.0 → 0.52.1
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 +16 -0
- package/dist/components/Base/Base.d.ts +2 -0
- package/dist/components/Base/Base.js.map +1 -1
- package/dist/components/Common/PaginationControl/PaginationControlTypes.d.ts +4 -1
- package/dist/components/Common/UI/Breadcrumbs/BreadcrumbsTypes.d.ts +1 -1
- package/dist/components/Common/UI/Breadcrumbs/BreadcrumbsTypes.js.map +1 -1
- package/dist/components/Common/UI/CheckboxGroup/CheckboxGroupTypes.d.ts +1 -1
- package/dist/components/Common/UI/CheckboxGroup/CheckboxGroupTypes.js.map +1 -1
- package/dist/components/Common/UI/ComboBox/ComboBoxTypes.d.ts +2 -2
- package/dist/components/Common/UI/DateRangePicker/DateRangePickerTypes.d.ts +3 -2
- package/dist/components/Common/UI/DescriptionList/DescriptionListTypes.d.ts +1 -1
- package/dist/components/Common/UI/DescriptionList/DescriptionListTypes.js.map +1 -1
- package/dist/components/Common/UI/Menu/MenuTypes.d.ts +3 -3
- package/dist/components/Common/UI/Menu/MenuTypes.js.map +1 -1
- package/dist/components/Common/UI/MultiSelectComboBox/MultiSelectComboBoxTypes.d.ts +2 -2
- package/dist/components/Common/UI/RadioGroup/RadioGroupTypes.d.ts +2 -2
- package/dist/components/Common/UI/RadioGroup/RadioGroupTypes.js.map +1 -1
- package/dist/components/Common/UI/Select/SelectTypes.d.ts +2 -2
- package/dist/components/Common/UI/Table/TableTypes.d.ts +4 -4
- package/dist/components/Common/UI/Table/TableTypes.js.map +1 -1
- package/dist/components/Common/UI/Tabs/TabsTypes.d.ts +2 -2
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +5 -3
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +5 -3
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +7 -5
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +5 -3
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +5 -3
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +10 -8
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Company/Industry/Context.js +8 -6
- package/dist/components/Company/Industry/Context.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +5 -3
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js +5 -3
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +5 -3
- package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +5 -3
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +5 -3
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
- package/dist/components/Contractor/ContractorList/index.d.ts +2 -1
- package/dist/components/Contractor/ContractorList/index.js +121 -99
- package/dist/components/Contractor/ContractorList/index.js.map +1 -1
- package/dist/components/Contractor/OnboardingFlow/OnboardingFlow.d.ts +1 -1
- package/dist/components/Contractor/OnboardingFlow/OnboardingFlow.js.map +1 -1
- package/dist/components/Contractor/OnboardingFlow/OnboardingFlowComponents.d.ts +2 -0
- package/dist/components/Contractor/OnboardingFlow/OnboardingFlowComponents.js.map +1 -1
- package/dist/components/Contractor/OnboardingFlow/onboardingStateMachine.js +150 -80
- package/dist/components/Contractor/OnboardingFlow/onboardingStateMachine.js.map +1 -1
- package/dist/components/Contractor/OnboardingFlow/onboardingStateMachine.test.d.ts +1 -0
- package/dist/components/Contractor/Profile/BusinessSelfOnboardingProfile.js +19 -18
- package/dist/components/Contractor/Profile/BusinessSelfOnboardingProfile.js.map +1 -1
- package/dist/components/Contractor/Profile/ContractorProfile.d.ts +1 -1
- package/dist/components/Contractor/Profile/ContractorProfile.js +114 -110
- package/dist/components/Contractor/Profile/ContractorProfile.js.map +1 -1
- package/dist/components/Contractor/Profile/IndividualSelfOnboardingProfile.js +27 -26
- package/dist/components/Contractor/Profile/IndividualSelfOnboardingProfile.js.map +1 -1
- package/dist/components/Contractor/Submit/Submit.js +106 -63
- package/dist/components/Contractor/Submit/Submit.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js +5 -3
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fields.d.ts +2 -2
- package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fields.js.map +1 -1
- package/dist/components/Payroll/usePreparedPayrollData.js +10 -8
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/contexts/ComponentAdapter/useComponentContext.d.ts +1 -1
- package/dist/contexts/ComponentAdapter/useComponentContext.js.map +1 -1
- package/dist/contexts/GustoProvider/GustoProvider.d.ts +1 -0
- package/dist/contexts/GustoProvider/GustoProvider.js.map +1 -1
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.d.ts +1 -0
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
- package/dist/contexts/ThemeProvider/types.d.ts +2 -2
- package/dist/i18n/en/Contractor.ContractorList.json.js +22 -20
- package/dist/i18n/en/Contractor.ContractorList.json.js.map +1 -1
- package/dist/i18n/en/Contractor.Submit.json.js +11 -11
- package/dist/i18n/types.d.ts +7 -3
- package/dist/models/WA_RISK_CODES.d.ts +1 -0
- package/dist/models/WA_RISK_CODES.js.map +1 -1
- package/dist/partner-hook-utils/composeErrorHandler.d.ts +4 -0
- package/dist/partner-hook-utils/composeErrorHandler.js.map +1 -1
- package/dist/partner-hook-utils/form/SDKFormProvider.d.ts +1 -0
- package/dist/partner-hook-utils/form/SDKFormProvider.js.map +1 -1
- package/dist/partner-hook-utils/form/composeSubmitHandler.d.ts +4 -0
- package/dist/partner-hook-utils/form/composeSubmitHandler.js.map +1 -1
- package/dist/partner-hook-utils/form/fields/CheckboxHookField.d.ts +1 -0
- package/dist/partner-hook-utils/form/fields/CheckboxHookField.js.map +1 -1
- package/dist/partner-hook-utils/form/fields/DatePickerHookField.d.ts +1 -0
- package/dist/partner-hook-utils/form/fields/DatePickerHookField.js.map +1 -1
- package/dist/partner-hook-utils/form/fields/NumberInputHookField.d.ts +1 -0
- package/dist/partner-hook-utils/form/fields/NumberInputHookField.js.map +1 -1
- package/dist/partner-hook-utils/form/fields/RadioGroupHookField.d.ts +1 -0
- package/dist/partner-hook-utils/form/fields/RadioGroupHookField.js.map +1 -1
- package/dist/partner-hook-utils/form/fields/SelectHookField.d.ts +1 -0
- package/dist/partner-hook-utils/form/fields/SelectHookField.js.map +1 -1
- package/dist/partner-hook-utils/form/fields/SwitchHookField.d.ts +1 -0
- package/dist/partner-hook-utils/form/fields/SwitchHookField.js.map +1 -1
- package/dist/partner-hook-utils/form/fields/TextInputHookField.d.ts +1 -0
- package/dist/partner-hook-utils/form/fields/TextInputHookField.js.map +1 -1
- package/dist/partner-hook-utils/types.d.ts +9 -0
- package/dist/shared/constants.d.ts +10 -0
- package/dist/shared/constants.js +7 -6
- package/dist/shared/constants.js.map +1 -1
- package/dist/types/Helpers.d.ts +2 -0
- package/dist/types/hooks.d.ts +1 -0
- package/dist/types/observability.d.ts +1 -0
- package/docs/guides/endpoint-inventory.json +17 -1
- package/package.json +11 -11
|
@@ -1,101 +1,144 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
2
|
-
import { useTranslation as
|
|
3
|
-
import { useContractorsUpdateOnboardingStatusMutation as
|
|
4
|
-
import { useContractorsGetOnboardingStatusSuspense as
|
|
5
|
-
import { useContractorsGetSuspense as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { jsx as t, jsxs as a } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation as N } from "react-i18next";
|
|
3
|
+
import { useContractorsUpdateOnboardingStatusMutation as P } from "@gusto/embedded-api/react-query/contractorsUpdateOnboardingStatus";
|
|
4
|
+
import { useContractorsGetOnboardingStatusSuspense as j } from "@gusto/embedded-api/react-query/contractorsGetOnboardingStatus";
|
|
5
|
+
import { useContractorsGetSuspense as T } from "@gusto/embedded-api/react-query/contractorsGet";
|
|
6
|
+
import { useContractorDocumentsGetAllSuspense as k } from "@gusto/embedded-api/react-query/contractorDocumentsGetAll";
|
|
7
|
+
import { useContractorDocumentsGetPdf as H } from "@gusto/embedded-api/react-query/contractorDocumentsGetPdf";
|
|
8
|
+
import { SubmitDone as F } from "./SubmitDone.js";
|
|
9
|
+
import { Flex as c, FlexItem as W } from "../../Common/Flex/Flex.js";
|
|
10
|
+
import { ActionsLayout as V } from "../../Common/ActionsLayout/ActionsLayout.js";
|
|
11
|
+
import { useComponentContext as D } from "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
10
12
|
import "react";
|
|
11
|
-
import { useI18n as
|
|
12
|
-
import { BaseComponent as
|
|
13
|
-
import { useBase as
|
|
14
|
-
import { ContractorOnboardingStatus as
|
|
15
|
-
import { firstLastName as
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
import { useI18n as z, useComponentDictionary as J } from "../../../i18n/I18n.js";
|
|
14
|
+
import { BaseComponent as K } from "../../Base/Base.js";
|
|
15
|
+
import { useBase as Q } from "../../Base/useBase.js";
|
|
16
|
+
import { ContractorOnboardingStatus as O, componentEvents as f } from "../../../shared/constants.js";
|
|
17
|
+
import { firstLastName as X } from "../../../helpers/formattedStrings.js";
|
|
18
|
+
import { W9_DOCUMENT_NAME as _ } from "../Documents/SignatureForm/useContractorSignatureForm/w9Fields.js";
|
|
19
|
+
function bt(e) {
|
|
20
|
+
return /* @__PURE__ */ t(K, { ...e, children: /* @__PURE__ */ t(Y, { ...e, children: e.children }) });
|
|
18
21
|
}
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const { Alert:
|
|
22
|
-
contractorUuid:
|
|
23
|
-
}),
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
const Y = ({ contractorId: e, selfOnboarding: l, dictionary: r }) => {
|
|
23
|
+
z("Contractor.Submit"), J("Contractor.Submit", r);
|
|
24
|
+
const { Alert: u, Box: m, BoxHeader: i, Button: d, Heading: s, UnorderedList: C } = D(), { t: n } = N("Contractor.Submit"), { onEvent: p, baseSubmitHandler: R } = Q(), x = Object.values(n("warningItems", { returnObjects: !0 })), { data: A } = j({
|
|
25
|
+
contractorUuid: e
|
|
26
|
+
}), g = A.contractorOnboardingStatus?.onboardingStatus, { data: U } = T({ contractorUuid: e }), h = U.contractor, B = h?.type === "Individual" ? h.firstName : h?.businessName, { data: E } = k({
|
|
27
|
+
contractorUuid: e
|
|
28
|
+
}), b = (E.documents ?? []).filter(
|
|
29
|
+
(o) => o.requiresSigning && !o.signedAt
|
|
30
|
+
), v = b.some((o) => o.name === _), { mutateAsync: I, isPending: y } = P(), L = async () => {
|
|
31
|
+
await R(null, async () => {
|
|
32
|
+
const o = await I({
|
|
26
33
|
request: {
|
|
27
|
-
contractorUuid:
|
|
34
|
+
contractorUuid: e,
|
|
28
35
|
contractorOnboardingStatusUpdateRequestBody: {
|
|
29
|
-
onboardingStatus:
|
|
36
|
+
onboardingStatus: O.ONBOARDING_COMPLETED
|
|
30
37
|
}
|
|
31
38
|
}
|
|
32
39
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
),
|
|
40
|
+
p(
|
|
41
|
+
f.CONTRACTOR_ONBOARDING_STATUS_UPDATED,
|
|
42
|
+
o.contractorOnboardingStatus
|
|
43
|
+
), p(f.CONTRACTOR_SUBMIT_DONE, { message: n("submitDone.successMessage") });
|
|
37
44
|
});
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
message:
|
|
45
|
+
}, w = () => {
|
|
46
|
+
p(f.CONTRACTOR_INVITE_CONTRACTOR, { contractorId: e }), p(f.CONTRACTOR_SUBMIT_DONE, {
|
|
47
|
+
message: n("inviteContractor.successMessage")
|
|
41
48
|
});
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
onboardingStatus:
|
|
45
|
-
message:
|
|
49
|
+
}, M = () => {
|
|
50
|
+
p(f.CONTRACTOR_SUBMIT_DONE, {
|
|
51
|
+
onboardingStatus: g,
|
|
52
|
+
message: n("submitDone.successMessage")
|
|
46
53
|
});
|
|
47
54
|
};
|
|
48
|
-
return
|
|
49
|
-
/* @__PURE__ */ t(
|
|
50
|
-
/* @__PURE__ */ t(
|
|
51
|
-
|
|
55
|
+
return g === O.ONBOARDING_COMPLETED ? /* @__PURE__ */ t(F, { onDone: M }) : g === O.SELF_ONBOARDING_NOT_INVITED && l ? /* @__PURE__ */ t($, { onSubmit: w, contractorId: e }) : /* @__PURE__ */ a(c, { flexDirection: "column", gap: 24, children: [
|
|
56
|
+
/* @__PURE__ */ t(W, { children: /* @__PURE__ */ t(s, { as: "h2", children: n("heading") }) }),
|
|
57
|
+
b.length > 0 && /* @__PURE__ */ t(
|
|
58
|
+
m,
|
|
52
59
|
{
|
|
53
60
|
header: /* @__PURE__ */ t(
|
|
54
61
|
i,
|
|
55
62
|
{
|
|
56
|
-
title:
|
|
57
|
-
description:
|
|
63
|
+
title: n("documentRequirements.title"),
|
|
64
|
+
description: n("documentRequirements.description", { contractorName: B })
|
|
58
65
|
}
|
|
59
66
|
),
|
|
60
|
-
children: /* @__PURE__ */
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
/* @__PURE__ */ t(
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
children: /* @__PURE__ */ a(c, { flexDirection: "column", gap: 16, children: [
|
|
68
|
+
b.map((o) => {
|
|
69
|
+
const S = o.name === _, q = S ? n("documentRequirements.documents.taxpayer_identification_form_w_9.title") : o.title ?? "", G = S ? n("documentRequirements.documents.taxpayer_identification_form_w_9.description") : o.description ?? "";
|
|
70
|
+
return /* @__PURE__ */ t(
|
|
71
|
+
Z,
|
|
72
|
+
{
|
|
73
|
+
title: q,
|
|
74
|
+
description: G,
|
|
75
|
+
document: o,
|
|
76
|
+
downloadLabel: n("documentRequirements.downloadCta")
|
|
77
|
+
},
|
|
78
|
+
o.uuid
|
|
79
|
+
);
|
|
80
|
+
}),
|
|
81
|
+
v && /* @__PURE__ */ t(u, { status: "info", label: n("documentRequirements.alertLabel") })
|
|
66
82
|
] })
|
|
67
83
|
}
|
|
68
84
|
),
|
|
69
|
-
/* @__PURE__ */
|
|
70
|
-
/* @__PURE__ */ t(
|
|
71
|
-
/* @__PURE__ */ t(
|
|
85
|
+
/* @__PURE__ */ a(c, { flexDirection: "column", gap: 8, children: [
|
|
86
|
+
/* @__PURE__ */ t(u, { status: "warning", label: n("title"), children: /* @__PURE__ */ t(C, { items: x }) }),
|
|
87
|
+
/* @__PURE__ */ t(V, { justifyContent: "end", children: /* @__PURE__ */ t(d, { title: n("submitCta"), onClick: L, isLoading: y, children: n("submitCta") }) })
|
|
72
88
|
] })
|
|
73
89
|
] });
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
|
|
90
|
+
}, Z = ({
|
|
91
|
+
title: e,
|
|
92
|
+
description: l,
|
|
93
|
+
document: r,
|
|
94
|
+
downloadLabel: u
|
|
77
95
|
}) => {
|
|
78
|
-
const {
|
|
79
|
-
|
|
80
|
-
|
|
96
|
+
const { Text: m, Button: i } = D(), d = r?.uuid, { data: s, isLoading: C } = H(
|
|
97
|
+
{ documentUuid: d ?? "" },
|
|
98
|
+
{ enabled: !!d }
|
|
99
|
+
), n = s?.documentPdf?.documentUrl ?? null;
|
|
100
|
+
return /* @__PURE__ */ a(c, { gap: 16, justifyContent: "space-between", alignItems: "center", children: [
|
|
101
|
+
/* @__PURE__ */ a(c, { flexDirection: "column", gap: 4, children: [
|
|
102
|
+
/* @__PURE__ */ t(m, { weight: "medium", children: e }),
|
|
103
|
+
/* @__PURE__ */ t(m, { variant: "supporting", children: l })
|
|
104
|
+
] }),
|
|
105
|
+
(C || n) && /* @__PURE__ */ t(
|
|
106
|
+
i,
|
|
107
|
+
{
|
|
108
|
+
variant: "secondary",
|
|
109
|
+
isLoading: C,
|
|
110
|
+
onClick: () => {
|
|
111
|
+
n && window.open(n, "_blank", "noopener,noreferrer");
|
|
112
|
+
},
|
|
113
|
+
children: u
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
] });
|
|
117
|
+
}, $ = ({
|
|
118
|
+
onSubmit: e,
|
|
119
|
+
contractorId: l
|
|
120
|
+
}) => {
|
|
121
|
+
const { t: r } = N("Contractor.Submit", { keyPrefix: "inviteContractor" }), { Button: u, Heading: m, Text: i } = D(), { data: d } = T({ contractorUuid: l }), s = d.contractor;
|
|
122
|
+
return /* @__PURE__ */ a(c, { flexDirection: "column", children: [
|
|
123
|
+
/* @__PURE__ */ t(m, { as: "h2", children: r("title") }),
|
|
81
124
|
/* @__PURE__ */ t(i, { children: r("description") }),
|
|
82
|
-
/* @__PURE__ */
|
|
83
|
-
/* @__PURE__ */
|
|
84
|
-
/* @__PURE__ */ t(i, { children:
|
|
125
|
+
/* @__PURE__ */ a(c, { flexDirection: "column", children: [
|
|
126
|
+
/* @__PURE__ */ a("div", { children: [
|
|
127
|
+
/* @__PURE__ */ t(i, { children: X({
|
|
85
128
|
first_name: s?.firstName,
|
|
86
129
|
last_name: s?.lastName
|
|
87
130
|
}) }),
|
|
88
131
|
/* @__PURE__ */ t(i, { children: s?.email })
|
|
89
132
|
] }),
|
|
90
|
-
/* @__PURE__ */
|
|
133
|
+
/* @__PURE__ */ a("div", { children: [
|
|
91
134
|
/* @__PURE__ */ t(i, { children: r("startDateLabel") }),
|
|
92
135
|
/* @__PURE__ */ t(i, { children: s?.startDate })
|
|
93
136
|
] })
|
|
94
137
|
] }),
|
|
95
|
-
/* @__PURE__ */ t(
|
|
138
|
+
/* @__PURE__ */ t(u, { title: r("inviteCta"), onClick: e, children: r("inviteCta") })
|
|
96
139
|
] });
|
|
97
140
|
};
|
|
98
141
|
export {
|
|
99
|
-
|
|
142
|
+
bt as ContractorSubmit
|
|
100
143
|
};
|
|
101
144
|
//# sourceMappingURL=Submit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Submit.js","sources":["../../../../src/components/Contractor/Submit/Submit.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useContractorsUpdateOnboardingStatusMutation } from '@gusto/embedded-api/react-query/contractorsUpdateOnboardingStatus'\nimport { useContractorsGetOnboardingStatusSuspense } from '@gusto/embedded-api/react-query/contractorsGetOnboardingStatus'\nimport { useContractorsGetSuspense } from '@gusto/embedded-api/react-query/contractorsGet'\nimport { SubmitDone } from './SubmitDone'\nimport { ActionsLayout, Flex, FlexItem } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n, useComponentDictionary } from '@/i18n'\nimport { BaseComponent, useBase, type BaseComponentInterface } from '@/components/Base'\nimport { componentEvents, ContractorOnboardingStatus } from '@/shared/constants'\nimport { firstLastName } from '@/helpers/formattedStrings'\n\n/**\n * Props for {@link ContractorSubmit}.\n *\n * @public\n */\nexport interface ContractorSubmitProps extends BaseComponentInterface<'Contractor.Submit'> {\n /** UUID of the contractor being submitted. */\n contractorId: string\n /** When true, adjusts the submission for the self-onboarding flow, surfacing the invite step before the contractor's onboarding status is finalized. */\n selfOnboarding?: boolean\n}\n\n/**\n * Finalizes contractor onboarding by updating the onboarding status, and in the self-onboarding flow can trigger an invitation to the contractor.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `contractor/onboardingStatus/updated` | The contractor's onboarding status was successfully updated. | The updated `contractorOnboardingStatus` returned by the API. |\n * | `contractor/invite/selfOnboarding` | The invite action was triggered for a self-onboarding contractor. | `{ contractorId: string }` |\n * | `contractor/submit/done` | The submission step finished — fired after a successful status update, after an invite, or when the contractor was already onboarded. | `{ message: string }`, optionally with `onboardingStatus` when the contractor was already completed. |\n *\n * @param props - See {@link ContractorSubmitProps}.\n * @returns The rendered submission step.\n * @public\n */\nexport function ContractorSubmit(props: ContractorSubmitProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({ contractorId, selfOnboarding, dictionary }: ContractorSubmitProps) => {\n useI18n('Contractor.Submit')\n useComponentDictionary('Contractor.Submit', dictionary)\n const { Alert, Box, BoxHeader, Button, Text, Heading, UnorderedList } = useComponentContext()\n const { t } = useTranslation('Contractor.Submit')\n const { onEvent, baseSubmitHandler } = useBase()\n const items = Object.values(t('warningItems', { returnObjects: true }))\n\n const { data } = useContractorsGetOnboardingStatusSuspense({\n contractorUuid: contractorId,\n })\n const onboardingStatus = data.contractorOnboardingStatus?.onboardingStatus\n\n const { mutateAsync } = useContractorsUpdateOnboardingStatusMutation()\n\n const onSubmit = async () => {\n await baseSubmitHandler(null, async () => {\n const response = await mutateAsync({\n request: {\n contractorUuid: contractorId,\n contractorOnboardingStatusUpdateRequestBody: {\n onboardingStatus: ContractorOnboardingStatus.ONBOARDING_COMPLETED,\n },\n },\n })\n onEvent(\n componentEvents.CONTRACTOR_ONBOARDING_STATUS_UPDATED,\n response.contractorOnboardingStatus,\n )\n onEvent(componentEvents.CONTRACTOR_SUBMIT_DONE, { message: t('submitDone.successMessage') })\n })\n }\n const handleInviteContractor = () => {\n onEvent(componentEvents.CONTRACTOR_INVITE_CONTRACTOR, { contractorId })\n onEvent(componentEvents.CONTRACTOR_SUBMIT_DONE, {\n message: t('inviteContractor.successMessage'),\n })\n }\n\n const handleSubmitDone = () => {\n onEvent(componentEvents.CONTRACTOR_SUBMIT_DONE, {\n onboardingStatus,\n message: t('submitDone.successMessage'),\n })\n }\n\n if (onboardingStatus === ContractorOnboardingStatus.ONBOARDING_COMPLETED) {\n return <SubmitDone onDone={handleSubmitDone} />\n }\n if (\n onboardingStatus === ContractorOnboardingStatus.SELF_ONBOARDING_NOT_INVITED &&\n selfOnboarding\n ) {\n return <InviteContractor onSubmit={handleInviteContractor} contractorId={contractorId} />\n }\n\n return (\n <Flex flexDirection=\"column\" gap={24}>\n <FlexItem>\n <Heading as=\"h2\">{t('heading')}</Heading>\n </FlexItem>\n\n <Box\n header={\n <BoxHeader\n title={t('documentRequirements.title')}\n description={t('documentRequirements.description')}\n />\n }\n >\n <Flex flexDirection=\"column\" gap={16}>\n {Object.values(t('documentRequirements.items', { returnObjects: true })).map(item => (\n <div key={item.title}>\n <Text weight=\"medium\">{item.title}</Text>\n <Text variant=\"supporting\">{item.description}</Text>\n </div>\n ))}\n <Alert status=\"info\" label={t('documentRequirements.alertLabel')}></Alert>\n </Flex>\n </Box>\n <Flex flexDirection=\"column\" gap={8}>\n <Alert status=\"warning\" label={t('title')}>\n <UnorderedList items={items} />\n </Alert>\n <ActionsLayout justifyContent=\"end\">\n <Button title={t('submitCta')} onClick={onSubmit}>\n {t('submitCta')}\n </Button>\n </ActionsLayout>\n </Flex>\n </Flex>\n )\n}\n\nconst InviteContractor = ({\n onSubmit,\n contractorId,\n}: {\n onSubmit: () => void\n contractorId: string\n}) => {\n const { t } = useTranslation('Contractor.Submit', { keyPrefix: 'inviteContractor' })\n const { Button, Heading, Text } = useComponentContext()\n\n const { data: contractorData } = useContractorsGetSuspense({ contractorUuid: contractorId })\n const contractor = contractorData.contractor\n\n return (\n <Flex flexDirection=\"column\">\n <Heading as=\"h2\">{t('title')}</Heading>\n <Text>{t('description')}</Text>\n <Flex flexDirection=\"column\">\n <div>\n <Text>\n {firstLastName({\n first_name: contractor?.firstName,\n last_name: contractor?.lastName,\n })}\n </Text>\n <Text>{contractor?.email}</Text>\n </div>\n <div>\n <Text>{t('startDateLabel')}</Text>\n <Text>{contractor?.startDate}</Text>\n </div>\n </Flex>\n <Button title={t('inviteCta')} onClick={onSubmit}>\n {t('inviteCta')}\n </Button>\n </Flex>\n )\n}\n"],"names":["ContractorSubmit","props","jsx","BaseComponent","Root","contractorId","selfOnboarding","dictionary","useI18n","useComponentDictionary","Alert","Box","BoxHeader","Button","Text","Heading","UnorderedList","useComponentContext","t","useTranslation","onEvent","baseSubmitHandler","useBase","items","data","useContractorsGetOnboardingStatusSuspense","onboardingStatus","mutateAsync","useContractorsUpdateOnboardingStatusMutation","onSubmit","response","ContractorOnboardingStatus","componentEvents","handleInviteContractor","handleSubmitDone","SubmitDone","InviteContractor","jsxs","Flex","FlexItem","item","ActionsLayout","contractorData","useContractorsGetSuspense","contractor","firstLastName"],"mappings":";;;;;;;;;;;;;;;AAsCO,SAASA,GAAiBC,GAA8B;AAC7D,SACE,gBAAAC,EAACC,GAAA,EAAe,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAAA,EAAM,SAAA,CAAS,EAAA,CACnC;AAEJ;AAEA,MAAMG,IAAO,CAAC,EAAE,cAAAC,GAAc,gBAAAC,GAAgB,YAAAC,QAAwC;AACpF,EAAAC,EAAQ,mBAAmB,GAC3BC,EAAuB,qBAAqBF,CAAU;AACtD,QAAM,EAAE,OAAAG,GAAO,KAAAC,GAAK,WAAAC,GAAW,QAAAC,GAAQ,MAAAC,GAAM,SAAAC,GAAS,eAAAC,EAAA,IAAkBC,EAAA,GAClE,EAAE,GAAAC,EAAA,IAAMC,EAAe,mBAAmB,GAC1C,EAAE,SAAAC,GAAS,mBAAAC,EAAA,IAAsBC,EAAA,GACjCC,IAAQ,OAAO,OAAOL,EAAE,gBAAgB,EAAE,eAAe,GAAA,CAAM,CAAC,GAEhE,EAAE,MAAAM,E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E,GAAS,MAAAD,EAAA,IAASG,EAAA,GAE5B,EAAE,MAAMyB,EAAA,IAAmBC,EAA0B,EAAE,gBAAgBtC,GAAc,GACrFuC,IAAaF,EAAe;AAElC,SACE,gBAAAL,EAACC,GAAA,EAAK,eAAc,UAClB,UAAA;AAAA,IAAA,gBAAApC,EAACa,GAAA,EAAQ,IAAG,MAAM,UAAAG,EAAE,OAAO,GAAE;AAAA,IAC7B,gBAAAhB,EAACY,GAAA,EAAM,UAAAI,EAAE,aAAa,EAAA,CAAE;AAAA,IACxB,gBAAAmB,EAACC,GAAA,EAAK,eAAc,UAClB,UAAA;AAAA,MAAA,gBAAAD,EAAC,OAAA,EACC,UAAA;AAAA,QAAA,gBAAAnC,EAACY,KACE,UAAA+B,EAAc;AAAA,UACb,YAAYD,GAAY;AAAA,UACxB,WAAWA,GAAY;AAAA,QAAA,CACxB,GACH;AAAA,QACA,gBAAA1C,EAACY,GAAA,EAAM,UAAA8B,GAAY,MAAA,CAAM;AAAA,MAAA,GAC3B;AAAA,wBACC,OAAA,EACC,UAAA;AAAA,QAAA,gBAAA1C,EAACY,GAAA,EAAM,UAAAI,EAAE,gBAAgB,EAAA,CAAE;AAAA,QAC3B,gBAAAhB,EAACY,GAAA,EAAM,UAAA8B,GAAY,UAAA,CAAU;AAAA,MAAA,EAAA,CAC/B;AAAA,IAAA,GACF;AAAA,IACA,gBAAA1C,EAACW,GAAA,EAAO,OAAOK,EAAE,WAAW,GAAG,SAASW,GACrC,UAAAX,EAAE,WAAW,EAAA,CAChB;AAAA,EAAA,GACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"Submit.js","sources":["../../../../src/components/Contractor/Submit/Submit.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useContractorsUpdateOnboardingStatusMutation } from '@gusto/embedded-api/react-query/contractorsUpdateOnboardingStatus'\nimport { useContractorsGetOnboardingStatusSuspense } from '@gusto/embedded-api/react-query/contractorsGetOnboardingStatus'\nimport { useContractorsGetSuspense } from '@gusto/embedded-api/react-query/contractorsGet'\nimport { useContractorDocumentsGetAllSuspense } from '@gusto/embedded-api/react-query/contractorDocumentsGetAll'\nimport { useContractorDocumentsGetPdf } from '@gusto/embedded-api/react-query/contractorDocumentsGetPdf'\nimport type { Document } from '@gusto/embedded-api/models/components/document'\nimport { SubmitDone } from './SubmitDone'\nimport { ActionsLayout, Flex, FlexItem } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n, useComponentDictionary } from '@/i18n'\nimport { BaseComponent, useBase, type BaseComponentInterface } from '@/components/Base'\nimport { componentEvents, ContractorOnboardingStatus } from '@/shared/constants'\nimport { firstLastName } from '@/helpers/formattedStrings'\nimport { W9_DOCUMENT_NAME } from '@/components/Contractor/Documents/SignatureForm/useContractorSignatureForm/w9Fields'\n\n/**\n * Props for {@link ContractorSubmit}.\n *\n * @public\n */\nexport interface ContractorSubmitProps extends BaseComponentInterface<'Contractor.Submit'> {\n /** UUID of the contractor being submitted. */\n contractorId: string\n /** When true, adjusts the submission for the self-onboarding flow, surfacing the invite step before the contractor's onboarding status is finalized. */\n selfOnboarding?: boolean\n}\n\n/**\n * Finalizes contractor onboarding by updating the onboarding status, and in the self-onboarding flow can trigger an invitation to the contractor.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `contractor/onboardingStatus/updated` | The contractor's onboarding status was successfully updated. | The updated `contractorOnboardingStatus` returned by the API. |\n * | `contractor/invite/selfOnboarding` | The invite action was triggered for a self-onboarding contractor. | `{ contractorId: string }` |\n * | `contractor/submit/done` | The submission step finished — fired after a successful status update, after an invite, or when the contractor was already onboarded. | `{ message: string }`, optionally with `onboardingStatus` when the contractor was already completed. |\n *\n * @param props - See {@link ContractorSubmitProps}.\n * @returns The rendered submission step.\n * @public\n */\nexport function ContractorSubmit(props: ContractorSubmitProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({ contractorId, selfOnboarding, dictionary }: ContractorSubmitProps) => {\n useI18n('Contractor.Submit')\n useComponentDictionary('Contractor.Submit', dictionary)\n const { Alert, Box, BoxHeader, Button, Heading, UnorderedList } = useComponentContext()\n const { t } = useTranslation('Contractor.Submit')\n const { onEvent, baseSubmitHandler } = useBase()\n const items = Object.values(t('warningItems', { returnObjects: true }))\n\n const { data } = useContractorsGetOnboardingStatusSuspense({\n contractorUuid: contractorId,\n })\n const onboardingStatus = data.contractorOnboardingStatus?.onboardingStatus\n\n const { data: contractorData } = useContractorsGetSuspense({ contractorUuid: contractorId })\n const contractor = contractorData.contractor\n const contractorName =\n contractor?.type === 'Individual' ? contractor.firstName : contractor?.businessName\n\n const { data: documentsData } = useContractorDocumentsGetAllSuspense({\n contractorUuid: contractorId,\n })\n const documentsToCollect = (documentsData.documents ?? []).filter(\n d => d.requiresSigning && !d.signedAt,\n )\n const hasW9 = documentsToCollect.some(d => d.name === W9_DOCUMENT_NAME)\n\n const { mutateAsync, isPending } = useContractorsUpdateOnboardingStatusMutation()\n\n const onSubmit = async () => {\n await baseSubmitHandler(null, async () => {\n const response = await mutateAsync({\n request: {\n contractorUuid: contractorId,\n contractorOnboardingStatusUpdateRequestBody: {\n onboardingStatus: ContractorOnboardingStatus.ONBOARDING_COMPLETED,\n },\n },\n })\n onEvent(\n componentEvents.CONTRACTOR_ONBOARDING_STATUS_UPDATED,\n response.contractorOnboardingStatus,\n )\n onEvent(componentEvents.CONTRACTOR_SUBMIT_DONE, { message: t('submitDone.successMessage') })\n })\n }\n const handleInviteContractor = () => {\n onEvent(componentEvents.CONTRACTOR_INVITE_CONTRACTOR, { contractorId })\n onEvent(componentEvents.CONTRACTOR_SUBMIT_DONE, {\n message: t('inviteContractor.successMessage'),\n })\n }\n\n const handleSubmitDone = () => {\n onEvent(componentEvents.CONTRACTOR_SUBMIT_DONE, {\n onboardingStatus,\n message: t('submitDone.successMessage'),\n })\n }\n\n if (onboardingStatus === ContractorOnboardingStatus.ONBOARDING_COMPLETED) {\n return <SubmitDone onDone={handleSubmitDone} />\n }\n if (\n onboardingStatus === ContractorOnboardingStatus.SELF_ONBOARDING_NOT_INVITED &&\n selfOnboarding\n ) {\n return <InviteContractor onSubmit={handleInviteContractor} contractorId={contractorId} />\n }\n\n return (\n <Flex flexDirection=\"column\" gap={24}>\n <FlexItem>\n <Heading as=\"h2\">{t('heading')}</Heading>\n </FlexItem>\n\n {documentsToCollect.length > 0 && (\n <Box\n header={\n <BoxHeader\n title={t('documentRequirements.title')}\n description={t('documentRequirements.description', { contractorName })}\n />\n }\n >\n <Flex flexDirection=\"column\" gap={16}>\n {documentsToCollect.map(document => {\n const isW9 = document.name === W9_DOCUMENT_NAME\n const title = isW9\n ? t('documentRequirements.documents.taxpayer_identification_form_w_9.title')\n : (document.title ?? '')\n const description = isW9\n ? t('documentRequirements.documents.taxpayer_identification_form_w_9.description')\n : (document.description ?? '')\n return (\n <DocumentRequirementItem\n key={document.uuid}\n title={title}\n description={description}\n document={document}\n downloadLabel={t('documentRequirements.downloadCta')}\n />\n )\n })}\n {hasW9 && <Alert status=\"info\" label={t('documentRequirements.alertLabel')}></Alert>}\n </Flex>\n </Box>\n )}\n <Flex flexDirection=\"column\" gap={8}>\n <Alert status=\"warning\" label={t('title')}>\n <UnorderedList items={items} />\n </Alert>\n <ActionsLayout justifyContent=\"end\">\n <Button title={t('submitCta')} onClick={onSubmit} isLoading={isPending}>\n {t('submitCta')}\n </Button>\n </ActionsLayout>\n </Flex>\n </Flex>\n )\n}\n\nconst DocumentRequirementItem = ({\n title,\n description,\n document,\n downloadLabel,\n}: {\n title: string\n description: string\n document: Document | undefined\n downloadLabel: string\n}) => {\n const { Text, Button } = useComponentContext()\n const documentUuid = document?.uuid\n const { data: pdfData, isLoading: isPdfLoading } = useContractorDocumentsGetPdf(\n { documentUuid: documentUuid ?? '' },\n { enabled: Boolean(documentUuid) },\n )\n const pdfUrl = pdfData?.documentPdf?.documentUrl ?? null\n\n return (\n <Flex gap={16} justifyContent=\"space-between\" alignItems=\"center\">\n <Flex flexDirection=\"column\" gap={4}>\n <Text weight=\"medium\">{title}</Text>\n <Text variant=\"supporting\">{description}</Text>\n </Flex>\n {(isPdfLoading || pdfUrl) && (\n <Button\n variant=\"secondary\"\n isLoading={isPdfLoading}\n onClick={() => {\n if (pdfUrl) window.open(pdfUrl, '_blank', 'noopener,noreferrer')\n }}\n >\n {downloadLabel}\n </Button>\n )}\n </Flex>\n )\n}\n\nconst InviteContractor = ({\n onSubmit,\n contractorId,\n}: {\n onSubmit: () => void\n contractorId: string\n}) => {\n const { t } = useTranslation('Contractor.Submit', { keyPrefix: 'inviteContractor' })\n const { Button, Heading, Text } = useComponentContext()\n\n const { data: contractorData } = useContractorsGetSuspense({ contractorUuid: contractorId })\n const contractor = contractorData.contractor\n\n return (\n <Flex flexDirection=\"column\">\n <Heading as=\"h2\">{t('title')}</Heading>\n <Text>{t('description')}</Text>\n <Flex flexDirection=\"column\">\n <div>\n <Text>\n {firstLastName({\n first_name: contractor?.firstName,\n last_name: contractor?.lastName,\n })}\n </Text>\n <Text>{contractor?.email}</Text>\n </div>\n <div>\n <Text>{t('startDateLabel')}</Text>\n <Text>{contractor?.startDate}</Text>\n </div>\n </Flex>\n <Button title={t('inviteCta')} onClick={onSubmit}>\n {t('inviteCta')}\n </Button>\n </Flex>\n )\n}\n"],"names":["ContractorSubmit","props","jsx","BaseComponent","Root","contractorId","selfOnboarding","dictionary","useI18n","useComponentDictionary","Alert","Box","BoxHeader","Button","Heading","UnorderedList","useComponentContext","t","useTranslation","onEvent","baseSubmitHandler","useBase","items","data","useContractorsGetOnboardingStatusSuspense","onboardingStatus","contractorData","useContractorsGetSuspense","contractor","contractorName","documentsData","useContractorDocumentsGetAllSuspense","documentsToCollect","d","hasW9","W9_DOCUMENT_NAME","mutateAsync","isPending","useContractorsUpdateOnboardingStatusMutation","onSubmit","response","ContractorOnboardingStatus","componentEvents","handleInviteContractor","handleSubmitDone","SubmitDone","InviteContractor","jsxs","Flex","FlexItem","document","isW9","title","description","DocumentRequirementItem","ActionsLayout","downloadLabel","Text","documentUuid","pdfData","isPdfLoading","useContractorDocumentsGetPdf","pdfUrl","firstLastName"],"mappings":";;;;;;;;;;;;;;;;;;AA0CO,SAASA,GAAiBC,GAA8B;AAC7D,SACE,gBAAAC,EAACC,GAAA,EAAe,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAAA,EAAM,SAAA,CAAS,EAAA,CACnC;AAEJ;AAEA,MAAMG,IAAO,CAAC,EAAE,cAAAC,GAAc,gBAAAC,GAAgB,YAAAC,QAAwC;AACpF,EAAAC,EAAQ,mBAAmB,GAC3BC,EAAuB,qBAAqBF,CAAU;AACtD,QAAM,EAAE,OAAAG,GAAO,KAAAC,GAAK,WAAAC,GAAW,QAAAC,GAAQ,SAAAC,GAAS,eAAAC,EAAA,IAAkBC,EAAA,GAC5D,EAAE,GAAAC,EAAA,IAAMC,EAAe,mBAAmB,GAC1C,EAAE,SAAAC,GAAS,mBAAAC,EAAA,IAAsBC,EAAA,GACjCC,IAAQ,OAAO,OAAOL,EAAE,gBAAgB,EAAE,eAAe,GAAA,CAAM,CAAC,GAEhE,EAAE,MAAAM,EAAA,IAASC,EAA0C;AAAA,IACzD,gBAAgBnB;AAAA,EAAA,CACjB,GACKoB,IAAmBF,EAAK,4BAA4B,kBAEpD,EAAE,MAAMG,EAAA,IAAmBC,EAA0B,EAAE,gBAAgBtB,GAAc,GACrFuB,IAAaF,EAAe,YAC5BG,IACJD,GAAY,SAAS,eAAeA,EAAW,YAAYA,GAAY,cAEnE,EAAE,MAAME,EAAA,IAAkBC,EAAqC;AAAA,IACnE,gBAAgB1B;AAAA,EAAA,CACjB,GACK2B,KAAsBF,EAAc,aAAa,CAAA,GAAI;AAAA,IACzD,CAAAG,MAAKA,EAAE,mBAAmB,CAACA,EAAE;AAAA,EAAA,GAEzBC,IAAQF,EAAmB,KAAK,CAAAC,MAAKA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A,EAAQ,IAAG,MAAM,UAAAG,EAAE,OAAO,GAAE;AAAA,IAC7B,gBAAAf,EAACuD,GAAA,EAAM,UAAAxC,EAAE,aAAa,EAAA,CAAE;AAAA,IACxB,gBAAA8B,EAACC,GAAA,EAAK,eAAc,UAClB,UAAA;AAAA,MAAA,gBAAAD,EAAC,OAAA,EACC,UAAA;AAAA,QAAA,gBAAA7C,EAACuD,KACE,UAAAM,EAAc;AAAA,UACb,YAAYnC,GAAY;AAAA,UACxB,WAAWA,GAAY;AAAA,QAAA,CACxB,GACH;AAAA,QACA,gBAAA1B,EAACuD,GAAA,EAAM,UAAA7B,GAAY,MAAA,CAAM;AAAA,MAAA,GAC3B;AAAA,wBACC,OAAA,EACC,UAAA;AAAA,QAAA,gBAAA1B,EAACuD,GAAA,EAAM,UAAAxC,EAAE,gBAAgB,EAAA,CAAE;AAAA,QAC3B,gBAAAf,EAACuD,GAAA,EAAM,UAAA7B,GAAY,UAAA,CAAU;AAAA,MAAA,EAAA,CAC/B;AAAA,IAAA,GACF;AAAA,IACA,gBAAA1B,EAACW,GAAA,EAAO,OAAOI,EAAE,WAAW,GAAG,SAASsB,GACrC,UAAAtB,EAAE,WAAW,EAAA,CAChB;AAAA,EAAA,GACF;AAEJ;"}
|
package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js
CHANGED
|
@@ -9,13 +9,15 @@ import "@gusto/embedded-api/models/errors/gustoembeddederror";
|
|
|
9
9
|
import "@gusto/embedded-api/models/errors/sdkvalidationerror";
|
|
10
10
|
import "@gusto/embedded-api/models/errors/unprocessableentityerror";
|
|
11
11
|
import "@gusto/embedded-api/models/errors/httpclienterrors";
|
|
12
|
+
import "dompurify";
|
|
13
|
+
import "../../../../../../contexts/LocaleProvider/useLocale.js";
|
|
12
14
|
import "../../../../../../shared/constants.js";
|
|
13
15
|
import "../../../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
14
16
|
import "../../../../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
15
17
|
import { createCompoundContext as t } from "../../../../../Base/createCompoundContext.js";
|
|
16
|
-
const [
|
|
18
|
+
const [v, P] = t("DocumentListContext");
|
|
17
19
|
export {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
P as DocumentListProvider,
|
|
21
|
+
v as useDocumentList
|
|
20
22
|
};
|
|
21
23
|
//# sourceMappingURL=useDocumentList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDocumentList.js","sources":["../../../../../../../src/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.ts"],"sourcesContent":["import type { Form } from '@gusto/embedded-api/models/components/form'\nimport { createCompoundContext } from '@/components/Base'\n\ntype DocumentListContextType = {\n employeeForms: Form[]\n hasSignedAllForms: boolean\n handleContinue: () => void\n handleRequestFormToSign: (form: Form) => void\n documentListError: Error | null\n formToSign?: Form\n}\n\nconst [useDocumentList, DocumentListProvider] =\n createCompoundContext<DocumentListContextType>('DocumentListContext')\nexport { useDocumentList, DocumentListProvider }\n"],"names":["useDocumentList","DocumentListProvider","createCompoundContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDocumentList.js","sources":["../../../../../../../src/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.ts"],"sourcesContent":["import type { Form } from '@gusto/embedded-api/models/components/form'\nimport { createCompoundContext } from '@/components/Base'\n\ntype DocumentListContextType = {\n employeeForms: Form[]\n hasSignedAllForms: boolean\n handleContinue: () => void\n handleRequestFormToSign: (form: Form) => void\n documentListError: Error | null\n formToSign?: Form\n}\n\nconst [useDocumentList, DocumentListProvider] =\n createCompoundContext<DocumentListContextType>('DocumentListContext')\nexport { useDocumentList, DocumentListProvider }\n"],"names":["useDocumentList","DocumentListProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;;;;;AAYA,MAAM,CAACA,GAAiBC,CAAoB,IAC1CC,EAA+C,qBAAqB;"}
|
|
@@ -108,7 +108,7 @@ export interface DateStateTaxQuestion extends SharedQuestionMetadata {
|
|
|
108
108
|
*
|
|
109
109
|
* @public
|
|
110
110
|
* @group Fields
|
|
111
|
-
* @
|
|
111
|
+
* @siblingOf {@link StateTaxFieldsGroup}
|
|
112
112
|
*/
|
|
113
113
|
export type StateTaxQuestionFieldEntry = SelectStateTaxQuestion | RadioStateTaxQuestion | TextStateTaxQuestion | NumberStateTaxQuestion | CurrencyStateTaxQuestion | DateStateTaxQuestion;
|
|
114
114
|
/**
|
|
@@ -117,7 +117,7 @@ export type StateTaxQuestionFieldEntry = SelectStateTaxQuestion | RadioStateTaxQ
|
|
|
117
117
|
*
|
|
118
118
|
* @public
|
|
119
119
|
* @group Fields
|
|
120
|
-
* @
|
|
120
|
+
* @siblingOf {@link StateTaxFields}
|
|
121
121
|
*/
|
|
122
122
|
export interface StateTaxFieldsGroup {
|
|
123
123
|
/** Two-letter state code. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.js","sources":["../../../../../../src/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fields.tsx"],"sourcesContent":["import type { ComponentType } from 'react'\nimport { useMemo } from 'react'\nimport type { EmployeeStateTaxesList } from '@gusto/embedded-api/models/components/employeestatetaxeslist'\nimport { getQuestionVariant, type StateTaxQuestionVariant } from './fieldMapping'\nimport {\n CurrencyStateTaxField,\n DateStateTaxField,\n NumberStateTaxField,\n RadioStateTaxField,\n SelectStateTaxField,\n TextStateTaxField,\n} from './fieldComponents'\nimport type { BoundFieldMeta } from './fieldMeta'\nimport type {\n CurrencyStateTaxFieldProps,\n DateStateTaxFieldProps,\n NumberStateTaxFieldProps,\n RadioStateTaxFieldProps,\n SelectStateTaxFieldProps,\n TextStateTaxFieldProps,\n} from './fieldProps'\nimport { snakeCaseToCamelCase } from '@/helpers/formattedStrings'\n\nexport type {\n BaseStateTaxFieldProps,\n StateTaxValidationMessages,\n CurrencyStateTaxFieldProps,\n DateStateTaxFieldProps,\n NumberStateTaxFieldProps,\n RadioStateTaxFieldProps,\n SelectStateTaxFieldProps,\n TextStateTaxFieldProps,\n} from './fieldProps'\n\n// ── Discriminated union surfaced to partners ───────────────────────────\n\n/**\n * Metadata shared by every {@link StateTaxQuestionFieldEntry} variant,\n * independent of which input the question renders.\n *\n * @public\n */\nexport interface SharedQuestionMetadata {\n /** Stable identifier for this question (camelCase form of the API key). */\n questionId: string\n /** API-supplied label; default text for the rendered Field. */\n label: string\n /** API-supplied description (raw HTML, sanitized internally before render). */\n description: string | null\n}\n\n/**\n * A state-tax question that renders as a select (dropdown). Includes read-only\n * question metadata from the API and a bound select field, exposed as\n * `<question.Field />`.\n *\n * @public\n * @group Fields\n */\nexport interface SelectStateTaxQuestion extends SharedQuestionMetadata {\n /** Discriminant identifying the select variant. */\n type: 'select'\n /** Field component pre-bound to this question's API-supplied metadata. */\n Field: ComponentType<SelectStateTaxFieldProps>\n}\n\n/**\n * A state-tax question that renders as a radio group. Includes read-only\n * question metadata from the API and a bound radio field, exposed as\n * `<question.Field />`.\n *\n * @public\n * @group Fields\n */\nexport interface RadioStateTaxQuestion extends SharedQuestionMetadata {\n /** Discriminant identifying the radio variant. */\n type: 'radio'\n /** Field component pre-bound to this question's API-supplied metadata. */\n Field: ComponentType<RadioStateTaxFieldProps>\n}\n\n/**\n * A state-tax question that renders as a single-line text input. Includes\n * read-only question metadata from the API and a bound text field, exposed as\n * `<question.Field />`.\n *\n * @public\n * @group Fields\n */\nexport interface TextStateTaxQuestion extends SharedQuestionMetadata {\n /** Discriminant identifying the text variant. */\n type: 'text'\n /** Field component pre-bound to this question's API-supplied metadata. */\n Field: ComponentType<TextStateTaxFieldProps>\n}\n\n/**\n * A state-tax question that renders as a decimal number input. Includes\n * read-only question metadata from the API and a bound number field, exposed as\n * `<question.Field />`.\n *\n * @public\n * @group Fields\n */\nexport interface NumberStateTaxQuestion extends SharedQuestionMetadata {\n /** Discriminant identifying the number variant. */\n type: 'number'\n /** Field component pre-bound to this question's API-supplied metadata. */\n Field: ComponentType<NumberStateTaxFieldProps>\n}\n\n/**\n * A state-tax question that renders as a currency-formatted number input. Includes\n * read-only question metadata from the API and a bound currency field, exposed as\n * `<question.Field />`.\n *\n * @public\n * @group Fields\n */\nexport interface CurrencyStateTaxQuestion extends SharedQuestionMetadata {\n /** Discriminant identifying the currency variant. */\n type: 'currency'\n /** Field component pre-bound to this question's API-supplied metadata. */\n Field: ComponentType<CurrencyStateTaxFieldProps>\n}\n\n/**\n * A state-tax question that renders as a date picker. Includes read-only\n * question metadata from the API and a bound date field, exposed as\n * `<question.Field />`.\n *\n * @public\n * @group Fields\n */\nexport interface DateStateTaxQuestion extends SharedQuestionMetadata {\n /** Discriminant identifying the date variant. */\n type: 'date'\n /** Field component pre-bound to this question's API-supplied metadata. */\n Field: ComponentType<DateStateTaxFieldProps>\n}\n\n/**\n * One question entry within a {@link StateTaxFieldsGroup}, discriminated by\n * `type` to identify which input variant the question uses. Each entry carries\n * a `Field` component pre-bound to its API-supplied metadata so callers can\n * render the input directly.\n *\n * @public\n * @group Fields\n * @groupWith {@link StateTaxFieldsGroup}\n */\nexport type StateTaxQuestionFieldEntry =\n | SelectStateTaxQuestion\n | RadioStateTaxQuestion\n | TextStateTaxQuestion\n | NumberStateTaxQuestion\n | CurrencyStateTaxQuestion\n | DateStateTaxQuestion\n\n/**\n * Group of state-tax questions for a single jurisdiction returned by\n * {@link useStateFields}.\n *\n * @public\n * @group Fields\n * @groupWith {@link StateTaxFields}\n */\nexport interface StateTaxFieldsGroup {\n /** Two-letter state code. */\n state: string\n /** Ordered list of question entries for this state, post admin-only filtering. */\n questions: StateTaxQuestionFieldEntry[]\n}\n\n/**\n * Iterable, render-ready group + question entries with bound Field components,\n * grouped by state.\n *\n * @public\n *\n * @example\n * The value exposed on `form.Fields`: one entry per state, each carrying its\n * questions as pre-bound `Field` components you render directly.\n *\n * ```tsx\n * function StateTaxQuestions({ fields }: { fields: StateTaxFields }) {\n * return fields.map(group => (\n * <section key={group.state}>\n * <h3>{group.state}</h3>\n * {group.questions.map(question => (\n * <question.Field key={question.questionId} />\n * ))}\n * </section>\n * ))\n * }\n * ```\n */\nexport type StateTaxFields = StateTaxFieldsGroup[]\n\n// ── Factory ────────────────────────────────────────────────────────────\n\n/** @internal */\nexport interface CreateStateFieldsOptions {\n isAdmin: boolean\n}\n\n/** @internal */\nexport function createStateFields(\n employeeStateTaxes: EmployeeStateTaxesList[],\n options: CreateStateFieldsOptions,\n): StateTaxFieldsGroup[] {\n const { isAdmin } = options\n const groups: StateTaxFieldsGroup[] = []\n\n for (const stateGroup of employeeStateTaxes) {\n if (!stateGroup.state || !stateGroup.questions) continue\n\n const questions: StateTaxQuestionFieldEntry[] = []\n for (const question of stateGroup.questions) {\n if (question.isQuestionForAdminOnly && !isAdmin) continue\n\n const formKey = snakeCaseToCamelCase(question.key)\n const meta: BoundFieldMeta = {\n name: `states.${stateGroup.state}.${formKey}`,\n apiLabel: question.label,\n apiDescription: question.description,\n }\n const variant = getQuestionVariant(question)\n const shared: SharedQuestionMetadata = {\n questionId: formKey,\n label: question.label,\n description: question.description,\n }\n\n questions.push(buildEntry(variant, meta, shared))\n }\n\n if (questions.length === 0) continue\n\n groups.push({\n state: stateGroup.state,\n questions,\n })\n }\n\n return groups\n}\n\nfunction buildEntry(\n variant: StateTaxQuestionVariant,\n meta: BoundFieldMeta,\n shared: SharedQuestionMetadata,\n): StateTaxQuestionFieldEntry {\n switch (variant) {\n case 'select':\n return {\n type: 'select',\n Field: function BoundSelectStateTaxField(props: SelectStateTaxFieldProps) {\n return <SelectStateTaxField meta={meta} {...props} />\n },\n ...shared,\n }\n case 'radio':\n return {\n type: 'radio',\n Field: function BoundRadioStateTaxField(props: RadioStateTaxFieldProps) {\n return <RadioStateTaxField meta={meta} {...props} />\n },\n ...shared,\n }\n case 'text':\n return {\n type: 'text',\n Field: function BoundTextStateTaxField(props: TextStateTaxFieldProps) {\n return <TextStateTaxField meta={meta} {...props} />\n },\n ...shared,\n }\n case 'number':\n return {\n type: 'number',\n Field: function BoundNumberStateTaxField(props: NumberStateTaxFieldProps) {\n return <NumberStateTaxField meta={meta} {...props} />\n },\n ...shared,\n }\n case 'currency':\n return {\n type: 'currency',\n Field: function BoundCurrencyStateTaxField(props: CurrencyStateTaxFieldProps) {\n return <CurrencyStateTaxField meta={meta} {...props} />\n },\n ...shared,\n }\n case 'date':\n return {\n type: 'date',\n Field: function BoundDateStateTaxField(props: DateStateTaxFieldProps) {\n return <DateStateTaxField meta={meta} {...props} />\n },\n ...shared,\n }\n }\n}\n\n/**\n * Memoizes the bound field components for a state-taxes form, avoiding unnecessary rebuilds when the data refetches but the underlying questions haven't changed.\n *\n * @param employeeStateTaxes - Array of state-tax groups returned by the employee state-taxes API.\n * @param isAdmin - When `true`, admin-only questions are included; when `false`, they are filtered out.\n * @returns An array of {@link StateTaxFieldsGroup} — one entry per state, each with a `questions` array of bound field components.\n * @public\n * @group Utility hooks\n */\nexport function useStateFields(\n employeeStateTaxes: EmployeeStateTaxesList[],\n isAdmin: boolean,\n): StateTaxFieldsGroup[] {\n return useMemo(\n () => createStateFields(employeeStateTaxes, { isAdmin }),\n [employeeStateTaxes, isAdmin],\n )\n}\n"],"names":["createStateFields","employeeStateTaxes","options","isAdmin","groups","stateGroup","questions","question","formKey","snakeCaseToCamelCase","meta","variant","getQuestionVariant","shared","buildEntry","props","jsx","SelectStateTaxField","RadioStateTaxField","TextStateTaxField","NumberStateTaxField","CurrencyStateTaxField","DateStateTaxField","useStateFields","useMemo"],"mappings":";;;;;AA+MO,SAASA,EACdC,GACAC,GACuB;AACvB,QAAM,EAAE,SAAAC,MAAYD,GACdE,IAAgC,CAAA;AAEtC,aAAWC,KAAcJ,GAAoB;AAC3C,QAAI,CAACI,EAAW,SAAS,CAACA,EAAW,UAAW;AAEhD,UAAMC,IAA0C,CAAA;AAChD,eAAWC,KAAYF,EAAW,WAAW;AAC3C,UAAIE,EAAS,0BAA0B,CAACJ,EAAS;AAEjD,YAAMK,IAAUC,EAAqBF,EAAS,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AAAV,GAAa,GAAGK,EAAA,CAAO;AAAA,QACrD;AAAA,QACA,GAAGF;AAAA,MAAA;AAAA,IAEP,KAAK;AACH,aAAO;AAAA,QACL,MAAM;AAAA,QACN,OAAO,SAAoCE,GAAmC;AAC5E,iBAAO,gBAAAC,EAACK,GAAA,EAAsB,MAAAX,GAAa,GAAGK,EAAA,CAAO;AAAA,QACvD;AAAA,QACA,GAAGF;AAAA,MAAA;AAAA,IAEP,KAAK;AACH,aAAO;AAAA,QACL,MAAM;AAAA,QACN,OAAO,SAAgCE,GAA+B;AACpE,iBAAO,gBAAAC,EAACM,GAAA,EAAkB,MAAAZ,GAAa,GAAGK,EAAA,CAAO;AAAA,QACnD;AAAA,QACA,GAAGF;AAAA,MAAA;AAAA,EACL;AAEN;AAWO,SAASU,EACdtB,GACAE,GACuB;AACvB,SAAOqB;AAAA,IACL,MAAMxB,EAAkBC,GAAoB,EAAE,SAAAE,GAAS;AAAA,IACvD,CAACF,GAAoBE,CAAO;AAAA,EAAA;AAEhC;"}
|
|
1
|
+
{"version":3,"file":"fields.js","sources":["../../../../../../src/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fields.tsx"],"sourcesContent":["import type { ComponentType } from 'react'\nimport { useMemo } from 'react'\nimport type { EmployeeStateTaxesList } from '@gusto/embedded-api/models/components/employeestatetaxeslist'\nimport { getQuestionVariant, type StateTaxQuestionVariant } from './fieldMapping'\nimport {\n CurrencyStateTaxField,\n DateStateTaxField,\n NumberStateTaxField,\n RadioStateTaxField,\n SelectStateTaxField,\n TextStateTaxField,\n} from './fieldComponents'\nimport type { BoundFieldMeta } from './fieldMeta'\nimport type {\n CurrencyStateTaxFieldProps,\n DateStateTaxFieldProps,\n NumberStateTaxFieldProps,\n RadioStateTaxFieldProps,\n SelectStateTaxFieldProps,\n TextStateTaxFieldProps,\n} from './fieldProps'\nimport { snakeCaseToCamelCase } from '@/helpers/formattedStrings'\n\nexport type {\n BaseStateTaxFieldProps,\n StateTaxValidationMessages,\n CurrencyStateTaxFieldProps,\n DateStateTaxFieldProps,\n NumberStateTaxFieldProps,\n RadioStateTaxFieldProps,\n SelectStateTaxFieldProps,\n TextStateTaxFieldProps,\n} from './fieldProps'\n\n// ── Discriminated union surfaced to partners ───────────────────────────\n\n/**\n * Metadata shared by every {@link StateTaxQuestionFieldEntry} variant,\n * independent of which input the question renders.\n *\n * @public\n */\nexport interface SharedQuestionMetadata {\n /** Stable identifier for this question (camelCase form of the API key). */\n questionId: string\n /** API-supplied label; default text for the rendered Field. */\n label: string\n /** API-supplied description (raw HTML, sanitized internally before render). */\n description: string | null\n}\n\n/**\n * A state-tax question that renders as a select (dropdown). Includes read-only\n * question metadata from the API and a bound select field, exposed as\n * `<question.Field />`.\n *\n * @public\n * @group Fields\n */\nexport interface SelectStateTaxQuestion extends SharedQuestionMetadata {\n /** Discriminant identifying the select variant. */\n type: 'select'\n /** Field component pre-bound to this question's API-supplied metadata. */\n Field: ComponentType<SelectStateTaxFieldProps>\n}\n\n/**\n * A state-tax question that renders as a radio group. Includes read-only\n * question metadata from the API and a bound radio field, exposed as\n * `<question.Field />`.\n *\n * @public\n * @group Fields\n */\nexport interface RadioStateTaxQuestion extends SharedQuestionMetadata {\n /** Discriminant identifying the radio variant. */\n type: 'radio'\n /** Field component pre-bound to this question's API-supplied metadata. */\n Field: ComponentType<RadioStateTaxFieldProps>\n}\n\n/**\n * A state-tax question that renders as a single-line text input. Includes\n * read-only question metadata from the API and a bound text field, exposed as\n * `<question.Field />`.\n *\n * @public\n * @group Fields\n */\nexport interface TextStateTaxQuestion extends SharedQuestionMetadata {\n /** Discriminant identifying the text variant. */\n type: 'text'\n /** Field component pre-bound to this question's API-supplied metadata. */\n Field: ComponentType<TextStateTaxFieldProps>\n}\n\n/**\n * A state-tax question that renders as a decimal number input. Includes\n * read-only question metadata from the API and a bound number field, exposed as\n * `<question.Field />`.\n *\n * @public\n * @group Fields\n */\nexport interface NumberStateTaxQuestion extends SharedQuestionMetadata {\n /** Discriminant identifying the number variant. */\n type: 'number'\n /** Field component pre-bound to this question's API-supplied metadata. */\n Field: ComponentType<NumberStateTaxFieldProps>\n}\n\n/**\n * A state-tax question that renders as a currency-formatted number input. Includes\n * read-only question metadata from the API and a bound currency field, exposed as\n * `<question.Field />`.\n *\n * @public\n * @group Fields\n */\nexport interface CurrencyStateTaxQuestion extends SharedQuestionMetadata {\n /** Discriminant identifying the currency variant. */\n type: 'currency'\n /** Field component pre-bound to this question's API-supplied metadata. */\n Field: ComponentType<CurrencyStateTaxFieldProps>\n}\n\n/**\n * A state-tax question that renders as a date picker. Includes read-only\n * question metadata from the API and a bound date field, exposed as\n * `<question.Field />`.\n *\n * @public\n * @group Fields\n */\nexport interface DateStateTaxQuestion extends SharedQuestionMetadata {\n /** Discriminant identifying the date variant. */\n type: 'date'\n /** Field component pre-bound to this question's API-supplied metadata. */\n Field: ComponentType<DateStateTaxFieldProps>\n}\n\n/**\n * One question entry within a {@link StateTaxFieldsGroup}, discriminated by\n * `type` to identify which input variant the question uses. Each entry carries\n * a `Field` component pre-bound to its API-supplied metadata so callers can\n * render the input directly.\n *\n * @public\n * @group Fields\n * @siblingOf {@link StateTaxFieldsGroup}\n */\nexport type StateTaxQuestionFieldEntry =\n | SelectStateTaxQuestion\n | RadioStateTaxQuestion\n | TextStateTaxQuestion\n | NumberStateTaxQuestion\n | CurrencyStateTaxQuestion\n | DateStateTaxQuestion\n\n/**\n * Group of state-tax questions for a single jurisdiction returned by\n * {@link useStateFields}.\n *\n * @public\n * @group Fields\n * @siblingOf {@link StateTaxFields}\n */\nexport interface StateTaxFieldsGroup {\n /** Two-letter state code. */\n state: string\n /** Ordered list of question entries for this state, post admin-only filtering. */\n questions: StateTaxQuestionFieldEntry[]\n}\n\n/**\n * Iterable, render-ready group + question entries with bound Field components,\n * grouped by state.\n *\n * @public\n *\n * @example\n * The value exposed on `form.Fields`: one entry per state, each carrying its\n * questions as pre-bound `Field` components you render directly.\n *\n * ```tsx\n * function StateTaxQuestions({ fields }: { fields: StateTaxFields }) {\n * return fields.map(group => (\n * <section key={group.state}>\n * <h3>{group.state}</h3>\n * {group.questions.map(question => (\n * <question.Field key={question.questionId} />\n * ))}\n * </section>\n * ))\n * }\n * ```\n */\nexport type StateTaxFields = StateTaxFieldsGroup[]\n\n// ── Factory ────────────────────────────────────────────────────────────\n\n/** @internal */\nexport interface CreateStateFieldsOptions {\n isAdmin: boolean\n}\n\n/** @internal */\nexport function createStateFields(\n employeeStateTaxes: EmployeeStateTaxesList[],\n options: CreateStateFieldsOptions,\n): StateTaxFieldsGroup[] {\n const { isAdmin } = options\n const groups: StateTaxFieldsGroup[] = []\n\n for (const stateGroup of employeeStateTaxes) {\n if (!stateGroup.state || !stateGroup.questions) continue\n\n const questions: StateTaxQuestionFieldEntry[] = []\n for (const question of stateGroup.questions) {\n if (question.isQuestionForAdminOnly && !isAdmin) continue\n\n const formKey = snakeCaseToCamelCase(question.key)\n const meta: BoundFieldMeta = {\n name: `states.${stateGroup.state}.${formKey}`,\n apiLabel: question.label,\n apiDescription: question.description,\n }\n const variant = getQuestionVariant(question)\n const shared: SharedQuestionMetadata = {\n questionId: formKey,\n label: question.label,\n description: question.description,\n }\n\n questions.push(buildEntry(variant, meta, shared))\n }\n\n if (questions.length === 0) continue\n\n groups.push({\n state: stateGroup.state,\n questions,\n })\n }\n\n return groups\n}\n\nfunction buildEntry(\n variant: StateTaxQuestionVariant,\n meta: BoundFieldMeta,\n shared: SharedQuestionMetadata,\n): StateTaxQuestionFieldEntry {\n switch (variant) {\n case 'select':\n return {\n type: 'select',\n Field: function BoundSelectStateTaxField(props: SelectStateTaxFieldProps) {\n return <SelectStateTaxField meta={meta} {...props} />\n },\n ...shared,\n }\n case 'radio':\n return {\n type: 'radio',\n Field: function BoundRadioStateTaxField(props: RadioStateTaxFieldProps) {\n return <RadioStateTaxField meta={meta} {...props} />\n },\n ...shared,\n }\n case 'text':\n return {\n type: 'text',\n Field: function BoundTextStateTaxField(props: TextStateTaxFieldProps) {\n return <TextStateTaxField meta={meta} {...props} />\n },\n ...shared,\n }\n case 'number':\n return {\n type: 'number',\n Field: function BoundNumberStateTaxField(props: NumberStateTaxFieldProps) {\n return <NumberStateTaxField meta={meta} {...props} />\n },\n ...shared,\n }\n case 'currency':\n return {\n type: 'currency',\n Field: function BoundCurrencyStateTaxField(props: CurrencyStateTaxFieldProps) {\n return <CurrencyStateTaxField meta={meta} {...props} />\n },\n ...shared,\n }\n case 'date':\n return {\n type: 'date',\n Field: function BoundDateStateTaxField(props: DateStateTaxFieldProps) {\n return <DateStateTaxField meta={meta} {...props} />\n },\n ...shared,\n }\n }\n}\n\n/**\n * Memoizes the bound field components for a state-taxes form, avoiding unnecessary rebuilds when the data refetches but the underlying questions haven't changed.\n *\n * @param employeeStateTaxes - Array of state-tax groups returned by the employee state-taxes API.\n * @param isAdmin - When `true`, admin-only questions are included; when `false`, they are filtered out.\n * @returns An array of {@link StateTaxFieldsGroup} — one entry per state, each with a `questions` array of bound field components.\n * @public\n * @group Utility hooks\n */\nexport function useStateFields(\n employeeStateTaxes: EmployeeStateTaxesList[],\n isAdmin: boolean,\n): StateTaxFieldsGroup[] {\n return useMemo(\n () => createStateFields(employeeStateTaxes, { isAdmin }),\n [employeeStateTaxes, isAdmin],\n )\n}\n"],"names":["createStateFields","employeeStateTaxes","options","isAdmin","groups","stateGroup","questions","question","formKey","snakeCaseToCamelCase","meta","variant","getQuestionVariant","shared","buildEntry","props","jsx","SelectStateTaxField","RadioStateTaxField","TextStateTaxField","NumberStateTaxField","CurrencyStateTaxField","DateStateTaxField","useStateFields","useMemo"],"mappings":";;;;;AA+MO,SAASA,EACdC,GACAC,GACuB;AACvB,QAAM,EAAE,SAAAC,MAAYD,GACdE,IAAgC,CAAA;AAEtC,aAAWC,KAAcJ,GAAoB;AAC3C,QAAI,CAACI,EAAW,SAAS,CAACA,EAAW,UAAW;AAEhD,UAAMC,IAA0C,CAAA;AAChD,eAAWC,KAAYF,EAAW,WAAW;AAC3C,UAA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ACN,OAAO,SAAkCE,GAAiC;AACxE,iBAAO,gBAAAC,EAACI,GAAA,EAAoB,MAAAV,GAAa,GAAGK,EAAA,CAAO;AAAA,QACrD;AAAA,QACA,GAAGF;AAAA,MAAA;AAAA,IAEP,KAAK;AACH,aAAO;AAAA,QACL,MAAM;AAAA,QACN,OAAO,SAAoCE,GAAmC;AAC5E,iBAAO,gBAAAC,EAACK,GAAA,EAAsB,MAAAX,GAAa,GAAGK,EAAA,CAAO;AAAA,QACvD;AAAA,QACA,GAAGF;AAAA,MAAA;AAAA,IAEP,KAAK;AACH,aAAO;AAAA,QACL,MAAM;AAAA,QACN,OAAO,SAAgCE,GAA+B;AACpE,iBAAO,gBAAAC,EAACM,GAAA,EAAkB,MAAAZ,GAAa,GAAGK,EAAA,CAAO;AAAA,QACnD;AAAA,QACA,GAAGF;AAAA,MAAA;AAAA,EACL;AAEN;AAWO,SAASU,EACdtB,GACAE,GACuB;AACvB,SAAOqB;AAAA,IACL,MAAMxB,EAAkBC,GAAoB,EAAE,SAAAE,GAAS;AAAA,IACvD,CAACF,GAAoBE,CAAO;AAAA,EAAA;AAEhC;"}
|
|
@@ -11,11 +11,13 @@ import "@gusto/embedded-api/models/errors/apierror";
|
|
|
11
11
|
import "@gusto/embedded-api/models/errors/gustoembeddederror";
|
|
12
12
|
import "@gusto/embedded-api/models/errors/sdkvalidationerror";
|
|
13
13
|
import "@gusto/embedded-api/models/errors/httpclienterrors";
|
|
14
|
+
import "dompurify";
|
|
15
|
+
import "../../contexts/LocaleProvider/useLocale.js";
|
|
14
16
|
import "../../shared/constants.js";
|
|
15
17
|
import "../../contexts/ComponentAdapter/useComponentContext.js";
|
|
16
18
|
import "../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
17
19
|
import { retryAsync as x } from "../../helpers/retryAsync.js";
|
|
18
|
-
const q = 4, v = 1500, B = (e) => e instanceof T ? e.errors.some((r) => r.category === "invalid_operation") : !1,
|
|
20
|
+
const q = 4, v = 1500, B = (e) => e instanceof T ? e.errors.some((r) => r.category === "invalid_operation") : !1, $ = ({
|
|
19
21
|
companyId: e,
|
|
20
22
|
payrollId: r,
|
|
21
23
|
employeeUuids: a,
|
|
@@ -31,7 +33,7 @@ const q = 4, v = 1500, B = (e) => e instanceof T ? e.errors.some((r) => r.catego
|
|
|
31
33
|
enabled: !!o?.payPeriod?.payScheduleUuid
|
|
32
34
|
}
|
|
33
35
|
), P = y(async () => {
|
|
34
|
-
const
|
|
36
|
+
const s = await p({
|
|
35
37
|
request: {
|
|
36
38
|
companyId: e,
|
|
37
39
|
payrollId: r,
|
|
@@ -41,8 +43,8 @@ const q = 4, v = 1500, B = (e) => e instanceof T ? e.errors.some((r) => r.catego
|
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
});
|
|
44
|
-
f(
|
|
45
|
-
}, [e, r, p, h, n, l]),
|
|
46
|
+
f(s.payrollPrepared), s.payrollPrepared && (t.current = !0, l?.(s.payrollPrepared));
|
|
47
|
+
}, [e, r, p, h, n, l]), i = y(async () => {
|
|
46
48
|
await d(
|
|
47
49
|
null,
|
|
48
50
|
() => x(P, {
|
|
@@ -53,11 +55,11 @@ const q = 4, v = 1500, B = (e) => e instanceof T ? e.errors.some((r) => r.catego
|
|
|
53
55
|
);
|
|
54
56
|
}, [d, P]);
|
|
55
57
|
b(() => {
|
|
56
|
-
u.current || (u.current = !0,
|
|
57
|
-
}, [
|
|
58
|
+
u.current || (u.current = !0, i());
|
|
59
|
+
}, [i]);
|
|
58
60
|
const g = c && !t.current, R = c && t.current, A = g || E;
|
|
59
61
|
return {
|
|
60
|
-
handlePreparePayroll:
|
|
62
|
+
handlePreparePayroll: i,
|
|
61
63
|
preparedPayroll: o,
|
|
62
64
|
paySchedule: S?.payScheduleShow,
|
|
63
65
|
isLoading: A,
|
|
@@ -66,6 +68,6 @@ const q = 4, v = 1500, B = (e) => e instanceof T ? e.errors.some((r) => r.catego
|
|
|
66
68
|
};
|
|
67
69
|
};
|
|
68
70
|
export {
|
|
69
|
-
|
|
71
|
+
$ as usePreparedPayrollData
|
|
70
72
|
};
|
|
71
73
|
//# sourceMappingURL=usePreparedPayrollData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePreparedPayrollData.js","sources":["../../../src/components/Payroll/usePreparedPayrollData.ts"],"sourcesContent":["import { useState, useEffect, useCallback, useRef, useMemo } from 'react'\nimport { usePayrollsPrepareMutation } from '@gusto/embedded-api/react-query/payrollsPrepare'\nimport { usePaySchedulesGet } from '@gusto/embedded-api/react-query/paySchedulesGet'\nimport type { PayrollPrepared } from '@gusto/embedded-api/models/components/payrollshow'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payscheduleshow'\nimport { UnprocessableEntityError } from '@gusto/embedded-api/models/errors/unprocessableentityerror'\nimport { useBase } from '../Base'\nimport { retryAsync } from '@/helpers/retryAsync'\n\ninterface UsePreparedPayrollDataParams {\n companyId: string\n payrollId: string\n employeeUuids?: string[]\n sortBy?: string\n onDataReady?: (preparedPayroll: PayrollPrepared) => void\n}\n\ninterface UsePreparedPayrollDataReturn {\n handlePreparePayroll: () => Promise<void>\n preparedPayroll: PayrollPrepared | undefined\n paySchedule: PayScheduleShow | undefined\n isLoading: boolean\n isPaginating: boolean\n hasInitialData: boolean\n}\n\nconst PREPARE_MAX_ATTEMPTS = 4\nconst PREPARE_RETRY_DELAY_MS = 1500\n\nconst isPayrollBeingProcessedError = (error: unknown): boolean => {\n if (!(error instanceof UnprocessableEntityError)) return false\n return error.errors.some(e => e.category === 'invalid_operation')\n}\n\n/**\n * Wraps the prepare-payroll mutation and pay-schedule fetch, retrying while the payroll is still being processed.\n *\n * @remarks\n * Fires the prepare call once on mount, then exposes `handlePreparePayroll` for callers that need to re-prepare\n * (e.g. after sort or pagination changes). Distinguishes initial loading from subsequent pagination via\n * `isLoading` and `isPaginating`, and surfaces the pay schedule for the prepared payroll's pay period.\n *\n * @param params - The company and payroll identifiers, plus optional employee filter, sort, and ready callback.\n * @returns The prepared payroll, its pay schedule, loading flags, and a `handlePreparePayroll` callback to re-run.\n * @internal\n */\nexport const usePreparedPayrollData = ({\n companyId,\n payrollId,\n employeeUuids,\n sortBy,\n onDataReady,\n}: UsePreparedPayrollDataParams): UsePreparedPayrollDataReturn => {\n const { mutateAsync: preparePayroll, isPending: isPreparePayrollPending } =\n usePayrollsPrepareMutation()\n const [preparedPayroll, setPreparedPayroll] = useState<PayrollPrepared | undefined>()\n const hasInitialDataRef = useRef(false)\n const hasFiredRef = useRef(false)\n const { baseSubmitHandler } = useBase()\n\n const employeeUuidsKey = useMemo(() => employeeUuids?.join(',') ?? '', [employeeUuids])\n\n const { data: payScheduleData, isLoading: isPayScheduleLoading } = usePaySchedulesGet(\n {\n companyId,\n payScheduleId: preparedPayroll?.payPeriod?.payScheduleUuid || '',\n },\n {\n enabled: !!preparedPayroll?.payPeriod?.payScheduleUuid,\n },\n )\n\n const executePrepare = useCallback(async () => {\n const result = await preparePayroll({\n request: {\n companyId,\n payrollId,\n sortBy,\n requestBody: {\n employeeUuids,\n },\n },\n })\n setPreparedPayroll(result.payrollPrepared)\n if (result.payrollPrepared) {\n hasInitialDataRef.current = true\n onDataReady?.(result.payrollPrepared)\n }\n }, [companyId, payrollId, preparePayroll, employeeUuidsKey, sortBy, onDataReady])\n\n const handlePreparePayroll = useCallback(async () => {\n await baseSubmitHandler(null, () =>\n retryAsync(executePrepare, {\n maxAttempts: PREPARE_MAX_ATTEMPTS,\n delayMs: PREPARE_RETRY_DELAY_MS,\n shouldRetry: isPayrollBeingProcessedError,\n }),\n )\n }, [baseSubmitHandler, executePrepare])\n\n useEffect(() => {\n if (hasFiredRef.current) return\n hasFiredRef.current = true\n void handlePreparePayroll()\n }, [handlePreparePayroll])\n\n const isInitialLoading = isPreparePayrollPending && !hasInitialDataRef.current\n const isPaginating = isPreparePayrollPending && hasInitialDataRef.current\n const isLoading = isInitialLoading || isPayScheduleLoading\n\n return {\n handlePreparePayroll,\n preparedPayroll,\n paySchedule: payScheduleData?.payScheduleShow,\n isLoading,\n isPaginating,\n hasInitialData: hasInitialDataRef.current,\n }\n}\n"],"names":["PREPARE_MAX_ATTEMPTS","PREPARE_RETRY_DELAY_MS","isPayrollBeingProcessedError","error","UnprocessableEntityError","e","usePreparedPayrollData","companyId","payrollId","employeeUuids","sortBy","onDataReady","preparePayroll","isPreparePayrollPending","usePayrollsPrepareMutation","preparedPayroll","setPreparedPayroll","useState","hasInitialDataRef","useRef","hasFiredRef","baseSubmitHandler","useBase","employeeUuidsKey","useMemo","payScheduleData","isPayScheduleLoading","usePaySchedulesGet","executePrepare","useCallback","result","handlePreparePayroll","retryAsync","useEffect","isInitialLoading","isPaginating","isLoading"],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePreparedPayrollData.js","sources":["../../../src/components/Payroll/usePreparedPayrollData.ts"],"sourcesContent":["import { useState, useEffect, useCallback, useRef, useMemo } from 'react'\nimport { usePayrollsPrepareMutation } from '@gusto/embedded-api/react-query/payrollsPrepare'\nimport { usePaySchedulesGet } from '@gusto/embedded-api/react-query/paySchedulesGet'\nimport type { PayrollPrepared } from '@gusto/embedded-api/models/components/payrollshow'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payscheduleshow'\nimport { UnprocessableEntityError } from '@gusto/embedded-api/models/errors/unprocessableentityerror'\nimport { useBase } from '../Base'\nimport { retryAsync } from '@/helpers/retryAsync'\n\ninterface UsePreparedPayrollDataParams {\n companyId: string\n payrollId: string\n employeeUuids?: string[]\n sortBy?: string\n onDataReady?: (preparedPayroll: PayrollPrepared) => void\n}\n\ninterface UsePreparedPayrollDataReturn {\n handlePreparePayroll: () => Promise<void>\n preparedPayroll: PayrollPrepared | undefined\n paySchedule: PayScheduleShow | undefined\n isLoading: boolean\n isPaginating: boolean\n hasInitialData: boolean\n}\n\nconst PREPARE_MAX_ATTEMPTS = 4\nconst PREPARE_RETRY_DELAY_MS = 1500\n\nconst isPayrollBeingProcessedError = (error: unknown): boolean => {\n if (!(error instanceof UnprocessableEntityError)) return false\n return error.errors.some(e => e.category === 'invalid_operation')\n}\n\n/**\n * Wraps the prepare-payroll mutation and pay-schedule fetch, retrying while the payroll is still being processed.\n *\n * @remarks\n * Fires the prepare call once on mount, then exposes `handlePreparePayroll` for callers that need to re-prepare\n * (e.g. after sort or pagination changes). Distinguishes initial loading from subsequent pagination via\n * `isLoading` and `isPaginating`, and surfaces the pay schedule for the prepared payroll's pay period.\n *\n * @param params - The company and payroll identifiers, plus optional employee filter, sort, and ready callback.\n * @returns The prepared payroll, its pay schedule, loading flags, and a `handlePreparePayroll` callback to re-run.\n * @internal\n */\nexport const usePreparedPayrollData = ({\n companyId,\n payrollId,\n employeeUuids,\n sortBy,\n onDataReady,\n}: UsePreparedPayrollDataParams): UsePreparedPayrollDataReturn => {\n const { mutateAsync: preparePayroll, isPending: isPreparePayrollPending } =\n usePayrollsPrepareMutation()\n const [preparedPayroll, setPreparedPayroll] = useState<PayrollPrepared | undefined>()\n const hasInitialDataRef = useRef(false)\n const hasFiredRef = useRef(false)\n const { baseSubmitHandler } = useBase()\n\n const employeeUuidsKey = useMemo(() => employeeUuids?.join(',') ?? '', [employeeUuids])\n\n const { data: payScheduleData, isLoading: isPayScheduleLoading } = usePaySchedulesGet(\n {\n companyId,\n payScheduleId: preparedPayroll?.payPeriod?.payScheduleUuid || '',\n },\n {\n enabled: !!preparedPayroll?.payPeriod?.payScheduleUuid,\n },\n )\n\n const executePrepare = useCallback(async () => {\n const result = await preparePayroll({\n request: {\n companyId,\n payrollId,\n sortBy,\n requestBody: {\n employeeUuids,\n },\n },\n })\n setPreparedPayroll(result.payrollPrepared)\n if (result.payrollPrepared) {\n hasInitialDataRef.current = true\n onDataReady?.(result.payrollPrepared)\n }\n }, [companyId, payrollId, preparePayroll, employeeUuidsKey, sortBy, onDataReady])\n\n const handlePreparePayroll = useCallback(async () => {\n await baseSubmitHandler(null, () =>\n retryAsync(executePrepare, {\n maxAttempts: PREPARE_MAX_ATTEMPTS,\n delayMs: PREPARE_RETRY_DELAY_MS,\n shouldRetry: isPayrollBeingProcessedError,\n }),\n )\n }, [baseSubmitHandler, executePrepare])\n\n useEffect(() => {\n if (hasFiredRef.current) return\n hasFiredRef.current = true\n void handlePreparePayroll()\n }, [handlePreparePayroll])\n\n const isInitialLoading = isPreparePayrollPending && !hasInitialDataRef.current\n const isPaginating = isPreparePayrollPending && hasInitialDataRef.current\n const isLoading = isInitialLoading || isPayScheduleLoading\n\n return {\n handlePreparePayroll,\n preparedPayroll,\n paySchedule: payScheduleData?.payScheduleShow,\n isLoading,\n isPaginating,\n hasInitialData: hasInitialDataRef.current,\n }\n}\n"],"names":["PREPARE_MAX_ATTEMPTS","PREPARE_RETRY_DELAY_MS","isPayrollBeingProcessedError","error","UnprocessableEntityError","e","usePreparedPayrollData","companyId","payrollId","employeeUuids","sortBy","onDataReady","preparePayroll","isPreparePayrollPending","usePayrollsPrepareMutation","preparedPayroll","setPreparedPayroll","useState","hasInitialDataRef","useRef","hasFiredRef","baseSubmitHandler","useBase","employeeUuidsKey","useMemo","payScheduleData","isPayScheduleLoading","usePaySchedulesGet","executePrepare","useCallback","result","handlePreparePayroll","retryAsync","useEffect","isInitialLoading","isPaginating","isLoading"],"mappings":";;;;;;;;;;;;;;;;;;;AA0BA,MAAMA,IAAuB,GACvBC,IAAyB,MAEzBC,IAA+B,CAACC,MAC9BA,aAAiBC,IAChBD,EAAM,OAAO,KAAK,CAAAE,MAAKA,EAAE,aAAa,mBAAmB,IADP,IAgB9CC,IAAyB,CAAC;AAAA,EACrC,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAAC;AAAA,EACA,QAAAC;AAAA,EACA,aAAAC;AACF,MAAkE;AAChE,QAAM,EAAE,aAAaC,GAAgB,WAAWC,EAAA,IAC9CC,EAAA,GACI,CAACC,GAAiBC,CAAkB,IAAIC,EAAA,GACxCC,IAAoBC,EAAO,EAAK,GAChCC,IAAcD,EAAO,EAAK,GAC1B,EAAE,mBAAAE,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cAAAD;AAAA,IACA,gBAAgBjB,EAAkB;AAAA,EAAA;AAEtC;"}
|
|
@@ -51,7 +51,7 @@ import { PayrollLoadingProps } from '../../components/Common/PayrollLoading/Payr
|
|
|
51
51
|
* which fall back to built-in SDK implementations when omitted.
|
|
52
52
|
*
|
|
53
53
|
* @public
|
|
54
|
-
* @group
|
|
54
|
+
* @group Component adapter
|
|
55
55
|
*
|
|
56
56
|
* @example Partial override with GustoProvider
|
|
57
57
|
* ```tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useComponentContext.js","sources":["../../../src/contexts/ComponentAdapter/useComponentContext.ts"],"sourcesContent":["import { createContext, useContext } from 'react'\nimport type { FunctionComponent } from 'react'\nimport type { TextInputProps } from '@/components/Common/UI/TextInput/TextInputTypes'\nimport type { TextAreaProps } from '@/components/Common/UI/TextArea/TextAreaTypes'\nimport type { NumberInputProps } from '@/components/Common/UI/NumberInput/NumberInputTypes'\nimport type { CheckboxGroupProps } from '@/components/Common/UI/CheckboxGroup/CheckboxGroupTypes'\nimport type { ComboBoxProps } from '@/components/Common/UI/ComboBox/ComboBoxTypes'\nimport type { CheckboxProps } from '@/components/Common/UI/Checkbox/CheckboxTypes'\nimport type { DatePickerProps } from '@/components/Common/UI/DatePicker/DatePickerTypes'\nimport type { RadioProps } from '@/components/Common/UI/Radio/RadioTypes'\nimport type { RadioGroupProps } from '@/components/Common/UI/RadioGroup/RadioGroupTypes'\nimport type { SelectProps } from '@/components/Common/UI/Select/SelectTypes'\nimport type { SwitchProps } from '@/components/Common/UI/Switch/SwitchTypes'\nimport type { ButtonIconProps, ButtonProps } from '@/components/Common/UI/Button/ButtonTypes'\nimport type { AlertProps } from '@/components/Common/UI/Alert/AlertTypes'\nimport type { CardProps } from '@/components/Common/UI/Card/CardTypes'\nimport type { BoxProps } from '@/components/Common/UI/Box/BoxTypes'\nimport type { FormBoxProps } from '@/components/Common/UI/FormBox/FormBoxTypes'\nimport type { LinkProps } from '@/components/Common/UI/Link/LinkTypes'\nimport type { BadgeProps } from '@/components/Common/UI/Badge/BadgeTypes'\nimport type { BannerProps } from '@/components/Common/UI/Banner/BannerTypes'\nimport type { MenuProps } from '@/components/Common/UI/Menu/MenuTypes'\nimport type { TableProps } from '@/components/Common/UI/Table/TableTypes'\nimport type { OrderedListProps, UnorderedListProps } from '@/components/Common/UI/List/ListTypes'\nimport type { HeadingProps } from '@/components/Common/UI/Heading/HeadingTypes'\nimport type { PaginationControlProps } from '@/components/Common/PaginationControl/PaginationControlTypes'\nimport type { TextProps } from '@/components/Common/UI/Text/TextTypes'\nimport type { CalendarPreviewProps } from '@/components/Common/UI/CalendarPreview/CalendarPreviewTypes'\nimport type { DateRangePickerProps } from '@/components/Common/UI/DateRangePicker/DateRangePickerTypes'\nimport type { ProgressBarProps } from '@/components/Common/UI/ProgressBar/ProgressBarTypes'\nimport type { BreadcrumbsProps } from '@/components/Common/UI/Breadcrumbs/BreadcrumbsTypes'\nimport type { TabsProps } from '@/components/Common/UI/Tabs/TabsTypes'\nimport type { DialogProps } from '@/components/Common/UI/Dialog/DialogTypes'\nimport type { ModalProps } from '@/components/Common/UI/Modal/ModalTypes'\nimport type { LoadingSpinnerProps } from '@/components/Common/UI/LoadingSpinner/LoadingSpinnerTypes'\nimport type { DescriptionListProps } from '@/components/Common/UI/DescriptionList/DescriptionListTypes'\nimport type { FileInputProps } from '@/components/Common/UI/FileInput/FileInputTypes'\nimport type { BoxHeaderProps } from '@/components/Common/UI/BoxHeader/BoxHeaderTypes'\nimport type { FormBoxHeaderProps } from '@/components/Common/UI/FormBoxHeader/FormBoxHeaderTypes'\nimport type { MultiSelectComboBoxProps } from '@/components/Common/UI/MultiSelectComboBox/MultiSelectComboBoxTypes'\nimport type { PayrollLoadingProps } from '@/components/Common/PayrollLoading/PayrollLoadingTypes'\n\n/**\n * Full map of UI components used by the SDK. Every property is a React component that the\n * SDK renders internally — override any of them to substitute your own design system.\n *\n * Pass a `Partial<ComponentsContextType>` to {@link GustoProvider} via the `components` prop to\n * replace specific components while keeping SDK defaults for the rest.\n *\n * To take full control of every UI component (and eliminate the React Aria dependency),\n * pass a complete {@link ComponentsContextType} to {@link GustoProviderCustomUIAdapter} instead.\n * All properties are then required except `PaginationControl` and `PayrollLoading`,\n * which fall back to built-in SDK implementations when omitted.\n *\n * @public\n * @group Utility types\n *\n * @example Partial override with GustoProvider\n * ```tsx\n * import { GustoProvider } from '@gusto/embedded-react-sdk'\n *\n * function App() {\n * return (\n * <GustoProvider\n * config={{ baseUrl: '/api/gusto/' }}\n * components={{\n * Button: MyButton,\n * TextInput: MyTextInput,\n * }}\n * >\n * <EmployeeOnboardingFlow companyId=\"company_123\" />\n * </GustoProvider>\n * )\n * }\n * ```\n *\n * @example Full replacement with GustoProviderCustomUIAdapter\n * ```tsx\n * import { GustoProviderCustomUIAdapter, type ComponentsContextType } from '@gusto/embedded-react-sdk'\n *\n * const myComponents: ComponentsContextType = {\n * Alert: props => <MyAlert {...props} />,\n * Button: props => <MyButton {...props} />,\n * // ... all required components\n * }\n *\n * function App() {\n * return (\n * <GustoProviderCustomUIAdapter\n * config={{ baseUrl: '/api/gusto/' }}\n * components={myComponents}\n * >\n * <EmployeeOnboardingFlow companyId=\"company_123\" />\n * </GustoProviderCustomUIAdapter>\n * )\n * }\n * ```\n */\nexport interface ComponentsContextType {\n /** Status message with an optional dismiss action; used for errors, warnings, success, and info. */\n Alert: FunctionComponent<AlertProps>\n /** Small inline label for status, counts, or tags; optionally dismissible. */\n Badge: FunctionComponent<BadgeProps>\n /** Full-width notification banner for prominent warnings and errors. */\n Banner: FunctionComponent<BannerProps>\n /** HTML `<button>` with primary, secondary, tertiary, and error variants. */\n Button: FunctionComponent<ButtonProps>\n /** Icon-only `<button>`; requires `aria-label` since there is no visible text for assistive technologies. */\n ButtonIcon: FunctionComponent<ButtonIconProps>\n /** Sectioned layout container with distinct header, body, and footer areas. */\n Box: FunctionComponent<BoxProps>\n /** Header section of a Box with a title, optional description, and optional inline action. */\n BoxHeader: FunctionComponent<BoxHeaderProps>\n /** Bordered container for grouping related form fields, with an optional header slot. */\n FormBox: FunctionComponent<FormBoxProps>\n /** Header section of a FormBox with a title, optional description, and optional inline action. */\n FormBoxHeader: FunctionComponent<FormBoxHeaderProps>\n /** Read-only calendar for visualizing a date range with optional highlighted dates. */\n CalendarPreview: FunctionComponent<CalendarPreviewProps>\n /** Content container with an optional overflow menu and a leading action slot. */\n Card: FunctionComponent<CardProps>\n /** Form field wrapping a single `<input type=\"checkbox\" />`. */\n Checkbox: FunctionComponent<CheckboxProps>\n /** Form field grouping `<input type=\"checkbox\" />` elements for multi-option selection. */\n CheckboxGroup: FunctionComponent<CheckboxGroupProps>\n /** Form field wrapping a typeahead `<input />` for single-option selection. */\n ComboBox: FunctionComponent<ComboBoxProps>\n /** Form field wrapping an `<input type=\"date\" />` with a calendar picker popover. */\n DatePicker: FunctionComponent<DatePickerProps>\n /** Form field wrapping paired `<input type=\"date\" />` elements for a date range. */\n DateRangePicker: FunctionComponent<DateRangePickerProps>\n /** HTML `<dl>` of term/description pairs in stacked or horizontal layout. */\n DescriptionList: FunctionComponent<DescriptionListProps>\n /** Modal confirmation dialog with a primary action and a cancel action. */\n Dialog: FunctionComponent<DialogProps>\n /** Form field wrapping an `<input type=\"file\" />`. */\n FileInput: FunctionComponent<FileInputProps>\n /** HTML `<h1>`–`<h6>` with visual style controlled independently from semantic level. */\n Heading: FunctionComponent<HeadingProps>\n /** HTML `<a>` for inline navigation. */\n Link: FunctionComponent<LinkProps>\n /** Spinner shown while data or an action is pending. */\n LoadingSpinner: FunctionComponent<LoadingSpinnerProps>\n /** Popover menu of actions anchored to a trigger element. */\n Menu: FunctionComponent<MenuProps>\n /** Overlay modal with customizable body content and footer. */\n Modal: FunctionComponent<ModalProps>\n /** Form field wrapping a typeahead `<input />` for multi-option selection. */\n MultiSelectComboBox: FunctionComponent<MultiSelectComboBoxProps>\n /** Form field wrapping a numeric `<input />` for currency, decimal, or percent values. */\n NumberInput: FunctionComponent<NumberInputProps>\n /** HTML `<ol>` for a numbered list of items. */\n OrderedList: FunctionComponent<OrderedListProps>\n /** Step-based progress indicator for multi-step flows. */\n ProgressBar: FunctionComponent<ProgressBarProps>\n /** Navigation breadcrumb trail showing the user's position in a multi-step flow. */\n Breadcrumbs: FunctionComponent<BreadcrumbsProps>\n /** Form field wrapping a single `<input type=\"radio\" />`. */\n Radio: FunctionComponent<RadioProps>\n /** Form field grouping `<input type=\"radio\" />` elements for single-option selection. */\n RadioGroup: FunctionComponent<RadioGroupProps>\n /** Form field wrapping a single-select dropdown. */\n Select: FunctionComponent<SelectProps>\n /** Form field wrapping an `<input type=\"checkbox\" />` styled as a toggle. */\n Switch: FunctionComponent<SwitchProps>\n /** Tabbed navigation with associated content panels. */\n Tabs: FunctionComponent<TabsProps>\n /** Tabular data display with headers, rows, optional footer, and empty state. */\n Table: FunctionComponent<TableProps>\n /** Body text element rendered as `<p>`, `<span>`, `<div>`, or `<pre>`. */\n Text: FunctionComponent<TextProps>\n /** Form field wrapping an `<input />`. */\n TextInput: FunctionComponent<TextInputProps>\n /** Form field wrapping a `<textarea>`. */\n TextArea: FunctionComponent<TextAreaProps>\n /** HTML `<ul>` for an unordered list of items. */\n UnorderedList: FunctionComponent<UnorderedListProps>\n\n /** Pagination controls for list views. Defaults to the SDK's built-in pagination UI when omitted. */\n PaginationControl?: FunctionComponent<PaginationControlProps>\n /** Loading indicator for payroll calculation. Defaults to the SDK's built-in loading state when omitted. */\n PayrollLoading?: FunctionComponent<PayrollLoadingProps>\n}\n\n/** @internal */\nexport const ComponentsContext = createContext<ComponentsContextType | null>(null)\n\n/** @internal */\nexport const useComponentContext = () => {\n const context = useContext(ComponentsContext)\n if (!context) {\n throw new Error('useComponentContext must be used within a ComponentsProvider')\n }\n return context\n}\n"],"names":["ComponentsContext","createContext","useComponentContext","context","useContext"],"mappings":";AAyLO,MAAMA,IAAoBC,EAA4C,IAAI,GAGpEC,IAAsB,MAAM;AACvC,QAAMC,IAAUC,EAAWJ,CAAiB;AAC5C,MAAI,CAACG;AACH,UAAM,IAAI,MAAM,8DAA8D;AAEhF,SAAOA;AACT;"}
|
|
1
|
+
{"version":3,"file":"useComponentContext.js","sources":["../../../src/contexts/ComponentAdapter/useComponentContext.ts"],"sourcesContent":["import { createContext, useContext } from 'react'\nimport type { FunctionComponent } from 'react'\nimport type { TextInputProps } from '@/components/Common/UI/TextInput/TextInputTypes'\nimport type { TextAreaProps } from '@/components/Common/UI/TextArea/TextAreaTypes'\nimport type { NumberInputProps } from '@/components/Common/UI/NumberInput/NumberInputTypes'\nimport type { CheckboxGroupProps } from '@/components/Common/UI/CheckboxGroup/CheckboxGroupTypes'\nimport type { ComboBoxProps } from '@/components/Common/UI/ComboBox/ComboBoxTypes'\nimport type { CheckboxProps } from '@/components/Common/UI/Checkbox/CheckboxTypes'\nimport type { DatePickerProps } from '@/components/Common/UI/DatePicker/DatePickerTypes'\nimport type { RadioProps } from '@/components/Common/UI/Radio/RadioTypes'\nimport type { RadioGroupProps } from '@/components/Common/UI/RadioGroup/RadioGroupTypes'\nimport type { SelectProps } from '@/components/Common/UI/Select/SelectTypes'\nimport type { SwitchProps } from '@/components/Common/UI/Switch/SwitchTypes'\nimport type { ButtonIconProps, ButtonProps } from '@/components/Common/UI/Button/ButtonTypes'\nimport type { AlertProps } from '@/components/Common/UI/Alert/AlertTypes'\nimport type { CardProps } from '@/components/Common/UI/Card/CardTypes'\nimport type { BoxProps } from '@/components/Common/UI/Box/BoxTypes'\nimport type { FormBoxProps } from '@/components/Common/UI/FormBox/FormBoxTypes'\nimport type { LinkProps } from '@/components/Common/UI/Link/LinkTypes'\nimport type { BadgeProps } from '@/components/Common/UI/Badge/BadgeTypes'\nimport type { BannerProps } from '@/components/Common/UI/Banner/BannerTypes'\nimport type { MenuProps } from '@/components/Common/UI/Menu/MenuTypes'\nimport type { TableProps } from '@/components/Common/UI/Table/TableTypes'\nimport type { OrderedListProps, UnorderedListProps } from '@/components/Common/UI/List/ListTypes'\nimport type { HeadingProps } from '@/components/Common/UI/Heading/HeadingTypes'\nimport type { PaginationControlProps } from '@/components/Common/PaginationControl/PaginationControlTypes'\nimport type { TextProps } from '@/components/Common/UI/Text/TextTypes'\nimport type { CalendarPreviewProps } from '@/components/Common/UI/CalendarPreview/CalendarPreviewTypes'\nimport type { DateRangePickerProps } from '@/components/Common/UI/DateRangePicker/DateRangePickerTypes'\nimport type { ProgressBarProps } from '@/components/Common/UI/ProgressBar/ProgressBarTypes'\nimport type { BreadcrumbsProps } from '@/components/Common/UI/Breadcrumbs/BreadcrumbsTypes'\nimport type { TabsProps } from '@/components/Common/UI/Tabs/TabsTypes'\nimport type { DialogProps } from '@/components/Common/UI/Dialog/DialogTypes'\nimport type { ModalProps } from '@/components/Common/UI/Modal/ModalTypes'\nimport type { LoadingSpinnerProps } from '@/components/Common/UI/LoadingSpinner/LoadingSpinnerTypes'\nimport type { DescriptionListProps } from '@/components/Common/UI/DescriptionList/DescriptionListTypes'\nimport type { FileInputProps } from '@/components/Common/UI/FileInput/FileInputTypes'\nimport type { BoxHeaderProps } from '@/components/Common/UI/BoxHeader/BoxHeaderTypes'\nimport type { FormBoxHeaderProps } from '@/components/Common/UI/FormBoxHeader/FormBoxHeaderTypes'\nimport type { MultiSelectComboBoxProps } from '@/components/Common/UI/MultiSelectComboBox/MultiSelectComboBoxTypes'\nimport type { PayrollLoadingProps } from '@/components/Common/PayrollLoading/PayrollLoadingTypes'\n\n/**\n * Full map of UI components used by the SDK. Every property is a React component that the\n * SDK renders internally — override any of them to substitute your own design system.\n *\n * Pass a `Partial<ComponentsContextType>` to {@link GustoProvider} via the `components` prop to\n * replace specific components while keeping SDK defaults for the rest.\n *\n * To take full control of every UI component (and eliminate the React Aria dependency),\n * pass a complete {@link ComponentsContextType} to {@link GustoProviderCustomUIAdapter} instead.\n * All properties are then required except `PaginationControl` and `PayrollLoading`,\n * which fall back to built-in SDK implementations when omitted.\n *\n * @public\n * @group Component adapter\n *\n * @example Partial override with GustoProvider\n * ```tsx\n * import { GustoProvider } from '@gusto/embedded-react-sdk'\n *\n * function App() {\n * return (\n * <GustoProvider\n * config={{ baseUrl: '/api/gusto/' }}\n * components={{\n * Button: MyButton,\n * TextInput: MyTextInput,\n * }}\n * >\n * <EmployeeOnboardingFlow companyId=\"company_123\" />\n * </GustoProvider>\n * )\n * }\n * ```\n *\n * @example Full replacement with GustoProviderCustomUIAdapter\n * ```tsx\n * import { GustoProviderCustomUIAdapter, type ComponentsContextType } from '@gusto/embedded-react-sdk'\n *\n * const myComponents: ComponentsContextType = {\n * Alert: props => <MyAlert {...props} />,\n * Button: props => <MyButton {...props} />,\n * // ... all required components\n * }\n *\n * function App() {\n * return (\n * <GustoProviderCustomUIAdapter\n * config={{ baseUrl: '/api/gusto/' }}\n * components={myComponents}\n * >\n * <EmployeeOnboardingFlow companyId=\"company_123\" />\n * </GustoProviderCustomUIAdapter>\n * )\n * }\n * ```\n */\nexport interface ComponentsContextType {\n /** Status message with an optional dismiss action; used for errors, warnings, success, and info. */\n Alert: FunctionComponent<AlertProps>\n /** Small inline label for status, counts, or tags; optionally dismissible. */\n Badge: FunctionComponent<BadgeProps>\n /** Full-width notification banner for prominent warnings and errors. */\n Banner: FunctionComponent<BannerProps>\n /** HTML `<button>` with primary, secondary, tertiary, and error variants. */\n Button: FunctionComponent<ButtonProps>\n /** Icon-only `<button>`; requires `aria-label` since there is no visible text for assistive technologies. */\n ButtonIcon: FunctionComponent<ButtonIconProps>\n /** Sectioned layout container with distinct header, body, and footer areas. */\n Box: FunctionComponent<BoxProps>\n /** Header section of a Box with a title, optional description, and optional inline action. */\n BoxHeader: FunctionComponent<BoxHeaderProps>\n /** Bordered container for grouping related form fields, with an optional header slot. */\n FormBox: FunctionComponent<FormBoxProps>\n /** Header section of a FormBox with a title, optional description, and optional inline action. */\n FormBoxHeader: FunctionComponent<FormBoxHeaderProps>\n /** Read-only calendar for visualizing a date range with optional highlighted dates. */\n CalendarPreview: FunctionComponent<CalendarPreviewProps>\n /** Content container with an optional overflow menu and a leading action slot. */\n Card: FunctionComponent<CardProps>\n /** Form field wrapping a single `<input type=\"checkbox\" />`. */\n Checkbox: FunctionComponent<CheckboxProps>\n /** Form field grouping `<input type=\"checkbox\" />` elements for multi-option selection. */\n CheckboxGroup: FunctionComponent<CheckboxGroupProps>\n /** Form field wrapping a typeahead `<input />` for single-option selection. */\n ComboBox: FunctionComponent<ComboBoxProps>\n /** Form field wrapping an `<input type=\"date\" />` with a calendar picker popover. */\n DatePicker: FunctionComponent<DatePickerProps>\n /** Form field wrapping paired `<input type=\"date\" />` elements for a date range. */\n DateRangePicker: FunctionComponent<DateRangePickerProps>\n /** HTML `<dl>` of term/description pairs in stacked or horizontal layout. */\n DescriptionList: FunctionComponent<DescriptionListProps>\n /** Modal confirmation dialog with a primary action and a cancel action. */\n Dialog: FunctionComponent<DialogProps>\n /** Form field wrapping an `<input type=\"file\" />`. */\n FileInput: FunctionComponent<FileInputProps>\n /** HTML `<h1>`–`<h6>` with visual style controlled independently from semantic level. */\n Heading: FunctionComponent<HeadingProps>\n /** HTML `<a>` for inline navigation. */\n Link: FunctionComponent<LinkProps>\n /** Spinner shown while data or an action is pending. */\n LoadingSpinner: FunctionComponent<LoadingSpinnerProps>\n /** Popover menu of actions anchored to a trigger element. */\n Menu: FunctionComponent<MenuProps>\n /** Overlay modal with customizable body content and footer. */\n Modal: FunctionComponent<ModalProps>\n /** Form field wrapping a typeahead `<input />` for multi-option selection. */\n MultiSelectComboBox: FunctionComponent<MultiSelectComboBoxProps>\n /** Form field wrapping a numeric `<input />` for currency, decimal, or percent values. */\n NumberInput: FunctionComponent<NumberInputProps>\n /** HTML `<ol>` for a numbered list of items. */\n OrderedList: FunctionComponent<OrderedListProps>\n /** Step-based progress indicator for multi-step flows. */\n ProgressBar: FunctionComponent<ProgressBarProps>\n /** Navigation breadcrumb trail showing the user's position in a multi-step flow. */\n Breadcrumbs: FunctionComponent<BreadcrumbsProps>\n /** Form field wrapping a single `<input type=\"radio\" />`. */\n Radio: FunctionComponent<RadioProps>\n /** Form field grouping `<input type=\"radio\" />` elements for single-option selection. */\n RadioGroup: FunctionComponent<RadioGroupProps>\n /** Form field wrapping a single-select dropdown. */\n Select: FunctionComponent<SelectProps>\n /** Form field wrapping an `<input type=\"checkbox\" />` styled as a toggle. */\n Switch: FunctionComponent<SwitchProps>\n /** Tabbed navigation with associated content panels. */\n Tabs: FunctionComponent<TabsProps>\n /** Tabular data display with headers, rows, optional footer, and empty state. */\n Table: FunctionComponent<TableProps>\n /** Body text element rendered as `<p>`, `<span>`, `<div>`, or `<pre>`. */\n Text: FunctionComponent<TextProps>\n /** Form field wrapping an `<input />`. */\n TextInput: FunctionComponent<TextInputProps>\n /** Form field wrapping a `<textarea>`. */\n TextArea: FunctionComponent<TextAreaProps>\n /** HTML `<ul>` for an unordered list of items. */\n UnorderedList: FunctionComponent<UnorderedListProps>\n\n /** Pagination controls for list views. Defaults to the SDK's built-in pagination UI when omitted. */\n PaginationControl?: FunctionComponent<PaginationControlProps>\n /** Loading indicator for payroll calculation. Defaults to the SDK's built-in loading state when omitted. */\n PayrollLoading?: FunctionComponent<PayrollLoadingProps>\n}\n\n/** @internal */\nexport const ComponentsContext = createContext<ComponentsContextType | null>(null)\n\n/** @internal */\nexport const useComponentContext = () => {\n const context = useContext(ComponentsContext)\n if (!context) {\n throw new Error('useComponentContext must be used within a ComponentsProvider')\n }\n return context\n}\n"],"names":["ComponentsContext","createContext","useComponentContext","context","useContext"],"mappings":";AAyLO,MAAMA,IAAoBC,EAA4C,IAAI,GAGpEC,IAAsB,MAAM;AACvC,QAAMC,IAAUC,EAAWJ,CAAiB;AAC5C,MAAI,CAACG;AACH,UAAM,IAAI,MAAM,8DAA8D;AAEhF,SAAOA;AACT;"}
|
|
@@ -34,5 +34,6 @@ export interface GustoProviderProps extends Omit<GustoBaseProviderProps, 'compon
|
|
|
34
34
|
* @param props - See {@link GustoProviderProps}.
|
|
35
35
|
* @returns The configured provider tree wrapping `children`.
|
|
36
36
|
* @public
|
|
37
|
+
* @group Providers
|
|
37
38
|
*/
|
|
38
39
|
export declare function GustoProvider(props: GustoProviderProps): React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GustoProvider.js","sources":["../../../src/contexts/GustoProvider/GustoProvider.tsx"],"sourcesContent":["import type React from 'react'\n// GustoProvider uses react-aria as the default components so we need to include the react-aria I18nProvider here.\n// For use without react-aria, the GustoProviderCustomUIAdapter can be used which does not includes it.\n// eslint-disable-next-line no-restricted-imports\nimport { I18nProvider } from 'react-aria-components'\nimport type { QueryClient } from '@tanstack/react-query'\nimport { createComponents } from '../ComponentAdapter/createComponentsWithDefaults'\nimport type { ComponentsContextType } from '../ComponentAdapter/useComponentContext'\nimport type { GustoBaseProviderProps } from './GustoProviderCustomUIAdapter'\nimport { GustoProviderCustomUIAdapter } from './GustoProviderCustomUIAdapter'\n\n/**\n * Props for {@link GustoProvider}.\n *\n * @remarks\n * Extends {@link GustoProviderProps} but makes `components` optional and partial: any components\n * you do not supply fall back to the SDK's built-in React Aria implementations.\n *\n * @public\n */\nexport interface GustoProviderProps extends Omit<GustoBaseProviderProps, 'components'> {\n /** Optional TanStack Query `QueryClient` to share with the rest of your app. When omitted, the SDK creates its own client configured for Gusto's API. */\n queryClient?: QueryClient\n /** Partial component overrides. Any component you do not supply uses the SDK's default React Aria implementation. */\n components?: Partial<ComponentsContextType>\n /** The application tree that should have access to the SDK. */\n children?: React.ReactNode\n}\n\n/**\n * Top-level provider that configures the SDK at the application level.\n *\n * @remarks\n * Wrap your application's component tree with `GustoProvider` so that any SDK component below it\n * has access to the API client, theme, locale, translations, and UI components. Components you\n * provide via the `components` prop override the SDK's React Aria defaults; any component you do\n * not supply uses the default.\n *\n * For full UI control without the bundled React Aria defaults, use {@link GustoProviderCustomUIAdapter}\n * instead and supply a complete component map.\n *\n * @param props - See {@link GustoProviderProps}.\n * @returns The configured provider tree wrapping `children`.\n * @public\n */\nexport function GustoProvider(props: GustoProviderProps) {\n const { children, components = {}, locale, queryClient, ...remainingProps } = props\n\n return (\n <GustoProviderCustomUIAdapter\n locale={locale}\n queryClient={queryClient}\n {...remainingProps}\n components={createComponents(components)}\n >\n {/* react-aria locale provider that exposes correct locale to number formatters */}\n <I18nProvider locale={locale}>{children}</I18nProvider>\n </GustoProviderCustomUIAdapter>\n )\n}\n"],"names":["GustoProvider","props","children","components","locale","queryClient","remainingProps","jsx","GustoProviderCustomUIAdapter","createComponents","I18nProvider"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"GustoProvider.js","sources":["../../../src/contexts/GustoProvider/GustoProvider.tsx"],"sourcesContent":["import type React from 'react'\n// GustoProvider uses react-aria as the default components so we need to include the react-aria I18nProvider here.\n// For use without react-aria, the GustoProviderCustomUIAdapter can be used which does not includes it.\n// eslint-disable-next-line no-restricted-imports\nimport { I18nProvider } from 'react-aria-components'\nimport type { QueryClient } from '@tanstack/react-query'\nimport { createComponents } from '../ComponentAdapter/createComponentsWithDefaults'\nimport type { ComponentsContextType } from '../ComponentAdapter/useComponentContext'\nimport type { GustoBaseProviderProps } from './GustoProviderCustomUIAdapter'\nimport { GustoProviderCustomUIAdapter } from './GustoProviderCustomUIAdapter'\n\n/**\n * Props for {@link GustoProvider}.\n *\n * @remarks\n * Extends {@link GustoProviderProps} but makes `components` optional and partial: any components\n * you do not supply fall back to the SDK's built-in React Aria implementations.\n *\n * @public\n */\nexport interface GustoProviderProps extends Omit<GustoBaseProviderProps, 'components'> {\n /** Optional TanStack Query `QueryClient` to share with the rest of your app. When omitted, the SDK creates its own client configured for Gusto's API. */\n queryClient?: QueryClient\n /** Partial component overrides. Any component you do not supply uses the SDK's default React Aria implementation. */\n components?: Partial<ComponentsContextType>\n /** The application tree that should have access to the SDK. */\n children?: React.ReactNode\n}\n\n/**\n * Top-level provider that configures the SDK at the application level.\n *\n * @remarks\n * Wrap your application's component tree with `GustoProvider` so that any SDK component below it\n * has access to the API client, theme, locale, translations, and UI components. Components you\n * provide via the `components` prop override the SDK's React Aria defaults; any component you do\n * not supply uses the default.\n *\n * For full UI control without the bundled React Aria defaults, use {@link GustoProviderCustomUIAdapter}\n * instead and supply a complete component map.\n *\n * @param props - See {@link GustoProviderProps}.\n * @returns The configured provider tree wrapping `children`.\n * @public\n * @group Providers\n */\nexport function GustoProvider(props: GustoProviderProps) {\n const { children, components = {}, locale, queryClient, ...remainingProps } = props\n\n return (\n <GustoProviderCustomUIAdapter\n locale={locale}\n queryClient={queryClient}\n {...remainingProps}\n components={createComponents(components)}\n >\n {/* react-aria locale provider that exposes correct locale to number formatters */}\n <I18nProvider locale={locale}>{children}</I18nProvider>\n </GustoProviderCustomUIAdapter>\n )\n}\n"],"names":["GustoProvider","props","children","components","locale","queryClient","remainingProps","jsx","GustoProviderCustomUIAdapter","createComponents","I18nProvider"],"mappings":";;;;AA8CO,SAASA,EAAcC,GAA2B;AACvD,QAAM,EAAE,UAAAC,GAAU,YAAAC,IAAa,CAAA,GAAI,QAAAC,GAAQ,aAAAC,GAAa,GAAGC,EAAA,IAAmBL;AAE9E,SACE,gBAAAM;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,QAAAJ;AAAA,MACA,aAAAC;AAAA,MACC,GAAGC;AAAA,MACJ,YAAYG,EAAiBN,CAAU;AAAA,MAGvC,UAAA,gBAAAI,EAACG,GAAA,EAAa,QAAAN,GAAiB,UAAAF,EAAA,CAAS;AAAA,IAAA;AAAA,EAAA;AAG9C;"}
|