@gusto/embedded-react-sdk 0.52.0 → 0.52.2

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 (131) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/components/Base/Base.d.ts +2 -0
  3. package/dist/components/Base/Base.js.map +1 -1
  4. package/dist/components/Common/PaginationControl/PaginationControlTypes.d.ts +4 -1
  5. package/dist/components/Common/UI/Breadcrumbs/BreadcrumbsTypes.d.ts +1 -1
  6. package/dist/components/Common/UI/Breadcrumbs/BreadcrumbsTypes.js.map +1 -1
  7. package/dist/components/Common/UI/CheckboxGroup/CheckboxGroupTypes.d.ts +1 -1
  8. package/dist/components/Common/UI/CheckboxGroup/CheckboxGroupTypes.js.map +1 -1
  9. package/dist/components/Common/UI/ComboBox/ComboBoxTypes.d.ts +2 -2
  10. package/dist/components/Common/UI/DateRangePicker/DateRangePickerTypes.d.ts +3 -2
  11. package/dist/components/Common/UI/DescriptionList/DescriptionListTypes.d.ts +1 -1
  12. package/dist/components/Common/UI/DescriptionList/DescriptionListTypes.js.map +1 -1
  13. package/dist/components/Common/UI/Menu/MenuTypes.d.ts +3 -3
  14. package/dist/components/Common/UI/Menu/MenuTypes.js.map +1 -1
  15. package/dist/components/Common/UI/MultiSelectComboBox/MultiSelectComboBoxTypes.d.ts +2 -2
  16. package/dist/components/Common/UI/RadioGroup/RadioGroupTypes.d.ts +2 -2
  17. package/dist/components/Common/UI/RadioGroup/RadioGroupTypes.js.map +1 -1
  18. package/dist/components/Common/UI/Select/SelectTypes.d.ts +2 -2
  19. package/dist/components/Common/UI/Table/TableTypes.d.ts +4 -4
  20. package/dist/components/Common/UI/Table/TableTypes.js.map +1 -1
  21. package/dist/components/Common/UI/Tabs/TabsTypes.d.ts +2 -2
  22. package/dist/components/Company/DocumentSigner/shared/useSignCompanyForm/fields.js +4 -4
  23. package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/fields.js +5 -5
  24. package/dist/components/Company/StateTaxes/stateTaxesStateMachine.d.ts +0 -1
  25. package/dist/components/Company/StateTaxes/stateTaxesStateMachine.js +12 -14
  26. package/dist/components/Company/StateTaxes/stateTaxesStateMachine.js.map +1 -1
  27. package/dist/components/Contractor/Address/Address.js +83 -75
  28. package/dist/components/Contractor/Address/Address.js.map +1 -1
  29. package/dist/components/Contractor/ContractorList/index.d.ts +2 -1
  30. package/dist/components/Contractor/ContractorList/index.js +112 -99
  31. package/dist/components/Contractor/ContractorList/index.js.map +1 -1
  32. package/dist/components/Contractor/Documents/SignatureForm/SignatureForm.js +170 -123
  33. package/dist/components/Contractor/Documents/SignatureForm/SignatureForm.js.map +1 -1
  34. package/dist/components/Contractor/Documents/SignatureForm/SignatureForm.module.scss.js +12 -0
  35. package/dist/components/Contractor/Documents/SignatureForm/SignatureForm.module.scss.js.map +1 -0
  36. package/dist/components/Contractor/Documents/SignatureForm/useContractorSignatureForm/fields.js +44 -43
  37. package/dist/components/Contractor/Documents/SignatureForm/useContractorSignatureForm/fields.js.map +1 -1
  38. package/dist/components/Contractor/Documents/SignatureForm/useContractorSignatureForm/useContractorSignatureForm.js +91 -88
  39. package/dist/components/Contractor/Documents/SignatureForm/useContractorSignatureForm/useContractorSignatureForm.js.map +1 -1
  40. package/dist/components/Contractor/Documents/SignatureForm/useContractorSignatureForm/w9Fields.d.ts +0 -33
  41. package/dist/components/Contractor/Documents/SignatureForm/useContractorSignatureForm/w9Fields.js +77 -86
  42. package/dist/components/Contractor/Documents/SignatureForm/useContractorSignatureForm/w9Fields.js.map +1 -1
  43. package/dist/components/Contractor/OnboardingFlow/OnboardingFlow.d.ts +1 -1
  44. package/dist/components/Contractor/OnboardingFlow/OnboardingFlow.js.map +1 -1
  45. package/dist/components/Contractor/OnboardingFlow/OnboardingFlowComponents.d.ts +2 -0
  46. package/dist/components/Contractor/OnboardingFlow/OnboardingFlowComponents.js.map +1 -1
  47. package/dist/components/Contractor/OnboardingFlow/onboardingStateMachine.js +150 -80
  48. package/dist/components/Contractor/OnboardingFlow/onboardingStateMachine.js.map +1 -1
  49. package/dist/components/Contractor/OnboardingFlow/onboardingStateMachine.test.d.ts +1 -0
  50. package/dist/components/Contractor/PaymentMethod/shared/useContractorBankAccountForm/fields.js +1 -1
  51. package/dist/components/Contractor/Profile/BusinessSelfOnboardingProfile.js +19 -18
  52. package/dist/components/Contractor/Profile/BusinessSelfOnboardingProfile.js.map +1 -1
  53. package/dist/components/Contractor/Profile/ContractorProfile.d.ts +1 -1
  54. package/dist/components/Contractor/Profile/ContractorProfile.js +121 -111
  55. package/dist/components/Contractor/Profile/ContractorProfile.js.map +1 -1
  56. package/dist/components/Contractor/Profile/IndividualSelfOnboardingProfile.js +27 -26
  57. package/dist/components/Contractor/Profile/IndividualSelfOnboardingProfile.js.map +1 -1
  58. package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/fields.js +16 -16
  59. package/dist/components/Contractor/Submit/Submit.js +127 -67
  60. package/dist/components/Contractor/Submit/Submit.js.map +1 -1
  61. package/dist/components/Contractor/shared/useContractorHasSignedW9.d.ts +8 -0
  62. package/dist/components/Contractor/shared/useContractorHasSignedW9.js +10 -0
  63. package/dist/components/Contractor/shared/useContractorHasSignedW9.js.map +1 -0
  64. package/dist/components/Employee/Compensation/shared/useCompensationForm/fields.js +4 -4
  65. package/dist/components/Employee/Compensation/shared/useJobForm/fields.js +6 -6
  66. package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/fields.js +8 -8
  67. package/dist/components/Employee/Deductions/shared/useDeductionForm/fields.js +4 -4
  68. package/dist/components/Employee/Documents/shared/useSignEmployeeForm/fields.js +1 -1
  69. package/dist/components/Employee/FederalTaxes/shared/useFederalTaxesForm/fields.js +4 -4
  70. package/dist/components/Employee/PaymentMethod/shared/useBankForm/fields.js +1 -1
  71. package/dist/components/Employee/PaymentMethod/shared/useSplitPaymentsForm/splitFieldFactory.js +4 -4
  72. package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/fields.js +8 -8
  73. package/dist/components/Employee/Profile/shared/useHomeAddressForm/fields.js +5 -5
  74. package/dist/components/Employee/Profile/shared/useHomeAddressForm/useCurrentHomeAddressForm.d.ts +1 -0
  75. package/dist/components/Employee/Profile/shared/useHomeAddressForm/useCurrentHomeAddressForm.js.map +1 -1
  76. package/dist/components/Employee/Profile/shared/useWorkAddressForm/fields.js +4 -4
  77. package/dist/components/Employee/Profile/shared/useWorkAddressForm/useCurrentWorkAddressForm.d.ts +1 -0
  78. package/dist/components/Employee/Profile/shared/useWorkAddressForm/useCurrentWorkAddressForm.js.map +1 -1
  79. package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fieldComponents.js +8 -8
  80. package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fields.d.ts +2 -2
  81. package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fields.js.map +1 -1
  82. package/dist/components/index.d.ts +40 -0
  83. package/dist/contexts/ComponentAdapter/useComponentContext.d.ts +1 -1
  84. package/dist/contexts/ComponentAdapter/useComponentContext.js.map +1 -1
  85. package/dist/contexts/GustoProvider/GustoProvider.d.ts +1 -0
  86. package/dist/contexts/GustoProvider/GustoProvider.js.map +1 -1
  87. package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.d.ts +1 -0
  88. package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
  89. package/dist/contexts/ThemeProvider/types.d.ts +2 -2
  90. package/dist/i18n/en/Contractor.Address.json.js +22 -20
  91. package/dist/i18n/en/Contractor.Address.json.js.map +1 -1
  92. package/dist/i18n/en/Contractor.ContractorList.json.js +22 -20
  93. package/dist/i18n/en/Contractor.ContractorList.json.js.map +1 -1
  94. package/dist/i18n/en/Contractor.Profile.json.js +13 -11
  95. package/dist/i18n/en/Contractor.Profile.json.js.map +1 -1
  96. package/dist/i18n/en/Contractor.SignatureForm.json.js +5 -5
  97. package/dist/i18n/en/Contractor.Submit.json.js +11 -11
  98. package/dist/i18n/types.d.ts +29 -9
  99. package/dist/index.d.ts +6 -3
  100. package/dist/models/WA_RISK_CODES.d.ts +1 -0
  101. package/dist/models/WA_RISK_CODES.js.map +1 -1
  102. package/dist/partner-hook-utils/composeErrorHandler.d.ts +4 -0
  103. package/dist/partner-hook-utils/composeErrorHandler.js.map +1 -1
  104. package/dist/partner-hook-utils/form/SDKFormProvider.d.ts +1 -0
  105. package/dist/partner-hook-utils/form/SDKFormProvider.js.map +1 -1
  106. package/dist/partner-hook-utils/form/composeSubmitHandler.d.ts +4 -0
  107. package/dist/partner-hook-utils/form/composeSubmitHandler.js.map +1 -1
  108. package/dist/partner-hook-utils/form/fields/CheckboxHookField.d.ts +1 -0
  109. package/dist/partner-hook-utils/form/fields/CheckboxHookField.js.map +1 -1
  110. package/dist/partner-hook-utils/form/fields/DatePickerHookField.d.ts +1 -0
  111. package/dist/partner-hook-utils/form/fields/DatePickerHookField.js.map +1 -1
  112. package/dist/partner-hook-utils/form/fields/NumberInputHookField.d.ts +1 -0
  113. package/dist/partner-hook-utils/form/fields/NumberInputHookField.js.map +1 -1
  114. package/dist/partner-hook-utils/form/fields/RadioGroupHookField.d.ts +1 -0
  115. package/dist/partner-hook-utils/form/fields/RadioGroupHookField.js.map +1 -1
  116. package/dist/partner-hook-utils/form/fields/SelectHookField.d.ts +1 -0
  117. package/dist/partner-hook-utils/form/fields/SelectHookField.js.map +1 -1
  118. package/dist/partner-hook-utils/form/fields/SwitchHookField.d.ts +1 -0
  119. package/dist/partner-hook-utils/form/fields/SwitchHookField.js.map +1 -1
  120. package/dist/partner-hook-utils/form/fields/TextInputHookField.d.ts +1 -0
  121. package/dist/partner-hook-utils/form/fields/TextInputHookField.js.map +1 -1
  122. package/dist/partner-hook-utils/types.d.ts +9 -0
  123. package/dist/shared/constants.d.ts +10 -0
  124. package/dist/shared/constants.js +7 -6
  125. package/dist/shared/constants.js.map +1 -1
  126. package/dist/style.css +1 -1
  127. package/dist/types/Helpers.d.ts +2 -0
  128. package/dist/types/hooks.d.ts +1 -0
  129. package/dist/types/observability.d.ts +1 -0
  130. package/docs/guides/endpoint-inventory.json +17 -28
  131. package/package.json +16 -16
