@gusto/embedded-react-sdk 0.9.0 → 0.10.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.
Files changed (96) hide show
  1. package/CHANGELOG.md +86 -2
  2. package/dist/components/Base/Base.d.ts +1 -1
  3. package/dist/components/Base/Base.js +39 -40
  4. package/dist/components/Base/Base.js.map +1 -1
  5. package/dist/components/Common/OnboardingStatusBadge/index.d.ts +21 -0
  6. package/dist/components/Common/OnboardingStatusBadge/index.js +17 -0
  7. package/dist/components/Common/OnboardingStatusBadge/index.js.map +1 -0
  8. package/dist/components/Common/TaxInputs/TaxInputs.js +42 -36
  9. package/dist/components/Common/TaxInputs/TaxInputs.js.map +1 -1
  10. package/dist/components/Contractor/Address/Form.js +4 -12
  11. package/dist/components/Contractor/Address/Form.js.map +1 -1
  12. package/dist/components/Contractor/List/index.d.ts +25 -0
  13. package/dist/components/Contractor/List/index.js +84 -0
  14. package/dist/components/Contractor/List/index.js.map +1 -0
  15. package/dist/components/Contractor/List/useContractorList.d.ts +20 -0
  16. package/dist/components/Contractor/List/useContractorList.js +31 -0
  17. package/dist/components/Contractor/List/useContractorList.js.map +1 -0
  18. package/dist/components/Contractor/NewHireReport/NewHireReport.d.ts +21 -0
  19. package/dist/components/Contractor/NewHireReport/NewHireReport.js +111 -0
  20. package/dist/components/Contractor/NewHireReport/NewHireReport.js.map +1 -0
  21. package/dist/components/Contractor/NewHireReport/types.d.ts +4 -0
  22. package/dist/components/Contractor/PaymentMethod/BankAccountForm.d.ts +2 -0
  23. package/dist/components/Contractor/PaymentMethod/BankAccountForm.js +52 -0
  24. package/dist/components/Contractor/PaymentMethod/BankAccountForm.js.map +1 -0
  25. package/dist/components/Contractor/PaymentMethod/PaymentMethod.d.ts +31 -0
  26. package/dist/components/Contractor/PaymentMethod/PaymentMethod.js +116 -0
  27. package/dist/components/Contractor/PaymentMethod/PaymentMethod.js.map +1 -0
  28. package/dist/components/Contractor/PaymentMethod/PaymentTypeForm.d.ts +11 -0
  29. package/dist/components/Contractor/PaymentMethod/PaymentTypeForm.js +35 -0
  30. package/dist/components/Contractor/PaymentMethod/PaymentTypeForm.js.map +1 -0
  31. package/dist/components/Contractor/PaymentMethod/types.d.ts +8 -0
  32. package/dist/components/Contractor/index.d.ts +3 -0
  33. package/dist/components/Contractor/index.js +8 -2
  34. package/dist/components/Contractor/index.js.map +1 -1
  35. package/dist/components/Employee/Compensation/Edit.js +59 -56
  36. package/dist/components/Employee/Compensation/Edit.js.map +1 -1
  37. package/dist/components/Employee/Compensation/useCompensation.d.ts +2 -0
  38. package/dist/components/Employee/Compensation/useCompensation.js +16 -14
  39. package/dist/components/Employee/Compensation/useCompensation.js.map +1 -1
  40. package/dist/components/Employee/Deductions/DeductionForm.js +11 -3
  41. package/dist/components/Employee/Deductions/DeductionForm.js.map +1 -1
  42. package/dist/components/Employee/Deductions/Deductions.js +25 -25
  43. package/dist/components/Employee/Deductions/Deductions.js.map +1 -1
  44. package/dist/components/Employee/EmployeeList/List.js +56 -51
  45. package/dist/components/Employee/EmployeeList/List.js.map +1 -1
  46. package/dist/components/Employee/OnboardingSummary/OnboardingSummary.js +48 -43
  47. package/dist/components/Employee/OnboardingSummary/OnboardingSummary.js.map +1 -1
  48. package/dist/components/Employee/PaymentMethod/BankAccountEdit.js +1 -1
  49. package/dist/components/Employee/PaymentMethod/BankAccountEdit.js.map +1 -1
  50. package/dist/components/Employee/PaymentMethod/PaymentMethod.js +3 -4
  51. package/dist/components/Employee/PaymentMethod/PaymentMethod.js.map +1 -1
  52. package/dist/components/Employee/PaymentMethod/PaymentTypeForm.js +1 -1
  53. package/dist/components/Employee/PaymentMethod/PaymentTypeForm.js.map +1 -1
  54. package/dist/components/Employee/PaymentMethod/Split.js +88 -76
  55. package/dist/components/Employee/PaymentMethod/Split.js.map +1 -1
  56. package/dist/components/Employee/PaymentMethod/usePaymentMethod.d.ts +2 -2
  57. package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +29 -25
  58. package/dist/components/Employee/PaymentMethod/usePaymentMethod.js.map +1 -1
  59. package/dist/components/Employee/Profile/AdminPersonalDetails.d.ts +49 -20
  60. package/dist/components/Employee/Profile/AdminPersonalDetails.js +27 -25
  61. package/dist/components/Employee/Profile/AdminPersonalDetails.js.map +1 -1
  62. package/dist/components/Employee/Profile/PersonalDetailsInputs.js +1 -1
  63. package/dist/components/Employee/Profile/Profile.js +135 -129
  64. package/dist/components/Employee/Profile/Profile.js.map +1 -1
  65. package/dist/components/Employee/Taxes/StateForm.d.ts +1 -1
  66. package/dist/components/Employee/Taxes/StateForm.js +27 -25
  67. package/dist/components/Employee/Taxes/StateForm.js.map +1 -1
  68. package/dist/components/Employee/Taxes/Taxes.d.ts +1 -1
  69. package/dist/components/Employee/Taxes/Taxes.js +77 -73
  70. package/dist/components/Employee/Taxes/Taxes.js.map +1 -1
  71. package/dist/components/index.d.ts +1 -1
  72. package/dist/i18n/I18n.js +17 -17
  73. package/dist/i18n/I18n.js.map +1 -1
  74. package/dist/i18n/en/Contractor.ContractorList.json.js +25 -0
  75. package/dist/i18n/en/Contractor.ContractorList.json.js.map +1 -0
  76. package/dist/i18n/en/Contractor.NewHireReport.json.js +24 -0
  77. package/dist/i18n/en/Contractor.NewHireReport.json.js.map +1 -0
  78. package/dist/i18n/en/Contractor.PaymentMethod.json.js +35 -0
  79. package/dist/i18n/en/Contractor.PaymentMethod.json.js.map +1 -0
  80. package/dist/i18n/en/Employee.Compensation.json.js +22 -20
  81. package/dist/i18n/en/Employee.Compensation.json.js.map +1 -1
  82. package/dist/i18n/en/Employee.PaymentMethod.json.js +18 -17
  83. package/dist/i18n/en/Employee.PaymentMethod.json.js.map +1 -1
  84. package/dist/i18n/en/common.json.d.ts +21 -9
  85. package/dist/i18n/en/common.json.js +35 -23
  86. package/dist/i18n/en/common.json.js.map +1 -1
  87. package/dist/index.js +4 -4
  88. package/dist/shared/constants.d.ts +18 -0
  89. package/dist/shared/constants.js +28 -15
  90. package/dist/shared/constants.js.map +1 -1
  91. package/dist/style.css +1 -1
  92. package/dist/types/i18next.d.ts +64 -1
  93. package/package.json +4 -3
  94. package/dist/components/Employee/PaymentMethod/Constants.d.ts +0 -8
  95. package/dist/components/Employee/PaymentMethod/Constants.js +0 -6
  96. package/dist/components/Employee/PaymentMethod/Constants.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.1
