@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
@@ -1,7 +1,7 @@
1
1
  import { k as useState, f as useEffect, m as useRef, u as useMemo } from './dom-context-hooks.module-50442785.js';
2
2
  import { d as dist, J, $ as $e, g as getEnvironmentSDK, w as wn, L, F as Fn, q as Pn, r as $n } from './index.module-02cb914c.js';
3
3
  import { j as jsonpointer } from './jsonpointer-388a7082.js';
4
- import { I as INDIRECT_TAX_SPAIN_REGIONS, a as INDIRECT_TAX_PROVINCES, g as getCountryObj, b as validTaxDocument } from './subregions-7c9778d0.js';
4
+ import { I as INDIRECT_TAX_SPAIN_REGIONS, a as INDIRECT_TAX_PROVINCES, g as getCountryObj, b as validTaxDocument } from './subregions-7c5112e8.js';
5
5
  import { a as TAX_FORM_CONTEXT_NAMESPACE, U as USER_FORM_CONTEXT_NAMESPACE, d as COUNTRIES_QUERY_NAMESPACE, T as TAX_CONTEXT_NAMESPACE, c as USER_QUERY_NAMESPACE } from './data-8698cbc6.js';
6
6
  import { T as TAX_FORM_UPDATED_EVENT_KEY } from './eventKeys-f76b6a03.js';
7
7
 
