@saasquatch/mint-components 1.12.0-9 → 1.12.1-1

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 (187) hide show
  1. package/dist/cjs/{ShadowViewAddon-040cffad.js → ShadowViewAddon-88821c64.js} +3 -6
  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 +79 -202
  5. package/dist/cjs/sqm-big-stat_39.cjs.entry.js +160 -281
  6. package/dist/cjs/{sqm-invoice-table-view-c58966f8.js → sqm-invoice-table-view-a9133a11.js} +0 -98
  7. package/dist/cjs/sqm-portal-registration-form-view-621348a6.js +85 -0
  8. package/dist/cjs/sqm-portal-registration-form.cjs.entry.js +12 -81
  9. package/dist/cjs/sqm-stencilbook.cjs.entry.js +323 -334
  10. package/dist/collection/collection-manifest.json +1 -6
  11. package/dist/collection/components/sqm-big-stat/useBigStat.js +3 -6
  12. package/dist/collection/components/sqm-checkbox-field/sqm-checkbox-field.js +5 -5
  13. package/dist/collection/components/sqm-marketing-emails-checkbox/MarketingEmailsCheckbox.stories.js +11 -0
  14. package/dist/collection/components/sqm-marketing-emails-checkbox/sqm-marketing-emails-checkbox.js +160 -0
  15. package/dist/collection/components/sqm-portal-registration-form/PortalRegistrationForm.stories.js +5 -1
  16. package/dist/collection/components/sqm-portal-registration-form/sqm-portal-registration-form-view.js +1 -1
  17. package/dist/collection/components/sqm-portal-registration-form/sqm-portal-registration-form.js +3 -2
  18. package/dist/collection/components/sqm-portal-registration-form/usePortalRegistrationForm.js +6 -0
  19. package/dist/collection/components/sqm-stencilbook/sqm-stencilbook.js +4 -8
  20. package/dist/collection/components/tax-and-cash/BankingForm.stories.js +0 -2
  21. package/dist/collection/components/tax-and-cash/TaxForm.stories.js +0 -96
  22. package/dist/collection/components/tax-and-cash/sqm-banking-info-form/sqm-banking-info-form.js +1 -5
  23. package/dist/collection/components/tax-and-cash/sqm-banking-info-form/useBankingInfoForm.js +38 -101
  24. package/dist/collection/components/tax-and-cash/sqm-docusign-form/docusign-iframe/DocusignIframe.js +2 -15
  25. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash/data.js +0 -7
  26. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash/sqm-tax-and-cash.js +8 -8
  27. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash/useTaxAndCash.js +2 -2
  28. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard-view.js +0 -22
  29. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard.js +9 -99
  30. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash-dashboard/useTaxAndCashDashboard.js +1 -8
  31. package/dist/collection/components/tax-and-cash/sqm-user-info-form/sqm-user-info-form-view.js +2 -2
  32. package/dist/collection/components/tax-and-cash/sqm-user-info-form/useUserInfoForm.js +11 -14
  33. package/dist/esm/{ShadowViewAddon-69b61037.js → ShadowViewAddon-65c8679e.js} +3 -6
  34. package/dist/esm/loader.js +1 -1
  35. package/dist/esm/mint-components.js +1 -1
  36. package/dist/esm/sqm-banking-info-form_16.entry.js +79 -202
  37. package/dist/esm/sqm-big-stat_39.entry.js +159 -280
  38. package/dist/esm/{sqm-invoice-table-view-d1cfdaf4.js → sqm-invoice-table-view-71915a5e.js} +0 -98
  39. package/dist/esm/sqm-portal-registration-form-view-1d3066e1.js +83 -0
  40. package/dist/esm/sqm-portal-registration-form.entry.js +18 -87
  41. package/dist/esm/sqm-stencilbook.entry.js +323 -334
  42. package/dist/esm/stencil-hooks.module-ac12ca1c.js +1 -1
  43. package/dist/esm-es5/ShadowViewAddon-65c8679e.js +1 -0
  44. package/dist/esm-es5/loader.js +1 -1
  45. package/dist/esm-es5/mint-components.js +1 -1
  46. package/dist/esm-es5/sqm-banking-info-form_16.entry.js +1 -1
  47. package/dist/esm-es5/sqm-big-stat_39.entry.js +1 -1
  48. package/dist/esm-es5/sqm-invoice-table-view-71915a5e.js +1 -0
  49. package/dist/esm-es5/sqm-portal-registration-form-view-1d3066e1.js +1 -0
  50. package/dist/esm-es5/sqm-portal-registration-form.entry.js +1 -1
  51. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  52. package/dist/esm-es5/stencil-hooks.module-ac12ca1c.js +1 -1
  53. package/dist/mint-components/mint-components.esm.js +1 -1
  54. package/dist/mint-components/p-1279f7a3.system.entry.js +1 -0
  55. package/dist/mint-components/p-15a64357.entry.js +13 -0
  56. package/dist/mint-components/p-17f56865.entry.js +9 -0
  57. package/dist/mint-components/p-2a414b2e.system.js +2 -2
  58. package/dist/mint-components/p-3cb18382.system.js +1 -0
  59. package/dist/mint-components/p-40b1de58.js +1 -0
  60. package/dist/mint-components/p-4112e198.system.js +1 -0
  61. package/dist/mint-components/p-5cd917db.js +1 -0
  62. package/dist/mint-components/p-6792c8d8.system.entry.js +1 -0
  63. package/dist/mint-components/p-a02afa72.system.js +1 -0
  64. package/dist/mint-components/p-acd77a6e.entry.js +223 -0
  65. package/dist/mint-components/p-b3e97f8a.system.entry.js +1 -0
  66. package/dist/mint-components/{p-9eae245f.js → p-b651706a.js} +3 -6
  67. package/dist/mint-components/p-b8233366.entry.js +174 -0
  68. package/dist/mint-components/p-ca809fdd.system.js +1 -1
  69. package/dist/mint-components/p-cb38b9b0.system.entry.js +1 -0
  70. package/dist/mint-components/p-fd2c5407.js +2 -2
  71. package/dist/types/components/sqm-checkbox-field/sqm-checkbox-field-view.d.ts +1 -1
  72. package/dist/types/components/sqm-checkbox-field/sqm-checkbox-field.d.ts +4 -4
  73. package/dist/types/components/sqm-marketing-emails-checkbox/MarketingEmailsCheckbox.stories.d.ts +8 -0
  74. package/dist/types/components/sqm-marketing-emails-checkbox/sqm-marketing-emails-checkbox.d.ts +34 -0
  75. package/dist/types/components/sqm-portal-registration-form/PortalRegistrationForm.stories.d.ts +1 -0
  76. package/dist/types/components/sqm-portal-registration-form/sqm-portal-registration-form-view.d.ts +1 -0
  77. package/dist/types/components/sqm-portal-registration-form/sqm-portal-registration-form.d.ts +1 -1
  78. package/dist/types/components/tax-and-cash/TaxForm.stories.d.ts +0 -2
  79. package/dist/types/components/tax-and-cash/sqm-banking-info-form/sqm-banking-info-form-view.d.ts +0 -2
  80. package/dist/types/components/tax-and-cash/sqm-docusign-form/useDocusignForm.d.ts +1 -1
  81. package/dist/types/components/tax-and-cash/sqm-tax-and-cash/data.d.ts +0 -6
  82. package/dist/types/components/tax-and-cash/sqm-tax-and-cash/sqm-tax-and-cash.d.ts +2 -2
  83. package/dist/types/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard-view.d.ts +0 -12
  84. package/dist/types/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard.d.ts +2 -19
  85. package/dist/types/components.d.ts +108 -625
  86. package/docs/docs.docx +0 -0
  87. package/docs/raisins.json +1 -1
  88. package/grapesjs/grapesjs.js +1 -1
  89. package/package.json +2 -2
  90. package/dist/cjs/extractProps-fd93ba62.js +0 -21
  91. package/dist/cjs/keys-cff24974.js +0 -11
  92. package/dist/cjs/sqm-code-verification.cjs.entry.js +0 -342
  93. package/dist/cjs/sqm-email-verification.cjs.entry.js +0 -283
  94. package/dist/cjs/sqm-scroll.cjs.entry.js +0 -109
  95. package/dist/cjs/sqm-widget-verification-internal.cjs.entry.js +0 -103
  96. package/dist/cjs/sqm-widget-verification.cjs.entry.js +0 -210
  97. package/dist/cjs/usePayoutStatus-b9fb7399.js +0 -70
  98. package/dist/cjs/useVerificationEmail-6aacdb71.js +0 -169
  99. package/dist/collection/components/sqm-payout-button-scroll/PayoutButtonScroll.stories.js +0 -8
  100. package/dist/collection/components/sqm-payout-button-scroll/sqm-payout-button-scroll-view.js +0 -23
  101. package/dist/collection/components/sqm-payout-button-scroll/sqm-payout-button-scroll.js +0 -118
  102. package/dist/collection/components/sqm-payout-button-scroll/usePayoutButton.js +0 -44
  103. package/dist/collection/components/sqm-widget-verification/keys.js +0 -4
  104. package/dist/collection/components/sqm-widget-verification/sqm-code-verification/WidgetCodeVerification.stories.js +0 -36
  105. package/dist/collection/components/sqm-widget-verification/sqm-code-verification/sqm-code-verification-view.js +0 -128
  106. package/dist/collection/components/sqm-widget-verification/sqm-code-verification/sqm-code-verification.js +0 -301
  107. package/dist/collection/components/sqm-widget-verification/sqm-code-verification/useCodeVerification.js +0 -153
  108. package/dist/collection/components/sqm-widget-verification/sqm-email-verification/WidgetEmailVerification.stories.js +0 -42
  109. package/dist/collection/components/sqm-widget-verification/sqm-email-verification/sqm-email-verification-view.js +0 -91
  110. package/dist/collection/components/sqm-widget-verification/sqm-email-verification/sqm-email-verification.js +0 -226
  111. package/dist/collection/components/sqm-widget-verification/sqm-email-verification/useEmailVerification.js +0 -126
  112. package/dist/collection/components/sqm-widget-verification/sqm-widget-verification-internal.js +0 -339
  113. package/dist/collection/components/sqm-widget-verification/sqm-widget-verification.js +0 -557
  114. package/dist/collection/components/sqm-widget-verification/useVerificationEmail.js +0 -165
  115. package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/PayoutStatusAlert.stories.js +0 -22
  116. package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert-view.js +0 -131
  117. package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert.js +0 -354
  118. package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/usePayoutStatus.js +0 -65
  119. package/dist/esm/extractProps-ae1afbb3.js +0 -19
  120. package/dist/esm/keys-db1897ae.js +0 -6
  121. package/dist/esm/sqm-code-verification.entry.js +0 -338
  122. package/dist/esm/sqm-email-verification.entry.js +0 -279
  123. package/dist/esm/sqm-scroll.entry.js +0 -105
  124. package/dist/esm/sqm-widget-verification-internal.entry.js +0 -99
  125. package/dist/esm/sqm-widget-verification.entry.js +0 -206
  126. package/dist/esm/usePayoutStatus-1a635054.js +0 -67
  127. package/dist/esm/useVerificationEmail-c32696ba.js +0 -167
  128. package/dist/esm-es5/ShadowViewAddon-69b61037.js +0 -1
  129. package/dist/esm-es5/extractProps-ae1afbb3.js +0 -1
  130. package/dist/esm-es5/keys-db1897ae.js +0 -1
  131. package/dist/esm-es5/sqm-code-verification.entry.js +0 -1
  132. package/dist/esm-es5/sqm-email-verification.entry.js +0 -1
  133. package/dist/esm-es5/sqm-invoice-table-view-d1cfdaf4.js +0 -1
  134. package/dist/esm-es5/sqm-scroll.entry.js +0 -1
  135. package/dist/esm-es5/sqm-widget-verification-internal.entry.js +0 -1
  136. package/dist/esm-es5/sqm-widget-verification.entry.js +0 -1
  137. package/dist/esm-es5/usePayoutStatus-1a635054.js +0 -1
  138. package/dist/esm-es5/useVerificationEmail-c32696ba.js +0 -1
  139. package/dist/mint-components/p-1712a9fd.entry.js +0 -11
  140. package/dist/mint-components/p-1e616d45.system.js +0 -1
  141. package/dist/mint-components/p-24092973.entry.js +0 -9
  142. package/dist/mint-components/p-26468242.js +0 -1
  143. package/dist/mint-components/p-331d060e.entry.js +0 -223
  144. package/dist/mint-components/p-3925bcd6.entry.js +0 -13
  145. package/dist/mint-components/p-39840341.js +0 -1
  146. package/dist/mint-components/p-4364001c.entry.js +0 -12
  147. package/dist/mint-components/p-4bd7a472.js +0 -1
  148. package/dist/mint-components/p-517224ef.js +0 -19
  149. package/dist/mint-components/p-5a23b560.system.entry.js +0 -1
  150. package/dist/mint-components/p-64491210.system.entry.js +0 -1
  151. package/dist/mint-components/p-8300d8c8.system.js +0 -1
  152. package/dist/mint-components/p-8bddb468.system.entry.js +0 -1
  153. package/dist/mint-components/p-9596e97c.system.entry.js +0 -1
  154. package/dist/mint-components/p-974070c4.system.entry.js +0 -1
  155. package/dist/mint-components/p-a85f57bb.entry.js +0 -1
  156. package/dist/mint-components/p-a8645c1b.system.js +0 -1
  157. package/dist/mint-components/p-b2a99637.system.js +0 -1
  158. package/dist/mint-components/p-b62faaa5.system.entry.js +0 -1
  159. package/dist/mint-components/p-c05e7b9f.entry.js +0 -195
  160. package/dist/mint-components/p-c510fb88.entry.js +0 -1
  161. package/dist/mint-components/p-c7057066.system.entry.js +0 -1
  162. package/dist/mint-components/p-d7806f31.js +0 -48
  163. package/dist/mint-components/p-e01ac27c.system.js +0 -1
  164. package/dist/mint-components/p-e45a8501.system.entry.js +0 -1
  165. package/dist/mint-components/p-e990dc21.system.js +0 -1
  166. package/dist/mint-components/p-ead27698.system.entry.js +0 -1
  167. package/dist/mint-components/p-f340214f.entry.js +0 -25
  168. package/dist/types/components/sqm-payout-button-scroll/PayoutButtonScroll.stories.d.ts +0 -5
  169. package/dist/types/components/sqm-payout-button-scroll/sqm-payout-button-scroll-view.d.ts +0 -10
  170. package/dist/types/components/sqm-payout-button-scroll/sqm-payout-button-scroll.d.ts +0 -26
  171. package/dist/types/components/sqm-payout-button-scroll/usePayoutButton.d.ts +0 -7
  172. package/dist/types/components/sqm-widget-verification/keys.d.ts +0 -4
  173. package/dist/types/components/sqm-widget-verification/sqm-code-verification/WidgetCodeVerification.stories.d.ts +0 -9
  174. package/dist/types/components/sqm-widget-verification/sqm-code-verification/sqm-code-verification-view.d.ts +0 -26
  175. package/dist/types/components/sqm-widget-verification/sqm-code-verification/sqm-code-verification.d.ts +0 -54
  176. package/dist/types/components/sqm-widget-verification/sqm-code-verification/useCodeVerification.d.ts +0 -25
  177. package/dist/types/components/sqm-widget-verification/sqm-email-verification/WidgetEmailVerification.stories.d.ts +0 -10
  178. package/dist/types/components/sqm-widget-verification/sqm-email-verification/sqm-email-verification-view.d.ts +0 -21
  179. package/dist/types/components/sqm-widget-verification/sqm-email-verification/sqm-email-verification.d.ts +0 -40
  180. package/dist/types/components/sqm-widget-verification/sqm-email-verification/useEmailVerification.d.ts +0 -10
  181. package/dist/types/components/sqm-widget-verification/sqm-widget-verification-internal.d.ts +0 -20
  182. package/dist/types/components/sqm-widget-verification/sqm-widget-verification.d.ts +0 -87
  183. package/dist/types/components/sqm-widget-verification/useVerificationEmail.d.ts +0 -14
  184. package/dist/types/components/tax-and-cash/sqm-payout-status-alert/PayoutStatusAlert.stories.d.ts +0 -10
  185. package/dist/types/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert-view.d.ts +0 -30
  186. package/dist/types/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert.d.ts +0 -62
  187. package/dist/types/components/tax-and-cash/sqm-payout-status-alert/usePayoutStatus.d.ts +0 -21