4
+
5
+ - Fixed work address being stale when editing an existing employee in employee onboarding
6
+
7
+ ## 0.10.0
8
+
9
+ ### Features & Enhancements
10
+
11
+ - Added contractor payment method with custom validation, including handling for masked account numbers
12
+ - Added `annualMaximum` field to DeductionForm with comprehensive tests
13
+ - Added PaymentMethod percentage validation tests
14
+
15
+ ### Fixes
16
+
17
+ - Correctly set version for employee taxes
18
+ - Set correct mode on deductions cancel
19
+ - Skip state taxes for states that only have questions for admins
20
+ - Allow special characters in user name
21
+ - Fix split validation
22
+ - Fix withholding allowance of 0 causing error on state tax submission
23
+ - Restore proper SSN validation
24
+ - Update rate to not be labeled optional when it is required
25
+
26
+ ### Chores & Maintenance
27
+
28
+ - Upgrade embedded API version to 0.6.4
29
+ - Update changelog with breaking changes and update docs
30
+
3
31
  ## 0.9.0
4
32
 
5
33
  - Added new Contractor.Address form component for managing contractor address information
@@ -9,6 +37,10 @@
9
37
  - Fixed state tax boolean validation issues
10
38
  - Updated Gusto embedded-api version to the latest
11
39
 
40
+ ### Breaking changes
41
+
42
+ Be sure to note the breaking change listed below for version 0.8.2 around component renaming and removal of the top level Flow component.
43
+
12
44
  ## 0.8.2
13
45
 
14
46
  - Refactored employee flow components structure and improved organization within Employee namespace
@@ -17,6 +49,56 @@
17
49
  - Fixed commission Zod schema validation issues
18
50
  - Fixed issue with headers not being passed properly through our API client
19
51
 
52
+ ### Breaking changes
53
+
54
+ > Note: We are pre alpha and are regularly iterating on the SDK as we learn more about our consumers and their needs which sometimes involves breaking changes. [Read more about our current versioning strategy here](./docs/04/01/versioning.md).
55
+
56
+ #### Rename components to remove the "Flow" naming suffix
57
+
58
+ The following components have been updated to remove the "Flow" naming suffix.
59
+
60
+ | Old name | Updated name |
61
+ | ----------------------------- | ------------------------- |
62
+ | `Employee.DocumentSignerFlow` | `Employee.DocumentSigner` |
63
+ | `Company.LocationsFlow` | `Company.Locations` |
64
+ | `Company.BankAccountFlow` | `Company.BankAccount` |
65
+ | `Company.StateTaxesFlow` | `Company.StateTaxes` |
66
+ | `Company.DocumentSignerFlow` | `Company.DocumentSigner` |
67
+
68
+ #### Removed top level Flow component and renamed flow subcomponents
69
+
70
+ We have removed the top level `Flow` component and have migrated the flow subcomponents to `Employee` and `Company` respectively.
71
+
72
+ | Old name | Updated name |
73
+ | --------------------------------- | ----------------------------- |
74
+ | `Flow.EmployeeOnboardingFlow` | `Employee.OnboardingFlow` |
75
+ | `Flow.EmployeeSelfOnboardingFlow` | `Employee.SelfOnboardingFlow` |
76
+
77
+ Some examples of before/after:
78
+
79
+ _Before_
80
+
81
+ ```tsx
82
+ import { Flow } from '@gusto/embedded-react-sdk'
83
+
84
+ ...
85
+
86
+ <Flow.EmployeeOnboardingFlow ... />
87
+ <Flow.EmployeeSelfOnboardingFlow ... />
88
+
89
+ ```
90
+
91
+ _After_
92
+
93
+ ```tsx
94
+ import { Employee } from '@gusto/embedded-react-sdk'
95
+
96
+ ...
97
+
98
+ <Employee.OnboardingFlow ... />
99
+ <Employee.SelfOnboardingFlow ... />
100
+ ```
101
+
20
102
  ## 0.8.1
21
103
 
22
104
  - Replaced Valibot with Zod for bundle size reduction. Also included zod as a dependency
@@ -125,7 +207,9 @@ You would do the following instead::
125
207
  >
126
208
  ```
127
209
 
128
- #### DocumentSigner has been renamed to DocumentSigner
210
+ #### DocumentSigner has been renamed to DocumentSignerFlow
211
+
212
+ > This was actually reverted in 0.8.2. If you have DocumentSigner as the component name, you can continue to use that if you are on 0.8.2 or later. Between 0.7.0 up until 0.8.2 the naming is DocumentSignerFlow
129
213
 
130
214
  Where you would previously do
131
215
 
@@ -136,7 +220,7 @@ Where you would previously do
136
220
  You should update the naming as follows:
137
221
 
138
222
  ```tsx
