@saasquatch/mint-components 1.8.3-3 → 1.8.3

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 (76) hide show
  1. package/dist/cjs/{ShadowViewAddon-7b5c40eb.js → ShadowViewAddon-a9bac47c.js} +2 -2
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/mint-components.cjs.js +1 -1
  4. package/dist/cjs/sqm-banking-info-form_16.cjs.entry.js +1237 -36
  5. package/dist/cjs/sqm-big-stat_38.cjs.entry.js +1 -3
  6. package/dist/cjs/{sqm-invoice-table-view-035d5aed.js → sqm-invoice-table-view-2e93ac53.js} +368 -7
  7. package/dist/cjs/sqm-stencilbook.cjs.entry.js +3 -3
  8. package/dist/collection/components/sqm-leaderboard/sqm-leaderboard.js +0 -3
  9. package/dist/collection/components/sqm-portal-footer/sqm-portal-footer.js +0 -8
  10. package/dist/collection/components/tax-and-cash/TaxForm.stories.js +16 -0
  11. package/dist/collection/components/tax-and-cash/phoneExtensions.js +970 -0
  12. package/dist/collection/components/tax-and-cash/sqm-banking-info-form/sqm-banking-info-form-view.js +1 -1
  13. package/dist/collection/components/tax-and-cash/sqm-indirect-tax-form/useIndirectTaxForm.js +33 -14
  14. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash/data.js +10 -2
  15. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash/sqm-tax-and-cash.js +234 -0
  16. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard-view.js +1 -1
  17. package/dist/collection/components/tax-and-cash/sqm-user-info-form/small-views/IndirectTaxDetailsView.js +6 -6
  18. package/dist/collection/components/tax-and-cash/sqm-user-info-form/sqm-user-info-form-view.js +87 -12
  19. package/dist/collection/components/tax-and-cash/sqm-user-info-form/sqm-user-info-form.js +233 -1
  20. package/dist/collection/components/tax-and-cash/sqm-user-info-form/useUserInfoForm.js +52 -7
  21. package/dist/collection/components/tax-and-cash/subregions.js +338 -0
  22. package/dist/collection/components/tax-and-cash/utils.js +6 -1
  23. package/dist/collection/components/views/copy-text-view.js +2 -2
  24. package/dist/esm/{ShadowViewAddon-d9424229.js → ShadowViewAddon-352dc73a.js} +2 -2
  25. package/dist/esm/loader.js +1 -1
  26. package/dist/esm/mint-components.js +1 -1
  27. package/dist/esm/sqm-banking-info-form_16.entry.js +1237 -36
  28. package/dist/esm/sqm-big-stat_38.entry.js +1 -3
  29. package/dist/esm/{sqm-invoice-table-view-1115795f.js → sqm-invoice-table-view-e925c4db.js} +366 -7
  30. package/dist/esm/sqm-stencilbook.entry.js +3 -3
  31. package/dist/esm-es5/ShadowViewAddon-352dc73a.js +1 -0
  32. package/dist/esm-es5/loader.js +1 -1
  33. package/dist/esm-es5/mint-components.js +1 -1
  34. package/dist/esm-es5/sqm-banking-info-form_16.entry.js +1 -1
  35. package/dist/esm-es5/sqm-big-stat_38.entry.js +1 -1
  36. package/dist/esm-es5/sqm-invoice-table-view-e925c4db.js +1 -0
  37. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  38. package/dist/mint-components/mint-components.esm.js +1 -1
  39. package/dist/mint-components/{p-f37b7296.entry.js → p-12c2757a.entry.js} +2 -2
  40. package/dist/mint-components/p-1ee63bff.entry.js +168 -0
  41. package/dist/mint-components/{p-89995fd0.js → p-26258333.js} +1 -1
  42. package/dist/mint-components/p-2ca2b028.system.js +1 -0
  43. package/dist/mint-components/p-4d45d92d.js +1 -0
  44. package/dist/mint-components/p-5d030951.system.entry.js +1 -0
  45. package/dist/mint-components/p-7eb6fab2.system.js +1 -1
  46. package/dist/mint-components/{p-2ee988c7.entry.js → p-8a174905.entry.js} +1 -1
  47. package/dist/mint-components/p-8e2274a8.system.js +1 -0
  48. package/dist/mint-components/{p-92b99bb2.system.entry.js → p-95a23c8f.system.entry.js} +1 -1
  49. package/dist/mint-components/{p-f4a6e490.system.entry.js → p-d3d04e96.system.entry.js} +1 -1
  50. package/dist/types/components/sqm-leaderboard/sqm-leaderboard.d.ts +0 -3
  51. package/dist/types/components/sqm-portal-footer/sqm-portal-footer.d.ts +0 -2
  52. package/dist/types/components/tax-and-cash/phoneExtensions.d.ts +970 -0
  53. package/dist/types/components/tax-and-cash/sqm-tax-and-cash/data.d.ts +16 -2
  54. package/dist/types/components/tax-and-cash/sqm-tax-and-cash/sqm-tax-and-cash.d.ts +42 -0
  55. package/dist/types/components/tax-and-cash/sqm-user-info-form/sqm-user-info-form-view.d.ts +39 -6
  56. package/dist/types/components/tax-and-cash/sqm-user-info-form/sqm-user-info-form.d.ts +40 -0
  57. package/dist/types/components/tax-and-cash/sqm-user-info-form/useUserInfoForm.d.ts +20 -0
  58. package/dist/types/components/tax-and-cash/subregions.d.ts +8 -0
  59. package/dist/types/components/tax-and-cash/utils.d.ts +2 -1
  60. package/dist/types/components.d.ts +158 -4
  61. package/dist/types/global/android.d.ts +7 -0
  62. package/dist/types/global/demo.d.ts +2 -0
  63. package/dist/types/stories/features.d.ts +4 -0
  64. package/dist/types/stories/templates.d.ts +4 -0
  65. package/docs/UserFormFastFollow--2024-04-26--14-31-04.xlsx +0 -0
  66. package/docs/docs.docx +0 -0
  67. package/docs/raisins.json +1 -1
  68. package/grapesjs/grapesjs.js +1 -1
  69. package/package.json +1 -1
  70. package/dist/esm-es5/ShadowViewAddon-d9424229.js +0 -1
  71. package/dist/esm-es5/sqm-invoice-table-view-1115795f.js +0 -1
  72. package/dist/mint-components/p-58d2e9cb.entry.js +0 -153
  73. package/dist/mint-components/p-5ff96052.system.entry.js +0 -1
  74. package/dist/mint-components/p-67b91751.system.js +0 -1
  75. package/dist/mint-components/p-79fc68b0.js +0 -1
  76. package/dist/mint-components/p-9755ab8f.system.js +0 -1
