@gusto/embedded-react-sdk 0.37.0-rc.1 → 0.37.0

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 (240) hide show
  1. package/CHANGELOG.md +44 -8
  2. package/README.md +6 -0
  3. package/dist/UNSTABLE_Hooks.d.ts +1 -1
  4. package/dist/UNSTABLE_Hooks.js +50 -6
  5. package/dist/UNSTABLE_Hooks.js.map +1 -1
  6. package/dist/components/Base/Base.d.ts +2 -1
  7. package/dist/components/Base/Base.js +78 -77
  8. package/dist/components/Base/Base.js.map +1 -1
  9. package/dist/components/Common/Fields/CheckboxField/CheckboxField.d.ts +2 -0
  10. package/dist/components/Common/Fields/CheckboxField/CheckboxField.js +17 -16
  11. package/dist/components/Common/Fields/CheckboxField/CheckboxField.js.map +1 -1
  12. package/dist/components/Common/Fields/DatePickerField/DatePickerField.d.ts +5 -3
  13. package/dist/components/Common/Fields/DatePickerField/DatePickerField.js +46 -36
  14. package/dist/components/Common/Fields/DatePickerField/DatePickerField.js.map +1 -1
  15. package/dist/components/Common/Fields/NumberInputField/NumberInputField.d.ts +2 -0
  16. package/dist/components/Common/Fields/NumberInputField/NumberInputField.js +21 -20
  17. package/dist/components/Common/Fields/NumberInputField/NumberInputField.js.map +1 -1
  18. package/dist/components/Common/Fields/RadioGroupField/RadioGroupField.d.ts +3 -1
  19. package/dist/components/Common/Fields/RadioGroupField/RadioGroupField.js +20 -19
  20. package/dist/components/Common/Fields/RadioGroupField/RadioGroupField.js.map +1 -1
  21. package/dist/components/Common/Fields/SelectField/SelectField.d.ts +3 -1
  22. package/dist/components/Common/Fields/SelectField/SelectField.js +19 -18
  23. package/dist/components/Common/Fields/SelectField/SelectField.js.map +1 -1
  24. package/dist/components/Common/Fields/SwitchField/SwitchField.d.ts +2 -0
  25. package/dist/components/Common/Fields/SwitchField/SwitchField.js +19 -18
  26. package/dist/components/Common/Fields/SwitchField/SwitchField.js.map +1 -1
  27. package/dist/components/Common/Fields/TextInputField/TextInputField.d.ts +2 -0
  28. package/dist/components/Common/Fields/TextInputField/TextInputField.js +10 -9
  29. package/dist/components/Common/Fields/TextInputField/TextInputField.js.map +1 -1
  30. package/dist/components/Common/SignatureForm/SignatureFormActions.js +1 -1
  31. package/dist/components/Common/SignatureForm/SignatureFormFields.js +1 -1
  32. package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.js +5 -6
  33. package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatoryForm.js.map +1 -1
  34. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +9 -6
  35. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
  36. package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.js +4 -5
  37. package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.js.map +1 -1
  38. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +9 -6
  39. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
  40. package/dist/components/Company/AssignSignatory/useAssignSignatory.js +11 -8
  41. package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
  42. package/dist/components/Company/BankAccount/BankAccountForm/context.js +9 -6
  43. package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
  44. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +9 -6
  45. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  46. package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js +9 -6
  47. package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
  48. package/dist/components/Company/FederalTaxes/useFederalTaxes.js +15 -12
  49. package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
  50. package/dist/components/Company/Industry/Context.js +12 -9
  51. package/dist/components/Company/Industry/Context.js.map +1 -1
  52. package/dist/components/Company/Locations/LocationForm/Form.js +4 -5
  53. package/dist/components/Company/Locations/LocationForm/Form.js.map +1 -1
  54. package/dist/components/Company/Locations/LocationForm/useLocationForm.js +9 -6
  55. package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
  56. package/dist/components/Company/Locations/LocationsList/useLocationsList.js +9 -6
  57. package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
  58. package/dist/components/Company/OnboardingOverview/context.js +9 -6
  59. package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
  60. package/dist/components/Company/PaySchedule/_parts/Edit.js +9 -10
  61. package/dist/components/Company/PaySchedule/_parts/Edit.js.map +1 -1
  62. package/dist/components/Company/PaySchedule/usePaySchedule.js +11 -8
  63. package/dist/components/Company/PaySchedule/usePaySchedule.js.map +1 -1
  64. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +9 -6
  65. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
  66. package/dist/components/Company/StateTaxes/StateTaxesList/context.js +9 -6
  67. package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
  68. package/dist/components/Contractor/Address/Form.js +6 -7
  69. package/dist/components/Contractor/Address/Form.js.map +1 -1
  70. package/dist/components/Contractor/Address/useAddress.js +11 -8
  71. package/dist/components/Contractor/Address/useAddress.js.map +1 -1
  72. package/dist/components/Contractor/Payments/CreatePayment/EditContractorPaymentPresentation.js +2 -3
  73. package/dist/components/Contractor/Payments/CreatePayment/EditContractorPaymentPresentation.js.map +1 -1
  74. package/dist/components/Contractor/Profile/useContractorProfile.js +21 -16
  75. package/dist/components/Contractor/Profile/useContractorProfile.js.map +1 -1
  76. package/dist/components/Employee/Deductions/DeductionsForm/ChildSupportForm.js +14 -11
  77. package/dist/components/Employee/Deductions/DeductionsForm/ChildSupportForm.js.map +1 -1
  78. package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.js +13 -10
  79. package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.js.map +1 -1
  80. package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.js +6 -3
  81. package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.js.map +1 -1
  82. package/dist/components/Employee/Deductions/IncludeDeductions/IncludeDeductions.js +2 -3
  83. package/dist/components/Employee/Deductions/IncludeDeductions/IncludeDeductions.js.map +1 -1
  84. package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js +9 -6
  85. package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  86. package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js +9 -6
  87. package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
  88. package/dist/components/Employee/EmployeeList/useEmployeeList.js +9 -6
  89. package/dist/components/Employee/EmployeeList/useEmployeeList.js.map +1 -1
  90. package/dist/components/Employee/FederalTaxes/useFederalTaxes.js +9 -6
  91. package/dist/components/Employee/FederalTaxes/useFederalTaxes.js.map +1 -1
  92. package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +11 -8
  93. package/dist/components/Employee/PaymentMethod/usePaymentMethod.js.map +1 -1
  94. package/dist/components/Employee/Profile/HomeAddress.d.ts +3 -3
  95. package/dist/components/Employee/Profile/HomeAddress.js +44 -43
  96. package/dist/components/Employee/Profile/HomeAddress.js.map +1 -1
  97. package/dist/components/Employee/Profile/PersonalDetailsInputs.js +14 -15
  98. package/dist/components/Employee/Profile/PersonalDetailsInputs.js.map +1 -1
  99. package/dist/components/Employee/Profile/useProfile.js +9 -6
  100. package/dist/components/Employee/Profile/useProfile.js.map +1 -1
  101. package/dist/components/Employee/StateTaxes/useStateTaxes.js +9 -6
  102. package/dist/components/Employee/StateTaxes/useStateTaxes.js.map +1 -1
  103. package/dist/components/Employee/Taxes/useTaxes.js +9 -6
  104. package/dist/components/Employee/Taxes/useTaxes.js.map +1 -1
  105. package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +16 -13
  106. package/dist/components/Payroll/GrossUpModal/GrossUpModal.js.map +1 -1
  107. package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js +2 -3
  108. package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js.map +1 -1
  109. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js +185 -177
  110. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js.map +1 -1
  111. package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js +2 -3
  112. package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js.map +1 -1
  113. package/dist/components/Payroll/usePreparedPayrollData.js +7 -5
  114. package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
  115. package/dist/components/UNSTABLE_Hooks/collectErrors.d.ts +6 -0
  116. package/dist/components/UNSTABLE_Hooks/collectErrors.js +9 -0
  117. package/dist/components/UNSTABLE_Hooks/collectErrors.js.map +1 -0
  118. package/dist/components/UNSTABLE_Hooks/form/FormFieldsMetadataContext.d.ts +1 -1
  119. package/dist/components/UNSTABLE_Hooks/form/FormFieldsMetadataContext.js +3 -3
  120. package/dist/components/UNSTABLE_Hooks/form/FormFieldsMetadataContext.js.map +1 -1
  121. package/dist/components/UNSTABLE_Hooks/form/FormFieldsMetadataProvider.d.ts +2 -2
  122. package/dist/components/UNSTABLE_Hooks/form/FormFieldsMetadataProvider.js +13 -0
  123. package/dist/components/UNSTABLE_Hooks/form/FormFieldsMetadataProvider.js.map +1 -0
  124. package/dist/components/UNSTABLE_Hooks/form/SDKFormProvider.d.ts +11 -6
  125. package/dist/components/UNSTABLE_Hooks/form/SDKFormProvider.js +24 -0
  126. package/dist/components/UNSTABLE_Hooks/form/SDKFormProvider.js.map +1 -0
  127. package/dist/components/UNSTABLE_Hooks/form/composeFormSchema.d.ts +26 -0
  128. package/dist/components/UNSTABLE_Hooks/form/composeFormSchema.js +24 -0
  129. package/dist/components/UNSTABLE_Hooks/form/composeFormSchema.js.map +1 -0
  130. package/dist/components/UNSTABLE_Hooks/form/composeSubmitHandler.d.ts +53 -0
  131. package/dist/components/UNSTABLE_Hooks/form/composeSubmitHandler.js +34 -0
  132. package/dist/components/UNSTABLE_Hooks/form/composeSubmitHandler.js.map +1 -0
  133. package/dist/components/UNSTABLE_Hooks/form/composeSubmitHandler.test.d.ts +1 -0
  134. package/dist/components/UNSTABLE_Hooks/form/deriveFieldsMetadata.js +14 -0
  135. package/dist/components/UNSTABLE_Hooks/form/deriveFieldsMetadata.js.map +1 -0
  136. package/dist/components/UNSTABLE_Hooks/form/fields/CheckboxHookField.d.ts +9 -0
  137. package/dist/components/UNSTABLE_Hooks/form/fields/CheckboxHookField.js +34 -0
  138. package/dist/components/UNSTABLE_Hooks/form/fields/CheckboxHookField.js.map +1 -0
  139. package/dist/components/UNSTABLE_Hooks/form/fields/DatePickerHookField.d.ts +9 -0
  140. package/dist/components/UNSTABLE_Hooks/form/fields/DatePickerHookField.js +29 -0
  141. package/dist/components/UNSTABLE_Hooks/form/fields/DatePickerHookField.js.map +1 -0
  142. package/dist/components/UNSTABLE_Hooks/form/fields/NumberInputHookField.d.ts +12 -0
  143. package/dist/components/UNSTABLE_Hooks/form/fields/NumberInputHookField.js +40 -0
  144. package/dist/components/UNSTABLE_Hooks/form/fields/NumberInputHookField.js.map +1 -0
  145. package/dist/components/UNSTABLE_Hooks/form/fields/RadioGroupHookField.d.ts +10 -0
  146. package/dist/components/UNSTABLE_Hooks/form/fields/RadioGroupHookField.js +40 -0
  147. package/dist/components/UNSTABLE_Hooks/form/fields/RadioGroupHookField.js.map +1 -0
  148. package/dist/components/UNSTABLE_Hooks/form/fields/SelectHookField.d.ts +10 -0
  149. package/dist/components/UNSTABLE_Hooks/form/fields/SelectHookField.js +40 -0
  150. package/dist/components/UNSTABLE_Hooks/form/fields/SelectHookField.js.map +1 -0
  151. package/dist/components/UNSTABLE_Hooks/form/fields/SwitchHookField.d.ts +9 -0
  152. package/dist/components/UNSTABLE_Hooks/form/fields/SwitchHookField.js +34 -0
  153. package/dist/components/UNSTABLE_Hooks/form/fields/SwitchHookField.js.map +1 -0
  154. package/dist/components/UNSTABLE_Hooks/form/fields/TextInputHookField.d.ts +11 -0
  155. package/dist/components/UNSTABLE_Hooks/form/fields/TextInputHookField.js +38 -0
  156. package/dist/components/UNSTABLE_Hooks/form/fields/TextInputHookField.js.map +1 -0
  157. package/dist/components/UNSTABLE_Hooks/form/fields/index.d.ts +15 -0
  158. package/dist/components/UNSTABLE_Hooks/form/getFieldWithOptions.d.ts +2 -0
  159. package/dist/components/UNSTABLE_Hooks/form/getFieldWithOptions.js +8 -0
  160. package/dist/components/UNSTABLE_Hooks/form/getFieldWithOptions.js.map +1 -0
  161. package/dist/components/UNSTABLE_Hooks/form/getFormSubmissionValues.d.ts +18 -0
  162. package/dist/components/UNSTABLE_Hooks/form/getFormSubmissionValues.js +10 -0
  163. package/dist/components/UNSTABLE_Hooks/form/getFormSubmissionValues.js.map +1 -0
  164. package/dist/components/UNSTABLE_Hooks/form/getFormSubmissionValues.test.d.ts +1 -0
  165. package/dist/components/UNSTABLE_Hooks/form/index.d.ts +6 -1
  166. package/dist/components/UNSTABLE_Hooks/form/resolveRequiredFields.d.ts +6 -0
  167. package/dist/components/UNSTABLE_Hooks/form/resolveRequiredFields.js +14 -0
  168. package/dist/components/UNSTABLE_Hooks/form/resolveRequiredFields.js.map +1 -0
  169. package/dist/components/UNSTABLE_Hooks/form/types.d.ts +12 -0
  170. package/dist/components/UNSTABLE_Hooks/form/useFieldErrorMessage.d.ts +2 -1
  171. package/dist/components/UNSTABLE_Hooks/form/useFieldErrorMessage.js +10 -8
  172. package/dist/components/UNSTABLE_Hooks/form/useFieldErrorMessage.js.map +1 -1
  173. package/dist/components/UNSTABLE_Hooks/form/useFieldsMetadata.d.ts +2 -2
  174. package/dist/components/UNSTABLE_Hooks/form/useFieldsMetadata.js.map +1 -1
  175. package/dist/components/UNSTABLE_Hooks/form/withOptions.js +7 -0
  176. package/dist/components/UNSTABLE_Hooks/form/withOptions.js.map +1 -0
  177. package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/CompensationForm.d.ts +5 -0
  178. package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/CompensationForm.js +151 -0
  179. package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/CompensationForm.js.map +1 -0
  180. package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/compensationSchema.d.ts +97 -0
  181. package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/compensationSchema.js +121 -0
  182. package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/compensationSchema.js.map +1 -0
  183. package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/fields.d.ts +34 -0
  184. package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/fields.js +50 -0
  185. package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/fields.js.map +1 -0
  186. package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/index.d.ts +5 -1
  187. package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/useCompensationForm.d.ts +97 -9
  188. package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/useCompensationForm.js +255 -3
  189. package/dist/components/UNSTABLE_Hooks/hooks/useCompensationForm/useCompensationForm.js.map +1 -1
  190. package/dist/components/UNSTABLE_Hooks/hooks/useEmployeeDetailsForm/EmployeeDetailsForm.d.ts +5 -0
  191. package/dist/components/UNSTABLE_Hooks/hooks/useEmployeeDetailsForm/EmployeeDetailsForm.js +114 -0
  192. package/dist/components/UNSTABLE_Hooks/hooks/useEmployeeDetailsForm/EmployeeDetailsForm.js.map +1 -0
  193. package/dist/components/UNSTABLE_Hooks/hooks/useEmployeeDetailsForm/employeeDetailsSchema.d.ts +39 -0
  194. package/dist/components/UNSTABLE_Hooks/hooks/useEmployeeDetailsForm/employeeDetailsSchema.js +45 -0
  195. package/dist/components/UNSTABLE_Hooks/hooks/useEmployeeDetailsForm/employeeDetailsSchema.js.map +1 -0
  196. package/dist/components/UNSTABLE_Hooks/hooks/useEmployeeDetailsForm/fields.d.ts +23 -0
  197. package/dist/components/UNSTABLE_Hooks/hooks/useEmployeeDetailsForm/fields.js +46 -0
  198. package/dist/components/UNSTABLE_Hooks/hooks/useEmployeeDetailsForm/fields.js.map +1 -0
  199. package/dist/components/UNSTABLE_Hooks/hooks/useEmployeeDetailsForm/index.d.ts +7 -0
  200. package/dist/components/UNSTABLE_Hooks/hooks/useEmployeeDetailsForm/useEmployeeDetailsForm.d.ts +77 -0
  201. package/dist/components/UNSTABLE_Hooks/hooks/useEmployeeDetailsForm/useEmployeeDetailsForm.js +153 -0
  202. package/dist/components/UNSTABLE_Hooks/hooks/useEmployeeDetailsForm/useEmployeeDetailsForm.js.map +1 -0
  203. package/dist/components/UNSTABLE_Hooks/hooks/useWorkAddressForm/WorkAddressForm.d.ts +5 -0
  204. package/dist/components/UNSTABLE_Hooks/hooks/useWorkAddressForm/WorkAddressForm.js +71 -0
  205. package/dist/components/UNSTABLE_Hooks/hooks/useWorkAddressForm/WorkAddressForm.js.map +1 -0
  206. package/dist/components/UNSTABLE_Hooks/hooks/useWorkAddressForm/fields.d.ts +10 -0
  207. package/dist/components/UNSTABLE_Hooks/hooks/useWorkAddressForm/fields.js +14 -0
  208. package/dist/components/UNSTABLE_Hooks/hooks/useWorkAddressForm/fields.js.map +1 -0
  209. package/dist/components/UNSTABLE_Hooks/hooks/useWorkAddressForm/index.d.ts +7 -0
  210. package/dist/components/UNSTABLE_Hooks/hooks/useWorkAddressForm/useWorkAddressForm.d.ts +68 -0
  211. package/dist/components/UNSTABLE_Hooks/hooks/useWorkAddressForm/useWorkAddressForm.js +129 -0
  212. package/dist/components/UNSTABLE_Hooks/hooks/useWorkAddressForm/useWorkAddressForm.js.map +1 -0
  213. package/dist/components/UNSTABLE_Hooks/hooks/useWorkAddressForm/workAddressSchema.d.ts +25 -0
  214. package/dist/components/UNSTABLE_Hooks/hooks/useWorkAddressForm/workAddressSchema.js +24 -0
  215. package/dist/components/UNSTABLE_Hooks/hooks/useWorkAddressForm/workAddressSchema.js.map +1 -0
  216. package/dist/components/UNSTABLE_Hooks/index.d.ts +8 -4
  217. package/dist/components/UNSTABLE_Hooks/types.d.ts +9 -6
  218. package/dist/components/UNSTABLE_Hooks/useErrorHandling.d.ts +9 -0
  219. package/dist/components/UNSTABLE_Hooks/useErrorHandling.js +12 -0
  220. package/dist/components/UNSTABLE_Hooks/useErrorHandling.js.map +1 -0
  221. package/dist/components/UNSTABLE_Hooks/useErrorHandling.test.d.ts +1 -0
  222. package/dist/helpers/requiredIf.d.ts +13 -0
  223. package/dist/helpers/requiredIf.js +8 -0
  224. package/dist/helpers/requiredIf.js.map +1 -0
  225. package/dist/i18n/I18n.js +5 -5
  226. package/dist/i18n/I18n.js.map +1 -1
  227. package/dist/i18n/en/UNSTABLE.CompensationForm.json.js +58 -0
  228. package/dist/i18n/en/UNSTABLE.CompensationForm.json.js.map +1 -0
  229. package/dist/i18n/en/UNSTABLE.EmployeeDetailsForm.json.js +34 -0
  230. package/dist/i18n/en/UNSTABLE.EmployeeDetailsForm.json.js.map +1 -0
  231. package/dist/i18n/en/UNSTABLE.WorkAddressForm.json.js +24 -0
  232. package/dist/i18n/en/UNSTABLE.WorkAddressForm.json.js.map +1 -0
  233. package/dist/models/WA_RISK_CODES.d.ts +5 -2866
  234. package/dist/models/WA_RISK_CODES.js.map +1 -1
  235. package/dist/style.css +1 -1
  236. package/dist/types/i18next.d.ts +117 -1
  237. package/dist/types/sdkError.d.ts +7 -1
  238. package/dist/types/sdkError.js.map +1 -1
  239. package/docs/reference/endpoint-inventory.json +92 -0
  240. package/package.json +9 -9