@@ -16,39 +16,6 @@ export declare const W9_DOCUMENT_NAME = "taxpayer_identification_form_w_9";
16
16
  * @internal
17
17
  */
18
18
  export declare const NOT_APPLICABLE_VALUE = "N/A";
19
- /**
20
- * EIN input transform that preserves the `N/A` sentinel (and the in-progress
21
- * prefixes a user types toward it) while formatting numeric input as a standard
22
- * EIN (`NN-NNNNNNN`).
23
- *
24
- * @remarks
25
- * The W-9 accepts `N/A` for a taxpayer who supplies an SSN instead of an EIN,
26
- * but the plain `normalizeEin` formatter strips every non-digit on each
27
- * keystroke — making the sentinel impossible to type. This wrapper lets the
28
- * sentinel through (normalized to uppercase) and defers to `normalizeEin` for
29
- * everything else.
30
- *
31
- * @param value - Raw user input.
32
- * @returns The `N/A` sentinel (or an in-progress prefix), otherwise the EIN-formatted value.
33
- * @internal
34
- */
35
- export declare function normalizeEinOrNotApplicable(value: string): string;
36
- /**
37
- * SSN input transform that preserves the `N/A` sentinel (and the in-progress
38
- * prefixes `N` and `N/`) while otherwise deferring to {@link normalizeSSN}.
39
- *
40
- * @remarks
41
- * The W-9 accepts `N/A` for a taxpayer who supplies an EIN instead of an SSN,
42
- * but the plain `normalizeSSN` formatter strips every non-digit on each
43
- * keystroke — making the sentinel impossible to type. This wrapper lets the
44
- * sentinel through (normalized to uppercase) and defers to `normalizeSSN` for
45
- * everything else.
46
- *
47
- * @param value - Raw user input.
48
- * @returns The `N/A` sentinel (or an in-progress prefix), otherwise the SSN-formatted value.
49
- * @internal
50
- */
51
- export declare function normalizeSsnOrNotApplicable(value: string): string;
52
19
  /**
53
20
  * Form-field name for the synthesized federal tax classification radio group.
54
21
  *
@@ -1,15 +1,4 @@
1
- import { normalizeEin as S } from "../../../../../helpers/federalEin.js";
2
- import { normalizeSSN as N } from "../../../../../helpers/ssn.js";
3
- const R = "taxpayer_identification_form_w_9", _ = "N/A";
4
- function D(e) {
5
- const t = e.replace(/\s/g, "").toUpperCase();
6
- return t === "NA" ? _ : t === "N" || t === "N/" || t === _ ? t : S(e);
7
- }
8
- function k(e) {
9
- const t = e.replace(/\s/g, "").toUpperCase();
10
- return t === "NA" ? _ : t === "N" || t === "N/" || t === _ ? t : N(e);
11
- }
12
- const x = "taxClassification", T = "llcClassificationCode", F = "otherText", C = [
1
+ const C = "taxpayer_identification_form_w_9", P = "N/A", S = "taxClassification", x = "llcClassificationCode", T = "otherText", A = [
13
2
  "individual_proprietor",
14
3
  "c_corporation",
15
4
  "s_corporation",
@@ -17,7 +6,7 @@ const x = "taxClassification", T = "llcClassificationCode", F = "otherText", C =
17
6
  "trust_estate",
18
7
  "limited_liability_company",
19
8
  "other"
20
- ], y = "limited_liability_company", I = "other", K = ["c", "s", "p"], l = {
9
+ ], y = "limited_liability_company", F = "other", b = ["c", "s", "p"], _ = {
21
10
  name: "name",
22
11
  businessName: "business_name",
23
12
  otherText: "other_text",
@@ -34,64 +23,67 @@ const x = "taxClassification", T = "llcClassificationCode", F = "otherText", C =
34
23
  ssn: "ssn",
35
24
  ein: "ein",
36
25
  signatureText: "signature_text"
37
- }, g = /* @__PURE__ */ new Set(["ssn", "ein"]);
38
- function E(e) {
39
- return typeof e == "string" && /[X•*]/.test(e);
26
+ }, I = /* @__PURE__ */ new Set(["ssn", "ein"]);
27
+ function N(s) {
28
+ return typeof s == "string" && /[X•*]/.test(s);
29
+ }
30
+ function h(s) {
31
+ return s ? (I.has(s.key ?? "") || s.dataType === "ssn" || s.dataType === "ein") && N(s.value) : !1;
40
32
  }
