@gusto/embedded-react-sdk 0.35.0-rc.1 → 0.35.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/dist/components/Common/SignatureForm/SignatureFormFields.js +1 -1
  2. package/dist/components/Company/AssignSignatory/AssignSignatorySelection.js +1 -1
  3. package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.js +12 -12
  4. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +4 -3
  5. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
  6. package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.js +1 -1
  7. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +4 -3
  8. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
  9. package/dist/components/Company/AssignSignatory/useAssignSignatory.js +6 -5
  10. package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
  11. package/dist/components/Company/BankAccount/BankAccountForm/Form.js +1 -1
  12. package/dist/components/Company/BankAccount/BankAccountForm/context.js +4 -3
  13. package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
  14. package/dist/components/Company/BankAccount/BankAccountVerify/Form.js +1 -1
  15. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +4 -3
  16. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  17. package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js +4 -3
  18. package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
  19. package/dist/components/Company/FederalTaxes/Form.js +1 -1
  20. package/dist/components/Company/FederalTaxes/useFederalTaxes.js +6 -5
  21. package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
  22. package/dist/components/Company/Industry/Context.js +7 -6
  23. package/dist/components/Company/Industry/Context.js.map +1 -1
  24. package/dist/components/Company/Locations/LocationForm/Form.js +1 -1
  25. package/dist/components/Company/Locations/LocationForm/useLocationForm.js +4 -3
  26. package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
  27. package/dist/components/Company/Locations/LocationsList/useLocationsList.js +4 -3
  28. package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
  29. package/dist/components/Company/OnboardingOverview/context.js +4 -3
  30. package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
  31. package/dist/components/Company/PaySchedule/_parts/Edit.js +15 -15
  32. package/dist/components/Company/PaySchedule/usePaySchedule.js +6 -5
  33. package/dist/components/Company/PaySchedule/usePaySchedule.js.map +1 -1
  34. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +4 -3
  35. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
  36. package/dist/components/Company/StateTaxes/StateTaxesList/context.js +4 -3
  37. package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
  38. package/dist/components/Contractor/Address/Form.js +1 -1
  39. package/dist/components/Contractor/Address/useAddress.js +6 -5
  40. package/dist/components/Contractor/Address/useAddress.js.map +1 -1
  41. package/dist/components/Contractor/PaymentMethod/BankAccountForm.js +2 -2
  42. package/dist/components/Contractor/PaymentMethod/PaymentTypeForm.js +1 -1
  43. package/dist/components/Contractor/Payments/CreatePayment/EditContractorPaymentPresentation.js +10 -10
  44. package/dist/components/Contractor/Profile/ContractorProfileForm.js +15 -15
  45. package/dist/components/Employee/Compensation/Edit.js +14 -14
  46. package/dist/components/Employee/Deductions/DeductionsForm/ChildSupportForm.js +10 -9
  47. package/dist/components/Employee/Deductions/DeductionsForm/ChildSupportForm.js.map +1 -1
  48. package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.js +11 -10
  49. package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.js.map +1 -1
  50. package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.js +11 -10
  51. package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.js.map +1 -1
  52. package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js +4 -3
  53. package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  54. package/dist/components/Employee/DocumentSigner/EmploymentEligibility/EmploymentEligibilityPresentation.js +18 -18
  55. package/dist/components/Employee/DocumentSigner/I9SignatureForm/I9SignatureForm.js +7 -7
  56. package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js +4 -3
  57. package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
  58. package/dist/components/Employee/EmployeeList/useEmployeeList.js +4 -3
  59. package/dist/components/Employee/EmployeeList/useEmployeeList.js.map +1 -1
  60. package/dist/components/Employee/FederalTaxes/FederalForm.js +7 -7
  61. package/dist/components/Employee/FederalTaxes/useFederalTaxes.js +4 -3
  62. package/dist/components/Employee/FederalTaxes/useFederalTaxes.js.map +1 -1
  63. package/dist/components/Employee/PaymentMethod/BankAccountEdit.js +2 -2
  64. package/dist/components/Employee/PaymentMethod/PaymentTypeForm.js +1 -1
  65. package/dist/components/Employee/PaymentMethod/Split.js +8 -8
  66. package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +6 -5
  67. package/dist/components/Employee/PaymentMethod/usePaymentMethod.js.map +1 -1
  68. package/dist/components/Employee/Profile/AdminPersonalDetails.js +1 -1
  69. package/dist/components/Employee/Profile/HomeAddress.js +1 -1
  70. package/dist/components/Employee/Profile/PersonalDetailsInputs.js +2 -2
  71. package/dist/components/Employee/Profile/useProfile.js +4 -3
  72. package/dist/components/Employee/Profile/useProfile.js.map +1 -1
  73. package/dist/components/Employee/StateTaxes/useStateTaxes.js +4 -3
  74. package/dist/components/Employee/StateTaxes/useStateTaxes.js.map +1 -1
  75. package/dist/components/Employee/Taxes/FederalForm.js +7 -7
  76. package/dist/components/Employee/Taxes/useTaxes.js +4 -3
  77. package/dist/components/Employee/Taxes/useTaxes.js.map +1 -1
  78. package/dist/components/InformationRequests/InformationRequestForm/InformationRequestForm.js +10 -10
  79. package/dist/components/InformationRequests/InformationRequestForm/InformationRequestForm.js.map +1 -1
  80. package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetailsForm/ConfirmWireDetailsForm.js +9 -9
  81. package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +9 -9
  82. package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.js +12 -12
  83. package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormPresentation.js +1 -1
  84. package/dist/components/Payroll/OffCycleReasonSelection/OffCycleReasonSelectionPresentation.js +1 -1
  85. package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModal.js +10 -10
  86. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js +36 -36
  87. package/dist/components/Payroll/PayrollEditEmployee/TimeOffField.js +6 -6
  88. package/dist/components/Payroll/usePreparedPayrollData.js +3 -2
  89. package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
  90. package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +8 -7
  91. package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
  92. package/dist/helpers/formattedStrings.js +13 -12
  93. package/dist/helpers/formattedStrings.js.map +1 -1
  94. package/package.json +2 -2
@@ -9,16 +9,16 @@ import u from "./PayrollEditEmployeePresentation.module.scss.js";
9
9
  import { TimeOffField as ne } from "./TimeOffField.js";
10
10
  import { Flex as x } from "../../Common/Flex/Flex.js";
11
11
  import { Grid as P } from "../../Common/Grid/Grid.js";