139
- <Employee.DocumentSigner employeeId="some-id" onEvent={() => {}} />
223
+ <Employee.DocumentSignerFlow employeeId="some-id" onEvent={() => {}} />
140
224
  ```
141
225
 
142
226
  ## 0.6.0
@@ -14,4 +14,4 @@ export interface BaseComponentInterface<TResourceKey extends keyof Resources = k
14
14
  LoaderComponent?: () => JSX.Element;
15
15
  onEvent: OnEventType<EventType, unknown>;
16
16
  }
17
- export declare const BaseComponent: <TResourceKey extends keyof Resources = keyof Resources>({ children, FallbackComponent, LoaderComponent, onEvent, dictionary, }: BaseComponentInterface<TResourceKey>) => import("react/jsx-runtime").JSX.Element;
17
+ export declare const BaseComponent: <TResourceKey extends keyof Resources = keyof Resources>({ children, FallbackComponent, LoaderComponent, onEvent, }: BaseComponentInterface<TResourceKey>) => import("react/jsx-runtime").JSX.Element;
@@ -1,72 +1,71 @@
1
- import { jsx as a, jsxs as h } from "react/jsx-runtime";
2
- import { useState as p, useCallback as x, Suspense as v } from "react";
3
- import { ErrorBoundary as A } from "react-error-boundary";
4
- import { useTranslation as S } from "react-i18next";
5
- import { APIError as _ } from "@gusto/embedded-api/models/errors/apierror";
6
- import { SDKValidationError as j } from "@gusto/embedded-api/models/errors/sdkvalidationerror";
7
- import { UnprocessableEntityErrorObject as u } from "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
8
- import { FadeIn as B } from "../Common/FadeIn/FadeIn.js";
9
- import { BaseContext as I } from "./useBase.js";
10
- import { componentEvents as K } from "../../shared/constants.js";
11
- import { useAsyncError as P } from "../Common/hooks/useAsyncError.js";
12
- import { Loading as R } from "../Common/Loading/Loading.js";
13
- import { InternalError as w } from "../Common/InternalError/InternalError.js";
14
- import { snakeCaseToCamelCase as M } from "../../helpers/formattedStrings.js";
15
- import { useComponentContext as O } from "../../contexts/ComponentAdapter/useComponentContext.js";
16
- const T = (t) => t.map((e) => e.message ? /* @__PURE__ */ a("li", { children: e.message }, e.key) : null), y = (t, e) => {
17
- const s = e ? e + "." : "";
1
+ import { jsx as a, jsxs as b } from "react/jsx-runtime";
2
+ import { useState as u, useCallback as h, Suspense as x } from "react";
3
+ import { ErrorBoundary as v } from "react-error-boundary";
4
+ import { useTranslation as A } from "react-i18next";
5
+ import { APIError as S } from "@gusto/embedded-api/models/errors/apierror";
6
+ import { SDKValidationError as _ } from "@gusto/embedded-api/models/errors/sdkvalidationerror";
7
+ import { UnprocessableEntityErrorObject as d } from "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
8
+ import { FadeIn as j } from "../Common/FadeIn/FadeIn.js";
9
+ import { BaseContext as B } from "./useBase.js";
10
+ import { componentEvents as I } from "../../shared/constants.js";
11
+ import { useAsyncError as K } from "../Common/hooks/useAsyncError.js";
12
+ import { Loading as P } from "../Common/Loading/Loading.js";
13
+ import { InternalError as R } from "../Common/InternalError/InternalError.js";
14
+ import { snakeCaseToCamelCase as w } from "../../helpers/formattedStrings.js";
15
+ import { useComponentContext as M } from "../../contexts/ComponentAdapter/useComponentContext.js";
16
+ const O = (t) => t.map((e) => e.message ? /* @__PURE__ */ a("li", { children: e.message }, e.key) : null), y = (t, e) => {
17
+ const n = e ? e + "." : "";
18
18
  if (t.category === "invalid_attribute_value" || t.category === "invalid_operation")
19
19
  return [
20
20
  {
21
- key: M(s + t.errorKey),
21
+ key: w(n + t.errorKey),
22
22
  message: t.message ?? ""
23
23
  }
24
24
  ];
25
25
  if (t.category === "nested_errors" && t.errors !== void 0) {
26
26
  let o = "";
27
- return t.metadata?.key && typeof t.metadata.key == "string" ? o = t.metadata.key : t.metadata?.state && typeof t.metadata.state == "string" ? o = t.metadata.state : t.errorKey && (o = t.errorKey), t.errors.flatMap((f) => y(f, s + o));
27
+ return t.metadata?.key && typeof t.metadata.key == "string" ? o = t.metadata.key : t.metadata?.state && typeof t.metadata.state == "string" ? o = t.metadata.state : t.errorKey && (o = t.errorKey), t.errors.flatMap((l) => y(l, n + o));
28
28
  }
29
29
  return [];
30
- }, Z = ({
30
+ }, Y = ({
31
31
  children: t,
32
- FallbackComponent: e = w,
33
- LoaderComponent: s = R,
34
- onEvent: o,
35
- dictionary: f
32
+ FallbackComponent: e = R,
33
+ LoaderComponent: n = P,
34
+ onEvent: o
36
35
  }) => {
37
- const [E, i] = p(null), [m, d] = p(null), l = P(), { t: g } = S(), k = O(), C = (r) => {
38
- i(r), r instanceof u && Array.isArray(r.errors) && d(r.errors.flatMap((c) => y(c)));
39
- }, b = x(
36
+ const [l, i] = u(null), [m, p] = u(null), f = K(), { t: E } = A(), g = M(), k = (r) => {
37
+ i(r), r instanceof d && Array.isArray(r.errors) && p(r.errors.flatMap((c) => y(c)));
38
+ }, C = h(
40
39
  async (r, c) => {
41
- i(null), d(null);
40
+ i(null), p(null);
42
41
  try {
43
42
  await c(r);
44
- } catch (n) {
45
- n instanceof _ || n instanceof j || n instanceof u ? C(n) : l(n);
43
+ } catch (s) {
44
+ s instanceof S || s instanceof _ || s instanceof d ? k(s) : f(s);
46
45
  }
47
46
  },
48
- [i, l]
47
+ [i, f]
49
48
  );
50
49
  return /* @__PURE__ */ a(
51
- I.Provider,
50
+ B.Provider,
52
51
  {
53
52
  value: {
54
53
  fieldErrors: m,
55
54
  setError: i,
56
55
  onEvent: o,
57
- throwError: l,
58
- baseSubmitHandler: b
56
+ throwError: f,
57
+ baseSubmitHandler: C
59
58
  },
60
- children: /* @__PURE__ */ h(
61
- A,
59
+ children: /* @__PURE__ */ b(
60
+ v,
62
61
  {
63
62
  FallbackComponent: e,
64
63
  onError: (r) => {
65
- o(K.ERROR, r);
64
+ o(I.ERROR, r);
66
65
  },
67
66
  children: [
68
- (E || m) && /* @__PURE__ */ a(k.Alert, { label: g("status.errorEncountered"), status: "error", children: m && /* @__PURE__ */ a("ul", { children: T(m) }) }),
69
- /* @__PURE__ */ a(v, { fallback: /* @__PURE__ */ a(s, {}), children: /* @__PURE__ */ a(B, { children: t }) })
67
+ (l || m) && /* @__PURE__ */ a(g.Alert, { label: E("status.errorEncountered"), status: "error", children: m && /* @__PURE__ */ a("ul", { children: O(m) }) }),
68
+ /* @__PURE__ */ a(x, { fallback: /* @__PURE__ */ a(n, {}), children: /* @__PURE__ */ a(j, { children: t }) })
70
69
  ]
71
70
  }
72
71
  )
@@ -74,6 +73,6 @@ const T = (t) => t.map((e) => e.message ? /* @__PURE__ */ a("li", { children: e.
74
73
  );
75
74
  };
76
75
  export {
77
- Z as BaseComponent
76
+ Y as BaseComponent
78
77
  };
79
78
  //# 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 { FadeIn } from '../Common/FadeIn/FadeIn'\nimport { BaseContext, type FieldError, type KnownErrors, type OnEventType } from './useBase'\nimport { componentEvents, type EventType } from '@/shared/constants'\nimport { InternalError, Loading, useAsyncError } from '@/components/Common'\nimport { snakeCaseToCamelCase } from '@/helpers/formattedStrings'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport type { ResourceDictionary, Resources } from '@/types/Helpers'\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?: () => JSX.Element\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 = Loading,\n onEvent,\n dictionary,\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 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,\n onEvent,\n throwError,\n baseSubmitHandler,\n }}\n >\n <ErrorBoundary\n FallbackComponent={FallbackComponent}\n onError={err => {\n onEvent(componentEvents.ERROR, err)\n }}\n >\n {(error || fieldErrors) && (\n <Components.Alert label={t('status.errorEncountered')} status=\"error\">\n {fieldErrors && <ul>{renderErrorList(fieldErrors)}</ul>}\n </Components.Alert>\n )}\n <Suspense fallback={<LoaderComponent />}>\n <FadeIn>{children}</FadeIn>\n </Suspense>\n </ErrorBoundary>\n </BaseContext.Provider>\n )\n}\n"],"names":["renderErrorList","errorList","errorFromList","jsx","getFieldErrors","error","parentKey","keyPrefix","snakeCaseToCamelCase","keySuffix","err","BaseComponent","children","FallbackComponent","InternalError","LoaderComponent","Loading","onEvent","dictionary","setError","useState","fieldErrors","setFieldErrors","throwError","useAsyncError","t","useTranslation","Components","useComponentContext","processError","UnprocessableEntityErrorObject","baseSubmitHandler","useCallback","data","componentHandler","APIError","SDKValidationError","BaseContext","jsxs","ErrorBoundary","componentEvents","Suspense","FadeIn"],"mappings":";;;;;;;;;;;;;;;AAiCA,MAAMA,IAAkB,CAACC,MAChBA,EAAU,IAAI,CAAiBC,MAChCA,EAAc,UACR,gBAAAC,EAAA,MAAA,EAA4B,UAAcD,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AuC;AACzD,MAAAf,EAAS,IAAI,GACbG,EAAe,IAAI;AACf,UAAA;AACF,cAAMY,EAAiBD,CAAI;AAAA,eACpBvB,GAAK;AACZ,QACEA,aAAeyB,KACfzB,aAAe0B,KACf1B,aAAeoB,IAEfD,EAAanB,CAAG,MACAA,CAAG;AAAA,MAAA;AAAA,IAEzB;AAAA,IACA,CAACS,GAAUI,CAAU;AAAA,EACvB;AAGE,SAAA,gBAAApB;AAAA,IAACkC,EAAY;AAAA,IAAZ;AAAA,MACC,OAAO;AAAA,QACL,aAAAhB;AAAA,QACA,UAAAF;AAAA,QACA,SAAAF;AAAA,QACA,YAAAM;AAAA,QACA,mBAAAQ;AAAA,MACF;AAAA,MAEA,UAAA,gBAAAO;AAAA,QAACC;AAAA,QAAA;AAAA,UACC,mBAAA1B;AAAA,UACA,SAAS,CAAOH,MAAA;AACN,YAAAO,EAAAuB,EAAgB,OAAO9B,CAAG;AAAA,UACpC;AAAA,UAEE,UAAA;AAAA,aAAAL,KAASgB,MACR,gBAAAlB,EAAAwB,EAAW,OAAX,EAAiB,OAAOF,EAAE,yBAAyB,GAAG,QAAO,SAC3D,UAAeJ,KAAA,gBAAAlB,EAAC,QAAI,UAAgBH,EAAAqB,CAAW,EAAE,CAAA,GACpD;AAAA,YAEF,gBAAAlB,EAACsC,KAAS,UAAU,gBAAAtC,EAACY,KAAgB,GACnC,UAAA,gBAAAZ,EAACuC,GAAQ,EAAA,UAAA9B,EAAS,CAAA,EACpB,CAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;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 { FadeIn } from '../Common/FadeIn/FadeIn'\nimport { BaseContext, type FieldError, type KnownErrors, type OnEventType } from './useBase'\nimport { componentEvents, type EventType } from '@/shared/constants'\nimport { InternalError, Loading, useAsyncError } from '@/components/Common'\nimport { snakeCaseToCamelCase } from '@/helpers/formattedStrings'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport type { ResourceDictionary, Resources } from '@/types/Helpers'\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?: () => JSX.Element\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 = Loading,\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 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,\n onEvent,\n throwError,\n baseSubmitHandler,\n }}\n >\n <ErrorBoundary\n FallbackComponent={FallbackComponent}\n onError={err => {\n onEvent(componentEvents.ERROR, err)\n }}\n >\n {(error || fieldErrors) && (\n <Components.Alert label={t('status.errorEncountered')} status=\"error\">\n {fieldErrors && <ul>{renderErrorList(fieldErrors)}</ul>}\n </Components.Alert>\n )}\n <Suspense fallback={<LoaderComponent />}>\n <FadeIn>{children}</FadeIn>\n </Suspense>\n </ErrorBoundary>\n </BaseContext.Provider>\n )\n}\n"],"names":["renderErrorList","errorList","errorFromList","jsx","getFieldErrors","error","parentKey","keyPrefix","snakeCaseToCamelCase","keySuffix","err","BaseComponent","children","FallbackComponent","InternalError","LoaderComponent","Loading","onEvent","setError","useState","fieldErrors","setFieldErrors","throwError","useAsyncError","t","useTranslation","Components","useComponentContext","processError","UnprocessableEntityErrorObject","baseSubmitHandler","useCallback","data","componentHandler","APIError","SDKValidationError","BaseContext","jsxs","ErrorBoundary","componentEvents","Suspense","FadeIn"],"mappings":";;;;;;;;;;;;;;;AAiCA,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,SAAS,MAElBA,EAAM,UAAU,SAAS,OAAOA,EAAM,SAAS,SAAU,WAElEI,IAAYJ,EAAM,SAAS,QAClBA,EAAM,aACfI,IAAYJ,EAAM,WAEbA,EAAM,OAAO,QAAQ,CAAAK,MAAON,EAAeM,GAAKH,IAAYE,CAAS,CAAC;AAAA,EAA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AiB,OAAOF,EAAE,yBAAyB,GAAG,QAAO,SAC3D,UAAeJ,KAAA,gBAAAjB,EAAC,QAAI,UAAgBH,EAAAoB,CAAW,EAAE,CAAA,GACpD;AAAA,YAEF,gBAAAjB,EAACqC,KAAS,UAAU,gBAAArC,EAACY,KAAgB,GACnC,UAAA,gBAAAZ,EAACsC,GAAQ,EAAA,UAAA7B,EAAS,CAAA,EACpB,CAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;AAAA,EACF;AAEJ;"}
@@ -0,0 +1,21 @@
1
+ import "./types/i18next.d.ts"
2
+ import { ContractorOnboardingStatus1 } from '@gusto/embedded-api/models/components/contractor';
3
+ import { OnboardingStatus } from '@gusto/embedded-api/models/components/employee';
4
+ type OnboardingStatuses = ContractorOnboardingStatus1 | OnboardingStatus;
5
+ interface OnboardingStatusBadgeProps<T extends OnboardingStatuses> {
6
+ onboarded?: boolean;
7
+ onboardingEntity: 'contractor' | 'employee';
8
+ onboardingStatus?: T | null;
9
+ }
10
+ export declare const OnboardingStatusBadge: <T extends OnboardingStatuses>({ onboarded, onboardingEntity, onboardingStatus, }: OnboardingStatusBadgeProps<T>) => import("react/jsx-runtime").JSX.Element;
11
+ interface ContractorOnboardingStatusBadgeProps {
12
+ onboarded?: boolean;
13
+ onboardingStatus?: ContractorOnboardingStatus1 | null;
14
+ }
15
+ export declare const ContractorOnboardingStatusBadge: (props: ContractorOnboardingStatusBadgeProps) => import("react/jsx-runtime").JSX.Element;
16
+ interface EmployeeOnboardingStatusBadgeProps {
17
+ onboarded?: boolean;
18
+ onboardingStatus?: OnboardingStatus | null;
19
+ }
20
+ export declare const EmployeeOnboardingStatusBadge: (props: EmployeeOnboardingStatusBadgeProps) => import("react/jsx-runtime").JSX.Element;
21
+ export {};
@@ -0,0 +1,17 @@
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import { useTranslation as i } from "react-i18next";
3
+ import { useComponentContext as d } from "../../../contexts/ComponentAdapter/useComponentContext.js";
4
+ const o = ({
5
+ onboarded: t,
6
+ onboardingEntity: r,
7
+ onboardingStatus: a
8
+ }) => {
9
+ const { Badge: e } = d(), { t: s } = i();
10
+ return /* @__PURE__ */ n(e, { status: t ? "success" : "warning", children: s(`onboardingStatus.${r}.${a ?? "undefined"}`) });
11
+ }, m = (t) => /* @__PURE__ */ n(o, { ...t, onboardingEntity: "contractor" }), p = (t) => /* @__PURE__ */ n(o, { ...t, onboardingEntity: "employee" });
12
+ export {
13
+ m as ContractorOnboardingStatusBadge,
14
+ p as EmployeeOnboardingStatusBadge,
15
+ o as OnboardingStatusBadge
16
+ };
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/Common/OnboardingStatusBadge/index.tsx"],"sourcesContent":["import type { ContractorOnboardingStatus1 } from '@gusto/embedded-api/models/components/contractor'\nimport type { OnboardingStatus } from '@gusto/embedded-api/models/components/employee'\nimport { useTranslation } from 'react-i18next'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\ntype OnboardingStatuses = ContractorOnboardingStatus1 | OnboardingStatus\n\ninterface OnboardingStatusBadgeProps<T extends OnboardingStatuses> {\n onboarded?: boolean\n onboardingEntity: 'contractor' | 'employee'\n onboardingStatus?: T | null\n}\nexport const OnboardingStatusBadge = <T extends OnboardingStatuses>({\n onboarded,\n onboardingEntity,\n onboardingStatus,\n}: OnboardingStatusBadgeProps<T>) => {\n const { Badge } = useComponentContext()\n const { t } = useTranslation()\n\n //HACK: `never` should instead be a better type\n return (\n <Badge status={onboarded ? 'success' : 'warning'}>\n {t(`onboardingStatus.${onboardingEntity}.${onboardingStatus ?? 'undefined'}` as never)}\n </Badge>\n )\n}\n\ninterface ContractorOnboardingStatusBadgeProps {\n onboarded?: boolean\n onboardingStatus?: ContractorOnboardingStatus1 | null\n}\nexport const ContractorOnboardingStatusBadge = (props: ContractorOnboardingStatusBadgeProps) => (\n <OnboardingStatusBadge {...props} onboardingEntity=\"contractor\" />\n)\n\ninterface EmployeeOnboardingStatusBadgeProps {\n onboarded?: boolean\n onboardingStatus?: OnboardingStatus | null\n}\nexport const EmployeeOnboardingStatusBadge = (props: EmployeeOnboardingStatusBadgeProps) => (\n <OnboardingStatusBadge {...props} onboardingEntity=\"employee\" />\n)\n"],"names":["OnboardingStatusBadge","onboarded","onboardingEntity","onboardingStatus","Badge","useComponentContext","t","useTranslation","jsx","ContractorOnboardingStatusBadge","props","EmployeeOnboardingStatusBadge"],"mappings":";;;AAYO,MAAMA,IAAwB,CAA+B;AAAA,EAClE,WAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,kBAAAC;AACF,MAAqC;AAC7B,QAAA,EAAE,OAAAC,EAAM,IAAIC,EAAoB,GAChC,EAAE,GAAAC,EAAE,IAAIC,EAAe;AAG7B,SACG,gBAAAC,EAAAJ,GAAA,EAAM,QAAQH,IAAY,YAAY,WACpC,UAAEK,EAAA,oBAAoBJ,CAAgB,IAAIC,KAAoB,WAAW,EAAW,GACvF;AAEJ,GAMaM,IAAkC,CAACC,MAC9C,gBAAAF,EAACR,KAAuB,GAAGU,GAAO,kBAAiB,aAAa,CAAA,GAOrDC,IAAgC,CAACD,MAC5C,gBAAAF,EAACR,KAAuB,GAAGU,GAAO,kBAAiB,WAAW,CAAA;"}
@@ -1,28 +1,28 @@
1
1
  import { jsx as r } from "react/jsx-runtime";
2
2
  import v from "dompurify";
3
3
  import { useTranslation as w } from "react-i18next";
4
- import { SelectField as b } from "../Fields/SelectField/SelectField.js";
5
- import { TextInputField as y } from "../Fields/TextInputField/TextInputField.js";
4
+ import { SelectField as y } from "../Fields/SelectField/SelectField.js";
5
+ import { TextInputField as b } from "../Fields/TextInputField/TextInputField.js";
6
6
  import { NumberInputField as k } from "../Fields/NumberInputField/NumberInputField.js";
7
7
  import { RadioGroupField as _ } from "../Fields/RadioGroupField/RadioGroupField.js";
8
8
  import { DatePickerField as D } from "../Fields/DatePickerField/DatePickerField.js";
9
- import { useComponentContext as h } from "../../../contexts/ComponentAdapter/useComponentContext.js";
10
- import { useMaskedTransform as C } from "../../../helpers/mask.js";
11
- const T = { ALLOWED_TAGS: ["a", "b", "strong"], ALLOWED_ATTR: ["target", "href"] };
9
+ import { useComponentContext as R } from "../../../contexts/ComponentAdapter/useComponentContext.js";
10
+ import { useMaskedTransform as h } from "../../../helpers/mask.js";
11
+ const C = { ALLOWED_TAGS: ["a", "b", "strong"], ALLOWED_ATTR: ["target", "href"] };
12
12
  function V({
13
13
  questionType: t,
14
14
  ...e
15
15
  }) {
16
16
  switch (t.toLowerCase()) {
17
17
  case "date":
18
- return /* @__PURE__ */ r(g, { ...e });
19
- case "radio":
20
18
  return /* @__PURE__ */ r(I, { ...e });
19
+ case "radio":
20
+ return /* @__PURE__ */ r(x, { ...e });
21
21
  case "text":
22
22
  case "account_number":
23
- return /* @__PURE__ */ r(m, { ...e });
23
+ return /* @__PURE__ */ r(f, { ...e });
24
24
  case "select":
25
- return /* @__PURE__ */ r(x, { ...e });
25
+ return /* @__PURE__ */ r(T, { ...e });
26
26
  case "number":
27
27
  return /* @__PURE__ */ r(d, { ...e });
28
28
  case "workers_compensation_rate":
@@ -33,38 +33,40 @@ function V({
33
33
  case "currency":
34
34
  return /* @__PURE__ */ r(d, { ...e, isCurrency: !0 });
35
35
  default:
36
- return /* @__PURE__ */ r(m, { ...e });
36
+ return /* @__PURE__ */ r(f, { ...e });
37
37
  }
38
38
  }
39
- function x({ question: t, requirement: e, isDisabled: s = !1 }) {
39
+ function T({ question: t, requirement: e, isDisabled: s = !1 }) {
40
40
  const { key: a, label: i, description: l } = t || e, n = t ? t.answers[0]?.value : e.value, o = t ? t.inputQuestionFormat : e.metadata;
41
41
  if (!o?.options) throw new Error("Select input must have options");
42
42
  return a ? /* @__PURE__ */ r(
43
- b,
43
+ y,
44
44
  {
45
+ isRequired: !0,
45
46
  name: a,
46
47
  defaultValue: n,
47
48
  label: i,
48
49
  description: l,
49
50
  isDisabled: a.includes("fileNewHireReport") ? n !== void 0 : s,
50
- options: o.options.map((c, u) => ({
51
- value: c.value,
52
- label: c.label
51
+ options: o.options.map((u, c) => ({
52
+ value: u.value,
53
+ label: u.label
53
54
  }))
54
55
  }
55
56
  ) : null;
56
57
  }
57
- function m({ question: t, requirement: e, isDisabled: s = !1 }) {
58
- const { key: a, label: i, description: l } = t || e, n = t ? t.answers[0]?.value : e.value, o = e?.metadata?.mask ?? null, c = C(o);
58
+ function f({ question: t, requirement: e, isDisabled: s = !1 }) {
59
+ const { key: a, label: i, description: l } = t || e, n = t ? t.answers[0]?.value : e.value, o = e?.metadata?.mask ?? null, u = h(o);
59
60
  return a ? /* @__PURE__ */ r(
60
- y,
61
+ b,
61
62
  {
63
+ isRequired: !0,
62
64
  name: a,
63
65
  label: i,
64
66
  defaultValue: n,
65
67
  description: l,
66
68
  isDisabled: s,
67
- transform: o ? c : void 0,
69
+ transform: o ? u : void 0,
68
70
  placeholder: o || void 0
69
71
  }
70
72
  ) : null;
@@ -76,16 +78,17 @@ function d({
76
78
  isPercent: a,
77
79
  isDisabled: i = !1
78
80
  }) {
79
- const { t: l } = w("common"), { key: n, label: o, description: c } = t || e, u = t ? t.answers[0]?.value : e.value;
81
+ const { t: l } = w("common"), { key: n, label: o, description: u } = t || e, c = t ? t.answers[0]?.value : e.value;
80
82
  if (!n) return null;
81
- const f = e?.metadata?.type === "workers_compensation_rate" && e.metadata.riskClassCode !== void 0 ? `${e.metadata.riskClassCode}: ${e.metadata.riskClassDescription}` : null, p = e?.metadata?.rateType === "currency_per_hour" ? l("inputs.workersCompensationRatePerHourAdornment") : void 0;
83
+ const m = e?.metadata?.type === "workers_compensation_rate" && e.metadata.riskClassCode !== void 0 ? `${e.metadata.riskClassCode}: ${e.metadata.riskClassDescription}` : null, p = e?.metadata?.rateType === "currency_per_hour" ? l("inputs.workersCompensationRatePerHourAdornment") : void 0;
82
84
  return /* @__PURE__ */ r(
83
85
  k,
84
86
  {
87
+ isRequired: !0,
85
88
  name: n,
86
89
  label: o,
87
- description: c ?? f,
88
- defaultValue: Number(u),
90
+ description: u ?? m,
91
+ defaultValue: typeof c < "u" ? Number(c) : void 0,
89
92
  format: s ? "currency" : a ? "percent" : "decimal",
90
93
  isDisabled: i,
91
94
  maximumFractionDigits: a ? 4 : void 0,
@@ -93,38 +96,41 @@ function d({
93
96
  }
94
97
  );
95
98
  }
96
- function I({ question: t, requirement: e, isDisabled: s = !1 }) {
97
- const { key: a, label: i, description: l } = t || e, n = t ? t.answers[0]?.value : e.value, { Text: o } = h(), c = t ? t.inputQuestionFormat : e.metadata;
98
- if (!c?.options) throw new Error(`RadioInput must have options:${JSON.stringify(t)}`);
99
+ function x({ question: t, requirement: e, isDisabled: s = !1 }) {
100
+ const { key: a, label: i, description: l } = t || e, n = t ? t.answers[0]?.value : e.value, { Text: o } = R(), u = t ? t.inputQuestionFormat : e.metadata;
101
+ if (!u?.options) throw new Error(`RadioInput must have options:${JSON.stringify(t)}`);
99
102
  return a ? /* @__PURE__ */ r(
100
103
  _,
101
104
  {
105
+ isRequired: !0,
102
106
  name: a,
103
107
  isDisabled: a.includes("fileNewHireReport") ? n !== void 0 : s,
104
108
  description: l && /* @__PURE__ */ r(o, { as: "span", children: /* @__PURE__ */ r(
105
109
  "span",
106
110
  {
107
- dangerouslySetInnerHTML: { __html: v.sanitize(l, T) }
111
+ dangerouslySetInnerHTML: { __html: v.sanitize(l, C) }
108
112
  }
109
113
  ) }),
110
114
  label: i,
111
- options: c.options.map((u) => ({
112
- value: u.value,
113
- label: u.label
115
+ options: u.options.map((c) => ({
116
+ value: c.value,
117
+ label: c.label
114
118
  }))
115
119
  }
116
120
  ) : null;
117
121
  }
118
- function g({
122
+ function I({
119
123
  question: t,
120
124
  requirement: e,
121
125
  isDisabled: s = !1
122
126
  }) {
123
127
  const { key: a, label: i, description: l } = t || e, n = t ? t.answers[0]?.value : e.value;
124
- if (typeof n != "string") throw new Error("Expecting value to be string for DateInput");
128
+ if (typeof n != "string" && typeof n < "u")
129
+ throw new Error("Expecting value to be string for DateInput");
125
130
  return a ? /* @__PURE__ */ r(
126
131
  D,
127
132
  {
133
+ isRequired: !0,
128
134
  name: a,
129
135
  defaultValue: n ? new Date(n) : null,
130
136
  label: i,
@@ -134,11 +140,11 @@ function g({
134
140
  ) : null;
135
141
  }
136
142
  export {
137
- g as DateField,
143
+ I as DateField,
138
144
  d as NumberInput,
139
145
  V as QuestionInput,
140
- I as RadioInput,
141
- x as SelectInput,
142
- m as TextInput
146
+ x as RadioInput,
147
+ T as SelectInput,
148
+ f as TextInput
143
149
  };
144
150
  //# 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 <NumberInput {...props} isPercent />\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 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 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}\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 name={key}\n label={label}\n description={description ?? wcDescription}\n defaultValue={Number(value)}\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 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') throw new Error('Expecting value to be string for DateInput')\n\n if (!key) return null\n\n return (\n <DatePickerField\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"],"names":["dompurifyConfig","QuestionInput","questionType","props","jsx","DateField","RadioInput","TextInput","SelectInput","NumberInput","question","requirement","isDisabled","key","label","description","value","meta","SelectField","item","_","mask","transform","useMaskedTransform","TextInputField","isCurrency","isPercent","t","useTranslation","wcDescription","adornmentEnd","NumberInputField","Text","useComponentContext","RadioGroupField","DOMPurify","DatePickerField"],"mappings":";;;;;;;;;;AAYA,MAAMA,IAAkB,EAAE,cAAc,CAAC,KAAK,KAAK,QAAQ,GAAG,cAAc,CAAC,UAAU,MAAM,EAAE;AAexF,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,aAAa,UAAW,CAAA;AAAA,IAE5F,KAAK;AAAA,IACL,KAAK;AACH,aAAQ,gBAAAC,EAAAK,GAAA,EAAa,GAAGN,GAAO,WAAS,IAAC;AAAA,IAC3C,KAAK;AACH,aAAQ,gBAAAC,EAAAK,GAAA,EAAa,GAAGN,GAAO,YAAU,IAAC;AAAA,IAC5C;AACS,aAAA,gBAAAC,EAACG,GAAW,EAAA,GAAGJ,EAAO,CAAA;AAAA,EAAA;AAGnC;AAEO,SAASK,EAAY,EAAE,UAAAE,GAAU,aAAAC,GAAa,YAAAC,IAAa,MAAuB;AACvF,QAAM,EAAE,KAAAC,GAAK,OAAAC,GAAO,aAAAC,EAAY,IAAIL,KAAsBC,GACp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;AAAA,UACC,yBAAyB,EAAE,QAAQ+B,EAAU,SAASpB,GAAaf,CAAe,EAAE;AAAA,QAAA;AAAA,MAAA,GAExF;AAAA,MAGJ,OAAAc;AAAA,MACA,SAASG,EAAK,QAAQ,IAAI,CAASE,OAAA;AAAA,QACjC,OAAOA,EAAK;AAAA,QACZ,OAAOA,EAAK;AAAA,MAAA,EACZ;AAAA,IAAA;AAAA,EACJ,IAvBe;AAyBnB;AAEO,SAASd,EAAU;AAAA,EACxB,UAAAK;AAAA,EACA,aAAAC;AAAA,EACA,YAAAC,IAAa;AACf,GAAsC;AACpC,QAAM,EAAE,KAAAC,GAAK,OAAAC,GAAO,aAAAC,EAAY,IAAIL,KAAsBC,GACpDK,IAAQN,IAAWA,EAAS,QAAQ,CAAC,GAAG,QAAQC,EAAY;AAClE,MAAI,OAAOK,KAAU,SAAgB,OAAA,IAAI,MAAM,4CAA4C;AAEvF,SAACH,IAGH,gBAAAT;AAAA,IAACgC;AAAA,IAAA;AAAA,MACC,MAAMvB;AAAA,MACN,cAAcG,IAAQ,IAAI,KAAKA,CAAK,IAAI;AAAA,MACxC,OAAAF;AAAA,MACA,aAAAC;AAAA,MACA,YAAAH;AAAA,IAAA;AAAA,EACF,IATe;AAWnB;"}
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 <NumberInput {...props} isPercent />\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}\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"],"names":["dompurifyConfig","QuestionInput","questionType","props","jsx","DateField","RadioInput","TextInput","SelectInput","NumberInput","question","requirement","isDisabled","key","label","description","value","meta","SelectField","item","_","mask","transform","useMaskedTransform","TextInputField","isCurrency","isPercent","t","useTranslation","wcDescription","adornmentEnd","NumberInputField","Text","useComponentContext","RadioGroupField","DOMPurify","DatePickerField"],"mappings":";;;;;;;;;;AAYA,MAAMA,IAAkB,EAAE,cAAc,CAAC,KAAK,KAAK,QAAQ,GAAG,cAAc,CAAC,UAAU,MAAM,EAAE;AAexF,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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AQ,IAAI,KAAKA,CAAK,IAAI;AAAA,MACxC,OAAAF;AAAA,MACA,aAAAC;AAAA,MACA,YAAAH;AAAA,IAAA;AAAA,EACF,IAVe;AAYnB;"}
@@ -16,12 +16,12 @@ function g() {
16
16
  errorMessage: e("validations.street1")
17
17
  }
18
18
  ),
19
- /* @__PURE__ */ r(t, { name: "street2", label: e("street2", "Street 2") }),
19
+ /* @__PURE__ */ r(t, { name: "street2", label: e("street2") }),
20
20
  /* @__PURE__ */ r(
21
21
  t,
22
22
  {
23
23
  name: "city",
24
- label: e("city", "City"),
24
+ label: e("city"),
25
25
  isRequired: !0,
26
26
  errorMessage: e("validations.city")
27
27
  }
@@ -34,21 +34,13 @@ function g() {
34
34
  label: e(`statesHash.${a}`, { ns: "common", defaultValue: a }),
35
35
  value: a
36
36
  })),
37
- label: e("state", "State"),
37
+ label: e("state"),
38
38
  placeholder: e("statePlaceholder"),
39
39
  errorMessage: e("validations.state"),
40
40
  isRequired: !0
41
41
  }
42
42
  ),
43
- /* @__PURE__ */ r(
44
- t,
45
- {
46
- name: "zip",
47
- label: e("zip", "Zip"),
48
- isRequired: !0,
49
- errorMessage: e("validations.zip")
50
- }
51
- )
43
+ /* @__PURE__ */ r(t, { name: "zip", label: e("zip"), isRequired: !0, errorMessage: e("validations.zip") })
52
44
  ] });
53
45
  }
54
46
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"Form.js","sources":["../../../../src/components/Contractor/Address/Form.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { TextInputField, SelectField, Grid } from '@/components/Common'\nimport { STATES_ABBR } from '@/shared/constants'\n\nexport function Form() {\n const { t } = useTranslation('Contractor.Address')\n\n return (\n <Grid gridTemplateColumns={{ base: '1fr', small: ['1fr', '1fr'] }} gap={20}>\n <TextInputField\n name=\"street1\"\n label={t('street1')}\n isRequired\n errorMessage={t('validations.street1')}\n />\n <TextInputField name=\"street2\" label={t('street2', 'Street 2')} />\n <TextInputField\n name=\"city\"\n label={t('city', 'City')}\n isRequired\n errorMessage={t('validations.city')}\n />\n <SelectField\n name=\"state\"\n options={STATES_ABBR.map(stateAbbr => ({\n label: t(`statesHash.${stateAbbr}`, { ns: 'common', defaultValue: stateAbbr }),\n value: stateAbbr,\n }))}\n label={t('state', 'State')}\n placeholder={t('statePlaceholder')}\n errorMessage={t('validations.state')}\n isRequired\n />\n <TextInputField\n name=\"zip\"\n label={t('zip', 'Zip')}\n isRequired\n errorMessage={t('validations.zip')}\n />\n </Grid>\n )\n}\n"],"names":["Form","t","useTranslation","jsxs","Grid","jsx","TextInputField","SelectField","STATES_ABBR","stateAbbr"],"mappings":";;;;;;AAIO,SAASA,IAAO;AACrB,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,oBAAoB;AAEjD,SACG,gBAAAC,EAAAC,GAAA,EAAK,qBAAqB,EAAE,MAAM,OAAO,OAAO,CAAC,OAAO,KAAK,EAAE,GAAG,KAAK,IACtE,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,OAAOL,EAAE,SAAS;AAAA,QAClB,YAAU;AAAA,QACV,cAAcA,EAAE,qBAAqB;AAAA,MAAA;AAAA,IACvC;AAAA,IACA,gBAAAI,EAACC,KAAe,MAAK,WAAU,OAAOL,EAAE,WAAW,UAAU,GAAG;AAAA,IAChE,gBAAAI;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,OAAOL,EAAE,QAAQ,MAAM;AAAA,QACvB,YAAU;AAAA,QACV,cAAcA,EAAE,kBAAkB;AAAA,MAAA;AAAA,IACpC;AAAA,IACA,gBAAAI;AAAA,MAACE;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,SAASC,EAAY,IAAI,CAAcC,OAAA;AAAA,UACrC,OAAOR,EAAE,cAAcQ,CAAS,IAAI,EAAE,IAAI,UAAU,cAAcA,GAAW;AAAA,UAC7E,OAAOA;AAAA,QAAA,EACP;AAAA,QACF,OAAOR,EAAE,SAAS,OAAO;AAAA,QACzB,aAAaA,EAAE,kBAAkB;AAAA,QACjC,cAAcA,EAAE,mBAAmB;AAAA,QACnC,YAAU;AAAA,MAAA;AAAA,IACZ;AAAA,IACA,gBAAAI;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,OAAOL,EAAE,OAAO,KAAK;AAAA,QACrB,YAAU;AAAA,QACV,cAAcA,EAAE,iBAAiB;AAAA,MAAA;AAAA,IAAA;AAAA,EACnC,GACF;AAEJ;"}
1
+ {"version":3,"file":"Form.js","sources":["../../../../src/components/Contractor/Address/Form.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { TextInputField, SelectField, Grid } from '@/components/Common'\nimport { STATES_ABBR } from '@/shared/constants'\n\nexport function Form() {\n const { t } = useTranslation('Contractor.Address')\n\n return (\n <Grid gridTemplateColumns={{ base: '1fr', small: ['1fr', '1fr'] }} gap={20}>\n <TextInputField\n name=\"street1\"\n label={t('street1')}\n isRequired\n errorMessage={t('validations.street1')}\n />\n <TextInputField name=\"street2\" label={t('street2')} />\n <TextInputField\n name=\"city\"\n label={t('city')}\n isRequired\n errorMessage={t('validations.city')}\n />\n <SelectField\n name=\"state\"\n options={STATES_ABBR.map(stateAbbr => ({\n label: t(`statesHash.${stateAbbr}`, { ns: 'common', defaultValue: stateAbbr }),\n value: stateAbbr,\n }))}\n label={t('state')}\n placeholder={t('statePlaceholder')}\n errorMessage={t('validations.state')}\n isRequired\n />\n <TextInputField name=\"zip\" label={t('zip')} isRequired errorMessage={t('validations.zip')} />\n </Grid>\n )\n}\n"],"names":["Form","t","useTranslation","jsxs","Grid","jsx","TextInputField","SelectField","STATES_ABBR","stateAbbr"],"mappings":";;;;;;AAIO,SAASA,IAAO;AACrB,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,oBAAoB;AAEjD,SACG,gBAAAC,EAAAC,GAAA,EAAK,qBAAqB,EAAE,MAAM,OAAO,OAAO,CAAC,OAAO,KAAK,EAAE,GAAG,KAAK,IACtE,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,OAAOL,EAAE,SAAS;AAAA,QAClB,YAAU;AAAA,QACV,cAAcA,EAAE,qBAAqB;AAAA,MAAA;AAAA,IACvC;AAAA,sBACCK,GAAe,EAAA,MAAK,WAAU,OAAOL,EAAE,SAAS,GAAG;AAAA,IACpD,gBAAAI;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,OAAOL,EAAE,MAAM;AAAA,QACf,YAAU;AAAA,QACV,cAAcA,EAAE,kBAAkB;AAAA,MAAA;AAAA,IACpC;AAAA,IACA,gBAAAI;AAAA,MAACE;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,SAASC,EAAY,IAAI,CAAcC,OAAA;AAAA,UACrC,OAAOR,EAAE,cAAcQ,CAAS,IAAI,EAAE,IAAI,UAAU,cAAcA,GAAW;AAAA,UAC7E,OAAOA;AAAA,QAAA,EACP;AAAA,QACF,OAAOR,EAAE,OAAO;AAAA,QAChB,aAAaA,EAAE,kBAAkB;AAAA,QACjC,cAAcA,EAAE,mBAAmB;AAAA,QACnC,YAAU;AAAA,MAAA;AAAA,IACZ;AAAA,IACC,gBAAAI,EAAAC,GAAA,EAAe,MAAK,OAAM,OAAOL,EAAE,KAAK,GAAG,YAAU,IAAC,cAAcA,EAAE,iBAAiB,EAAG,CAAA;AAAA,EAAA,GAC7F;AAEJ;"}