@saasquatch/mint-components 1.12.0-1 → 1.12.0-11

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 (159) hide show
  1. package/dist/cjs/{ShadowViewAddon-88821c64.js → ShadowViewAddon-040cffad.js} +6 -3
  2. package/dist/cjs/extractProps-fd93ba62.js +21 -0
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/mint-components.cjs.js +1 -1
  5. package/dist/cjs/sqm-banking-info-form_16.cjs.entry.js +92 -78
  6. package/dist/cjs/sqm-big-stat_39.cjs.entry.js +128 -63
  7. package/dist/cjs/sqm-code-verification.cjs.entry.js +67 -77
  8. package/dist/cjs/sqm-email-verification.cjs.entry.js +158 -12
  9. package/dist/cjs/{sqm-invoice-table-view-ce9a34ac.js → sqm-invoice-table-view-c58966f8.js} +79 -0
  10. package/dist/cjs/sqm-stencilbook.cjs.entry.js +56 -14
  11. package/dist/cjs/sqm-widget-verification-internal.cjs.entry.js +81 -11
  12. package/dist/cjs/sqm-widget-verification.cjs.entry.js +102 -19
  13. package/dist/cjs/usePayoutStatus-b9fb7399.js +70 -0
  14. package/dist/cjs/useVerificationEmail-6aacdb71.js +169 -0
  15. package/dist/collection/collection-manifest.json +1 -1
  16. package/dist/collection/components/sqm-big-stat/useBigStat.js +6 -3
  17. package/dist/collection/components/sqm-payout-button-scroll/PayoutButtonScroll.stories.js +1 -2
  18. package/dist/collection/components/sqm-payout-button-scroll/sqm-payout-button-scroll-view.js +1 -0
  19. package/dist/collection/components/sqm-payout-button-scroll/sqm-payout-button-scroll.js +16 -3
  20. package/dist/collection/components/sqm-widget-verification/sqm-code-verification/WidgetCodeVerification.stories.js +9 -2
  21. package/dist/collection/components/sqm-widget-verification/sqm-code-verification/sqm-code-verification-view.js +20 -10
  22. package/dist/collection/components/sqm-widget-verification/sqm-code-verification/sqm-code-verification.js +34 -63
  23. package/dist/collection/components/sqm-widget-verification/sqm-code-verification/useCodeVerification.js +38 -29
  24. package/dist/collection/components/sqm-widget-verification/sqm-email-verification/WidgetEmailVerification.stories.js +23 -3
  25. package/dist/collection/components/sqm-widget-verification/sqm-email-verification/sqm-email-verification-view.js +17 -4
  26. package/dist/collection/components/sqm-widget-verification/sqm-email-verification/sqm-email-verification.js +65 -11
  27. package/dist/collection/components/sqm-widget-verification/sqm-email-verification/useEmailVerification.js +77 -21
  28. package/dist/collection/components/sqm-widget-verification/sqm-widget-verification-internal.js +327 -15
  29. package/dist/collection/components/sqm-widget-verification/sqm-widget-verification.js +447 -22
  30. package/dist/collection/components/sqm-widget-verification/useVerificationEmail.js +165 -0
  31. package/dist/collection/components/tax-and-cash/BankingForm.stories.js +1 -0
  32. package/dist/collection/components/tax-and-cash/TaxForm.stories.js +78 -0
  33. package/dist/collection/components/tax-and-cash/sqm-banking-info-form/sqm-banking-info-form.js +2 -1
  34. package/dist/collection/components/tax-and-cash/sqm-banking-info-form/useBankingInfoForm.js +7 -0
  35. package/dist/collection/components/tax-and-cash/sqm-docusign-form/docusign-iframe/DocusignIframe.js +0 -1
  36. package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/PayoutStatusAlert.stories.js +10 -0
  37. package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert-view.js +72 -13
  38. package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert.js +146 -9
  39. package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/usePayoutStatus.js +30 -15
  40. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash/data.js +6 -0
  41. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash/sqm-tax-and-cash.js +8 -8
  42. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash/useTaxAndCash.js +2 -2
  43. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard-view.js +22 -16
  44. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard.js +99 -88
  45. package/dist/collection/components/tax-and-cash/sqm-tax-and-cash-dashboard/useTaxAndCashDashboard.js +8 -1
  46. package/dist/collection/components/tax-and-cash/sqm-user-info-form/sqm-user-info-form-view.js +1 -6
  47. package/dist/collection/components/tax-and-cash/sqm-user-info-form/useUserInfoForm.js +16 -11
  48. package/dist/esm/{ShadowViewAddon-65c8679e.js → ShadowViewAddon-69b61037.js} +6 -3
  49. package/dist/esm/extractProps-ae1afbb3.js +19 -0
  50. package/dist/esm/{keys-a1496e39.js → keys-db1897ae.js} +1 -1
  51. package/dist/esm/loader.js +1 -1
  52. package/dist/esm/mint-components.js +1 -1
  53. package/dist/esm/sqm-banking-info-form_16.entry.js +92 -78
  54. package/dist/esm/sqm-big-stat_39.entry.js +127 -62
  55. package/dist/esm/sqm-code-verification.entry.js +69 -79
  56. package/dist/esm/sqm-email-verification.entry.js +159 -13
  57. package/dist/esm/{sqm-invoice-table-view-08c03ba7.js → sqm-invoice-table-view-d1cfdaf4.js} +79 -0
  58. package/dist/esm/sqm-stencilbook.entry.js +56 -14
  59. package/dist/esm/sqm-widget-verification-internal.entry.js +84 -14
  60. package/dist/esm/sqm-widget-verification.entry.js +104 -21
  61. package/dist/esm/usePayoutStatus-1a635054.js +67 -0
  62. package/dist/esm/useVerificationEmail-c32696ba.js +167 -0
  63. package/dist/esm-es5/ShadowViewAddon-69b61037.js +1 -0
  64. package/dist/esm-es5/extractProps-ae1afbb3.js +1 -0
  65. package/dist/esm-es5/{keys-a1496e39.js → keys-db1897ae.js} +1 -1
  66. package/dist/esm-es5/loader.js +1 -1
  67. package/dist/esm-es5/mint-components.js +1 -1
  68. package/dist/esm-es5/sqm-banking-info-form_16.entry.js +1 -1
  69. package/dist/esm-es5/sqm-big-stat_39.entry.js +1 -1
  70. package/dist/esm-es5/sqm-code-verification.entry.js +1 -1
  71. package/dist/esm-es5/sqm-email-verification.entry.js +1 -1
  72. package/dist/esm-es5/sqm-invoice-table-view-d1cfdaf4.js +1 -0
  73. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  74. package/dist/esm-es5/sqm-widget-verification-internal.entry.js +1 -1
  75. package/dist/esm-es5/sqm-widget-verification.entry.js +1 -1
  76. package/dist/esm-es5/usePayoutStatus-1a635054.js +1 -0
  77. package/dist/esm-es5/useVerificationEmail-c32696ba.js +1 -0
  78. package/dist/mint-components/mint-components.esm.js +1 -1
  79. package/dist/mint-components/p-0e45bc0e.system.entry.js +1 -0
  80. package/dist/mint-components/p-1712a9fd.entry.js +11 -0
  81. package/dist/mint-components/p-1e616d45.system.js +1 -0
  82. package/dist/mint-components/{p-721a89c6.entry.js → p-24092973.entry.js} +2 -2
  83. package/dist/mint-components/p-26468242.js +1 -0
  84. package/dist/mint-components/p-282a7d85.entry.js +195 -0
  85. package/dist/mint-components/p-331d060e.entry.js +223 -0
  86. package/dist/mint-components/p-39840341.js +1 -0
  87. package/dist/mint-components/p-4364001c.entry.js +12 -0
  88. package/dist/mint-components/p-4bd7a472.js +1 -0
  89. package/dist/mint-components/p-517224ef.js +19 -0
  90. package/dist/mint-components/p-5f766d09.entry.js +25 -0
  91. package/dist/mint-components/p-8300d8c8.system.js +1 -0
  92. package/dist/mint-components/p-8bddb468.system.entry.js +1 -0
  93. package/dist/mint-components/p-9596e97c.system.entry.js +1 -0
  94. package/dist/mint-components/p-974070c4.system.entry.js +1 -0
  95. package/dist/mint-components/{p-b651706a.js → p-9eae245f.js} +6 -3
  96. package/dist/mint-components/p-a8645c1b.system.js +1 -0
  97. package/dist/mint-components/p-aabab609.system.entry.js +1 -0
  98. package/dist/mint-components/p-b2a99637.system.js +1 -0
  99. package/dist/mint-components/{p-66a04cca.system.entry.js → p-b62faaa5.system.entry.js} +1 -1
  100. package/dist/mint-components/p-c510fb88.entry.js +1 -0
  101. package/dist/mint-components/p-ca809fdd.system.js +1 -1
  102. package/dist/mint-components/p-d7806f31.js +48 -0
  103. package/dist/mint-components/p-e01ac27c.system.js +1 -0
  104. package/dist/mint-components/p-e45a8501.system.entry.js +1 -0
  105. package/dist/mint-components/p-e990dc21.system.js +1 -0
  106. package/dist/types/components/sqm-payout-button-scroll/PayoutButtonScroll.stories.d.ts +0 -1
  107. package/dist/types/components/sqm-payout-button-scroll/sqm-payout-button-scroll.d.ts +7 -0
  108. package/dist/types/components/sqm-widget-verification/sqm-code-verification/WidgetCodeVerification.stories.d.ts +1 -0
  109. package/dist/types/components/sqm-widget-verification/sqm-code-verification/sqm-code-verification-view.d.ts +3 -3
  110. package/dist/types/components/sqm-widget-verification/sqm-code-verification/sqm-code-verification.d.ts +4 -10
  111. package/dist/types/components/sqm-widget-verification/sqm-code-verification/useCodeVerification.d.ts +2 -0
  112. package/dist/types/components/sqm-widget-verification/sqm-email-verification/WidgetEmailVerification.stories.d.ts +4 -1
  113. package/dist/types/components/sqm-widget-verification/sqm-email-verification/sqm-email-verification-view.d.ts +6 -1
  114. package/dist/types/components/sqm-widget-verification/sqm-email-verification/sqm-email-verification.d.ts +10 -2
  115. package/dist/types/components/sqm-widget-verification/sqm-email-verification/useEmailVerification.d.ts +3 -2
  116. package/dist/types/components/sqm-widget-verification/sqm-widget-verification-internal.d.ts +15 -0
  117. package/dist/types/components/sqm-widget-verification/sqm-widget-verification.d.ts +79 -0
  118. package/dist/types/components/sqm-widget-verification/useVerificationEmail.d.ts +14 -0
  119. package/dist/types/components/tax-and-cash/TaxForm.stories.d.ts +1 -0
  120. package/dist/types/components/tax-and-cash/sqm-banking-info-form/sqm-banking-info-form-view.d.ts +1 -0
  121. package/dist/types/components/tax-and-cash/sqm-payout-status-alert/PayoutStatusAlert.stories.d.ts +2 -0
  122. package/dist/types/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert-view.d.ts +12 -0
  123. package/dist/types/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert.d.ts +41 -0
  124. package/dist/types/components/tax-and-cash/sqm-payout-status-alert/usePayoutStatus.d.ts +12 -0
  125. package/dist/types/components/tax-and-cash/sqm-tax-and-cash/data.d.ts +6 -0
  126. package/dist/types/components/tax-and-cash/sqm-tax-and-cash/sqm-tax-and-cash.d.ts +2 -2
  127. package/dist/types/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard-view.d.ts +10 -3
  128. package/dist/types/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard.d.ts +19 -18
  129. package/dist/types/components.d.ts +366 -92
  130. package/docs/docs.docx +0 -0
  131. package/docs/raisins.json +1 -1
  132. package/grapesjs/grapesjs.js +1 -1
  133. package/package.json +1 -1
  134. package/dist/cjs/useEmailVerification-30a1c7f6.js +0 -75
  135. package/dist/collection/components/sqm-widget-verification/useWidgetVerification.js +0 -3
  136. package/dist/esm/useEmailVerification-7135732c.js +0 -72
  137. package/dist/esm-es5/ShadowViewAddon-65c8679e.js +0 -1
  138. package/dist/esm-es5/sqm-invoice-table-view-08c03ba7.js +0 -1
  139. package/dist/esm-es5/useEmailVerification-7135732c.js +0 -1
  140. package/dist/mint-components/p-117b4705.system.js +0 -1
  141. package/dist/mint-components/p-1bd0cda8.system.entry.js +0 -1
  142. package/dist/mint-components/p-1ee62d9f.system.entry.js +0 -1
  143. package/dist/mint-components/p-1f9a9b70.system.entry.js +0 -1
  144. package/dist/mint-components/p-23fdd44e.entry.js +0 -1
  145. package/dist/mint-components/p-36f7caec.system.entry.js +0 -1
  146. package/dist/mint-components/p-39397731.entry.js +0 -1
  147. package/dist/mint-components/p-39af4acd.entry.js +0 -240
  148. package/dist/mint-components/p-4c9b6fbe.system.js +0 -1
  149. package/dist/mint-components/p-65e2c043.system.js +0 -1
  150. package/dist/mint-components/p-663303b7.entry.js +0 -8
  151. package/dist/mint-components/p-6cae44d7.js +0 -1
  152. package/dist/mint-components/p-7f5c7bf7.system.entry.js +0 -1
  153. package/dist/mint-components/p-8a337864.js +0 -7
  154. package/dist/mint-components/p-a02afa72.system.js +0 -1
  155. package/dist/mint-components/p-a5a9aa07.entry.js +0 -189
  156. package/dist/mint-components/p-c763c0b2.js +0 -1
  157. package/dist/mint-components/p-e93e5740.entry.js +0 -1
  158. package/dist/mint-components/p-e9ca48fc.system.entry.js +0 -1
  159. package/dist/types/components/sqm-widget-verification/useWidgetVerification.d.ts +0 -1
