@gusto/embedded-react-sdk 0.10.6-rc.2 → 0.10.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/components/Base/Base.js +19 -18
  3. package/dist/components/Base/Base.js.map +1 -1
  4. package/dist/components/Common/SignatureForm/SignatureForm.js +6 -4
  5. package/dist/components/Common/SignatureForm/SignatureForm.js.map +1 -1
  6. package/dist/components/Common/SignatureForm/SignatureFormActions.js +7 -6
  7. package/dist/components/Common/SignatureForm/SignatureFormActions.js.map +1 -1
  8. package/dist/components/Common/SignatureForm/SignatureFormFields.js +8 -7
  9. package/dist/components/Common/SignatureForm/SignatureFormFields.js.map +1 -1
  10. package/dist/components/Common/TaxInputs/TaxInputs.d.ts +5 -1
  11. package/dist/components/Common/TaxInputs/TaxInputs.js +64 -56
  12. package/dist/components/Common/TaxInputs/TaxInputs.js.map +1 -1
  13. package/dist/components/Company/AssignSignatory/AssignSignatory.js +13 -11
  14. package/dist/components/Company/AssignSignatory/AssignSignatory.js.map +1 -1
  15. package/dist/components/Company/AssignSignatory/AssignSignatorySelection.js +1 -1
  16. package/dist/components/Company/AssignSignatory/CreateSignatory/Actions.js +1 -1
  17. package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatory.js +1 -0
  18. package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatory.js.map +1 -1
  19. package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.js +3 -2
  20. package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.js.map +1 -1
  21. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +1 -1
  22. package/dist/components/Company/AssignSignatory/InviteSignatory/Actions.js +1 -1
  23. package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatory.js +4 -3
  24. package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatory.js.map +1 -1
  25. package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.js +10 -9
  26. package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.js.map +1 -1
  27. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +1 -1
  28. package/dist/components/Company/AssignSignatory/TitleSelect.js +8 -7
  29. package/dist/components/Company/AssignSignatory/TitleSelect.js.map +1 -1
  30. package/dist/components/Company/AssignSignatory/useAssignSignatory.js +1 -1
  31. package/dist/components/Company/BankAccount/BankAccountForm/Actions.js +9 -8
  32. package/dist/components/Company/BankAccount/BankAccountForm/Actions.js.map +1 -1
  33. package/dist/components/Company/BankAccount/BankAccountForm/Form.js +8 -7
  34. package/dist/components/Company/BankAccount/BankAccountForm/Form.js.map +1 -1
  35. package/dist/components/Company/BankAccount/BankAccountForm/context.js +1 -1
  36. package/dist/components/Company/BankAccount/BankAccountList/Actions.js +1 -1
  37. package/dist/components/Company/BankAccount/BankAccountVerify/Actions.js +1 -1
  38. package/dist/components/Company/BankAccount/BankAccountVerify/Form.js +5 -4
  39. package/dist/components/Company/BankAccount/BankAccountVerify/Form.js.map +1 -1
  40. package/dist/components/Company/DocumentSigner/DocumentList/Actions.js +1 -1
  41. package/dist/components/Company/DocumentSigner/DocumentList/DocumentList.js +17 -15
  42. package/dist/components/Company/DocumentSigner/DocumentList/DocumentList.js.map +1 -1
  43. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +1 -1
  44. package/dist/components/Company/DocumentSigner/SignatureForm/SignatureForm.js +9 -7
  45. package/dist/components/Company/DocumentSigner/SignatureForm/SignatureForm.js.map +1 -1
  46. package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js +1 -1
  47. package/dist/components/Company/FederalTaxes/Actions.js +1 -1
  48. package/dist/components/Company/FederalTaxes/FederalTaxes.js +17 -15
  49. package/dist/components/Company/FederalTaxes/FederalTaxes.js.map +1 -1
  50. package/dist/components/Company/FederalTaxes/Form.js +3 -2
  51. package/dist/components/Company/FederalTaxes/Form.js.map +1 -1
  52. package/dist/components/Company/FederalTaxes/useFederalTaxes.js +1 -1
  53. package/dist/components/Company/Industry/Actions.js +1 -1
  54. package/dist/components/Company/Industry/Context.js +1 -1
  55. package/dist/components/Company/Industry/Edit.js +1 -1
  56. package/dist/components/Company/Locations/LocationForm/Actions.js +1 -1
  57. package/dist/components/Company/Locations/LocationForm/Form.js +5 -4
  58. package/dist/components/Company/Locations/LocationForm/Form.js.map +1 -1
  59. package/dist/components/Company/Locations/LocationForm/LocationForm.js +9 -7
  60. package/dist/components/Company/Locations/LocationForm/LocationForm.js.map +1 -1
  61. package/dist/components/Company/Locations/LocationForm/useLocationForm.js +1 -1
  62. package/dist/components/Company/Locations/LocationsList/Actions.js +1 -1
  63. package/dist/components/Company/Locations/LocationsList/List.js +1 -1
  64. package/dist/components/Company/Locations/LocationsList/LocationsList.js +11 -9
  65. package/dist/components/Company/Locations/LocationsList/LocationsList.js.map +1 -1
  66. package/dist/components/Company/Locations/LocationsList/useLocationsList.js +1 -1
  67. package/dist/components/Company/OnboardingOverview/Completed.js +6 -5
  68. package/dist/components/Company/OnboardingOverview/Completed.js.map +1 -1
  69. package/dist/components/Company/OnboardingOverview/MissingRequirements.js +3 -2
  70. package/dist/components/Company/OnboardingOverview/MissingRequirements.js.map +1 -1
  71. package/dist/components/Company/OnboardingOverview/OnboardingOverview.js +4 -2
  72. package/dist/components/Company/OnboardingOverview/OnboardingOverview.js.map +1 -1
  73. package/dist/components/Company/OnboardingOverview/context.js +1 -1
  74. package/dist/components/Company/PaySchedule/PaySchedule.js +18 -16
  75. package/dist/components/Company/PaySchedule/PaySchedule.js.map +1 -1
  76. package/dist/components/Company/PaySchedule/_parts/Actions.js +1 -1
  77. package/dist/components/Company/PaySchedule/_parts/Edit.js +26 -25
  78. package/dist/components/Company/PaySchedule/_parts/Edit.js.map +1 -1
  79. package/dist/components/Company/PaySchedule/_parts/Head.js +3 -2
  80. package/dist/components/Company/PaySchedule/_parts/Head.js.map +1 -1
  81. package/dist/components/Company/PaySchedule/_parts/List.js +6 -5
  82. package/dist/components/Company/PaySchedule/_parts/List.js.map +1 -1
  83. package/dist/components/Company/PaySchedule/usePaySchedule.js +1 -1
  84. package/dist/components/Company/StateTaxes/StateTaxes.js +23 -44
  85. package/dist/components/Company/StateTaxes/StateTaxes.js.map +1 -1
  86. package/dist/components/Company/StateTaxes/StateTaxesComponents.d.ts +6 -8
  87. package/dist/components/Company/StateTaxes/StateTaxesComponents.js +15 -16
  88. package/dist/components/Company/StateTaxes/StateTaxesComponents.js.map +1 -1
  89. package/dist/components/Company/StateTaxes/StateTaxesForm/Actions.js +1 -1
  90. package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js +65 -59
  91. package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js.map +1 -1
  92. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +1 -1
  93. package/dist/components/Company/StateTaxes/StateTaxesList/Actions.js +1 -1
  94. package/dist/components/Company/StateTaxes/StateTaxesList/List.js +1 -1
  95. package/dist/components/Company/StateTaxes/StateTaxesList/context.js +1 -1
  96. package/dist/components/Company/StateTaxes/stateTaxesStateMachine.d.ts +5 -0
  97. package/dist/components/Company/StateTaxes/stateTaxesStateMachine.js +48 -0
  98. package/dist/components/Company/StateTaxes/stateTaxesStateMachine.js.map +1 -0
  99. package/dist/components/Contractor/Address/Address.js +2 -0
  100. package/dist/components/Contractor/Address/Address.js.map +1 -1
  101. package/dist/components/Contractor/Address/Form.js +7 -6
  102. package/dist/components/Contractor/Address/Form.js.map +1 -1
  103. package/dist/components/Contractor/Address/useAddress.js +1 -1
  104. package/dist/components/Contractor/List/index.js +3 -2
  105. package/dist/components/Contractor/List/index.js.map +1 -1
  106. package/dist/components/Contractor/NewHireReport/NewHireReport.js +17 -16
  107. package/dist/components/Contractor/NewHireReport/NewHireReport.js.map +1 -1
  108. package/dist/components/Contractor/PaymentMethod/BankAccountForm.js +1 -1
  109. package/dist/components/Contractor/PaymentMethod/PaymentMethod.js +3 -2
  110. package/dist/components/Contractor/PaymentMethod/PaymentMethod.js.map +1 -1
  111. package/dist/components/Contractor/PaymentMethod/PaymentTypeForm.js +3 -2
  112. package/dist/components/Contractor/PaymentMethod/PaymentTypeForm.js.map +1 -1
  113. package/dist/components/Employee/Compensation/Actions.js +6 -5
  114. package/dist/components/Employee/Compensation/Actions.js.map +1 -1
  115. package/dist/components/Employee/Compensation/Edit.js +3 -2
  116. package/dist/components/Employee/Compensation/Edit.js.map +1 -1
  117. package/dist/components/Employee/Compensation/List.js +1 -1
  118. package/dist/components/Employee/Deductions/Actions.js +1 -1
  119. package/dist/components/Employee/Deductions/DeductionForm.js +1 -1
  120. package/dist/components/Employee/Deductions/DeductionsList.js +1 -1
  121. package/dist/components/Employee/Deductions/IncludeDeductionsForm.js +1 -1
  122. package/dist/components/Employee/Deductions/useDeductions.js +1 -1
  123. package/dist/components/Employee/DocumentSigner/DocumentList/Actions.js +1 -1
  124. package/dist/components/Employee/DocumentSigner/DocumentList/DocumentList.js +12 -10
  125. package/dist/components/Employee/DocumentSigner/DocumentList/DocumentList.js.map +1 -1
  126. package/dist/components/Employee/DocumentSigner/DocumentList/List.js +3 -2
  127. package/dist/components/Employee/DocumentSigner/DocumentList/List.js.map +1 -1
  128. package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js +1 -1
  129. package/dist/components/Employee/DocumentSigner/SignatureForm/SignatureForm.js +10 -8
  130. package/dist/components/Employee/DocumentSigner/SignatureForm/SignatureForm.js.map +1 -1
  131. package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js +1 -1
  132. package/dist/components/Employee/EmployeeList/Actions.js +1 -1
  133. package/dist/components/Employee/EmployeeList/EmployeeList.js +4 -2
  134. package/dist/components/Employee/EmployeeList/EmployeeList.js.map +1 -1
  135. package/dist/components/Employee/EmployeeList/Head.js +3 -2
  136. package/dist/components/Employee/EmployeeList/Head.js.map +1 -1
  137. package/dist/components/Employee/EmployeeList/List.js +15 -14
  138. package/dist/components/Employee/EmployeeList/List.js.map +1 -1
  139. package/dist/components/Employee/EmployeeList/useEmployeeList.js +1 -1
  140. package/dist/components/Employee/Landing/Landing.js +7 -6
  141. package/dist/components/Employee/Landing/Landing.js.map +1 -1
  142. package/dist/components/Employee/PaymentMethod/Actions.js +1 -1
  143. package/dist/components/Employee/PaymentMethod/BankAccountEdit.js +3 -2
  144. package/dist/components/Employee/PaymentMethod/BankAccountEdit.js.map +1 -1
  145. package/dist/components/Employee/PaymentMethod/BankAccountsList.js +1 -1
  146. package/dist/components/Employee/PaymentMethod/PaymentTypeForm.js +3 -2
  147. package/dist/components/Employee/PaymentMethod/PaymentTypeForm.js.map +1 -1
  148. package/dist/components/Employee/PaymentMethod/Split.js +4 -3
  149. package/dist/components/Employee/PaymentMethod/Split.js.map +1 -1
  150. package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +1 -1
  151. package/dist/components/Employee/Profile/Actions.js +1 -1
  152. package/dist/components/Employee/Profile/AdminPersonalDetails.js +10 -9
  153. package/dist/components/Employee/Profile/AdminPersonalDetails.js.map +1 -1
  154. package/dist/components/Employee/Profile/HomeAddress.js +5 -4
  155. package/dist/components/Employee/Profile/HomeAddress.js.map +1 -1
  156. package/dist/components/Employee/Profile/PersonalDetailsInputs.js +1 -1
  157. package/dist/components/Employee/Profile/useProfile.js +1 -1
  158. package/dist/components/Employee/Taxes/Actions.js +1 -1
  159. package/dist/components/Employee/Taxes/FederalForm.js +1 -1
  160. package/dist/components/Employee/Taxes/useTaxes.js +1 -1
  161. package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +1 -1
  162. package/dist/i18n/en/Company.StateTaxes.json.js +2 -1
  163. package/dist/i18n/en/Company.StateTaxes.json.js.map +1 -1
  164. package/dist/style.css +1 -1
  165. package/dist/types/i18next.d.ts +1 -0
  166. package/package.json +2 -2
  167. package/dist/components/Company/StateTaxes/stateTaxesReducer.d.ts +0 -20
  168. package/dist/components/Company/StateTaxes/stateTaxesReducer.js +0 -40
  169. package/dist/components/Company/StateTaxes/stateTaxesReducer.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.7