@@ -0,0 +1,121 @@
1
+ import { z as e } from "zod";
2
+ import { composeFormSchema as u } from "../../form/composeFormSchema.js";
3
+ import { filterRequiredFields as M } from "../../form/resolveRequiredFields.js";
4
+ import { FlsaStatus as t, FLSA_OVERTIME_SALARY_LIMIT as R, PAY_PERIODS as r } from "../../../../shared/constants.js";
5
+ import { yearlyRate as N } from "../../../../helpers/payRateCalculator.js";
6
+ const a = {
7
+ REQUIRED: "REQUIRED",
8
+ RATE_MINIMUM: "RATE_MINIMUM",
9
+ RATE_EXEMPT_THRESHOLD: "RATE_EXEMPT_THRESHOLD",
10
+ PAYMENT_UNIT_OWNER: "PAYMENT_UNIT_OWNER",
11
+ PAYMENT_UNIT_COMMISSION: "PAYMENT_UNIT_COMMISSION",
12
+ RATE_COMMISSION_ZERO: "RATE_COMMISSION_ZERO"
13
+ }, O = {
14
+ jobTitle: e.string().min(1, { message: a.REQUIRED }),
15
+ flsaStatus: e.enum([
16
+ t.EXEMPT,
17
+ t.SALARIED_NONEXEMPT,
18
+ t.NONEXEMPT,
19
+ t.OWNER,
20
+ t.COMMISSION_ONLY_EXEMPT,
21
+ t.COMMISSION_ONLY_NONEXEMPT
22
+ ]),
23
+ paymentUnit: e.enum([
24
+ r.HOUR,
25
+ r.WEEK,
26
+ r.MONTH,
27
+ r.YEAR,
28
+ r.PAYCHECK
29
+ ]),
30
+ rate: e.number().optional(),
31
+ startDate: e.iso.date().nullable().optional(),
32
+ adjustForMinimumWage: e.boolean(),
33
+ minimumWageId: e.string().optional(),
34
+ stateWcCovered: e.boolean().optional(),
35
+ stateWcClassCode: e.string().optional(),
36
+ twoPercentShareholder: e.boolean().optional()
37
+ }, c = /* @__PURE__ */ new Set([
38
+ "adjustForMinimumWage",
39
+ "minimumWageId",
40
+ "stateWcCovered",
41
+ "stateWcClassCode",
42
+ "twoPercentShareholder"
43
+ ]), S = {
44
+ ...O,
45
+ rate: e.preprocess((s) => Number.isNaN(s) ? void 0 : s, e.number()),
46
+ startDate: e.preprocess((s) => {
47
+ if (s instanceof Date) return s.toISOString().split("T")[0];
48
+ if (!(s === null || s === ""))
49
+ return s;
50
+ }, e.iso.date()),
51
+ stateWcCovered: e.preprocess((s) => typeof s == "string" ? s === "true" : s, e.boolean()).optional()
52
+ }, T = /* @__PURE__ */ new Set([
53
+ "jobTitle",
54
+ "flsaStatus",
55
+ "rate",
56
+ "paymentUnit"
57
+ ]), _ = /* @__PURE__ */ new Set([]);
58
+ function C(s, o) {
59
+ s.adjustForMinimumWage && (!s.minimumWageId || s.minimumWageId.trim() === "") && o.addIssue({
60
+ code: e.ZodIssueCode.custom,
61
+ path: ["minimumWageId"],
62
+ message: a.REQUIRED
63
+ }), s.stateWcCovered === !0 && (!s.stateWcClassCode || s.stateWcClassCode.trim() === "") && o.addIssue({
64
+ code: e.ZodIssueCode.custom,
65
+ path: ["stateWcClassCode"],
66
+ message: a.REQUIRED
67
+ });
68
+ const { flsaStatus: i, paymentUnit: E, rate: d } = s;
69
+ i === t.EXEMPT || i === t.SALARIED_NONEXEMPT || i === t.NONEXEMPT ? (i === t.EXEMPT && d !== void 0 && N(d, E) < R && o.addIssue({
70
+ code: e.ZodIssueCode.custom,
71
+ path: ["rate"],
72
+ message: a.RATE_EXEMPT_THRESHOLD
73
+ }), d === void 0 ? o.addIssue({
74
+ code: e.ZodIssueCode.custom,
75
+ path: ["rate"],
76
+ message: a.REQUIRED
77
+ }) : d < 1 && o.addIssue({
78
+ code: e.ZodIssueCode.custom,
79
+ path: ["rate"],
80
+ message: a.RATE_MINIMUM
81
+ })) : i === t.OWNER ? (E !== r.PAYCHECK && o.addIssue({
82
+ code: e.ZodIssueCode.custom,
83
+ path: ["paymentUnit"],
84
+ message: a.PAYMENT_UNIT_OWNER
85
+ }), d === void 0 ? o.addIssue({
86
+ code: e.ZodIssueCode.custom,
87
+ path: ["rate"],
88
+ message: a.REQUIRED
89
+ }) : d < 1 && o.addIssue({
90
+ code: e.ZodIssueCode.custom,
91
+ path: ["rate"],
92
+ message: a.RATE_MINIMUM
93
+ })) : [t.COMMISSION_ONLY_EXEMPT, t.COMMISSION_ONLY_NONEXEMPT].includes(i) && (E !== r.YEAR && o.addIssue({
94
+ code: e.ZodIssueCode.custom,
95
+ path: ["paymentUnit"],
96
+ message: a.PAYMENT_UNIT_COMMISSION
97
+ }), d !== 0 && o.addIssue({
98
+ code: e.ZodIssueCode.custom,
99
+ path: ["rate"],
100
+ message: a.RATE_COMMISSION_ZERO
101
+ }));
102
+ }
103
+ function p(s = {}) {
104
+ const { mode: o = "create", requiredFields: i, withStartDateField: E = !0 } = s, d = E ? i : M(i, "startDate"), n = new Set(T);
105
+ return E && n.add("startDate"), u({
106
+ fieldValidators: S,
107
+ fixedFields: c,
108
+ requiredOnCreate: n,
109
+ requiredOnUpdate: _,
110
+ mode: o,
111
+ requiredFields: d
112
+ }).superRefine((I, m) => {
113
+ C(I, m);
114
+ });
115
+ }
116
+ p();
117
+ export {
118
+ a as CompensationErrorCodes,
119
+ p as createCompensationSchema
120
+ };
121
+ //# sourceMappingURL=compensationSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compensationSchema.js","sources":["../../../../../src/components/UNSTABLE_Hooks/hooks/useCompensationForm/compensationSchema.ts"],"sourcesContent":["import { z } from 'zod'\nimport { composeFormSchema } from '../../form/composeFormSchema'\nimport { filterRequiredFields, type RequiredFields } from '../../form/resolveRequiredFields'\nimport { FLSA_OVERTIME_SALARY_LIMIT, FlsaStatus, PAY_PERIODS } from '@/shared/constants'\nimport { yearlyRate } from '@/helpers/payRateCalculator'\n\nexport const CompensationErrorCodes = {\n REQUIRED: 'REQUIRED',\n RATE_MINIMUM: 'RATE_MINIMUM',\n RATE_EXEMPT_THRESHOLD: 'RATE_EXEMPT_THRESHOLD',\n PAYMENT_UNIT_OWNER: 'PAYMENT_UNIT_OWNER',\n PAYMENT_UNIT_COMMISSION: 'PAYMENT_UNIT_COMMISSION',\n RATE_COMMISSION_ZERO: 'RATE_COMMISSION_ZERO',\n} as const\n\nexport type CompensationErrorCode =\n (typeof CompensationErrorCodes)[keyof typeof CompensationErrorCodes]\n\nconst fieldValidators = {\n jobTitle: z.string().min(1, { message: CompensationErrorCodes.REQUIRED }),\n flsaStatus: z.enum([\n FlsaStatus.EXEMPT,\n FlsaStatus.SALARIED_NONEXEMPT,\n FlsaStatus.NONEXEMPT,\n FlsaStatus.OWNER,\n FlsaStatus.COMMISSION_ONLY_EXEMPT,\n FlsaStatus.COMMISSION_ONLY_NONEXEMPT,\n ]),\n paymentUnit: z.enum([\n PAY_PERIODS.HOUR,\n PAY_PERIODS.WEEK,\n PAY_PERIODS.MONTH,\n PAY_PERIODS.YEAR,\n PAY_PERIODS.PAYCHECK,\n ]),\n rate: z.number().optional(),\n startDate: z.iso.date().nullable().optional(),\n adjustForMinimumWage: z.boolean(),\n minimumWageId: z.string().optional(),\n stateWcCovered: z.boolean().optional(),\n stateWcClassCode: z.string().optional(),\n twoPercentShareholder: z.boolean().optional(),\n}\n\nconst FIXED_FIELDS = new Set([\n 'adjustForMinimumWage',\n 'minimumWageId',\n 'stateWcCovered',\n 'stateWcClassCode',\n 'twoPercentShareholder',\n])\n\nexport type CompensationField = Exclude<\n keyof typeof fieldValidators,\n | 'adjustForMinimumWage'\n | 'minimumWageId'\n | 'stateWcCovered'\n | 'stateWcClassCode'\n | 'twoPercentShareholder'\n>\n\nexport type CompensationFormData = {\n [K in keyof typeof fieldValidators]: z.infer<(typeof fieldValidators)[K]>\n}\nexport type CompensationFormOutputs = CompensationFormData\n\nconst runtimeFieldValidators = {\n ...fieldValidators,\n rate: z.preprocess(val => (Number.isNaN(val) ? undefined : val), z.number()),\n startDate: z.preprocess(val => {\n if (val instanceof Date) return val.toISOString().split('T')[0]\n if (val === null || val === '') return undefined\n return val\n }, z.iso.date()),\n stateWcCovered: z\n .preprocess(val => (typeof val === 'string' ? val === 'true' : val), z.boolean())\n .optional(),\n}\n\nconst REQUIRED_ON_CREATE = new Set<CompensationField>([\n 'jobTitle',\n 'flsaStatus',\n 'rate',\n 'paymentUnit',\n])\nconst REQUIRED_ON_UPDATE = new Set<CompensationField>([])\n\ninterface CompensationSchemaOptions {\n mode?: 'create' | 'update'\n requiredFields?: RequiredFields<CompensationField>\n withStartDateField?: boolean\n}\n\nfunction compensationSuperRefine(data: CompensationFormData, ctx: z.RefinementCtx) {\n if (data.adjustForMinimumWage && (!data.minimumWageId || data.minimumWageId.trim() === '')) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['minimumWageId'],\n message: CompensationErrorCodes.REQUIRED,\n })\n }\n\n if (\n data.stateWcCovered === true &&\n (!data.stateWcClassCode || data.stateWcClassCode.trim() === '')\n ) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['stateWcClassCode'],\n message: CompensationErrorCodes.REQUIRED,\n })\n }\n\n const { flsaStatus, paymentUnit, rate } = data\n\n if (\n flsaStatus === FlsaStatus.EXEMPT ||\n flsaStatus === FlsaStatus.SALARIED_NONEXEMPT ||\n flsaStatus === FlsaStatus.NONEXEMPT\n ) {\n if (\n flsaStatus === FlsaStatus.EXEMPT &&\n rate !== undefined &&\n yearlyRate(rate, paymentUnit) < FLSA_OVERTIME_SALARY_LIMIT\n ) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['rate'],\n message: CompensationErrorCodes.RATE_EXEMPT_THRESHOLD,\n })\n }\n\n if (rate === undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['rate'],\n message: CompensationErrorCodes.REQUIRED,\n })\n } else if (rate < 1) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['rate'],\n message: CompensationErrorCodes.RATE_MINIMUM,\n })\n }\n } else if (flsaStatus === FlsaStatus.OWNER) {\n if (paymentUnit !== PAY_PERIODS.PAYCHECK) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['paymentUnit'],\n message: CompensationErrorCodes.PAYMENT_UNIT_OWNER,\n })\n }\n if (rate === undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['rate'],\n message: CompensationErrorCodes.REQUIRED,\n })\n } else if (rate < 1) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['rate'],\n message: CompensationErrorCodes.RATE_MINIMUM,\n })\n }\n } else if (\n [FlsaStatus.COMMISSION_ONLY_EXEMPT, FlsaStatus.COMMISSION_ONLY_NONEXEMPT].includes(flsaStatus)\n ) {\n if (paymentUnit !== PAY_PERIODS.YEAR) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['paymentUnit'],\n message: CompensationErrorCodes.PAYMENT_UNIT_COMMISSION,\n })\n }\n if (rate !== 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['rate'],\n message: CompensationErrorCodes.RATE_COMMISSION_ZERO,\n })\n }\n }\n}\n\nexport function createCompensationSchema(options: CompensationSchemaOptions = {}) {\n const { mode = 'create', requiredFields, withStartDateField = true } = options\n\n const effectiveRequiredFields = withStartDateField\n ? requiredFields\n : filterRequiredFields(requiredFields, 'startDate')\n\n const effectiveRequiredOnCreate = new Set(REQUIRED_ON_CREATE)\n if (withStartDateField) {\n effectiveRequiredOnCreate.add('startDate')\n }\n\n const baseSchema = composeFormSchema({\n fieldValidators: runtimeFieldValidators,\n fixedFields: FIXED_FIELDS,\n requiredOnCreate: effectiveRequiredOnCreate,\n requiredOnUpdate: REQUIRED_ON_UPDATE,\n mode,\n requiredFields: effectiveRequiredFields,\n })\n\n return baseSchema.superRefine((data, ctx) => {\n compensationSuperRefine(data as CompensationFormData, ctx)\n })\n}\n\nexport const CompensationSchema = createCompensationSchema()\n"],"names":["CompensationErrorCodes","fieldValidators","z","FlsaStatus","PAY_PERIODS","FIXED_FIELDS","runtimeFieldValidators","val","REQUIRED_ON_CREATE","REQUIRED_ON_UPDATE","compensationSuperRefine","data","ctx","flsaStatus","paymentUnit","rate","yearlyRate","FLSA_OVERTIME_SALARY_LIMIT","createCompensationSchema","options","mode","requiredFields","withStartDateField","effectiveRequiredFields","filterRequiredFields","effectiveRequiredOnCreate","composeFormSchema"],"mappings":"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"}
@@ -0,0 +1,34 @@
1
+ import { MinimumWage } from '@gusto/embedded-api/models/components/minimumwage';
2
+ import { FlsaStatusType } from '@gusto/embedded-api/models/components/flsastatustype';
3
+ import { PaymentUnit } from '@gusto/embedded-api/models/components/compensation';
4
+ import { HookFieldProps } from '../../form/types';
5
+ import { TextInputHookFieldProps } from '../../form/fields/TextInputHookField';
6
+ import { SelectHookFieldProps } from '../../form/fields/SelectHookField';
7
+ import { NumberInputHookFieldProps } from '../../form/fields/NumberInputHookField';
8
+ import { CheckboxHookFieldProps } from '../../form/fields/CheckboxHookField';
9
+ import { RadioGroupHookFieldProps } from '../../form/fields/RadioGroupHookField';
10
+ import { DatePickerHookFieldProps } from '../../form/fields/DatePickerHookField';
11
+ import { CompensationErrorCodes } from './compensationSchema';
12
+ import { WARiskClassCode } from '../../../../models/WA_RISK_CODES';
13
+ export type RequiredValidation = typeof CompensationErrorCodes.REQUIRED;
14
+ export type RateValidation = (typeof CompensationErrorCodes)['REQUIRED' | 'RATE_MINIMUM' | 'RATE_EXEMPT_THRESHOLD'];
15
+ export type JobTitleFieldProps = HookFieldProps<TextInputHookFieldProps<RequiredValidation>>;
16
+ export declare function JobTitleField(props: JobTitleFieldProps): import("react/jsx-runtime").JSX.Element;
17
+ export type FlsaStatusFieldProps = HookFieldProps<SelectHookFieldProps<RequiredValidation, FlsaStatusType>>;
18
+ export declare function FlsaStatusField(props: FlsaStatusFieldProps): import("react/jsx-runtime").JSX.Element;
19
+ export type RateFieldProps = HookFieldProps<NumberInputHookFieldProps<RateValidation>>;
20
+ export declare function RateField(props: RateFieldProps): import("react/jsx-runtime").JSX.Element;
21
+ export type PaymentUnitFieldProps = HookFieldProps<SelectHookFieldProps<RequiredValidation, PaymentUnit>>;
22
+ export declare function PaymentUnitField(props: PaymentUnitFieldProps): import("react/jsx-runtime").JSX.Element;
23
+ export type AdjustForMinimumWageFieldProps = HookFieldProps<CheckboxHookFieldProps>;
24
+ export declare function AdjustForMinimumWageField(props: AdjustForMinimumWageFieldProps): import("react/jsx-runtime").JSX.Element;
25
+ export type MinimumWageIdFieldProps = HookFieldProps<SelectHookFieldProps<RequiredValidation, MinimumWage>>;
26
+ export declare function MinimumWageIdField(props: MinimumWageIdFieldProps): import("react/jsx-runtime").JSX.Element;
27
+ export type TwoPercentShareholderFieldProps = HookFieldProps<CheckboxHookFieldProps>;
28
+ export declare function TwoPercentShareholderField(props: TwoPercentShareholderFieldProps): import("react/jsx-runtime").JSX.Element;
29
+ export type StateWcCoveredFieldProps = HookFieldProps<RadioGroupHookFieldProps<never, string>>;
30
+ export declare function StateWcCoveredField(props: StateWcCoveredFieldProps): import("react/jsx-runtime").JSX.Element;
31
+ export type StateWcClassCodeFieldProps = HookFieldProps<SelectHookFieldProps<RequiredValidation, WARiskClassCode>>;
32
+ export declare function StateWcClassCodeField(props: StateWcClassCodeFieldProps): import("react/jsx-runtime").JSX.Element;
33
+ export type StartDateFieldProps = HookFieldProps<DatePickerHookFieldProps<typeof CompensationErrorCodes.REQUIRED>>;
34
+ export declare function StartDateField(props: StartDateFieldProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,50 @@
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { SelectHookField as n } from "../../form/fields/SelectHookField.js";
3
+ import { RadioGroupHookField as o } from "../../form/fields/RadioGroupHookField.js";
4
+ import { CheckboxHookField as r } from "../../form/fields/CheckboxHookField.js";
5
+ import { NumberInputHookField as i } from "../../form/fields/NumberInputHookField.js";
6
+ import { TextInputHookField as a } from "../../form/fields/TextInputHookField.js";
7
+ import { DatePickerHookField as m } from "../../form/fields/DatePickerHookField.js";
8
+ function p(e) {
9
+ return /* @__PURE__ */ t(a, { ...e, name: "jobTitle" });
10
+ }
11
+ function k(e) {
12
+ return /* @__PURE__ */ t(n, { ...e, name: "flsaStatus" });
13
+ }
14
+ function S(e) {
15
+ return /* @__PURE__ */ t(i, { ...e, name: "rate", format: "currency", min: 0 });
16
+ }
17
+ function W(e) {
18
+ return /* @__PURE__ */ t(n, { ...e, name: "paymentUnit" });
19
+ }
20
+ function C(e) {
21
+ return /* @__PURE__ */ t(r, { ...e, name: "adjustForMinimumWage" });
22
+ }
23
+ function H(e) {
24
+ return /* @__PURE__ */ t(n, { ...e, name: "minimumWageId" });
25
+ }
26
+ function h(e) {
27
+ return /* @__PURE__ */ t(r, { ...e, name: "twoPercentShareholder" });
28
+ }
29
+ function b(e) {
30
+ return /* @__PURE__ */ t(o, { ...e, name: "stateWcCovered" });
31
+ }
32
+ function g(e) {
33
+ return /* @__PURE__ */ t(n, { ...e, name: "stateWcClassCode" });
34
+ }
35
+ function j(e) {
36
+ return /* @__PURE__ */ t(m, { ...e, name: "startDate" });
37
+ }
38
+ export {
39
+ C as AdjustForMinimumWageField,
40
+ k as FlsaStatusField,
41
+ p as JobTitleField,
42
+ H as MinimumWageIdField,
43
+ W as PaymentUnitField,
44
+ S as RateField,
45
+ j as StartDateField,
46
+ g as StateWcClassCodeField,
47
+ b as StateWcCoveredField,
48
+ h as TwoPercentShareholderField
49
+ };
50
+ //# sourceMappingURL=fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.js","sources":["../../../../../src/components/UNSTABLE_Hooks/hooks/useCompensationForm/fields.tsx"],"sourcesContent":["import type { MinimumWage } from '@gusto/embedded-api/models/components/minimumwage'\nimport type { FlsaStatusType } from '@gusto/embedded-api/models/components/flsastatustype'\nimport type { PaymentUnit } from '@gusto/embedded-api/models/components/compensation'\nimport type { HookFieldProps } from '../../form/types'\nimport type { TextInputHookFieldProps } from '../../form/fields/TextInputHookField'\nimport type { SelectHookFieldProps } from '../../form/fields/SelectHookField'\nimport type { NumberInputHookFieldProps } from '../../form/fields/NumberInputHookField'\nimport type { CheckboxHookFieldProps } from '../../form/fields/CheckboxHookField'\nimport type { RadioGroupHookFieldProps } from '../../form/fields/RadioGroupHookField'\nimport type { DatePickerHookFieldProps } from '../../form/fields/DatePickerHookField'\nimport {\n TextInputHookField,\n SelectHookField,\n NumberInputHookField,\n CheckboxHookField,\n RadioGroupHookField,\n DatePickerHookField,\n} from '../../form/fields'\nimport type { CompensationErrorCodes } from './compensationSchema'\nimport type { WARiskClassCode } from '@/models/WA_RISK_CODES'\n\nexport type RequiredValidation = typeof CompensationErrorCodes.REQUIRED\nexport type RateValidation = (typeof CompensationErrorCodes)[\n | 'REQUIRED'\n | 'RATE_MINIMUM'\n | 'RATE_EXEMPT_THRESHOLD']\n\nexport type JobTitleFieldProps = HookFieldProps<TextInputHookFieldProps<RequiredValidation>>\n\nexport function JobTitleField(props: JobTitleFieldProps) {\n return <TextInputHookField {...props} name=\"jobTitle\" />\n}\n\nexport type FlsaStatusFieldProps = HookFieldProps<\n SelectHookFieldProps<RequiredValidation, FlsaStatusType>\n>\n\nexport function FlsaStatusField(props: FlsaStatusFieldProps) {\n return <SelectHookField {...props} name=\"flsaStatus\" />\n}\n\nexport type RateFieldProps = HookFieldProps<NumberInputHookFieldProps<RateValidation>>\n\nexport function RateField(props: RateFieldProps) {\n return <NumberInputHookField {...props} name=\"rate\" format=\"currency\" min={0} />\n}\n\nexport type PaymentUnitFieldProps = HookFieldProps<\n SelectHookFieldProps<RequiredValidation, PaymentUnit>\n>\n\nexport function PaymentUnitField(props: PaymentUnitFieldProps) {\n return <SelectHookField {...props} name=\"paymentUnit\" />\n}\n\nexport type AdjustForMinimumWageFieldProps = HookFieldProps<CheckboxHookFieldProps>\n\nexport function AdjustForMinimumWageField(props: AdjustForMinimumWageFieldProps) {\n return <CheckboxHookField {...props} name=\"adjustForMinimumWage\" />\n}\n\nexport type MinimumWageIdFieldProps = HookFieldProps<\n SelectHookFieldProps<RequiredValidation, MinimumWage>\n>\n\nexport function MinimumWageIdField(props: MinimumWageIdFieldProps) {\n return <SelectHookField {...props} name=\"minimumWageId\" />\n}\n\nexport type TwoPercentShareholderFieldProps = HookFieldProps<CheckboxHookFieldProps>\n\nexport function TwoPercentShareholderField(props: TwoPercentShareholderFieldProps) {\n return <CheckboxHookField {...props} name=\"twoPercentShareholder\" />\n}\n\nexport type StateWcCoveredFieldProps = HookFieldProps<RadioGroupHookFieldProps<never, string>>\n\nexport function StateWcCoveredField(props: StateWcCoveredFieldProps) {\n return <RadioGroupHookField {...props} name=\"stateWcCovered\" />\n}\n\nexport type StateWcClassCodeFieldProps = HookFieldProps<\n SelectHookFieldProps<RequiredValidation, WARiskClassCode>\n>\n\nexport function StateWcClassCodeField(props: StateWcClassCodeFieldProps) {\n return <SelectHookField {...props} name=\"stateWcClassCode\" />\n}\n\nexport type StartDateFieldProps = HookFieldProps<\n DatePickerHookFieldProps<typeof CompensationErrorCodes.REQUIRED>\n>\n\nexport function StartDateField(props: StartDateFieldProps) {\n return <DatePickerHookField {...props} name=\"startDate\" />\n}\n"],"names":["JobTitleField","props","jsx","TextInputHookField","FlsaStatusField","SelectHookField","RateField","NumberInputHookField","PaymentUnitField","AdjustForMinimumWageField","CheckboxHookField","MinimumWageIdField","TwoPercentShareholderField","StateWcCoveredField","RadioGroupHookField","StateWcClassCodeField","StartDateField","DatePickerHookField"],"mappings":";;;;;;;AA6BO,SAASA,EAAcC,GAA2B;AACvD,SAAO,gBAAAC,EAACC,GAAA,EAAoB,GAAGF,GAAO,MAAK,YAAW;AACxD;AAMO,SAASG,EAAgBH,GAA6B;AAC3D,SAAO,gBAAAC,EAACG,GAAA,EAAiB,GAAGJ,GAAO,MAAK,cAAa;AACvD;AAIO,SAASK,EAAUL,GAAuB;AAC/C,SAAO,gBAAAC,EAACK,KAAsB,GAAGN,GAAO,MAAK,QAAO,QAAO,YAAW,KAAK,EAAA,CAAG;AAChF;AAMO,SAASO,EAAiBP,GAA8B;AAC7D,SAAO,gBAAAC,EAACG,GAAA,EAAiB,GAAGJ,GAAO,MAAK,eAAc;AACxD;AAIO,SAASQ,EAA0BR,GAAuC;AAC/E,SAAO,gBAAAC,EAACQ,GAAA,EAAmB,GAAGT,GAAO,MAAK,wBAAuB;AACnE;AAMO,SAASU,EAAmBV,GAAgC;AACjE,SAAO,gBAAAC,EAACG,GAAA,EAAiB,GAAGJ,GAAO,MAAK,iBAAgB;AAC1D;AAIO,SAASW,EAA2BX,GAAwC;AACjF,SAAO,gBAAAC,EAACQ,GAAA,EAAmB,GAAGT,GAAO,MAAK,yBAAwB;AACpE;AAIO,SAASY,EAAoBZ,GAAiC;AACnE,SAAO,gBAAAC,EAACY,GAAA,EAAqB,GAAGb,GAAO,MAAK,kBAAiB;AAC/D;AAMO,SAASc,EAAsBd,GAAmC;AACvE,SAAO,gBAAAC,EAACG,GAAA,EAAiB,GAAGJ,GAAO,MAAK,oBAAmB;AAC7D;AAMO,SAASe,EAAef,GAA4B;AACzD,SAAO,gBAAAC,EAACe,GAAA,EAAqB,GAAGhB,GAAO,MAAK,aAAY;AAC1D;"}
@@ -1,3 +1,7 @@
1
1
  import "./types/i18next.d.ts"
2
2
  export { useCompensationForm } from './useCompensationForm';
3
- export type { UseCompensationFormProps, UseCompensationFormResult, UseCompensationFormReady, } from './useCompensationForm';
3
+ export type { CompensationSubmitCallbacks, CompensationSubmitOptions, CompensationRequiredFields, UseCompensationFormProps, UseCompensationFormResult, UseCompensationFormReady, CompensationFieldsMetadata, CompensationFormFields, } from './useCompensationForm';
4
+ export { CompensationForm } from './CompensationForm';
5
+ export type { CompensationFormProps } from './CompensationForm';
6
+ export { CompensationSchema, createCompensationSchema, CompensationErrorCodes, type CompensationErrorCode, type CompensationField, type CompensationFormData, type CompensationFormOutputs, } from './compensationSchema';
7
+ export type { RequiredValidation, RateValidation, StartDateFieldProps, JobTitleFieldProps, FlsaStatusFieldProps, RateFieldProps, PaymentUnitFieldProps, AdjustForMinimumWageFieldProps, MinimumWageIdFieldProps, TwoPercentShareholderFieldProps, StateWcCoveredFieldProps, StateWcClassCodeFieldProps, } from './fields';
@@ -1,16 +1,104 @@
1
- import { Compensation } from '@gusto/embedded-api/models/components/compensation';
2
- import { HookLoadingResult, HookSubmitResult, BaseFormHookReady } from '../../types';
3
- export interface UseCompensationFormProps {
1
+ import { UseFormProps } from 'react-hook-form';
2
+ import { Compensation, PaymentUnit } from '@gusto/embedded-api/models/components/compensation';
3
+ import { Job } from '@gusto/embedded-api/models/components/job';
4
+ import { FlsaStatusType } from '@gusto/embedded-api/models/components/flsastatustype';
5
+ import { MinimumWage } from '@gusto/embedded-api/models/components/minimumwage';
6
+ import { HookSubmitResult } from '../../types';
7
+ import { RequiredFields } from '../../form/resolveRequiredFields';
8
+ import { CompensationField, CompensationFormData } from './compensationSchema';
9
+ import { JobTitleField, FlsaStatusField, RateField, PaymentUnitField, AdjustForMinimumWageField, MinimumWageIdField, TwoPercentShareholderField, StateWcCoveredField, StateWcClassCodeField, StartDateField } from './fields';
10
+ import { WARiskClassCode } from '../../../../models/WA_RISK_CODES';
11
+ export interface CompensationSubmitCallbacks {
12
+ onJobCreated?: (job: Job) => void;
13
+ onJobUpdated?: (job: Job) => void;
14
+ onCompensationUpdated?: (compensation: Compensation | undefined) => void;
15
+ }
16
+ export interface CompensationSubmitOptions {
4
17
  employeeId?: string;
5
18
  startDate?: string;
6
19
  }
7
- export interface UseCompensationFormReady extends BaseFormHookReady {
20
+ export type CompensationRequiredFields = RequiredFields<CompensationField>;
21
+ export interface UseCompensationFormProps {
22
+ employeeId?: string;
23
+ withStartDateField?: boolean;
24
+ jobId?: string;
25
+ requiredFields?: CompensationRequiredFields;
26
+ defaultValues?: Partial<CompensationFormData>;
27
+ validationMode?: UseFormProps['mode'];
28
+ shouldFocusError?: boolean;
29
+ }
30
+ export declare function useCompensationForm({ employeeId, withStartDateField, jobId, requiredFields, defaultValues: partnerDefaults, validationMode, shouldFocusError, }: UseCompensationFormProps): {
31
+ isLoading: true;
32
+ errorHandling: import('../..').HookErrorHandling;
33
+ data?: undefined;
34
+ status?: undefined;
35
+ actions?: undefined;
36
+ form?: undefined;
37
+ } | {
38
+ isLoading: false;
8
39
  data: {
9
- compensation: Compensation;
40
+ compensation: Compensation | null;
41
+ jobs: Job[] | undefined;
42
+ currentJob: Job | null;
43
+ minimumWages: MinimumWage[];
44
+ };
45
+ status: {
46
+ isPending: boolean;
47
+ mode: string;
10
48
  };
11
49
  actions: {
12
- onSubmit: () => Promise<HookSubmitResult<Compensation> | undefined>;
50
+ onSubmit: (callbacks?: CompensationSubmitCallbacks, options?: CompensationSubmitOptions) => Promise<HookSubmitResult<Compensation | undefined> | undefined>;
13
51
  };
14
- }
15
- export type UseCompensationFormResult = HookLoadingResult | UseCompensationFormReady;
16
- export declare function useCompensationForm(props: UseCompensationFormProps): UseCompensationFormResult;
52
+ errorHandling: import('../..').HookErrorHandling;
53
+ form: {
54
+ Fields: {
55
+ StartDate: typeof StartDateField | undefined;
56
+ JobTitle: typeof JobTitleField;
57
+ FlsaStatus: typeof FlsaStatusField | undefined;
58
+ Rate: typeof RateField;
59
+ PaymentUnit: typeof PaymentUnitField;
60
+ AdjustForMinimumWage: typeof AdjustForMinimumWageField | undefined;
61
+ MinimumWageId: typeof MinimumWageIdField | undefined;
62
+ TwoPercentShareholder: typeof TwoPercentShareholderField | undefined;
63
+ StateWcCovered: typeof StateWcCoveredField | undefined;
64
+ StateWcClassCode: typeof StateWcClassCodeField | undefined;
65
+ };
66
+ fieldsMetadata: {
67
+ startDate: import('../..').FieldMetadata;
68
+ jobTitle: import('../..').FieldMetadata;
69
+ flsaStatus: import('../..').FieldMetadataWithOptions<FlsaStatusType>;
70
+ rate: {
71
+ isDisabled: boolean;
72
+ name: string;
73
+ isRequired?: boolean;
74
+ hasRedactedValue?: boolean;
75
+ };
76
+ paymentUnit: import('../..').FieldMetadataWithOptions<PaymentUnit>;
77
+ adjustForMinimumWage: {
78
+ isDisabled: boolean;
79
+ name: string;
80
+ isRequired?: boolean;
81
+ hasRedactedValue?: boolean;
82
+ };
83
+ minimumWageId: import('../..').FieldMetadataWithOptions<MinimumWage>;
84
+ twoPercentShareholder: {
85
+ isDisabled: boolean;
86
+ name: string;
87
+ isRequired?: boolean;
88
+ hasRedactedValue?: boolean;
89
+ };
90
+ stateWcCovered: import('../..').FieldMetadataWithOptions<string>;
91
+ stateWcClassCode: import('../..').FieldMetadataWithOptions<WARiskClassCode>;
92
+ };
93
+ hookFormInternals: {
94
+ formMethods: import('react-hook-form').UseFormReturn<CompensationFormData, unknown, CompensationFormData>;
95
+ };
96
+ getFormSubmissionValues: () => CompensationFormData | undefined;
97
+ };
98
+ };
99
+ export type UseCompensationFormResult = ReturnType<typeof useCompensationForm>;
100
+ export type UseCompensationFormReady = Extract<UseCompensationFormResult, {
101
+ data: object;
102
+ }>;
103
+ export type CompensationFieldsMetadata = UseCompensationFormReady['form']['fieldsMetadata'];
104
+ export type CompensationFormFields = UseCompensationFormReady['form']['Fields'];
@@ -1,7 +1,259 @@
1
- function e(o) {
2
- throw new Error("useCompensationForm is not yet implemented");
1
+ import { useMemo as j, useEffect as Me } from "react";
2
+ import { useForm as ge, useWatch as I } from "react-hook-form";
3
+ import { zodResolver as Ee } from "@hookform/resolvers/zod";
4
+ import { useJobsAndCompensationsGetJobs as he } from "@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs";
5
+ import { useJobsAndCompensationsCreateJobMutation as Oe } from "@gusto/embedded-api/react-query/jobsAndCompensationsCreateJob";
6
+ import { useJobsAndCompensationsUpdateMutation as Fe } from "@gusto/embedded-api/react-query/jobsAndCompensationsUpdate";
7
+ import { useJobsAndCompensationsUpdateCompensationMutation as Pe } from "@gusto/embedded-api/react-query/jobsAndCompensationsUpdateCompensation";
8
+ import { useLocationsGetMinimumWages as Ue } from "@gusto/embedded-api/react-query/locationsGetMinimumWages";
9
+ import { useEmployeeAddressesGetWorkAddresses as De } from "@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses";
10
+ import { useEmployeesGet as Te } from "@gusto/embedded-api/react-query/employeesGet";
11
+ import { useFederalTaxDetailsGet as Ae } from "@gusto/embedded-api/react-query/federalTaxDetailsGet";
12
+ import { useErrorHandling as Ne } from "../../useErrorHandling.js";
13
+ import { withOptions as f } from "../../form/withOptions.js";
14
+ import { deriveFieldsMetadata as we } from "../../form/deriveFieldsMetadata.js";
15
+ import { createGetFormSubmissionValues as je } from "../../form/getFormSubmissionValues.js";
16
+ import { createCompensationSchema as Ie } from "./compensationSchema.js";
17
+ import { StateWcClassCodeField as Le, StateWcCoveredField as Je, TwoPercentShareholderField as Re, MinimumWageIdField as _e, AdjustForMinimumWageField as qe, PaymentUnitField as Ve, RateField as Ye, FlsaStatusField as He, JobTitleField as Xe, StartDateField as ke } from "./fields.js";
18
+ import { PAY_PERIODS as u, FlsaStatus as s, TIP_CREDITS_UNSUPPORTED_STATES as xe } from "../../../../shared/constants.js";
19
+ import { useBaseSubmit as Ge } from "../../../Base/useBaseSubmit.js";
20
+ import { SDKInternalError as Z } from "../../../../types/sdkError.js";
21
+ import { WA_RISK_CLASS_CODES as ee } from "../../../../models/WA_RISK_CODES.js";
22
+ function Ke(e) {
23
+ return e?.compensations?.find((m) => m.uuid === e.currentCompensationUuid);
24
+ }
25
+ function Qe(e) {
26
+ return e.reduce((m, l) => {
27
+ const S = l.compensations?.find(
28
+ (c) => c.uuid === l.currentCompensationUuid
29
+ );
30
+ return !l.primary || !S ? m : S.flsaStatus ?? m;
31
+ }, void 0);
32
+ }
33
+ const te = Object.keys(s).map((e) => s[e]), $e = te.map((e) => ({
34
+ value: e,
35
+ label: e
36
+ })), oe = [
37
+ u.HOUR,
38
+ u.WEEK,
39
+ u.MONTH,
40
+ u.YEAR,
41
+ u.PAYCHECK
42
+ ], Be = oe.map((e) => ({
43
+ value: e,
44
+ label: e
45
+ }));
46
+ function gt({
47
+ employeeId: e,
48
+ withStartDateField: m = !0,
49
+ jobId: l,
50
+ requiredFields: S,
51
+ defaultValues: c,
52
+ validationMode: ae = "onSubmit",
53
+ shouldFocusError: se = !0
54
+ }) {
55
+ const g = he(
56
+ { employeeId: e ?? "" },
57
+ { enabled: !!e }
58
+ ), E = De(
59
+ { employeeId: e ?? "" },
60
+ { enabled: !!e }
61
+ ), h = Te({ employeeId: e ?? "" }, { enabled: !!e }), n = g.data?.jobList, L = E.data?.employeeWorkAddressesList, O = L?.find((t) => t.active), J = O?.locationUuid, R = h.data?.employee, F = R?.companyUuid, P = Ue(
62
+ { locationUuid: J ?? "" },
63
+ { enabled: !!J }
64
+ ), U = Ae(
65
+ { companyId: F ?? "" },
66
+ { enabled: !!F }
67
+ ), W = P.data?.minimumWageList ?? [], _ = U.data?.federalTaxDetails, q = _?.taxPayerType === "S-Corporation", o = j(() => n ? l ? n.find((t) => t.uuid === l) ?? null : n.length === 1 ? n[0] ?? null : null : null, [n, l]), C = j(() => Ke(o), [o]), ne = j(() => {
68
+ if (n)
69
+ return Qe(n);
70
+ }, [n]), b = !o, D = Ie({
71
+ mode: b ? "create" : "update",
72
+ requiredFields: S,
73
+ withStartDateField: m
74
+ }), T = O?.state, ie = o?.hireDate, y = {
75
+ jobTitle: o?.title || c?.jobTitle || "",
76
+ flsaStatus: C?.flsaStatus ?? ne ?? c?.flsaStatus ?? s.NONEXEMPT,
77
+ rate: Number(C?.rate ?? c?.rate ?? 0),
78
+ adjustForMinimumWage: C?.adjustForMinimumWage ?? !1,
79
+ minimumWageId: C?.minimumWages?.[0]?.uuid ?? "",
80
+ paymentUnit: C?.paymentUnit ?? c?.paymentUnit ?? u.HOUR,
81
+ stateWcCovered: o?.stateWcCovered ?? !1,
82
+ stateWcClassCode: o?.stateWcClassCode ?? "",
83
+ twoPercentShareholder: o?.twoPercentShareholder ?? !1,
84
+ startDate: ie ?? c?.startDate ?? null
85
+ }, a = ge({
86
+ resolver: Ee(D),
87
+ mode: ae,
88
+ shouldFocusError: se,
89
+ defaultValues: y,
90
+ values: y,
91
+ resetOptions: { keepDirtyValues: !0 }
92
+ }), d = I({
93
+ control: a.control,
94
+ name: "flsaStatus"
95
+ }), re = I({
96
+ control: a.control,
97
+ name: "adjustForMinimumWage"
98
+ }), de = I({
99
+ control: a.control,
100
+ name: "stateWcCovered"
101
+ });
102
+ Me(() => {
103
+ d === s.OWNER ? a.setValue("paymentUnit", u.PAYCHECK) : d === s.COMMISSION_ONLY_NONEXEMPT || d === s.COMMISSION_ONLY_EXEMPT ? (a.setValue("paymentUnit", u.YEAR), a.setValue("rate", 0)) : a.setValue("paymentUnit", y.paymentUnit);
104
+ }, [d, a.setValue, y.paymentUnit]);
105
+ const V = Pe(), Y = Oe(), H = Fe(), me = V.isPending || Y.isPending || H.isPending, { baseSubmitHandler: ue, error: le, setError: ce } = Ge("CompensationForm"), X = Ne(e ? [g, E, h, P, U] : [], { error: le, setError: ce }), k = d === s.COMMISSION_ONLY_NONEXEMPT || d === s.COMMISSION_ONLY_EXEMPT, pe = d === s.OWNER, Ce = d !== s.NONEXEMPT || o?.primary === !0 || b, A = d === s.NONEXEMPT && W.length > 0 && T !== void 0 && !xe.includes(T), v = T === "WA", fe = W.map((t) => ({
106
+ value: t.uuid,
107
+ label: `${t.wage} - ${t.authority}: ${t.notes ?? ""}`
108
+ })), Se = ee.map(({ code: t, description: M }) => ({
109
+ value: t,
110
+ label: `${t}: ${M}`
111
+ })), i = we(D), We = {
112
+ startDate: i.startDate,
113
+ jobTitle: i.jobTitle,
114
+ flsaStatus: f(
115
+ i.flsaStatus,
116
+ $e,
117
+ te
118
+ ),
119
+ rate: { ...i.rate, isDisabled: k },
120
+ paymentUnit: f(
121
+ { ...i.paymentUnit, isDisabled: pe || k },
122
+ Be,
123
+ oe
124
+ ),
125
+ adjustForMinimumWage: {
126
+ ...i.adjustForMinimumWage,
127
+ isDisabled: !A
128
+ },
129
+ minimumWageId: f(
130
+ i.minimumWageId,
131
+ fe,
132
+ W
133
+ ),
134
+ twoPercentShareholder: {
135
+ ...i.twoPercentShareholder,
136
+ isDisabled: !q
137
+ },
138
+ stateWcCovered: f(
139
+ { ...i.stateWcCovered, isDisabled: !v },
140
+ [
141
+ { label: "Yes", value: "true" },
142
+ { label: "No", value: "false" }
143
+ ],
144
+ ["yes", "no"]
145
+ ),
146
+ stateWcClassCode: f(
147
+ { ...i.stateWcClassCode, isDisabled: !v },
148
+ Se,
149
+ ee
150
+ )
151
+ }, be = async (t, M) => {
152
+ let x;
153
+ return await new Promise((G) => {
154
+ a.handleSubmit(
155
+ async (ye) => {
156
+ await ue(ye, async (ve) => {
157
+ const K = M?.employeeId ?? e;
158
+ if (!K)
159
+ throw new Z("employeeId is required to submit compensation");
160
+ const {
161
+ jobTitle: Q,
162
+ twoPercentShareholder: $,
163
+ startDate: B,
164
+ ...r
165
+ } = ve, N = m && B ? B : M?.startDate;
166
+ let p;
167
+ if (o)
168
+ p = (await H.mutateAsync({
169
+ request: {
170
+ jobId: o.uuid,
171
+ requestBody: {
172
+ title: Q,
173
+ version: o.version,
174
+ hireDate: N,
175
+ stateWcClassCode: r.stateWcCovered ? r.stateWcClassCode : null,
176
+ stateWcCovered: r.stateWcCovered,
177
+ twoPercentShareholder: $ ?? !1
178
+ }
179
+ }
180
+ })).job, t?.onJobUpdated?.(p);
181
+ else {
182
+ if (!N)
183
+ throw new Z("Start date is required");
184
+ p = (await Y.mutateAsync({
185
+ request: {
186
+ employeeId: K,
187
+ requestBody: {
188
+ title: Q,
189
+ hireDate: N,
190
+ stateWcCovered: r.stateWcCovered,
191
+ stateWcClassCode: r.stateWcCovered ? r.stateWcClassCode : null,
192
+ twoPercentShareholder: $ ?? !1
193
+ }
194
+ }
195
+ })).job, t?.onJobCreated?.(p);
196
+ }
197
+ const { compensation: z } = await V.mutateAsync({
198
+ request: {
199
+ compensationId: p.currentCompensationUuid,
200
+ compensationsUpdateRequestBody: {
201
+ // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
202
+ version: p.compensations?.find(
203
+ (w) => w.uuid === p.currentCompensationUuid
204
+ )?.version,
205
+ ...r,
206
+ rate: String(r.rate),
207
+ minimumWages: r.adjustForMinimumWage ? [{ uuid: r.minimumWageId }] : []
208
+ }
209
+ }
210
+ });
211
+ t?.onCompensationUpdated?.(z), x = {
212
+ mode: b ? "create" : "update",
213
+ data: z
214
+ };
215
+ }), G();
216
+ },
217
+ () => {
218
+ G();
219
+ }
220
+ )();
221
+ }), x;
222
+ };
223
+ return (e ? g.isLoading || E.isLoading || h.isLoading || P.isLoading || U.isLoading : !1) || e && (!n || !L || !O || !R || !F || !_) ? { isLoading: !0, errorHandling: X } : {
224
+ isLoading: !1,
225
+ data: {
226
+ compensation: C ?? null,
227
+ jobs: n,
228
+ currentJob: o,
229
+ minimumWages: W
230
+ },
231
+ status: {
232
+ isPending: me,
233
+ mode: b ? "create" : "update"
234
+ },
235
+ actions: { onSubmit: be },
236
+ errorHandling: X,
237
+ form: {
238
+ Fields: {
239
+ StartDate: m ? ke : void 0,
240
+ JobTitle: Xe,
241
+ FlsaStatus: Ce ? He : void 0,
242
+ Rate: Ye,
243
+ PaymentUnit: Ve,
244
+ AdjustForMinimumWage: A ? qe : void 0,
245
+ MinimumWageId: A && re ? _e : void 0,
246
+ TwoPercentShareholder: q ? Re : void 0,
247
+ StateWcCovered: v ? Je : void 0,
248
+ StateWcClassCode: v && de ? Le : void 0
249
+ },
250
+ fieldsMetadata: We,
251
+ hookFormInternals: { formMethods: a },
252
+ getFormSubmissionValues: je(a, D)
253
+ }
254
+ };
3
255
  }
4
256
  export {
5
- e as useCompensationForm
257
+ gt as useCompensationForm
6
258
  };
7
259
  //# sourceMappingURL=useCompensationForm.js.map