@@ -110,8 +110,8 @@
110
110
  "./components/sqm-user-name/sqm-user-name.js",
111
111
  "./components/sqm-widget-verification/sqm-widget-verification-internal.js",
112
112
  "./components/sqm-widget-verification/sqm-widget-verification.js",
113
- "./components/sqm-widget-verification/sqm-email-verification/sqm-email-verification.js",
114
113
  "./components/sqm-widget-verification/sqm-code-verification/sqm-code-verification.js",
114
+ "./components/sqm-widget-verification/sqm-email-verification/sqm-email-verification.js",
115
115
  "./components/tax-and-cash/sqm-payout-details-card/sqm-payout-details-card.js",
116
116
  "./components/tax-and-cash/sqm-tax-and-cash/sqm-tax-and-cash.js"
117
117
  ],
@@ -709,9 +709,12 @@ const payoutBalanceQuery = () => {
709
709
  query payoutBalance {
710
710
  viewer: viewer {
711
711
  ... on User {
712
- publisher {
713
- payoutsAccount {
714
- balance
712
+ id
713
+ impactConnection {
714
+ publisher {
715
+ payoutsAccount {
716
+ balance
717
+ }
715
718
  }
716
719
  }
717
720
  }
@@ -3,7 +3,6 @@ export default {
3
3
  title: "Components/Payout Scroll Button",
4
4
  };
5
5
  const defaultProps = {
6
- payoutSettingsComplete: false,
6
+ payoutSettingsComplete: true,
7
7
  };
8
- export const Default = () => (h("sqm-payout-button-scroll", { demoData: { states: defaultProps } }));
9
8
  export const CompletedTaxForm = () => (h("sqm-payout-button-scroll", { demoData: { states: { ...defaultProps, payoutSettingsComplete: true } } }));
@@ -7,6 +7,7 @@ const style = {
7
7
  PayoutButtonDescription: {
8
8
  color: "var(--sl-color-neutral-500)",
9
9
  fontSize: "var(--sl-font-size-small)",
10
+ margin: "0",
10
11
  },
11
12
  };
12
13
  const sheet = createStyleSheet(style);
@@ -8,7 +8,14 @@ import deepmerge from "deepmerge";
8
8
  */
9
9
  export class PayoutButtonScroll {
10
10
  constructor() {
11
+ /**
12
+ * @uiName Payout button text
13
+ */
11
14
  this.payoutButtonText = "Payouts & Tax Settings";
15
+ /**
16
+ * Description text under payout button
17
+ * @uiName Payout button description text
18
+ */
12
19
  this.payoutButtonDescription = "Check your payout settings to see when you’ll get paid out next";
13
20
  this.ignored = true;
14
21
  withHooks(this);
@@ -35,7 +42,10 @@ export class PayoutButtonScroll {
35
42
  "required": false,
36
43
  "optional": false,
37
44
  "docs": {
38
- "tags": [],
45
+ "tags": [{
46
+ "text": "Payout button text",
47
+ "name": "uiName"
48
+ }],
39
49
  "text": ""
40
50
  },
41
51
  "attribute": "payout-button-text",
@@ -53,8 +63,11 @@ export class PayoutButtonScroll {
53
63
  "required": false,
54
64
  "optional": false,
55
65
  "docs": {
56
- "tags": [],
57
- "text": ""
66
+ "tags": [{
67
+ "text": "Payout button description text",
68
+ "name": "uiName"
69
+ }],
70
+ "text": "Description text under payout button"
58
71
  },
59
72
  "attribute": "payout-button-description",
60
73
  "reflect": false,
@@ -3,12 +3,19 @@ export default {
3
3
  title: "Components/Widget Code Verification",
4
4
  };
5
5
  const defaultProps = {
6
+ initialiseLoading: false,
6
7
  email: "testemail@example.com",
7
8
  loading: false,
8
9
  verifyFailed: false,
9
- codeResent: false,
10
+ emailResent: false,
10
11
  };
11
12
  export const Default = () => (h("sqm-code-verification", { demoData: { states: defaultProps } }));
13
+ export const InitialLoading = () => (h("sqm-code-verification", { demoData: {
14
+ states: {
15
+ ...defaultProps,
16
+ initialiseLoading: true,
17
+ },
18
+ } }));
12
19
  export const Loading = () => (h("sqm-code-verification", { demoData: {
13
20
  states: {
14
21
  ...defaultProps,
@@ -18,7 +25,7 @@ export const Loading = () => (h("sqm-code-verification", { demoData: {
18
25
  export const CodeResent = () => (h("sqm-code-verification", { demoData: {
19
26
  states: {
20
27
  ...defaultProps,
21
- codeResent: true,
28
+ emailResent: true,
22
29
  },
23
30
  } }));
24
31
  export const VerificationFailed = () => (h("sqm-code-verification", { demoData: {
@@ -85,7 +85,16 @@ export function WidgetCodeVerificationView(props) {
85
85
  id: "resendCodeText",
86
86
  defaultMessage: text.resendCodeText,
87
87
  }, {
88
- resendCodeLink: (h("a", { href: text.resendCodeLink, target: "_blank", style: { textDecoration: "none" } }, text.resendCodeLabel)),
88
+ resendCodeLink: (h("a", { href: "", style: { textDecoration: "none" }, onClick: (e) => {
89
+ e.preventDefault();
90
+ callbacks.resendEmail();
91
+ } }, text.resendCodeLabel)),
92
+ });
93
+ const codeResentSuccessfully = intl.formatMessage({
94
+ id: "codeResentSuccessfully",
95
+ defaultMessage: text.codeResentSuccessfullyText,
96
+ }, {
97
+ email: states.email,
89
98
  });
90
99
  const inputClass = states.verifyFailed
91
100
  ? sheet.classes.CodeInputError
@@ -96,11 +105,14 @@ export function WidgetCodeVerificationView(props) {
96
105
  styleString),
97
106
  h("div", { class: sheet.classes.Wrapper },
98
107
  h("div", { class: sheet.classes.HeaderContainer },
99
- h(TextSpanView, { type: "p" }, states.verifyFailed
100
- ? text.reverifyCodeHeaderText
101
- : text.verifyCodeHeaderText)),
102
- states.codeResent && (h("sqm-form-message", { type: "success", exportparts: "successalert-icon" },
103
- h("b", null, text.codeResentSuccessfullyText))),
108
+ h(TextSpanView, { type: "p" }, intl.formatMessage({
109
+ id: `emailHeaderText`,
110
+ defaultMessage: states.verifyFailed
111
+ ? text.reverifyCodeHeaderText
112
+ : text.verifyCodeHeaderText,
113
+ }, { email: states.email }))),
114
+ states.emailResent && (h("sqm-form-message", { type: "success", exportparts: "successalert-icon" },
115
+ h("b", null, codeResentSuccessfully))),
104
116
  h("div", { class: sheet.classes.InputsContainer },
105
117
  h("div", { ref: refs.codeWrapperRef, class: sheet.classes.CodeInputContainer },
106
118
  h("sl-input", { class: inputClass, name: "code" }),
@@ -110,9 +122,7 @@ export function WidgetCodeVerificationView(props) {
110
122
  h("sl-input", { class: inputClass, name: "code" }),
111
123
  h("sl-input", { class: inputClass, name: "code" })),
112
124
  states.verifyFailed && (h("p", { class: sheet.classes.ErrorText }, text.invalidCodeText)),
113
- h("sl-button", { class: sheet.classes.ContinueButton, onClick: callbacks.submitCode, loading: states.loading, exportparts: "base: primarybutton-base", type: "primary" }, text.verifyText)),
125
+ h("sl-button", { class: sheet.classes.ContinueButton, onClick: callbacks.submitCode, disabled: states.loading || states.initialiseLoading, loading: states.loading || states.initialiseLoading, exportparts: "base: primarybutton-base", type: "primary" }, text.verifyText)),
114
126
  h("div", { class: sheet.classes.FooterContainer },
115
- h(TextSpanView, { type: "p" }, resendCodeText),
116
- h(TextSpanView, { type: "p" },
117
- h("a", { href: "/", style: { textDecoration: "none" } }, text.useDifferentEmailText))))));
127
+ h(TextSpanView, { type: "p" }, resendCodeText)))));
118
128
  }
@@ -1,16 +1,17 @@
1
- import { isDemo } from "@saasquatch/component-boilerplate";
2
- import { withHooks } from "@saasquatch/stencil-hooks";
1
+ import { isDemo, useSetParent } from "@saasquatch/component-boilerplate";
2
+ import { useState, withHooks } from "@saasquatch/stencil-hooks";
3
3
  import { Component, h, Prop } from "@stencil/core";
4
4
  import deepmerge from "deepmerge";
5
5
  import { getProps } from "../../../utils/utils";
6
6
  import { WidgetCodeVerificationView, } from "./sqm-code-verification-view";
7
7
  import { useWidgetCodeVerification } from "./useCodeVerification";
8
+ import { VERIFICATION_PARENT_NAMESPACE } from "../keys";
8
9
  export class WidgetCodeVerification {
9
10
  constructor() {
10
11
  /**
11
12
  * @uiName Verify code widget header text
12
13
  */
13
- this.verifyCodeHeaderText = "Enter the code sent to email@example.com from our referral provider, impact.com.";
14
+ this.verifyCodeHeaderText = "Enter the code sent to {email} from our referral provider, impact.com.";
14
15
  /**
15
16
  * @uiName Reverify code widget header text
16
17
  */
@@ -25,27 +26,16 @@ export class WidgetCodeVerification {
25
26
  * @uiName Resend code label
26
27
  */
27
28
  this.resendCodeLabel = "Resend code";
28
- /**
29
- * The link that appears in the resend code link
30
- * @uiName Resend code link
31
- */
32
- // AL: TODO connect route to resend verification code
33
- this.resendCodeLink = "/resend-code";
34
29
  /**
35
30
  * Link text displayed under verify button
36
31
  * @uiName Resend code text
37
32
  */
38
33
  this.codeResentSuccessfullyText = "Another code has been sent to {email}";
39
- /**
40
- * Link text displayed under the verify button
41
- * @uiName Use different email text
42
- */
43
- this.useDifferentEmailText = "Use a different email";
44
34
  /**
45
35
  * Error text displayed under verification input
46
36
  * @uiName Invalid code text
47
37
  */
48
- this.invalidCodeText = " Please check your code and try again. If you’re still having trouble, try resending your code.";
38
+ this.invalidCodeText = "Please check your code and try again. If you’re still having trouble, try resending your code.";
49
39
  /**
50
40
  * @uiName Verify code button text
51
41
  */
@@ -89,7 +79,7 @@ export class WidgetCodeVerification {
89
79
  },
90
80
  "attribute": "verify-code-header-text",
91
81
  "reflect": false,
92
- "defaultValue": "\"Enter the code sent to email@example.com from our referral provider, impact.com.\""
82
+ "defaultValue": "\"Enter the code sent to {email} from our referral provider, impact.com.\""
93
83
  },
94
84
  "reverifyCodeHeaderText": {
95
85
  "type": "string",
@@ -154,27 +144,6 @@ export class WidgetCodeVerification {
154
144
  "reflect": false,
155
145
  "defaultValue": "\"Resend code\""
156
146
  },
157
- "resendCodeLink": {
158
- "type": "string",
159
- "mutable": false,
160
- "complexType": {
161
- "original": "string",
162
- "resolved": "string",
163
- "references": {}
164
- },
165
- "required": false,
166
- "optional": false,
167
- "docs": {
168
- "tags": [{
169
- "text": "Resend code link",
170
- "name": "uiName"
171
- }],
172
- "text": "The link that appears in the resend code link"
173
- },
174
- "attribute": "resend-code-link",
175
- "reflect": false,
176
- "defaultValue": "\"/resend-code\""
177
- },
178
147
  "codeResentSuccessfullyText": {
179
148
  "type": "string",
180
149
  "mutable": false,
@@ -196,27 +165,6 @@ export class WidgetCodeVerification {
196
165
  "reflect": false,
197
166
  "defaultValue": "\"Another code has been sent to {email}\""
198
167
  },
199
- "useDifferentEmailText": {
200
- "type": "string",
201
- "mutable": false,
202
- "complexType": {
203
- "original": "string",
204
- "resolved": "string",
205
- "references": {}
206
- },
207
- "required": false,
208
- "optional": false,
209
- "docs": {
210
- "tags": [{
211
- "text": "Use different email text",
212
- "name": "uiName"
213
- }],
214
- "text": "Link text displayed under the verify button"
215
- },
216
- "attribute": "use-different-email-text",
217
- "reflect": false,
218
- "defaultValue": "\"Use a different email\""
219
- },
220
168
  "invalidCodeText": {
221
169
  "type": "string",
222
170
  "mutable": false,
@@ -236,7 +184,7 @@ export class WidgetCodeVerification {
236
184
  },
237
185
  "attribute": "invalid-code-text",
238
186
  "reflect": false,
239
- "defaultValue": "\" Please check your code and try again. If you\u2019re still having trouble, try resending your code.\""
187
+ "defaultValue": "\"Please check your code and try again. If you\u2019re still having trouble, try resending your code.\""
240
188
  },
241
189
  "verifyText": {
242
190
  "type": "string",
@@ -285,7 +233,7 @@ export class WidgetCodeVerification {
285
233
  "mutable": false,
286
234
  "complexType": {
287
235
  "original": "DemoData<WidgetCodeVerificationViewProps>",
288
- "resolved": "{ states?: { loading: boolean; email: string; verifyFailed?: boolean; codeResent?: boolean; }; refs?: { codeWrapperRef: any; }; }",
236
+ "resolved": "{ states?: { initialiseLoading: boolean; loading: boolean; email: string; verifyFailed?: boolean; emailResent: boolean; }; refs?: { codeWrapperRef: any; }; }",
289
237
  "references": {
290
238
  "DemoData": {
291
239
  "location": "import",
@@ -309,21 +257,44 @@ export class WidgetCodeVerification {
309
257
  }],
310
258
  "text": ""
311
259
  }
260
+ },
261
+ "onVerification": {
262
+ "type": "unknown",
263
+ "mutable": false,
264
+ "complexType": {
265
+ "original": "(token: string) => any",
266
+ "resolved": "(token: string) => any",
267
+ "references": {}
268
+ },
269
+ "required": false,
270
+ "optional": true,
271
+ "docs": {
272
+ "tags": [{
273
+ "text": undefined,
274
+ "name": "undocumented"
275
+ }],
276
+ "text": ""
277
+ }
312
278
  }
313
279
  }; }
314
280
  }
315
281
  function useDemoWidgetCodeVerification(props) {
282
+ const [emailResent, setEmailResent] = useState(false);
283
+ const setVerifiedContext = useSetParent(VERIFICATION_PARENT_NAMESPACE);
316
284
  return deepmerge({
317
285
  states: {
318
286
  loading: false,
319
- email: "",
320
- verifyFailed: false,
287
+ email: "test@example.com",
288
+ emailResent,
289
+ resendError: true,
290
+ verifyFailed: true,
321
291
  },
322
292
  refs: {
323
293
  codeWrapperRef: () => { },
324
294
  },
325
295
  callbacks: {
326
- submitCode: async () => { },
296
+ resendEmail: async () => setEmailResent(true),
297
+ submitCode: async () => setVerifiedContext(true),
327
298
  },
328
299
  text: props.getTextProps(),
329
300
  }, props.demoData || {}, { arrayMerge: (_, a) => a });
@@ -1,12 +1,14 @@
1
1
  import { useMutation, useParent, useParentValue, useUserIdentity, } from "@saasquatch/component-boilerplate";
2
2
  import { useEffect, useHost, useState } from "@saasquatch/stencil-hooks";
3
- import { SHOW_CODE_NAMESPACE, VERIFICATION_EMAIL_NAMESPACE, VERIFICATION_EVENT_KEY, } from "../keys";
4
- import { useVerificationEmailMutation } from "../sqm-email-verification/useEmailVerification";
5
3
  import { gql } from "graphql-request";
6
- // TODO: Move to component-boilerplate
4
+ import { SHOW_CODE_NAMESPACE, VERIFICATION_EMAIL_NAMESPACE, } from "../keys";
5
+ import { useVerificationEmail } from "../useVerificationEmail";
7
6
  export const VerifyEmailWithCodeMutation = gql `
8
- mutation verifyUserEmail($user: UserIdInput!, $code: String!) {
9
- verifyUserEmail(user: $user, code: $code) {
7
+ mutation submitImpactPublisherEmail2FACode(
8
+ $user: UserIdInput!
9
+ $code: String!
10
+ ) {
11
+ submitImpactPublisherEmail2FACode(user: $user, code: $code) {
10
12
  verifiedEmail
11
13
  accessKey
12
14
  }
@@ -43,9 +45,8 @@ export function useWidgetCodeVerification(props) {
43
45
  const [emailResent, setEmailResent] = useState(false);
44
46
  const [codeRef, setCodeRef] = useState(null);
45
47
  const [validationError, setValidationError] = useState(false);
46
- // TODO: Need to handle error states for these errors
47
- const [verifyUser, { loading: verifyLoading, errors: verifyErrors }] = useCodeVerificationMutation();
48
- const [request, { loading: resendLoading, data, errors: resendErrors }] = useVerificationEmailMutation();
48
+ const [emailError, setEmailError] = useState(false);
49
+ const { initialized, send: [sendEmail, { loading: sendLoading, errors: sendErrors }], verify: [verifyEmail, { loading: verifyLoading, errors: verifyErrors }], } = useVerificationEmail();
49
50
  useEffect(() => {
50
51
  if (!codeRef)
51
52
  return;
@@ -61,7 +62,7 @@ export function useWidgetCodeVerification(props) {
61
62
  }
62
63
  });
63
64
  element.addEventListener("input", (e) => {
64
- const input = e.target.value;
65
+ const input = e.data;
65
66
  if (!input)
66
67
  return;
67
68
  if (idx === codeElements.length - 1) {
@@ -71,8 +72,10 @@ export function useWidgetCodeVerification(props) {
71
72
  if (input.length > 1) {
72
73
  const rest = input.slice(1);
73
74
  e.target.value = input.slice(0, 1);
74
- codeElements[idx + 1].value = rest;
75
- codeElements[idx + 1].dispatchEvent(new Event("input"));
75
+ codeElements[idx + 1].dispatchEvent(new InputEvent("input", {
76
+ inputType: "insertFromPaste",
77
+ data: rest,
78
+ }));
76
79
  }
77
80
  codeElements[idx + 1].focus();
78
81
  });
@@ -83,14 +86,16 @@ export function useWidgetCodeVerification(props) {
83
86
  setValidationError(false);
84
87
  };
85
88
  const resendEmail = async () => {
86
- // TODO: Error checks, depends on what mutation is set up as
87
- const result = await request();
88
- if (emailSent) {
89
- setEmailResent(true);
90
- setTimeout(() => {
91
- setEmailResent(false);
92
- }, 500);
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;
93
96
  }
97
+ if (emailSent)
98
+ setEmailResent(true);
94
99
  setEmailSent(true);
95
100
  };
96
101
  const submitCode = async () => {
@@ -104,16 +109,13 @@ export function useWidgetCodeVerification(props) {
104
109
  codeElements.forEach((element) => {
105
110
  code = `${code}${element.value}`;
106
111
  });
112
+ // UI should only allow this to be called if initialized, but checking just in case
113
+ if (!initialized)
114
+ return;
107
115
  setValidationError(false);
108
- // Only 123456 passes for a valid code rn
109
- const res = await verifyUser(code);
110
- if (res) {
111
- const event = new CustomEvent(VERIFICATION_EVENT_KEY, {
112
- detail: { token: res.verifyUserEmail.accessKey },
113
- composed: true,
114
- bubbles: true,
115
- });
116
- host.dispatchEvent(event);
116
+ const res = await verifyEmail(code);
117
+ if (res === null || res === void 0 ? void 0 : res.success) {
118
+ props.onVerification(res.accessKey);
117
119
  reset();
118
120
  }
119
121
  else {
@@ -121,10 +123,15 @@ export function useWidgetCodeVerification(props) {
121
123
  }
122
124
  };
123
125
  useEffect(() => {
126
+ // Wait for mutations to be determined from user lookup
127
+ if (!initialized)
128
+ return;
124
129
  // email should already exist if user has completed email-verification
125
130
  if (!email)
126
131
  resendEmail();
127
- }, []);
132
+ else
133
+ setEmailSent(true);
134
+ }, [initialized]);
128
135
  return {
129
136
  refs: {
130
137
  codeWrapperRef: setCodeRef,
@@ -132,7 +139,9 @@ export function useWidgetCodeVerification(props) {
132
139
  states: {
133
140
  email,
134
141
  emailResent,
135
- loading: verifyLoading || resendLoading,
142
+ resendError: sendErrors || verifyErrors,
143
+ initialiseLoading: !initialized,
144
+ loading: sendLoading || verifyLoading,
136
145
  verifyFailed: !!validationError,
137
146
  },
138
147
  callbacks: {
@@ -4,19 +4,39 @@ export default {
4
4
  };
5
5
  const defaultProps = {
6
6
  email: "",
7
- error: "",
7
+ error: false,
8
8
  loading: false,
9
+ initialLoading: false,
10
+ sendCodeError: false,
9
11
  };
10
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
+ } }));
11
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: {
12
26
  states: {
13
27
  ...defaultProps,
14
28
  loading: true,
15
29
  },
16
30
  } }));
17
- export const Error = () => (h("sqm-email-verification", { demoData: {
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: {
18
38
  states: {
19
39
  ...defaultProps,
20
- error: "Email is invalid",
40
+ sendCodeError: true,
21
41
  },
22
42
  } }));
@@ -15,6 +15,16 @@ const style = {
15
15
  flexDirection: "column",
16
16
  maxWidth: "320px",
17
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
+ },
18
28
  ContinueButton: {
19
29
  width: "100%",
20
30
  maxWidth: "100px",
@@ -63,15 +73,18 @@ export function WidgetEmailVerificationView(props) {
63
73
  h("style", { type: "text/css" },
64
74
  vanillaStyle,
65
75
  styleString),
66
- states.loading ? (renderLoadingSkeleton()) : (h("div", { class: sheet.classes.Wrapper },
67
- " ",
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 },
68
81
  h(TextSpanView, { type: "p" }, text.verifyEmailHeaderText),
69
82
  h("sl-form", { "onSl-submit": callbacks.submitEmail },
70
83
  h("div", { class: sheet.classes.InputsContainer },
71
- h("sl-input", Object.assign({ exportparts: "label: input-label, base: input-base", label: text.emailLabel, value: states.email, type: "email", id: "email", name: "email", required: true }, (states.error
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
72
85
  ? {
73
86
  class: sheet.classes.ErrorInput,
74
- helpText: "Please enter a valid email",
87
+ helpText: text.emailValidationErrorText,
75
88
  }
76
89
  : {}))),
77
90
  h("sl-button", { submit: true, class: sheet.classes.ContinueButton, loading: states.loading, exportparts: "base: primarybutton-base", type: "primary" }, text.sendCodeText)))))));