12
- import { useComponentContext as re } from "../../../contexts/ComponentAdapter/useComponentContext.js";
13
- import { useI18n as oe } from "../../../i18n/I18n.js";
14
- import { Form as ie } from "../../Common/Form/Form.js";
15
- import { firstLastName as se, formatNumberAsCurrency as ae } from "../../../helpers/formattedStrings.js";
16
- import { getAdditionalEarningsCompensations as me, getReimbursementCompensation as le, calculateGrossPay as G } from "../helpers.js";
17
- import { HOURS_COMPENSATION_NAMES as k, EXCLUDED_ADDITIONAL_EARNINGS as de, COMPENSATION_NAME_DOUBLE_OVERTIME as ue, COMPENSATION_NAME_OVERTIME as ce, COMPENSATION_NAME_REGULAR_HOURS as pe, COMPENSATION_NAME_REIMBURSEMENT as fe, COMPENSATION_NAME_CASH_TIPS as he, COMPENSATION_NAME_COMMISSION as Ce, COMPENSATION_NAME_CORRECTION_PAYMENT as Ne, COMPENSATION_NAME_PAYCHECK_TIPS as Ee, COMPENSATION_NAME_BONUS as ge } from "../../../shared/constants.js";
18
- import be from "../../../hooks/useContainerBreakpoints/useContainerBreakpoints.js";
19
- import { TextInputField as Me } from "../../Common/Fields/TextInputField/TextInputField.js";
20
- import { NumberInputField as w } from "../../Common/Fields/NumberInputField/NumberInputField.js";
21
- import { RadioGroupField as Oe } from "../../Common/Fields/RadioGroupField/RadioGroupField.js";
12
+ import { RadioGroupField as re } from "../../Common/Fields/RadioGroupField/RadioGroupField.js";
13
+ import { TextInputField as oe } from "../../Common/Fields/TextInputField/TextInputField.js";
14
+ import { NumberInputField as G } from "../../Common/Fields/NumberInputField/NumberInputField.js";
15
+ import { useComponentContext as ie } from "../../../contexts/ComponentAdapter/useComponentContext.js";
16
+ import { useI18n as se } from "../../../i18n/I18n.js";
17
+ import { Form as ae } from "../../Common/Form/Form.js";
18
+ import { firstLastName as me, formatNumberAsCurrency as le } from "../../../helpers/formattedStrings.js";
19
+ import { getAdditionalEarningsCompensations as de, getReimbursementCompensation as ue, calculateGrossPay as k } from "../helpers.js";
20
+ import { HOURS_COMPENSATION_NAMES as w, EXCLUDED_ADDITIONAL_EARNINGS as ce, COMPENSATION_NAME_DOUBLE_OVERTIME as pe, COMPENSATION_NAME_OVERTIME as fe, COMPENSATION_NAME_REGULAR_HOURS as he, COMPENSATION_NAME_REIMBURSEMENT as Ce, COMPENSATION_NAME_CASH_TIPS as Ne, COMPENSATION_NAME_COMMISSION as Ee, COMPENSATION_NAME_CORRECTION_PAYMENT as ge, COMPENSATION_NAME_PAYCHECK_TIPS as be, COMPENSATION_NAME_BONUS as Me } from "../../../shared/constants.js";
21
+ import Oe from "../../../hooks/useContainerBreakpoints/useContainerBreakpoints.js";
22
22
  const Te = m.object({
23
23
  hourlyCompensations: m.record(m.string(), m.record(m.string(), m.string().optional())),
24
24
  timeOffCompensations: m.record(m.string(), m.string().optional()),
@@ -72,22 +72,22 @@ const Te = m.object({
72
72
  withReimbursements: M = !0,
73
73
  hasDirectDepositSetup: $ = !0
74
74
  }) => {
75
- const { Button: v, Heading: c, Text: B } = re(), { t } = ee("Payroll.PayrollEditEmployee");
76
- oe("Payroll.PayrollEditEmployee");
77
- const f = l.jobs?.find((e) => e.primary), O = f ? [f] : [], F = Z(null), p = be({
75
+ const { Button: v, Heading: c, Text: B } = ie(), { t } = ee("Payroll.PayrollEditEmployee");
76
+ se("Payroll.PayrollEditEmployee");
77
+ const f = l.jobs?.find((e) => e.primary), O = f ? [f] : [], F = Z(null), p = Oe({
78
78
  ref: F
79
79
  }).includes("small");
80
80
  i?.hourlyCompensations?.forEach((e) => {
81
81
  const n = l.jobs?.find((s) => s.uuid === e.jobUuid);
82
82
  n && !O.find((s) => s.uuid === n.uuid) && O.push(n);
83
83
  });
84
- const A = (i?.paidTimeOff || []).filter((e) => e.name), _ = me({
84
+ const A = (i?.paidTimeOff || []).filter((e) => e.name), _ = de({
85
85
  flsaStatus: f?.compensations?.[0]?.flsaStatus,
86
86
  existingFixedCompensations: i?.fixedCompensations || [],
87
87
  primaryJobUuid: f?.uuid,
88
88
  fixedCompensationTypes: b,
89
- excludedTypes: de
90
- }), N = M ? le(
89
+ excludedTypes: ce
90
+ }), N = M ? ue(
91
91
  i?.fixedCompensations || [],
92
92
  b,
93
93
  f?.uuid
@@ -95,28 +95,28 @@ const Te = m.object({
95
95
  (s) => s.jobUuid === e && s.name?.toLowerCase() === n.toLowerCase()
96
96
  ), q = (e) => {
97
97
  switch (e) {
98
- case pe:
98
+ case he:
99
99
  return t("compensationNames.regularHours");
100
- case ce:
100
+ case fe:
101
101
  return t("compensationNames.overtime");
102
- case ue:
102
+ case pe:
103
103
  return t("compensationNames.doubleOvertime");
104
104
  default:
105
105
  return e;
106
106
  }
107
107
  }, j = (e) => {
108
108
  switch (e) {
109
- case ge:
109
+ case Me:
110
110
  return t("fixedCompensationNames.bonus");
111
- case Ee:
111
+ case be:
112
112
  return t("fixedCompensationNames.paycheckTips");
113
- case Ne:
113
+ case ge:
114
114
  return t("fixedCompensationNames.correctionPayment");
115
- case Ce:
115
+ case Ee:
116
116
  return t("fixedCompensationNames.commission");
117
- case he:
117
+ case Ne:
118
118
  return t("fixedCompensationNames.cashTips");
119
- case fe:
119
+ case Ce:
120
120
  return t("fixedCompensationNames.reimbursement");
121
121
  default:
122
122
  return e;
@@ -125,7 +125,7 @@ const Te = m.object({
125
125
  hourlyCompensations: (() => {
126
126
  const e = {};
127
127
  return O.forEach((n) => {
128
- k.forEach((s) => {
128
+ w.forEach((s) => {
129
129
  const h = R(n.uuid, s);
130
130
  h && (e[n.uuid] || (e[n.uuid] = {}), e[n.uuid][h.name] = h.hours ? parseFloat(h.hours).toString() : "");
131
131
  });
@@ -166,7 +166,7 @@ const Te = m.object({
166
166
  (i?.paidTimeOff || []).filter((h) => h.name),
167
167
  f?.uuid
168
168
  );
169
- return G(
169
+ return k(
170
170
  s,
171
171
  l,
172
172
  o,
@@ -174,7 +174,7 @@ const Te = m.object({
174
174
  C
175
175
  );
176
176
  } catch {
177
- return i ? G(
177
+ return i ? k(
178
178
  i,
179
179
  l,
180
180
  o,
@@ -190,7 +190,7 @@ const Te = m.object({
190
190
  o,
191
191
  d,
192
192
  C
193
- ]), W = se({
193
+ ]), W = me({
194
194
  first_name: l.firstName,
195
195
  last_name: l.lastName
196
196
  }), Y = (e) => {
@@ -201,7 +201,7 @@ const Te = m.object({
201
201
  f?.uuid
202
202
  );
203
203
  E(n);
204
- }, L = ae(z || 0), U = /* @__PURE__ */ a(
204
+ }, L = le(z || 0), U = /* @__PURE__ */ a(
205
205
  x,
206
206
  {
207
207
  flexDirection: p ? "row" : "column",
@@ -240,19 +240,19 @@ const Te = m.object({
240
240
  }
241
241
  ),
242
242
  /* @__PURE__ */ a(Q, { ...I, children: [
243
- /* @__PURE__ */ a(ie, { children: [
243
+ /* @__PURE__ */ a(ae, { children: [
244
244
  O.length > 0 && /* @__PURE__ */ a("div", { className: u.fieldGroup, children: [
245
245
  /* @__PURE__ */ r(c, { as: "h3", children: t("regularHoursTitle") }),
246
246
  O.map((e) => /* @__PURE__ */ a(x, { flexDirection: "column", gap: 8, children: [
247
247
  O.length > 1 && /* @__PURE__ */ r(c, { as: "h4", children: e.title }),
248
- /* @__PURE__ */ r(P, { gridTemplateColumns: { base: "1fr", small: [320, 320] }, gap: 20, children: k.map((n) => {
248
+ /* @__PURE__ */ r(P, { gridTemplateColumns: { base: "1fr", small: [320, 320] }, gap: 20, children: w.map((n) => {
249
249
  const s = R(
250
250
  e.uuid,
251
251
  n
252
252
  );
253
253
  if (s)
254
254
  return /* @__PURE__ */ r(
255
- Me,
255
+ oe,
256
256
  {
257
257
  type: "number",
258
258
  min: 0,
@@ -285,7 +285,7 @@ const Te = m.object({
285
285
  gridTemplateColumns: { base: "1fr", small: [320, 320], large: [320, 320, 320] },
286
286
  gap: 20,
287
287
  children: _.map((e) => /* @__PURE__ */ r(
288
- w,
288
+ G,
289
289
  {
290
290
  format: "currency",
291
291
  min: 0,
@@ -301,7 +301,7 @@ const Te = m.object({
301
301
  N && /* @__PURE__ */ a("div", { className: u.fieldGroup, children: [
302
302
  /* @__PURE__ */ r(c, { as: "h4", children: t("reimbursementTitle") }),
303
303
  /* @__PURE__ */ r(P, { gridTemplateColumns: { base: "1fr", small: [320, 320] }, gap: 20, children: /* @__PURE__ */ r(
304
- w,
304
+ G,
305
305
  {
306
306
  format: "currency",
307
307
  min: 0,
@@ -314,7 +314,7 @@ const Te = m.object({
314
314
  $ && /* @__PURE__ */ a("div", { className: u.fieldGroup, children: [
315
315
  /* @__PURE__ */ r(c, { as: "h4", children: t("paymentMethodTitle") }),
316
316
  /* @__PURE__ */ r(
317
- Oe,
317
+ re,
318
318
  {
319
319
  name: "paymentMethod",
320
320
  isRequired: !0,
@@ -5,23 +5,23 @@ import { useTranslation as c } from "react-i18next";
5
5
  import { Flex as y } from "../../Common/Flex/Flex.js";
6
6
  import "classnames";
7
7
  import "../../../shared/constants.js";
8
- import { useComponentContext as x } from "../../../contexts/ComponentAdapter/useComponentContext.js";
9
- import { useI18n as h } from "../../../i18n/I18n.js";
10
- import { TextInputField as B } from "../../Common/Fields/TextInputField/TextInputField.js";
8
+ import { TextInputField as x } from "../../Common/Fields/TextInputField/TextInputField.js";
9
+ import { useComponentContext as h } from "../../../contexts/ComponentAdapter/useComponentContext.js";
10
+ import { useI18n as B } from "../../../i18n/I18n.js";
11
11
  const P = ({
12
12
  accrualBalance: e,
13
13
  accrualMethod: o,
14
14
  hoursUsed: r,
15
15
  id: t
16
16
  }) => {
17
- const { Text: n } = x(), { t: i } = c("Payroll.PayrollEditEmployee");
17
+ const { Text: n } = h(), { t: i } = c("Payroll.PayrollEditEmployee");
18
18
  if (o === "unlimited")
19
19
  return null;
20
20
  const a = parseFloat(e) - r;
21
21
  return /* @__PURE__ */ l(n, { size: "sm", variant: "supporting", "aria-live": "polite", "aria-atomic": !0, id: t, children: i("timeOffBalance.remaining", { balance: a.toFixed(1) }) });
22
22
  }, U = ({ timeOff: e, employee: o }) => {
23
23
  const { t: r } = c("Payroll.PayrollEditEmployee");
24
- h("Payroll.PayrollEditEmployee");
24
+ B("Payroll.PayrollEditEmployee");
25
25
  const { control: t } = d(), n = p(), i = f({
26
26
  control: t,
27
27
  name: `timeOffCompensations.${e.name}`
@@ -31,7 +31,7 @@ const P = ({
31
31
  const m = parseFloat(i || "0"), a = o.eligiblePaidTimeOff?.find((s) => s.name === e.name);
32
32
  return /* @__PURE__ */ u(y, { flexDirection: "column", gap: 4, children: [
33
33
  /* @__PURE__ */ l(
34
- B,
34
+ x,
35
35
  {
36
36
  name: `timeOffCompensations.${e.name}`,
37
37
  type: "number",
@@ -14,8 +14,9 @@ import "classnames";
14
14
  import "../../contexts/ComponentAdapter/useComponentContext.js";
15
15
  import "../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
16
16
  import "dompurify";
17
+ import "../../contexts/LocaleProvider/useLocale.js";
17
18
  import { retryAsync as x } from "../../helpers/retryAsync.js";
18
- const q = 4, v = 1500, w = (e) => e instanceof T ? Array.isArray(e.errors) && e.errors.some((r) => r.category === "invalid_operation") : !1, W = ({
19
+ const q = 4, v = 1500, w = (e) => e instanceof T ? Array.isArray(e.errors) && e.errors.some((r) => r.category === "invalid_operation") : !1, Z = ({
19
20
  companyId: e,
20
21
  payrollId: r,
21
22
  employeeUuids: a,
@@ -66,6 +67,6 @@ const q = 4, v = 1500, w = (e) => e instanceof T ? Array.isArray(e.errors) && e.
66
67
  };
67
68
  };
68
69
  export {
69
- W as usePreparedPayrollData
70
+ Z as usePreparedPayrollData
70
71
  };
71
72
  //# 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/payroll'\nimport type { PayScheduleObject } from '@gusto/embedded-api/models/components/payscheduleobject'\nimport type { QueryParamSortBy } from '@gusto/embedded-api/models/operations/putv1companiescompanyidpayrollspayrollidprepare'\nimport { UnprocessableEntityErrorObject } from '@gusto/embedded-api/models/errors/unprocessableentityerrorobject'\nimport { useBase } from '../Base'\nimport { retryAsync } from '@/helpers/retryAsync'\n\ninterface UsePreparedPayrollDataParams {\n companyId: string\n payrollId: string\n employeeUuids?: string[]\n sortBy?: QueryParamSortBy\n onDataReady?: (preparedPayroll: PayrollPrepared) => void\n}\n\ninterface UsePreparedPayrollDataReturn {\n handlePreparePayroll: () => Promise<void>\n preparedPayroll: PayrollPrepared | undefined\n paySchedule: PayScheduleObject | 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 UnprocessableEntityErrorObject)) return false\n return Array.isArray(error.errors) && error.errors.some(e => e.category === 'invalid_operation')\n}\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?.payScheduleObject,\n isLoading,\n isPaginating,\n hasInitialData: hasInitialDataRef.current,\n }\n}\n"],"names":["PREPARE_MAX_ATTEMPTS","PREPARE_RETRY_DELAY_MS","isPayrollBeingProcessedError","error","UnprocessableEntityErrorObject","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":";;;;;;;;;;;;;;;;;AA2BA,MAAMA,IAAuB,GACvBC,IAAyB,MAEzBC,IAA+B,CAACC,MAC9BA,aAAiBC,IAChB,MAAM,QAAQD,EAAM,MAAM,KAAKA,EAAM,OAAO,KAAK,CAAAE,MAAKA,EAAE,aAAa,mBAAmB,IADhC,IAIpDC,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,E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AK;AAAA,IACA,iBAAAhB;AAAA,IACA,aAAaU,GAAiB;AAAA,IAC9B,WAAAW;AAAA,IACA,cAAAD;AAAA,IACA,gBAAgBjB,EAAkB;AAAA,EAAA;AAEtC;"}
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/payroll'\nimport type { PayScheduleObject } from '@gusto/embedded-api/models/components/payscheduleobject'\nimport type { QueryParamSortBy } from '@gusto/embedded-api/models/operations/putv1companiescompanyidpayrollspayrollidprepare'\nimport { UnprocessableEntityErrorObject } from '@gusto/embedded-api/models/errors/unprocessableentityerrorobject'\nimport { useBase } from '../Base'\nimport { retryAsync } from '@/helpers/retryAsync'\n\ninterface UsePreparedPayrollDataParams {\n companyId: string\n payrollId: string\n employeeUuids?: string[]\n sortBy?: QueryParamSortBy\n onDataReady?: (preparedPayroll: PayrollPrepared) => void\n}\n\ninterface UsePreparedPayrollDataReturn {\n handlePreparePayroll: () => Promise<void>\n preparedPayroll: PayrollPrepared | undefined\n paySchedule: PayScheduleObject | 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 UnprocessableEntityErrorObject)) return false\n return Array.isArray(error.errors) && error.errors.some(e => e.category === 'invalid_operation')\n}\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?.payScheduleObject,\n isLoading,\n isPaginating,\n hasInitialData: hasInitialDataRef.current,\n }\n}\n"],"names":["PREPARE_MAX_ATTEMPTS","PREPARE_RETRY_DELAY_MS","isPayrollBeingProcessedError","error","UnprocessableEntityErrorObject","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":";;;;;;;;;;;;;;;;;;AA2BA,MAAMA,IAAuB,GACvBC,IAAyB,MAEzBC,IAA+B,CAACC,MAC9BA,aAAiBC,IAChB,MAAM,QAAQD,EAAM,MAAM,KAAKA,EAAM,OAAO,KAAK,CAAAE,MAAKA,EAAE,aAAa,mBAAmB,IADhC,IAIpDC,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,EAAA,IAAsBC,EAAA,GAExBC,IAAmBC,EAAQ,MAAMf,GAAe,KAAK,GAAG,KAAK,IAAI,CAACA,CAAa,CAAC,GAEhF,EAAE,MAAMgB,GAAiB,WAAWC,MAAyBC;AAAA,IACjE;AAAA,MACE,WAAApB;AAAA,MACA,eAAeQ,GAAiB,WAAW,mBAAmB;AAAA,IAAA;AAAA,IAEhE;AAAA,MACE,SAAS,CAAC,CAACA,GAAiB,WAAW;AAAA,IAAA;AAAA,EACzC,GAGIa,IAAiBC,EAAY,YAAY;AAC7C,UAAMC,IAAS,MAAMlB,EAAe;AAAA,MAClC,SAAS;AAAA,QACP,WAAAL;AAAA,QACA,WAAAC;AAAA,QACA,QAAAE;AAAA,QACA,aAAa;AAAA,UACX,eAAAD;AAAA,QAAA;AAAA,MACF;AAAA,IACF,CACD;AACD,IAAAO,EAAmBc,EAAO,eAAe,GACrCA,EAAO,oBACTZ,EAAkB,UAAU,IAC5BP,IAAcmB,EAAO,eAAe;AAAA,EAExC,GAAG,CAACvB,GAAWC,GAAWI,GAAgBW,GAAkBb,GAAQC,CAAW,CAAC,GAE1EoB,IAAuBF,EAAY,YAAY;AACnD,UAAMR;AAAA,MAAkB;AAAA,MAAM,MAC5BW,EAAWJ,GAAgB;AAAA,QACzB,aAAa5B;AAAA,QACb,SAASC;AAAA,QACT,aAAaC;AAAA,MAAA,CACd;AAAA,IAAA;AAAA,EAEL,GAAG,CAACmB,GAAmBO,CAAc,CAAC;AAEtC,EAAAK,EAAU,MAAM;AACd,IAAIb,EAAY,YAChBA,EAAY,UAAU,IACjBW,EAAA;AAAA,EACP,GAAG,CAACA,CAAoB,CAAC;AAEzB,QAAMG,IAAmBrB,KAA2B,CAACK,EAAkB,SACjEiB,IAAetB,KAA2BK,EAAkB,SAC5DkB,IAAYF,KAAoBR;AAEtC,SAAO;AAAA,IACL,sBAAAK;AAAA,IACA,iBAAAhB;AAAA,IACA,aAAaU,GAAiB;AAAA,IAC9B,WAAAW;AAAA,IACA,cAAAD;AAAA,IACA,gBAAgBjB,EAAkB;AAAA,EAAA;AAEtC;"}
@@ -7,14 +7,15 @@ import { ApiProvider as x } from "../ApiProvider/ApiProvider.js";
7
7
  import { LoadingIndicatorProvider as C } from "../LoadingIndicatorProvider/LoadingIndicatorProvider.js";
8
8
  import { ObservabilityProvider as I } from "../ObservabilityProvider/ObservabilityProvider.js";
9
9
  import { sanitizeError as L } from "../ObservabilityProvider/sanitization.js";
10
- import { SDKI18next as s } from "./SDKI18next.js";
10
+ import { SDKI18next as m } from "./SDKI18next.js";
11
11
  import "../../shared/constants.js";
12
12
  import "classnames";
13
13
  import { InternalError as S } from "../../components/Common/InternalError/InternalError.js";
14
14
  import "../ComponentAdapter/useComponentContext.js";
15
15
  import { LocaleProvider as U } from "../LocaleProvider/LocaleProvider.js";
16
+ import "../LocaleProvider/useLocale.js";
16
17
  import { ThemeProvider as z } from "../ThemeProvider/ThemeProvider.js";
17
- const N = (m) => {
18
+ const Q = (s) => {
18
19
  const {
19
20
  children: c,
20
21
  config: r,
@@ -26,12 +27,12 @@ const N = (m) => {
26
27
  components: f,
27
28
  LoaderComponent: v,
28
29
  queryClient: u
29
- } = m;
30
+ } = s;
30
31
  if (n)
31
32
  for (const e in n) {
32
33
  const i = e;
33
34
  for (const t in n[i])
34
- s.addResourceBundle(
35
+ m.addResourceBundle(
35
36
  i,
36
37
  t,
37
38
  n[i][t],
@@ -40,7 +41,7 @@ const N = (m) => {
40
41
  );
41
42
  }
42
43
  g(() => {
43
- (async () => await s.changeLanguage(a))();
44
+ (async () => await m.changeLanguage(a))();
44
45
  }, [a]);
45
46
  const b = k(() => {
46
47
  if (r.observability?.onError)
@@ -59,7 +60,7 @@ const N = (m) => {
59
60
  r.observability.onError(h);
60
61
  };
61
62
  }, [r.observability]);
62
- return /* @__PURE__ */ o(P, { value: f, children: /* @__PURE__ */ o(C, { value: v, children: /* @__PURE__ */ o(I, { observability: r.observability, children: /* @__PURE__ */ o(y, { FallbackComponent: S, onError: b, children: /* @__PURE__ */ o(z, { theme: p, children: /* @__PURE__ */ o(U, { locale: l, currency: d, children: /* @__PURE__ */ o(E, { i18n: s, children: /* @__PURE__ */ o(
63
+ return /* @__PURE__ */ o(P, { value: f, children: /* @__PURE__ */ o(C, { value: v, children: /* @__PURE__ */ o(I, { observability: r.observability, children: /* @__PURE__ */ o(y, { FallbackComponent: S, onError: b, children: /* @__PURE__ */ o(z, { theme: p, children: /* @__PURE__ */ o(U, { locale: l, currency: d, children: /* @__PURE__ */ o(E, { i18n: m, children: /* @__PURE__ */ o(
63
64
  x,
64
65
  {
65
66
  url: r.baseUrl,
@@ -71,6 +72,6 @@ const N = (m) => {
71
72
  ) }, a) }) }) }) }) }) });
72
73
  };
73
74
  export {
74
- N as GustoProviderCustomUIAdapter
75
+ Q as GustoProviderCustomUIAdapter
75
76
  };
76
77
  //# sourceMappingURL=GustoProviderCustomUIAdapter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GustoProviderCustomUIAdapter.js","sources":["../../../src/contexts/GustoProvider/GustoProviderCustomUIAdapter.tsx"],"sourcesContent":["import type React from 'react'\nimport type { ErrorInfo } from 'react'\nimport { ErrorBoundary } from 'react-error-boundary'\nimport { I18nextProvider } from 'react-i18next'\nimport type { QueryClient } from '@tanstack/react-query'\nimport { useEffect, useMemo } from 'react'\nimport { ComponentsProvider } from '../ComponentAdapter/ComponentsProvider'\nimport type { ComponentsContextType } from '../ComponentAdapter/useComponentContext'\nimport { ApiProvider } from '../ApiProvider/ApiProvider'\nimport { LoadingIndicatorProvider } from '../LoadingIndicatorProvider/LoadingIndicatorProvider'\nimport type { LoadingIndicatorContextProps } from '../LoadingIndicatorProvider/useLoadingIndicator'\nimport { ObservabilityProvider } from '../ObservabilityProvider'\nimport { sanitizeError } from '../ObservabilityProvider/sanitization'\nimport { SDKI18next } from './SDKI18next'\nimport { InternalError } from '@/components/Common'\nimport { LocaleProvider } from '@/contexts/LocaleProvider'\nimport { ThemeProvider } from '@/contexts/ThemeProvider'\nimport type { GustoSDKTheme } from '@/contexts/ThemeProvider/theme'\nimport type { ResourceDictionary, SupportedLanguages } from '@/types/Helpers'\nimport type { SDKHooks } from '@/types/hooks'\nimport type { ObservabilityHook } from '@/types/observability'\n\nexport interface APIConfig {\n baseUrl: string\n headers?: HeadersInit\n hooks?: SDKHooks\n observability?: ObservabilityHook\n}\n\nexport interface GustoProviderProps {\n config: APIConfig\n dictionary?: ResourceDictionary\n lng?: string\n locale?: string\n currency?: string\n theme?: GustoSDKTheme\n queryClient?: QueryClient\n components: ComponentsContextType\n LoaderComponent?: LoadingIndicatorContextProps['LoadingIndicator']\n}\n\nexport interface GustoProviderCustomUIAdapterProps extends GustoProviderProps {\n children?: React.ReactNode\n}\n\n/**\n * A provider that accepts UI component adapters through the components prop\n */\nconst GustoProviderCustomUIAdapter: React.FC<GustoProviderCustomUIAdapterProps> = props => {\n const {\n children,\n config,\n dictionary,\n lng = 'en',\n locale = 'en-US',\n currency = 'USD',\n theme,\n components,\n LoaderComponent,\n queryClient,\n } = props\n\n // Handle dictionary resources\n if (dictionary) {\n for (const language in dictionary) {\n const lang = language as SupportedLanguages\n for (const ns in dictionary[lang]) {\n // Adding resources overrides to i18next instance - initial load will override common namespace and add component specific dictionaries provided by partners\n SDKI18next.addResourceBundle(\n lang,\n ns,\n (dictionary[lang] as Record<string, unknown>)[ns],\n true,\n true,\n )\n }\n }\n }\n\n // Handle language change\n useEffect(() => {\n void (async () => {\n await SDKI18next.changeLanguage(lng)\n })()\n }, [lng])\n\n // Create sanitized error handler that respects sanitization config\n const handleTopLevelError = useMemo(() => {\n if (!config.observability?.onError) return undefined\n\n return (error: unknown, errorInfo: ErrorInfo) => {\n if (!config.observability?.onError) return\n\n const unsanitizedError = {\n type: 'internal_error' as const,\n message: error instanceof Error ? error.message : 'Unknown error',\n stack: error instanceof Error ? error.stack : undefined,\n context: {\n componentStack: errorInfo.componentStack ?? undefined,\n },\n originalError: error,\n timestamp: Date.now(),\n }\n\n // Apply sanitization with the same config used for other errors\n const sanitizedError = sanitizeError(unsanitizedError, config.observability.sanitization)\n\n config.observability.onError(sanitizedError)\n }\n }, [config.observability])\n return (\n <ComponentsProvider value={components}>\n <LoadingIndicatorProvider value={LoaderComponent}>\n <ObservabilityProvider observability={config.observability}>\n <ErrorBoundary FallbackComponent={InternalError} onError={handleTopLevelError}>\n <ThemeProvider theme={theme}>\n <LocaleProvider locale={locale} currency={currency}>\n <I18nextProvider i18n={SDKI18next} key={lng}>\n <ApiProvider\n url={config.baseUrl}\n headers={config.headers}\n hooks={config.hooks}\n queryClient={queryClient}\n >\n {children}\n </ApiProvider>\n </I18nextProvider>\n </LocaleProvider>\n </ThemeProvider>\n </ErrorBoundary>\n </ObservabilityProvider>\n </LoadingIndicatorProvider>\n </ComponentsProvider>\n )\n}\n\nexport { GustoProviderCustomUIAdapter }\n"],"names":["GustoProviderCustomUIAdapter","props","children","config","dictionary","lng","locale","currency","theme","components","LoaderComponent","queryClient","language","lang","ns","SDKI18next","useEffect","handleTopLevelError","useMemo","error","errorInfo","unsanitizedError","sanitizedError","sanitizeError","jsx","ComponentsProvider","LoadingIndicatorProvider","ObservabilityProvider","ErrorBoundary","InternalError","ThemeProvider","LocaleProvider","I18nextProvider","ApiProvider"],"mappings":";;;;;;;;;;;;;;;;AAgDA,MAAMA,IAA4E,CAAAC,MAAS;AACzF,QAAM;AAAA,IACJ,UAAAC;AAAA,IACA,QAAAC;AAAA,IACA,YAAAC;AAAA,IACA,KAAAC,IAAM;AAAA,IACN,QAAAC,IAAS;AAAA,IACT,UAAAC,IAAW;AAAA,IACX,OAAAC;AAAA,IACA,YAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,aAAAC;AAAA,EAAA,IACEV;AAGJ,MAAIG;AACF,eAAWQ,KAAYR,GAAY;AACjC,YAAMS,IAAOD;AACb,iBAAWE,KAAMV,EAAWS,CAAI;AAE9B,QAAAE,EAAW;AAAA,UACTF;AAAA,UACAC;AAAA,UACCV,EAAWS,CAAI,EAA8BC,CAAE;AAAA,UAChD;AAAA,UACA;AAAA,QAAA;AAAA,IAGN;AAIF,EAAAE,EAAU,MAAM;AACd,KAAM,YACJ,MAAMD,EAAW,eAAeV,CAAG;AAAA,EAEvC,GAAG,CAACA,CAAG,CAAC;AAGR,QAAMY,IAAsBC,EAAQ,MAAM;AACxC,QAAKf,EAAO,eAAe;AAE3B,aAAO,CAACgB,GAAgBC,MAAyB;AAC/C,YAAI,CAACjB,EAAO,eAAe,QAAS;AAEpC,cAAMkB,IAAmB;AAAA,UACvB,MAAM;AAAA,UACN,SAASF,aAAiB,QAAQA,EAAM,UAAU;AAAA,UAClD,OAAOA,aAAiB,QAAQA,EAAM,QAAQ;AAAA,UAC9C,SAAS;AAAA,YACP,gBAAgBC,EAAU,kBAAkB;AAAA,UAAA;AAAA,UAE9C,eAAeD;AAAA,UACf,WAAW,KAAK,IAAA;AAAA,QAAI,GAIhBG,IAAiBC,EAAcF,GAAkBlB,EAAO,cAAc,YAAY;AAExF,QAAAA,EAAO,cAAc,QAAQmB,CAAc;AAAA,MAC7C;AAAA,EACF,GAAG,CAACnB,EAAO,aAAa,CAAC;AACzB,SACE,gBAAAqB,EAACC,GAAA,EAAmB,OAAOhB,GACzB,UAAA,gBAAAe,EAACE,GAAA,EAAyB,OAAOhB,GAC/B,UAAA,gBAAAc,EAACG,GAAA,EAAsB,eAAexB,EAAO,eAC3C,UAAA,gBAAAqB,EAACI,GAAA,EAAc,mBAAmBC,GAAe,SAASZ,GACxD,UAAA,gBAAAO,EAACM,GAAA,EAAc,OAAAtB,GACb,UAAA,gBAAAgB,EAACO,GAAA,EAAe,QAAAzB,GAAgB,UAAAC,GAC9B,UAAA,gBAAAiB,EAACQ,GAAA,EAAgB,MAAMjB,GACrB,UAAA,gBAAAS;AAAA,IAACS;AAAA,IAAA;AAAA,MACC,KAAK9B,EAAO;AAAA,MACZ,SAASA,EAAO;AAAA,MAChB,OAAOA,EAAO;AAAA,MACd,aAAAQ;AAAA,MAEC,UAAAT;AAAA,IAAA;AAAA,EAAA,KAPmCG,CASxC,GACF,GACF,EAAA,CACF,EAAA,CACF,GACF,GACF;AAEJ;"}
1
+ {"version":3,"file":"GustoProviderCustomUIAdapter.js","sources":["../../../src/contexts/GustoProvider/GustoProviderCustomUIAdapter.tsx"],"sourcesContent":["import type React from 'react'\nimport type { ErrorInfo } from 'react'\nimport { ErrorBoundary } from 'react-error-boundary'\nimport { I18nextProvider } from 'react-i18next'\nimport type { QueryClient } from '@tanstack/react-query'\nimport { useEffect, useMemo } from 'react'\nimport { ComponentsProvider } from '../ComponentAdapter/ComponentsProvider'\nimport type { ComponentsContextType } from '../ComponentAdapter/useComponentContext'\nimport { ApiProvider } from '../ApiProvider/ApiProvider'\nimport { LoadingIndicatorProvider } from '../LoadingIndicatorProvider/LoadingIndicatorProvider'\nimport type { LoadingIndicatorContextProps } from '../LoadingIndicatorProvider/useLoadingIndicator'\nimport { ObservabilityProvider } from '../ObservabilityProvider'\nimport { sanitizeError } from '../ObservabilityProvider/sanitization'\nimport { SDKI18next } from './SDKI18next'\nimport { InternalError } from '@/components/Common'\nimport { LocaleProvider } from '@/contexts/LocaleProvider'\nimport { ThemeProvider } from '@/contexts/ThemeProvider'\nimport type { GustoSDKTheme } from '@/contexts/ThemeProvider/theme'\nimport type { ResourceDictionary, SupportedLanguages } from '@/types/Helpers'\nimport type { SDKHooks } from '@/types/hooks'\nimport type { ObservabilityHook } from '@/types/observability'\n\nexport interface APIConfig {\n baseUrl: string\n headers?: HeadersInit\n hooks?: SDKHooks\n observability?: ObservabilityHook\n}\n\nexport interface GustoProviderProps {\n config: APIConfig\n dictionary?: ResourceDictionary\n lng?: string\n locale?: string\n currency?: string\n theme?: GustoSDKTheme\n queryClient?: QueryClient\n components: ComponentsContextType\n LoaderComponent?: LoadingIndicatorContextProps['LoadingIndicator']\n}\n\nexport interface GustoProviderCustomUIAdapterProps extends GustoProviderProps {\n children?: React.ReactNode\n}\n\n/**\n * A provider that accepts UI component adapters through the components prop\n */\nconst GustoProviderCustomUIAdapter: React.FC<GustoProviderCustomUIAdapterProps> = props => {\n const {\n children,\n config,\n dictionary,\n lng = 'en',\n locale = 'en-US',\n currency = 'USD',\n theme,\n components,\n LoaderComponent,\n queryClient,\n } = props\n\n // Handle dictionary resources\n if (dictionary) {\n for (const language in dictionary) {\n const lang = language as SupportedLanguages\n for (const ns in dictionary[lang]) {\n // Adding resources overrides to i18next instance - initial load will override common namespace and add component specific dictionaries provided by partners\n SDKI18next.addResourceBundle(\n lang,\n ns,\n (dictionary[lang] as Record<string, unknown>)[ns],\n true,\n true,\n )\n }\n }\n }\n\n // Handle language change\n useEffect(() => {\n void (async () => {\n await SDKI18next.changeLanguage(lng)\n })()\n }, [lng])\n\n // Create sanitized error handler that respects sanitization config\n const handleTopLevelError = useMemo(() => {\n if (!config.observability?.onError) return undefined\n\n return (error: unknown, errorInfo: ErrorInfo) => {\n if (!config.observability?.onError) return\n\n const unsanitizedError = {\n type: 'internal_error' as const,\n message: error instanceof Error ? error.message : 'Unknown error',\n stack: error instanceof Error ? error.stack : undefined,\n context: {\n componentStack: errorInfo.componentStack ?? undefined,\n },\n originalError: error,\n timestamp: Date.now(),\n }\n\n // Apply sanitization with the same config used for other errors\n const sanitizedError = sanitizeError(unsanitizedError, config.observability.sanitization)\n\n config.observability.onError(sanitizedError)\n }\n }, [config.observability])\n return (\n <ComponentsProvider value={components}>\n <LoadingIndicatorProvider value={LoaderComponent}>\n <ObservabilityProvider observability={config.observability}>\n <ErrorBoundary FallbackComponent={InternalError} onError={handleTopLevelError}>\n <ThemeProvider theme={theme}>\n <LocaleProvider locale={locale} currency={currency}>\n <I18nextProvider i18n={SDKI18next} key={lng}>\n <ApiProvider\n url={config.baseUrl}\n headers={config.headers}\n hooks={config.hooks}\n queryClient={queryClient}\n >\n {children}\n </ApiProvider>\n </I18nextProvider>\n </LocaleProvider>\n </ThemeProvider>\n </ErrorBoundary>\n </ObservabilityProvider>\n </LoadingIndicatorProvider>\n </ComponentsProvider>\n )\n}\n\nexport { GustoProviderCustomUIAdapter }\n"],"names":["GustoProviderCustomUIAdapter","props","children","config","dictionary","lng","locale","currency","theme","components","LoaderComponent","queryClient","language","lang","ns","SDKI18next","useEffect","handleTopLevelError","useMemo","error","errorInfo","unsanitizedError","sanitizedError","sanitizeError","jsx","ComponentsProvider","LoadingIndicatorProvider","ObservabilityProvider","ErrorBoundary","InternalError","ThemeProvider","LocaleProvider","I18nextProvider","ApiProvider"],"mappings":";;;;;;;;;;;;;;;;;AAgDA,MAAMA,IAA4E,CAAAC,MAAS;AACzF,QAAM;AAAA,IACJ,UAAAC;AAAA,IACA,QAAAC;AAAA,IACA,YAAAC;AAAA,IACA,KAAAC,IAAM;AAAA,IACN,QAAAC,IAAS;AAAA,IACT,UAAAC,IAAW;AAA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gBAAAgB,EAACO,GAAA,EAAe,QAAAzB,GAAgB,UAAAC,GAC9B,UAAA,gBAAAiB,EAACQ,GAAA,EAAgB,MAAMjB,GACrB,UAAA,gBAAAS;AAAA,IAACS;AAAA,IAAA;AAAA,MACC,KAAK9B,EAAO;AAAA,MACZ,SAASA,EAAO;AAAA,MAChB,OAAOA,EAAO;AAAA,MACd,aAAAQ;AAAA,MAEC,UAAAT;AAAA,IAAA;AAAA,EAAA,KAPmCG,CASxC,GACF,GACF,EAAA,CACF,EAAA,CACF,GACF,GACF;AAEJ;"}
@@ -1,19 +1,20 @@
1
1
  import i from "dompurify";
2
2
  import "react-i18next";
3
3
  import "react";
4
- const c = (t) => t.charAt(0).toLocaleUpperCase() + t.slice(1), h = ({
4
+ import "../contexts/LocaleProvider/useLocale.js";
5
+ const c = (t) => t.charAt(0).toLocaleUpperCase() + t.slice(1), F = ({
5
6
  first_name: t,
6
7
  last_name: e
7
8
  }) => `${t ? c(t) : ""}${e ? n(c(e)) : ""}`, n = (t) => t ? ` ${t}` : "", m = (t) => {
8
9
  const e = n(t.street1), r = n(t.street2);
9
10
  return `${e},${r}`;
10
- }, u = (t) => `${n(t.city)}, ${n(t.state)} ${n(t.zip)}`, F = (t) => `${m(t)} ${u(t)}`, l = (t, e) => e ? `${t}%` : `$${t}`, s = (t, e = "en-US") => {
11
+ }, u = (t) => `${n(t.city)}, ${n(t.state)} ${n(t.zip)}`, S = (t) => `${m(t)} ${u(t)}`, l = (t, e) => e ? `${t}%` : `$${t}`, s = (t, e = "en-US") => {
11
12
  const r = t.toLocaleString(e, {
12
13
  minimumFractionDigits: 2,
13
14
  maximumFractionDigits: 2
14
15
  });
15
16
  return l(r, !1);
16
- }, S = ({
17
+ }, C = ({
17
18
  rate: t,
18
19
  paymentUnit: e,
19
20
  t: r,
@@ -41,26 +42,26 @@ const c = (t) => t.charAt(0).toLocaleUpperCase() + t.slice(1), h = ({
41
42
  return o;
42
43
  }
43
44
  }, p = { ALLOWED_TAGS: ["a", "b", "strong"], ALLOWED_ATTR: ["href", "target"] };
44
- function C(t) {
45
+ function D(t) {
45
46
  return t ? { __html: i.sanitize(t, p) } : { __html: "" };
46
47
  }
47
- const $ = (t) => t.replace(/\D/g, ""), D = (t) => t.replace(/\.value$/, ""), L = (t) => t.replace(/_([a-z])/g, (e, r) => r.toUpperCase()), R = (t) => {
48
+ const $ = (t) => t.replace(/\D/g, ""), L = (t) => t.replace(/\.value$/, ""), R = (t) => t.replace(/_([a-z])/g, (e, r) => r.toUpperCase()), k = (t) => {
48
49
  if (!t) return "";
49
50
  const e = $(String(t));
50
51
  return e.length === 10 ? `${e.slice(0, 3)}-${e.slice(3, 6)}-${e.slice(6)}` : e.length === 11 && e.startsWith("1") ? `${e.slice(1, 4)}-${e.slice(4, 7)}-${e.slice(7)}` : e || "";
51
52
  };
52
53
  export {
53
- F as addressInline,
54
+ S as addressInline,
54
55
  l as amountStr,
55
- C as createMarkup,
56
- h as firstLastName,
56
+ D as createMarkup,
57
+ F as firstLastName,
57
58
  s as formatNumberAsCurrency,
58
- S as formatPayRate,
59
- R as formatPhoneNumber,
59
+ C as formatPayRate,
60
+ k as formatPhoneNumber,
60
61
  u as getCityStateZip,
61
62
  m as getStreet,
62
- D as normalizeErrorKeyForForm,
63
+ L as normalizeErrorKeyForForm,
63
64
  $ as removeNonDigits,
64
- L as snakeCaseToCamelCase
65
+ R as snakeCaseToCamelCase
65
66
  };
66
67
  //# sourceMappingURL=formattedStrings.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formattedStrings.js","sources":["../../src/helpers/formattedStrings.ts"],"sourcesContent":["import DOMPurify from 'dompurify'\nimport { type Location } from '@gusto/embedded-api/models/components/location'\nimport { type EmployeeAddress } from '@gusto/embedded-api/models/components/employeeaddress'\nimport { type TFunction } from 'i18next'\nimport { useTranslation } from 'react-i18next'\nimport { useCallback } from 'react'\nimport { useLocale } from '@/contexts/LocaleProvider/useLocale'\n\nconst capitalize = (word: string) => word.charAt(0).toLocaleUpperCase() + word.slice(1)\n\nexport const firstLastName = ({\n first_name,\n last_name,\n}: {\n first_name?: string | null\n last_name?: string | null\n}) =>\n `${first_name ? capitalize(first_name) : ''}${last_name ? maybeString(capitalize(last_name)) : ''}`\n\nconst maybeString = (str: string | null | undefined) => {\n return str ? ` ${str}` : ''\n}\n\nexport const getStreet = (address: EmployeeAddress | Location) => {\n const street1 = maybeString(address.street1)\n const street2 = maybeString(address.street2)\n\n return `${street1},${street2}`\n}\n\nexport const getCityStateZip = (address: EmployeeAddress | Location) =>\n `${maybeString(address.city)}, ${maybeString(address.state)} ${maybeString(address.zip)}`\n\nexport const addressInline = (address: EmployeeAddress | Location) =>\n `${getStreet(address)} ${getCityStateZip(address)}`\n\nexport const currentDateString = () => {\n const d = new Date()\n const dateString = `${String(d.getFullYear())}-${('0' + String(d.getMonth() + 1)).slice(-2)}-${('0' + String(d.getDate())).slice(-2)}`\n return dateString\n}\n\nexport function isNumberKey({ which, keyCode }: KeyboardEvent) {\n const charCode = which ? which : keyCode\n if (charCode > 31 && charCode != 46 && (charCode < 48 || charCode > 57)) return false\n return true\n}\n\nexport const booleanToString = (value: boolean) => (value ? 'true' : 'false')\n\nexport const amountStr = (amount: string, isPercentage: boolean) =>\n isPercentage ? `${amount}%` : `$${amount}`\n\nexport const formatNumberAsCurrency = (amount: number, locale: string = 'en-US') => {\n const formattedNumber = amount.toLocaleString(locale, {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n })\n return amountStr(formattedNumber, false)\n}\n\nexport const formatPayRate = ({\n rate,\n paymentUnit,\n t,\n locale = 'en-US',\n}: {\n rate: number\n paymentUnit: string\n t: TFunction\n locale?: string\n}) => {\n const amount = formatNumberAsCurrency(rate, locale)\n\n switch (paymentUnit) {\n case 'Hour':\n return t('payRateFormats.hourly', { amount, ns: 'common' })\n case 'Week':\n return t('payRateFormats.weekly', {\n amount: formatNumberAsCurrency(rate * 52, locale),\n ns: 'common',\n })\n case 'Month':\n return t('payRateFormats.monthly', {\n amount: formatNumberAsCurrency(rate * 12, locale),\n ns: 'common',\n })\n case 'Year':\n return t('payRateFormats.yearly', { amount, ns: 'common' })\n case 'Paycheck':\n return t('payRateFormats.paycheck', { amount, ns: 'common' })\n default:\n return amount\n }\n}\n\nexport const useFormatPayRate = () => {\n const { t } = useTranslation('common')\n const { locale } = useLocale()\n\n return useCallback(\n (rate: number, paymentUnit: string) => {\n return formatPayRate({ rate, paymentUnit, t, locale })\n },\n [t, locale],\n )\n}\n\nconst dompurifyConfig = { ALLOWED_TAGS: ['a', 'b', 'strong'], ALLOWED_ATTR: ['href', 'target'] }\nexport function createMarkup(dirty: string) {\n if (!dirty) return { __html: '' }\n return { __html: DOMPurify.sanitize(dirty, dompurifyConfig) }\n}\n\nexport const removeNonDigits = (value: string): string => {\n return value.replace(/\\D/g, '')\n}\n\nexport const normalizeErrorKeyForForm = (errorKey: string): string =>\n errorKey.replace(/\\.value$/, '')\n\nexport const snakeCaseToCamelCase = (s: string) => {\n return s.replace(/_([a-z])/g, (_: string, char: string) => char.toUpperCase())\n}\n\nexport const camelCaseToSnakeCase = (s: string) => {\n return s\n .replace(\n /([a-z0-9])([A-Z])/g,\n (_: string, group1: string, group2: string) => `${group1}_${group2.toLowerCase()}`,\n )\n .replace(\n /([A-Z])([A-Z])(?=[a-z])/g,\n (_: string, group1: string, group2: string) =>\n `${group1.toLowerCase()}_${group2.toLowerCase()}`,\n )\n .toLowerCase()\n}\n\nexport const formatPhoneNumber = (phoneNumber: string | number | null | undefined): string => {\n if (!phoneNumber) return ''\n\n const digits = removeNonDigits(String(phoneNumber))\n\n if (digits.length === 10) {\n return `${digits.slice(0, 3)}-${digits.slice(3, 6)}-${digits.slice(6)}`\n }\n\n if (digits.length === 11 && digits.startsWith('1')) {\n return `${digits.slice(1, 4)}-${digits.slice(4, 7)}-${digits.slice(7)}`\n }\n\n return digits || ''\n}\n"],"names":["capitalize","word","firstLastName","first_name","last_name","maybeString","str","getStreet","address","street1","street2","getCityStateZip","addressInline","amountStr","amount","isPercentage","formatNumberAsCurrency","locale","formattedNumber","formatPayRate","rate","paymentUnit","t","dompurifyConfig","createMarkup","dirty","DOMPurify","removeNonDigits","value","normalizeErrorKeyForForm","errorKey","snakeCaseToCamelCase","s","_","char","formatPhoneNumber","phoneNumber","digits"],"mappings":";;;AAQA,MAAMA,IAAa,CAACC,MAAiBA,EAAK,OAAO,CAAC,EAAE,sBAAsBA,EAAK,MAAM,CAAC,GAEzEC,IAAgB,CAAC;AAAA,EAC5B,YAAAC;AAAA,EACA,WAAAC;AACF,MAIE,GAAGD,IAAaH,EAAWG,CAAU,IAAI,EAAE,GAAGC,IAAYC,EAAYL,EAAWI,CAAS,CAAC,IAAI,EAAE,IAE7FC,IAAc,CAACC,MACZA,IAAM,IAAIA,CAAG,KAAK,IAGdC,IAAY,CAACC,MAAwC;AAChE,QAAMC,IAAUJ,EAAYG,EAAQ,OAAO,GACrCE,IAAUL,EAAYG,EAAQ,OAAO;AAE3C,SAAO,GAAGC,CAAO,IAAIC,CAAO;AAC9B,GAEaC,IAAkB,CAACH,MAC9B,GAAGH,EAAYG,EAAQ,IAAI,CAAC,KAAKH,EAAYG,EAAQ,KAAK,CAAC,IAAIH,EAAYG,EAAQ,GAAG,CAAC,IAE5EI,IAAgB,CAACJ,MAC5B,GAAGD,EAAUC,CAAO,CAAC,IAAIG,EAAgBH,CAAO,CAAC,IAgBtCK,IAAY,CAACC,GAAgBC,MACxCA,IAAe,GAAGD,CAAM,MAAM,IAAIA,CAAM,IAE7BE,IAAyB,CAACF,GAAgBG,IAAiB,YAAY;AAClF,QAAMC,IAAkBJ,EAAO,eAAeG,GAAQ;AAAA,IACpD,uBAAuB;AAAA,IACvB,uBAAuB;AAAA,EAAA,CACxB;AACD,SAAOJ,EAAUK,GAAiB,EAAK;AACzC,GAEaC,IAAgB,CAAC;AAAA,EAC5B,MAAAC;AAAA,EACA,aAAAC;AAAA,EACA,GAAAC;AAAA,EACA,QAAAL,IAAS;AACX,MAKM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AC,CAAC,KAGnEA,EAAO,WAAW,MAAMA,EAAO,WAAW,GAAG,IACxC,GAAGA,EAAO,MAAM,GAAG,CAAC,CAAC,IAAIA,EAAO,MAAM,GAAG,CAAC,CAAC,IAAIA,EAAO,MAAM,CAAC,CAAC,KAGhEA,KAAU;AACnB;"}
1
+ {"version":3,"file":"formattedStrings.js","sources":["../../src/helpers/formattedStrings.ts"],"sourcesContent":["import DOMPurify from 'dompurify'\nimport { type Location } from '@gusto/embedded-api/models/components/location'\nimport { type EmployeeAddress } from '@gusto/embedded-api/models/components/employeeaddress'\nimport { type TFunction } from 'i18next'\nimport { useTranslation } from 'react-i18next'\nimport { useCallback } from 'react'\nimport { useLocale } from '@/contexts/LocaleProvider/useLocale'\n\nconst capitalize = (word: string) => word.charAt(0).toLocaleUpperCase() + word.slice(1)\n\nexport const firstLastName = ({\n first_name,\n last_name,\n}: {\n first_name?: string | null\n last_name?: string | null\n}) =>\n `${first_name ? capitalize(first_name) : ''}${last_name ? maybeString(capitalize(last_name)) : ''}`\n\nconst maybeString = (str: string | null | undefined) => {\n return str ? ` ${str}` : ''\n}\n\nexport const getStreet = (address: EmployeeAddress | Location) => {\n const street1 = maybeString(address.street1)\n const street2 = maybeString(address.street2)\n\n return `${street1},${street2}`\n}\n\nexport const getCityStateZip = (address: EmployeeAddress | Location) =>\n `${maybeString(address.city)}, ${maybeString(address.state)} ${maybeString(address.zip)}`\n\nexport const addressInline = (address: EmployeeAddress | Location) =>\n `${getStreet(address)} ${getCityStateZip(address)}`\n\nexport const currentDateString = () => {\n const d = new Date()\n const dateString = `${String(d.getFullYear())}-${('0' + String(d.getMonth() + 1)).slice(-2)}-${('0' + String(d.getDate())).slice(-2)}`\n return dateString\n}\n\nexport function isNumberKey({ which, keyCode }: KeyboardEvent) {\n const charCode = which ? which : keyCode\n if (charCode > 31 && charCode != 46 && (charCode < 48 || charCode > 57)) return false\n return true\n}\n\nexport const booleanToString = (value: boolean) => (value ? 'true' : 'false')\n\nexport const amountStr = (amount: string, isPercentage: boolean) =>\n isPercentage ? `${amount}%` : `$${amount}`\n\nexport const formatNumberAsCurrency = (amount: number, locale: string = 'en-US') => {\n const formattedNumber = amount.toLocaleString(locale, {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n })\n return amountStr(formattedNumber, false)\n}\n\nexport const formatPayRate = ({\n rate,\n paymentUnit,\n t,\n locale = 'en-US',\n}: {\n rate: number\n paymentUnit: string\n t: TFunction\n locale?: string\n}) => {\n const amount = formatNumberAsCurrency(rate, locale)\n\n switch (paymentUnit) {\n case 'Hour':\n return t('payRateFormats.hourly', { amount, ns: 'common' })\n case 'Week':\n return t('payRateFormats.weekly', {\n amount: formatNumberAsCurrency(rate * 52, locale),\n ns: 'common',\n })\n case 'Month':\n return t('payRateFormats.monthly', {\n amount: formatNumberAsCurrency(rate * 12, locale),\n ns: 'common',\n })\n case 'Year':\n return t('payRateFormats.yearly', { amount, ns: 'common' })\n case 'Paycheck':\n return t('payRateFormats.paycheck', { amount, ns: 'common' })\n default:\n return amount\n }\n}\n\nexport const useFormatPayRate = () => {\n const { t } = useTranslation('common')\n const { locale } = useLocale()\n\n return useCallback(\n (rate: number, paymentUnit: string) => {\n return formatPayRate({ rate, paymentUnit, t, locale })\n },\n [t, locale],\n )\n}\n\nconst dompurifyConfig = { ALLOWED_TAGS: ['a', 'b', 'strong'], ALLOWED_ATTR: ['href', 'target'] }\nexport function createMarkup(dirty: string) {\n if (!dirty) return { __html: '' }\n return { __html: DOMPurify.sanitize(dirty, dompurifyConfig) }\n}\n\nexport const removeNonDigits = (value: string): string => {\n return value.replace(/\\D/g, '')\n}\n\nexport const normalizeErrorKeyForForm = (errorKey: string): string =>\n errorKey.replace(/\\.value$/, '')\n\nexport const snakeCaseToCamelCase = (s: string) => {\n return s.replace(/_([a-z])/g, (_: string, char: string) => char.toUpperCase())\n}\n\nexport const camelCaseToSnakeCase = (s: string) => {\n return s\n .replace(\n /([a-z0-9])([A-Z])/g,\n (_: string, group1: string, group2: string) => `${group1}_${group2.toLowerCase()}`,\n )\n .replace(\n /([A-Z])([A-Z])(?=[a-z])/g,\n (_: string, group1: string, group2: string) =>\n `${group1.toLowerCase()}_${group2.toLowerCase()}`,\n )\n .toLowerCase()\n}\n\nexport const formatPhoneNumber = (phoneNumber: string | number | null | undefined): string => {\n if (!phoneNumber) return ''\n\n const digits = removeNonDigits(String(phoneNumber))\n\n if (digits.length === 10) {\n return `${digits.slice(0, 3)}-${digits.slice(3, 6)}-${digits.slice(6)}`\n }\n\n if (digits.length === 11 && digits.startsWith('1')) {\n return `${digits.slice(1, 4)}-${digits.slice(4, 7)}-${digits.slice(7)}`\n }\n\n return digits || ''\n}\n"],"names":["capitalize","word","firstLastName","first_name","last_name","maybeString","str","getStreet","address","street1","street2","getCityStateZip","addressInline","amountStr","amount","isPercentage","formatNumberAsCurrency","locale","formattedNumber","formatPayRate","rate","paymentUnit","t","dompurifyConfig","createMarkup","dirty","DOMPurify","removeNonDigits","value","normalizeErrorKeyForForm","errorKey","snakeCaseToCamelCase","s","_","char","formatPhoneNumber","phoneNumber","digits"],"mappings":";;;;AAQA,MAAMA,IAAa,CAACC,MAAiBA,EAAK,OAAO,CAAC,EAAE,sBAAsBA,EAAK,MAAM,CAAC,GAEzEC,IAAgB,CAAC;AAAA,EAC5B,YAAAC;AAAA,EACA,WAAAC;AACF,MAIE,GAAGD,IAAaH,EAAWG,CAAU,IAAI,EAAE,GAAGC,IAAYC,EAAYL,EAAWI,CAAS,CAAC,IAAI,EAAE,IAE7FC,IAAc,CAACC,MACZA,IAAM,IAAIA,CAAG,KAAK,IAGdC,IAAY,CAACC,MAAwC;AAChE,QAAMC,IAAUJ,EAAYG,EAAQ,OAAO,GACrCE,IAAUL,EAAYG,EAAQ,OAAO;AAE3C,SAAO,GAAGC,CAAO,IAAIC,CAAO;AAC9B,GAEaC,IAAkB,CAACH,MAC9B,GAAGH,EAAYG,EAAQ,IAAI,CAAC,KAAKH,EAAYG,EAAQ,KAAK,CA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AAU,SAASD,GAAOF,CAAe,EAAA,IADvC,EAAE,QAAQ,GAAA;AAE/B;AAEO,MAAMI,IAAkB,CAACC,MACvBA,EAAM,QAAQ,OAAO,EAAE,GAGnBC,IAA2B,CAACC,MACvCA,EAAS,QAAQ,YAAY,EAAE,GAEpBC,IAAuB,CAACC,MAC5BA,EAAE,QAAQ,aAAa,CAACC,GAAWC,MAAiBA,EAAK,aAAa,GAiBlEC,IAAoB,CAACC,MAA4D;AAC5F,MAAI,CAACA,EAAa,QAAO;AAEzB,QAAMC,IAASV,EAAgB,OAAOS,CAAW,CAAC;AAElD,SAAIC,EAAO,WAAW,KACb,GAAGA,EAAO,MAAM,GAAG,CAAC,CAAC,IAAIA,EAAO,MAAM,GAAG,CAAC,CAAC,IAAIA,EAAO,MAAM,CAAC,CAAC,KAGnEA,EAAO,WAAW,MAAMA,EAAO,WAAW,GAAG,IACxC,GAAGA,EAAO,MAAM,GAAG,CAAC,CAAC,IAAIA,EAAO,MAAM,GAAG,CAAC,CAAC,IAAIA,EAAO,MAAM,CAAC,CAAC,KAGhEA,KAAU;AACnB;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gusto/embedded-react-sdk",
3
- "version": "0.35.0-rc.1",
3
+ "version": "0.35.0-rc.3",
4
4
  "homepage": "https://github.com/Gusto/embedded-react-sdk",
5
5
  "bugs": {
6
6
  "url": "https://github.com/Gusto/embedded-react-sdk/issues"
@@ -150,7 +150,7 @@
150
150
  "deepmerge": "^4.3.1",
151
151
  "dompurify": "^3.3.3",
152
152
  "i18next": "^25.8.18",
153
- "react-aria": "^3.45.0",
153
+ "react-aria": "^3.44.0",
154
154
  "react-aria-components": "1.13.0",
155
155
  "react-error-boundary": "^6.1.1",
156
156
  "react-hook-form": "^7.71.2",