@saasquatch/mint-components 2.3.0-10 → 2.3.0-12

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/{usePortalRegistrationForm-23ee2d62.js → AsYouType-d15caac8.js} +265 -223
  2. package/dist/cjs/sqm-banking-info-form_10.cjs.entry.js +14 -6
  3. package/dist/cjs/sqm-big-stat_47.cjs.entry.js +20 -14
  4. package/dist/cjs/sqm-portal-forgot-password_6.cjs.entry.js +3 -2
  5. package/dist/cjs/sqm-stencilbook.cjs.entry.js +6 -3
  6. package/dist/cjs/{sqm-user-info-form-view-374a3f01.js → sqm-user-info-form-view-c2cad72c.js} +996 -10
  7. package/dist/cjs/subregions-3542b0b8.js +1068 -0
  8. package/dist/cjs/{useIndirectTaxForm-112914a0.js → useIndirectTaxForm-64c0231c.js} +3 -1
  9. package/dist/cjs/usePortalRegistrationForm-8a3a14ac.js +215 -0
  10. package/dist/collection/components/tax-and-cash/phoneExtensions.js +12 -0
  11. package/dist/collection/components/tax-and-cash/sqm-indirect-tax-form/useIndirectTaxForm.js +2 -0
  12. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash/useTaxAndCash.js +16 -11
  13. package/dist/collection/components/tax-and-cash/sqm-user-info-form/UserInfoFormView.stories.js +2 -0
  14. package/dist/collection/components/tax-and-cash/sqm-user-info-form/small-views/IndirectTaxDetailsView.js +2 -2
  15. package/dist/collection/components/tax-and-cash/sqm-user-info-form/sqm-user-info-form-view.js +8 -5
  16. package/dist/collection/components/tax-and-cash/sqm-user-info-form/useUserInfoForm.js +9 -5
  17. package/dist/collection/components/tax-and-cash/utils.js +30 -27
  18. package/dist/esm/{usePortalRegistrationForm-3a1f36a2.js → AsYouType-2d56519e.js} +248 -223
  19. package/dist/esm/sqm-banking-info-form_10.entry.js +14 -6
  20. package/dist/esm/sqm-big-stat_47.entry.js +19 -13
  21. package/dist/esm/sqm-portal-forgot-password_6.entry.js +2 -1
  22. package/dist/esm/sqm-stencilbook.entry.js +6 -3
  23. package/dist/esm/{sqm-user-info-form-view-5322525c.js → sqm-user-info-form-view-5051c1d0.js} +994 -8
  24. package/dist/esm/subregions-7c5112e8.js +1055 -0
  25. package/dist/esm/{useIndirectTaxForm-a6ac7e7e.js → useIndirectTaxForm-d7d6be39.js} +3 -1
  26. package/dist/esm/usePortalRegistrationForm-78fdfd93.js +213 -0
  27. package/dist/esm-es5/AsYouType-2d56519e.js +1 -0
  28. package/dist/esm-es5/sqm-banking-info-form_10.entry.js +1 -1
  29. package/dist/esm-es5/sqm-big-stat_47.entry.js +1 -1
  30. package/dist/esm-es5/sqm-portal-forgot-password_6.entry.js +1 -1
  31. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  32. package/dist/esm-es5/sqm-user-info-form-view-5051c1d0.js +1 -0
  33. package/dist/esm-es5/subregions-7c5112e8.js +1 -0
  34. package/dist/esm-es5/{useIndirectTaxForm-a6ac7e7e.js → useIndirectTaxForm-d7d6be39.js} +2 -2
  35. package/dist/esm-es5/usePortalRegistrationForm-78fdfd93.js +1 -0
  36. package/dist/mint-components/mint-components.esm.js +1 -1
  37. package/dist/mint-components/p-0c6bd136.system.entry.js +1 -0
  38. package/dist/mint-components/{p-2d4132fb.js → p-1e1b03fa.js} +7 -5
  39. package/dist/mint-components/p-1e699fb8.entry.js +9 -0
  40. package/dist/mint-components/p-1f387c7b.system.js +1 -1
  41. package/dist/mint-components/p-29b267a9.system.entry.js +1 -0
  42. package/dist/mint-components/p-5959ebdb.system.js +1 -0
  43. package/dist/mint-components/p-5c3bff99.entry.js +1 -0
  44. package/dist/mint-components/p-5f8fa87c.js +1 -0
  45. package/dist/mint-components/p-6c9f7515.system.entry.js +1 -0
  46. package/dist/mint-components/p-769166a5.system.js +1 -0
  47. package/dist/mint-components/p-7c72eeb5.js +1 -0
  48. package/dist/mint-components/p-8dcd72fe.system.entry.js +1 -0
  49. package/dist/mint-components/p-a08157c4.js +1 -0
  50. package/dist/mint-components/p-a779e577.js +13 -0
  51. package/dist/mint-components/{p-5bc707cf.entry.js → p-aed3c69d.entry.js} +23 -23
  52. package/dist/mint-components/{p-85ecc0aa.entry.js → p-d0ed1c1b.entry.js} +8 -8
  53. package/dist/mint-components/p-d463fa82.system.js +1 -0
  54. package/dist/mint-components/{p-6ef373ed.system.js → p-d67f8e0f.system.js} +2 -2
  55. package/dist/mint-components/p-ee91aeac.system.js +1 -0
  56. package/dist/types/components/tax-and-cash/phoneExtensions.d.ts +12 -0
  57. package/dist/types/components/tax-and-cash/utils.d.ts +8 -2
  58. package/docs/docs.docx +0 -0
  59. package/package.json +1 -1
  60. package/dist/cjs/subregions-984e30d7.js +0 -1505
  61. package/dist/esm/subregions-7c9778d0.js +0 -1492
  62. package/dist/esm-es5/sqm-user-info-form-view-5322525c.js +0 -1
  63. package/dist/esm-es5/subregions-7c9778d0.js +0 -1
  64. package/dist/esm-es5/usePortalRegistrationForm-3a1f36a2.js +0 -1
  65. package/dist/mint-components/p-2bc6ac74.system.entry.js +0 -1
  66. package/dist/mint-components/p-335a5736.entry.js +0 -1
  67. package/dist/mint-components/p-3a41b39c.js +0 -13
  68. package/dist/mint-components/p-5623f1e0.js +0 -1
  69. package/dist/mint-components/p-5fdf0286.system.js +0 -1
  70. package/dist/mint-components/p-7f29622d.js +0 -1
  71. package/dist/mint-components/p-8a08cec6.system.entry.js +0 -1
  72. package/dist/mint-components/p-a8cfa8fd.entry.js +0 -9
  73. package/dist/mint-components/p-b9509a55.system.entry.js +0 -1
  74. package/dist/mint-components/p-bd03efe0.system.js +0 -1
  75. package/dist/mint-components/p-c13c20b2.system.js +0 -1
  76. package/dist/mint-components/p-db6bf7cf.system.entry.js +0 -1