@@ -1149,6 +1149,8 @@ const COMPLETE_PARTNER = dist.gql `
1149
1149
  impactConnection {
1150
1150
  connected
1151
1151
  publisher {
1152
+ phoneNumber
1153
+ phoneNumberCountryCode
1152
1154
  brandedSignup
1153
1155
  requiredTaxDocumentType
1154
1156
  currentTaxDocument {
@@ -0,0 +1,213 @@
1
+ import { m as useRef, f as useEffect } from './dom-context-hooks.module-50442785.js';
2
+ import { d as dist, L, O as Oe, w as wn, j as jn, b as useCallback } from './index.module-02cb914c.js';
3
+ import { j as jsonpointer } from './jsonpointer-388a7082.js';
4
+ import { A as AsYouType } from './AsYouType-2d56519e.js';
5
+ import { u as useRegistrationFormState } from './useRegistrationFormState-aa44cfff.js';
6
+
7
+ const RegistrationFormQuery = dist.gql `
8
+ query RegistrationFormQuery($key: String!) {
9
+ form(key: $key) {
10
+ key
11
+ type
12
+ initialData {
13
+ initialData
14
+ isEnabled
15
+ isEnabledErrorMessage
16
+ }
17
+ }
18
+ }
19
+ `;
20
+ function usePortalRegistrationForm(props) {
21
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
22
+ const formRef = useRef(null);
23
+ const locale = L();
24
+ const { registrationFormState, setRegistrationFormState } = useRegistrationFormState({});
25
+ const [request, { loading, errors, data, formError }] = Oe();
26
+ const queryResponse = wn(RegistrationFormQuery, { key: props.formKey });
27
+ const formLoading = loading || queryResponse.loading;
28
+ useEffect(() => {
29
+ var _a, _b, _c;
30
+ const initialData = (_a = queryResponse === null || queryResponse === void 0 ? void 0 : queryResponse.data) === null || _a === void 0 ? void 0 : _a.form.initialData.initialData;
31
+ const disabled = ((_b = queryResponse === null || queryResponse === void 0 ? void 0 : queryResponse.data) === null || _b === void 0 ? void 0 : _b.form.initialData.isEnabled) === false;
32
+ const disabledMessage = ((_c = queryResponse === null || queryResponse === void 0 ? void 0 : queryResponse.data) === null || _c === void 0 ? void 0 : _c.form.initialData.isEnabledErrorMessage) ||
33
+ props.formDisabledErrorMessage;
34
+ const formState = {
35
+ loading: formLoading,
36
+ disabled,
37
+ disabledMessage,
38
+ initialData,
39
+ };
40
+ setRegistrationFormState(formState);
41
+ }, [(_a = queryResponse === null || queryResponse === void 0 ? void 0 : queryResponse.data) === null || _a === void 0 ? void 0 : _a.form.initialData]);
42
+ useEffect(() => {
43
+ if (!formRef.current)
44
+ return;
45
+ const form = formRef.current;
46
+ form.addEventListener("sl-input", inputFunction);
47
+ return () => {
48
+ form.removeEventListener("sl-input", inputFunction);
49
+ };
50
+ }, [formRef.current]);
51
+ const submit = async (event) => {
52
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
53
+ let formControls = event.target.getFormControls();
54
+ let formData = {};
55
+ let validationErrors = {};
56
+ formControls === null || formControls === void 0 ? void 0 : formControls.forEach((control) => {
57
+ if (!control.name)
58
+ return;
59
+ const key = control.name;
60
+ const value = control.value;
61
+ // control.value = initialData[key] || control.value;
62
+ jsonpointer.set(formData, key, value);
63
+ // required validation
64
+ if (control.required && !value) {
65
+ jsonpointer.set(validationErrors, key, props.requiredFieldErrorMessage);
66
+ }
67
+ // custom validation
68
+ if (typeof control.validationError === "function") {
69
+ const validate = control.validationError;
70
+ const validationError = validate({ control, key, value });
71
+ if (validationError)
72
+ jsonpointer.set(validationErrors, key, validationError);
73
+ }
74
+ });
75
+ if ((props.confirmPassword || formData.confirmPassword) &&
76
+ formData.password !== formData.confirmPassword) {
77
+ validationErrors = {
78
+ ...validationErrors,
79
+ confirmPassword: props.passwordMismatchErrorMessage,
80
+ };
81
+ }
82
+ if (Object.keys(validationErrors).length) {
83
+ // early return for validation errors
84
+ setRegistrationFormState({
85
+ ...registrationFormState,
86
+ loading: false,
87
+ error: "",
88
+ validationErrors,
89
+ });
90
+ return;
91
+ }
92
+ setRegistrationFormState({
93
+ ...registrationFormState,
94
+ loading: true,
95
+ error: "",
96
+ validationErrors: {},
97
+ });
98
+ const { email, password } = formData;
99
+ delete formData.email;
100
+ delete formData.password;
101
+ delete formData.confirmPassword;
102
+ const redirectPath = props.redirectPath;
103
+ const _googleOAuthIdToken = registrationFormState._googleOAuthIdToken;
104
+ const variables = {
105
+ key: props.formKey,
106
+ formData: {
107
+ ...(_googleOAuthIdToken ? { _googleOAuthIdToken } : {}),
108
+ locale,
109
+ email,
110
+ password,
111
+ redirectPath,
112
+ ...formData,
113
+ },
114
+ };
115
+ try {
116
+ const result = await request(variables);
117
+ if (result instanceof Error) {
118
+ throw result;
119
+ }
120
+ setRegistrationFormState({
121
+ ...registrationFormState,
122
+ loading: false,
123
+ error: "",
124
+ validationErrors: {},
125
+ });
126
+ 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"; });
127
+ if (managedIdentityResponse &&
128
+ managedIdentityResponse.result.results.length &&
129
+ managedIdentityResponse.result.results[0].success &&
130
+ managedIdentityResponse.result.results[0].data.token) {
131
+ jn.push(props.nextPage);
132
+ }
133
+ else if (
134
+ // check for blocked email error response
135
+ ((_b = result.submitForm) === null || _b === void 0 ? void 0 : _b.results.length) === 1 &&
136
+ ((_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 &&
137
+ ((_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) ===
138
+ 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"))) {
139
+ setRegistrationFormState({
140
+ ...registrationFormState,
141
+ loading: false,
142
+ error: "",
143
+ validationErrors: {
144
+ email: props.invalidEmailErrorMessage,
145
+ },
146
+ });
147
+ }
148
+ }
149
+ catch (error) {
150
+ // check for invalid email
151
+ 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")) {
152
+ setRegistrationFormState({
153
+ ...registrationFormState,
154
+ loading: false,
155
+ error: "",
156
+ validationErrors: { email: props.invalidEmailErrorMessage },
157
+ });
158
+ }
159
+ else {
160
+ setRegistrationFormState({
161
+ ...registrationFormState,
162
+ loading: false,
163
+ error: props.networkErrorMessage,
164
+ validationErrors: {},
165
+ });
166
+ }
167
+ }
168
+ };
169
+ const inputFunction = useCallback((e) => {
170
+ var _a, _b;
171
+ const name = (_b = (_a = e.target) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.toLowerCase();
172
+ if (name !== "tel")
173
+ return;
174
+ const asYouType = new AsYouType("US");
175
+ e.target.value = asYouType.input(e.target.value);
176
+ }, []);
177
+ let errorMessage = "";
178
+ if (((_b = queryResponse === null || queryResponse === void 0 ? void 0 : queryResponse.data) === null || _b === void 0 ? void 0 : _b.form.initialData.isEnabled) === false) {
179
+ errorMessage =
180
+ ((_c = queryResponse === null || queryResponse === void 0 ? void 0 : queryResponse.data) === null || _c === void 0 ? void 0 : _c.form.initialData.isEnabledErrorMessage) ||
181
+ props.formDisabledErrorMessage;
182
+ }
183
+ else if ((_d = errors === null || errors === void 0 ? void 0 : errors.response) === null || _d === void 0 ? void 0 : _d["error"]) {
184
+ errorMessage = props.networkErrorMessage;
185
+ }
186
+ 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)) {
187
+ errorMessage = props.networkErrorMessage;
188
+ }
189
+ else {
190
+ errorMessage =
191
+ 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);
192
+ }
193
+ return {
194
+ states: {
195
+ loading: loading || queryResponse.loading,
196
+ error: errorMessage,
197
+ registrationFormState,
198
+ confirmPassword: props.confirmPassword,
199
+ hideInputs: props.hideInputs,
200
+ loginPath: props.loginPath,
201
+ enablePasswordValidation: !props.disablePasswordValidation,
202
+ },
203
+ callbacks: {
204
+ submit,
205
+ inputFunction,
206
+ },
207
+ refs: {
208
+ formRef,
209
+ },
210
+ };
211
+ }
212
+
213
+ export { usePortalRegistrationForm as u };