41
- function h(e) {
42
- return e ? (g.has(e.key ?? "") || e.dataType === "ssn" || e.dataType === "ein") && E(e.value) : !1;
33
+ function u(s) {
34
+ const n = /* @__PURE__ */ new Map();
35
+ for (const t of s.fields ?? [])
36
+ t.key && n.set(t.key, t);
37
+ return n;
43
38
  }
44
- function u(e) {
45
- const t = /* @__PURE__ */ new Map();
46
- for (const n of e.fields ?? [])
47
- n.key && t.set(n.key, n);
48
- return t;
39
+ function p(s) {
40
+ return s === "1" || s === "true";
49
41
  }
50
- function A(e) {
51
- return e === "1" || e === "true";
42
+ function O(s) {
43
+ return s.name === C;
52
44
  }
53
- function b(e) {
54
- const t = u(e), n = t.get("ssn"), s = t.get("ein"), o = h(n), a = h(s);
45
+ function g(s) {
46
+ const n = u(s), t = n.get("ssn"), e = n.get("ein"), a = h(t), o = h(e);
55
47
  return {
56
- ssnRedacted: o,
57
- einRedacted: a,
58
- ssnPlaceholder: o ? n?.value ?? void 0 : void 0,
59
- einPlaceholder: a ? s?.value ?? void 0 : void 0
48
+ ssnRedacted: a,
49
+ einRedacted: o,
50
+ ssnPlaceholder: a ? t?.value ?? void 0 : void 0,
51
+ einPlaceholder: o ? e?.value ?? void 0 : void 0
60
52
  };
61
53
  }
62
- function L(e) {
63
- const t = u(e), n = /* @__PURE__ */ new Set();
64
- for (const [o, a] of Object.entries(l))
65
- t.has(a) && n.add(o);
66
- return C.some((o) => t.has(o)) && (n.add(x), n.add(T)), n;
54
+ function E(s) {
55
+ const n = u(s), t = /* @__PURE__ */ new Set();
56
+ for (const [a, o] of Object.entries(_))
57
+ n.has(o) && t.add(a);
58
+ return A.some((a) => n.has(a)) && (t.add(S), t.add(x)), t;
67
59
  }
68
- function z(e) {
69
- const t = u(e), n = b(e), s = (a) => t.get(a)?.value ?? "", o = C.find((a) => A(t.get(a)?.value)) ?? "";
60
+ function v(s) {
61
+ const n = u(s), t = g(s), e = (o) => n.get(o)?.value ?? "", a = A.find((o) => p(n.get(o)?.value)) ?? "";
70
62
  return {
71
- name: s("name"),
72
- businessName: s("business_name"),
73
- taxClassification: o,
63
+ name: e("name"),
64
+ businessName: e("business_name"),
65
+ taxClassification: a,
74
66
  // The LLC code serializes into the `tax_classification` field, so seed it
75
67
  // back from there when the LLC classification is the selected one.
76
- llcClassificationCode: o === y ? s("tax_classification") : "",
77
- otherText: s("other_text"),
78
- foreignPartners: A(t.get("foreign_partners")?.value),
79
- exemptPayeeCode: s("exempt_payee_code"),
80
- exemptionFromFatca: s("exemption_from_FATCA"),
81
- homeAddressStreet1: s("home_address_street_1"),
82
- homeAddressStreet2: s("home_address_street_2"),
83
- homeAddressCity: s("home_address_city"),
84
- homeAddressState: s("home_address_state"),
85
- homeAddressZip: s("home_address_zip"),
86
- accountNumber: s("account_number"),
87
- companyName: s("company_name"),
88
- ssn: n.ssnRedacted ? "" : s("ssn"),
89
- ein: n.einRedacted ? "" : s("ein"),
90
- signatureText: s("signature_text"),
68
+ llcClassificationCode: a === y ? e("tax_classification") : "",
69
+ otherText: e("other_text"),
70
+ foreignPartners: p(n.get("foreign_partners")?.value),
71
+ exemptPayeeCode: e("exempt_payee_code"),
72
+ exemptionFromFatca: e("exemption_from_FATCA"),
73
+ homeAddressStreet1: e("home_address_street_1"),
74
+ homeAddressStreet2: e("home_address_street_2"),
75
+ homeAddressCity: e("home_address_city"),
76
+ homeAddressState: e("home_address_state"),
77
+ homeAddressZip: e("home_address_zip"),
78
+ accountNumber: e("account_number"),
79
+ companyName: e("company_name"),
80
+ ssn: t.ssnRedacted ? "" : e("ssn"),
81
+ ein: t.einRedacted ? "" : e("ein"),
82
+ signatureText: e("signature_text"),
91
83
  agree: !1
92
84
  };
93
85
  }
94
- const V = {
86
+ const D = {
95
87
  name: "",
96
88
  businessName: "",
97
89
  taxClassification: "",
@@ -111,7 +103,7 @@ const V = {
111
103
  ein: "",
112
104
  signatureText: "",
113
105
  agree: !1
114
- }, O = [
106
+ }, L = [
115
107
  "name",
116
108
  "businessName",
117
109
  "exemptPayeeCode",
@@ -125,39 +117,38 @@ const V = {
125
117
  "companyName",
126
118
  "signatureText"
127
119
  ];
128
- function U(e, t, n) {
129
- const s = L(e), o = [], a = t, r = (i) => {
130
- const m = a[i];
120
+ function R(s, n, t) {
121
+ const e = E(s), a = [], o = n, r = (i) => {
122
+ const m = o[i];
131
123
  return typeof m == "string" ? m : "";
132
- }, c = r("taxClassification"), d = (i, m) => {
133
- o.push({ key: l[i], value: m });
124
+ }, d = r("taxClassification"), c = (i, m) => {
125
+ a.push({ key: _[i], value: m });
134
126
  };
135
- for (const i of O)
136
- s.has(i) && d(i, r(i));
137
- s.has(F) && c === I && d("otherText", r("otherText")), s.has("foreignPartners") && o.push({
138
- key: l.foreignPartners,
139
- value: t.foreignPartners ? "1" : "0"
127
+ for (const i of L)
128
+ e.has(i) && c(i, r(i));
129
+ e.has(T) && d === F && c("otherText", r("otherText")), e.has("foreignPartners") && a.push({
130
+ key: _.foreignPartners,
131
+ value: n.foreignPartners ? "1" : "0"
140
132
  });
141
- const f = r("ssn"), p = r("ein");
142
- return s.has("ssn") && !(n.ssnRedacted && f === "") && d("ssn", f), s.has("ein") && !(n.einRedacted && p === "") && d("ein", p), c && (o.push({ key: c, value: "1" }), c === y && o.push({ key: "tax_classification", value: r("llcClassificationCode") })), o;
133
+ const l = r("ssn"), f = r("ein");
134
+ return e.has("ssn") && !(t.ssnRedacted && l === "") && c("ssn", l), e.has("ein") && !(t.einRedacted && f === "") && c("ein", f), d && (a.push({ key: d, value: "1" }), d === y && a.push({ key: "tax_classification", value: r("llcClassificationCode") })), a;
143
135
  }
144
136
  export {
145
- V as EMPTY_W9_DEFAULTS,
146
- K as LLC_CLASSIFICATION_CODES,
147
- T as LLC_CLASSIFICATION_FIELD,
137
+ D as EMPTY_W9_DEFAULTS,
138
+ b as LLC_CLASSIFICATION_CODES,
139
+ x as LLC_CLASSIFICATION_FIELD,
148
140
  y as LLC_CLASSIFICATION_OPTION,
149
- _ as NOT_APPLICABLE_VALUE,
150
- I as OTHER_CLASSIFICATION_OPTION,
151
- F as OTHER_TEXT_FIELD,
152
- x as TAX_CLASSIFICATION_FIELD,
153
- C as TAX_CLASSIFICATION_OPTION_KEYS,
154
- R as W9_DOCUMENT_NAME,
155
- l as W9_FIELD_API_KEYS,
156
- z as buildW9Defaults,
157
- L as getPresentFieldNames,
158
- b as getRedactionState,
159
- D as normalizeEinOrNotApplicable,
160
- k as normalizeSsnOrNotApplicable,
161
- U as serializeW9Fields
141
+ P as NOT_APPLICABLE_VALUE,
142
+ F as OTHER_CLASSIFICATION_OPTION,
143
+ T as OTHER_TEXT_FIELD,
144
+ S as TAX_CLASSIFICATION_FIELD,
145
+ A as TAX_CLASSIFICATION_OPTION_KEYS,
146
+ C as W9_DOCUMENT_NAME,
147
+ _ as W9_FIELD_API_KEYS,
148
+ v as buildW9Defaults,
149
+ E as getPresentFieldNames,
150
+ g as getRedactionState,
151
+ O as isW9Document,
152
+ R as serializeW9Fields
162
153
  };
163
154
  //# sourceMappingURL=w9Fields.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"w9Fields.js","sources":["../../../../../../src/components/Contractor/Documents/SignatureForm/useContractorSignatureForm/w9Fields.ts"],"sourcesContent":["import type {\n Document,\n Fields as DocumentField,\n} from '@gusto/embedded-api/models/components/document'\nimport type { ContractorSignatureFormData } from './contractorSignatureFormSchema'\nimport { normalizeEin } from '@/helpers/federalEin'\nimport { normalizeSSN } from '@/helpers/ssn'\n\n/**\n * The `name` of the W-9 document — the only contractor document type that\n * supports signing today.\n *\n * @internal\n */\nexport const W9_DOCUMENT_NAME = 'taxpayer_identification_form_w_9'\n\n/**\n * Sentinel the API returns (and accepts) for a taxpayer-ID field that doesn't\n * apply to the signer — e.g. the EIN of an individual contractor, or the SSN of\n * a business contractor. The sign endpoint stamps this verbatim, so the form\n * both prefills it and treats it as a valid submission.\n *\n * @internal\n */\nexport const NOT_APPLICABLE_VALUE = 'N/A'\n\n/**\n * EIN input transform that preserves the `N/A` sentinel (and the in-progress\n * prefixes a user types toward it) while formatting numeric input as a standard\n * EIN (`NN-NNNNNNN`).\n *\n * @remarks\n * The W-9 accepts `N/A` for a taxpayer who supplies an SSN instead of an EIN,\n * but the plain `normalizeEin` formatter strips every non-digit on each\n * keystroke — making the sentinel impossible to type. This wrapper lets the\n * sentinel through (normalized to uppercase) and defers to `normalizeEin` for\n * everything else.\n *\n * @param value - Raw user input.\n * @returns The `N/A` sentinel (or an in-progress prefix), otherwise the EIN-formatted value.\n * @internal\n */\nexport function normalizeEinOrNotApplicable(value: string): string {\n const sentinel = value.replace(/\\s/g, '').toUpperCase()\n if (sentinel === 'NA') return NOT_APPLICABLE_VALUE\n if (sentinel === 'N' || sentinel === 'N/' || sentinel === NOT_APPLICABLE_VALUE) return sentinel\n return normalizeEin(value)\n}\n\n/**\n * SSN input transform that preserves the `N/A` sentinel (and the in-progress\n * prefixes `N` and `N/`) while otherwise deferring to {@link normalizeSSN}.\n *\n * @remarks\n * The W-9 accepts `N/A` for a taxpayer who supplies an EIN instead of an SSN,\n * but the plain `normalizeSSN` formatter strips every non-digit on each\n * keystroke — making the sentinel impossible to type. This wrapper lets the\n * sentinel through (normalized to uppercase) and defers to `normalizeSSN` for\n * everything else.\n *\n * @param value - Raw user input.\n * @returns The `N/A` sentinel (or an in-progress prefix), otherwise the SSN-formatted value.\n * @internal\n */\nexport function normalizeSsnOrNotApplicable(value: string): string {\n const sentinel = value.replace(/\\s/g, '').toUpperCase()\n if (sentinel === 'NA') return NOT_APPLICABLE_VALUE\n if (sentinel === 'N' || sentinel === 'N/' || sentinel === NOT_APPLICABLE_VALUE) return sentinel\n return normalizeSSN(value)\n}\n\n/**\n * Form-field name for the synthesized federal tax classification radio group.\n *\n * @internal\n */\nexport const TAX_CLASSIFICATION_FIELD = 'taxClassification'\n\n/**\n * Form-field name for the synthesized LLC tax classification code select.\n *\n * @internal\n */\nexport const LLC_CLASSIFICATION_FIELD = 'llcClassificationCode'\n\n/**\n * Form-field name for the \"Other\" free-text classification field.\n *\n * @internal\n */\nexport const OTHER_TEXT_FIELD = 'otherText'\n\n/**\n * Ordered classification option keys backing the {@link TAX_CLASSIFICATION_FIELD}\n * radio group. Each maps to a W-9 checkbox field on the underlying document.\n *\n * @internal\n */\nexport const TAX_CLASSIFICATION_OPTION_KEYS = [\n 'individual_proprietor',\n 'c_corporation',\n 's_corporation',\n 'partnership',\n 'trust_estate',\n 'limited_liability_company',\n 'other',\n] as const\n\n/**\n * A single federal tax classification option key.\n *\n * @internal\n */\nexport type TaxClassificationOptionKey = (typeof TAX_CLASSIFICATION_OPTION_KEYS)[number]\n\n/**\n * The classification option that reveals the LLC tax classification select.\n *\n * @internal\n */\nexport const LLC_CLASSIFICATION_OPTION: TaxClassificationOptionKey = 'limited_liability_company'\n\n/**\n * The classification option that reveals the \"Other\" free-text field.\n *\n * @internal\n */\nexport const OTHER_CLASSIFICATION_OPTION: TaxClassificationOptionKey = 'other'\n\n/**\n * Ordered LLC tax classification code options.\n *\n * @internal\n */\nexport const LLC_CLASSIFICATION_CODES = ['c', 's', 'p'] as const\n\n/**\n * Maps each pass-through {@link ContractorSignatureFormData} field to its W-9\n * API field key. Synthesized fields (`taxClassification`,\n * `llcClassificationCode`) and `agree` are intentionally absent.\n *\n * @internal\n */\nexport const W9_FIELD_API_KEYS = {\n name: 'name',\n businessName: 'business_name',\n otherText: 'other_text',\n foreignPartners: 'foreign_partners',\n exemptPayeeCode: 'exempt_payee_code',\n exemptionFromFatca: 'exemption_from_FATCA',\n homeAddressStreet1: 'home_address_street_1',\n homeAddressStreet2: 'home_address_street_2',\n homeAddressCity: 'home_address_city',\n homeAddressState: 'home_address_state',\n homeAddressZip: 'home_address_zip',\n accountNumber: 'account_number',\n companyName: 'company_name',\n ssn: 'ssn',\n ein: 'ein',\n signatureText: 'signature_text',\n} as const satisfies Record<string, string>\n\n/** A pass-through W-9 field name (one with a single backing API key). */\ntype PassThroughFieldName = keyof typeof W9_FIELD_API_KEYS\n\n/** API field keys whose values are sensitive and arrive masked when on file. */\nconst SENSITIVE_FIELD_KEYS = new Set(['ssn', 'ein'])\n\n/** Whether a value is a server-side mask (e.g. `XXX-XX-1111`) rather than real input. */\nfunction isMaskedValue(value: string | null | undefined): boolean {\n return typeof value === 'string' && /[X•*]/.test(value)\n}\n\n/** Whether a document field carries a redacted (masked) sensitive value. */\nfunction hasRedactedValue(field: DocumentField | undefined): boolean {\n if (!field) return false\n const isSensitive =\n SENSITIVE_FIELD_KEYS.has(field.key ?? '') ||\n field.dataType === 'ssn' ||\n field.dataType === 'ein'\n return isSensitive && isMaskedValue(field.value)\n}\n\nfunction indexFields(document: Document): Map<string, DocumentField> {\n const byKey = new Map<string, DocumentField>()\n for (const field of document.fields ?? []) {\n if (field.key) byKey.set(field.key, field)\n }\n return byKey\n}\n\n/** Coerces an API checkbox value (`'1'`, `'true'`) to a boolean. */\nfunction toBoolean(value: string | null | undefined): boolean {\n return value === '1' || value === 'true'\n}\n\n/**\n * Whether the document is a W-9 (the only signable contractor document type).\n *\n * @internal\n */\nexport function isW9Document(document: Document): boolean {\n return document.name === W9_DOCUMENT_NAME\n}\n\n/**\n * Redaction state for the sensitive W-9 fields, derived from the API response.\n *\n * @internal\n */\nexport interface W9RedactionState {\n /** Whether the API returned a masked SSN value. */\n ssnRedacted: boolean\n /** Whether the API returned a masked EIN value. */\n einRedacted: boolean\n /** The masked SSN to surface as a placeholder, when redacted. */\n ssnPlaceholder?: string\n /** The masked EIN to surface as a placeholder, when redacted. */\n einPlaceholder?: string\n}\n\n/**\n * Computes the redaction state of the SSN/EIN fields from the document.\n *\n * @param document - The W-9 document returned by the API.\n * @returns The redaction flags and masked placeholders.\n * @internal\n */\nexport function getRedactionState(document: Document): W9RedactionState {\n const byKey = indexFields(document)\n const ssnField = byKey.get('ssn')\n const einField = byKey.get('ein')\n const ssnRedacted = hasRedactedValue(ssnField)\n const einRedacted = hasRedactedValue(einField)\n return {\n ssnRedacted,\n einRedacted,\n ssnPlaceholder: ssnRedacted ? (ssnField?.value ?? undefined) : undefined,\n einPlaceholder: einRedacted ? (einField?.value ?? undefined) : undefined,\n }\n}\n\n/**\n * Computes which W-9 form fields the API actually returned — the safety check\n * that drives presence-gating in {@link useContractorSignatureForm}.\n *\n * @remarks\n * A pass-through field is present when its API key is in `document.fields`. The\n * synthesized classification fields (`taxClassification`,\n * `llcClassificationCode`) are present when the document carries any of the\n * federal tax classification checkbox fields.\n *\n * @param document - The W-9 document returned by the API.\n * @returns The set of present camelCase field names.\n * @internal\n */\nexport function getPresentFieldNames(document: Document): Set<string> {\n const byKey = indexFields(document)\n const presentFieldNames = new Set<string>()\n\n for (const [fieldName, apiKey] of Object.entries(W9_FIELD_API_KEYS)) {\n if (byKey.has(apiKey)) presentFieldNames.add(fieldName)\n }\n\n const hasClassification = TAX_CLASSIFICATION_OPTION_KEYS.some(key => byKey.has(key))\n if (hasClassification) {\n presentFieldNames.add(TAX_CLASSIFICATION_FIELD)\n presentFieldNames.add(LLC_CLASSIFICATION_FIELD)\n }\n\n return presentFieldNames\n}\n\n/**\n * Builds default form values from a document's fields.\n *\n * @remarks\n * Pass-through values are seeded from the API `value`. The classification radio\n * defaults to whichever classification checkbox is already set (`'1'`/`'true'`),\n * and when that is the LLC classification the LLC code select is seeded from the\n * `tax_classification` field it serializes into. A masked SSN/EIN seeds an empty\n * input (the mask is surfaced as a placeholder instead) so it is never echoed\n * back as the new value on submit.\n *\n * @param document - The W-9 document returned by the API.\n * @returns The default form values.\n * @internal\n */\nexport function buildW9Defaults(document: Document): ContractorSignatureFormData {\n const byKey = indexFields(document)\n const redaction = getRedactionState(document)\n const textValue = (apiKey: string): string => byKey.get(apiKey)?.value ?? ''\n const selectedClassification =\n TAX_CLASSIFICATION_OPTION_KEYS.find(key => toBoolean(byKey.get(key)?.value)) ?? ''\n\n return {\n name: textValue('name'),\n businessName: textValue('business_name'),\n taxClassification: selectedClassification,\n // The LLC code serializes into the `tax_classification` field, so seed it\n // back from there when the LLC classification is the selected one.\n llcClassificationCode:\n selectedClassification === LLC_CLASSIFICATION_OPTION ? textValue('tax_classification') : '',\n otherText: textValue('other_text'),\n foreignPartners: toBoolean(byKey.get('foreign_partners')?.value),\n exemptPayeeCode: textValue('exempt_payee_code'),\n exemptionFromFatca: textValue('exemption_from_FATCA'),\n homeAddressStreet1: textValue('home_address_street_1'),\n homeAddressStreet2: textValue('home_address_street_2'),\n homeAddressCity: textValue('home_address_city'),\n homeAddressState: textValue('home_address_state'),\n homeAddressZip: textValue('home_address_zip'),\n accountNumber: textValue('account_number'),\n companyName: textValue('company_name'),\n ssn: redaction.ssnRedacted ? '' : textValue('ssn'),\n ein: redaction.einRedacted ? '' : textValue('ein'),\n signatureText: textValue('signature_text'),\n agree: false,\n }\n}\n\n/**\n * The empty default form values, used while the document is still loading.\n *\n * @internal\n */\nexport const EMPTY_W9_DEFAULTS: ContractorSignatureFormData = {\n name: '',\n businessName: '',\n taxClassification: '',\n llcClassificationCode: '',\n otherText: '',\n foreignPartners: false,\n exemptPayeeCode: '',\n exemptionFromFatca: '',\n homeAddressStreet1: '',\n homeAddressStreet2: '',\n homeAddressCity: '',\n homeAddressState: '',\n homeAddressZip: '',\n accountNumber: '',\n companyName: '',\n ssn: '',\n ein: '',\n signatureText: '',\n agree: false,\n}\n\n/**\n * A single `{ key, value }` pair sent in the sign request.\n *\n * @internal\n */\nexport interface SignFieldValue {\n /** The API field key. */\n key: string\n /** The serialized field value. */\n value: string\n}\n\n/** Pass-through text fields serialized verbatim (everything except the checkbox and TIN fields). */\nconst TEXT_PASS_THROUGH_FIELDS: PassThroughFieldName[] = [\n 'name',\n 'businessName',\n 'exemptPayeeCode',\n 'exemptionFromFatca',\n 'homeAddressStreet1',\n 'homeAddressStreet2',\n 'homeAddressCity',\n 'homeAddressState',\n 'homeAddressZip',\n 'accountNumber',\n 'companyName',\n 'signatureText',\n]\n\n/**\n * Serializes W-9 form values into the `{ key, value }` field array expected by\n * the sign API.\n *\n * @remarks\n * Only fields the API returned (see {@link getPresentFieldNames}) are sent.\n * Applies the W-9 mapping: the chosen classification key is sent with value\n * `'1'`; when the LLC classification is chosen, the selected LLC code is sent\n * under the `tax_classification` key. `foreignPartners` serializes to\n * `'1'`/`'0'`. The `otherText` value is only included for the \"Other\"\n * classification. An untouched redacted SSN/EIN is omitted so the mask is never\n * sent back. The `date` field is intentionally omitted so the API auto-fills the\n * signing date in its own locale-correct format.\n *\n * @param document - The W-9 document being signed.\n * @param values - The validated form values.\n * @param redaction - The redaction state from {@link getRedactionState}.\n * @returns The ordered field array for the sign request body.\n * @internal\n */\nexport function serializeW9Fields(\n document: Document,\n values: ContractorSignatureFormData,\n redaction: W9RedactionState,\n): SignFieldValue[] {\n const presentFieldNames = getPresentFieldNames(document)\n const fields: SignFieldValue[] = []\n // The schema preprocesses empty inputs to `undefined`, so read through an\n // `unknown` view and coalesce missing values to an empty string.\n const raw = values as Record<string, unknown>\n const text = (name: string): string => {\n const value = raw[name]\n return typeof value === 'string' ? value : ''\n }\n const classification = text('taxClassification')\n\n const pushField = (fieldName: PassThroughFieldName, value: string) => {\n fields.push({ key: W9_FIELD_API_KEYS[fieldName], value })\n }\n\n for (const fieldName of TEXT_PASS_THROUGH_FIELDS) {\n if (!presentFieldNames.has(fieldName)) continue\n pushField(fieldName, text(fieldName))\n }\n\n if (presentFieldNames.has(OTHER_TEXT_FIELD) && classification === OTHER_CLASSIFICATION_OPTION) {\n pushField('otherText', text('otherText'))\n }\n\n if (presentFieldNames.has('foreignPartners')) {\n fields.push({\n key: W9_FIELD_API_KEYS.foreignPartners,\n value: values.foreignPartners ? '1' : '0',\n })\n }\n\n // A redacted field left untouched is omitted so the masked value isn't sent\n // back as a replacement; the server keeps the value already on file.\n const ssnValue = text('ssn')\n const einValue = text('ein')\n if (presentFieldNames.has('ssn') && !(redaction.ssnRedacted && ssnValue === '')) {\n pushField('ssn', ssnValue)\n }\n if (presentFieldNames.has('ein') && !(redaction.einRedacted && einValue === '')) {\n pushField('ein', einValue)\n }\n\n if (classification) {\n fields.push({ key: classification, value: '1' })\n if (classification === LLC_CLASSIFICATION_OPTION) {\n fields.push({ key: 'tax_classification', value: text('llcClassificationCode') })\n }\n }\n\n return fields\n}\n"],"names":["W9_DOCUMENT_NAME","NOT_APPLICABLE_VALUE","normalizeEinOrNotApplicable","value","sentinel","normalizeEin","normalizeSsnOrNotApplicable","normalizeSSN","TAX_CLASSIFICATION_FIELD","LLC_CLASSIFICATION_FIELD","OTHER_TEXT_FIELD","TAX_CLASSIFICATION_OPTION_KEYS","LLC_CLASSIFICATION_OPTION","OTHER_CLASSIFICATION_OPTION","LLC_CLASSIFICATION_CODES","W9_FIELD_API_KEYS","SENSITIVE_FIELD_KEYS","isMaskedValue","hasRedactedValue","field","indexFields","document","byKey","toBoolean","getRedactionState","ssnField","einField","ssnRedacted","einRedacted","getPresentFieldNames","presentFieldNames","fieldName","apiKey","key","buildW9Defaults","redaction","textValue","selectedClassification","EMPTY_W9_DEFAULTS","TEXT_PASS_THROUGH_FIELDS","serializeW9Fields","values","fields","raw","text","name","classification","pushField","ssnValue","einValue"],"mappings":";;AAcO,MAAMA,IAAmB,oCAUnBC,IAAuB;AAkB7B,SAASC,EAA4BC,GAAuB;AACjE,QAAMC,IAAWD,EAAM,QAAQ,OAAO,EAAE,EAAE,YAAA;AAC1C,SAAIC,MAAa,OAAaH,IAC1BG,MAAa,OAAOA,MAAa,QAAQA,MAAaH,IAA6BG,IAChFC,EAAaF,CAAK;AAC3B;AAiBO,SAASG,EAA4BH,GAAuB;AACjE,QAAMC,IAAWD,EAAM,QAAQ,OAAO,EAAE,EAAE,YAAA;AAC1C,SAAIC,MAAa,OAAaH,IAC1BG,MAAa,OAAOA,MAAa,QAAQA,MAAaH,IAA6BG,IAChFG,EAAaJ,CAAK;AAC3B;AAOO,MAAMK,IAA2B,qBAO3BC,IAA2B,yBAO3BC,IAAmB,aAQnBC,IAAiC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAcaC,IAAwD,6BAOxDC,IAA0D,SAO1DC,IAA2B,CAAC,KAAK,KAAK,GAAG,GASzCC,IAAoB;AAAA,EAC/B,MAAM;AAAA,EACN,cAAc;AAAA,EACd,WAAW;AAAA,EACX,iBAAiB;AAAA,EACjB,iBAAiB;AAAA,EACjB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,E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BK,IAAWL,EAAK,KAAK;AAC3B,SAAId,EAAkB,IAAI,KAAK,KAAK,EAAEK,EAAU,eAAea,MAAa,OAC1ED,EAAU,OAAOC,CAAQ,GAEvBlB,EAAkB,IAAI,KAAK,KAAK,EAAEK,EAAU,eAAec,MAAa,OAC1EF,EAAU,OAAOE,CAAQ,GAGvBH,MACFJ,EAAO,KAAK,EAAE,KAAKI,GAAgB,OAAO,KAAK,GAC3CA,MAAmBlC,KACrB8B,EAAO,KAAK,EAAE,KAAK,sBAAsB,OAAOE,EAAK,uBAAuB,GAAG,IAI5EF;AACT;"}
1
+ {"version":3,"file":"w9Fields.js","sources":["../../../../../../src/components/Contractor/Documents/SignatureForm/useContractorSignatureForm/w9Fields.ts"],"sourcesContent":["import type {\n Document,\n Fields as DocumentField,\n} from '@gusto/embedded-api/models/components/document'\nimport type { ContractorSignatureFormData } from './contractorSignatureFormSchema'\n\n/**\n * The `name` of the W-9 document — the only contractor document type that\n * supports signing today.\n *\n * @internal\n */\nexport const W9_DOCUMENT_NAME = 'taxpayer_identification_form_w_9'\n\n/**\n * Sentinel the API returns (and accepts) for a taxpayer-ID field that doesn't\n * apply to the signer — e.g. the EIN of an individual contractor, or the SSN of\n * a business contractor. The sign endpoint stamps this verbatim, so the form\n * both prefills it and treats it as a valid submission.\n *\n * @internal\n */\nexport const NOT_APPLICABLE_VALUE = 'N/A'\n\n/**\n * Form-field name for the synthesized federal tax classification radio group.\n *\n * @internal\n */\nexport const TAX_CLASSIFICATION_FIELD = 'taxClassification'\n\n/**\n * Form-field name for the synthesized LLC tax classification code select.\n *\n * @internal\n */\nexport const LLC_CLASSIFICATION_FIELD = 'llcClassificationCode'\n\n/**\n * Form-field name for the \"Other\" free-text classification field.\n *\n * @internal\n */\nexport const OTHER_TEXT_FIELD = 'otherText'\n\n/**\n * Ordered classification option keys backing the {@link TAX_CLASSIFICATION_FIELD}\n * radio group. Each maps to a W-9 checkbox field on the underlying document.\n *\n * @internal\n */\nexport const TAX_CLASSIFICATION_OPTION_KEYS = [\n 'individual_proprietor',\n 'c_corporation',\n 's_corporation',\n 'partnership',\n 'trust_estate',\n 'limited_liability_company',\n 'other',\n] as const\n\n/**\n * A single federal tax classification option key.\n *\n * @internal\n */\nexport type TaxClassificationOptionKey = (typeof TAX_CLASSIFICATION_OPTION_KEYS)[number]\n\n/**\n * The classification option that reveals the LLC tax classification select.\n *\n * @internal\n */\nexport const LLC_CLASSIFICATION_OPTION: TaxClassificationOptionKey = 'limited_liability_company'\n\n/**\n * The classification option that reveals the \"Other\" free-text field.\n *\n * @internal\n */\nexport const OTHER_CLASSIFICATION_OPTION: TaxClassificationOptionKey = 'other'\n\n/**\n * Ordered LLC tax classification code options.\n *\n * @internal\n */\nexport const LLC_CLASSIFICATION_CODES = ['c', 's', 'p'] as const\n\n/**\n * Maps each pass-through {@link ContractorSignatureFormData} field to its W-9\n * API field key. Synthesized fields (`taxClassification`,\n * `llcClassificationCode`) and `agree` are intentionally absent.\n *\n * @internal\n */\nexport const W9_FIELD_API_KEYS = {\n name: 'name',\n businessName: 'business_name',\n otherText: 'other_text',\n foreignPartners: 'foreign_partners',\n exemptPayeeCode: 'exempt_payee_code',\n exemptionFromFatca: 'exemption_from_FATCA',\n homeAddressStreet1: 'home_address_street_1',\n homeAddressStreet2: 'home_address_street_2',\n homeAddressCity: 'home_address_city',\n homeAddressState: 'home_address_state',\n homeAddressZip: 'home_address_zip',\n accountNumber: 'account_number',\n companyName: 'company_name',\n ssn: 'ssn',\n ein: 'ein',\n signatureText: 'signature_text',\n} as const satisfies Record<string, string>\n\n/** A pass-through W-9 field name (one with a single backing API key). */\ntype PassThroughFieldName = keyof typeof W9_FIELD_API_KEYS\n\n/** API field keys whose values are sensitive and arrive masked when on file. */\nconst SENSITIVE_FIELD_KEYS = new Set(['ssn', 'ein'])\n\n/** Whether a value is a server-side mask (e.g. `XXX-XX-1111`) rather than real input. */\nfunction isMaskedValue(value: string | null | undefined): boolean {\n return typeof value === 'string' && /[X•*]/.test(value)\n}\n\n/** Whether a document field carries a redacted (masked) sensitive value. */\nfunction hasRedactedValue(field: DocumentField | undefined): boolean {\n if (!field) return false\n const isSensitive =\n SENSITIVE_FIELD_KEYS.has(field.key ?? '') ||\n field.dataType === 'ssn' ||\n field.dataType === 'ein'\n return isSensitive && isMaskedValue(field.value)\n}\n\nfunction indexFields(document: Document): Map<string, DocumentField> {\n const byKey = new Map<string, DocumentField>()\n for (const field of document.fields ?? []) {\n if (field.key) byKey.set(field.key, field)\n }\n return byKey\n}\n\n/** Coerces an API checkbox value (`'1'`, `'true'`) to a boolean. */\nfunction toBoolean(value: string | null | undefined): boolean {\n return value === '1' || value === 'true'\n}\n\n/**\n * Whether the document is a W-9 (the only signable contractor document type).\n *\n * @internal\n */\nexport function isW9Document(document: Document): boolean {\n return document.name === W9_DOCUMENT_NAME\n}\n\n/**\n * Redaction state for the sensitive W-9 fields, derived from the API response.\n *\n * @internal\n */\nexport interface W9RedactionState {\n /** Whether the API returned a masked SSN value. */\n ssnRedacted: boolean\n /** Whether the API returned a masked EIN value. */\n einRedacted: boolean\n /** The masked SSN to surface as a placeholder, when redacted. */\n ssnPlaceholder?: string\n /** The masked EIN to surface as a placeholder, when redacted. */\n einPlaceholder?: string\n}\n\n/**\n * Computes the redaction state of the SSN/EIN fields from the document.\n *\n * @param document - The W-9 document returned by the API.\n * @returns The redaction flags and masked placeholders.\n * @internal\n */\nexport function getRedactionState(document: Document): W9RedactionState {\n const byKey = indexFields(document)\n const ssnField = byKey.get('ssn')\n const einField = byKey.get('ein')\n const ssnRedacted = hasRedactedValue(ssnField)\n const einRedacted = hasRedactedValue(einField)\n return {\n ssnRedacted,\n einRedacted,\n ssnPlaceholder: ssnRedacted ? (ssnField?.value ?? undefined) : undefined,\n einPlaceholder: einRedacted ? (einField?.value ?? undefined) : undefined,\n }\n}\n\n/**\n * Computes which W-9 form fields the API actually returned — the safety check\n * that drives presence-gating in {@link useContractorSignatureForm}.\n *\n * @remarks\n * A pass-through field is present when its API key is in `document.fields`. The\n * synthesized classification fields (`taxClassification`,\n * `llcClassificationCode`) are present when the document carries any of the\n * federal tax classification checkbox fields.\n *\n * @param document - The W-9 document returned by the API.\n * @returns The set of present camelCase field names.\n * @internal\n */\nexport function getPresentFieldNames(document: Document): Set<string> {\n const byKey = indexFields(document)\n const presentFieldNames = new Set<string>()\n\n for (const [fieldName, apiKey] of Object.entries(W9_FIELD_API_KEYS)) {\n if (byKey.has(apiKey)) presentFieldNames.add(fieldName)\n }\n\n const hasClassification = TAX_CLASSIFICATION_OPTION_KEYS.some(key => byKey.has(key))\n if (hasClassification) {\n presentFieldNames.add(TAX_CLASSIFICATION_FIELD)\n presentFieldNames.add(LLC_CLASSIFICATION_FIELD)\n }\n\n return presentFieldNames\n}\n\n/**\n * Builds default form values from a document's fields.\n *\n * @remarks\n * Pass-through values are seeded from the API `value`. The classification radio\n * defaults to whichever classification checkbox is already set (`'1'`/`'true'`),\n * and when that is the LLC classification the LLC code select is seeded from the\n * `tax_classification` field it serializes into. A masked SSN/EIN seeds an empty\n * input (the mask is surfaced as a placeholder instead) so it is never echoed\n * back as the new value on submit.\n *\n * @param document - The W-9 document returned by the API.\n * @returns The default form values.\n * @internal\n */\nexport function buildW9Defaults(document: Document): ContractorSignatureFormData {\n const byKey = indexFields(document)\n const redaction = getRedactionState(document)\n const textValue = (apiKey: string): string => byKey.get(apiKey)?.value ?? ''\n const selectedClassification =\n TAX_CLASSIFICATION_OPTION_KEYS.find(key => toBoolean(byKey.get(key)?.value)) ?? ''\n\n return {\n name: textValue('name'),\n businessName: textValue('business_name'),\n taxClassification: selectedClassification,\n // The LLC code serializes into the `tax_classification` field, so seed it\n // back from there when the LLC classification is the selected one.\n llcClassificationCode:\n selectedClassification === LLC_CLASSIFICATION_OPTION ? textValue('tax_classification') : '',\n otherText: textValue('other_text'),\n foreignPartners: toBoolean(byKey.get('foreign_partners')?.value),\n exemptPayeeCode: textValue('exempt_payee_code'),\n exemptionFromFatca: textValue('exemption_from_FATCA'),\n homeAddressStreet1: textValue('home_address_street_1'),\n homeAddressStreet2: textValue('home_address_street_2'),\n homeAddressCity: textValue('home_address_city'),\n homeAddressState: textValue('home_address_state'),\n homeAddressZip: textValue('home_address_zip'),\n accountNumber: textValue('account_number'),\n companyName: textValue('company_name'),\n ssn: redaction.ssnRedacted ? '' : textValue('ssn'),\n ein: redaction.einRedacted ? '' : textValue('ein'),\n signatureText: textValue('signature_text'),\n agree: false,\n }\n}\n\n/**\n * The empty default form values, used while the document is still loading.\n *\n * @internal\n */\nexport const EMPTY_W9_DEFAULTS: ContractorSignatureFormData = {\n name: '',\n businessName: '',\n taxClassification: '',\n llcClassificationCode: '',\n otherText: '',\n foreignPartners: false,\n exemptPayeeCode: '',\n exemptionFromFatca: '',\n homeAddressStreet1: '',\n homeAddressStreet2: '',\n homeAddressCity: '',\n homeAddressState: '',\n homeAddressZip: '',\n accountNumber: '',\n companyName: '',\n ssn: '',\n ein: '',\n signatureText: '',\n agree: false,\n}\n\n/**\n * A single `{ key, value }` pair sent in the sign request.\n *\n * @internal\n */\nexport interface SignFieldValue {\n /** The API field key. */\n key: string\n /** The serialized field value. */\n value: string\n}\n\n/** Pass-through text fields serialized verbatim (everything except the checkbox and TIN fields). */\nconst TEXT_PASS_THROUGH_FIELDS: PassThroughFieldName[] = [\n 'name',\n 'businessName',\n 'exemptPayeeCode',\n 'exemptionFromFatca',\n 'homeAddressStreet1',\n 'homeAddressStreet2',\n 'homeAddressCity',\n 'homeAddressState',\n 'homeAddressZip',\n 'accountNumber',\n 'companyName',\n 'signatureText',\n]\n\n/**\n * Serializes W-9 form values into the `{ key, value }` field array expected by\n * the sign API.\n *\n * @remarks\n * Only fields the API returned (see {@link getPresentFieldNames}) are sent.\n * Applies the W-9 mapping: the chosen classification key is sent with value\n * `'1'`; when the LLC classification is chosen, the selected LLC code is sent\n * under the `tax_classification` key. `foreignPartners` serializes to\n * `'1'`/`'0'`. The `otherText` value is only included for the \"Other\"\n * classification. An untouched redacted SSN/EIN is omitted so the mask is never\n * sent back. The `date` field is intentionally omitted so the API auto-fills the\n * signing date in its own locale-correct format.\n *\n * @param document - The W-9 document being signed.\n * @param values - The validated form values.\n * @param redaction - The redaction state from {@link getRedactionState}.\n * @returns The ordered field array for the sign request body.\n * @internal\n */\nexport function serializeW9Fields(\n document: Document,\n values: ContractorSignatureFormData,\n redaction: W9RedactionState,\n): SignFieldValue[] {\n const presentFieldNames = getPresentFieldNames(document)\n const fields: SignFieldValue[] = []\n // The schema preprocesses empty inputs to `undefined`, so read through an\n // `unknown` view and coalesce missing values to an empty string.\n const raw = values as Record<string, unknown>\n const text = (name: string): string => {\n const value = raw[name]\n return typeof value === 'string' ? value : ''\n }\n const classification = text('taxClassification')\n\n const pushField = (fieldName: PassThroughFieldName, value: string) => {\n fields.push({ key: W9_FIELD_API_KEYS[fieldName], value })\n }\n\n for (const fieldName of TEXT_PASS_THROUGH_FIELDS) {\n if (!presentFieldNames.has(fieldName)) continue\n pushField(fieldName, text(fieldName))\n }\n\n if (presentFieldNames.has(OTHER_TEXT_FIELD) && classification === OTHER_CLASSIFICATION_OPTION) {\n pushField('otherText', text('otherText'))\n }\n\n if (presentFieldNames.has('foreignPartners')) {\n fields.push({\n key: W9_FIELD_API_KEYS.foreignPartners,\n value: values.foreignPartners ? '1' : '0',\n })\n }\n\n // A redacted field left untouched is omitted so the masked value isn't sent\n // back as a replacement; the server keeps the value already on file.\n const ssnValue = text('ssn')\n const einValue = text('ein')\n if (presentFieldNames.has('ssn') && !(redaction.ssnRedacted && ssnValue === '')) {\n pushField('ssn', ssnValue)\n }\n if (presentFieldNames.has('ein') && !(redaction.einRedacted && einValue === '')) {\n pushField('ein', einValue)\n }\n\n if (classification) {\n fields.push({ key: classification, value: '1' })\n if (classification === LLC_CLASSIFICATION_OPTION) {\n fields.push({ key: 'tax_classification', value: text('llcClassificationCode') })\n }\n }\n\n return fields\n}\n"],"names":["W9_DOCUMENT_NAME","NOT_APPLICABLE_VALUE","TAX_CLASSIFICATION_FIELD","LLC_CLASSIFICATION_FIELD","OTHER_TEXT_FIELD","TAX_CLASSIFICATION_OPTION_KEYS","LLC_CLASSIFICATION_OPTION","OTHER_CLASSIFICATION_OPTION","LLC_CLASSIFICATION_CODES","W9_FIELD_API_KEYS","SENSITIVE_FIELD_KEYS","isMaskedValue","value","hasRedactedValue","field","indexFields","document","byKey","toBoolean","isW9Document","getRedactionState","ssnField","einField","ssnRedacted","einRedacted","getPresentFieldNames","presentFieldNames","fieldName","apiKey","key","buildW9Defaults","redaction","textValue","selectedClassification","EMPTY_W9_DEFAULTS","TEXT_PASS_THROUGH_FIELDS","serializeW9Fields","values","fields","raw","text","name","classification","pushField","ssnValue","einValue"],"mappings":"AAYO,MAAMA,IAAmB,oCAUnBC,IAAuB,OAOvBC,IAA2B,qBAO3BC,IAA2B,yBAO3BC,IAAmB,aAQnBC,IAAiC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAcaC,IAAwD,6BAOxDC,IAA0D,SAO1DC,IAA2B,CAAC,KAAK,KAAK,GAAG,GASzCC,IAAoB;AAAA,EAC/B,MAAM;AAAA,EACN,cAAc;AAAA,EACd,WAAW;AAAA,EACX,iBAAiB;AAAA,EACjB,iBAAiB;AAAA,EACjB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,aAAa;AAAA,EACb,KAAK;AAAA,EACL,KAAK;AAAA,EACL,eAAe;AACjB,GAMMC,IAAuB,oBAAI,IAAI,CAAC,OAAO,KAAK,CAAC;AAGnD,SAASC,EAAcC,GAA2C;AAChE,SAAO,OAAOA,KAAU,YAAY,QAAQ,KAAKA,CAAK;AACxD;AAGA,SAASC,EAAiBC,GAA2C;AACnE,SAAKA,KAEHJ,EAAqB,IAAII,EAAM,O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K,sBAAsB,OAAOE,EAAK,uBAAuB,GAAG,IAI5EF;AACT;"}
@@ -27,7 +27,7 @@ import { OnboardingFlowProps } from './OnboardingFlowComponents';
27
27
  * | `contractor/onboarding/continue` | Fired when the user chooses to continue onboarding a contractor | — |
28
28
  * | `contractor/created` | Fired when a new contractor is created successfully | Create contractor API response |
29
29
  * | `contractor/updated` | Fired when an existing contractor is updated | Update contractor API response |
30
- * | `contractor/profile/done` | Fired when the contractor profile step is complete | `{ contractorId: string, selfOnboarding: boolean }` |
30
+ * | `contractor/profile/done` | Fired when the contractor profile step is complete | `{ contractorId: string, onboardingStatus?: string, selfOnboarding: boolean }` |
31
31
  * | `contractor/address/updated` | Fired when the contractor address is updated | Create or update contractor address API response |
32
32
  * | `contractor/address/done` | Fired when the address step is complete | — |
33
33
  * | `contractor/bankAccount/created` | Fired when a bank account is created for the contractor | Create contractor bank account API response |
@@ -1 +1 @@
1
- {"version":3,"file":"OnboardingFlow.js","sources":["../../../../src/components/Contractor/OnboardingFlow/OnboardingFlow.tsx"],"sourcesContent":["import { createMachine } from 'robot3'\nimport { useMemo } from 'react'\nimport { onboardingMachine } from './onboardingStateMachine'\nimport type { OnboardingFlowProps } from './OnboardingFlowComponents'\nimport {\n ContractorListContextual,\n type OnboardingFlowContextInterface,\n} from './OnboardingFlowComponents'\nimport { Flow } from '@/components/Flow/Flow'\n\n/**\n * Guided flow for admins to onboard a contractor to the company.\n *\n * @remarks\n * Renders a multi-step experience that collects every piece of information\n * required to add a contractor to a company. Begins on the contractor list\n * and transitions into the per-step screens when \"Add contractor\" or a row's\n * \"Edit\"/\"Continue\" action is invoked; the submit step returns to the list.\n * The flow is driven by an internal state machine and wraps each step in\n * error and suspense boundaries.\n *\n * Each step of the flow is also exported as a standalone block (see the\n * Blocks table) for composing a custom workflow when this orchestration\n * is the wrong fit.\n *\n * The flow forwards every event emitted by its blocks to `onEvent`;\n * see the events table on each block for the full set of events and\n * payloads observable from this flow.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `contractor/create` | Fired when the user chooses to add a new contractor | — |\n * | `contractor/update` | Fired when the user selects a contractor to edit | `{ contractorId: string }` |\n * | `contractor/deleted` | Fired when a contractor is deleted | `{ contractorId: string }` |\n * | `contractor/onboarding/continue` | Fired when the user chooses to continue onboarding a contractor | — |\n * | `contractor/created` | Fired when a new contractor is created successfully | Create contractor API response |\n * | `contractor/updated` | Fired when an existing contractor is updated | Update contractor API response |\n * | `contractor/profile/done` | Fired when the contractor profile step is complete | `{ contractorId: string, selfOnboarding: boolean }` |\n * | `contractor/address/updated` | Fired when the contractor address is updated | Create or update contractor address API response |\n * | `contractor/address/done` | Fired when the address step is complete | — |\n * | `contractor/bankAccount/created` | Fired when a bank account is created for the contractor | Create contractor bank account API response |\n * | `contractor/paymentMethod/updated` | Fired when the payment method is updated | Update contractor payment method API response |\n * | `contractor/paymentMethod/done` | Fired when the payment method step is complete | — |\n * | `contractor/newHireReport/updated` | Fired when the new hire report is updated | Update contractor API response |\n * | `contractor/newHireReport/done` | Fired when the new hire report step is complete | — |\n * | `contractor/onboardingStatus/updated` | Fired when the contractor's onboarding status is updated | Change contractor onboarding status API response |\n * | `contractor/submit/done` | Fired when the contractor submission is complete | `{ message: string }` or `{ onboardingStatus, message: string }` |\n * | `contractor/invite/selfOnboarding` | Fired when the contractor is invited for self-onboarding | `{ contractorId: string }` |\n *\n * @components\n * - {@link ContractorList}\n * - {@link ContractorProfile}\n * - {@link Address}\n * - {@link PaymentMethod}\n * - {@link NewHireReport}\n * - {@link ContractorSubmit}\n *\n * @param props - See {@link OnboardingFlowProps}.\n * @returns The multi-step onboarding flow with internal navigation between the contractor list and the per-step screens.\n * @public\n *\n * @example\n * ```tsx title=\"App.tsx\"\n * import { ContractorOnboarding, type EventType } from '@gusto/embedded-react-sdk'\n *\n * function MyApp() {\n * return (\n * <ContractorOnboarding.OnboardingFlow\n * companyId=\"a007e1ab-3595-43c2-ab4b-af7a5af2e365\"\n * onEvent={(eventType: EventType) => {\n * if (eventType === 'contractor/submit/done') {\n * // Contractor onboarding complete — navigate to your next screen\n * }\n * }}\n * />\n * )\n * }\n * ```\n */\nexport const OnboardingFlow = ({ companyId, onEvent, defaultValues }: OnboardingFlowProps) => {\n const onboardingFlow = useMemo(\n () =>\n createMachine(\n 'list',\n onboardingMachine,\n (initialContext: OnboardingFlowContextInterface) => ({\n ...initialContext,\n component: ContractorListContextual,\n companyId,\n defaultValues,\n selfOnboarding: false,\n }),\n ),\n [companyId, defaultValues],\n )\n return <Flow machine={onboardingFlow} onEvent={onEvent} />\n}\n"],"names":["OnboardingFlow","companyId","onEvent","defaultValues","onboardingFlow","useMemo","createMachine","onboardingMachine","initialContext","ContractorListContextual","jsx","Flow"],"mappings":";;;;;;AAgFO,MAAMA,IAAiB,CAAC,EAAE,WAAAC,GAAW,SAAAC,GAAS,eAAAC,QAAyC;AAC5F,QAAMC,IAAiBC;AAAA,IACrB,MACEC;AAAA,MACE;AAAA,MACAC;AAAA,MACA,CAACC,OAAoD;AAAA,QACnD,GAAGA;AAAA,QACH,WAAWC;AAAA,QACX,WAAAR;AAAA,QACA,eAAAE;AAAA,QACA,gBAAgB;AAAA,MAAA;AAAA,IAClB;AAAA,IAEJ,CAACF,GAAWE,CAAa;AAAA,EAAA;AAE3B,SAAO,gBAAAO,EAACC,GAAA,EAAK,SAASP,GAAgB,SAAAF,EAAA,CAAkB;AAC1D;"}
1
+ {"version":3,"file":"OnboardingFlow.js","sources":["../../../../src/components/Contractor/OnboardingFlow/OnboardingFlow.tsx"],"sourcesContent":["import { createMachine } from 'robot3'\nimport { useMemo } from 'react'\nimport { onboardingMachine } from './onboardingStateMachine'\nimport type { OnboardingFlowProps } from './OnboardingFlowComponents'\nimport {\n ContractorListContextual,\n type OnboardingFlowContextInterface,\n} from './OnboardingFlowComponents'\nimport { Flow } from '@/components/Flow/Flow'\n\n/**\n * Guided flow for admins to onboard a contractor to the company.\n *\n * @remarks\n * Renders a multi-step experience that collects every piece of information\n * required to add a contractor to a company. Begins on the contractor list\n * and transitions into the per-step screens when \"Add contractor\" or a row's\n * \"Edit\"/\"Continue\" action is invoked; the submit step returns to the list.\n * The flow is driven by an internal state machine and wraps each step in\n * error and suspense boundaries.\n *\n * Each step of the flow is also exported as a standalone block (see the\n * Blocks table) for composing a custom workflow when this orchestration\n * is the wrong fit.\n *\n * The flow forwards every event emitted by its blocks to `onEvent`;\n * see the events table on each block for the full set of events and\n * payloads observable from this flow.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `contractor/create` | Fired when the user chooses to add a new contractor | — |\n * | `contractor/update` | Fired when the user selects a contractor to edit | `{ contractorId: string }` |\n * | `contractor/deleted` | Fired when a contractor is deleted | `{ contractorId: string }` |\n * | `contractor/onboarding/continue` | Fired when the user chooses to continue onboarding a contractor | — |\n * | `contractor/created` | Fired when a new contractor is created successfully | Create contractor API response |\n * | `contractor/updated` | Fired when an existing contractor is updated | Update contractor API response |\n * | `contractor/profile/done` | Fired when the contractor profile step is complete | `{ contractorId: string, onboardingStatus?: string, selfOnboarding: boolean }` |\n * | `contractor/address/updated` | Fired when the contractor address is updated | Create or update contractor address API response |\n * | `contractor/address/done` | Fired when the address step is complete | — |\n * | `contractor/bankAccount/created` | Fired when a bank account is created for the contractor | Create contractor bank account API response |\n * | `contractor/paymentMethod/updated` | Fired when the payment method is updated | Update contractor payment method API response |\n * | `contractor/paymentMethod/done` | Fired when the payment method step is complete | — |\n * | `contractor/newHireReport/updated` | Fired when the new hire report is updated | Update contractor API response |\n * | `contractor/newHireReport/done` | Fired when the new hire report step is complete | — |\n * | `contractor/onboardingStatus/updated` | Fired when the contractor's onboarding status is updated | Change contractor onboarding status API response |\n * | `contractor/submit/done` | Fired when the contractor submission is complete | `{ message: string }` or `{ onboardingStatus, message: string }` |\n * | `contractor/invite/selfOnboarding` | Fired when the contractor is invited for self-onboarding | `{ contractorId: string }` |\n *\n * @components\n * - {@link ContractorList}\n * - {@link ContractorProfile}\n * - {@link Address}\n * - {@link PaymentMethod}\n * - {@link NewHireReport}\n * - {@link ContractorSubmit}\n *\n * @param props - See {@link OnboardingFlowProps}.\n * @returns The multi-step onboarding flow with internal navigation between the contractor list and the per-step screens.\n * @public\n *\n * @example\n * ```tsx title=\"App.tsx\"\n * import { ContractorOnboarding, type EventType } from '@gusto/embedded-react-sdk'\n *\n * function MyApp() {\n * return (\n * <ContractorOnboarding.OnboardingFlow\n * companyId=\"a007e1ab-3595-43c2-ab4b-af7a5af2e365\"\n * onEvent={(eventType: EventType) => {\n * if (eventType === 'contractor/submit/done') {\n * // Contractor onboarding complete — navigate to your next screen\n * }\n * }}\n * />\n * )\n * }\n * ```\n */\nexport const OnboardingFlow = ({ companyId, onEvent, defaultValues }: OnboardingFlowProps) => {\n const onboardingFlow = useMemo(\n () =>\n createMachine(\n 'list',\n onboardingMachine,\n (initialContext: OnboardingFlowContextInterface) => ({\n ...initialContext,\n component: ContractorListContextual,\n companyId,\n defaultValues,\n selfOnboarding: false,\n }),\n ),\n [companyId, defaultValues],\n )\n return <Flow machine={onboardingFlow} onEvent={onEvent} />\n}\n"],"names":["OnboardingFlow","companyId","onEvent","defaultValues","onboardingFlow","useMemo","createMachine","onboardingMachine","initialContext","ContractorListContextual","jsx","Flow"],"mappings":";;;;;;AAgFO,MAAMA,IAAiB,CAAC,EAAE,WAAAC,GAAW,SAAAC,GAAS,eAAAC,QAAyC;AAC5F,QAAMC,IAAiBC;AAAA,IACrB,MACEC;AAAA,MACE;AAAA,MACAC;AAAA,MACA,CAACC,OAAoD;AAAA,QACnD,GAAGA;AAAA,QACH,WAAWC;AAAA,QACX,WAAAR;AAAA,QACA,eAAAE;AAAA,QACA,gBAAgB;AAAA,MAAA;AAAA,IAClB;AAAA,IAEJ,CAACF,GAAWE,CAAa;AAAA,EAAA;AAE3B,SAAO,gBAAAO,EAACC,GAAA,EAAK,SAASP,GAAgB,SAAAF,EAAA,CAAkB;AAC1D;"}
@@ -34,6 +34,8 @@ export interface OnboardingFlowContextInterface extends FlowContextInterface {
34
34
  defaultValues?: OnboardingFlowDefaultValues;
35
35
  /** True when the contractor will be self-onboarding; switches the flow to the shorter self-onboarding path. */
36
36
  selfOnboarding?: boolean;
37
+ /** True while the new hire report step should be shown; false once the contractor has advanced past the admin's initial onboarding pass. */
38
+ showNewHireReport?: boolean;
37
39
  /** Success message to display on the contractor list when returning from a completed sub-flow. */
38
40
  successMessage?: string;
39
41
  }
@@ -1 +1 @@
1
- {"version":3,"file":"OnboardingFlowComponents.js","sources":["../../../../src/components/Contractor/OnboardingFlow/OnboardingFlowComponents.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { ContractorList } from '../ContractorList'\nimport { ContractorProfile } from '../Profile'\nimport { Address } from '../Address'\nimport { PaymentMethod } from '../PaymentMethod/PaymentMethod'\nimport { NewHireReport } from '../NewHireReport/NewHireReport'\nimport { ContractorSubmit } from '../Submit/Submit'\nimport type { ContractorDetailsFormData } from '../Profile/shared'\nimport type { AddressDefaultValues } from '../Address'\nimport { useFlow, type FlowContextInterface } from '@/components/Flow/useFlow'\nimport type { RequireAtLeastOne } from '@/types/Helpers'\nimport type { BaseComponentInterface } from '@/components/Base'\nimport { ensureRequired } from '@/helpers/ensureRequired'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\n\n/**\n * Default pre-fill values for the contractor onboarding flow.\n * At least one of `profile` or `address` must be provided.\n *\n * @public\n */\nexport type OnboardingFlowDefaultValues = RequireAtLeastOne<{\n profile?: Partial<ContractorDetailsFormData>\n address?: AddressDefaultValues\n}>\n/**\n * Props for {@link OnboardingFlow}.\n *\n * @public\n */\nexport interface OnboardingFlowProps extends BaseComponentInterface<never> {\n /** The associated company identifier. */\n companyId: string\n /** Default values for individual flow step components — `profile` and/or `address` sub-objects. */\n defaultValues?: RequireAtLeastOne<OnboardingFlowDefaultValues>\n}\n/** @internal */\nexport interface OnboardingFlowContextInterface extends FlowContextInterface {\n /** The associated company identifier. */\n companyId: string\n /** The contractor currently being onboarded; populated once the profile step creates or selects one. */\n contractorId?: string\n /** Default values for individual flow step components. */\n defaultValues?: OnboardingFlowDefaultValues\n /** True when the contractor will be self-onboarding; switches the flow to the shorter self-onboarding path. */\n selfOnboarding?: boolean\n /** Success message to display on the contractor list when returning from a completed sub-flow. */\n successMessage?: string\n}\n\n/** @internal */\nexport function ContractorListContextual() {\n const { companyId, onEvent, successMessage } = useFlow<OnboardingFlowContextInterface>()\n return (\n <ContractorList\n onEvent={onEvent}\n companyId={ensureRequired(companyId)}\n successMessage={successMessage}\n />\n )\n}\n\n/** @internal */\nexport function ProfileContextual() {\n const { companyId, onEvent, contractorId, defaultValues } =\n useFlow<OnboardingFlowContextInterface>()\n return (\n <ContractorProfile\n onEvent={onEvent}\n companyId={ensureRequired(companyId)}\n contractorId={contractorId}\n defaultValues={defaultValues?.profile}\n />\n )\n}\n\n/** @internal */\nexport function AddressContextual() {\n const { onEvent, contractorId, defaultValues } = useFlow<OnboardingFlowContextInterface>()\n return (\n <Address\n onEvent={onEvent}\n contractorId={ensureRequired(contractorId)}\n defaultValues={defaultValues?.address}\n />\n )\n}\n/** @internal */\nexport function PaymentMethodContextual() {\n const { onEvent, contractorId } = useFlow<OnboardingFlowContextInterface>()\n return <PaymentMethod onEvent={onEvent} contractorId={ensureRequired(contractorId)} />\n}\n/** @internal */\nexport function NewHireReportContextual() {\n const { onEvent, contractorId, selfOnboarding } = useFlow<OnboardingFlowContextInterface>()\n return (\n <NewHireReport\n onEvent={onEvent}\n contractorId={ensureRequired(contractorId)}\n selfOnboarding={selfOnboarding}\n />\n )\n}\n/** @internal */\nexport function SubmitContextual() {\n const { onEvent, contractorId, selfOnboarding } = useFlow<OnboardingFlowContextInterface>()\n return (\n <ContractorSubmit\n onEvent={onEvent}\n contractorId={ensureRequired(contractorId)}\n selfOnboarding={selfOnboarding}\n />\n )\n}\n\n/** @internal */\nexport function ProgressBarCta() {\n const { onEvent } = useFlow<OnboardingFlowContextInterface>()\n const { Button } = useComponentContext()\n useI18n('Contractor.ContractorList')\n const { t } = useTranslation('Contractor.ContractorList')\n return (\n <Button\n onClick={() => {\n onEvent(componentEvents.CANCEL)\n }}\n variant=\"secondary\"\n >\n {t('progressBarCta')}\n </Button>\n )\n}\n"],"names":["ContractorListContextual","companyId","onEvent","successMessage","useFlow","jsx","ContractorList","ensureRequired","ProfileContextual","contractorId","defaultValues","ContractorProfile","AddressContextual","Address","PaymentMethodContextual","PaymentMethod","NewHireReportContextual","selfOnboarding","NewHireReport","SubmitContextual","ContractorSubmit","ProgressBarCta","Button","useComponentContext","useI18n","t","useTranslation","componentEvents"],"mappings":";;;;;;;;;;;;;AAqDO,SAASA,IAA2B;AACzC,QAAM,EAAE,WAAAC,GAAW,SAAAC,GAAS,gBAAAC,EAAA,IAAmBC,EAAA;AAC/C,SACE,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,SAAAJ;AAAA,MACA,WAAWK,EAAeN,CAAS;AAAA,MACnC,gBAAAE;AAAA,IAAA;AAAA,EAAA;AAGN;AAGO,SAASK,IAAoB;AAClC,QAAM,EAAE,WAAAP,GAAW,SAAAC,GAAS,cAAAO,GAAc,eAAAC,EAAA,IACxCN,EAAA;AACF,SACE,gBAAAC;AAAA,IAACM;AAAA,IAAA;AAAA,MACC,SAAAT;AAAA,MACA,WAAWK,EAAeN,CAAS;AAAA,MACnC,cAAAQ;AAAA,MACA,eAAeC,GAAe;AAAA,IAAA;AAAA,EAAA;AAGpC;AAGO,SAASE,IAAoB;AAClC,QAAM,EAAE,SAAAV,GAAS,cAAAO,GAAc,eAAAC,EAAA,IAAkBN,EAAA;AACjD,SACE,gBAAAC;AAAA,IAACQ;AAAA,IAAA;AAAA,MACC,SAAAX;AAAA,MACA,cAAcK,EAAeE,CAAY;AAAA,MACzC,eAAeC,GAAe;AAAA,IAAA;AAAA,EAAA;AAGpC;AAEO,SAASI,IAA0B;AACxC,QAAM,EAAE,SAAAZ,GAAS,cAAAO,EAAA,IAAiBL,EAAA;AAClC,2BAAQW,GAAA,EAAc,SAAAb,GAAkB,cAAcK,EAAeE,CAAY,GAAG;AACtF;AAEO,SAASO,IAA0B;AACxC,QAAM,EAAE,SAAAd,GAAS,cAAAO,GAAc,gBAAAQ,EAAA,IAAmBb,EAAA;AAClD,SACE,gBAAAC;AAAA,IAACa;AAAA,IAAA;AAAA,MACC,SAAAhB;AAAA,MACA,cAAcK,EAAeE,CAAY;AAAA,MACzC,gBAAAQ;AAAA,IAAA;AAAA,EAAA;AAGN;AAEO,SAASE,IAAmB;AACjC,QAAM,EAAE,SAAAjB,GAAS,cAAAO,GAAc,gBAAAQ,EAAA,IAAmBb,EAAA;AAClD,SACE,gBAAAC;AAAA,IAACe;AAAA,IAAA;AAAA,MACC,SAAAlB;AAAA,MACA,cAAcK,EAAeE,CAAY;AAAA,MACzC,gBAAAQ;AAAA,IAAA;AAAA,EAAA;AAGN;AAGO,SAASI,IAAiB;AAC/B,QAAM,EAAE,SAAAnB,EAAA,IAAYE,EAAA,GACd,EAAE,QAAAkB,EAAA,IAAWC,EAAA;AACnB,EAAAC,EAAQ,2BAA2B;AACnC,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,2BAA2B;AACxD,SACE,gBAAArB;AAAA,IAACiB;AAAA,IAAA;AAAA,MACC,SAAS,MAAM;AACb,QAAApB,EAAQyB,EAAgB,MAAM;AAAA,MAChC;AAAA,MACA,SAAQ;AAAA,MAEP,YAAE,gBAAgB;AAAA,IAAA;AAAA,EAAA;AAGzB;"}
1
+ {"version":3,"file":"OnboardingFlowComponents.js","sources":["../../../../src/components/Contractor/OnboardingFlow/OnboardingFlowComponents.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { ContractorList } from '../ContractorList'\nimport { ContractorProfile } from '../Profile'\nimport { Address } from '../Address'\nimport { PaymentMethod } from '../PaymentMethod/PaymentMethod'\nimport { NewHireReport } from '../NewHireReport/NewHireReport'\nimport { ContractorSubmit } from '../Submit/Submit'\nimport type { ContractorDetailsFormData } from '../Profile/shared'\nimport type { AddressDefaultValues } from '../Address'\nimport { useFlow, type FlowContextInterface } from '@/components/Flow/useFlow'\nimport type { RequireAtLeastOne } from '@/types/Helpers'\nimport type { BaseComponentInterface } from '@/components/Base'\nimport { ensureRequired } from '@/helpers/ensureRequired'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\n\n/**\n * Default pre-fill values for the contractor onboarding flow.\n * At least one of `profile` or `address` must be provided.\n *\n * @public\n */\nexport type OnboardingFlowDefaultValues = RequireAtLeastOne<{\n profile?: Partial<ContractorDetailsFormData>\n address?: AddressDefaultValues\n}>\n/**\n * Props for {@link OnboardingFlow}.\n *\n * @public\n */\nexport interface OnboardingFlowProps extends BaseComponentInterface<never> {\n /** The associated company identifier. */\n companyId: string\n /** Default values for individual flow step components — `profile` and/or `address` sub-objects. */\n defaultValues?: RequireAtLeastOne<OnboardingFlowDefaultValues>\n}\n/** @internal */\nexport interface OnboardingFlowContextInterface extends FlowContextInterface {\n /** The associated company identifier. */\n companyId: string\n /** The contractor currently being onboarded; populated once the profile step creates or selects one. */\n contractorId?: string\n /** Default values for individual flow step components. */\n defaultValues?: OnboardingFlowDefaultValues\n /** True when the contractor will be self-onboarding; switches the flow to the shorter self-onboarding path. */\n selfOnboarding?: boolean\n /** True while the new hire report step should be shown; false once the contractor has advanced past the admin's initial onboarding pass. */\n showNewHireReport?: boolean\n /** Success message to display on the contractor list when returning from a completed sub-flow. */\n successMessage?: string\n}\n\n/** @internal */\nexport function ContractorListContextual() {\n const { companyId, onEvent, successMessage } = useFlow<OnboardingFlowContextInterface>()\n return (\n <ContractorList\n onEvent={onEvent}\n companyId={ensureRequired(companyId)}\n successMessage={successMessage}\n />\n )\n}\n\n/** @internal */\nexport function ProfileContextual() {\n const { companyId, onEvent, contractorId, defaultValues } =\n useFlow<OnboardingFlowContextInterface>()\n return (\n <ContractorProfile\n onEvent={onEvent}\n companyId={ensureRequired(companyId)}\n contractorId={contractorId}\n defaultValues={defaultValues?.profile}\n />\n )\n}\n\n/** @internal */\nexport function AddressContextual() {\n const { onEvent, contractorId, defaultValues } = useFlow<OnboardingFlowContextInterface>()\n return (\n <Address\n onEvent={onEvent}\n contractorId={ensureRequired(contractorId)}\n defaultValues={defaultValues?.address}\n />\n )\n}\n/** @internal */\nexport function PaymentMethodContextual() {\n const { onEvent, contractorId } = useFlow<OnboardingFlowContextInterface>()\n return <PaymentMethod onEvent={onEvent} contractorId={ensureRequired(contractorId)} />\n}\n/** @internal */\nexport function NewHireReportContextual() {\n const { onEvent, contractorId, selfOnboarding } = useFlow<OnboardingFlowContextInterface>()\n return (\n <NewHireReport\n onEvent={onEvent}\n contractorId={ensureRequired(contractorId)}\n selfOnboarding={selfOnboarding}\n />\n )\n}\n/** @internal */\nexport function SubmitContextual() {\n const { onEvent, contractorId, selfOnboarding } = useFlow<OnboardingFlowContextInterface>()\n return (\n <ContractorSubmit\n onEvent={onEvent}\n contractorId={ensureRequired(contractorId)}\n selfOnboarding={selfOnboarding}\n />\n )\n}\n\n/** @internal */\nexport function ProgressBarCta() {\n const { onEvent } = useFlow<OnboardingFlowContextInterface>()\n const { Button } = useComponentContext()\n useI18n('Contractor.ContractorList')\n const { t } = useTranslation('Contractor.ContractorList')\n return (\n <Button\n onClick={() => {\n onEvent(componentEvents.CANCEL)\n }}\n variant=\"secondary\"\n >\n {t('progressBarCta')}\n </Button>\n )\n}\n"],"names":["ContractorListContextual","companyId","onEvent","successMessage","useFlow","jsx","ContractorList","ensureRequired","ProfileContextual","contractorId","defaultValues","ContractorProfile","AddressContextual","Address","PaymentMethodContextual","PaymentMethod","NewHireReportContextual","selfOnboarding","NewHireReport","SubmitContextual","ContractorSubmit","ProgressBarCta","Button","useComponentContext","useI18n","t","useTranslation","componentEvents"],"mappings":";;;;;;;;;;;;;A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