@@ -261,5 +261,5 @@ export const BankingInfoFormView = (props) => {
261
261
  : slots.paymentFixedDaySelectSlot))))),
262
262
  h("div", { class: classes.BtnContainer },
263
263
  h("sl-button", { type: "primary", disabled: states.disabled || states.saveDisabled, loading: states.saveLoading, submit: true, exportparts: "base: primarybutton-base" }, text.continueButton),
264
- !states.hideBackButton && (h("sl-button", { class: classes.SecondaryBtn, type: "text", onClick: callbacks.onBack }, text.backButton))))));
264
+ !states.hideBackButton && (h("sl-button", { exportparts: "base: secondarybutton-base", class: classes.SecondaryBtn, type: "text", onClick: callbacks.onBack }, text.backButton))))));
265
265
  };
@@ -8,16 +8,23 @@ import { getCountryObj, validTaxDocument } from "../utils";
8
8
  const CONNECT_PARTNER = gql `
9
9
  mutation createImpactConnection($vars: ImpactConnectionInput!) {
10
10
  createImpactConnection(impactConnectionInput: $vars) {
11
- id
12
- accountId
13
- impactConnection {
14
- connected
15
- publisher {
16
- brandedSignup
17
- requiredTaxDocumentType
18
- currentTaxDocument {
19
- type
20
- status
11
+ success
12
+ validationErrors {
13
+ field
14
+ message
15
+ }
16
+ user {
17
+ id
18
+ accountId
19
+ impactConnection {
20
+ connected
21
+ publisher {
22
+ brandedSignup
23
+ requiredTaxDocumentType
24
+ currentTaxDocument {
25
+ type
26
+ status
27
+ }
21
28
  }
22
29
  }
23
30
  }
@@ -100,7 +107,7 @@ export function useIndirectTaxForm(props) {
100
107
  setFormState((p) => ({ ...p, [field]: value }));
101
108
  };
102
109
  const onSubmit = async (event) => {
103
- var _a, _b, _c, _d;
110
+ var _a, _b, _c, _d, _e, _f;
104
111
  if (!option) {
105
112
  setErrors({ taxDetails: true });
106
113
  return;
@@ -135,6 +142,12 @@ export function useIndirectTaxForm(props) {
135
142
  lastName: userForm.lastName,
136
143
  countryCode: userForm.countryCode,
137
144
  currency: userForm.currency,
145
+ address: userForm.address,
146
+ city: userForm.city,
147
+ state: userForm.state,
148
+ postalCode: userForm.postalCode,
149
+ phoneNumber: userForm.phoneNumber,
150
+ phoneNumberCountryCode: userForm.phoneNumberCountryCode,
138
151
  indirectTaxCountryCode: formData.selectedRegion,
139
152
  indirectTaxRegion: formData.province || formData.subRegion,
140
153
  indirectTaxId: formData.indirectTaxNumber,
@@ -146,10 +159,16 @@ export function useIndirectTaxForm(props) {
146
159
  });
147
160
  if (!result || ((_a = result) === null || _a === void 0 ? void 0 : _a.message))
148
161
  throw new Error();
162
+ if (!((_b = result.createImpactConnection) === null || _b === void 0 ? void 0 : _b.success)) {
163
+ // Output backend errors to console for now
164
+ console.error("Failed to create Impact connection: ", result.createImpactConnection
165
+ .validationErrors);
166
+ throw new Error();
167
+ }
149
168
  await refetch();
150
- const resultPublisher = (_c = (_b = result
151
- .createImpactConnection) === null || _b === void 0 ? void 0 : _b.impactConnection) === null || _c === void 0 ? void 0 : _c.publisher;
152
- const hasValidCurrentDocument = validTaxDocument(resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType, (_d = resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.currentTaxDocument) === null || _d === void 0 ? void 0 : _d.type);
169
+ const resultPublisher = (_e = (_d = (_c = result
170
+ .createImpactConnection) === null || _c === void 0 ? void 0 : _c.user) === null || _d === void 0 ? void 0 : _d.impactConnection) === null || _e === void 0 ? void 0 : _e.publisher;
171
+ const hasValidCurrentDocument = validTaxDocument(resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType, (_f = resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.currentTaxDocument) === null || _f === void 0 ? void 0 : _f.type);
153
172
  if ((resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) &&
154
173
  !hasValidCurrentDocument) {
155
174
  // Go to docusign form
@@ -25,10 +25,17 @@ export const GET_USER = gql `
25
25
  lastName
