@gusto/embedded-react-sdk 0.34.0 → 0.35.0-rc.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 +38 -0
- package/dist/components/Base/Base.d.ts +6 -2
- package/dist/components/Base/Base.js +105 -59
- package/dist/components/Base/Base.js.map +1 -1
- package/dist/components/Base/useBase.d.ts +1 -0
- package/dist/components/Base/useBase.js.map +1 -1
- package/dist/components/Base/useBaseSubmit.d.ts +1 -1
- package/dist/components/Base/useBaseSubmit.js +60 -33
- package/dist/components/Base/useBaseSubmit.js.map +1 -1
- package/dist/components/Common/HamburgerMenu/HamburgerMenu.d.ts +1 -1
- package/dist/components/Common/HamburgerMenu/HamburgerMenu.js +15 -13
- package/dist/components/Common/HamburgerMenu/HamburgerMenu.js.map +1 -1
- package/dist/components/Common/HamburgerMenu/HamburgerMenuTypes.d.ts +1 -0
- package/dist/components/Common/SignatureForm/SignatureFormFields.js +1 -1
- package/dist/components/Common/UI/Menu/Menu.js +26 -25
- package/dist/components/Common/UI/Menu/Menu.js.map +1 -1
- package/dist/components/Common/UI/Menu/Menu.module.scss.js +7 -7
- package/dist/components/Common/UI/Menu/MenuTypes.d.ts +5 -0
- package/dist/components/Common/UI/Menu/MenuTypes.js +4 -3
- package/dist/components/Common/UI/Menu/MenuTypes.js.map +1 -1
- package/dist/components/Common/UI/Table/Table.module.scss.js +1 -1
- package/dist/components/Company/AssignSignatory/AssignSignatorySelection.js +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.js +12 -12
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +3 -4
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.js +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +3 -4
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +5 -6
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/Form.js +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +3 -4
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountVerify/Form.js +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +3 -4
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js +3 -4
- package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
- package/dist/components/Company/FederalTaxes/Form.js +1 -1
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +5 -6
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Company/Industry/Context.js +6 -7
- package/dist/components/Company/Industry/Context.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/Form.js +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +3 -4
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js +3 -4
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +3 -4
- package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
- package/dist/components/Company/PaySchedule/_parts/Edit.js +15 -15
- package/dist/components/Company/PaySchedule/usePaySchedule.js +5 -6
- package/dist/components/Company/PaySchedule/usePaySchedule.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +3 -4
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +3 -4
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
- package/dist/components/Contractor/Address/Form.js +1 -1
- package/dist/components/Contractor/Address/useAddress.js +5 -6
- package/dist/components/Contractor/Address/useAddress.js.map +1 -1
- package/dist/components/Contractor/PaymentMethod/BankAccountForm.js +2 -2
- package/dist/components/Contractor/PaymentMethod/PaymentTypeForm.js +1 -1
- package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js +119 -113
- package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js.map +1 -1
- package/dist/components/Contractor/Payments/CreatePayment/EditContractorPaymentPresentation.js +10 -10
- package/dist/components/Contractor/Profile/ContractorProfileForm.js +15 -15
- package/dist/components/Employee/Compensation/Edit.js +70 -70
- package/dist/components/Employee/Compensation/Edit.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/ChildSupportForm.js +9 -10
- package/dist/components/Employee/Deductions/DeductionsForm/ChildSupportForm.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.js +10 -11
- package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.js +10 -11
- package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js +3 -4
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/EmploymentEligibility/EmploymentEligibilityPresentation.js +18 -18
- package/dist/components/Employee/DocumentSigner/I9SignatureForm/I9SignatureForm.js +7 -7
- package/dist/components/Employee/DocumentSigner/SignatureForm/Form.js +5 -5
- package/dist/components/Employee/DocumentSigner/SignatureForm/Form.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/Preview.js +8 -8
- package/dist/components/Employee/DocumentSigner/SignatureForm/Preview.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js +3 -4
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
- package/dist/components/Employee/EmployeeList/useEmployeeList.js +3 -4
- package/dist/components/Employee/EmployeeList/useEmployeeList.js.map +1 -1
- package/dist/components/Employee/FederalTaxes/FederalForm.js +7 -7
- package/dist/components/Employee/FederalTaxes/useFederalTaxes.js +3 -4
- package/dist/components/Employee/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/BankAccountEdit.js +2 -2
- package/dist/components/Employee/PaymentMethod/PaymentTypeForm.js +1 -1
- package/dist/components/Employee/PaymentMethod/Split.js +8 -8
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +5 -6
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js.map +1 -1
- package/dist/components/Employee/Profile/AdminPersonalDetails.js +1 -1
- package/dist/components/Employee/Profile/HomeAddress.js +1 -1
- package/dist/components/Employee/Profile/PersonalDetailsInputs.js +2 -2
- package/dist/components/Employee/Profile/useProfile.js +3 -4
- package/dist/components/Employee/Profile/useProfile.js.map +1 -1
- package/dist/components/Employee/StateTaxes/StateTaxes.js +69 -61
- package/dist/components/Employee/StateTaxes/StateTaxes.js.map +1 -1
- package/dist/components/Employee/StateTaxes/useStateTaxes.js +3 -4
- package/dist/components/Employee/StateTaxes/useStateTaxes.js.map +1 -1
- package/dist/components/Employee/Taxes/FederalForm.js +7 -7
- package/dist/components/Employee/Taxes/useTaxes.js +3 -4
- package/dist/components/Employee/Taxes/useTaxes.js.map +1 -1
- package/dist/components/InformationRequests/InformationRequestForm/InformationRequestForm.js +10 -10
- package/dist/components/InformationRequests/InformationRequestForm/InformationRequestForm.js.map +1 -1
- package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetailsForm/ConfirmWireDetailsForm.js +9 -9
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.d.ts +2 -0
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +101 -0
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js.map +1 -0
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.module.scss.js +16 -0
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.module.scss.js.map +1 -0
- package/dist/components/Payroll/GrossUpModal/GrossUpModalTypes.d.ts +7 -0
- package/dist/components/Payroll/GrossUpModal/index.d.ts +3 -0
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js +86 -67
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js.map +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.d.ts +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.js +83 -49
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.js.map +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationTypes.d.ts +6 -0
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormPresentation.js +1 -1
- package/dist/components/Payroll/OffCycleReasonSelection/OffCycleReasonSelectionPresentation.js +1 -1
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModal.js +102 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModal.js.map +1 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModal.module.scss.js +14 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingModal/OffCycleTaxWithholdingModal.module.scss.js.map +1 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTable.js +52 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTable.js.map +1 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTable.module.scss.js +16 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTable.module.scss.js.map +1 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTableTypes.d.ts +12 -2
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTableTypes.js +15 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTableTypes.js.map +1 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/index.d.ts +2 -1
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js +212 -120
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.d.ts +3 -1
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js +76 -64
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/grossUpHelpers.d.ts +2 -0
- package/dist/components/Payroll/PayrollConfiguration/grossUpHelpers.js +11 -0
- package/dist/components/Payroll/PayrollConfiguration/grossUpHelpers.js.map +1 -0
- package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js +67 -57
- package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js +36 -36
- package/dist/components/Payroll/PayrollEditEmployee/TimeOffField.js +6 -6
- package/dist/components/Payroll/usePreparedPayrollData.js +44 -44
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.d.ts +2 -0
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +58 -39
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
- package/dist/contexts/ObservabilityProvider/ObservabilityContext.d.ts +5 -0
- package/dist/contexts/ObservabilityProvider/ObservabilityContext.js +6 -0
- package/dist/contexts/ObservabilityProvider/ObservabilityContext.js.map +1 -0
- package/dist/contexts/ObservabilityProvider/ObservabilityProvider.d.ts +7 -0
- package/dist/contexts/ObservabilityProvider/ObservabilityProvider.js +11 -0
- package/dist/contexts/ObservabilityProvider/ObservabilityProvider.js.map +1 -0
- package/dist/contexts/ObservabilityProvider/index.d.ts +5 -0
- package/dist/contexts/ObservabilityProvider/observabilityUtils.d.ts +5 -0
- package/dist/contexts/ObservabilityProvider/observabilityUtils.js +45 -0
- package/dist/contexts/ObservabilityProvider/observabilityUtils.js.map +1 -0
- package/dist/contexts/ObservabilityProvider/sanitization.d.ts +19 -0
- package/dist/contexts/ObservabilityProvider/sanitization.js +95 -0
- package/dist/contexts/ObservabilityProvider/sanitization.js.map +1 -0
- package/dist/contexts/ObservabilityProvider/sanitization.test.d.ts +1 -0
- package/dist/contexts/ObservabilityProvider/useObservability.d.ts +2 -0
- package/dist/contexts/ObservabilityProvider/useObservability.js +11 -0
- package/dist/contexts/ObservabilityProvider/useObservability.js.map +1 -0
- package/dist/contexts/ObservabilityProvider/useSanitizedObservability.d.ts +8 -0
- package/dist/contexts/ObservabilityProvider/useSanitizedObservability.js +28 -0
- package/dist/contexts/ObservabilityProvider/useSanitizedObservability.js.map +1 -0
- package/dist/contexts/index.d.ts +2 -0
- package/dist/helpers/formattedStrings.js +12 -13
- package/dist/helpers/formattedStrings.js.map +1 -1
- package/dist/helpers/rem.d.ts +7 -3
- package/dist/helpers/rem.js +14 -10
- package/dist/helpers/rem.js.map +1 -1
- package/dist/helpers/rem.test.d.ts +1 -0
- package/dist/helpers/retryAsync.d.ts +7 -0
- package/dist/helpers/retryAsync.js +18 -0
- package/dist/helpers/retryAsync.js.map +1 -0
- package/dist/i18n/I18n.js +15 -15
- package/dist/i18n/I18n.js.map +1 -1
- package/dist/i18n/en/Company.PaySchedule.json.js +1 -1
- package/dist/i18n/en/Payroll.GrossUpModal.json.js +24 -0
- package/dist/i18n/en/Payroll.GrossUpModal.json.js.map +1 -0
- package/dist/i18n/en/Payroll.OffCycleTaxWithholding.json.js +13 -11
- package/dist/i18n/en/Payroll.OffCycleTaxWithholding.json.js.map +1 -1
- package/dist/i18n/en/Payroll.PayrollConfiguration.json.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +19 -13
- package/dist/index.js.map +1 -1
- package/dist/shared/constants.d.ts +5 -0
- package/dist/shared/constants.js +11 -8
- package/dist/shared/constants.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/i18next.d.ts +26 -1
- package/dist/types/observability.d.ts +145 -0
- package/docs/reference/endpoint-inventory.json +10 -1
- package/package.json +21 -21
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { APIError as r } from "@gusto/embedded-api/models/errors/apierror";
|
|
2
|
+
import { GustoEmbeddedError as s } from "@gusto/embedded-api/models/errors/gustoembeddederror";
|
|
3
|
+
import { SDKValidationError as e } from "@gusto/embedded-api/models/errors/sdkvalidationerror";
|
|
4
|
+
function u(t, n) {
|
|
5
|
+
const o = Date.now(), i = t instanceof Error ? t.message : "Unknown error", a = t instanceof Error ? t.stack : void 0;
|
|
6
|
+
return t instanceof e ? {
|
|
7
|
+
type: n || "validation_error",
|
|
8
|
+
message: i,
|
|
9
|
+
stack: a,
|
|
10
|
+
context: {
|
|
11
|
+
validationSchema: t.pretty()
|
|
12
|
+
},
|
|
13
|
+
originalError: t,
|
|
14
|
+
timestamp: o
|
|
15
|
+
} : t instanceof r ? {
|
|
16
|
+
type: n || "api_error",
|
|
17
|
+
message: i,
|
|
18
|
+
stack: a,
|
|
19
|
+
context: {
|
|
20
|
+
statusCode: t.httpMeta.response.status
|
|
21
|
+
},
|
|
22
|
+
originalError: t,
|
|
23
|
+
timestamp: o
|
|
24
|
+
} : t instanceof s ? {
|
|
25
|
+
type: n || "api_error",
|
|
26
|
+
message: i,
|
|
27
|
+
stack: a,
|
|
28
|
+
context: {
|
|
29
|
+
statusCode: t.httpMeta.response.status
|
|
30
|
+
},
|
|
31
|
+
originalError: t,
|
|
32
|
+
timestamp: o
|
|
33
|
+
} : n ? {
|
|
34
|
+
type: n,
|
|
35
|
+
message: i,
|
|
36
|
+
stack: a,
|
|
37
|
+
context: {},
|
|
38
|
+
originalError: t,
|
|
39
|
+
timestamp: o
|
|
40
|
+
} : null;
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
u as createObservabilityError
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=observabilityUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observabilityUtils.js","sources":["../../../src/contexts/ObservabilityProvider/observabilityUtils.ts"],"sourcesContent":["import { APIError } from '@gusto/embedded-api/models/errors/apierror'\nimport { GustoEmbeddedError } from '@gusto/embedded-api/models/errors/gustoembeddederror'\nimport { SDKValidationError } from '@gusto/embedded-api/models/errors/sdkvalidationerror'\nimport type { ObservabilityError, ObservabilityErrorType } from '@/types/observability'\n\n/**\n * Converts SDK errors into structured ObservabilityError objects\n */\nexport function createObservabilityError(\n error: unknown,\n type?: ObservabilityErrorType,\n): ObservabilityError | null {\n const timestamp = Date.now()\n const message = error instanceof Error ? error.message : 'Unknown error'\n const stack = error instanceof Error ? error.stack : undefined\n\n // Auto-detect error type based on instance if not provided\n if (error instanceof SDKValidationError) {\n return {\n type: type || 'validation_error',\n message,\n stack,\n context: {\n validationSchema: error.pretty(),\n },\n originalError: error,\n timestamp,\n }\n }\n\n if (error instanceof APIError) {\n return {\n type: type || 'api_error',\n message,\n stack,\n context: {\n statusCode: error.httpMeta.response.status,\n },\n originalError: error,\n timestamp,\n }\n }\n\n if (error instanceof GustoEmbeddedError) {\n return {\n type: type || 'api_error',\n message,\n stack,\n context: {\n statusCode: error.httpMeta.response.status,\n },\n originalError: error,\n timestamp,\n }\n }\n\n // For unknown errors, only create ObservabilityError if type is explicitly provided\n if (type) {\n return {\n type,\n message,\n stack,\n context: {},\n originalError: error,\n timestamp,\n }\n }\n\n return null\n}\n"],"names":["createObservabilityError","error","type","timestamp","message","stack","SDKValidationError","APIError","GustoEmbeddedError"],"mappings":";;;AAQO,SAASA,EACdC,GACAC,GAC2B;AAC3B,QAAMC,IAAY,KAAK,IAAA,GACjBC,IAAUH,aAAiB,QAAQA,EAAM,UAAU,iBACnDI,IAAQJ,aAAiB,QAAQA,EAAM,QAAQ;AAGrD,SAAIA,aAAiBK,IACZ;AAAA,IACL,MAAMJ,KAAQ;AAAA,IACd,SAAAE;AAAA,IACA,OAAAC;AAAA,IACA,SAAS;AAAA,MACP,kBAAkBJ,EAAM,OAAA;AAAA,IAAO;AAAA,IAEjC,eAAeA;AAAA,IACf,WAAAE;AAAA,EAAA,IAIAF,aAAiBM,IACZ;AAAA,IACL,MAAML,KAAQ;AAAA,IACd,SAAAE;AAAA,IACA,OAAAC;AAAA,IACA,SAAS;AAAA,MACP,YAAYJ,EAAM,SAAS,SAAS;AAAA,IAAA;AAAA,IAEtC,eAAeA;AAAA,IACf,WAAAE;AAAA,EAAA,IAIAF,aAAiBO,IACZ;AAAA,IACL,MAAMN,KAAQ;AAAA,IACd,SAAAE;AAAA,IACA,OAAAC;AAAA,IACA,SAAS;AAAA,MACP,YAAYJ,EAAM,SAAS,SAAS;AAAA,IAAA;AAAA,IAEtC,eAAeA;AAAA,IACf,WAAAE;AAAA,EAAA,IAKAD,IACK;AAAA,IACL,MAAAA;AAAA,IACA,SAAAE;AAAA,IACA,OAAAC;AAAA,IACA,SAAS,CAAA;AAAA,IACT,eAAeJ;AAAA,IACf,WAAAE;AAAA,EAAA,IAIG;AACT;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ObservabilityError, ObservabilityMetric, SanitizationConfig } from '../../types/observability';
|
|
2
|
+
/**
|
|
3
|
+
* Sanitizes a string by replacing PII patterns with redacted placeholders
|
|
4
|
+
*/
|
|
5
|
+
export declare function sanitizeString(value: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Recursively sanitizes an object by:
|
|
8
|
+
* 1. Removing sensitive field names
|
|
9
|
+
* 2. Redacting PII patterns in string values
|
|
10
|
+
*/
|
|
11
|
+
export declare function sanitizeObject(obj: unknown, additionalSensitiveFields?: string[]): unknown;
|
|
12
|
+
/**
|
|
13
|
+
* Sanitizes an ObservabilityError to remove PII
|
|
14
|
+
*/
|
|
15
|
+
export declare function sanitizeError(error: ObservabilityError, config?: SanitizationConfig): ObservabilityError;
|
|
16
|
+
/**
|
|
17
|
+
* Sanitizes an ObservabilityMetric to remove PII
|
|
18
|
+
*/
|
|
19
|
+
export declare function sanitizeMetric(metric: ObservabilityMetric, config?: SanitizationConfig): ObservabilityMetric;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
const u = [
|
|
2
|
+
// SSN patterns (XXX-XX-XXXX, XXXXXXXXX)
|
|
3
|
+
{ pattern: /\b\d{3}-\d{2}-\d{4}\b/g, replacement: "[SSN-REDACTED]" },
|
|
4
|
+
{ pattern: /\b\d{9}\b/g, replacement: "[SSN-REDACTED]" },
|
|
5
|
+
// Email addresses
|
|
6
|
+
{
|
|
7
|
+
pattern: /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/g,
|
|
8
|
+
replacement: "[EMAIL-REDACTED]"
|
|
9
|
+
},
|
|
10
|
+
// Phone numbers (various formats)
|
|
11
|
+
{ pattern: /\b\d{3}[-.\s]?\d{3}[-.\s]?\d{4}\b/g, replacement: "[PHONE-REDACTED]" },
|
|
12
|
+
{ pattern: /\(\d{3}\)\s*\d{3}[-.\s]?\d{4}/g, replacement: "[PHONE-REDACTED]" },
|
|
13
|
+
// Credit card numbers (basic pattern)
|
|
14
|
+
{ pattern: /\b\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}\b/g, replacement: "[CC-REDACTED]" },
|
|
15
|
+
// API keys and tokens (common patterns)
|
|
16
|
+
{ pattern: /\b[A-Za-z0-9_-]{32,}\b/g, replacement: "[TOKEN-REDACTED]" }
|
|
17
|
+
], d = [
|
|
18
|
+
"password",
|
|
19
|
+
"token",
|
|
20
|
+
"apiKey",
|
|
21
|
+
"api_key",
|
|
22
|
+
"secret",
|
|
23
|
+
"ssn",
|
|
24
|
+
"social_security_number",
|
|
25
|
+
"creditCard",
|
|
26
|
+
"credit_card",
|
|
27
|
+
"cvv",
|
|
28
|
+
"pin",
|
|
29
|
+
"bankAccount",
|
|
30
|
+
"bank_account",
|
|
31
|
+
"routingNumber",
|
|
32
|
+
"routing_number",
|
|
33
|
+
"accountNumber",
|
|
34
|
+
"account_number"
|
|
35
|
+
];
|
|
36
|
+
function c(t) {
|
|
37
|
+
let e = t;
|
|
38
|
+
for (const { pattern: n, replacement: r } of u)
|
|
39
|
+
e = e.replace(n, r);
|
|
40
|
+
return e;
|
|
41
|
+
}
|
|
42
|
+
function s(t, e = []) {
|
|
43
|
+
if (t == null)
|
|
44
|
+
return t;
|
|
45
|
+
if (typeof t == "string")
|
|
46
|
+
return c(t);
|
|
47
|
+
if (typeof t == "number" || typeof t == "boolean")
|
|
48
|
+
return t;
|
|
49
|
+
if (Array.isArray(t))
|
|
50
|
+
return t.map((n) => s(n, e));
|
|
51
|
+
if (typeof t == "object") {
|
|
52
|
+
const n = {}, r = [...d, ...e];
|
|
53
|
+
for (const [i, a] of Object.entries(t)) {
|
|
54
|
+
if (r.some((o) => i.toLowerCase().includes(o.toLowerCase()))) {
|
|
55
|
+
n[i] = "[REDACTED]";
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
n[i] = s(a, e);
|
|
59
|
+
}
|
|
60
|
+
return n;
|
|
61
|
+
}
|
|
62
|
+
return t;
|
|
63
|
+
}
|
|
64
|
+
function E(t, e = {}) {
|
|
65
|
+
const {
|
|
66
|
+
enabled: n = !0,
|
|
67
|
+
includeOriginalError: r = !1,
|
|
68
|
+
customErrorSanitizer: i,
|
|
69
|
+
additionalSensitiveFields: a = []
|
|
70
|
+
} = e;
|
|
71
|
+
return i ? i(t) : n ? {
|
|
72
|
+
...t,
|
|
73
|
+
message: c(t.message),
|
|
74
|
+
stack: t.stack ? c(t.stack) : void 0,
|
|
75
|
+
context: s(
|
|
76
|
+
t.context,
|
|
77
|
+
a
|
|
78
|
+
),
|
|
79
|
+
originalError: r ? t.originalError : void 0
|
|
80
|
+
} : r ? t : { ...t, originalError: void 0 };
|
|
81
|
+
}
|
|
82
|
+
function l(t, e = {}) {
|
|
83
|
+
const { enabled: n = !0, customMetricSanitizer: r, additionalSensitiveFields: i = [] } = e;
|
|
84
|
+
return r ? r(t) : n ? {
|
|
85
|
+
...t,
|
|
86
|
+
tags: t.tags ? s(t.tags, i) : void 0
|
|
87
|
+
} : t;
|
|
88
|
+
}
|
|
89
|
+
export {
|
|
90
|
+
E as sanitizeError,
|
|
91
|
+
l as sanitizeMetric,
|
|
92
|
+
s as sanitizeObject,
|
|
93
|
+
c as sanitizeString
|
|
94
|
+
};
|
|
95
|
+
//# sourceMappingURL=sanitization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitization.js","sources":["../../../src/contexts/ObservabilityProvider/sanitization.ts"],"sourcesContent":["import type {\n ObservabilityError,\n ObservabilityMetric,\n SanitizationConfig,\n} from '@/types/observability'\n\n/**\n * Common PII patterns to redact from strings\n */\nconst PII_PATTERNS = [\n // SSN patterns (XXX-XX-XXXX, XXXXXXXXX)\n { pattern: /\\b\\d{3}-\\d{2}-\\d{4}\\b/g, replacement: '[SSN-REDACTED]' },\n { pattern: /\\b\\d{9}\\b/g, replacement: '[SSN-REDACTED]' },\n\n // Email addresses\n {\n pattern: /\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}\\b/g,\n replacement: '[EMAIL-REDACTED]',\n },\n\n // Phone numbers (various formats)\n { pattern: /\\b\\d{3}[-.\\s]?\\d{3}[-.\\s]?\\d{4}\\b/g, replacement: '[PHONE-REDACTED]' },\n { pattern: /\\(\\d{3}\\)\\s*\\d{3}[-.\\s]?\\d{4}/g, replacement: '[PHONE-REDACTED]' },\n\n // Credit card numbers (basic pattern)\n { pattern: /\\b\\d{4}[-\\s]?\\d{4}[-\\s]?\\d{4}[-\\s]?\\d{4}\\b/g, replacement: '[CC-REDACTED]' },\n\n // API keys and tokens (common patterns)\n { pattern: /\\b[A-Za-z0-9_-]{32,}\\b/g, replacement: '[TOKEN-REDACTED]' },\n]\n\n/**\n * Fields that commonly contain sensitive data and should be removed\n */\nconst SENSITIVE_FIELD_NAMES = [\n 'password',\n 'token',\n 'apiKey',\n 'api_key',\n 'secret',\n 'ssn',\n 'social_security_number',\n 'creditCard',\n 'credit_card',\n 'cvv',\n 'pin',\n 'bankAccount',\n 'bank_account',\n 'routingNumber',\n 'routing_number',\n 'accountNumber',\n 'account_number',\n]\n\n/**\n * Sanitizes a string by replacing PII patterns with redacted placeholders\n */\nexport function sanitizeString(value: string): string {\n let sanitized = value\n\n for (const { pattern, replacement } of PII_PATTERNS) {\n sanitized = sanitized.replace(pattern, replacement)\n }\n\n return sanitized\n}\n\n/**\n * Recursively sanitizes an object by:\n * 1. Removing sensitive field names\n * 2. Redacting PII patterns in string values\n */\nexport function sanitizeObject(obj: unknown, additionalSensitiveFields: string[] = []): unknown {\n if (obj === null || obj === undefined) {\n return obj\n }\n\n if (typeof obj === 'string') {\n return sanitizeString(obj)\n }\n\n if (typeof obj === 'number' || typeof obj === 'boolean') {\n return obj\n }\n\n if (Array.isArray(obj)) {\n return obj.map(item => sanitizeObject(item, additionalSensitiveFields))\n }\n\n if (typeof obj === 'object') {\n const sanitized: Record<string, unknown> = {}\n\n // Combine default and additional sensitive fields for this call only\n const allSensitiveFields = [...SENSITIVE_FIELD_NAMES, ...additionalSensitiveFields]\n\n for (const [key, value] of Object.entries(obj)) {\n // Skip sensitive fields entirely\n if (allSensitiveFields.some(field => key.toLowerCase().includes(field.toLowerCase()))) {\n sanitized[key] = '[REDACTED]'\n continue\n }\n\n sanitized[key] = sanitizeObject(value, additionalSensitiveFields)\n }\n\n return sanitized\n }\n\n return obj\n}\n\n/**\n * Sanitizes an ObservabilityError to remove PII\n */\nexport function sanitizeError(\n error: ObservabilityError,\n config: SanitizationConfig = {},\n): ObservabilityError {\n const {\n enabled = true,\n includeOriginalError = false,\n customErrorSanitizer,\n additionalSensitiveFields = [],\n } = config\n\n // If custom sanitizer is provided, use it\n if (customErrorSanitizer) {\n return customErrorSanitizer(error)\n }\n\n // If sanitization is disabled, return as-is but still respect includeOriginalError\n if (!enabled) {\n return includeOriginalError ? error : { ...error, originalError: undefined }\n }\n\n // Sanitize the error, passing additionalSensitiveFields to sanitizeObject\n const sanitized: ObservabilityError = {\n ...error,\n message: sanitizeString(error.message),\n stack: error.stack ? sanitizeString(error.stack) : undefined,\n context: sanitizeObject(\n error.context,\n additionalSensitiveFields,\n ) as ObservabilityError['context'],\n originalError: includeOriginalError ? error.originalError : undefined,\n }\n\n return sanitized\n}\n\n/**\n * Sanitizes an ObservabilityMetric to remove PII\n */\nexport function sanitizeMetric(\n metric: ObservabilityMetric,\n config: SanitizationConfig = {},\n): ObservabilityMetric {\n const { enabled = true, customMetricSanitizer, additionalSensitiveFields = [] } = config\n\n // If custom sanitizer is provided, use it\n if (customMetricSanitizer) {\n return customMetricSanitizer(metric)\n }\n\n // If sanitization is disabled, return as-is\n if (!enabled) {\n return metric\n }\n\n // Sanitize metric tags (in case they contain dynamic values), passing additionalSensitiveFields\n const sanitized: ObservabilityMetric = {\n ...metric,\n tags: metric.tags\n ? (sanitizeObject(metric.tags, additionalSensitiveFields) as Record<string, string>)\n : undefined,\n }\n\n return sanitized\n}\n"],"names":["PII_PATTERNS","SENSITIVE_FIELD_NAMES","sanitizeString","value","sanitized","pattern","replacement","sanitizeObject","obj","additionalSensitiveFields","item","allSensitiveFields","key","field","sanitizeError","error","config","enabled","includeOriginalError","customErrorSanitizer","sanitizeMetric","metric","customMetricSanitizer"],"mappings":"AASA,MAAMA,IAAe;AAAA;AAAA,EAEnB,EAAE,SAAS,0BAA0B,aAAa,iBAAA;AAAA,EAClD,EAAE,SAAS,cAAc,aAAa,iBAAA;AAAA;AAAA,EAGtC;AAAA,IACE,SAAS;AAAA,IACT,aAAa;AAAA,EAAA;AAAA;AAAA,EAIf,EAAE,SAAS,sCAAsC,aAAa,mBAAA;AAAA,EAC9D,EAAE,SAAS,kCAAkC,aAAa,mBAAA;AAAA;AAAA,EAG1D,EAAE,SAAS,+CAA+C,aAAa,gBAAA;AAAA;AAAA,EAGvE,EAAE,SAAS,2BAA2B,aAAa,mBAAA;AACrD,GAKMC,IAAwB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKO,SAASC,EAAeC,GAAuB;AACpD,MAAIC,IAAYD;AAEhB,aAAW,EAAE,SAAAE,GAAS,aAAAC,EAAA,KAAiBN;AACrC,IAAAI,IAAYA,EAAU,QAAQC,GAASC,CAAW;AAGpD,SAAOF;AACT;AAOO,SAASG,EAAeC,GAAcC,IAAsC,IAAa;AAC9F,MAAID,KAAQ;AACV,WAAOA;AAGT,MAAI,OAAOA,KAAQ;AACjB,WAAON,EAAeM,CAAG;AAG3B,MAAI,OAAOA,KAAQ,YAAY,OAAOA,KAAQ;AAC5C,WAAOA;AAGT,MAAI,MAAM,QAAQA,CAAG;AACnB,WAAOA,EAAI,IAAI,CAAAE,MAAQH,EAAeG,GAAMD,CAAyB,CAAC;AAGxE,MAAI,OAAOD,KAAQ,UAAU;AAC3B,UAAMJ,IAAqC,CAAA,GAGrCO,IAAqB,CAAC,GAAGV,GAAuB,GAAGQ,CAAyB;AAElF,eAAW,CAACG,GAAKT,CAAK,KAAK,OAAO,QAAQK,CAAG,GAAG;AAE9C,UAAIG,EAAmB,KAAK,CAAAE,MAASD,EAAI,YAAA,EAAc,SAASC,EAAM,YAAA,CAAa,CAAC,GAAG;AACrF,QAAAT,EAAUQ,CAAG,IAAI;AACjB;AAAA,MACF;AAEA,MAAAR,EAAUQ,CAAG,IAAIL,EAAeJ,GAAOM,CAAyB;AAAA,IAClE;AAEA,WAAOL;AAAA,EACT;AAEA,SAAOI;AACT;AAKO,SAASM,EACdC,GACAC,IAA6B,IACT;AACpB,QAAM;AAAA,IACJ,SAAAC,IAAU;AAAA,IACV,sBAAAC,IAAuB;AAAA,IACvB,sBAAAC;AAAA,IACA,2BAAAV,IAA4B,CAAA;AAAA,EAAC,IAC3BO;AAGJ,SAAIG,IACKA,EAAqBJ,CAAK,IAI9BE,IAKiC;AAAA,IACpC,GAAGF;AAAA,IACH,SAASb,EAAea,EAAM,OAAO;AAAA,IACrC,OAAOA,EAAM,QAAQb,EAAea,EAAM,KAAK,IAAI;AAAA,IACnD,SAASR;AAAA,MACPQ,EAAM;AAAA,MACNN;AAAA,IAAA;AAAA,IAEF,eAAeS,IAAuBH,EAAM,gBAAgB;AAAA,EAAA,IAZrDG,IAAuBH,IAAQ,EAAE,GAAGA,GAAO,eAAe,OAAA;AAgBrE;AAKO,SAASK,EACdC,GACAL,IAA6B,IACR;AACrB,QAAM,EAAE,SAAAC,IAAU,IAAM,uBAAAK,GAAuB,2BAAAb,IAA4B,CAAA,MAAOO;AAGlF,SAAIM,IACKA,EAAsBD,CAAM,IAIhCJ,IAKkC;AAAA,IACrC,GAAGI;AAAA,IACH,MAAMA,EAAO,OACRd,EAAec,EAAO,MAAMZ,CAAyB,IACtD;AAAA,EAAA,IARGY;AAYX;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useContext as t } from "react";
|
|
2
|
+
import { ObservabilityContext as e } from "./ObservabilityContext.js";
|
|
3
|
+
import { useSanitizedObservability as r } from "./useSanitizedObservability.js";
|
|
4
|
+
const n = () => {
|
|
5
|
+
const i = t(e);
|
|
6
|
+
return i === void 0 ? { observability: void 0 } : { observability: r(i.observability) };
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
n as useObservability
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=useObservability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useObservability.js","sources":["../../../src/contexts/ObservabilityProvider/useObservability.ts"],"sourcesContent":["import { useContext } from 'react'\nimport { ObservabilityContext } from './ObservabilityContext'\nimport type { ObservabilityContextValue } from './ObservabilityContext'\nimport { useSanitizedObservability } from './useSanitizedObservability'\n\nexport const useObservability = (): ObservabilityContextValue => {\n const context = useContext(ObservabilityContext)\n if (context === undefined) {\n return { observability: undefined }\n }\n\n const sanitizedObservability = useSanitizedObservability(context.observability)\n\n return { observability: sanitizedObservability }\n}\n"],"names":["useObservability","context","useContext","ObservabilityContext","useSanitizedObservability"],"mappings":";;;AAKO,MAAMA,IAAmB,MAAiC;AAC/D,QAAMC,IAAUC,EAAWC,CAAoB;AAC/C,SAAIF,MAAY,SACP,EAAE,eAAe,OAAA,IAKnB,EAAE,eAFsBG,EAA0BH,EAAQ,aAAa,EAEtD;AAC1B;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ObservabilityError, ObservabilityMetric, ObservabilityHook } from '../../types/observability';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps an ObservabilityHook to apply sanitization before calling the callbacks
|
|
4
|
+
*/
|
|
5
|
+
export declare function useSanitizedObservability(observability?: ObservabilityHook): {
|
|
6
|
+
onError: ((error: ObservabilityError) => void) | undefined;
|
|
7
|
+
onMetric: ((metric: ObservabilityMetric) => void) | undefined;
|
|
8
|
+
} | undefined;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useCallback as i } from "react";
|
|
2
|
+
import { sanitizeError as f, sanitizeMetric as u } from "./sanitization.js";
|
|
3
|
+
function E(n) {
|
|
4
|
+
const r = n?.sanitization, c = i(
|
|
5
|
+
(o) => {
|
|
6
|
+
if (!n?.onError) return;
|
|
7
|
+
const t = f(o, r);
|
|
8
|
+
n.onError(t);
|
|
9
|
+
},
|
|
10
|
+
[n, r]
|
|
11
|
+
), e = i(
|
|
12
|
+
(o) => {
|
|
13
|
+
if (!n?.onMetric) return;
|
|
14
|
+
const t = u(o, r);
|
|
15
|
+
n.onMetric(t);
|
|
16
|
+
},
|
|
17
|
+
[n, r]
|
|
18
|
+
);
|
|
19
|
+
if (n)
|
|
20
|
+
return {
|
|
21
|
+
onError: n.onError ? c : void 0,
|
|
22
|
+
onMetric: n.onMetric ? e : void 0
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
E as useSanitizedObservability
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=useSanitizedObservability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSanitizedObservability.js","sources":["../../../src/contexts/ObservabilityProvider/useSanitizedObservability.ts"],"sourcesContent":["import { useCallback } from 'react'\nimport { sanitizeError, sanitizeMetric } from './sanitization'\nimport type {\n ObservabilityError,\n ObservabilityMetric,\n ObservabilityHook,\n} from '@/types/observability'\n\n/**\n * Wraps an ObservabilityHook to apply sanitization before calling the callbacks\n */\nexport function useSanitizedObservability(observability?: ObservabilityHook) {\n const sanitizationConfig = observability?.sanitization\n\n const onError = useCallback(\n (error: ObservabilityError) => {\n if (!observability?.onError) return\n\n const sanitized = sanitizeError(error, sanitizationConfig)\n observability.onError(sanitized)\n },\n [observability, sanitizationConfig],\n )\n\n const onMetric = useCallback(\n (metric: ObservabilityMetric) => {\n if (!observability?.onMetric) return\n\n const sanitized = sanitizeMetric(metric, sanitizationConfig)\n observability.onMetric(sanitized)\n },\n [observability, sanitizationConfig],\n )\n\n if (!observability) {\n return undefined\n }\n\n return {\n onError: observability.onError ? onError : undefined,\n onMetric: observability.onMetric ? onMetric : undefined,\n }\n}\n"],"names":["useSanitizedObservability","observability","sanitizationConfig","onError","useCallback","error","sanitized","sanitizeError","onMetric","metric","sanitizeMetric"],"mappings":";;AAWO,SAASA,EAA0BC,GAAmC;AAC3E,QAAMC,IAAqBD,GAAe,cAEpCE,IAAUC;AAAA,IACd,CAACC,MAA8B;AAC7B,UAAI,CAACJ,GAAe,QAAS;AAE7B,YAAMK,IAAYC,EAAcF,GAAOH,CAAkB;AACzD,MAAAD,EAAc,QAAQK,CAAS;AAAA,IACjC;AAAA,IACA,CAACL,GAAeC,CAAkB;AAAA,EAAA,GAG9BM,IAAWJ;AAAA,IACf,CAACK,MAAgC;AAC/B,UAAI,CAACR,GAAe,SAAU;AAE9B,YAAMK,IAAYI,EAAeD,GAAQP,CAAkB;AAC3D,MAAAD,EAAc,SAASK,CAAS;AAAA,IAClC;AAAA,IACA,CAACL,GAAeC,CAAkB;AAAA,EAAA;AAGpC,MAAKD;AAIL,WAAO;AAAA,MACL,SAASA,EAAc,UAAUE,IAAU;AAAA,MAC3C,UAAUF,EAAc,WAAWO,IAAW;AAAA,IAAA;AAElD;"}
|
package/dist/contexts/index.d.ts
CHANGED
|
@@ -7,3 +7,5 @@ export { ApiProvider } from './ApiProvider/ApiProvider';
|
|
|
7
7
|
export type { ApiProviderProps } from './ApiProvider/ApiProvider';
|
|
8
8
|
export type { ComponentsContextType } from './ComponentAdapter/useComponentContext';
|
|
9
9
|
export * from './ComponentAdapter/componentAdapterTypes';
|
|
10
|
+
export { ObservabilityProvider, useObservability } from './ObservabilityProvider';
|
|
11
|
+
export type { ObservabilityProviderProps } from './ObservabilityProvider';
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import i from "dompurify";
|
|
2
2
|
import "react-i18next";
|
|
3
3
|
import "react";
|
|
4
|
-
|
|
5
|
-
const c = (t) => t.charAt(0).toLocaleUpperCase() + t.slice(1), F = ({
|
|
4
|
+
const c = (t) => t.charAt(0).toLocaleUpperCase() + t.slice(1), h = ({
|
|
6
5
|
first_name: t,
|
|
7
6
|
last_name: e
|
|
8
7
|
}) => `${t ? c(t) : ""}${e ? n(c(e)) : ""}`, n = (t) => t ? ` ${t}` : "", m = (t) => {
|
|
9
8
|
const e = n(t.street1), r = n(t.street2);
|
|
10
9
|
return `${e},${r}`;
|
|
11
|
-
}, u = (t) => `${n(t.city)}, ${n(t.state)} ${n(t.zip)}`,
|
|
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") => {
|
|
12
11
|
const r = t.toLocaleString(e, {
|
|
13
12
|
minimumFractionDigits: 2,
|
|
14
13
|
maximumFractionDigits: 2
|
|
15
14
|
});
|
|
16
15
|
return l(r, !1);
|
|
17
|
-
},
|
|
16
|
+
}, S = ({
|
|
18
17
|
rate: t,
|
|
19
18
|
paymentUnit: e,
|
|
20
19
|
t: r,
|
|
@@ -42,26 +41,26 @@ const c = (t) => t.charAt(0).toLocaleUpperCase() + t.slice(1), F = ({
|
|
|
42
41
|
return o;
|
|
43
42
|
}
|
|
44
43
|
}, p = { ALLOWED_TAGS: ["a", "b", "strong"], ALLOWED_ATTR: ["href", "target"] };
|
|
45
|
-
function
|
|
44
|
+
function C(t) {
|
|
46
45
|
return t ? { __html: i.sanitize(t, p) } : { __html: "" };
|
|
47
46
|
}
|
|
48
|
-
const $ = (t) => t.replace(/\D/g, ""),
|
|
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) => {
|
|
49
48
|
if (!t) return "";
|
|
50
49
|
const e = $(String(t));
|
|
51
50
|
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 || "";
|
|
52
51
|
};
|
|
53
52
|
export {
|
|
54
|
-
|
|
53
|
+
F as addressInline,
|
|
55
54
|
l as amountStr,
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
C as createMarkup,
|
|
56
|
+
h as firstLastName,
|
|
58
57
|
s as formatNumberAsCurrency,
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
S as formatPayRate,
|
|
59
|
+
R as formatPhoneNumber,
|
|
61
60
|
u as getCityStateZip,
|
|
62
61
|
m as getStreet,
|
|
63
|
-
|
|
62
|
+
D as normalizeErrorKeyForForm,
|
|
64
63
|
$ as removeNonDigits,
|
|
65
|
-
|
|
64
|
+
L as snakeCaseToCamelCase
|
|
66
65
|
};
|
|
67
66
|
//# 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":"
|
|
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;AACJ,QAAMH,IAASE,EAAuBI,GAAMH,CAAM;AAElD,UAAQI,GAAA;AAAA,IACN,KAAK;AACH,aAAOC,EAAE,yBAAyB,EAAE,QAAAR,GAAQ,IAAI,UAAU;AAAA,IAC5D,KAAK;AACH,aAAOQ,EAAE,yBAAyB;AAAA,QAChC,QAAQN,EAAuBI,IAAO,IAAIH,CAAM;AAAA,QAChD,IAAI;AAAA,MAAA,CACL;AAAA,IACH,KAAK;AACH,aAAOK,EAAE,0BAA0B;AAAA,QACjC,QAAQN,EAAuBI,IAAO,IAAIH,CAAM;AAAA,QAChD,IAAI;AAAA,MAAA,CACL;AAAA,IACH,KAAK;AACH,aAAOK,EAAE,yBAAyB,EAAE,QAAAR,GAAQ,IAAI,UAAU;AAAA,IAC5D,KAAK;AACH,aAAOQ,EAAE,2BAA2B,EAAE,QAAAR,GAAQ,IAAI,UAAU;AAAA,IAC9D;AACE,aAAOA;AAAA,EAAA;AAEb,GAcMS,IAAkB,EAAE,cAAc,CAAC,KAAK,KAAK,QAAQ,GAAG,cAAc,CAAC,QAAQ,QAAQ,EAAA;AACtF,SAASC,EAAaC,GAAe;AAC1C,SAAKA,IACE,EAAE,QAAQC,EAAU,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/dist/helpers/rem.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Detects font-size on the document root element with fallback to 16px
|
|
3
|
-
*
|
|
2
|
+
* Detects font-size on the document root element with fallback to 16px which is the default browser setting.
|
|
3
|
+
* The value is cached after the first call to avoid repeated expensive getComputedStyle() calls.
|
|
4
|
+
* @param options.forceRefresh - Force a fresh detection instead of using the cached value
|
|
5
|
+
* @returns The root font size in pixels as a string
|
|
4
6
|
*/
|
|
5
|
-
export declare function getRootFontSize(
|
|
7
|
+
export declare function getRootFontSize(options?: {
|
|
8
|
+
forceRefresh?: boolean;
|
|
9
|
+
}): string;
|
|
6
10
|
export declare function toRem(pxValue: number): string;
|
|
7
11
|
export declare const remToPx: (rem: string | number) => number;
|
package/dist/helpers/rem.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
let t = null;
|
|
2
|
+
function o(e) {
|
|
3
|
+
if (t)
|
|
4
|
+
return t;
|
|
5
|
+
const n = "16";
|
|
2
6
|
if (typeof window > "u")
|
|
3
|
-
return
|
|
4
|
-
const
|
|
5
|
-
return
|
|
7
|
+
return t = n, n;
|
|
8
|
+
const r = window.getComputedStyle(document.documentElement).getPropertyValue("font-size").match(/\d+/);
|
|
9
|
+
return t = r ? r[0] : n, t;
|
|
6
10
|
}
|
|
7
|
-
function
|
|
8
|
-
return String(e / Number(
|
|
11
|
+
function u(e) {
|
|
12
|
+
return String(e / Number(o())) + "rem";
|
|
9
13
|
}
|
|
10
|
-
const
|
|
14
|
+
const i = (e) => typeof e == "number" ? Number(o()) * e : Number(o()) * Number(e.replace("rem", ""));
|
|
11
15
|
export {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
o as getRootFontSize,
|
|
17
|
+
i as remToPx,
|
|
18
|
+
u as toRem
|
|
15
19
|
};
|
|
16
20
|
//# sourceMappingURL=rem.js.map
|
package/dist/helpers/rem.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rem.js","sources":["../../src/helpers/rem.ts"],"sourcesContent":["/**\n * Detects font-size on the document root element with fallback to 16px
|
|
1
|
+
{"version":3,"file":"rem.js","sources":["../../src/helpers/rem.ts"],"sourcesContent":["let cachedRootFontSize: string | null = null\n\n/**\n * Detects font-size on the document root element with fallback to 16px which is the default browser setting.\n * The value is cached after the first call to avoid repeated expensive getComputedStyle() calls.\n * @param options.forceRefresh - Force a fresh detection instead of using the cached value\n * @returns The root font size in pixels as a string\n */\nexport function getRootFontSize(options?: { forceRefresh?: boolean }) {\n if (cachedRootFontSize && !options?.forceRefresh) {\n return cachedRootFontSize\n }\n\n const defaultFontSize = '16'\n\n if (typeof window === 'undefined') {\n cachedRootFontSize = defaultFontSize\n return defaultFontSize\n }\n\n const match = window\n .getComputedStyle(document.documentElement)\n .getPropertyValue('font-size')\n .match(/\\d+/)\n\n cachedRootFontSize = match ? match[0] : defaultFontSize\n return cachedRootFontSize\n}\n\nexport function toRem(pxValue: number) {\n return String(pxValue / Number(getRootFontSize())) + 'rem'\n}\n\nexport const remToPx = (rem: string | number) =>\n typeof rem === 'number'\n ? Number(getRootFontSize()) * rem\n : Number(getRootFontSize()) * Number(rem.replace('rem', ''))\n"],"names":["cachedRootFontSize","getRootFontSize","options","defaultFontSize","match","toRem","pxValue","remToPx","rem"],"mappings":"AAAA,IAAIA,IAAoC;AAQjC,SAASC,EAAgBC,GAAsC;AACpE,MAAIF;AACF,WAAOA;AAGT,QAAMG,IAAkB;AAExB,MAAI,OAAO,SAAW;AACpB,WAAAH,IAAqBG,GACdA;AAGT,QAAMC,IAAQ,OACX,iBAAiB,SAAS,eAAe,EACzC,iBAAiB,WAAW,EAC5B,MAAM,KAAK;AAEd,SAAAJ,IAAqBI,IAAQA,EAAM,CAAC,IAAID,GACjCH;AACT;AAEO,SAASK,EAAMC,GAAiB;AACrC,SAAO,OAAOA,IAAU,OAAOL,EAAA,CAAiB,CAAC,IAAI;AACvD;AAEO,MAAMM,IAAU,CAACC,MACtB,OAAOA,KAAQ,WACX,OAAOP,GAAiB,IAAIO,IAC5B,OAAOP,EAAA,CAAiB,IAAI,OAAOO,EAAI,QAAQ,OAAO,EAAE,CAAC;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
async function c(o, { maxAttempts: r, delayMs: n, shouldRetry: a }) {
|
|
2
|
+
for (let t = 0; t < r; t++)
|
|
3
|
+
try {
|
|
4
|
+
return await o();
|
|
5
|
+
} catch (e) {
|
|
6
|
+
const i = t === r - 1;
|
|
7
|
+
if (a(e) && !i) {
|
|
8
|
+
await new Promise((s) => setTimeout(s, n));
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
throw e;
|
|
12
|
+
}
|
|
13
|
+
throw new Error("retryAsync: exhausted all attempts without resolving");
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
c as retryAsync
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=retryAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retryAsync.js","sources":["../../src/helpers/retryAsync.ts"],"sourcesContent":["interface RetryAsyncOptions {\n maxAttempts: number\n delayMs: number\n shouldRetry: (error: unknown) => boolean\n}\n\nexport async function retryAsync<T>(\n fn: () => Promise<T>,\n { maxAttempts, delayMs, shouldRetry }: RetryAsyncOptions,\n): Promise<T> {\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n try {\n return await fn()\n } catch (error) {\n const isLastAttempt = attempt === maxAttempts - 1\n if (shouldRetry(error) && !isLastAttempt) {\n await new Promise(resolve => setTimeout(resolve, delayMs))\n continue\n }\n throw error\n }\n }\n\n throw new Error('retryAsync: exhausted all attempts without resolving')\n}\n"],"names":["retryAsync","fn","maxAttempts","delayMs","shouldRetry","attempt","error","isLastAttempt","resolve"],"mappings":"AAMA,eAAsBA,EACpBC,GACA,EAAE,aAAAC,GAAa,SAAAC,GAAS,aAAAC,KACZ;AACZ,WAASC,IAAU,GAAGA,IAAUH,GAAaG;AAC3C,QAAI;AACF,aAAO,MAAMJ,EAAA;AAAA,IACf,SAASK,GAAO;AACd,YAAMC,IAAgBF,MAAYH,IAAc;AAChD,UAAIE,EAAYE,CAAK,KAAK,CAACC,GAAe;AACxC,cAAM,IAAI,QAAQ,CAAAC,MAAW,WAAWA,GAASL,CAAO,CAAC;AACzD;AAAA,MACF;AACA,YAAMG;AAAA,IACR;AAGF,QAAM,IAAI,MAAM,sDAAsD;AACxE;"}
|
package/dist/i18n/I18n.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
import p from "../_virtual/dynamic-import-helper.js";
|
|
2
2
|
import { useTranslation as a } from "react-i18next";
|
|
3
3
|
import { LRUCache as y } from "../helpers/LRUCache.js";
|
|
4
|
-
const f = "common", i = new y(50), c = ({ lng:
|
|
5
|
-
let r = !0,
|
|
4
|
+
const f = "common", i = new y(50), c = ({ lng: e = "en", ns: o }) => {
|
|
5
|
+
let r = !0, n = !1, t;
|
|
6
6
|
const m = (async () => {
|
|
7
7
|
try {
|
|
8
|
-
t = (await p(/* @__PURE__ */ Object.assign({ "./en/Company.Addresses.json": () => import("./en/Company.Addresses.json.js"), "./en/Company.AssignSignatory.json": () => import("./en/Company.AssignSignatory.json.js"), "./en/Company.BankAccount.json": () => import("./en/Company.BankAccount.json.js"), "./en/Company.DocumentList.json": () => import("./en/Company.DocumentList.json.js"), "./en/Company.FederalTaxes.json": () => import("./en/Company.FederalTaxes.json.js"), "./en/Company.Industry.json": () => import("./en/Company.Industry.json.js"), "./en/Company.Locations.json": () => import("./en/Company.Locations.json.js"), "./en/Company.OnboardingOverview.json": () => import("./en/Company.OnboardingOverview.json.js"), "./en/Company.PaySchedule.json": () => import("./en/Company.PaySchedule.json.js"), "./en/Company.SignatureForm.json": () => import("./en/Company.SignatureForm.json.js"), "./en/Company.StateTaxes.json": () => import("./en/Company.StateTaxes.json.js"), "./en/Contractor.Address.json": () => import("./en/Contractor.Address.json.js"), "./en/Contractor.ContractorList.json": () => import("./en/Contractor.ContractorList.json.js"), "./en/Contractor.NewHireReport.json": () => import("./en/Contractor.NewHireReport.json.js"), "./en/Contractor.PaymentMethod.json": () => import("./en/Contractor.PaymentMethod.json.js"), "./en/Contractor.Payments.CreatePayment.json": () => import("./en/Contractor.Payments.CreatePayment.json.js"), "./en/Contractor.Payments.PaymentHistory.json": () => import("./en/Contractor.Payments.PaymentHistory.json.js"), "./en/Contractor.Payments.PaymentStatement.json": () => import("./en/Contractor.Payments.PaymentStatement.json.js"), "./en/Contractor.Payments.PaymentSummary.json": () => import("./en/Contractor.Payments.PaymentSummary.json.js"), "./en/Contractor.Payments.PaymentsList.json": () => import("./en/Contractor.Payments.PaymentsList.json.js"), "./en/Contractor.Profile.json": () => import("./en/Contractor.Profile.json.js"), "./en/Contractor.Submit.json": () => import("./en/Contractor.Submit.json.js"), "./en/Employee.BankAccount.json": () => import("./en/Employee.BankAccount.json.js"), "./en/Employee.Compensation.json": () => import("./en/Employee.Compensation.json.js"), "./en/Employee.Deductions.json": () => import("./en/Employee.Deductions.json.js"), "./en/Employee.DocumentSigner.json": () => import("./en/Employee.DocumentSigner.json.js"), "./en/Employee.EmployeeDocuments.json": () => import("./en/Employee.EmployeeDocuments.json.js"), "./en/Employee.EmployeeList.json": () => import("./en/Employee.EmployeeList.json.js"), "./en/Employee.EmploymentEligibility.json": () => import("./en/Employee.EmploymentEligibility.json.js"), "./en/Employee.FederalTaxes.json": () => import("./en/Employee.FederalTaxes.json.js"), "./en/Employee.HomeAddress.json": () => import("./en/Employee.HomeAddress.json.js"), "./en/Employee.I9SignatureForm.json": () => import("./en/Employee.I9SignatureForm.json.js"), "./en/Employee.Landing.json": () => import("./en/Employee.Landing.json.js"), "./en/Employee.OnboardingSummary.json": () => import("./en/Employee.OnboardingSummary.json.js"), "./en/Employee.PaySchedules.json": () => import("./en/Employee.PaySchedules.json.js"), "./en/Employee.PaymentMethod.json": () => import("./en/Employee.PaymentMethod.json.js"), "./en/Employee.Profile.json": () => import("./en/Employee.Profile.json.js"), "./en/Employee.SplitPaycheck.json": () => import("./en/Employee.SplitPaycheck.json.js"), "./en/Employee.StateTaxes.json": () => import("./en/Employee.StateTaxes.json.js"), "./en/Employee.Taxes.json": () => import("./en/Employee.Taxes.json.js"), "./en/InformationRequests.InformationRequestForm.json": () => import("./en/InformationRequests.InformationRequestForm.json.js"), "./en/InformationRequests.InformationRequestList.json": () => import("./en/InformationRequests.InformationRequestList.json.js"), "./en/InformationRequests.json": () => import("./en/InformationRequests.json.js"), "./en/Payroll.Common.json": () => import("./en/Payroll.Common.json.js"), "./en/Payroll.ConfirmWireDetailsBanner.json": () => import("./en/Payroll.ConfirmWireDetailsBanner.json.js"), "./en/Payroll.ConfirmWireDetailsForm.json": () => import("./en/Payroll.ConfirmWireDetailsForm.json.js"), "./en/Payroll.EmployeeSelection.json": () => import("./en/Payroll.EmployeeSelection.json.js"), "./en/Payroll.OffCycle.json": () => import("./en/Payroll.OffCycle.json.js"), "./en/Payroll.OffCycleCreation.json": () => import("./en/Payroll.OffCycleCreation.json.js"), "./en/Payroll.OffCycleDeductionsSetting.json": () => import("./en/Payroll.OffCycleDeductionsSetting.json.js"), "./en/Payroll.OffCyclePayPeriodDateForm.json": () => import("./en/Payroll.OffCyclePayPeriodDateForm.json.js"), "./en/Payroll.OffCycleReasonSelection.json": () => import("./en/Payroll.OffCycleReasonSelection.json.js"), "./en/Payroll.OffCycleTaxWithholding.json": () => import("./en/Payroll.OffCycleTaxWithholding.json.js"), "./en/Payroll.PayrollBlocker.json": () => import("./en/Payroll.PayrollBlocker.json.js"), "./en/Payroll.PayrollConfiguration.json": () => import("./en/Payroll.PayrollConfiguration.json.js"), "./en/Payroll.PayrollEditEmployee.json": () => import("./en/Payroll.PayrollEditEmployee.json.js"), "./en/Payroll.PayrollFlow.json": () => import("./en/Payroll.PayrollFlow.json.js"), "./en/Payroll.PayrollHistory.json": () => import("./en/Payroll.PayrollHistory.json.js"), "./en/Payroll.PayrollLanding.json": () => import("./en/Payroll.PayrollLanding.json.js"), "./en/Payroll.PayrollList.json": () => import("./en/Payroll.PayrollList.json.js"), "./en/Payroll.PayrollOverview.json": () => import("./en/Payroll.PayrollOverview.json.js"), "./en/Payroll.PayrollReceipts.json": () => import("./en/Payroll.PayrollReceipts.json.js"), "./en/Payroll.RecoveryCasesList.json": () => import("./en/Payroll.RecoveryCasesList.json.js"), "./en/Payroll.RecoveryCasesResubmit.json": () => import("./en/Payroll.RecoveryCasesResubmit.json.js"), "./en/Payroll.WireInstructions.json": () => import("./en/Payroll.WireInstructions.json.js"), "./en/common.json": () => import("./en/common.json.js") }), `./${
|
|
8
|
+
t = (await p(/* @__PURE__ */ Object.assign({ "./en/Company.Addresses.json": () => import("./en/Company.Addresses.json.js"), "./en/Company.AssignSignatory.json": () => import("./en/Company.AssignSignatory.json.js"), "./en/Company.BankAccount.json": () => import("./en/Company.BankAccount.json.js"), "./en/Company.DocumentList.json": () => import("./en/Company.DocumentList.json.js"), "./en/Company.FederalTaxes.json": () => import("./en/Company.FederalTaxes.json.js"), "./en/Company.Industry.json": () => import("./en/Company.Industry.json.js"), "./en/Company.Locations.json": () => import("./en/Company.Locations.json.js"), "./en/Company.OnboardingOverview.json": () => import("./en/Company.OnboardingOverview.json.js"), "./en/Company.PaySchedule.json": () => import("./en/Company.PaySchedule.json.js"), "./en/Company.SignatureForm.json": () => import("./en/Company.SignatureForm.json.js"), "./en/Company.StateTaxes.json": () => import("./en/Company.StateTaxes.json.js"), "./en/Contractor.Address.json": () => import("./en/Contractor.Address.json.js"), "./en/Contractor.ContractorList.json": () => import("./en/Contractor.ContractorList.json.js"), "./en/Contractor.NewHireReport.json": () => import("./en/Contractor.NewHireReport.json.js"), "./en/Contractor.PaymentMethod.json": () => import("./en/Contractor.PaymentMethod.json.js"), "./en/Contractor.Payments.CreatePayment.json": () => import("./en/Contractor.Payments.CreatePayment.json.js"), "./en/Contractor.Payments.PaymentHistory.json": () => import("./en/Contractor.Payments.PaymentHistory.json.js"), "./en/Contractor.Payments.PaymentStatement.json": () => import("./en/Contractor.Payments.PaymentStatement.json.js"), "./en/Contractor.Payments.PaymentSummary.json": () => import("./en/Contractor.Payments.PaymentSummary.json.js"), "./en/Contractor.Payments.PaymentsList.json": () => import("./en/Contractor.Payments.PaymentsList.json.js"), "./en/Contractor.Profile.json": () => import("./en/Contractor.Profile.json.js"), "./en/Contractor.Submit.json": () => import("./en/Contractor.Submit.json.js"), "./en/Employee.BankAccount.json": () => import("./en/Employee.BankAccount.json.js"), "./en/Employee.Compensation.json": () => import("./en/Employee.Compensation.json.js"), "./en/Employee.Deductions.json": () => import("./en/Employee.Deductions.json.js"), "./en/Employee.DocumentSigner.json": () => import("./en/Employee.DocumentSigner.json.js"), "./en/Employee.EmployeeDocuments.json": () => import("./en/Employee.EmployeeDocuments.json.js"), "./en/Employee.EmployeeList.json": () => import("./en/Employee.EmployeeList.json.js"), "./en/Employee.EmploymentEligibility.json": () => import("./en/Employee.EmploymentEligibility.json.js"), "./en/Employee.FederalTaxes.json": () => import("./en/Employee.FederalTaxes.json.js"), "./en/Employee.HomeAddress.json": () => import("./en/Employee.HomeAddress.json.js"), "./en/Employee.I9SignatureForm.json": () => import("./en/Employee.I9SignatureForm.json.js"), "./en/Employee.Landing.json": () => import("./en/Employee.Landing.json.js"), "./en/Employee.OnboardingSummary.json": () => import("./en/Employee.OnboardingSummary.json.js"), "./en/Employee.PaySchedules.json": () => import("./en/Employee.PaySchedules.json.js"), "./en/Employee.PaymentMethod.json": () => import("./en/Employee.PaymentMethod.json.js"), "./en/Employee.Profile.json": () => import("./en/Employee.Profile.json.js"), "./en/Employee.SplitPaycheck.json": () => import("./en/Employee.SplitPaycheck.json.js"), "./en/Employee.StateTaxes.json": () => import("./en/Employee.StateTaxes.json.js"), "./en/Employee.Taxes.json": () => import("./en/Employee.Taxes.json.js"), "./en/InformationRequests.InformationRequestForm.json": () => import("./en/InformationRequests.InformationRequestForm.json.js"), "./en/InformationRequests.InformationRequestList.json": () => import("./en/InformationRequests.InformationRequestList.json.js"), "./en/InformationRequests.json": () => import("./en/InformationRequests.json.js"), "./en/Payroll.Common.json": () => import("./en/Payroll.Common.json.js"), "./en/Payroll.ConfirmWireDetailsBanner.json": () => import("./en/Payroll.ConfirmWireDetailsBanner.json.js"), "./en/Payroll.ConfirmWireDetailsForm.json": () => import("./en/Payroll.ConfirmWireDetailsForm.json.js"), "./en/Payroll.EmployeeSelection.json": () => import("./en/Payroll.EmployeeSelection.json.js"), "./en/Payroll.GrossUpModal.json": () => import("./en/Payroll.GrossUpModal.json.js"), "./en/Payroll.OffCycle.json": () => import("./en/Payroll.OffCycle.json.js"), "./en/Payroll.OffCycleCreation.json": () => import("./en/Payroll.OffCycleCreation.json.js"), "./en/Payroll.OffCycleDeductionsSetting.json": () => import("./en/Payroll.OffCycleDeductionsSetting.json.js"), "./en/Payroll.OffCyclePayPeriodDateForm.json": () => import("./en/Payroll.OffCyclePayPeriodDateForm.json.js"), "./en/Payroll.OffCycleReasonSelection.json": () => import("./en/Payroll.OffCycleReasonSelection.json.js"), "./en/Payroll.OffCycleTaxWithholding.json": () => import("./en/Payroll.OffCycleTaxWithholding.json.js"), "./en/Payroll.PayrollBlocker.json": () => import("./en/Payroll.PayrollBlocker.json.js"), "./en/Payroll.PayrollConfiguration.json": () => import("./en/Payroll.PayrollConfiguration.json.js"), "./en/Payroll.PayrollEditEmployee.json": () => import("./en/Payroll.PayrollEditEmployee.json.js"), "./en/Payroll.PayrollFlow.json": () => import("./en/Payroll.PayrollFlow.json.js"), "./en/Payroll.PayrollHistory.json": () => import("./en/Payroll.PayrollHistory.json.js"), "./en/Payroll.PayrollLanding.json": () => import("./en/Payroll.PayrollLanding.json.js"), "./en/Payroll.PayrollList.json": () => import("./en/Payroll.PayrollList.json.js"), "./en/Payroll.PayrollOverview.json": () => import("./en/Payroll.PayrollOverview.json.js"), "./en/Payroll.PayrollReceipts.json": () => import("./en/Payroll.PayrollReceipts.json.js"), "./en/Payroll.RecoveryCasesList.json": () => import("./en/Payroll.RecoveryCasesList.json.js"), "./en/Payroll.RecoveryCasesResubmit.json": () => import("./en/Payroll.RecoveryCasesResubmit.json.js"), "./en/Payroll.WireInstructions.json": () => import("./en/Payroll.WireInstructions.json.js"), "./en/common.json": () => import("./en/common.json.js") }), `./${e}/${o}.json`, 3)).default, r = !1;
|
|
9
9
|
} catch {
|
|
10
|
-
|
|
10
|
+
n = !0, r = !1;
|
|
11
11
|
}
|
|
12
12
|
})();
|
|
13
13
|
return () => {
|
|
14
14
|
if (r)
|
|
15
15
|
throw m;
|
|
16
|
-
if (
|
|
16
|
+
if (n)
|
|
17
17
|
throw new Error(`Error loading translation for component: ${o}`);
|
|
18
18
|
return t;
|
|
19
19
|
};
|
|
20
|
-
}, C = (
|
|
20
|
+
}, C = (e) => {
|
|
21
21
|
const { i18n: o } = a();
|
|
22
|
-
if (!
|
|
23
|
-
const r = Array.isArray(
|
|
24
|
-
for (const
|
|
25
|
-
const t = `${o.resolvedLanguage}:${
|
|
26
|
-
i.get(t) === null && i.put(t, c({ lng: o.resolvedLanguage, ns:
|
|
22
|
+
if (!e) return;
|
|
23
|
+
const r = Array.isArray(e) ? e : [e];
|
|
24
|
+
for (const n of r) {
|
|
25
|
+
const t = `${o.resolvedLanguage}:${n}`;
|
|
26
|
+
i.get(t) === null && i.put(t, c({ lng: o.resolvedLanguage, ns: n }));
|
|
27
27
|
const s = i.get(t);
|
|
28
28
|
if (s) {
|
|
29
29
|
const m = s();
|
|
30
30
|
o.addResourceBundle(
|
|
31
31
|
o.resolvedLanguage ?? "en",
|
|
32
|
-
|
|
32
|
+
n,
|
|
33
33
|
m,
|
|
34
34
|
!0,
|
|
35
35
|
!1
|
|
36
36
|
);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
}, d = (
|
|
39
|
+
}, d = (e, o) => {
|
|
40
40
|
const { i18n: r } = a();
|
|
41
41
|
if (o)
|
|
42
|
-
for (const
|
|
43
|
-
r.addResourceBundle(
|
|
42
|
+
for (const n in o)
|
|
43
|
+
r.addResourceBundle(n, e, o[n], !0, !0);
|
|
44
44
|
};
|
|
45
45
|
export {
|
|
46
46
|
f as defaultNS,
|
package/dist/i18n/I18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18n.js","sources":["../../src/i18n/I18n.ts"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport type { CustomTypeOptions } from 'i18next'\nimport { LRUCache } from '@/helpers/LRUCache'\nimport type { ResourceDictionary, Resources } from '@/types/Helpers'\n\nexport const defaultNS = 'common'\n\n//LRU cache holding requested resources\nconst resourceCache = new LRUCache(50)\n/**\n * Dynamic loading of translation resources - works with Suspence to prevent early access to loadable strings\n * @param lng(string): resource language\n * @param ns(string): Namespace/name of the component/resource\n * @returns Promise<Translation resource>\n */\nconst loadResource = ({ lng = 'en', ns }: { ns: string; lng?: string }) => {\n let isLoading = true\n let isError = false\n let resource: Record<string, string>\n\n const importResources = async () => {\n try {\n const module = await import(`@/i18n/${lng}/${ns}.json`)\n\n resource = module.default\n isLoading = false\n } catch (err) {\n isError = true\n isLoading = false\n }\n }\n const promise = importResources()\n return () => {\n if (isLoading) {\n // eslint-disable-next-line @typescript-eslint/only-throw-error\n throw promise // Throw the promise to indicate Suspense should suspend.\n } else if (isError) {\n throw new Error(`Error loading translation for component: ${ns}`) // Handle error\n } else {\n return resource // Return the resource when loading is complete\n }\n }\n}\n\n/**\n * Hook that allows component to load custom dictionary\n * @param @private {string} ns - Namespace - should match component name exactly - not exposed to consumers\n */\nexport const useI18n = (\n namespaces:\n | keyof CustomTypeOptions['resources']\n | Array<keyof CustomTypeOptions['resources']>\n | null,\n) => {\n //Getting our instance of i18n -> supplied by the provider set in GustoApiProvider\n const { i18n: i18nInstance } = useTranslation()\n //Abort when namespace is not provided\n if (!namespaces) return\n const nsMap = Array.isArray(namespaces) ? namespaces : [namespaces]\n for (const ns of nsMap) {\n const key = `${i18nInstance.resolvedLanguage}:${ns}`\n //Skip loading default resource if it is already in cache\n if (resourceCache.get(key) === null) {\n //If resource not in cache, initiate loading and add getter to cache\n resourceCache.put(key, loadResource({ lng: i18nInstance.resolvedLanguage, ns: ns }))\n }\n //Get resourceGetter from cache\n const resourceGetter = resourceCache.get(key)\n if (resourceGetter) {\n const resource = resourceGetter()\n i18nInstance.addResourceBundle(\n i18nInstance.resolvedLanguage ?? 'en',\n ns,\n resource,\n true,\n false,\n ) //Last argument is set to false to prevent override of keys provided by partners on GustoApiProvider level through dictionary prop\n }\n }\n}\n\n//Used by individual components to override their dictionaries with partner provided resources\nexport const useComponentDictionary = <K extends keyof Resources>(\n ns: keyof CustomTypeOptions['resources'],\n resource?: ResourceDictionary<K> | null,\n) => {\n const { i18n: i18nInstance } = useTranslation()\n if (resource) {\n for (const lang in resource) {\n i18nInstance.addResourceBundle(lang, ns, resource[lang], true, true)\n }\n }\n}\n"],"names":["defaultNS","resourceCache","LRUCache","loadResource","lng","ns","isLoading","isError","resource","promise","__variableDynamicImportRuntimeHelper","useI18n","namespaces","i18nInstance","useTranslation","nsMap","key","resourceGetter","useComponentDictionary","lang"],"mappings":";;;AAKO,MAAMA,IAAY,UAGnBC,IAAgB,IAAIC,EAAS,EAAE,GAO/BC,IAAe,CAAC,EAAE,KAAAC,IAAM,MAAM,IAAAC,QAAuC;AACzE,MAAIC,IAAY,IACZC,IAAU,IACVC;AAaJ,QAAMC,KAXkB,YAAY;AAClC,QAAI;AAGF,MAAAD,KAFe,MAAME
|
|
1
|
+
{"version":3,"file":"I18n.js","sources":["../../src/i18n/I18n.ts"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport type { CustomTypeOptions } from 'i18next'\nimport { LRUCache } from '@/helpers/LRUCache'\nimport type { ResourceDictionary, Resources } from '@/types/Helpers'\n\nexport const defaultNS = 'common'\n\n//LRU cache holding requested resources\nconst resourceCache = new LRUCache(50)\n/**\n * Dynamic loading of translation resources - works with Suspence to prevent early access to loadable strings\n * @param lng(string): resource language\n * @param ns(string): Namespace/name of the component/resource\n * @returns Promise<Translation resource>\n */\nconst loadResource = ({ lng = 'en', ns }: { ns: string; lng?: string }) => {\n let isLoading = true\n let isError = false\n let resource: Record<string, string>\n\n const importResources = async () => {\n try {\n const module = await import(`@/i18n/${lng}/${ns}.json`)\n\n resource = module.default\n isLoading = false\n } catch (err) {\n isError = true\n isLoading = false\n }\n }\n const promise = importResources()\n return () => {\n if (isLoading) {\n // eslint-disable-next-line @typescript-eslint/only-throw-error\n throw promise // Throw the promise to indicate Suspense should suspend.\n } else if (isError) {\n throw new Error(`Error loading translation for component: ${ns}`) // Handle error\n } else {\n return resource // Return the resource when loading is complete\n }\n }\n}\n\n/**\n * Hook that allows component to load custom dictionary\n * @param @private {string} ns - Namespace - should match component name exactly - not exposed to consumers\n */\nexport const useI18n = (\n namespaces:\n | keyof CustomTypeOptions['resources']\n | Array<keyof CustomTypeOptions['resources']>\n | null,\n) => {\n //Getting our instance of i18n -> supplied by the provider set in GustoApiProvider\n const { i18n: i18nInstance } = useTranslation()\n //Abort when namespace is not provided\n if (!namespaces) return\n const nsMap = Array.isArray(namespaces) ? namespaces : [namespaces]\n for (const ns of nsMap) {\n const key = `${i18nInstance.resolvedLanguage}:${ns}`\n //Skip loading default resource if it is already in cache\n if (resourceCache.get(key) === null) {\n //If resource not in cache, initiate loading and add getter to cache\n resourceCache.put(key, loadResource({ lng: i18nInstance.resolvedLanguage, ns: ns }))\n }\n //Get resourceGetter from cache\n const resourceGetter = resourceCache.get(key)\n if (resourceGetter) {\n const resource = resourceGetter()\n i18nInstance.addResourceBundle(\n i18nInstance.resolvedLanguage ?? 'en',\n ns,\n resource,\n true,\n false,\n ) //Last argument is set to false to prevent override of keys provided by partners on GustoApiProvider level through dictionary prop\n }\n }\n}\n\n//Used by individual components to override their dictionaries with partner provided resources\nexport const useComponentDictionary = <K extends keyof Resources>(\n ns: keyof CustomTypeOptions['resources'],\n resource?: ResourceDictionary<K> | null,\n) => {\n const { i18n: i18nInstance } = useTranslation()\n if (resource) {\n for (const lang in resource) {\n i18nInstance.addResourceBundle(lang, ns, resource[lang], true, true)\n }\n }\n}\n"],"names":["defaultNS","resourceCache","LRUCache","loadResource","lng","ns","isLoading","isError","resource","promise","__variableDynamicImportRuntimeHelper","useI18n","namespaces","i18nInstance","useTranslation","nsMap","key","resourceGetter","useComponentDictionary","lang"],"mappings":";;;AAKO,MAAMA,IAAY,UAGnBC,IAAgB,IAAIC,EAAS,EAAE,GAO/BC,IAAe,CAAC,EAAE,KAAAC,IAAM,MAAM,IAAAC,QAAuC;AACzE,MAAIC,IAAY,IACZC,IAAU,IACVC;AAaJ,QAAMC,KAXkB,YAAY;AAClC,QAAI;AAGF,MAAAD,KAFe,MAAME,ojMAAA,KAAAN,CAAA,IAAAC,CAAA,SAAA,CAAA,GAEH,SAClBC,IAAY;AAAA,IACd,QAAc;AACZ,MAAAC,IAAU,IACVD,IAAY;AAAA,IACd;AAAA,EACF,GACgB;AAChB,SAAO,MAAM;AACX,QAAIA;AAEF,YAAMG;QACGF;AACT,YAAM,IAAI,MAAM,4CAA4CF,CAAE,EAAE;AAEhE,WAAOG;AAAA,EAEX;AACF,GAMaG,IAAU,CACrBC,MAIG;AAEH,QAAM,EAAE,MAAMC,EAAA,IAAiBC,EAAA;AAE/B,MAAI,CAACF,EAAY;AACjB,QAAMG,IAAQ,MAAM,QAAQH,CAAU,IAAIA,IAAa,CAACA,CAAU;AAClE,aAAWP,KAAMU,GAAO;AACtB,UAAMC,IAAM,GAAGH,EAAa,gBAAgB,IAAIR,CAAE;AAElD,IAAIJ,EAAc,IAAIe,CAAG,MAAM,QAE7Bf,EAAc,IAAIe,GAAKb,EAAa,EAAE,KAAKU,EAAa,kBAAkB,IAAAR,EAAA,CAAQ,CAAC;AAGrF,UAAMY,IAAiBhB,EAAc,IAAIe,CAAG;AAC5C,QAAIC,GAAgB;AAClB,YAAMT,IAAWS,EAAA;AACjB,MAAAJ,EAAa;AAAA,QACXA,EAAa,oBAAoB;AAAA,QACjCR;AAAA,QACAG;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IAEJ;AAAA,EACF;AACF,GAGaU,IAAyB,CACpCb,GACAG,MACG;AACH,QAAM,EAAE,MAAMK,EAAA,IAAiBC,EAAA;AAC/B,MAAIN;AACF,eAAWW,KAAQX;AACjB,MAAAK,EAAa,kBAAkBM,GAAMd,GAAIG,EAASW,CAAI,GAAG,IAAM,EAAI;AAGzE;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e = `Pick what frequency you'd like to run payroll. If you need help, you can read more about <ScheduleLink href="https://gusto.com/resources/articles/payroll/best-payroll-schedule-small-business" target="_blank">how to choose a pay schedule.</ScheduleLink>`, t = 'Why do we need to ask for this? We need to know when to pay your employees. Some states have <PaymentLawLink href="https://www.dol.gov/agencies/whd/state/payday" target="_blank">laws around when you must pay your employees.</PaymentLawLink> Please choose pay schedules that are legal for your employees.', a = "+ Add another pay schedule", o = "Save & continue", n = "Continue", s = "Please make sure to verify this information is accurate. If this information isn't correct, it can delay when your team will be paid.", i = { name: "Name", actions: "Actions", active: "Active", inactive: "Inactive", edit: "Edit" }, r = { addPaySchedule: "Add pay schedule", editPaySchedule: "Edit pay schedule", pageTitle: "Set up pay schedule" }, y = { name: "Name", payfrequency: "Pay frequency", frequency: "Frequency", deadline: "Deadline to run payroll", frequencyOptions: "Frequency Options", firstPayDate: "First pay date", firstPayPeriodEndDate: "First pay period end date", firstPayDayOfTheMonth: "First pay day of the month", lastPayDayOfTheMonth: "Last pay day of the month", preview: "Preview", legend: "Legend" }, c = "Loading...", l = { frequencyOptionsDescription: "Select the pay days for the month.", anchorPayDateDescription: "Please account for the 2 days it will take to process payroll.", anchorEndOfPayPeriodDescription: "The last date of the first pay period to help calculate future pay periods. This can be the same date as the first pay date." }, d = { payPeriod: "Pay period", payday: "Payday", payrollDeadline: "Run payroll by
|
|
1
|
+
const e = `Pick what frequency you'd like to run payroll. If you need help, you can read more about <ScheduleLink href="https://gusto.com/resources/articles/payroll/best-payroll-schedule-small-business" target="_blank">how to choose a pay schedule.</ScheduleLink>`, t = 'Why do we need to ask for this? We need to know when to pay your employees. Some states have <PaymentLawLink href="https://www.dol.gov/agencies/whd/state/payday" target="_blank">laws around when you must pay your employees.</PaymentLawLink> Please choose pay schedules that are legal for your employees.', a = "+ Add another pay schedule", o = "Save & continue", n = "Continue", s = "Please make sure to verify this information is accurate. If this information isn't correct, it can delay when your team will be paid.", i = { name: "Name", actions: "Actions", active: "Active", inactive: "Inactive", edit: "Edit" }, r = { addPaySchedule: "Add pay schedule", editPaySchedule: "Edit pay schedule", pageTitle: "Set up pay schedule" }, y = { name: "Name", payfrequency: "Pay frequency", frequency: "Frequency", deadline: "Deadline to run payroll", frequencyOptions: "Frequency Options", firstPayDate: "First pay date", firstPayPeriodEndDate: "First pay period end date", firstPayDayOfTheMonth: "First pay day of the month", lastPayDayOfTheMonth: "Last pay day of the month", preview: "Preview", legend: "Legend" }, c = "Loading...", l = { frequencyOptionsDescription: "Select the pay days for the month.", anchorPayDateDescription: "Please account for the 2 days it will take to process payroll.", anchorEndOfPayPeriodDescription: "The last date of the first pay period to help calculate future pay periods. This can be the same date as the first pay date." }, d = { payPeriod: "Pay period", payday: "Payday", payrollDeadline: "Run payroll by 4:00PM (PDT) on " }, h = { cancel: "Cancel", save: "Save" }, p = { everyWeek: "Every week", everyOtherWeek: "Every other week", twicePerMonth: "Twice per month", monthly: "Monthly" }, u = { "15thAndLast": "15th and Last day of the month", custom: "Custom" }, f = { title: "Pay Schedule Preview", description: "Complete all the required fields to see a preview of your pay schedule." }, m = {
|
|
2
2
|
listDescription: e,
|
|
3
3
|
listDescription2: t,
|
|
4
4
|
addAnotherPayScheduleCta: a,
|