4
+
5
+ - Upgrade embedded api to fix state taxes validation issue
6
+ - Fix tax rate fields preventing form submission
7
+ - Remove unused docs tests
8
+ - Fix RC publish script to allow for branch selection
9
+
3
10
  ## 0.10.6
4
11
 
5
12
  ### Fixes
@@ -10,39 +10,40 @@ import { FadeIn as _ } from "../Common/FadeIn/FadeIn.js";
10
10
  import { BaseContext as j } from "./useBase.js";
11
11
  import { componentEvents as F } from "../../shared/constants.js";
12
12
  import { useAsyncError as K } from "../Common/hooks/useAsyncError.js";
13
+ import "classnames";
13
14
  import { InternalError as P } from "../Common/InternalError/InternalError.js";
14
15
  import { snakeCaseToCamelCase as w } from "../../helpers/formattedStrings.js";
15
16
  import { useComponentContext as M } from "../../contexts/ComponentAdapter/useComponentContext.js";
16
17
  import { useLoadingIndicator as O } from "../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
17
- const U = (e) => e.map((n) => n.message ? /* @__PURE__ */ o("li", { children: n.message }, n.key) : null), k = (e, n) => {
18
+ const U = (t) => t.map((n) => n.message ? /* @__PURE__ */ o("li", { children: n.message }, n.key) : null), k = (t, n) => {
18
19
  const m = n ? n + "." : "";
19
- if (e.category === "invalid_attribute_value" || e.category === "invalid_operation")
20
+ if (t.category === "invalid_attribute_value" || t.category === "invalid_operation")
20
21
  return [
21
22
  {
22
- key: w(m + e.errorKey),
23
- message: e.message ?? ""
23
+ key: w(m + t.errorKey),
24
+ message: t.message ?? ""
24
25
  }
25
26
  ];
26
- if (e.category === "nested_errors" && e.errors !== void 0) {
27
+ if (t.category === "nested_errors" && t.errors !== void 0) {
27
28
  let s = "";
28
- return e.metadata?.key && typeof e.metadata.key == "string" ? s = e.metadata.key : e.metadata?.state && typeof e.metadata.state == "string" ? s = e.metadata.state : e.errorKey && (s = e.errorKey), e.errors.flatMap((r) => k(r, m + s));
29
+ return t.metadata?.key && typeof t.metadata.key == "string" ? s = t.metadata.key : t.metadata?.state && typeof t.metadata.state == "string" ? s = t.metadata.state : t.errorKey && (s = t.errorKey), t.errors.flatMap((r) => k(r, m + s));
29
30
  }
30
31
  return [];
31
- }, re = ({
32
- children: e,
32
+ }, ot = ({
33
+ children: t,
33
34
  FallbackComponent: n = P,
34
35
  LoaderComponent: m,
35
36
  onEvent: s
36
37
  }) => {
37
- const [r, l] = y(null), [c, f] = y(null), p = K(), { t: x } = B(), d = M(), { LoadingIndicator: b } = O(), v = m ?? b, I = E((t) => {
38
- l(t), t || f(null);
39
- }, []), A = (t) => {
40
- l(t), t instanceof h && Array.isArray(t.errors) && f(t.errors.flatMap((a) => k(a)));
38
+ const [r, l] = y(null), [c, f] = y(null), p = K(), { t: x } = B(), d = M(), { LoadingIndicator: b } = O(), v = m ?? b, I = E((e) => {
39
+ l(e), e || f(null);
40
+ }, []), A = (e) => {
41
+ l(e), e instanceof h && Array.isArray(e.errors) && f(e.errors.flatMap((a) => k(a)));
41
42
  }, L = E(
42
- async (t, a) => {
43
+ async (e, a) => {
43
44
  l(null), f(null);
44
45
  try {
45
- await a(t);
46
+ await a(e);
46
47
  } catch (i) {
47
48
  i instanceof g || i instanceof C || i instanceof h ? A(i) : p(i);
48
49
  }
@@ -59,11 +60,11 @@ const U = (e) => e.map((n) => n.message ? /* @__PURE__ */ o("li", { children: n.
59
60
  throwError: p,
60
61
  baseSubmitHandler: L
61
62
  },
62
- children: /* @__PURE__ */ o(T, { children: ({ reset: t }) => /* @__PURE__ */ u(
63
+ children: /* @__PURE__ */ o(T, { children: ({ reset: e }) => /* @__PURE__ */ u(
63
64
  S,
64
65
  {
65
66
  FallbackComponent: n,
66
- onReset: t,
67
+ onReset: e,
67
68
  onError: (a) => {
68
69
  s(F.ERROR, a);
69
70
  },
@@ -73,7 +74,7 @@ const U = (e) => e.map((n) => n.message ? /* @__PURE__ */ o("li", { children: n.
73
74
  r && r instanceof g && /* @__PURE__ */ o(d.Text, { children: r.message }),
74
75
  r && r instanceof C && /* @__PURE__ */ o(d.Text, { as: "pre", children: r.pretty() })
75
76
  ] }),
76
- /* @__PURE__ */ o(R, { fallback: /* @__PURE__ */ o(v, {}), children: /* @__PURE__ */ o(_, { children: e }) })
77
+ /* @__PURE__ */ o(R, { fallback: /* @__PURE__ */ o(v, {}), children: /* @__PURE__ */ o(_, { children: t }) })
77
78
  ]
78
79
  }
79
80
  ) })
@@ -81,6 +82,6 @@ const U = (e) => e.map((n) => n.message ? /* @__PURE__ */ o("li", { children: n.
81
82
  );
82
83
  };
83
84
  export {
84
- re as BaseComponent
85
+ ot as BaseComponent
85
86
  };
86
87
  //# sourceMappingURL=Base.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Base.js","sources":["../../../src/components/Base/Base.tsx"],"sourcesContent":["import type { ReactNode, JSX } from 'react'\nimport { Suspense, useState, useCallback } from 'react'\nimport type { FallbackProps } from 'react-error-boundary'\nimport { ErrorBoundary } from 'react-error-boundary'\nimport { useTranslation } from 'react-i18next'\nimport { APIError } from '@gusto/embedded-api/models/errors/apierror'\nimport { SDKValidationError } from '@gusto/embedded-api/models/errors/sdkvalidationerror'\nimport { UnprocessableEntityErrorObject } from '@gusto/embedded-api/models/errors/unprocessableentityerrorobject'\nimport type { EntityErrorObject } from '@gusto/embedded-api/models/components/entityerrorobject'\nimport { QueryErrorResetBoundary } from '@tanstack/react-query'\nimport { FadeIn } from '../Common/FadeIn/FadeIn'\nimport { BaseContext, type FieldError, type KnownErrors, type OnEventType } from './useBase'\nimport { componentEvents, type EventType } from '@/shared/constants'\nimport { InternalError, useAsyncError } from '@/components/Common'\nimport { snakeCaseToCamelCase } from '@/helpers/formattedStrings'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport type { ResourceDictionary, Resources } from '@/types/Helpers'\nimport { useLoadingIndicator } from '@/contexts/LoadingIndicatorProvider/useLoadingIndicator'\nimport type { LoadingIndicatorContextProps } from '@/contexts/LoadingIndicatorProvider/useLoadingIndicator'\n\nexport interface CommonComponentInterface<TResourceKey extends keyof Resources = keyof Resources> {\n children?: ReactNode\n className?: string\n defaultValues?: unknown\n dictionary?: ResourceDictionary<TResourceKey>\n}\n\n// Base component wrapper with error and suspense handling\nexport interface BaseComponentInterface<TResourceKey extends keyof Resources = keyof Resources>\n extends CommonComponentInterface<TResourceKey> {\n FallbackComponent?: (props: FallbackProps) => JSX.Element\n LoaderComponent?: LoadingIndicatorContextProps['LoadingIndicator']\n onEvent: OnEventType<EventType, unknown>\n}\n\n/**Traverses errorList and finds items with message properties */\nconst renderErrorList = (errorList: FieldError[]): React.ReactNode[] => {\n return errorList.map(errorFromList => {\n if (errorFromList.message) {\n return <li key={errorFromList.key}>{errorFromList.message}</li>\n }\n return null\n })\n}\n/**Recuresively parses error list and constructs an array of objects containing attribute value error messages associated with form fields. Nested errors construct '.' separated keys\n * metadata.state is a special case for state taxes validation errors\n */\nconst getFieldErrors = (\n error: EntityErrorObject,\n parentKey?: string,\n): { key: string; message: string }[] => {\n const keyPrefix = parentKey ? parentKey + '.' : ''\n if (error.category === 'invalid_attribute_value' || error.category === 'invalid_operation') {\n return [\n {\n key: snakeCaseToCamelCase(keyPrefix + error.errorKey),\n message: error.message ?? '',\n },\n ]\n }\n if (error.category === 'nested_errors' && error.errors !== undefined) {\n //TODO: clean this up once Metadata type is fixed in openapi spec\n let keySuffix = ''\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n if (error.metadata?.key && typeof error.metadata.key === 'string') {\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n keySuffix = error.metadata.key as string\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n } else if (error.metadata?.state && typeof error.metadata.state === 'string') {\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n keySuffix = error.metadata.state as string\n } else if (error.errorKey) {\n keySuffix = error.errorKey\n }\n return error.errors.flatMap(err => getFieldErrors(err, keyPrefix + keySuffix))\n }\n return []\n}\n\ntype SubmitHandler<T> = (data: T) => Promise<void>\n\nexport const BaseComponent = <TResourceKey extends keyof Resources = keyof Resources>({\n children,\n FallbackComponent = InternalError,\n LoaderComponent: LoadingIndicatorFromProps,\n onEvent,\n}: BaseComponentInterface<TResourceKey>) => {\n const [error, setError] = useState<KnownErrors | null>(null)\n const [fieldErrors, setFieldErrors] = useState<FieldError[] | null>(null)\n const throwError = useAsyncError()\n const { t } = useTranslation()\n const Components = useComponentContext()\n\n const { LoadingIndicator: LoadingIndicatorFromContext } = useLoadingIndicator()\n\n const LoaderComponent = LoadingIndicatorFromProps ?? LoadingIndicatorFromContext\n\n // Enhanced setError that also clears fieldErrors when error is cleared\n const setErrorWithFieldsClear = useCallback((error: KnownErrors | null) => {\n setError(error)\n if (!error) {\n setFieldErrors(null)\n }\n }, [])\n\n const processError = (error: KnownErrors) => {\n setError(error)\n //422\tapplication/json - content relaited error\n if (error instanceof UnprocessableEntityErrorObject && Array.isArray(error.errors)) {\n setFieldErrors(error.errors.flatMap(err => getFieldErrors(err)))\n }\n }\n\n const baseSubmitHandler = useCallback(\n async <T,>(data: T, componentHandler: SubmitHandler<T>) => {\n setError(null)\n setFieldErrors(null)\n try {\n await componentHandler(data)\n } catch (err) {\n if (\n err instanceof APIError ||\n err instanceof SDKValidationError ||\n err instanceof UnprocessableEntityErrorObject\n ) {\n processError(err)\n } else throwError(err)\n }\n },\n [setError, throwError],\n )\n\n return (\n <BaseContext.Provider\n value={{\n fieldErrors,\n setError: setErrorWithFieldsClear,\n onEvent,\n throwError,\n baseSubmitHandler,\n }}\n >\n <QueryErrorResetBoundary>\n {({ reset: resetQueries }) => (\n <ErrorBoundary\n FallbackComponent={FallbackComponent}\n onReset={resetQueries}\n onError={err => {\n onEvent(componentEvents.ERROR, err)\n }}\n >\n {(error || fieldErrors) && (\n <Components.Alert label={t('status.errorEncountered')} status=\"error\">\n {fieldErrors && <Components.UnorderedList items={renderErrorList(fieldErrors)} />}\n {error && error instanceof APIError && (\n <Components.Text>{error.message}</Components.Text>\n )}\n {error && error instanceof SDKValidationError && (\n <Components.Text as=\"pre\">{error.pretty()}</Components.Text>\n )}\n </Components.Alert>\n )}\n <Suspense fallback={<LoaderComponent />}>\n <FadeIn>{children}</FadeIn>\n </Suspense>\n </ErrorBoundary>\n )}\n </QueryErrorResetBoundary>\n </BaseContext.Provider>\n )\n}\n"],"names":["renderErrorList","errorList","errorFromList","jsx","getFieldErrors","error","parentKey","keyPrefix","snakeCaseToCamelCase","keySuffix","err","BaseComponent","children","FallbackComponent","InternalError","LoadingIndicatorFromProps","onEvent","setError","useState","fieldErrors","setFieldErrors","throwError","useAsyncError","t","useTranslation","Components","useComponentContext","LoadingIndicatorFromContext","useLoadingIndicator","LoaderComponent","setErrorWithFieldsClear","useCallback","processError","UnprocessableEntityErrorObject","baseSubmitHandler","data","componentHandler","APIError","SDKValidationError","BaseContext","QueryErrorResetBoundary","resetQueries","jsxs","ErrorBoundary","componentEvents","Suspense","FadeIn"],"mappings":";;;;;;;;;;;;;;;;AAoCA,MAAMA,IAAkB,CAACC,MAChBA,EAAU,IAAI,CAAiBC,MAChCA,EAAc,UACR,gBAAAC,EAAA,MAAA,EAA4B,UAAcD,EAAA,QAAA,GAAlCA,EAAc,GAA4B,IAErD,IACR,GAKGE,IAAiB,CACrBC,GACAC,MACuC;AACjC,QAAAC,IAAYD,IAAYA,IAAY,MAAM;AAChD,MAAID,EAAM,aAAa,6BAA6BA,EAAM,aAAa;AAC9D,WAAA;AAAA,MACL;AAAA,QACE,KAAKG,EAAqBD,IAAYF,EAAM,QAAQ;AAAA,QACpD,SAASA,EAAM,WAAW;AAAA,MAAA;AAAA,IAE9B;AAEF,MAAIA,EAAM,aAAa,mBAAmBA,EAAM,WAAW,QAAW;AAEpE,QAAII,IAAY;AAEhB,WAAIJ,EAAM,UAAU,OAAO,OAAOA,EAAM,SAAS,OAAQ,WAEvDI,IAAYJ,EAAM,S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IAACoC,EAAY;AAAA,IAAZ;AAAA,MACC,OAAO;AAAA,QACL,aAAApB;AAAA,QACA,UAAUW;AAAA,QACV,SAAAd;AAAA,QACA,YAAAK;AAAA,QACA,mBAAAa;AAAA,MACF;AAAA,MAEA,4BAACM,GACE,EAAA,UAAA,CAAC,EAAE,OAAOC,QACT,gBAAAC;AAAA,QAACC;AAAA,QAAA;AAAA,UACC,mBAAA9B;AAAA,UACA,SAAS4B;AAAA,UACT,SAAS,CAAO/B,MAAA;AACN,YAAAM,EAAA4B,EAAgB,OAAOlC,CAAG;AAAA,UACpC;AAAA,UAEE,UAAA;AAAA,aAASL,KAAAc,MACR,gBAAAuB,EAAAjB,EAAW,OAAX,EAAiB,OAAOF,EAAE,yBAAyB,GAAG,QAAO,SAC3D,UAAA;AAAA,cAAAJ,uBAAgBM,EAAW,eAAX,EAAyB,OAAOzB,EAAgBmB,CAAW,GAAG;AAAA,cAC9Ed,KAASA,aAAiBgC,KACzB,gBAAAlC,EAACsB,EAAW,MAAX,EAAiB,YAAM,SAAQ;AAAA,cAEjCpB,KAASA,aAAiBiC,KACxB,gBAAAnC,EAAAsB,EAAW,MAAX,EAAgB,IAAG,OAAO,UAAMpB,EAAA,OAAA,EAAS,CAAA;AAAA,YAAA,GAE9C;AAAA,YAEF,gBAAAF,EAAC0C,KAAS,UAAU,gBAAA1C,EAAC0B,KAAgB,GACnC,UAAA,gBAAA1B,EAAC2C,GAAQ,EAAA,UAAAlC,EAAS,CAAA,EACpB,CAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA,EAGN,CAAA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
1
+ {"version":3,"file":"Base.js","sources":["../../../src/components/Base/Base.tsx"],"sourcesContent":["import type { ReactNode, JSX } from 'react'\nimport { Suspense, useState, useCallback } from 'react'\nimport type { FallbackProps } from 'react-error-boundary'\nimport { ErrorBoundary } from 'react-error-boundary'\nimport { useTranslation } from 'react-i18next'\nimport { APIError } from '@gusto/embedded-api/models/errors/apierror'\nimport { SDKValidationError } from '@gusto/embedded-api/models/errors/sdkvalidationerror'\nimport { UnprocessableEntityErrorObject } from '@gusto/embedded-api/models/errors/unprocessableentityerrorobject'\nimport type { EntityErrorObject } from '@gusto/embedded-api/models/components/entityerrorobject'\nimport { QueryErrorResetBoundary } from '@tanstack/react-query'\nimport { FadeIn } from '../Common/FadeIn/FadeIn'\nimport { BaseContext, type FieldError, type KnownErrors, type OnEventType } from './useBase'\nimport { componentEvents, type EventType } from '@/shared/constants'\nimport { InternalError, useAsyncError } from '@/components/Common'\nimport { snakeCaseToCamelCase } from '@/helpers/formattedStrings'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport type { ResourceDictionary, Resources } from '@/types/Helpers'\nimport { useLoadingIndicator } from '@/contexts/LoadingIndicatorProvider/useLoadingIndicator'\nimport type { LoadingIndicatorContextProps } from '@/contexts/LoadingIndicatorProvider/useLoadingIndicator'\n\nexport interface CommonComponentInterface<TResourceKey extends keyof Resources = keyof Resources> {\n children?: ReactNode\n className?: string\n defaultValues?: unknown\n dictionary?: ResourceDictionary<TResourceKey>\n}\n\n// Base component wrapper with error and suspense handling\nexport interface BaseComponentInterface<TResourceKey extends keyof Resources = keyof Resources>\n extends CommonComponentInterface<TResourceKey> {\n FallbackComponent?: (props: FallbackProps) => JSX.Element\n LoaderComponent?: LoadingIndicatorContextProps['LoadingIndicator']\n onEvent: OnEventType<EventType, unknown>\n}\n\n/**Traverses errorList and finds items with message properties */\nconst renderErrorList = (errorList: FieldError[]): React.ReactNode[] => {\n return errorList.map(errorFromList => {\n if (errorFromList.message) {\n return <li key={errorFromList.key}>{errorFromList.message}</li>\n }\n return null\n })\n}\n/**Recuresively parses error list and constructs an array of objects containing attribute value error messages associated with form fields. Nested errors construct '.' separated keys\n * metadata.state is a special case for state taxes validation errors\n */\nconst getFieldErrors = (\n error: EntityErrorObject,\n parentKey?: string,\n): { key: string; message: string }[] => {\n const keyPrefix = parentKey ? parentKey + '.' : ''\n if (error.category === 'invalid_attribute_value' || error.category === 'invalid_operation') {\n return [\n {\n key: snakeCaseToCamelCase(keyPrefix + error.errorKey),\n message: error.message ?? '',\n },\n ]\n }\n if (error.category === 'nested_errors' && error.errors !== undefined) {\n //TODO: clean this up once Metadata type is fixed in openapi spec\n let keySuffix = ''\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n if (error.metadata?.key && typeof error.metadata.key === 'string') {\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n keySuffix = error.metadata.key as string\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n } else if (error.metadata?.state && typeof error.metadata.state === 'string') {\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n keySuffix = error.metadata.state as string\n } else if (error.errorKey) {\n keySuffix = error.errorKey\n }\n return error.errors.flatMap(err => getFieldErrors(err, keyPrefix + keySuffix))\n }\n return []\n}\n\ntype SubmitHandler<T> = (data: T) => Promise<void>\n\nexport const BaseComponent = <TResourceKey extends keyof Resources = keyof Resources>({\n children,\n FallbackComponent = InternalError,\n LoaderComponent: LoadingIndicatorFromProps,\n onEvent,\n}: BaseComponentInterface<TResourceKey>) => {\n const [error, setError] = useState<KnownErrors | null>(null)\n const [fieldErrors, setFieldErrors] = useState<FieldError[] | null>(null)\n const throwError = useAsyncError()\n const { t } = useTranslation()\n const Components = useComponentContext()\n\n const { LoadingIndicator: LoadingIndicatorFromContext } = useLoadingIndicator()\n\n const LoaderComponent = LoadingIndicatorFromProps ?? LoadingIndicatorFromContext\n\n // Enhanced setError that also clears fieldErrors when error is cleared\n const setErrorWithFieldsClear = useCallback((error: KnownErrors | null) => {\n setError(error)\n if (!error) {\n setFieldErrors(null)\n }\n }, [])\n\n const processError = (error: KnownErrors) => {\n setError(error)\n //422\tapplication/json - content relaited error\n if (error instanceof UnprocessableEntityErrorObject && Array.isArray(error.errors)) {\n setFieldErrors(error.errors.flatMap(err => getFieldErrors(err)))\n }\n }\n\n const baseSubmitHandler = useCallback(\n async <T,>(data: T, componentHandler: SubmitHandler<T>) => {\n setError(null)\n setFieldErrors(null)\n try {\n await componentHandler(data)\n } catch (err) {\n if (\n err instanceof APIError ||\n err instanceof SDKValidationError ||\n err instanceof UnprocessableEntityErrorObject\n ) {\n processError(err)\n } else throwError(err)\n }\n },\n [setError, throwError],\n )\n\n return (\n <BaseContext.Provider\n value={{\n fieldErrors,\n setError: setErrorWithFieldsClear,\n onEvent,\n throwError,\n baseSubmitHandler,\n }}\n >\n <QueryErrorResetBoundary>\n {({ reset: resetQueries }) => (\n <ErrorBoundary\n FallbackComponent={FallbackComponent}\n onReset={resetQueries}\n onError={err => {\n onEvent(componentEvents.ERROR, err)\n }}\n >\n {(error || fieldErrors) && (\n <Components.Alert label={t('status.errorEncountered')} status=\"error\">\n {fieldErrors && <Components.UnorderedList items={renderErrorList(fieldErrors)} />}\n {error && error instanceof APIError && (\n <Components.Text>{error.message}</Components.Text>\n )}\n {error && error instanceof SDKValidationError && (\n <Components.Text as=\"pre\">{error.pretty()}</Components.Text>\n )}\n </Components.Alert>\n )}\n <Suspense fallback={<LoaderComponent />}>\n <FadeIn>{children}</FadeIn>\n </Suspense>\n </ErrorBoundary>\n )}\n </QueryErrorResetBoundary>\n </BaseContext.Provider>\n )\n}\n"],"names":["renderErrorList","errorList","errorFromList","jsx","getFieldErrors","error","parentKey","keyPrefix","snakeCaseToCamelCase","keySuffix","err","BaseComponent","children","FallbackComponent","InternalError","LoadingIndicatorFromProps","onEvent","setError","useState","fieldErrors","setFieldErrors","throwError","useAsyncError","t","useTranslation","Components","useComponentContext","LoadingIndicatorFromContext","useLoadingIndicator","LoaderComponent","setErrorWithFieldsClear","useCallback","processError","UnprocessableEntityErrorObject","baseSubmitHandler","data","componentHandler","APIError","SDKValidationError","BaseContext","QueryErrorResetBoundary","resetQueries","jsxs","ErrorBoundary","componentEvents","Suspense","FadeIn"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,MAAMA,IAAkB,CAACC,MAChBA,EAAU,IAA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B,IAAG,OAAO,UAAMpB,EAAA,OAAA,EAAS,CAAA;AAAA,YAAA,GAE9C;AAAA,YAEF,gBAAAF,EAAC0C,KAAS,UAAU,gBAAA1C,EAAC0B,KAAgB,GACnC,UAAA,gBAAA1B,EAAC2C,GAAQ,EAAA,UAAAlC,EAAS,CAAA,EACpB,CAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA,EAGN,CAAA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
@@ -5,22 +5,24 @@ import { zodResolver as l } from "@hookform/resolvers/zod";
5
5
  import t from "./SignatureForm.module.scss.js";
6
6
  import { Form as u } from "../Form/Form.js";
7
7
  import { Flex as c } from "../Flex/Flex.js";
8
+ import "react-i18next";
9
+ import "classnames";
8
10
  const f = o.object({
9
11
  signature: o.string().min(1),
10
12
  confirmSignature: o.literal(!0)
11
- }), d = {
13
+ }), p = {
12
14
  signature: ""
13
15
  };
14
- function b({ onSubmit: m, children: i, formProps: n }) {
16
+ function z({ onSubmit: m, children: i, formProps: n }) {
15
17
  const e = s({
16
18
  resolver: l(f),
17
- defaultValues: d,
19
+ defaultValues: p,
18
20
  ...n
19
21
  });
20
22
  return /* @__PURE__ */ r(a, { ...e, children: /* @__PURE__ */ r(u, { onSubmit: e.handleSubmit(m), className: t.container, children: /* @__PURE__ */ r("div", { className: t.formFields, children: /* @__PURE__ */ r(c, { flexDirection: "column", gap: 20, children: i }) }) }) });
21
23
  }
22
24
  export {
23
- b as SignatureForm,
25
+ z as SignatureForm,
24
26
  f as SignatureFormSchema
25
27
  };
26
28
  //# sourceMappingURL=SignatureForm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SignatureForm.js","sources":["../../../../src/components/Common/SignatureForm/SignatureForm.tsx"],"sourcesContent":["import { z } from 'zod'\nimport { FormProvider, useForm, type UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport styles from './SignatureForm.module.scss'\nimport { Form } from '@/components/Common/Form'\nimport { Flex } from '@/components/Common'\n\nexport const SignatureFormSchema = z.object({\n signature: z.string().min(1),\n confirmSignature: z.literal(true),\n})\n\nconst signatureFormDefaultValues = {\n signature: '',\n}\n\nexport type SignatureFormInputs = z.infer<typeof SignatureFormSchema>\n\ninterface SignatureFormProps {\n onSubmit: (data: SignatureFormInputs) => void | Promise<void>\n children?: React.ReactNode\n formProps?: Partial<UseFormProps<SignatureFormInputs>>\n}\n\nexport function SignatureForm({ onSubmit, children, formProps }: SignatureFormProps) {\n const methods = useForm<SignatureFormInputs>({\n resolver: zodResolver(SignatureFormSchema),\n defaultValues: signatureFormDefaultValues,\n ...formProps,\n })\n\n return (\n <FormProvider {...methods}>\n <Form onSubmit={methods.handleSubmit(onSubmit)} className={styles.container}>\n <div className={styles.formFields}>\n <Flex flexDirection=\"column\" gap={20}>\n {children}\n </Flex>\n </div>\n </Form>\n </FormProvider>\n )\n}\n"],"names":["SignatureFormSchema","z","signatureFormDefaultValues","SignatureForm","onSubmit","children","formProps","methods","useForm","zodResolver","jsx","FormProvider","Form","styles","Flex"],"mappings":";;;;;;;AAOa,MAAAA,IAAsBC,EAAE,OAAO;AAAA,EAC1C,WAAWA,EAAE,SAAS,IAAI,CAAC;AAAA,EAC3B,kBAAkBA,EAAE,QAAQ,EAAI;AAClC,CAAC,GAEKC,IAA6B;AAAA,EACjC,WAAW;AACb;AAUO,SAASC,EAAc,EAAE,UAAAC,GAAU,UAAAC,GAAU,WAAAC,KAAiC;AACnF,QAAMC,IAAUC,EAA6B;AAAA,IAC3C,UAAUC,EAAYT,CAAmB;AAAA,IACzC,eAAeE;AAAA,IACf,GAAGI;AAAA,EAAA,CACJ;AAED,SACG,gBAAAI,EAAAC,GAAA,EAAc,GAAGJ,GAChB,UAAC,gBAAAG,EAAAE,GAAA,EAAK,UAAUL,EAAQ,aAAaH,CAAQ,GAAG,WAAWS,EAAO,WAChE,UAAC,gBAAAH,EAAA,OAAA,EAAI,WAAWG,EAAO,YACrB,UAAA,gBAAAH,EAACI,GAAK,EAAA,eAAc,UAAS,KAAK,IAC/B,UAAAT,EACH,CAAA,EACF,CAAA,EACF,CAAA,GACF;AAEJ;"}
1
+ {"version":3,"file":"SignatureForm.js","sources":["../../../../src/components/Common/SignatureForm/SignatureForm.tsx"],"sourcesContent":["import { z } from 'zod'\nimport { FormProvider, useForm, type UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport styles from './SignatureForm.module.scss'\nimport { Form } from '@/components/Common/Form'\nimport { Flex } from '@/components/Common'\n\nexport const SignatureFormSchema = z.object({\n signature: z.string().min(1),\n confirmSignature: z.literal(true),\n})\n\nconst signatureFormDefaultValues = {\n signature: '',\n}\n\nexport type SignatureFormInputs = z.infer<typeof SignatureFormSchema>\n\ninterface SignatureFormProps {\n onSubmit: (data: SignatureFormInputs) => void | Promise<void>\n children?: React.ReactNode\n formProps?: Partial<UseFormProps<SignatureFormInputs>>\n}\n\nexport function SignatureForm({ onSubmit, children, formProps }: SignatureFormProps) {\n const methods = useForm<SignatureFormInputs>({\n resolver: zodResolver(SignatureFormSchema),\n defaultValues: signatureFormDefaultValues,\n ...formProps,\n })\n\n return (\n <FormProvider {...methods}>\n <Form onSubmit={methods.handleSubmit(onSubmit)} className={styles.container}>\n <div className={styles.formFields}>\n <Flex flexDirection=\"column\" gap={20}>\n {children}\n </Flex>\n </div>\n </Form>\n </FormProvider>\n )\n}\n"],"names":["SignatureFormSchema","z","signatureFormDefaultValues","SignatureForm","onSubmit","children","formProps","methods","useForm","zodResolver","jsx","FormProvider","Form","styles","Flex"],"mappings":";;;;;;;;;AAOa,MAAAA,IAAsBC,EAAE,OAAO;AAAA,EAC1C,WAAWA,EAAE,SAAS,IAAI,CAAC;AAAA,EAC3B,kBAAkBA,EAAE,QAAQ,EAAI;AAClC,CAAC,GAEKC,IAA6B;AAAA,EACjC,WAAW;AACb;AAUO,SAASC,EAAc,EAAE,UAAAC,GAAU,UAAAC,GAAU,WAAAC,KAAiC;AACnF,QAAMC,IAAUC,EAA6B;AAAA,IAC3C,UAAUC,EAAYT,CAAmB;AAAA,IACzC,eAAeE;AAAA,IACf,GAAGI;AAAA,EAAA,CACJ;AAED,SACG,gBAAAI,EAAAC,GAAA,EAAc,GAAGJ,GAChB,UAAC,gBAAAG,EAAAE,GAAA,EAAK,UAAUL,EAAQ,aAAaH,CAAQ,GAAG,WAAWS,EAAO,WAChE,UAAC,gBAAAH,EAAA,OAAA,EAAI,WAAWG,EAAO,YACrB,UAAA,gBAAAH,EAACI,GAAK,EAAA,eAAc,UAAS,KAAK,IAC/B,UAAAT,EACH,CAAA,EACF,CAAA,EACF,CAAA,GACF;AAEJ;"}
@@ -1,20 +1,21 @@
1
1
  import { jsxs as m, jsx as n } from "react/jsx-runtime";
2
- import "../../../shared/constants.js";
2
+ import "react-i18next";
3
+ import "classnames";
3
4
  import { ActionsLayout as s } from "../ActionsLayout/ActionsLayout.js";
4
5
  import { useComponentContext as p } from "../../../contexts/ComponentAdapter/useComponentContext.js";
5
- function l({
6
+ function d({
6
7
  onBack: t,
7
8
  backLabel: r,
8
- submitLabel: e,
9
- isLoading: i = !1
9
+ submitLabel: i,
10
+ isLoading: e = !1
10
11
  }) {
11
12
  const o = p();
12
13
  return /* @__PURE__ */ m(s, { children: [
13
14
  t && /* @__PURE__ */ n(o.Button, { variant: "secondary", type: "button", onClick: t, children: r }),
14
- /* @__PURE__ */ n(o.Button, { type: "submit", isLoading: i, children: e })
15
+ /* @__PURE__ */ n(o.Button, { type: "submit", isLoading: e, children: i })
15
16
  ] });
16
17
  }
17
18
  export {
18
- l as SignatureFormActions
19
+ d as SignatureFormActions
19
20
  };
20
21
  //# sourceMappingURL=SignatureFormActions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SignatureFormActions.js","sources":["../../../../src/components/Common/SignatureForm/SignatureFormActions.tsx"],"sourcesContent":["import { ActionsLayout } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\ninterface SignatureFormActionsProps {\n onBack?: () => void\n backLabel: string\n submitLabel: string\n isLoading?: boolean\n}\n\nexport function SignatureFormActions({\n onBack,\n backLabel,\n submitLabel,\n isLoading = false,\n}: SignatureFormActionsProps) {\n const Components = useComponentContext()\n\n return (\n <ActionsLayout>\n {onBack && (\n <Components.Button variant=\"secondary\" type=\"button\" onClick={onBack}>\n {backLabel}\n </Components.Button>\n )}\n <Components.Button type=\"submit\" isLoading={isLoading}>\n {submitLabel}\n </Components.Button>\n </ActionsLayout>\n )\n}\n"],"names":["SignatureFormActions","onBack","backLabel","submitLabel","isLoading","Components","useComponentContext","ActionsLayout","jsx"],"mappings":";;;;AAUO,SAASA,EAAqB;AAAA,EACnC,QAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC,IAAY;AACd,GAA8B;AAC5B,QAAMC,IAAaC,EAAoB;AAEvC,2BACGC,GACE,EAAA,UAAA;AAAA,IACCN,KAAA,gBAAAO,EAACH,EAAW,QAAX,EAAkB,SAAQ,aAAY,MAAK,UAAS,SAASJ,GAC3D,UACHC,EAAA,CAAA;AAAA,sBAEDG,EAAW,QAAX,EAAkB,MAAK,UAAS,WAAAD,GAC9B,UACHD,EAAA,CAAA;AAAA,EAAA,GACF;AAEJ;"}
1
+ {"version":3,"file":"SignatureFormActions.js","sources":["../../../../src/components/Common/SignatureForm/SignatureFormActions.tsx"],"sourcesContent":["import { ActionsLayout } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\ninterface SignatureFormActionsProps {\n onBack?: () => void\n backLabel: string\n submitLabel: string\n isLoading?: boolean\n}\n\nexport function SignatureFormActions({\n onBack,\n backLabel,\n submitLabel,\n isLoading = false,\n}: SignatureFormActionsProps) {\n const Components = useComponentContext()\n\n return (\n <ActionsLayout>\n {onBack && (\n <Components.Button variant=\"secondary\" type=\"button\" onClick={onBack}>\n {backLabel}\n </Components.Button>\n )}\n <Components.Button type=\"submit\" isLoading={isLoading}>\n {submitLabel}\n </Components.Button>\n </ActionsLayout>\n )\n}\n"],"names":["SignatureFormActions","onBack","backLabel","submitLabel","isLoading","Components","useComponentContext","ActionsLayout","jsx"],"mappings":";;;;;AAUO,SAASA,EAAqB;AAAA,EACnC,QAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC,IAAY;AACd,GAA8B;AAC5B,QAAMC,IAAaC,EAAoB;AAEvC,2BACGC,GACE,EAAA,UAAA;AAAA,IACCN,KAAA,gBAAAO,EAACH,EAAW,QAAX,EAAkB,SAAQ,aAAY,MAAK,UAAS,SAASJ,GAC3D,UACHC,EAAA,CAAA;AAAA,sBAEDG,EAAW,QAAX,EAAkB,MAAK,UAAS,WAAAD,GAC9B,UACHD,EAAA,CAAA;AAAA,EAAA,GACF;AAEJ;"}
@@ -1,15 +1,16 @@
1
- import { jsxs as m, Fragment as s, jsx as e } from "react/jsx-runtime";
2
- import "../../../shared/constants.js";
1
+ import { jsxs as n, Fragment as s, jsx as e } from "react/jsx-runtime";
2
+ import "react-i18next";
3
+ import "classnames";
3
4
  import { TextInputField as a } from "../Fields/TextInputField/TextInputField.js";
4
5
  import { CheckboxField as u } from "../Fields/CheckboxField/CheckboxField.js";
5
- function c({
6
+ function f({
6
7
  signatureLabel: r,
7
8
  signatureDescription: i = "",
8
9
  signatureError: t = "",
9
10
  confirmationLabel: o,
10
- confirmationError: n = ""
11
+ confirmationError: m = ""
11
12
  }) {
12
- return /* @__PURE__ */ m(s, { children: [
13
+ return /* @__PURE__ */ n(s, { children: [
13
14
  /* @__PURE__ */ e(
14
15
  a,
15
16
  {
@@ -26,12 +27,12 @@ function c({
26
27
  name: "confirmSignature",
27
28
  isRequired: !0,
28
29
  label: o,
29
- errorMessage: n
30
+ errorMessage: m
30
31
  }
31
32
  )
32
33
  ] });
33
34
  }
34
35
  export {
35
- c as SignatureFormFields
36
+ f as SignatureFormFields
36
37
  };
37
38
  //# sourceMappingURL=SignatureFormFields.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SignatureFormFields.js","sources":["../../../../src/components/Common/SignatureForm/SignatureFormFields.tsx"],"sourcesContent":["import { TextInputField, CheckboxField } from '@/components/Common'\n\ninterface SignatureFormFieldsProps {\n signatureLabel: string\n signatureDescription?: string\n signatureError?: string\n confirmationLabel: string\n confirmationError?: string\n}\n\nexport function SignatureFormFields({\n signatureLabel,\n signatureDescription = '',\n signatureError = '',\n confirmationLabel,\n confirmationError = '',\n}: SignatureFormFieldsProps) {\n return (\n <>\n <TextInputField\n name=\"signature\"\n label={signatureLabel}\n description={signatureDescription}\n errorMessage={signatureError}\n isRequired\n />\n <CheckboxField\n name=\"confirmSignature\"\n isRequired\n label={confirmationLabel}\n errorMessage={confirmationError}\n />\n </>\n )\n}\n"],"names":["SignatureFormFields","signatureLabel","signatureDescription","signatureError","confirmationLabel","confirmationError","jsxs","Fragment","jsx","TextInputField","CheckboxField"],"mappings":";;;;AAUO,SAASA,EAAoB;AAAA,EAClC,gBAAAC;AAAA,EACA,sBAAAC,IAAuB;AAAA,EACvB,gBAAAC,IAAiB;AAAA,EACjB,mBAAAC;AAAA,EACA,mBAAAC,IAAoB;AACtB,GAA6B;AAC3B,SAEI,gBAAAC,EAAAC,GAAA,EAAA,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,OAAOR;AAAA,QACP,aAAaC;AAAA,QACb,cAAcC;AAAA,QACd,YAAU;AAAA,MAAA;AAAA,IACZ;AAAA,IACA,gBAAAK;AAAA,MAACE;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,YAAU;AAAA,QACV,OAAON;AAAA,QACP,cAAcC;AAAA,MAAA;AAAA,IAAA;AAAA,EAChB,GACF;AAEJ;"}
1
+ {"version":3,"file":"SignatureFormFields.js","sources":["../../../../src/components/Common/SignatureForm/SignatureFormFields.tsx"],"sourcesContent":["import { TextInputField, CheckboxField } from '@/components/Common'\n\ninterface SignatureFormFieldsProps {\n signatureLabel: string\n signatureDescription?: string\n signatureError?: string\n confirmationLabel: string\n confirmationError?: string\n}\n\nexport function SignatureFormFields({\n signatureLabel,\n signatureDescription = '',\n signatureError = '',\n confirmationLabel,\n confirmationError = '',\n}: SignatureFormFieldsProps) {\n return (\n <>\n <TextInputField\n name=\"signature\"\n label={signatureLabel}\n description={signatureDescription}\n errorMessage={signatureError}\n isRequired\n />\n <CheckboxField\n name=\"confirmSignature\"\n isRequired\n label={confirmationLabel}\n errorMessage={confirmationError}\n />\n </>\n )\n}\n"],"names":["SignatureFormFields","signatureLabel","signatureDescription","signatureError","confirmationLabel","confirmationError","jsxs","Fragment","jsx","TextInputField","CheckboxField"],"mappings":";;;;;AAUO,SAASA,EAAoB;AAAA,EAClC,gBAAAC;AAAA,EACA,sBAAAC,IAAuB;AAAA,EACvB,gBAAAC,IAAiB;AAAA,EACjB,mBAAAC;AAAA,EACA,mBAAAC,IAAoB;AACtB,GAA6B;AAC3B,SAEI,gBAAAC,EAAAC,GAAA,EAAA,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,OAAOR;AAAA,QACP,aAAaC;AAAA,QACb,cAAcC;AAAA,QACd,YAAU;AAAA,MAAA;AAAA,IACZ;AAAA,IACA,gBAAAK;AAAA,MAACE;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,YAAU;AAAA,QACV,OAAON;AAAA,QACP,cAAcC;AAAA,MAAA;AAAA,IAAA;AAAA,EAChB,GACF;AAEJ;"}
@@ -14,11 +14,15 @@ type NumberFieldProps = {
14
14
  isCurrency?: boolean;
15
15
  isPercent?: boolean;
16
16
  };
17
+ type TextInputProps = {
18
+ type?: string;
19
+ isPercent?: boolean;
20
+ };
17
21
  export declare function QuestionInput({ questionType, ...props }: (EmpQ | CompR) & {
18
22
  questionType: string;
19
23
  }): import("react/jsx-runtime").JSX.Element;
20
24
  export declare function SelectInput({ question, requirement, isDisabled }: EmpQ | CompR): import("react/jsx-runtime").JSX.Element | null;
21
- export declare function TextInput({ question, requirement, isDisabled }: EmpQ | CompR): import("react/jsx-runtime").JSX.Element | null;
25
+ export declare function TextInput({ question, requirement, isDisabled, type, isPercent, }: (EmpQ | CompR) & TextInputProps): import("react/jsx-runtime").JSX.Element | null;
22
26
  export declare function NumberInput({ question, requirement, isCurrency, isPercent, isDisabled, }: (EmpQ | CompR) & NumberFieldProps): import("react/jsx-runtime").JSX.Element | null;
23
27
  export declare function RadioInput({ question, requirement, isDisabled }: EmpQ | CompR): import("react/jsx-runtime").JSX.Element | null;
24
28
  export declare function DateField({ question, requirement, isDisabled, }: (EmpQ | CompR) & NumberFieldProps): import("react/jsx-runtime").JSX.Element | null;
@@ -1,14 +1,14 @@
1
1
  import { jsx as a } from "react/jsx-runtime";
2
2
  import b from "dompurify";
3
3
  import { useTranslation as y } from "react-i18next";
4
- import { SelectField as m } from "../Fields/SelectField/SelectField.js";
4
+ import { SelectField as p } from "../Fields/SelectField/SelectField.js";
5
5
  import { TextInputField as w } from "../Fields/TextInputField/TextInputField.js";
6
6
  import { NumberInputField as k } from "../Fields/NumberInputField/NumberInputField.js";
7
7
  import { RadioGroupField as R } from "../Fields/RadioGroupField/RadioGroupField.js";
8
8
  import { DatePickerField as _ } from "../Fields/DatePickerField/DatePickerField.js";
9
- import { useComponentContext as D } from "../../../contexts/ComponentAdapter/useComponentContext.js";
10
- import { useMaskedTransform as T } from "../../../helpers/mask.js";
11
- const h = { ALLOWED_TAGS: ["a", "b", "strong"], ALLOWED_ATTR: ["target", "href"] };
9
+ import { useComponentContext as x } from "../../../contexts/ComponentAdapter/useComponentContext.js";
10
+ import { useMaskedTransform as D } from "../../../helpers/mask.js";
11
+ const T = { ALLOWED_TAGS: ["a", "b", "strong"], ALLOWED_ATTR: ["target", "href"] };
12
12
  function M({
13
13
  questionType: e,
14
14
  ...t
@@ -20,99 +20,107 @@ function M({
20
20
  return /* @__PURE__ */ a(C, { ...t });
21
21
  case "text":
22
22
  case "account_number":
23
- return /* @__PURE__ */ a(f, { ...t });
23
+ return /* @__PURE__ */ a(d, { ...t });
24
24
  case "select":
25
- return /* @__PURE__ */ a(x, { ...t });
25
+ return /* @__PURE__ */ a(h, { ...t });
26
26
  case "number":
27
- return /* @__PURE__ */ a(d, { ...t });
27
+ return /* @__PURE__ */ a(m, { ...t });
28
28
  case "workers_compensation_rate":
29
- return /* @__PURE__ */ a(d, { ...t, isPercent: t.requirement?.metadata?.rateType === "percent" });
29
+ return /* @__PURE__ */ a(m, { ...t, isPercent: t.requirement?.metadata?.rateType === "percent" });
30
30
  case "percent":
31
31
  case "tax_rate":
32
32
  return /* @__PURE__ */ a(g, { ...t });
33
33
  case "currency":
34
- return /* @__PURE__ */ a(d, { ...t, isCurrency: !0 });
34
+ return /* @__PURE__ */ a(m, { ...t, isCurrency: !0 });
35
35
  default:
36
- return /* @__PURE__ */ a(f, { ...t });
36
+ return /* @__PURE__ */ a(d, { ...t });
37
37
  }
38
38
  }
39
- function x({ question: e, requirement: t, isDisabled: l = !1 }) {
40
- const { key: r, label: u, description: i } = e || t, n = e ? e.answers[0]?.value : t.value, o = e ? e.inputQuestionFormat : t.metadata;
41
- if (!o?.options) throw new Error("Select input must have options");
39
+ function h({ question: e, requirement: t, isDisabled: l = !1 }) {
40
+ const { key: r, label: s, description: o } = e || t, n = e ? e.answers[0]?.value : t.value, u = e ? e.inputQuestionFormat : t.metadata;
41
+ if (!u?.options) throw new Error("Select input must have options");
42
42
  return r ? /* @__PURE__ */ a(
43
- m,
43
+ p,
44
44
  {
45
45
  isRequired: !0,
46
46
  name: r,
47
47
  defaultValue: n,
48
- label: u,
49
- description: i,
48
+ label: s,
49
+ description: o,
50
50
  isDisabled: r.includes("fileNewHireReport") ? n !== void 0 : l,
51
- options: o.options.map((s, c) => ({
52
- value: s.value,
53
- label: s.label
51
+ options: u.options.map((i, c) => ({
52
+ value: i.value,
53
+ label: i.label
54
54
  }))
55
55
  }
56
56
  ) : null;
57
57
  }
58
- function f({ question: e, requirement: t, isDisabled: l = !1 }) {
59
- const { key: r, label: u, description: i } = e || t, n = e ? e.answers[0]?.value : t.value, o = t?.metadata?.mask ?? null, s = T(o);
60
- return r ? /* @__PURE__ */ a(
58
+ function d({
59
+ question: e,
60
+ requirement: t,
61
+ isDisabled: l = !1,
62
+ type: r = "text",
63
+ isPercent: s = !1
64
+ }) {
65
+ const { key: o, label: n, description: u } = e || t, i = e ? e.answers[0]?.value : t.value, c = t?.metadata?.mask ?? null, f = D(c);
66
+ return o ? /* @__PURE__ */ a(
61
67
  w,
62
68
  {
63
69
  isRequired: !0,
64
- name: r,
65
- label: u,
66
- defaultValue: n,
67
- description: i,
70
+ name: o,
71
+ label: n,
72
+ defaultValue: i,
73
+ description: u,
68
74
  isDisabled: l,
69
- transform: o ? s : void 0,
70
- placeholder: o || void 0
75
+ transform: c ? f : void 0,
76
+ placeholder: c || void 0,
77
+ type: r,
78
+ adornmentEnd: s ? "%" : void 0
71
79
  }
72
80
  ) : null;
73
81
  }
74
- function d({
82
+ function m({
75
83
  question: e,
76
84
  requirement: t,
77
85
  isCurrency: l,
78
86
  isPercent: r,
79
- isDisabled: u = !1
87
+ isDisabled: s = !1
80
88
  }) {
81
- const { t: i } = y("common"), { key: n, label: o, description: s } = e || t, c = e ? e.answers[0]?.value : t.value;
89
+ const { t: o } = y("common"), { key: n, label: u, description: i } = e || t, c = e ? e.answers[0]?.value : t.value;
82
90
  if (!n) return null;
83
- const p = t?.metadata?.type === "workers_compensation_rate" && t.metadata.riskClassCode !== void 0 ? `${t.metadata.riskClassCode}: ${t.metadata.riskClassDescription}` : null, v = t?.metadata?.rateType === "currency_per_hour" ? i("inputs.workersCompensationRatePerHourAdornment") : void 0;
91
+ const f = t?.metadata?.type === "workers_compensation_rate" && t.metadata.riskClassCode !== void 0 ? `${t.metadata.riskClassCode}: ${t.metadata.riskClassDescription}` : null, v = t?.metadata?.rateType === "currency_per_hour" ? o("inputs.workersCompensationRatePerHourAdornment") : void 0;
84
92
  return /* @__PURE__ */ a(
85
93
  k,
86
94
  {
87
95
  isRequired: !0,
88
96
  name: n,
89
- label: o,
90
- description: s ?? p,
97
+ label: u,
98
+ description: i ?? f,
91
99
  defaultValue: typeof c < "u" ? Number(c) : void 0,
92
100
  format: l ? "currency" : r ? "percent" : "decimal",
93
- isDisabled: u,
101
+ isDisabled: s,
94
102
  maximumFractionDigits: r ? 4 : void 0,
95
103
  adornmentEnd: v
96
104
  }
97
105
  );
98
106
  }
99
107
  function C({ question: e, requirement: t, isDisabled: l = !1 }) {
100
- const { key: r, label: u, description: i } = e || t, n = e ? e.answers[0]?.value : t.value, { Text: o } = D(), s = e ? e.inputQuestionFormat : t.metadata;
101
- if (!s?.options) throw new Error(`RadioInput must have options:${JSON.stringify(e)}`);
108
+ const { key: r, label: s, description: o } = e || t, n = e ? e.answers[0]?.value : t.value, { Text: u } = x(), i = e ? e.inputQuestionFormat : t.metadata;
109
+ if (!i?.options) throw new Error(`RadioInput must have options:${JSON.stringify(e)}`);
102
110
  return r ? /* @__PURE__ */ a(
103
111
  R,
104
112
  {
105
113
  isRequired: !0,
106
114
  name: r,
107
115
  isDisabled: r.includes("fileNewHireReport") ? n !== void 0 : l,
108
- description: i && /* @__PURE__ */ a(o, { as: "span", children: /* @__PURE__ */ a(
116
+ description: o && /* @__PURE__ */ a(u, { as: "span", children: /* @__PURE__ */ a(
109
117
  "span",
110
118
  {
111
- dangerouslySetInnerHTML: { __html: b.sanitize(i, h) }
119
+ dangerouslySetInnerHTML: { __html: b.sanitize(o, T) }
112
120
  }
113
121
  ) }),
114
- label: u,
115
- options: s.options.map((c) => ({
122
+ label: s,
123
+ options: i.options.map((c) => ({
116
124
  value: c.value,
117
125
  label: c.label
118
126
  }))
@@ -124,7 +132,7 @@ function I({
124
132
  requirement: t,
125
133
  isDisabled: l = !1
126
134
  }) {
127
- const { key: r, label: u, description: i } = e || t, n = e ? e.answers[0]?.value : t.value;
135
+ const { key: r, label: s, description: o } = e || t, n = e ? e.answers[0]?.value : t.value;
128
136
  if (typeof n != "string" && typeof n < "u")
129
137
  throw new Error("Expecting value to be string for DateInput");
130
138
  return r ? /* @__PURE__ */ a(
@@ -133,38 +141,38 @@ function I({
133
141
  isRequired: !0,
134
142
  name: r,
135
143
  defaultValue: n ? new Date(n) : null,
136
- label: u,
137
- description: i,
144
+ label: s,
145
+ description: o,
138
146
  isDisabled: l
139
147
  }
140
148
  ) : null;
141
149
  }
142
150
  function g({ requirement: e, question: t, ...l }) {
143
151
  if (e) {
144
- const { key: r, metadata: u, label: i, description: n } = e, { validation: o } = u || {};
145
- return o?.type === "one_of" ? /* @__PURE__ */ a(
146
- m,
152
+ const { key: r, metadata: s, label: o, description: n } = e, { validation: u } = s || {};
153
+ return u?.type === "one_of" ? /* @__PURE__ */ a(
154
+ p,
147
155
  {
148
156
  isRequired: !0,
149
157
  name: r || "",
150
- label: i || "",
158
+ label: o || "",
151
159
  description: n,
152
- options: o.rates?.map((s) => ({
153
- value: s,
154
- label: s
160
+ options: u.rates?.map((i) => ({
161
+ value: i,
162
+ label: i
155
163
  })) || []
156
164
  }
157
- ) : /* @__PURE__ */ a(d, { requirement: e, ...l, isPercent: !0 });
165
+ ) : /* @__PURE__ */ a(d, { requirement: e, ...l, type: "number", isPercent: !0 });
158
166
  }
159
- return /* @__PURE__ */ a(d, { question: t, ...l, isPercent: !0 });
167
+ return /* @__PURE__ */ a(d, { question: t, ...l, type: "number", isPercent: !0 });
160
168
  }
161
169
  export {
162
170
  I as DateField,
163
- d as NumberInput,
171
+ m as NumberInput,
164
172
  M as QuestionInput,
165
173
  C as RadioInput,
166
- x as SelectInput,
174
+ h as SelectInput,
167
175
  g as TaxRateInput,
168
- f as TextInput
176
+ d as TextInput
169
177
  };
170
178
  //# sourceMappingURL=TaxInputs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TaxInputs.js","sources":["../../../../src/components/Common/TaxInputs/TaxInputs.tsx"],"sourcesContent":["import DOMPurify from 'dompurify'\nimport type { EmployeeStateTaxQuestion } from '@gusto/embedded-api/models/components/employeestatetaxquestion'\nimport { type TaxRequirement } from '@gusto/embedded-api/models/components/taxrequirement'\nimport { useTranslation } from 'react-i18next'\nimport { SelectField } from '../Fields/SelectField/SelectField'\nimport { TextInputField } from '../Fields/TextInputField/TextInputField'\nimport { NumberInputField } from '../Fields/NumberInputField/NumberInputField'\nimport { RadioGroupField } from '../Fields/RadioGroupField/RadioGroupField'\nimport { DatePickerField } from '../Fields/DatePickerField/DatePickerField'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useMaskedTransform } from '@/helpers/mask'\n\nconst dompurifyConfig = { ALLOWED_TAGS: ['a', 'b', 'strong'], ALLOWED_ATTR: ['target', 'href'] }\n\ninterface EmpQ {\n question: NonNullable<EmployeeStateTaxQuestion>\n requirement?: never\n isDisabled?: boolean\n}\ninterface CompR {\n requirement: TaxRequirement\n question?: never\n isDisabled?: boolean\n}\n\ntype NumberFieldProps = { isCurrency?: boolean; isPercent?: boolean }\n\nexport function QuestionInput({\n questionType,\n ...props\n}: (EmpQ | CompR) & {\n questionType: string\n}) {\n switch (questionType.toLowerCase()) {\n case 'date':\n return <DateField {...props} />\n case 'radio':\n return <RadioInput {...props} />\n case 'text':\n case 'account_number': //TODO: temporary - need special handling for account numbers\n return <TextInput {...props} />\n case 'select':\n return <SelectInput {...props} />\n case 'number':\n return <NumberInput {...props} />\n case 'workers_compensation_rate':\n return (\n <NumberInput {...props} isPercent={props.requirement?.metadata?.rateType === 'percent'} />\n )\n case 'percent':\n case 'tax_rate':\n return <TaxRateInput {...props} />\n case 'currency':\n return <NumberInput {...props} isCurrency />\n default:\n return <TextInput {...props} />\n // return null\n }\n}\n\nexport function SelectInput({ question, requirement, isDisabled = false }: EmpQ | CompR) {\n const { key, label, description } = question ? question : requirement\n const value = question ? question.answers[0]?.value : requirement.value\n\n const meta = question ? question.inputQuestionFormat : requirement.metadata\n if (!meta?.options) throw new Error('Select input must have options')\n\n if (!key) return null\n\n return (\n <SelectField\n isRequired\n name={key}\n defaultValue={value}\n label={label as string}\n description={description}\n isDisabled={\n key.includes('fileNewHireReport') ? (value === undefined ? false : true) : isDisabled\n }\n options={meta.options.map((item, _) => ({\n value: item.value,\n label: item.label,\n }))}\n />\n )\n}\n\nexport function TextInput({ question, requirement, isDisabled = false }: EmpQ | CompR) {\n const { key, label, description } = question ? question : requirement\n const value = question ? question.answers[0]?.value : requirement.value\n const mask = requirement?.metadata?.mask ?? null\n const transform = useMaskedTransform(mask)\n\n if (!key) return null\n return (\n <TextInputField\n isRequired\n name={key}\n label={label}\n // @ts-expect-error HACK value is insufficiently narrowed here\n defaultValue={value}\n description={description}\n isDisabled={isDisabled}\n transform={mask ? transform : undefined}\n placeholder={mask ? mask : undefined}\n />\n )\n}\n\nexport function NumberInput({\n question,\n requirement,\n isCurrency,\n isPercent,\n isDisabled = false,\n}: (EmpQ | CompR) & NumberFieldProps) {\n const { t } = useTranslation('common')\n const { key, label, description } = question ? question : requirement\n const value = question ? question.answers[0]?.value : requirement.value\n\n if (!key) return null\n\n const wcDescription =\n requirement?.metadata?.type === 'workers_compensation_rate' &&\n requirement.metadata.riskClassCode !== undefined\n ? `${requirement.metadata.riskClassCode}: ${requirement.metadata.riskClassDescription}`\n : null\n const adornmentEnd =\n requirement?.metadata?.rateType === 'currency_per_hour'\n ? t('inputs.workersCompensationRatePerHourAdornment')\n : undefined\n\n return (\n <NumberInputField\n isRequired\n name={key}\n label={label}\n description={description ?? wcDescription}\n defaultValue={typeof value !== 'undefined' ? Number(value) : undefined}\n format={isCurrency ? 'currency' : isPercent ? 'percent' : 'decimal'}\n isDisabled={isDisabled}\n maximumFractionDigits={isPercent ? 4 : undefined}\n adornmentEnd={adornmentEnd}\n />\n )\n}\n\nexport function RadioInput({ question, requirement, isDisabled = false }: EmpQ | CompR) {\n const { key, label, description } = question ? question : requirement\n const value = question ? question.answers[0]?.value : requirement.value\n const { Text } = useComponentContext()\n\n const meta = question ? question.inputQuestionFormat : requirement.metadata\n if (!meta?.options) throw new Error(`RadioInput must have options:${JSON.stringify(question)}`)\n\n if (!key) return null\n\n return (\n <RadioGroupField\n isRequired\n name={key}\n //File new hire report setting cannot be changed after it has been configured.\n isDisabled={\n key.includes('fileNewHireReport') ? (value === undefined ? false : true) : isDisabled\n }\n description={\n description && (\n <Text as=\"span\">\n <span\n dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(description, dompurifyConfig) }}\n />\n </Text>\n )\n }\n label={label as string}\n options={meta.options.map(item => ({\n value: item.value,\n label: item.label,\n }))}\n />\n )\n}\n//TODO: This type is untested as of yet\nexport function DateField({\n question,\n requirement,\n isDisabled = false,\n}: (EmpQ | CompR) & NumberFieldProps) {\n const { key, label, description } = question ? question : requirement\n const value = question ? question.answers[0]?.value : requirement.value\n if (typeof value !== 'string' && typeof value !== 'undefined')\n throw new Error('Expecting value to be string for DateInput')\n\n if (!key) return null\n\n return (\n <DatePickerField\n isRequired\n name={key}\n defaultValue={value ? new Date(value) : null}\n label={label as string}\n description={description}\n isDisabled={isDisabled}\n />\n )\n}\n\nexport function TaxRateInput({ requirement, question, ...props }: EmpQ | CompR) {\n if (requirement) {\n // Covers case for tax rate where the rate is a one_of option and must be submitted as a string\n // of enumerated rate values provided\n const { key, metadata, label, description } = requirement\n const { validation } = metadata || {}\n return validation?.type === 'one_of' ? (\n <SelectField\n isRequired\n name={key || ''}\n label={label || ''}\n description={description}\n options={\n validation.rates?.map(rate => ({\n value: rate,\n label: rate,\n })) || []\n }\n />\n ) : (\n <NumberInput requirement={requirement} {...props} isPercent />\n )\n }\n\n return <NumberInput question={question} {...props} isPercent />\n}\n"],"names":["dompurifyConfig","QuestionInput","questionType","props","jsx","DateField","RadioInput","TextInput","SelectInput","NumberInput","TaxRateInput","question","requirement","isDisabled","key","label","description","value","meta","SelectField","item","_","mask","transform","useMaskedTransform","TextInputField","isCurrency","isPercent","t","useTranslation","wcDescription","adornmentEnd","NumberInputField","Text","useCompon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,CAASC,OAAA;AAAA,UAC7B,OAAOA;AAAA,UACP,OAAOA;AAAA,QACT,EAAE,KAAK,CAAA;AAAA,MAAC;AAAA,IAAA,IAIX,gBAAApC,EAAAK,GAAA,EAAY,aAAAG,GAA2B,GAAGT,GAAO,WAAS,IAAC;AAAA,EAAA;AAIhE,2BAAQM,GAAY,EAAA,UAAAE,GAAqB,GAAGR,GAAO,WAAS,IAAC;AAC/D;"}
1
+ {"version":3,"file":"TaxInputs.js","sources":["../../../../src/components/Common/TaxInputs/TaxInputs.tsx"],"sourcesContent":["import DOMPurify from 'dompurify'\nimport type { EmployeeStateTaxQuestion } from '@gusto/embedded-api/models/components/employeestatetaxquestion'\nimport { type TaxRequirement } from '@gusto/embedded-api/models/components/taxrequirement'\nimport { useTranslation } from 'react-i18next'\nimport { SelectField } from '../Fields/SelectField/SelectField'\nimport { TextInputField } from '../Fields/TextInputField/TextInputField'\nimport { NumberInputField } from '../Fields/NumberInputField/NumberInputField'\nimport { RadioGroupField } from '../Fields/RadioGroupField/RadioGroupField'\nimport { DatePickerField } from '../Fields/DatePickerField/DatePickerField'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useMaskedTransform } from '@/helpers/mask'\n\nconst dompurifyConfig = { ALLOWED_TAGS: ['a', 'b', 'strong'], ALLOWED_ATTR: ['target', 'href'] }\n\ninterface EmpQ {\n question: NonNullable<EmployeeStateTaxQuestion>\n requirement?: never\n isDisabled?: boolean\n}\ninterface CompR {\n requirement: TaxRequirement\n question?: never\n isDisabled?: boolean\n}\n\ntype NumberFieldProps = { isCurrency?: boolean; isPercent?: boolean }\n\ntype TextInputProps = { type?: string; isPercent?: boolean }\n\nexport function QuestionInput({\n questionType,\n ...props\n}: (EmpQ | CompR) & {\n questionType: string\n}) {\n switch (questionType.toLowerCase()) {\n case 'date':\n return <DateField {...props} />\n case 'radio':\n return <RadioInput {...props} />\n case 'text':\n case 'account_number': //TODO: temporary - need special handling for account numbers\n return <TextInput {...props} />\n case 'select':\n return <SelectInput {...props} />\n case 'number':\n return <NumberInput {...props} />\n case 'workers_compensation_rate':\n return (\n <NumberInput {...props} isPercent={props.requirement?.metadata?.rateType === 'percent'} />\n )\n case 'percent':\n case 'tax_rate':\n return <TaxRateInput {...props} />\n case 'currency':\n return <NumberInput {...props} isCurrency />\n default:\n return <TextInput {...props} />\n // return null\n }\n}\n\nexport function SelectInput({ question, requirement, isDisabled = false }: EmpQ | CompR) {\n const { key, label, description } = question ? question : requirement\n const value = question ? question.answers[0]?.value : requirement.value\n\n const meta = question ? question.inputQuestionFormat : requirement.metadata\n if (!meta?.options) throw new Error('Select input must have options')\n\n if (!key) return null\n\n return (\n <SelectField\n isRequired\n name={key}\n defaultValue={value}\n label={label as string}\n description={description}\n isDisabled={\n key.includes('fileNewHireReport') ? (value === undefined ? false : true) : isDisabled\n }\n options={meta.options.map((item, _) => ({\n value: item.value,\n label: item.label,\n }))}\n />\n )\n}\n\nexport function TextInput({\n question,\n requirement,\n isDisabled = false,\n type = 'text',\n isPercent = false,\n}: (EmpQ | CompR) & TextInputProps) {\n const { key, label, description } = question ? question : requirement\n const value = question ? question.answers[0]?.value : requirement.value\n const mask = requirement?.metadata?.mask ?? null\n const transform = useMaskedTransform(mask)\n\n if (!key) return null\n return (\n <TextInputField\n isRequired\n name={key}\n label={label}\n // @ts-expect-error HACK value is insufficiently narrowed here\n defaultValue={value}\n description={description}\n isDisabled={isDisabled}\n transform={mask ? transform : undefined}\n placeholder={mask ? mask : undefined}\n type={type}\n adornmentEnd={isPercent ? '%' : undefined}\n />\n )\n}\n\nexport function NumberInput({\n question,\n requirement,\n isCurrency,\n isPercent,\n isDisabled = false,\n}: (EmpQ | CompR) & NumberFieldProps) {\n const { t } = useTranslation('common')\n const { key, label, description } = question ? question : requirement\n const value = question ? question.answers[0]?.value : requirement.value\n\n if (!key) return null\n\n const wcDescription =\n requirement?.metadata?.type === 'workers_compensation_rate' &&\n requirement.metadata.riskClassCode !== undefined\n ? `${requirement.metadata.riskClassCode}: ${requirement.metadata.riskClassDescription}`\n : null\n const adornmentEnd =\n requirement?.metadata?.rateType === 'currency_per_hour'\n ? t('inputs.workersCompensationRatePerHourAdornment')\n : undefined\n\n return (\n <NumberInputField\n isRequired\n name={key}\n label={label}\n description={description ?? wcDescription}\n defaultValue={typeof value !== 'undefined' ? Number(value) : undefined}\n format={isCurrency ? 'currency' : isPercent ? 'percent' : 'decimal'}\n isDisabled={isDisabled}\n maximumFractionDigits={isPercent ? 4 : undefined}\n adornmentEnd={adornmentEnd}\n />\n )\n}\n\nexport function RadioInput({ question, requirement, isDisabled = false }: EmpQ | CompR) {\n const { key, label, description } = question ? question : requirement\n const value = question ? question.answers[0]?.value : requirement.value\n const { Text } = useComponentContext()\n\n const meta = question ? question.inputQuestionFormat : requirement.metadata\n if (!meta?.options) throw new Error(`RadioInput must have options:${JSON.stringify(question)}`)\n\n if (!key) return null\n\n return (\n <RadioGroupField\n isRequired\n name={key}\n //File new hire report setting cannot be changed after it has been configured.\n isDisabled={\n key.includes('fileNewHireReport') ? (value === undefined ? false : true) : isDisabled\n }\n description={\n description && (\n <Text as=\"span\">\n <span\n dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(description, dompurifyConfig) }}\n />\n </Text>\n )\n }\n label={label as string}\n options={meta.options.map(item => ({\n value: item.value,\n label: item.label,\n }))}\n />\n )\n}\n//TODO: This type is untested as of yet\nexport function DateField({\n question,\n requirement,\n isDisabled = false,\n}: (EmpQ | CompR) & NumberFieldProps) {\n const { key, label, description } = question ? question : requirement\n const value = question ? question.answers[0]?.value : requirement.value\n if (typeof value !== 'string' && typeof value !== 'undefined')\n throw new Error('Expecting value to be string for DateInput')\n\n if (!key) return null\n\n return (\n <DatePickerField\n isRequired\n name={key}\n defaultValue={value ? new Date(value) : null}\n label={label as string}\n description={description}\n isDisabled={isDisabled}\n />\n )\n}\n\nexport function TaxRateInput({ requirement, question, ...props }: EmpQ | CompR) {\n if (requirement) {\n // Covers case for tax rate where the rate is a one_of option and must be submitted as a string\n // of enumerated rate values provided\n const { key, metadata, label, description } = requirement\n const { validation } = metadata || {}\n return validation?.type === 'one_of' ? (\n <SelectField\n isRequired\n name={key || ''}\n label={label || ''}\n description={description}\n options={\n validation.rates?.map(rate => ({\n value: rate,\n label: rate,\n })) || []\n }\n />\n ) : (\n <TextInput requirement={requirement} {...props} type=\"number\" isPercent />\n )\n }\n\n return <TextInput question={question} {...props} type=\"number\" isPercent />\n}\n"],"names":["dompurifyConfig","QuestionInput","questionType","props","jsx","DateField","RadioInput","TextInput","SelectInput","NumberInput","TaxRateInput","question","requirement","isDisabled","key","label","description","value","meta","SelectField","item","_","type","isPercent","mask","transform","useMaskedTransform","TextInputField","isCurrency","t","useTranslation","wcDescription","adornmentEnd","NumberInputField","Text","useComponentContext","RadioGroupField","DOMPurify","DatePickerField","metadata","validation","rate"],"mappings":";;;;;;;;;;AAYA,MAAMA,IAAkB,EAAE,cAAc,CAAC,KAAK,KAAK,QAAQ,GAAG,cAAc,CAAC,UAAU,MAAM,EAAE;AAiBxF,SAASC,EAAc;AAAA,EAC5B,cAAAC;AAAA,EACA,GAAGC;AACL,GAEG;AACO,UAAAD,EAAa,YAAe,GAAA;AAAA,IAClC,KAAK;AACI,aAAA,gBAAAE,EAACC,GAAW,EAAA,GAAGF,EAAO,CAAA;AAAA,IAC/B,KAAK;AACI,aAAA,gBAAAC,EAACE,GAAY,EAAA,GAAGH,EAAO,CAAA;AAAA,IAChC,KAAK;AAAA,IACL,KAAK;AACI,aAAA,gBAAAC,EAACG,GAAW,EAAA,GAAGJ,EAAO,CAAA;AAAA,IAC/B,KAAK;AACI,aAAA,gBAAAC,EAACI,GAAa,EAAA,GAAGL,EAAO,CAAA;AAAA,IACjC,KAAK;AACI,aAAA,gBAAAC,EAACK,GAAa,EAAA,GAAGN,EAAO,CAAA;AAAA,IACjC,KAAK;AAED,aAAA,gBAAAC,EAACK,KAAa,GAAGN,GAAO,WAAWA,EAAM,aAAa,UAAU,a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