26
26
  }
27
27
  publisher {
28
+ id
29
+ brandedSignup
28
30
  countryCode
29
31
  currency
30
- requiredTaxDocumentType
31
- brandedSignup
32
+ billingAddress
33
+ billingCity
34
+ billingState
35
+ billingCountryCode
36
+ billingPostalCode
37
+ phoneNumberCountryCode
38
+ phoneNumber
32
39
  taxInformation {
33
40
  indirectTaxId
34
41
  indirectTaxCountryCode
@@ -37,6 +44,7 @@ export const GET_USER = gql `
37
44
  withholdingTaxId
38
45
  withholdingTaxCountryCode
39
46
  }
47
+ requiredTaxDocumentType
40
48
  currentTaxDocument {
41
49
  status
42
50
  type
@@ -41,6 +41,41 @@ export class TaxAndCashMonolith {
41
41
  * @uiGroup Step 1 Properties
42
42
  */
43
43
  this.step1_country = "Country";
44
+ /**
45
+ * @uiName Phone number field label
46
+ * @uiGroup Step 1 Properties
47
+ */
48
+ this.step1_phoneNumber = "Phone number";
49
+ /**
50
+ * @uiName Address field label
51
+ * @uiGroup Step 1 Properties
52
+ */
53
+ this.step1_address = "Address";
54
+ /**
55
+ * @uiName City field label
56
+ * @uiGroup Step 1 Properties
57
+ */
58
+ this.step1_city = "City";
59
+ /**
60
+ * @uiName State field label for states
61
+ * @uiGroup Step 1 Properties
62
+ */
63
+ this.step1_state = "State";
64
+ /**
65
+ * @uiName State field label for provinces
66
+ * @uiGroup Step 1 Properties
67
+ */
68
+ this.step1_province = "Province";
69
+ /**
70
+ * @uiName State field label for regions
71
+ * @uiGroup Step 1 Properties
72
+ */
73
+ this.step1_region = "Region";
74
+ /**
75
+ * @uiName Postal code field label
76
+ * @uiGroup Step 1 Properties
77
+ */
78
+ this.step1_postalCode = "Postal code";
44
79
  /**
45
80
  * @uiName Currency field label
46
81
  * @uiGroup Step 1 Properties
@@ -785,6 +820,12 @@ export class TaxAndCashMonolith {
785
820
  * @uiGroup General Form Properties
786
821
  */
787
822
  this.fieldRequiredError = "{fieldName} is required";
823
+ /**
824
+ * Displayed under a field that includes invalid characters (non-ASCII).
825
+ * @uiName Invalid character error message
826
+ * @uiGroup General Form Properties
827
+ */
828
+ this.invalidCharacterError = "{fieldName} includes characters that aren't supported.";
788
829
  /**
789
830
  * Displayed under a field when it has an invalid entry.
790
831
  * @uiName Form field error message
@@ -857,6 +898,7 @@ export class TaxAndCashMonolith {
857
898
  generalErrorTitle: props.generalErrorTitle,
858
899
  generalErrorDescription: props.generalErrorDescription,
859
900
  fieldRequiredError: props.fieldRequiredError,
901
+ invalidCharacterError: props.invalidCharacterError,
860
902
  fieldInvalidError: props.fieldInvalidError,
861
903
  continueButton: props.continueButton,
862
904
  backButton: props.backButton,
@@ -1003,6 +1045,174 @@ export class TaxAndCashMonolith {
1003
1045
  "reflect": false,
1004
1046
  "defaultValue": "\"Country\""
1005
1047
  },
1048
+ "step1_phoneNumber": {
1049
+ "type": "string",
1050
+ "mutable": false,
1051
+ "complexType": {
1052
+ "original": "string",
1053
+ "resolved": "string",
1054
+ "references": {}
1055
+ },
1056
+ "required": false,
1057
+ "optional": false,
1058
+ "docs": {
1059
+ "tags": [{
1060
+ "text": "Phone number field label",
1061
+ "name": "uiName"
1062
+ }, {
1063
+ "text": "Step 1 Properties",
1064
+ "name": "uiGroup"
1065
+ }],
1066
+ "text": ""
1067
+ },
1068
+ "attribute": "step-1_phone-number",
1069
+ "reflect": false,
1070
+ "defaultValue": "\"Phone number\""
1071
+ },
1072
+ "step1_address": {
1073
+ "type": "string",
1074
+ "mutable": false,
1075
+ "complexType": {
1076
+ "original": "string",
1077
+ "resolved": "string",
1078
+ "references": {}
1079
+ },
1080
+ "required": false,
1081
+ "optional": false,
1082
+ "docs": {
1083
+ "tags": [{
1084
+ "text": "Address field label",
1085
+ "name": "uiName"
1086
+ }, {
1087
+ "text": "Step 1 Properties",
1088
+ "name": "uiGroup"
1089
+ }],
1090
+ "text": ""
1091
+ },
1092
+ "attribute": "step-1_address",
1093
+ "reflect": false,
1094
+ "defaultValue": "\"Address\""
1095
+ },
1096
+ "step1_city": {
1097
+ "type": "string",
1098
+ "mutable": false,
1099
+ "complexType": {
1100
+ "original": "string",
1101
+ "resolved": "string",
1102
+ "references": {}
1103
+ },
1104
+ "required": false,
1105
+ "optional": false,
1106
+ "docs": {
1107
+ "tags": [{
1108
+ "text": "City field label",
1109
+ "name": "uiName"
1110
+ }, {
1111
+ "text": "Step 1 Properties",
1112
+ "name": "uiGroup"
1113
+ }],
1114
+ "text": ""
1115
+ },
1116
+ "attribute": "step-1_city",
1117
+ "reflect": false,
1118
+ "defaultValue": "\"City\""
1119
+ },
1120
+ "step1_state": {
1121
+ "type": "string",
1122
+ "mutable": false,
1123
+ "complexType": {
1124
+ "original": "string",
1125
+ "resolved": "string",
1126
+ "references": {}
1127
+ },
1128
+ "required": false,
1129
+ "optional": false,
1130
+ "docs": {
1131
+ "tags": [{
1132
+ "text": "State field label for states",
1133
+ "name": "uiName"
1134
+ }, {
1135
+ "text": "Step 1 Properties",
1136
+ "name": "uiGroup"
1137
+ }],
1138
+ "text": ""
1139
+ },
1140
+ "attribute": "step-1_state",
1141
+ "reflect": false,
1142
+ "defaultValue": "\"State\""
1143
+ },
1144
+ "step1_province": {
1145
+ "type": "string",
1146
+ "mutable": false,
1147
+ "complexType": {
1148
+ "original": "string",
1149
+ "resolved": "string",
1150
+ "references": {}
1151
+ },
1152
+ "required": false,
1153
+ "optional": false,
1154
+ "docs": {
1155
+ "tags": [{
1156
+ "text": "State field label for provinces",
1157
+ "name": "uiName"
1158
+ }, {
1159
+ "text": "Step 1 Properties",
1160
+ "name": "uiGroup"
1161
+ }],
1162
+ "text": ""
1163
+ },
1164
+ "attribute": "step-1_province",
1165
+ "reflect": false,
1166
+ "defaultValue": "\"Province\""
1167
+ },
1168
+ "step1_region": {
1169
+ "type": "string",
1170
+ "mutable": false,
1171
+ "complexType": {
1172
+ "original": "string",
1173
+ "resolved": "string",
1174
+ "references": {}
1175
+ },
1176
+ "required": false,
1177
+ "optional": false,
1178
+ "docs": {
1179
+ "tags": [{
1180
+ "text": "State field label for regions",
1181
+ "name": "uiName"
1182
+ }, {
1183
+ "text": "Step 1 Properties",
1184
+ "name": "uiGroup"
1185
+ }],
1186
+ "text": ""
1187
+ },
1188
+ "attribute": "step-1_region",
1189
+ "reflect": false,
1190
+ "defaultValue": "\"Region\""
1191
+ },
1192
+ "step1_postalCode": {
1193
+ "type": "string",
1194
+ "mutable": false,
1195
+ "complexType": {
1196
+ "original": "string",
1197
+ "resolved": "string",
1198
+ "references": {}
1199
+ },
1200
+ "required": false,
1201
+ "optional": false,
1202
+ "docs": {
1203
+ "tags": [{
1204
+ "text": "Postal code field label",
1205
+ "name": "uiName"
1206
+ }, {
1207
+ "text": "Step 1 Properties",
1208
+ "name": "uiGroup"
1209
+ }],
1210
+ "text": ""
1211
+ },
1212
+ "attribute": "step-1_postal-code",
1213
+ "reflect": false,
1214
+ "defaultValue": "\"Postal code\""
1215
+ },
1006
1216
  "step1_currency": {
1007
1217
  "type": "string",
1008
1218
  "mutable": false,
@@ -4078,6 +4288,30 @@ export class TaxAndCashMonolith {
4078
4288
  "reflect": false,
4079
4289
  "defaultValue": "\"{fieldName} is required\""
4080
4290
  },
4291
+ "invalidCharacterError": {
4292
+ "type": "string",
4293
+ "mutable": false,
4294
+ "complexType": {
4295
+ "original": "string",
4296
+ "resolved": "string",
4297
+ "references": {}
4298
+ },
4299
+ "required": false,
4300
+ "optional": false,
4301
+ "docs": {
4302
+ "tags": [{
4303
+ "text": "Invalid character error message",
4304
+ "name": "uiName"
4305
+ }, {
4306
+ "text": "General Form Properties",
4307
+ "name": "uiGroup"
4308
+ }],
4309
+ "text": "Displayed under a field that includes invalid characters (non-ASCII)."
4310
+ },
4311
+ "attribute": "invalid-character-error",
4312
+ "reflect": false,
4313
+ "defaultValue": "\"{fieldName} includes characters that aren't supported.\""
4314
+ },
4081
4315
  "fieldInvalidError": {
4082
4316
  "type": "string",
4083
4317
  "mutable": false,
@@ -274,7 +274,7 @@ export const TaxAndCashDashboardView = (props) => {
274
274
  documentType: states.documentTypeString,
275
275
  })),
276
276
  h("span", { class: sheet.classes.StatusAlert }, statusMap[states.status]))),
277
- h("sl-button", { disabled: states.disabled || states.loading, onClick: callbacks.onClick, type: "default", class: sheet.classes.NewFormButton, exportparts: "base: secondarybutton-base" }, text.newFormButton))))))),
277
+ h("sl-button", { disabled: states.disabled || states.loading, onClick: callbacks.onClick, type: "default", class: sheet.classes.NewFormButton, exportparts: "base: primarybutton-base" }, text.newFormButton))))))),
278
278
  h("div", { class: sheet.classes.IndirectTaxPreviewContainer }, states.loading ? (h("div", { class: sheet.classes.TaxSectionSkeletonContainer },
279
279
  h("sl-skeleton", { class: sheet.classes.SkeletonOne }),
280
280
  h("sl-skeleton", { class: sheet.classes.SkeletonTwo }))) : (h("div", null,
@@ -3,7 +3,7 @@ import { intl } from "../../../../global/global";
3
3
  import { createStyleSheet } from "../../../../styling/JSS";
4
4
  import { vatLabels } from "../../countries";
5
5
  import { INDIRECT_TAX_PROVINCES } from "../../subregions";
6
- import { getIsRequiredErrorMessage } from "../../utils";
6
+ import { formatErrorMessage } from "../../utils";
7
7
  const style = {
8
8
  Container: {
9
9
  width: "100%",
@@ -88,13 +88,13 @@ export const OtherRegionSlotView = (props) => {
88
88
  return (h("div", { class: classes.ConditionalInputsContainer },
89
89
  h("sl-select", Object.assign({ required: true, exportparts: "label: input-label", class: classes.Input, value: formState.subRegion, label: text.subRegion, disabled: states.loading || states.disabled }, (((_a = formState.errors) === null || _a === void 0 ? void 0 : _a.indirectTaxNumber) && {
90
90
  class: classes.ErrorInput,
91
- helpText: getIsRequiredErrorMessage(text.subRegion, text.error.fieldRequiredError),
91
+ helpText: formatErrorMessage(text.subRegion, text.error.fieldRequiredError),
92
92
  }), { id: "subRegion", name: "/subRegion" }), props.data.esRegions.map((r) => (h("sl-menu-item", { value: r.regionCode }, r.displayName)))),
93
93
  h(IndirectTaxNumberInput, { name: "indirectTaxNumber", label: getTaxFieldLabel("VAT"), error: getTaxFieldError("VAT") }),
94
94
  h("sl-checkbox", { class: classes.Checkbox, exportparts: "label: input-label", checked: formState.hasSubRegionTaxNumber, "onSl-change": callbacks.onSpainToggle, disabled: states.disabled || states.isPartner }, text.isRegisteredSubRegionIncomeTax),
95
95
  formState.hasSubRegionTaxNumber && (h("sl-input", Object.assign({ required: true, exportparts: "label: input-label", class: classes.Input, label: text.subRegionTaxNumberLabel, disabled: states.loading || states.disabled, value: formState.subRegionTaxNumber }, (((_b = formState.errors) === null || _b === void 0 ? void 0 : _b.subRegionTaxNumber) && {
96
96
  class: classes.ErrorInput,
97
- helpText: getIsRequiredErrorMessage(text.subRegionTaxNumberLabel, text.error.fieldRequiredError),
97
+ helpText: formatErrorMessage(text.subRegionTaxNumberLabel, text.error.fieldRequiredError),
98
98
  }), { id: "subRegionTaxNumber", name: "/subRegionTaxNumber" })))));
99
99
  };
100
100
  const CanadaFields = () => {
@@ -104,13 +104,13 @@ export const OtherRegionSlotView = (props) => {
104
104
  return (h("div", { class: classes.ConditionalInputsContainer },
105
105
  h("sl-select", Object.assign({ required: true, value: formState.province, exportparts: "label: input-label", class: classes.Input, label: text.province, disabled: states.loading || states.disabled, "onSl-select": (e) => callbacks.onFormChange("province", e) }, (((_b = formState.errors) === null || _b === void 0 ? void 0 : _b.province) && {
106
106
  class: classes.ErrorInput,
107
- helpText: getIsRequiredErrorMessage(text.province, text.error.fieldRequiredError),
107
+ helpText: formatErrorMessage(text.province, text.error.fieldRequiredError),
108
108
  }), { id: "province", name: "/province" }), props.data.provinces.map((p) => (h("sl-menu-item", { value: p.regionCode }, p.displayName)))),
109
109
  currentTaxType === "GST" && (h(IndirectTaxNumberInput, { label: getTaxFieldLabel("GST"), error: getTaxFieldError("GST"), name: "indirectTaxNumber" })),
110
110
  currentTaxType === "HST" && (h(IndirectTaxNumberInput, { label: getTaxFieldLabel("HST"), error: getTaxFieldError("HST"), name: "indirectTaxNumber" })),
111
111
  formState.province === "QUEBEC" && (h("div", { class: classes.ConditionalInputsContainer },
112
112
  h("sl-checkbox", { class: classes.Checkbox, exportparts: "label: input-label", "onSl-change": callbacks.onQstToggle, checked: formState.hasQst, disabled: states.isPartner || states.disabled }, text.isRegisteredQST),
113
- formState.hasQst && (h(IndirectTaxNumberInput, { name: "qstNumber", label: text.qstNumber, error: getIsRequiredErrorMessage(text.qstNumber, text.error.fieldRequiredError) }))))));
113
+ formState.hasQst && (h(IndirectTaxNumberInput, { name: "qstNumber", label: text.qstNumber, error: formatErrorMessage(text.qstNumber, text.error.fieldRequiredError) }))))));
114
114
  };
115
115
  const getActiveForm = (selectedRegion) => {
116
116
  var _a;
@@ -136,7 +136,7 @@ export const OtherRegionSlotView = (props) => {
136
136
  h("div", { class: classes.InputContainer },
137
137
  h("sl-select", Object.assign({ required: true, class: classes.Input, value: formState.selectedRegion, exportparts: "label: input-label", label: text.selectedRegion, disabled: states.loading || states.disabled, "onSl-select": (e) => callbacks.onFormChange("selectedRegion", e) }, (((_a = formState.errors) === null || _a === void 0 ? void 0 : _a.selectedRegion) && {
138
138
  class: classes.ErrorInput,
139
- helpText: getIsRequiredErrorMessage(text.selectedRegion, text.error.fieldRequiredError),
139
+ helpText: formatErrorMessage(text.selectedRegion, text.error.fieldRequiredError),
140
140
  }), { id: "selectedRegion", name: "/selectedRegion" }),
141
141
  h("sl-input", { class: classes.SearchInput, placeholder: text.searchForCountryText, onKeyDown: (e) => {
142
142
  // Stop shoelace intercepting key presses
@@ -3,7 +3,8 @@ import { intl } from "../../../global/global";
3
3
  import { createStyleSheet } from "../../../styling/JSS";
4
4
  import { GeneralLoadingView } from "../TaxForm.stories";
5
5
  import { FORM_STEPS } from "../sqm-tax-and-cash/data";
6
- import { getIsRequiredErrorMessage } from "../utils";
6
+ import { formatErrorMessage, validateBillingField } from "../utils";
7
+ import { PHONE_EXTENSIONS } from "../phoneExtensions";
7
8
  const style = {
8
9
  FormWrapper: {},
9
10
  ErrorInput: {
@@ -106,9 +107,12 @@ const vanillaStyle = `
106
107
  flex-direction: column;
107
108
  }
108
109
 
110
+ sl-select#phoneNumberCountryCode::part(menu) {
111
+ width: 450px;
112
+ }
109
113
  `;
110
114
  export const UserInfoFormView = (props) => {
111
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
115
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
112
116
  const { states, states: { formState }, callbacks, text, refs, data, } = props;
113
117
  const { classes } = sheet;
114
118
  const bankingCollectionText = intl.formatMessage({
@@ -117,6 +121,20 @@ export const UserInfoFormView = (props) => {
117
121
  }, {
118
122
  termsAndConditionsLink: (h("a", { href: "https://app.impact.com/", target: "_blank" }, text.termsAndConditionsLabel)),
119
123
  });
124
+ let regionLabel = undefined;
125
+ switch (data.regionLabelEnum) {
126
+ case "STATE":
127
+ regionLabel = text.state;
128
+ break;
129
+ case "PROVINCE":
130
+ regionLabel = text.province;
131
+ break;
132
+ case "REGION":
133
+ regionLabel = text.region;
134
+ break;
135
+ default:
136
+ regionLabel = text.state;
137
+ }
120
138
  return (h("sl-form", { class: classes.FormWrapper, "onSl-submit": callbacks.onSubmit, ref: (el) => (refs.formRef.current = el), novalidate: true },
121
139
  h("style", { type: "text/css" },
122
140
  styleString,
@@ -151,18 +169,18 @@ export const UserInfoFormView = (props) => {
151
169
  h("div", { class: classes.InputContainer },
152
170
  h("sl-input", Object.assign({ exportparts: "label: input-label", value: formState.firstName, label: text.firstName, disabled: states.disabled || states.isUser || states.isPartner }, (((_b = formState.errors) === null || _b === void 0 ? void 0 : _b.firstName) ? {
153
171
  class: classes.ErrorInput,
154
- helpText: getIsRequiredErrorMessage(text.firstName, text.error.fieldRequiredError),
172
+ helpText: formatErrorMessage(text.firstName, formState.errors.firstName),
155
173
  }
156
174
  : {}), { id: "firstName", name: "/firstName", required: true })),
157
175
  h("sl-input", Object.assign({ exportparts: "label: input-label", value: formState.lastName, label: text.lastName, disabled: states.disabled || states.isUser || states.isPartner }, (((_c = formState.errors) === null || _c === void 0 ? void 0 : _c.lastName) ? {
158
176
  class: classes.ErrorInput,
159
- helpText: getIsRequiredErrorMessage(text.lastName, text.error.fieldRequiredError),
177
+ helpText: formatErrorMessage(text.lastName, formState.errors.lastName),
160
178
  }
161
179
  : {}), { id: "lastName", name: "/lastName", required: true })),
162
180
  h("sl-input", { exportparts: "label: input-label", value: formState.email, label: text.email, disabled: true, id: "email", name: "/email", required: true }),
163
181
  h("sl-select", Object.assign({ id: "countryCode", exportparts: "label: input-label", name: "/countryCode", label: text.country, value: formState.countryCode, disabled: states.disabled || states.isPartner }, (((_d = formState.errors) === null || _d === void 0 ? void 0 : _d.countryCode) ? {
164
182
  class: classes.ErrorInput,
165
- helpText: getIsRequiredErrorMessage(text.country, text.error.fieldRequiredError),
183
+ helpText: formatErrorMessage(text.country, formState.errors.countryCode),
166
184
  }
167
185
  : {}), { required: true, "onSl-select": (e) => callbacks.onFormChange("countryCode", e) }),
168
186
  h("sl-input", { class: classes.SearchInput, placeholder: text.searchForCountryText, onKeyDown: (e) => {
@@ -173,9 +191,66 @@ export const UserInfoFormView = (props) => {
173
191
  } }), (_e = data === null || data === void 0 ? void 0 : data.countries) === null || _e === void 0 ? void 0 :
174
192
  _e.map((c) => (h("sl-menu-item", { value: c.countryCode }, c.displayName))), (_f = data === null || data === void 0 ? void 0 : data.allCountries) === null || _f === void 0 ? void 0 :
175
193
  _f.map((c) => (h("sl-menu-item", { value: c.countryCode, style: { display: "none" } }, c.displayName)))),
176
- h("sl-select", Object.assign({ id: "currency", exportparts: "label: input-label", name: "/currency", label: text.currency, menu: true, value: formState.currency, disabled: states.disabled || states.isPartner, helpText: text.currencyHelpText }, (((_g = formState.errors) === null || _g === void 0 ? void 0 : _g.currency) ? {
194
+ h("div", { style: { display: "flex", gap: "4px" } },
195
+ h("sl-select", Object.assign({ id: "phoneNumberCountryCode", exportparts: "label: input-label", name: "/phoneNumberCountryCode", label: text.phoneNumber, style: { minWidth: "140px" }, value: formState.phoneNumberCountryCode, disabled: states.disabled || states.isPartner, ref: (el) => (refs.phoneCountryRef.current = el) }, (((_g = formState.errors) === null || _g === void 0 ? void 0 : _g.phoneNumberCountryCode) ? {
196
+ class: classes.ErrorInput,
197
+ }
198
+ : {}), { required: true, "onSl-select": (e) => callbacks.onFormChange("phoneCountry", e) }),
199
+ h("sl-input", { class: classes.SearchInput, placeholder: text.searchForCountryText, onKeyDown: (e) => {
200
+ // Stop shoelace intercepting key presses
201
+ e.stopPropagation();
202
+ }, "onSl-input": (e) => {
203
+ callbacks.setPhoneCountrySearch(e.target.value);
204
+ } }), (_h = data === null || data === void 0 ? void 0 : data.phoneCountries) === null || _h === void 0 ? void 0 :
205
+ _h.map((c) => {
206
+ var _a, _b;
207
+ return (h("sl-menu-item", { style: { width: "500px" }, value: c.countryCode },
208
+ h("div", { slot: "prefix", style: { marginRight: "8px" } }, `${(_a = PHONE_EXTENSIONS[c.countryCode]) === null || _a === void 0 ? void 0 : _a.name} `), (_b = PHONE_EXTENSIONS[c.countryCode]) === null || _b === void 0 ? void 0 :
209
+ _b.dial_code));
210
+ }), (_j = data === null || data === void 0 ? void 0 : data.allCountries) === null || _j === void 0 ? void 0 :
211
+ _j.map((c) => {
212
+ var _a, _b;
213
+ return (h("sl-menu-item", { value: c.countryCode, style: { display: "none" } },
214
+ h("div", { slot: "prefix", style: { marginRight: "8px" } }, `${(_a = PHONE_EXTENSIONS[c.countryCode]) === null || _a === void 0 ? void 0 : _a.name} `), (_b = PHONE_EXTENSIONS[c.countryCode]) === null || _b === void 0 ? void 0 :
215
+ _b.dial_code));
216
+ })),
217
+ h("sl-input", Object.assign({ exportparts: "label: input-label", label: " ", id: "phoneNumber", name: "/phoneNumber", value: formState.phoneNumber, style: { marginTop: "2px", width: "362px" }, validationError: ({ value }) =>
218
+ // Naive phone number validation
219
+ validateBillingField(/[a-zA-Z]+/, value) &&
220
+ formatErrorMessage(text.phoneNumber, text.error.fieldInvalidError), disabled: states.disabled || states.isPartner }, (((_k = formState.errors) === null || _k === void 0 ? void 0 : _k.phoneNumber) ? {
221
+ class: classes.ErrorInput,
222
+ helpText: formatErrorMessage(text.phoneNumber, formState.errors.phoneNumber),
223
+ }
224
+ : {}), { required: true }))),
225
+ h("sl-input", Object.assign({ exportparts: "label: input-label", label: text.address, id: "address", name: "/address", value: formState.address, validationError: ({ value }) =>
226
+ // Checks for non-ASCII characters
227
+ !validateBillingField(/^[\x20-\xFF]+$/, value) &&
228
+ formatErrorMessage(text.address, text.error.invalidCharacterError), disabled: states.disabled || states.isPartner }, (((_l = formState.errors) === null || _l === void 0 ? void 0 : _l.address) ? {
229
+ class: classes.ErrorInput,
230
+ helpText: formatErrorMessage(text.address, formState.errors.address),
231
+ }
232
+ : {}), { required: true })),
233
+ h("sl-input", Object.assign({ exportparts: "label: input-label", label: text.city, id: "city", name: "/city", value: formState.city, validationError: ({ value }) =>
234
+ // Checks for non-ASCII characters
235
+ !validateBillingField(/^[\x20-\xFF]+$/, value) &&
236
+ formatErrorMessage(text.city, text.error.invalidCharacterError), disabled: states.disabled || states.isPartner }, (((_m = formState.errors) === null || _m === void 0 ? void 0 : _m.city) ? {
237
+ class: classes.ErrorInput,
238
+ helpText: formatErrorMessage(text.city, formState.errors.city),
239
+ }
240
+ : {}), { required: true })),
241
+ !states.hideState && (h("sl-select", Object.assign({ label: regionLabel, exportparts: "label: input-label", id: "state", name: "/state", value: formState.state, disabled: states.disabled || states.isPartner }, (((_o = formState.errors) === null || _o === void 0 ? void 0 : _o.state) ? {
242
+ class: classes.ErrorInput,
243
+ helpText: formatErrorMessage(text.state, formState.errors.state),
244
+ }
245
+ : {}), { required: true }), (_p = data.regions) === null || _p === void 0 ? void 0 : _p.map((r) => (h("sl-menu-item", { value: r.value }, r.label))))),
246
+ h("sl-input", Object.assign({ label: text.postalCode, exportparts: "label: input-label", id: "postalCode", name: "/postalCode", value: formState.postalCode, disabled: states.disabled || states.isPartner }, (((_q = formState.errors) === null || _q === void 0 ? void 0 : _q.postalCode) ? {
247
+ class: classes.ErrorInput,
248
+ helpText: formatErrorMessage(text.postalCode, formState.errors.postalCode),
249
+ }
250
+ : {}), { required: true })),
251
+ h("sl-select", Object.assign({ id: "currency", exportparts: "label: input-label", name: "/currency", label: text.currency, menu: true, value: formState.currency, disabled: states.disabled || states.isPartner, helpText: text.currencyHelpText }, (((_r = formState.errors) === null || _r === void 0 ? void 0 : _r.currency) ? {
177
252
  class: classes.ErrorInput,
178
- helpText: getIsRequiredErrorMessage(text.currency, text.error.fieldRequiredError),
253
+ helpText: formatErrorMessage(text.currency, formState.errors.currency),
179
254
  }
180
255
  : {}), { required: true, ref: (el) => (refs.currencyRef.current = el) }),
181
256
  h("sl-input", { class: classes.SearchInput, placeholder: text.searchForCurrencyText, onKeyDown: (e) => {
@@ -183,12 +258,12 @@ export const UserInfoFormView = (props) => {
183
258
  e.stopPropagation();
184
259
  }, "onSl-input": (e) => {
185
260
  callbacks.setCurrencySearch(e.target.value);
186
- } }), (_h = data === null || data === void 0 ? void 0 : data.currencies) === null || _h === void 0 ? void 0 :
187
- _h.map((c) => (h("sl-menu-item", { value: c.currencyCode },
261
+ } }), (_s = data === null || data === void 0 ? void 0 : data.currencies) === null || _s === void 0 ? void 0 :
262
+ _s.map((c) => (h("sl-menu-item", { value: c.currencyCode },
188
263
  c.currencyCode,
189
264
  " - ",
190
- c.displayName))), (_j = data === null || data === void 0 ? void 0 : data.allCurrencies) === null || _j === void 0 ? void 0 :
191
- _j.map((c) => (h("sl-menu-item", { value: c.currencyCode, style: { display: "none" } },
265
+ c.displayName))), (_t = data === null || data === void 0 ? void 0 : data.allCurrencies) === null || _t === void 0 ? void 0 :
266
+ _t.map((c) => (h("sl-menu-item", { value: c.currencyCode, style: { display: "none" } },
192
267
  c.currencyCode,
193
268
  " - ",
194
269
  c.displayName)))),
@@ -196,6 +271,6 @@ export const UserInfoFormView = (props) => {
196
271
  h("sl-checkbox", { exportparts: "label: input-label", checked: formState.allowBankingCollection === true, "onSl-change": (e) => {
197
272
  e.target.value = e.target.checked;
198
273
  }, disabled: states.isPartner ? false : states.disabled, required: true, value: formState.allowBankingCollection, id: "allowBankingCollection", name: "/allowBankingCollection" }, bankingCollectionText),
199
- ((_k = formState.errors) === null || _k === void 0 ? void 0 : _k.allowBankingCollection) && (h("p", { class: classes.ErrorText }, getIsRequiredErrorMessage(text.termsAndConditionsLabel, text.error.fieldRequiredError))))),
274
+ ((_u = formState.errors) === null || _u === void 0 ? void 0 : _u.allowBankingCollection) && (h("p", { class: classes.ErrorText }, formatErrorMessage(text.termsAndConditionsLabel, formState.errors.allowBankingCollection))))),
200
275
  h("sl-button", { type: "primary", disabled: states.isPartner ? false : states.disabled, submit: true, exportparts: "base: primarybutton-base" }, text.continueButton))))));
201
276
  };