@@ -1,153 +0,0 @@
1
- import { useMutation, useParent, useParentValue, useUserIdentity, } from "@saasquatch/component-boilerplate";
2
- import { useEffect, useHost, useState } from "@saasquatch/stencil-hooks";
3
- import { gql } from "graphql-request";
4
- import { SHOW_CODE_NAMESPACE, VERIFICATION_EMAIL_NAMESPACE, } from "../keys";
5
- import { useVerificationEmail } from "../useVerificationEmail";
6
- export const VerifyEmailWithCodeMutation = gql `
7
- mutation submitImpactPublisherEmail2FACode(
8
- $user: UserIdInput!
9
- $code: String!
10
- ) {
11
- submitImpactPublisherEmail2FACode(user: $user, code: $code) {
12
- verifiedEmail
13
- accessKey
14
- }
15
- }
16
- `;
17
- export function useCodeVerificationMutation() {
18
- const user = useUserIdentity();
19
- const [request, { loading, data, errors }] = useMutation(VerifyEmailWithCodeMutation);
20
- const verifyUserWithCodeMutation = async (code) => {
21
- try {
22
- const result = await request({
23
- user: {
24
- id: user.id,
25
- accountId: user.accountId,
26
- },
27
- code,
28
- });
29
- if (result instanceof Error || !result)
30
- throw new Error();
31
- return result;
32
- }
33
- catch (e) {
34
- console.error("Failed to verify user", e);
35
- return null;
36
- }
37
- };
38
- return [verifyUserWithCodeMutation, { loading, data, errors }];
39
- }
40
- export function useWidgetCodeVerification(props) {
41
- const host = useHost();
42
- const [_, setShowCode] = useParent(SHOW_CODE_NAMESPACE);
43
- const email = useParentValue(VERIFICATION_EMAIL_NAMESPACE);
44
- const [emailSent, setEmailSent] = useState(false);
45
- const [emailResent, setEmailResent] = useState(false);
46
- const [codeRef, setCodeRef] = useState(null);
47
- const [validationError, setValidationError] = useState(false);
48
- const [emailError, setEmailError] = useState(false);
49
- const { initialized, send: [sendEmail, { loading: sendLoading, errors: sendErrors }], verify: [verifyEmail, { loading: verifyLoading, errors: verifyErrors }], } = useVerificationEmail();
50
- useEffect(() => {
51
- if (!codeRef)
52
- return;
53
- const slInputs = codeRef.querySelectorAll("sl-input");
54
- const codeElements = Array.from(slInputs).map((node) => node.shadowRoot.querySelector(`input[name="code"]`));
55
- codeElements.forEach((element, idx) => {
56
- element.addEventListener("focus", (e) => {
57
- e.target.select();
58
- });
59
- element.addEventListener("keydown", (e) => {
60
- if (e.key === "Backspace" && e.target.value === "") {
61
- codeElements[Math.max(0, idx - 1)].focus();
62
- }
63
- });
64
- element.addEventListener("input", (e) => {
65
- const input = e.data;
66
- if (!input)
67
- return;
68
- if (idx === codeElements.length - 1) {
69
- e.target.value = input.slice(-1);
70
- return;
71
- }
72
- if (input.length > 1) {
73
- const rest = input.slice(1);
74
- e.target.value = input.slice(0, 1);
75
- codeElements[idx + 1].dispatchEvent(new InputEvent("input", {
76
- inputType: "insertFromPaste",
77
- data: rest,
78
- }));
79
- }
80
- codeElements[idx + 1].focus();
81
- });
82
- });
83
- }, [codeRef]);
84
- const reset = () => {
85
- setShowCode(false);
86
- setValidationError(false);
87
- };
88
- const resendEmail = async () => {
89
- // UI should only allow this to be called if initialized, but checking just in case
90
- if (!initialized)
91
- return;
92
- const result = await sendEmail();
93
- if (!result) {
94
- setEmailError(true);
95
- return;
96
- }
97
- if (emailSent)
98
- setEmailResent(true);
99
- setEmailSent(true);
100
- };
101
- const submitCode = async () => {
102
- const slInputs = codeRef.querySelectorAll("sl-input");
103
- const codeElements = Array.from(slInputs).map((node) => node.shadowRoot.querySelector(`input[name="code"]`));
104
- if (codeElements.find((el) => !el.value)) {
105
- setValidationError(true);
106
- return;
107
- }
108
- let code = "";
109
- codeElements.forEach((element) => {
110
- code = `${code}${element.value}`;
111
- });
112
- // UI should only allow this to be called if initialized, but checking just in case
113
- if (!initialized)
114
- return;
115
- setValidationError(false);
116
- const res = await verifyEmail(code);
117
- if (res === null || res === void 0 ? void 0 : res.success) {
118
- props.onVerification(res.accessKey);
119
- reset();
120
- }
121
- else {
122
- setValidationError(true);
123
- }
124
- };
125
- useEffect(() => {
126
- // Wait for mutations to be determined from user lookup
127
- if (!initialized)
128
- return;
129
- // email should already exist if user has completed email-verification
130
- if (!email)
131
- resendEmail();
132
- else
133
- setEmailSent(true);
134
- }, [initialized]);
135
- return {
136
- refs: {
137
- codeWrapperRef: setCodeRef,
138
- },
139
- states: {
140
- email,
141
- emailResent,
142
- resendError: sendErrors || verifyErrors,
143
- initialiseLoading: !initialized,
144
- loading: sendLoading || verifyLoading,
145
- verifyFailed: !!validationError,
146
- },
147
- callbacks: {
148
- resendEmail,
149
- submitCode,
150
- },
151
- text: props.getTextProps(),
152
- };
153
- }
@@ -1,42 +0,0 @@
1
- import { h } from "@stencil/core";
2
- export default {
3
- title: "Components/Widget Email Verification",
4
- };
5
- const defaultProps = {
6
- email: "",
7
- error: false,
8
- loading: false,
9
- initialLoading: false,
10
- sendCodeError: false,
11
- };
12
- export const Default = () => (h("sqm-email-verification", { demoData: {} }));
13
- export const EmailIsPrefilled = () => (h("sqm-email-verification", { demoData: {
14
- states: {
15
- ...defaultProps,
16
- email: "test@example.com",
17
- },
18
- } }));
19
- export const Loading = () => (h("sqm-email-verification", { demoData: {
20
- states: {
21
- ...defaultProps,
22
- initialLoading: true,
23
- },
24
- } }));
25
- export const SaveLoading = () => (h("sqm-email-verification", { demoData: {
26
- states: {
27
- ...defaultProps,
28
- loading: true,
29
- },
30
- } }));
31
- export const InvalidEmail = () => (h("sqm-email-verification", { demoData: {
32
- states: {
33
- ...defaultProps,
34
- error: true,
35
- },
36
- } }));
37
- export const SendCodeError = () => (h("sqm-email-verification", { demoData: {
38
- states: {
39
- ...defaultProps,
40
- sendCodeError: true,
41
- },
42
- } }));
@@ -1,91 +0,0 @@
1
- import { h } from "@stencil/core";
2
- import { createStyleSheet } from "../../../styling/JSS";
3
- import { TextSpanView } from "../../sqm-text-span/sqm-text-span-view";
4
- const style = {
5
- Wrapper: {
6
- display: "flex",
7
- flexDirection: "column",
8
- gap: "var(--sl-spacing-medium)",
9
- marginTop: "var(--sl-spacing-medium)",
10
- },
11
- InputsContainer: {
12
- display: "flex",
13
- gap: "var(--sl-spacing-medium)",
14
- position: "relative",
15
- flexDirection: "column",
16
- maxWidth: "320px",
17
- },
18
- ErrorAlertContainer: {
19
- "&::part(base)": {
20
- backgroundColor: "var(--sl-color-red-100)",
21
- borderTop: "none",
22
- },
23
- "&::part(message)": {
24
- display: "flex",
25
- flexDirection: "column",
26
- },
27
- },
28
- ContinueButton: {
29
- width: "100%",
30
- maxWidth: "100px",
31
- },
32
- SkeletonOne: {
33
- width: "50%",
34
- height: "16px",
35
- },
36
- SkeletonTwo: {
37
- width: "30%",
38
- height: "34px",
39
- },
40
- SkeletonThree: {
41
- width: "15%",
42
- height: "24px",
43
- },
44
- ErrorInput: {
45
- "&::part(base)": {
46
- border: "1px solid var(--sl-color-danger-500)",
47
- borderRadius: "var(--sl-input-border-radius-medium)",
48
- },
49
- "&::part(help-text)": {
50
- color: "var(--sl-color-danger-500)",
51
- },
52
- },
53
- };
54
- const vanillaStyle = `
55
- :host {
56
- display: block;
57
- }
58
- :host([hidden]): {
59
- display: none;
60
- }
61
- `;
62
- const sheet = createStyleSheet(style);
63
- const styleString = sheet.toString();
64
- export function WidgetEmailVerificationView(props) {
65
- const { states, callbacks, text } = props;
66
- const renderLoadingSkeleton = () => {
67
- return (h("div", { class: sheet.classes.Wrapper },
68
- h("sl-skeleton", { class: sheet.classes.SkeletonOne }),
69
- h("sl-skeleton", { class: sheet.classes.SkeletonTwo }),
70
- h("sl-skeleton", { class: sheet.classes.SkeletonThree })));
71
- };
72
- return (h("div", { part: "sqm-base" },
73
- h("style", { type: "text/css" },
74
- vanillaStyle,
75
- styleString),
76
- states.sendCodeError && (h("sl-alert", { exportparts: "base: alert-base, icon:alert-icon", type: "danger", class: sheet.classes.ErrorAlertContainer, open: true },
77
- h("sl-icon", { slot: "icon", name: "exclamation-octagon" }),
78
- h("b", null, text.sendCodeErrorHeader),
79
- text.sendCodeErrorDescription)),
80
- states.initialLoading ? (renderLoadingSkeleton()) : (h("div", { class: sheet.classes.Wrapper },
81
- h(TextSpanView, { type: "p" }, text.verifyEmailHeaderText),
82
- h("sl-form", { "onSl-submit": callbacks.submitEmail },
83
- h("div", { class: sheet.classes.InputsContainer },
84
- h("sl-input", Object.assign({ exportparts: "label: input-label, base: input-base", label: text.emailLabel, value: states.email, type: "email", id: "email", name: "email", disabled: !!states.email || states.loading }, (states.error
85
- ? {
86
- class: sheet.classes.ErrorInput,
87
- helpText: text.emailValidationErrorText,
88
- }
89
- : {}))),
90
- h("sl-button", { submit: true, class: sheet.classes.ContinueButton, loading: states.loading, exportparts: "base: primarybutton-base", type: "primary" }, text.sendCodeText)))))));
91
- }
@@ -1,226 +0,0 @@
1
- import { withHooks } from "@saasquatch/stencil-hooks";
2
- import { Component, h, Prop } from "@stencil/core";
3
- import { useWidgetEmailVerification } from "./useEmailVerification";
4
- import { WidgetEmailVerificationView, } from "./sqm-email-verification-view";
5
- import { getProps } from "../../../utils/utils";
6
- import { isDemo, useSetParent } from "@saasquatch/component-boilerplate";
7
- import deepmerge from "deepmerge";
8
- import { SHOW_CODE_NAMESPACE } from "../keys";
9
- /**
10
- * @uiName Widget Verification Gate
11
- */
12
- export class WidgetEmailVerification {
13
- constructor() {
14
- /**
15
- * @uiName Verify email widget header text
16
- */
17
- this.verifyEmailHeaderText = "Start by verifying your email. We’ll send you a code through our referral provider, impact.com.";
18
- /**
19
- * @uiName Send code to email alert header
20
- */
21
- this.sendCodeErrorHeader = "There was an error sending your code.";
22
- /**
23
- * @uiName Send code to email alert description
24
- */
25
- this.sendCodeErrorDescription = "Please try again. If this problem continues, contact our program support team.";
26
- /**
27
- * @uiName Email input label
28
- */
29
- this.emailLabel = "Email";
30
- /**
31
- * @uiName Send code button text
32
- */
33
- this.sendCodeText = "Send code";
34
- /**
35
- * @uiName Send code button text
36
- */
37
- this.emailValidationErrorText = "Please enter a valid email";
38
- withHooks(this);
39
- }
40
- disconnectedCallback() { }
41
- getTextProps() {
42
- return getProps(this);
43
- }
44
- render() {
45
- const props = isDemo()
46
- ? useDemoWidgetEmailVerification(this)
47
- : useWidgetEmailVerification(this);
48
- return h(WidgetEmailVerificationView, Object.assign({}, props));
49
- }
50
- static get is() { return "sqm-email-verification"; }
51
- static get encapsulation() { return "shadow"; }
52
- static get properties() { return {
53
- "verifyEmailHeaderText": {
54
- "type": "string",
55
- "mutable": false,
56
- "complexType": {
57
- "original": "string",
58
- "resolved": "string",
59
- "references": {}
60
- },
61
- "required": false,
62
- "optional": false,
63
- "docs": {
64
- "tags": [{
65
- "text": "Verify email widget header text",
66
- "name": "uiName"
67
- }],
68
- "text": ""
69
- },
70
- "attribute": "verify-email-header-text",
71
- "reflect": false,
72
- "defaultValue": "\"Start by verifying your email. We\u2019ll send you a code through our referral provider, impact.com.\""
73
- },
74
- "sendCodeErrorHeader": {
75
- "type": "string",
76
- "mutable": false,
77
- "complexType": {
78
- "original": "string",
79
- "resolved": "string",
80
- "references": {}
81
- },
82
- "required": false,
83
- "optional": false,
84
- "docs": {
85
- "tags": [{
86
- "text": "Send code to email alert header",
87
- "name": "uiName"
88
- }],
89
- "text": ""
90
- },
91
- "attribute": "send-code-error-header",
92
- "reflect": false,
93
- "defaultValue": "\"There was an error sending your code.\""
94
- },
95
- "sendCodeErrorDescription": {
96
- "type": "string",
97
- "mutable": false,
98
- "complexType": {
99
- "original": "string",
100
- "resolved": "string",
101
- "references": {}
102
- },
103
- "required": false,
104
- "optional": false,
105
- "docs": {
106
- "tags": [{
107
- "text": "Send code to email alert description",
108
- "name": "uiName"
109
- }],
110
- "text": ""
111
- },
112
- "attribute": "send-code-error-description",
113
- "reflect": false,
114
- "defaultValue": "\"Please try again. If this problem continues, contact our program support team.\""
115
- },
116
- "emailLabel": {
117
- "type": "string",
118
- "mutable": false,
119
- "complexType": {
120
- "original": "string",
121
- "resolved": "string",
122
- "references": {}
123
- },
124
- "required": false,
125
- "optional": false,
126
- "docs": {
127
- "tags": [{
128
- "text": "Email input label",
129
- "name": "uiName"
130
- }],
131
- "text": ""
132
- },
133
- "attribute": "email-label",
134
- "reflect": false,
135
- "defaultValue": "\"Email\""
136
- },
137
- "sendCodeText": {
138
- "type": "string",
139
- "mutable": false,
140
- "complexType": {
141
- "original": "string",
142
- "resolved": "string",
143
- "references": {}
144
- },
145
- "required": false,
146
- "optional": false,
147
- "docs": {
148
- "tags": [{
149
- "text": "Send code button text",
150
- "name": "uiName"
151
- }],
152
- "text": ""
153
- },
154
- "attribute": "send-code-text",
155
- "reflect": false,
156
- "defaultValue": "\"Send code\""
157
- },
158
- "emailValidationErrorText": {
159
- "type": "string",
160
- "mutable": false,
161
- "complexType": {
162
- "original": "string",
163
- "resolved": "string",
164
- "references": {}
165
- },
166
- "required": false,
167
- "optional": false,
168
- "docs": {
169
- "tags": [{
170
- "text": "Send code button text",
171
- "name": "uiName"
172
- }],
173
- "text": ""
174
- },
175
- "attribute": "email-validation-error-text",
176
- "reflect": false,
177
- "defaultValue": "\"Please enter a valid email\""
178
- },
179
- "demoData": {
180
- "type": "unknown",
181
- "mutable": false,
182
- "complexType": {
183
- "original": "DemoData<WidgetEmailVerificationViewProps>",
184
- "resolved": "{ states?: { error: boolean; initialLoading: boolean; loading: boolean; email: string; sendCodeError: boolean; }; }",
185
- "references": {
186
- "DemoData": {
187
- "location": "import",
188
- "path": "../../../global/demo"
189
- },
190
- "WidgetEmailVerificationViewProps": {
191
- "location": "import",
192
- "path": "./sqm-email-verification-view"
193
- }
194
- }
195
- },
196
- "required": false,
197
- "optional": true,
198
- "docs": {
199
- "tags": [{
200
- "text": undefined,
201
- "name": "undocumented"
202
- }, {
203
- "text": "object",
204
- "name": "uiType"
205
- }],
206
- "text": ""
207
- }
208
- }
209
- }; }
210
- }
211
- function useDemoWidgetEmailVerification(props) {
212
- const setShowCode = useSetParent(SHOW_CODE_NAMESPACE);
213
- return deepmerge({
214
- states: {
215
- error: true,
216
- initialLoading: false,
217
- loading: false,
218
- email: "test@example.com",
219
- sendCodeError: true,
220
- },
221
- callbacks: {
222
- submitEmail: async () => setShowCode(true),
223
- },
224
- text: props.getTextProps(),
225
- }, props.demoData || {}, { arrayMerge: (_, a) => a });
226
- }
@@ -1,126 +0,0 @@
1
- import { useMutation, useParent, useQuery, useUserIdentity, } from "@saasquatch/component-boilerplate";
2
- import { useEffect, useState } from "@saasquatch/universal-hooks";
3
- import { gql } from "graphql-request";
4
- import { SHOW_CODE_NAMESPACE, VERIFICATION_EMAIL_NAMESPACE } from "../keys";
5
- import { useVerificationEmail } from "../useVerificationEmail";
6
- export const UpsertUserEmailMutation = gql `
7
- mutation upsertUser($userInput: UserInput!) {
8
- user(userInput: $userInput) {
9
- id
10
- accountId
11
- email
12
- }
13
- }
14
- `;
15
- export const UserLookupQuery = gql `
16
- query user {
17
- viewer {
18
- ... on User {
19
- id
20
- accountId
21
- email
22
- impactConnection {
23
- user {
24
- id
25
- email
26
- }
27
- }
28
- }
29
- }
30
- }
31
- `;
32
- export function useUpsertUserEmail() {
33
- const user = useUserIdentity();
34
- const [request, { loading: loading, data, errors }] = useMutation(UpsertUserEmailMutation);
35
- const upsertUserEmail = async (email) => {
36
- try {
37
- const result = await request({
38
- user: {
39
- id: user.id,
40
- accountId: user.accountId,
41
- email,
42
- },
43
- });
44
- if (result instanceof Error || !result)
45
- throw new Error();
46
- return result;
47
- }
48
- catch (e) {
49
- console.error("Could not set email on user", e);
50
- return undefined;
51
- }
52
- };
53
- return [
54
- upsertUserEmail,
55
- {
56
- loading,
57
- data,
58
- errors,
59
- },
60
- ];
61
- }
62
- export function useWidgetEmailVerification(props) {
63
- const [_, setShowCode] = useParent(SHOW_CODE_NAMESPACE);
64
- const [email, setEmail] = useParent(VERIFICATION_EMAIL_NAMESPACE);
65
- const [emailExists, setEmailExists] = useState(false);
66
- const [error, setError] = useState(false);
67
- const [mutationError, setMutationError] = useState(false);
68
- const { initialized, send: [sendEmail, { loading: sendLoading, errors }], } = useVerificationEmail();
69
- const [upsertUserEmail] = useUpsertUserEmail();
70
- const [loading, setLoading] = useState(true);
71
- const { data, loading: initialLoading } = useQuery(UserLookupQuery, {});
72
- const emailRegex = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
73
- useEffect(() => {
74
- if (!(data === null || data === void 0 ? void 0 : data.viewer))
75
- return;
76
- setEmailExists(!!data.viewer.email);
77
- }, [data]);
78
- useEffect(() => {
79
- if (initialized)
80
- setLoading(false);
81
- }, [initialized]);
82
- const submitEmail = async (e) => {
83
- e.preventDefault();
84
- if (!(data === null || data === void 0 ? void 0 : data.viewer))
85
- return;
86
- setLoading(true);
87
- const toAddress = data.viewer.email;
88
- if (!toAddress) {
89
- // If no email on the user, set one
90
- const formData = e.detail.formData;
91
- const newEmail = formData.get("email").toString();
92
- if (!emailRegex.test(newEmail)) {
93
- setError(true);
94
- return;
95
- }
96
- const result = await upsertUserEmail(newEmail);
97
- if (!result || !result.user.email)
98
- setError(true);
99
- }
100
- // UI should not allow this call til initialisation is done
101
- if (!initialized)
102
- return;
103
- const result = await sendEmail();
104
- if (!result || !result.success)
105
- setMutationError(true);
106
- else {
107
- // This is used to let the code verification widget know an email was already sent
108
- setEmail(toAddress);
109
- setShowCode(true);
110
- }
111
- setLoading(false);
112
- };
113
- return {
114
- callbacks: {
115
- submitEmail,
116
- },
117
- states: {
118
- loading,
119
- initialLoading: initialLoading && !initialized,
120
- error,
121
- email: data === null || data === void 0 ? void 0 : data.viewer.email,
122
- sendCodeError: mutationError,
123
- },
124
- text: props.getTextProps(),
125
- };
126
- }