@@ -3,7 +3,7 @@
3
3
  const domContextHooks_module = require('./dom-context-hooks.module-e7b6727c.js');
4
4
  const index_module = require('./index.module-f8c8495f.js');
5
5
  const jsonpointer = require('./jsonpointer-11327262.js');
6
- const subregions = require('./subregions-984e30d7.js');
6
+ const subregions = require('./subregions-3542b0b8.js');
7
7
  const data = require('./data-89ac73dd.js');
8
8
  const eventKeys = require('./eventKeys-7af4df4d.js');
9
9
 
@@ -1151,6 +1151,8 @@ const COMPLETE_PARTNER = index_module.dist.gql `
1151
1151
  impactConnection {
1152
1152
  connected
1153
1153
  publisher {
1154
+ phoneNumber
1155
+ phoneNumberCountryCode
1154
1156
  brandedSignup
1155
1157
  requiredTaxDocumentType
1156
1158
  currentTaxDocument {
@@ -0,0 +1,215 @@
1
+ 'use strict';
2
+
3
+ const domContextHooks_module = require('./dom-context-hooks.module-e7b6727c.js');
4
+ const index_module = require('./index.module-f8c8495f.js');
5
+ const jsonpointer = require('./jsonpointer-11327262.js');
6
+ const AsYouType = require('./AsYouType-d15caac8.js');
7
+ const useRegistrationFormState = require('./useRegistrationFormState-4fe5b770.js');
8
+
9
+ const RegistrationFormQuery = index_module.dist.gql `
10
+ query RegistrationFormQuery($key: String!) {
11
+ form(key: $key) {
12
+ key
13
+ type
14
+ initialData {
15
+ initialData
16
+ isEnabled
17
+ isEnabledErrorMessage
18
+ }
19
+ }
20
+ }
21
+ `;
22
+ function usePortalRegistrationForm(props) {
23
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
24
+ const formRef = domContextHooks_module.useRef(null);
25
+ const locale = index_module.L();
26
+ const { registrationFormState, setRegistrationFormState } = useRegistrationFormState.useRegistrationFormState({});
27
+ const [request, { loading, errors, data, formError }] = index_module.Oe();
28
+ const queryResponse = index_module.wn(RegistrationFormQuery, { key: props.formKey });
29
+ const formLoading = loading || queryResponse.loading;
30
+ domContextHooks_module.useEffect(() => {
31
+ var _a, _b, _c;
32
+ const initialData = (_a = queryResponse === null || queryResponse === void 0 ? void 0 : queryResponse.data) === null || _a === void 0 ? void 0 : _a.form.initialData.initialData;
33
+ const disabled = ((_b = queryResponse === null || queryResponse === void 0 ? void 0 : queryResponse.data) === null || _b === void 0 ? void 0 : _b.form.initialData.isEnabled) === false;
34
+ const disabledMessage = ((_c = queryResponse === null || queryResponse === void 0 ? void 0 : queryResponse.data) === null || _c === void 0 ? void 0 : _c.form.initialData.isEnabledErrorMessage) ||
35
+ props.formDisabledErrorMessage;
36
+ const formState = {
37
+ loading: formLoading,
38
+ disabled,
39
+ disabledMessage,
40
+ initialData,
41
+ };
42
+ setRegistrationFormState(formState);
43
+ }, [(_a = queryResponse === null || queryResponse === void 0 ? void 0 : queryResponse.data) === null || _a === void 0 ? void 0 : _a.form.initialData]);
44
+ domContextHooks_module.useEffect(() => {
45
+ if (!formRef.current)
46
+ return;
47
+ const form = formRef.current;
48
+ form.addEventListener("sl-input", inputFunction);
49
+ return () => {
50
+ form.removeEventListener("sl-input", inputFunction);
51
+ };
52
+ }, [formRef.current]);
53
+ const submit = async (event) => {
54
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
55
+ let formControls = event.target.getFormControls();
56
+ let formData = {};
57
+ let validationErrors = {};
58
+ formControls === null || formControls === void 0 ? void 0 : formControls.forEach((control) => {
59
+ if (!control.name)
60
+ return;
61
+ const key = control.name;
62
+ const value = control.value;
63
+ // control.value = initialData[key] || control.value;
64
+ jsonpointer.jsonpointer.set(formData, key, value);
65
+ // required validation
66
+ if (control.required && !value) {
67
+ jsonpointer.jsonpointer.set(validationErrors, key, props.requiredFieldErrorMessage);
68
+ }
69
+ // custom validation
70
+ if (typeof control.validationError === "function") {
71
+ const validate = control.validationError;
72
+ const validationError = validate({ control, key, value });
73
+ if (validationError)
74
+ jsonpointer.jsonpointer.set(validationErrors, key, validationError);
75
+ }
76
+ });
77
+ if ((props.confirmPassword || formData.confirmPassword) &&
78
+ formData.password !== formData.confirmPassword) {
79
+ validationErrors = {
80
+ ...validationErrors,
81
+ confirmPassword: props.passwordMismatchErrorMessage,
82
+ };
83
+ }
84
+ if (Object.keys(validationErrors).length) {
85
+ // early return for validation errors
86
+ setRegistrationFormState({
87
+ ...registrationFormState,
88
+ loading: false,
89
+ error: "",
90
+ validationErrors,
91
+ });
92
+ return;
93
+ }
94
+ setRegistrationFormState({
95
+ ...registrationFormState,
96
+ loading: true,
97
+ error: "",
98
+ validationErrors: {},
99
+ });
100
+ const { email, password } = formData;
101
+ delete formData.email;
102
+ delete formData.password;
103
+ delete formData.confirmPassword;
104
+ const redirectPath = props.redirectPath;
105
+ const _googleOAuthIdToken = registrationFormState._googleOAuthIdToken;
106
+ const variables = {
107
+ key: props.formKey,
108
+ formData: {
109
+ ...(_googleOAuthIdToken ? { _googleOAuthIdToken } : {}),
110
+ locale,
111
+ email,
112
+ password,
113
+ redirectPath,
114
+ ...formData,
115
+ },
116
+ };
117
+ try {
118
+ const result = await request(variables);
119
+ if (result instanceof Error) {
120
+ throw result;
121
+ }
122
+ setRegistrationFormState({
123
+ ...registrationFormState,
124
+ loading: false,
125
+ error: "",
126
+ validationErrors: {},
127
+ });
128
+ const managedIdentityResponse = (_a = result.submitForm) === null || _a === void 0 ? void 0 : _a.results.find((result) => { var _a; return ((_a = result === null || result === void 0 ? void 0 : result.formHandler) === null || _a === void 0 ? void 0 : _a.namespace) === "identity"; });
129
+ if (managedIdentityResponse &&
130
+ managedIdentityResponse.result.results.length &&
131
+ managedIdentityResponse.result.results[0].success &&
132
+ managedIdentityResponse.result.results[0].data.token) {
133
+ index_module.jn.push(props.nextPage);
134
+ }
135
+ else if (
136
+ // check for blocked email error response
137
+ ((_b = result.submitForm) === null || _b === void 0 ? void 0 : _b.results.length) === 1 &&
138
+ ((_f = (_e = (_d = (_c = result.submitForm) === null || _c === void 0 ? void 0 : _c.results[0]) === null || _d === void 0 ? void 0 : _d.result) === null || _e === void 0 ? void 0 : _e.results) === null || _f === void 0 ? void 0 : _f.length) === 1 &&
139
+ ((_l = (_k = (_j = (_h = (_g = result.submitForm) === null || _g === void 0 ? void 0 : _g.results[0]) === null || _h === void 0 ? void 0 : _h.result) === null || _j === void 0 ? void 0 : _j.results) === null || _k === void 0 ? void 0 : _k[0]) === null || _l === void 0 ? void 0 : _l.success) ===
140
+ false && ((_s = (_r = (_q = (_p = (_o = (_m = result.submitForm) === null || _m === void 0 ? void 0 : _m.results[0]) === null || _o === void 0 ? void 0 : _o.result) === null || _p === void 0 ? void 0 : _p.results) === null || _q === void 0 ? void 0 : _q[0]) === null || _r === void 0 ? void 0 : _r.message) === null || _s === void 0 ? void 0 : _s.startsWith("Blocked email"))) {
141
+ setRegistrationFormState({
142
+ ...registrationFormState,
143
+ loading: false,
144
+ error: "",
145
+ validationErrors: {
146
+ email: props.invalidEmailErrorMessage,
147
+ },
148
+ });
149
+ }
150
+ }
151
+ catch (error) {
152
+ // check for invalid email
153
+ if ((_t = error === null || error === void 0 ? void 0 : error.message) === null || _t === void 0 ? void 0 : _t.includes("is not a valid email address")) {
154
+ setRegistrationFormState({
155
+ ...registrationFormState,
156
+ loading: false,
157
+ error: "",
158
+ validationErrors: { email: props.invalidEmailErrorMessage },
159
+ });
160
+ }
161
+ else {
162
+ setRegistrationFormState({
163
+ ...registrationFormState,
164
+ loading: false,
165
+ error: props.networkErrorMessage,
166
+ validationErrors: {},
167
+ });
168
+ }
169
+ }
170
+ };
171
+ const inputFunction = index_module.useCallback((e) => {
172
+ var _a, _b;
173
+ const name = (_b = (_a = e.target) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.toLowerCase();
174
+ if (name !== "tel")
175
+ return;
176
+ const asYouType = new AsYouType.AsYouType("US");
177
+ e.target.value = asYouType.input(e.target.value);
178
+ }, []);
179
+ let errorMessage = "";
180
+ if (((_b = queryResponse === null || queryResponse === void 0 ? void 0 : queryResponse.data) === null || _b === void 0 ? void 0 : _b.form.initialData.isEnabled) === false) {
181
+ errorMessage =
182
+ ((_c = queryResponse === null || queryResponse === void 0 ? void 0 : queryResponse.data) === null || _c === void 0 ? void 0 : _c.form.initialData.isEnabledErrorMessage) ||
183
+ props.formDisabledErrorMessage;
184
+ }
185
+ else if ((_d = errors === null || errors === void 0 ? void 0 : errors.response) === null || _d === void 0 ? void 0 : _d["error"]) {
186
+ errorMessage = props.networkErrorMessage;
187
+ }
188
+ else if ((errors === null || errors === void 0 ? void 0 : errors.message) && !((_e = errors === null || errors === void 0 ? void 0 : errors.response) === null || _e === void 0 ? void 0 : _e.errors.length)) {
189
+ errorMessage = props.networkErrorMessage;
190
+ }
191
+ else {
192
+ errorMessage =
193
+ formError || ((_j = (_h = (_g = (_f = queryResponse === null || queryResponse === void 0 ? void 0 : queryResponse.errors) === null || _f === void 0 ? void 0 : _f.response) === null || _g === void 0 ? void 0 : _g.errors) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.message) || (registrationFormState === null || registrationFormState === void 0 ? void 0 : registrationFormState.error);
194
+ }
195
+ return {
196
+ states: {
197
+ loading: loading || queryResponse.loading,
198
+ error: errorMessage,
199
+ registrationFormState,
200
+ confirmPassword: props.confirmPassword,
201
+ hideInputs: props.hideInputs,
202
+ loginPath: props.loginPath,
203
+ enablePasswordValidation: !props.disablePasswordValidation,
204
+ },
205
+ callbacks: {
206
+ submit,
207
+ inputFunction,
208
+ },
209
+ refs: {
210
+ formRef,
211
+ },
212
+ };
213
+ }
214
+
215
+ exports.usePortalRegistrationForm = usePortalRegistrationForm;
@@ -219,6 +219,10 @@ export const PHONE_EXTENSIONS = {
219
219
  name: "Cuba",
220
220
  dial_code: "+53",
221
221
  },
222
+ CW: {
223
+ name: "Curaçao",
224
+ dial_code: "+599",
225
+ },
222
226
  CY: {
223
227
  name: "Cyprus",
224
228
  dial_code: "+357",
@@ -299,6 +303,10 @@ export const PHONE_EXTENSIONS = {
299
303
  name: "French Polynesia",
300
304
  dial_code: "+689",
301
305
  },
306
+ TF: {
307
+ name: "French Southern Territories",
308
+ dial_code: "+262",
309
+ },
302
310
  GA: {
303
311
  name: "Gabon",
304
312
  dial_code: "+241",
@@ -955,6 +963,10 @@ export const PHONE_EXTENSIONS = {
955
963
  name: "Wallis and Futuna",
956
964
  dial_code: "+681",
957
965
  },
966
+ EH: {
967
+ name: "Western Sahara",
968
+ dial_code: "+212",
969
+ },
958
970
  YE: {
959
971
  name: "Yemen",
960
972
  dial_code: "+967",
@@ -46,6 +46,8 @@ export const COMPLETE_PARTNER = gql `
46
46
  impactConnection {
47
47
  connected
48
48
  publisher {
49
+ phoneNumber
50
+ phoneNumberCountryCode
49
51
  brandedSignup
50
52
  requiredTaxDocumentType
51
53
  currentTaxDocument {
@@ -1,6 +1,6 @@
1
1
  import { getContextValueName, useHost, useLocale, useMutation, useParentQuery, useParentState, useUserIdentity, } from "@saasquatch/component-boilerplate";
2
2
  import { useEffect, useMemo } from "@saasquatch/universal-hooks";
3
- import { getCountryObj } from "../utils";
3
+ import { getCountryObj, isValidI18nPhoneNumber } from "../utils";
4
4
  import { COUNTRIES_NAMESPACE, COUNTRIES_QUERY_NAMESPACE, CURRENCIES_NAMESPACE, CURRENCIES_QUERY_NAMESPACE, FINANCE_NETWORK_SETTINGS_NAMESPACE, GET_COUNTRIES, GET_CURRENCIES, GET_FINANCE_NETWORK_SETTINGS, GET_USER, SORTED_COUNTRIES_NAMESPACE, TAX_CONTEXT_NAMESPACE, TAX_FORM_CONTEXT_NAMESPACE, USER_FORM_CONTEXT_NAMESPACE, USER_QUERY_NAMESPACE, } from "../data";
5
5
  import { COMPLETE_PARTNER, } from "../sqm-indirect-tax-form/useIndirectTaxForm";
6
6
  function getCurrentStep(user) {
@@ -8,15 +8,19 @@ function getCurrentStep(user) {
8
8
  if (!((_a = user.impactConnection) === null || _a === void 0 ? void 0 : _a.connected) || !((_b = user.impactConnection) === null || _b === void 0 ? void 0 : _b.publisher)) {
9
9
  return "/1";
10
10
  }
11
- const { requiredTaxDocumentType, currentTaxDocument, withdrawalSettings, brandedSignup, payoutsAccount, billingAddress, billingCity, billingCountryCode, billingPostalCode, billingState, phoneNumber, phoneNumberCountryCode, } = user.impactConnection.publisher;
12
- const hasBillingInfo = billingAddress &&
13
- billingCity &&
14
- billingCountryCode &&
15
- billingPostalCode &&
16
- phoneNumberCountryCode &&
17
- phoneNumber;
18
- if (!hasBillingInfo) {
19
- return "/1";
11
+ const { requiredTaxDocumentType, currentTaxDocument, withdrawalSettings, brandedSignup, payoutsAccount, billingAddress, billingCity, billingCountryCode, billingPostalCode, phoneNumber, phoneNumberCountryCode, } = user.impactConnection.publisher;
12
+ const isCompleted = user.impactConnection.connectionStatus === "COMPLETED";
13
+ if (!isCompleted) {
14
+ const hasBillingInfo = billingAddress &&
15
+ billingCity &&
16
+ billingCountryCode &&
17
+ billingPostalCode &&
18
+ phoneNumberCountryCode &&
19
+ phoneNumber &&
20
+ isValidI18nPhoneNumber(phoneNumberCountryCode, phoneNumber);
21
+ if (!hasBillingInfo) {
22
+ return "/1";
23
+ }
20
24
  }
21
25
  // If they do have a required document, look at current document
22
26
  if (requiredTaxDocumentType && !currentTaxDocument) {
@@ -158,7 +162,8 @@ export function useTaxAndCash() {
158
162
  publisher.billingCountryCode &&
159
163
  publisher.billingPostalCode &&
160
164
  publisher.phoneNumberCountryCode &&
161
- publisher.phoneNumber;
165
+ publisher.phoneNumber &&
166
+ isValidI18nPhoneNumber(publisher.phoneNumberCountryCode, publisher.phoneNumber);
162
167
  if (hasBillingInfo &&
163
168
  ((_b = user === null || user === void 0 ? void 0 : user.impactConnection) === null || _b === void 0 ? void 0 : _b.connectionStatus) === "STARTED") {
164
169
  const vars = {
@@ -11,6 +11,8 @@ const mockCountries = [
11
11
  { countryCode: "DE", displayName: "Germany" },
12
12
  { countryCode: "FR", displayName: "France" },
13
13
  { countryCode: "ES", displayName: "Spain" },
14
+ // Show handling of long country names
15
+ { countryCode: "CD", displayName: "Congo, The Democratic Republic of the Congo" },
14
16
  ];
15
17
  const mockCurrencies = [
16
18
  { currencyCode: "USD", displayName: "US Dollar" },
@@ -105,7 +105,7 @@ export const OtherRegionSlotView = (props) => {
105
105
  helpText: formatErrorMessage(text.subRegion, text.error.fieldRequiredError),
106
106
  }), { id: "subRegion", name: "/subRegion" }), props.data.esRegions.map((r) => (h("sl-menu-item", { value: r.regionCode }, r.displayName)))),
107
107
  h(IndirectTaxNumberInput, { name: "indirectTaxNumber", label: getTaxFieldLabel("VAT"), error: getTaxFieldError("VAT") }),
108
- h("sl-checkbox", { class: classes.Checkbox, exportparts: "label: input-label, base: input-base", checked: formState.hasSubRegionTaxNumber, "onSl-change": callbacks.onSpainToggle, disabled: states.disabled || states.isPartner }, text.isRegisteredSubRegionIncomeTax),
108
+ h("sl-checkbox", { class: classes.Checkbox, exportparts: "label: input-label, base: input-base", checked: formState.hasSubRegionTaxNumber, "onSl-change": callbacks.onSpainToggle, disabled: states.disabled }, text.isRegisteredSubRegionIncomeTax),
109
109
  formState.hasSubRegionTaxNumber && (h("sl-input", Object.assign({ required: true, exportparts: "label: input-label, base: input-base", 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) && {
110
110
  class: classes.ErrorInput,
111
111
  helpText: formatErrorMessage(text.subRegionTaxNumberLabel, text.error.fieldRequiredError),
@@ -123,7 +123,7 @@ export const OtherRegionSlotView = (props) => {
123
123
  currentTaxType === "GST" && (h(IndirectTaxNumberInput, { label: getTaxFieldLabel("GST"), error: getTaxFieldError("GST"), name: "indirectTaxNumber" })),
124
124
  currentTaxType === "HST" && (h(IndirectTaxNumberInput, { label: getTaxFieldLabel("HST"), error: getTaxFieldError("HST"), name: "indirectTaxNumber" })),
125
125
  formState.province === "QUEBEC" && (h("div", { class: classes.ConditionalInputsContainer },
126
- h("sl-checkbox", { class: classes.Checkbox, exportparts: "label: input-label, base: input-base", "onSl-change": callbacks.onQstToggle, checked: formState.hasQst, disabled: states.isPartner || states.disabled }, text.isRegisteredQST),
126
+ h("sl-checkbox", { class: classes.Checkbox, exportparts: "label: input-label, base: input-base", "onSl-change": callbacks.onQstToggle, checked: formState.hasQst, disabled: states.disabled }, text.isRegisteredQST),
127
127
  formState.hasQst && (h(IndirectTaxNumberInput, { name: "qstNumber", label: text.qstNumber, error: formatErrorMessage(text.qstNumber, text.error.fieldRequiredError) }))))));
128
128
  };
129
129
  const getActiveForm = (selectedRegion) => {
@@ -1,4 +1,5 @@
1
1
  import { h } from "@stencil/core";
2
+ import { AsYouType } from "libphonenumber-js";
2
3
  import { intl } from "../../../global/global";
3
4
  import { createStyleSheet } from "../../../styling/JSS";
4
5
  import { FORM_STEPS } from "../data";
@@ -107,10 +108,6 @@ const vanillaStyle = `
107
108
  flex-direction: column;
108
109
  }
109
110
 
110
- sl-select#phoneNumberCountryCode::part(menu) {
111
- min-width: 250px;
112
- }
113
-
114
111
  sl-button[type="primary"]::part(base){
115
112
  background-color: var(--sqm-primary-button-background);
116
113
  color: var(--sqm-primary-button-color);
@@ -204,6 +201,7 @@ const vanillaStyle = `
204
201
  background: var(--sqm-input-background, inherit);
205
202
  color: var(--sqm-input-color, inherit);
206
203
  border:none;
204
+ min-width: max-content;
207
205
  }
208
206
 
209
207
  sl-menu-item::part(base) {
@@ -388,7 +386,12 @@ export const UserInfoFormView = (props) => {
388
386
  h("div", { slot: "prefix" }, `${(_a = PHONE_EXTENSIONS[c.countryCode]) === null || _a === void 0 ? void 0 : _a.name} `), (_b = PHONE_EXTENSIONS[c.countryCode]) === null || _b === void 0 ? void 0 :
389
387
  _b.dial_code));
390
388
  })),
391
- h("sl-input", Object.assign({ exportparts: "label: input-label, base: input-base", id: "phoneNumber", name: "/phoneNumber", value: formState.phoneNumber, validationError: ({ control, value, formData }) => {
389
+ h("sl-input", Object.assign({ exportparts: "label: input-label, base: input-base", id: "phoneNumber", name: "/phoneNumber", value: formState.phoneNumber, "onSl-input": (e) => {
390
+ var _a;
391
+ const target = e.target;
392
+ const country = (((_a = refs.phoneCountryRef.current) === null || _a === void 0 ? void 0 : _a.value) || "US");
393
+ target.value = new AsYouType(country).input(target.value);
394
+ }, validationError: ({ control, value, formData }) => {
392
395
  // skip validation for values the user can't edit
393
396
  if (control === null || control === void 0 ? void 0 : control.disabled)
394
397
  return undefined;
@@ -3,7 +3,7 @@ import { useEffect, useMemo, useRef, useState, } from "@saasquatch/universal-hoo
3
3
  import jsonpointer from "jsonpointer";
4
4
  import { CURRENCIES_NAMESPACE, SORTED_COUNTRIES_NAMESPACE, TAX_CONTEXT_NAMESPACE, TAX_FORM_CONTEXT_NAMESPACE, USER_FORM_CONTEXT_NAMESPACE, USER_QUERY_NAMESPACE, } from "../data";
5
5
  import { ADDRESS_REGIONS } from "../subregions";
6
- import { objectIsFull, validTaxDocument } from "../utils";
6
+ import { objectIsFull, toDomesticNumber, validTaxDocument } from "../utils";
7
7
  import { TAX_FORM_UPDATED_EVENT_KEY } from "../eventKeys";
8
8
  import { CONNECT_PARTNER, COMPLETE_PARTNER, } from "../sqm-indirect-tax-form/useIndirectTaxForm";
9
9
  import { gql } from "graphql-request";
@@ -150,12 +150,12 @@ export function useUserInfoForm(props) {
150
150
  city: formData.city,
151
151
  state: formData.state,
152
152
  postalCode: formData.postalCode,
153
- phoneNumber: formData.phoneNumber,
153
+ phoneNumber: toDomesticNumber(formData.phoneNumberCountryCode, formData.phoneNumber),
154
154
  phoneNumberCountryCode: formData.phoneNumberCountryCode,
155
155
  };
156
156
  // If the partner has already been started call completeImpactPartner to
157
157
  // update the remaining details. Otherwise create a new connection.
158
- const userData = data === null || data === void 0 ? void 0 : data.user;
158
+ // const userData = data?.user;
159
159
  let result = null;
160
160
  let connectionResult;
161
161
  result = await completeImpactPartner({
@@ -220,12 +220,13 @@ export function useUserInfoForm(props) {
220
220
  return;
221
221
  }
222
222
  const { allowBankingCollection, ...userData } = formData;
223
+ const normalizedPhoneNumber = toDomesticNumber(userData.phoneNumberCountryCode, userData.phoneNumber);
223
224
  setUserFormContext({
224
225
  ...userFormContext,
225
226
  firstName: userData.firstName,
226
227
  lastName: userData.lastName,
227
228
  phoneNumberCountryCode: userData.phoneNumberCountryCode,
228
- phoneNumber: userData.phoneNumber,
229
+ phoneNumber: normalizedPhoneNumber,
229
230
  countryCode: userData.countryCode,
230
231
  address: userData.address,
231
232
  city: userData.city,
@@ -236,7 +237,10 @@ export function useUserInfoForm(props) {
236
237
  const skipNextStep = getSkipNextStep(userData);
237
238
  if (skipNextStep) {
238
239
  try {
239
- const { resultPublisher, hasValidCurrentDocument } = await connectPartner(formData);
240
+ const { resultPublisher, hasValidCurrentDocument } = await connectPartner({
241
+ ...formData,
242
+ phoneNumber: normalizedPhoneNumber,
243
+ });
240
244
  if ((resultPublisher === null || resultPublisher === void 0 ? void 0 : resultPublisher.requiredTaxDocumentType) &&
241
245
  !hasValidCurrentDocument) {
242
246
  // Go to docusign form
@@ -1,31 +1,46 @@
1
+ import { parsePhoneNumberFromString } from "libphonenumber-js";
1
2
  import { intl } from "../../global/global";
2
- import { PHONE_EXTENSIONS } from "./phoneExtensions";
3
- function stripLeadingZero(d) {
4
- return d.startsWith("0") ? d.slice(1) : d;
3
+ /**
4
+ * Normalize user input to the domestic form Impact stores: digits only,
5
+ * with the country dial code and trunk-zero prefix removed.
6
+ */
7
+ export function toDomesticNumber(phoneCountryCode, input) {
8
+ var _a;
9
+ if (!input)
10
+ return "";
11
+ const parsed = parsePhoneNumberFromString(input, phoneCountryCode === null || phoneCountryCode === void 0 ? void 0 : phoneCountryCode.toUpperCase());
12
+ return (_a = parsed === null || parsed === void 0 ? void 0 : parsed.nationalNumber) !== null && _a !== void 0 ? _a : input.replace(/\D/g, "");
5
13
  }
6
14
  /**
7
- * Mirrors Impact's I18nPhoneNumberParams validation rules per country.
8
- * Returns true when the phone number is valid for the given the phoneNumberCountryCode country.
15
+ * Validates a phone number against both libphonenumber-js's per-country
16
+ * pattern rules AND Impact's I18nPhoneNumber length rules, applied to the
17
+ * sanitized value we'll submit.
9
18
  */
10
19
  export function isValidI18nPhoneNumber(phoneCountryCode, phoneNumber) {
11
- var _a, _b;
12
20
  if (!phoneCountryCode || !(phoneNumber === null || phoneNumber === void 0 ? void 0 : phoneNumber.trim()))
13
21
  return false;
14
22
  const country = phoneCountryCode.toUpperCase();
15
- const digits = phoneNumber.replace(/\D/g, "");
23
+ const parsed = parsePhoneNumberFromString(phoneNumber, country);
24
+ if (!(parsed === null || parsed === void 0 ? void 0 : parsed.isValid()))
25
+ return false;
26
+ return passesImpactBackendLengthCheck(country, toDomesticNumber(country, phoneNumber));
27
+ }
28
+ /**
29
+ * Mirrors estalea.bucket.phone.I18nPhoneNumber.isValidI18nPhoneNumber()
30
+ * length rules on the already-sanitized (digits-only) submission value.
31
+ */
32
+ function passesImpactBackendLengthCheck(country, digits) {
33
+ if (!digits)
34
+ return false;
16
35
  switch (country) {
17
36
  case "US":
18
37
  case "CA": {
19
- // strip a single leading "1", then exactly 10 digits
20
38
  const n = digits.startsWith("1") ? digits.slice(1) : digits;
21
39
  return n.length === 10;
22
40
  }
23
41
  case "AU":
24
- // 9 or 10 digits
25
42
  return digits.length === 9 || digits.length === 10;
26
43
  case "NZ": {
27
- // trim "640" country prefix or leading "0" (only when >9 digits),
28
- // then 8–10 digits
29
44
  let n = digits;
30
45
  if (n.length > 9) {
31
46
  if (n.startsWith("640"))
@@ -35,25 +50,13 @@ export function isValidI18nPhoneNumber(phoneCountryCode, phoneNumber) {
35
50
  }
36
51
  return n.length >= 8 && n.length <= 10;
37
52
  }
38
- case "GB":
39
- // >= 6 digits after stripping a single leading "0", no dialing-code check
53
+ default:
40
54
  return stripLeadingZero(digits).length >= 6;
41
- default: {
42
- // All other countries: strip a single leading "0", then >= 6 digits
43
- if (stripLeadingZero(digits).length < 6)
44
- return false;
45
- // If input starts with "+", the dialing code (first whitespace-split
46
- // token) must match the selected country exactly. Splits on first
47
- // whitespace, so "+4420 7946 0958" supplies "4420" (not "44") and fails.
48
- if (phoneNumber.trim().startsWith("+")) {
49
- const supplied = phoneNumber.trim().split(/\s/)[0].slice(1);
50
- const expected = (_b = (_a = PHONE_EXTENSIONS[country]) === null || _a === void 0 ? void 0 : _a.dial_code) === null || _b === void 0 ? void 0 : _b.replace(/^\+/, "");
51
- return expected === supplied;
52
- }
53
- return true;
54
- }
55
55
  }
56
56
  }
57
+ function stripLeadingZero(digits) {
58
+ return digits.startsWith("0") ? digits.slice(1) : digits;
59
+ }
57
60
  export function validTaxDocument(requiredType) {
58
61
  const validTypes = ["W9", "W8BENE", "W8BEN"];
59
62
  if (validTypes.includes(requiredType))