@saasquatch/mint-components 1.15.3 → 1.15.4-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 (41) hide show
  1. package/dist/cjs/{sqm-base-registration-form-view-8029d30e.js → sqm-base-registration-form-view-66f99821.js} +9 -4
  2. package/dist/cjs/sqm-portal-google-registration-form.cjs.entry.js +29 -19
  3. package/dist/cjs/sqm-stencilbook.cjs.entry.js +3 -3
  4. package/dist/collection/components/sqm-base-registration/BaseRegistrationForm.stories.js +2 -2
  5. package/dist/collection/components/sqm-base-registration/sqm-base-registration-form-view.js +9 -4
  6. package/dist/collection/components/sqm-checkbox-field/sqm-checkbox-field.js +1 -1
  7. package/dist/collection/components/sqm-dropdown-field/sqm-dropdown-field.js +1 -1
  8. package/dist/collection/components/sqm-input-field/sqm-input-field.js +1 -1
  9. package/dist/collection/components/sqm-marketing-emails-checkbox/sqm-marketing-emails-checkbox.js +1 -1
  10. package/dist/collection/components/sqm-password-field/sqm-password-field.js +2 -2
  11. package/dist/collection/components/sqm-portal-google-registration-form/sqm-portal-google-registration-form.js +7 -5
  12. package/dist/collection/components/sqm-portal-google-registration-form/usePortalGoogleRegistrationForm.js +23 -15
  13. package/dist/esm/{sqm-base-registration-form-view-dafba287.js → sqm-base-registration-form-view-d81e316a.js} +9 -4
  14. package/dist/esm/sqm-portal-google-registration-form.entry.js +29 -19
  15. package/dist/esm/sqm-stencilbook.entry.js +3 -3
  16. package/dist/esm-es5/sqm-base-registration-form-view-d81e316a.js +1 -0
  17. package/dist/esm-es5/sqm-portal-google-registration-form.entry.js +1 -1
  18. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  19. package/dist/mint-components/mint-components.esm.js +1 -1
  20. package/dist/mint-components/{p-ec309e97.entry.js → p-268fad47.entry.js} +2 -2
  21. package/dist/mint-components/p-37996351.system.js +1 -1
  22. package/dist/mint-components/p-7176a952.entry.js +1 -0
  23. package/dist/mint-components/p-8d0393d9.system.entry.js +1 -0
  24. package/dist/mint-components/p-9308221f.js +1 -0
  25. package/dist/mint-components/p-bc021969.system.js +1 -0
  26. package/dist/mint-components/{p-7f308509.system.entry.js → p-e5186714.system.entry.js} +1 -1
  27. package/dist/types/components/sqm-base-registration/sqm-base-registration-form-view.d.ts +2 -1
  28. package/dist/types/components/sqm-checkbox-field/sqm-checkbox-field.d.ts +1 -1
  29. package/dist/types/components/sqm-dropdown-field/sqm-dropdown-field.d.ts +1 -1
  30. package/dist/types/components/sqm-input-field/sqm-input-field.d.ts +1 -1
  31. package/dist/types/components/sqm-marketing-emails-checkbox/sqm-marketing-emails-checkbox.d.ts +1 -1
  32. package/dist/types/components/sqm-password-field/sqm-password-field.d.ts +1 -1
  33. package/dist/types/components/sqm-portal-google-registration-form/usePortalGoogleRegistrationForm.d.ts +2 -1
  34. package/docs/docs.docx +0 -0
  35. package/docs/raisins.json +1 -1
  36. package/package.json +1 -1
  37. package/dist/esm-es5/sqm-base-registration-form-view-dafba287.js +0 -1
  38. package/dist/mint-components/p-2651ef99.system.js +0 -1
  39. package/dist/mint-components/p-59fe6066.js +0 -1
  40. package/dist/mint-components/p-9c4f4cd6.entry.js +0 -1
  41. package/dist/mint-components/p-a3647f70.system.entry.js +0 -1
@@ -40,6 +40,7 @@ sqm-portal-register {
40
40
  const sheet = JSS.createStyleSheet(style);
41
41
  const styleString = sheet.toString();
42
42
  function BaseRegistrationFormView(props) {
43
+ var _a, _b;
43
44
  const { states, content, callbacks } = props;
44
45
  return (index.h("div", { class: sheet.classes.Wrapper },
45
46
  index.h("style", { type: "text/css" },
@@ -47,10 +48,8 @@ function BaseRegistrationFormView(props) {
47
48
  styleString),
48
49
  index.h(sqmTextSpanView.TextSpanView, { type: "h3" }, content.pageLabel),
49
50
  index.h("sl-form", { class: sheet.classes.Column, "onSl-submit": callbacks.handleEmailSubmit, novalidate: true },
50
- states.error && (index.h("sqm-form-message", { type: "error", exportparts: "erroralert-icon" },
51
- index.h("div", { part: "erroralert-text" }, props.states.error))),
52
51
  content.formData,
53
- index.h("sl-input", { exportparts: "label: input-label, base: input-base", type: "email", name: "/email", label: content.emailLabel || "Email", required: true, validationError: ({ value }) => {
52
+ index.h("sl-input", Object.assign({ exportparts: "label: input-label, base: input-base", type: "email", name: "/email", label: content.emailLabel || "Email", required: true, validationError: ({ value }) => {
54
53
  if (!value) {
55
54
  return content.requiredFieldErrorMessage;
56
55
  }
@@ -58,7 +57,13 @@ function BaseRegistrationFormView(props) {
58
57
  if (!value.includes("@")) {
59
58
  return content.invalidEmailErrorMessage;
60
59
  }
61
- } }),
60
+ } }, (((_a = states === null || states === void 0 ? void 0 : states.validationErrors) === null || _a === void 0 ? void 0 : _a.email) ? {
61
+ class: sheet.classes.ErrorStyle,
62
+ helpText: ((_b = states === null || states === void 0 ? void 0 : states.validationErrors) === null || _b === void 0 ? void 0 : _b.email) ||
63
+ content.requiredFieldErrorMessage,
64
+ }
65
+ : []))),
66
+ content.terms,
62
67
  index.h("div", { class: sheet.classes.ButtonsContainer },
63
68
  index.h("sl-button", { submit: true, exportparts: "base: primarybutton-base", type: "primary", style: { margin: "0" } }, content.submitLabel || "Register"),
64
69
  index.h("sl-menu-divider", { style: { margin: "0" } }),
@@ -11,7 +11,7 @@ const JSS = require('./JSS-8503a151.js');
11
11
  require('./mixins-f7e0377a.js');
12
12
  require('./sqm-text-span-view-0aa82125.js');
13
13
  const useRegistrationFormState = require('./useRegistrationFormState-7b820f0c.js');
14
- const sqmBaseRegistrationFormView = require('./sqm-base-registration-form-view-8029d30e.js');
14
+ const sqmBaseRegistrationFormView = require('./sqm-base-registration-form-view-66f99821.js');
15
15
  const sqmPortalRegistrationFormView = require('./sqm-portal-registration-form-view-637a4bf4.js');
16
16
  require('./AsYouType-6788393a.js');
17
17
  const usePortalRegistrationForm = require('./usePortalRegistrationForm-f25d89e7.js');
@@ -75,7 +75,6 @@ function jwtDecode(token, options) {
75
75
  }
76
76
 
77
77
  function usePortalGoogleRegistrationForm(props) {
78
- const [emailValidationError, setEmailValidationError] = stencilHooks_module.useState(null);
79
78
  const [registrationFormState, setRegistrationFormState] = useRegistrationFormState.useRegistrationForm();
80
79
  const [showRegistrationForm, setShowRegistrationForm] = stencilHooks_module.useState({
81
80
  mode: "base",
@@ -83,33 +82,41 @@ function usePortalGoogleRegistrationForm(props) {
83
82
  const handleEmailSubmit = async (event) => {
84
83
  const formControls = event.target.getFormControls();
85
84
  let formData = {};
86
- let errorMessage = null;
85
+ let validationErrors = {};
87
86
  formControls.forEach((control) => {
88
87
  if (!control.name)
89
88
  return;
90
- jsonpointer.jsonpointer.set(formData, control.name, control.value);
91
- // only validate email field
92
- if (control.name !== "/email")
93
- return;
94
- if (control.required && !control.value)
95
- errorMessage = props.requiredFieldErrorMessage;
89
+ const key = control.name;
90
+ const value = control.value;
91
+ jsonpointer.jsonpointer.set(formData, key, value);
92
+ if (control.required && !value) {
93
+ jsonpointer.jsonpointer.set(validationErrors, key, props.requiredFieldErrorMessage);
94
+ }
95
+ // errorMessage = props.requiredFieldErrorMessage;
96
96
  if (typeof control.validationError === "function") {
97
97
  const validate = control.validationError;
98
98
  const validationError = validate({
99
99
  control,
100
- key: "email",
101
- value: control.value,
100
+ key,
101
+ value,
102
102
  });
103
103
  if (validationError)
104
- errorMessage = validationError;
104
+ jsonpointer.jsonpointer.set(validationErrors, key, validationError);
105
105
  }
106
106
  });
107
- if (errorMessage) {
108
- setEmailValidationError(errorMessage);
107
+ if (Object.keys(validationErrors).length) {
108
+ // early return for validation errors
109
+ setRegistrationFormState({
110
+ ...registrationFormState,
111
+ loading: false,
112
+ error: "",
113
+ validationErrors,
114
+ });
109
115
  return;
110
116
  }
111
117
  setRegistrationFormState({
112
118
  ...registrationFormState,
119
+ validationErrors: {},
113
120
  initialData: {
114
121
  ...registrationFormState === null || registrationFormState === void 0 ? void 0 : registrationFormState.initialData,
115
122
  ...formData,
@@ -139,8 +146,9 @@ function usePortalGoogleRegistrationForm(props) {
139
146
  }
140
147
  };
141
148
  return {
149
+ registrationFormState,
142
150
  showRegistrationForm,
143
- emailValidationError,
151
+ validationErrors: registrationFormState.validationErrors,
144
152
  handleGoogleInit,
145
153
  handleEmailSubmit,
146
154
  };
@@ -296,7 +304,7 @@ const PortalGoogleRegistrationForm = class {
296
304
  };
297
305
  const sheet = JSS.createStyleSheet(styles);
298
306
  const styleString = sheet.toString();
299
- const { handleGoogleInit, handleEmailSubmit, showRegistrationForm, emailValidationError, } = index_module.isDemo() ? useGoogleDemo(this) : usePortalGoogleRegistrationForm(this);
307
+ const { handleGoogleInit, handleEmailSubmit, showRegistrationForm, validationErrors, } = index_module.isDemo() ? useGoogleDemo(this) : usePortalGoogleRegistrationForm(this);
300
308
  const content = {
301
309
  formData: index.h("slot", { name: "formData" }),
302
310
  googleButton: (index.h("sqm-google-sign-in", { text: this.googleButtonText, onInitComplete: handleGoogleInit })),
@@ -321,14 +329,16 @@ const PortalGoogleRegistrationForm = class {
321
329
  };
322
330
  if (showRegistrationForm.mode === "base") {
323
331
  return (index.h(sqmBaseRegistrationFormView.BaseRegistrationFormView, { states: {
324
- error: emailValidationError,
332
+ validationErrors,
325
333
  }, callbacks: { handleEmailSubmit }, content: content }));
326
334
  }
327
335
  return (index.h(sqmPortalRegistrationFormView.PortalRegistrationFormView, { states: {
328
336
  ...states,
329
337
  emailDisabled: true,
330
338
  hidePasswords: showRegistrationForm.mode === "google",
331
- }, callbacks: callbacks, content: content, refs: refs }));
339
+ }, callbacks: callbacks,
340
+ // Show terms only on first screen
341
+ content: { ...content, terms: null }, refs: refs }));
332
342
  }
333
343
  };
334
344
  function useRegisterDemo(props) {
@@ -364,7 +374,7 @@ function useGoogleDemo(props) {
364
374
  mode: "base",
365
375
  });
366
376
  return cjs.cjs({
367
- emailValidationError: false,
377
+ validationErrors: {},
368
378
  handleEmailSubmit: () => setShowRegistrationForm({ mode: "manual" }),
369
379
  showRegistrationForm,
370
380
  handleGoogleInit: () => setShowRegistrationForm({ mode: "google" }),
@@ -28,7 +28,7 @@ const sqmNavigationSidebarItemView = require('./sqm-navigation-sidebar-item-view
28
28
  const sqmPortalEmailVerificationView = require('./sqm-portal-email-verification-view-7ebb426a.js');
29
29
  const sqmPortalForgotPasswordView = require('./sqm-portal-forgot-password-view-78f19ef9.js');
30
30
  const sqmPortalLoginView = require('./sqm-portal-login-view-761a4d8e.js');
31
- const sqmBaseRegistrationFormView = require('./sqm-base-registration-form-view-8029d30e.js');
31
+ const sqmBaseRegistrationFormView = require('./sqm-base-registration-form-view-66f99821.js');
32
32
  const sqmPortalRegistrationFormView = require('./sqm-portal-registration-form-view-637a4bf4.js');
33
33
  const sqmPortalProfileView = require('./sqm-portal-profile-view-33164798.js');
34
34
  require('./utilities-78f5e169.js');
@@ -15640,7 +15640,7 @@ const BaseRegistrationForm_stories = {
15640
15640
  };
15641
15641
  const defaultProps$q = {
15642
15642
  states: {
15643
- error: "",
15643
+ validationErrors: {},
15644
15644
  },
15645
15645
  callbacks: {
15646
15646
  handleEmailSubmit: () => console.log("Submit!"),
@@ -15660,7 +15660,7 @@ const defaultProps$q = {
15660
15660
  const errorProps$a = {
15661
15661
  ...defaultProps$q,
15662
15662
  states: {
15663
- error: "Something went wrong. Please try again.",
15663
+ validationErrors: { error: "Something went wrong. Please try again." },
15664
15664
  },
15665
15665
  };
15666
15666
  const Default$o = () => {
@@ -5,7 +5,7 @@ export default {
5
5
  };
6
6
  const defaultProps = {
7
7
  states: {
8
- error: "",
8
+ validationErrors: {},
9
9
  },
10
10
  callbacks: {
11
11
  handleEmailSubmit: () => console.log("Submit!"),
@@ -25,7 +25,7 @@ const defaultProps = {
25
25
  const errorProps = {
26
26
  ...defaultProps,
27
27
  states: {
28
- error: "Something went wrong. Please try again.",
28
+ validationErrors: { error: "Something went wrong. Please try again." },
29
29
  },
30
30
  };
31
31
  export const Default = () => {
@@ -37,6 +37,7 @@ sqm-portal-register {
37
37
  const sheet = createStyleSheet(style);
38
38
  const styleString = sheet.toString();
39
39
  export function BaseRegistrationFormView(props) {
40
+ var _a, _b;
40
41
  const { states, content, callbacks } = props;
41
42
  return (h("div", { class: sheet.classes.Wrapper },
42
43
  h("style", { type: "text/css" },
@@ -44,10 +45,8 @@ export function BaseRegistrationFormView(props) {
44
45
  styleString),
45
46
  h(TextSpanView, { type: "h3" }, content.pageLabel),
46
47
  h("sl-form", { class: sheet.classes.Column, "onSl-submit": callbacks.handleEmailSubmit, novalidate: true },
47
- states.error && (h("sqm-form-message", { type: "error", exportparts: "erroralert-icon" },
48
- h("div", { part: "erroralert-text" }, props.states.error))),
49
48
  content.formData,
50
- h("sl-input", { exportparts: "label: input-label, base: input-base", type: "email", name: "/email", label: content.emailLabel || "Email", required: true, validationError: ({ value }) => {
49
+ h("sl-input", Object.assign({ exportparts: "label: input-label, base: input-base", type: "email", name: "/email", label: content.emailLabel || "Email", required: true, validationError: ({ value }) => {
51
50
  if (!value) {
52
51
  return content.requiredFieldErrorMessage;
53
52
  }
@@ -55,7 +54,13 @@ export function BaseRegistrationFormView(props) {
55
54
  if (!value.includes("@")) {
56
55
  return content.invalidEmailErrorMessage;
57
56
  }
58
- } }),
57
+ } }, (((_a = states === null || states === void 0 ? void 0 : states.validationErrors) === null || _a === void 0 ? void 0 : _a.email) ? {
58
+ class: sheet.classes.ErrorStyle,
59
+ helpText: ((_b = states === null || states === void 0 ? void 0 : states.validationErrors) === null || _b === void 0 ? void 0 : _b.email) ||
60
+ content.requiredFieldErrorMessage,
61
+ }
62
+ : []))),
63
+ content.terms,
59
64
  h("div", { class: sheet.classes.ButtonsContainer },
60
65
  h("sl-button", { submit: true, exportparts: "base: primarybutton-base", type: "primary", style: { margin: "0" } }, content.submitLabel || "Register"),
61
66
  h("sl-menu-divider", { style: { margin: "0" } }),
@@ -8,7 +8,7 @@ import { CheckboxFieldView, } from "./sqm-checkbox-field-view";
8
8
  import { useCheckboxField } from "./useCheckboxField";
9
9
  /**
10
10
  * @uiName Form Checkbox Field
11
- * @validParents ["sqm-portal-register","sqm-portal-registration-form"]
11
+ * @validParents ["sqm-portal-register","sqm-portal-registration-form", "sqm-portal-google-registration-form"]
12
12
  * @exampleGroup Microsite Components
13
13
  * @example Form Checkbox Field - <sqm-checkbox-field checkbox-name="terms" checkbox-label="By signing up you agree to the {labelLink}" checkbox-label-link="https://example.com" checkbox-label-link-text="Terms and Conditions" error-message="Must be checked" ></sqm-checkbox-field>
14
14
  */
@@ -8,7 +8,7 @@ import { DropdownFieldView, } from "./sqm-dropdown-field-view";
8
8
  import { useDropdownField } from "./useDropdownField";
9
9
  /**
10
10
  * @uiName Form Dropdown Field
11
- * @validParents ["sqm-portal-register","sqm-portal-registration-form"]
11
+ * @validParents ["sqm-portal-register","sqm-portal-registration-form", "sqm-portal-google-registration-form"]
12
12
  * @slots [{"name":"", "title":"Drop Down Option"}]
13
13
  * @exampleGroup Microsite Components
14
14
  * @example Form Dropdown Field - <sqm-dropdown-field dropdown-label="Select an option" error-message="Select an option"><sl-menu-item value="option-1">Option 1</sl-menu-item><sl-menu-item value="option-2">Option 2</sl-menu-item><sl-menu-item value="option-3">Option 3</sl-menu-item></sqm-dropdown-field>
@@ -8,7 +8,7 @@ import { InputFieldView } from "./sqm-input-field-view";
8
8
  import { useInputField } from "./useInputField";
9
9
  /**
10
10
  * @uiName Form Input Field
11
- * @validParents ["sqm-portal-register","sqm-portal-registration-form"]
11
+ * @validParents ["sqm-portal-register","sqm-portal-registration-form", "sqm-portal-google-registration-form"]
12
12
  * @exampleGroup Microsite Components
13
13
  * @example Form Input Field - <sqm-input-field input-label="Field Label" field-type="text" error-message="Cannot be empty"></sqm-input-field>
14
14
  */
@@ -7,7 +7,7 @@ import { CheckboxFieldView, } from "../sqm-checkbox-field/sqm-checkbox-field-vie
7
7
  import { useCheckboxField } from "../sqm-checkbox-field/useCheckboxField";
8
8
  /**
9
9
  * @uiName Marketing Emails Checkbox Field
10
- * @validParents ["sqm-portal-register","sqm-portal-registration-form"]
10
+ * @validParents ["sqm-portal-register","sqm-portal-registration-form", "sqm-portal-google-registration-form"]
11
11
  * @requiredFeatures ["MARKETING_EMAILS"]
12
12
  */
13
13
  export class MarketingEmailsCheckbox {
@@ -3,13 +3,13 @@ import { withHooks } from "@saasquatch/stencil-hooks";
3
3
  import { useState } from "@saasquatch/universal-hooks";
4
4
  import { Component, h, Prop, State } from "@stencil/core";
5
5
  import deepmerge from "deepmerge";
6
+ import { getProps } from "../../utils/utils";
6
7
  import { validateNewPassword } from "./passwordValidation";
7
8
  import { PortalResetPasswordView, } from "./sqm-password-field-view";
8
9
  import { usePasswordField } from "./usePasswordField";
9
- import { getProps } from "../../utils/utils";
10
10
  /**
11
11
  * @uiName Form Password Field
12
- * @validParents ["sqm-portal-register","sqm-portal-registration-form"]
12
+ * @validParents ["sqm-portal-register","sqm-portal-registration-form", "sqm-portal-google-registration-form"]
13
13
  * @exampleGroup Microsite Components
14
14
  * @example Form Password Field - <sqm-password-field field-label="Password"></sqm-password-field>
15
15
  */
@@ -2,11 +2,11 @@ import { isDemo, navigation } from "@saasquatch/component-boilerplate";
2
2
  import { useState, withHooks } from "@saasquatch/stencil-hooks";
3
3
  import { Component, h, Prop, State } from "@stencil/core";
4
4
  import deepmerge from "deepmerge";
5
+ import { createStyleSheet } from "../../styling/JSS";
5
6
  import { BaseRegistrationFormView } from "../sqm-base-registration/sqm-base-registration-form-view";
6
7
  import { PortalRegistrationFormView, } from "../sqm-portal-registration-form/sqm-portal-registration-form-view";
7
8
  import { usePortalRegistrationForm } from "../sqm-portal-registration-form/usePortalRegistrationForm";
8
9
  import { usePortalGoogleRegistrationForm } from "./usePortalGoogleRegistrationForm";
9
- import { createStyleSheet } from "../../styling/JSS";
10
10
  /**
11
11
  * @uiName Google Registration
12
12
  * @canvasRenderer always-replace
@@ -161,7 +161,7 @@ export class PortalGoogleRegistrationForm {
161
161
  };
162
162
  const sheet = createStyleSheet(styles);
163
163
  const styleString = sheet.toString();
164
- const { handleGoogleInit, handleEmailSubmit, showRegistrationForm, emailValidationError, } = isDemo() ? useGoogleDemo(this) : usePortalGoogleRegistrationForm(this);
164
+ const { handleGoogleInit, handleEmailSubmit, showRegistrationForm, validationErrors, } = isDemo() ? useGoogleDemo(this) : usePortalGoogleRegistrationForm(this);
165
165
  const content = {
166
166
  formData: h("slot", { name: "formData" }),
167
167
  googleButton: (h("sqm-google-sign-in", { text: this.googleButtonText, onInitComplete: handleGoogleInit })),
@@ -192,14 +192,16 @@ export class PortalGoogleRegistrationForm {
192
192
  };
193
193
  if (showRegistrationForm.mode === "base") {
194
194
  return (h(BaseRegistrationFormView, { states: {
195
- error: emailValidationError,
195
+ validationErrors,
196
196
  }, callbacks: { handleEmailSubmit }, content: content }));
197
197
  }
198
198
  return (h(PortalRegistrationFormView, { states: {
199
199
  ...states,
200
200
  emailDisabled: true,
201
201
  hidePasswords: showRegistrationForm.mode === "google",
202
- }, callbacks: callbacks, content: content, refs: refs }));
202
+ }, callbacks: callbacks,
203
+ // Show terms only on first screen
204
+ content: { ...content, terms: null }, refs: refs }));
203
205
  }
204
206
  static get is() { return "sqm-portal-google-registration-form"; }
205
207
  static get encapsulation() { return "shadow"; }
@@ -874,7 +876,7 @@ function useGoogleDemo(props) {
874
876
  mode: "base",
875
877
  });
876
878
  return deepmerge({
877
- emailValidationError: false,
879
+ validationErrors: {},
878
880
  handleEmailSubmit: () => setShowRegistrationForm({ mode: "manual" }),
879
881
  showRegistrationForm,
880
882
  handleGoogleInit: () => setShowRegistrationForm({ mode: "google" }),
@@ -1,9 +1,8 @@
1
1
  import { useState } from "@saasquatch/universal-hooks";
2
2
  import jsonpointer from "jsonpointer";
3
- import { useRegistrationForm } from "../sqm-portal-registration-form/useRegistrationFormState";
4
3
  import { jwtDecode } from "jwt-decode";
4
+ import { useRegistrationForm } from "../sqm-portal-registration-form/useRegistrationFormState";
5
5
  export function usePortalGoogleRegistrationForm(props) {
6
- const [emailValidationError, setEmailValidationError] = useState(null);
7
6
  const [registrationFormState, setRegistrationFormState] = useRegistrationForm();
8
7
  const [showRegistrationForm, setShowRegistrationForm] = useState({
9
8
  mode: "base",
@@ -11,33 +10,41 @@ export function usePortalGoogleRegistrationForm(props) {
11
10
  const handleEmailSubmit = async (event) => {
12
11
  const formControls = event.target.getFormControls();
13
12
  let formData = {};
14
- let errorMessage = null;
13
+ let validationErrors = {};
15
14
  formControls.forEach((control) => {
16
15
  if (!control.name)
17
16
  return;
18
- jsonpointer.set(formData, control.name, control.value);
19
- // only validate email field
20
- if (control.name !== "/email")
21
- return;
22
- if (control.required && !control.value)
23
- errorMessage = props.requiredFieldErrorMessage;
17
+ const key = control.name;
18
+ const value = control.value;
19
+ jsonpointer.set(formData, key, value);
20
+ if (control.required && !value) {
21
+ jsonpointer.set(validationErrors, key, props.requiredFieldErrorMessage);
22
+ }
23
+ // errorMessage = props.requiredFieldErrorMessage;
24
24
  if (typeof control.validationError === "function") {
25
25
  const validate = control.validationError;
26
26
  const validationError = validate({
27
27
  control,
28
- key: "email",
29
- value: control.value,
28
+ key,
29
+ value,
30
30
  });
31
31
  if (validationError)
32
- errorMessage = validationError;
32
+ jsonpointer.set(validationErrors, key, validationError);
33
33
  }
34
34
  });
35
- if (errorMessage) {
36
- setEmailValidationError(errorMessage);
35
+ if (Object.keys(validationErrors).length) {
36
+ // early return for validation errors
37
+ setRegistrationFormState({
38
+ ...registrationFormState,
39
+ loading: false,
40
+ error: "",
41
+ validationErrors,
42
+ });
37
43
  return;
38
44
  }
39
45
  setRegistrationFormState({
40
46
  ...registrationFormState,
47
+ validationErrors: {},
41
48
  initialData: {
42
49
  ...registrationFormState === null || registrationFormState === void 0 ? void 0 : registrationFormState.initialData,
43
50
  ...formData,
@@ -67,8 +74,9 @@ export function usePortalGoogleRegistrationForm(props) {
67
74
  }
68
75
  };
69
76
  return {
77
+ registrationFormState,
70
78
  showRegistrationForm,
71
- emailValidationError,
79
+ validationErrors: registrationFormState.validationErrors,
72
80
  handleGoogleInit,
73
81
  handleEmailSubmit,
74
82
  };
@@ -38,6 +38,7 @@ sqm-portal-register {
38
38
  const sheet = createStyleSheet(style);
39
39
  const styleString = sheet.toString();
40
40
  function BaseRegistrationFormView(props) {
41
+ var _a, _b;
41
42
  const { states, content, callbacks } = props;
42
43
  return (h("div", { class: sheet.classes.Wrapper },
43
44
  h("style", { type: "text/css" },
@@ -45,10 +46,8 @@ function BaseRegistrationFormView(props) {
45
46
  styleString),
46
47
  h(TextSpanView, { type: "h3" }, content.pageLabel),
47
48
  h("sl-form", { class: sheet.classes.Column, "onSl-submit": callbacks.handleEmailSubmit, novalidate: true },
48
- states.error && (h("sqm-form-message", { type: "error", exportparts: "erroralert-icon" },
49
- h("div", { part: "erroralert-text" }, props.states.error))),
50
49
  content.formData,
51
- h("sl-input", { exportparts: "label: input-label, base: input-base", type: "email", name: "/email", label: content.emailLabel || "Email", required: true, validationError: ({ value }) => {
50
+ h("sl-input", Object.assign({ exportparts: "label: input-label, base: input-base", type: "email", name: "/email", label: content.emailLabel || "Email", required: true, validationError: ({ value }) => {
52
51
  if (!value) {
53
52
  return content.requiredFieldErrorMessage;
54
53
  }
@@ -56,7 +55,13 @@ function BaseRegistrationFormView(props) {
56
55
  if (!value.includes("@")) {
57
56
  return content.invalidEmailErrorMessage;
58
57
  }
59
- } }),
58
+ } }, (((_a = states === null || states === void 0 ? void 0 : states.validationErrors) === null || _a === void 0 ? void 0 : _a.email) ? {
59
+ class: sheet.classes.ErrorStyle,
60
+ helpText: ((_b = states === null || states === void 0 ? void 0 : states.validationErrors) === null || _b === void 0 ? void 0 : _b.email) ||
61
+ content.requiredFieldErrorMessage,
62
+ }
63
+ : []))),
64
+ content.terms,
60
65
  h("div", { class: sheet.classes.ButtonsContainer },
61
66
  h("sl-button", { submit: true, exportparts: "base: primarybutton-base", type: "primary", style: { margin: "0" } }, content.submitLabel || "Register"),
62
67
  h("sl-menu-divider", { style: { margin: "0" } }),
@@ -7,7 +7,7 @@ import { c as createStyleSheet } from './JSS-67b5cff8.js';
7
7
  import './mixins-83f90fa1.js';
8
8
  import './sqm-text-span-view-ca32495e.js';
9
9
  import { a as useRegistrationForm } from './useRegistrationFormState-d6f33135.js';
10
- import { B as BaseRegistrationFormView } from './sqm-base-registration-form-view-dafba287.js';
10
+ import { B as BaseRegistrationFormView } from './sqm-base-registration-form-view-d81e316a.js';
11
11
  import { P as PortalRegistrationFormView } from './sqm-portal-registration-form-view-3c1f6000.js';
12
12
  import './AsYouType-46f67d0d.js';
13
13
  import { u as usePortalRegistrationForm } from './usePortalRegistrationForm-4b35a357.js';
@@ -71,7 +71,6 @@ function jwtDecode(token, options) {
71
71
  }
72
72
 
73
73
  function usePortalGoogleRegistrationForm(props) {
74
- const [emailValidationError, setEmailValidationError] = useState(null);
75
74
  const [registrationFormState, setRegistrationFormState] = useRegistrationForm();
76
75
  const [showRegistrationForm, setShowRegistrationForm] = useState({
77
76
  mode: "base",
@@ -79,33 +78,41 @@ function usePortalGoogleRegistrationForm(props) {
79
78
  const handleEmailSubmit = async (event) => {
80
79
  const formControls = event.target.getFormControls();
81
80
  let formData = {};
82
- let errorMessage = null;
81
+ let validationErrors = {};
83
82
  formControls.forEach((control) => {
84
83
  if (!control.name)
85
84
  return;
86
- jsonpointer.set(formData, control.name, control.value);
87
- // only validate email field
88
- if (control.name !== "/email")
89
- return;
90
- if (control.required && !control.value)
91
- errorMessage = props.requiredFieldErrorMessage;
85
+ const key = control.name;
86
+ const value = control.value;
87
+ jsonpointer.set(formData, key, value);
88
+ if (control.required && !value) {
89
+ jsonpointer.set(validationErrors, key, props.requiredFieldErrorMessage);
90
+ }
91
+ // errorMessage = props.requiredFieldErrorMessage;
92
92
  if (typeof control.validationError === "function") {
93
93
  const validate = control.validationError;
94
94
  const validationError = validate({
95
95
  control,
96
- key: "email",
97
- value: control.value,
96
+ key,
97
+ value,
98
98
  });
99
99
  if (validationError)
100
- errorMessage = validationError;
100
+ jsonpointer.set(validationErrors, key, validationError);
101
101
  }
102
102
  });
103
- if (errorMessage) {
104
- setEmailValidationError(errorMessage);
103
+ if (Object.keys(validationErrors).length) {
104
+ // early return for validation errors
105
+ setRegistrationFormState({
106
+ ...registrationFormState,
107
+ loading: false,
108
+ error: "",
109
+ validationErrors,
110
+ });
105
111
  return;
106
112
  }
107
113
  setRegistrationFormState({
108
114
  ...registrationFormState,
115
+ validationErrors: {},
109
116
  initialData: {
110
117
  ...registrationFormState === null || registrationFormState === void 0 ? void 0 : registrationFormState.initialData,
111
118
  ...formData,
@@ -135,8 +142,9 @@ function usePortalGoogleRegistrationForm(props) {
135
142
  }
136
143
  };
137
144
  return {
145
+ registrationFormState,
138
146
  showRegistrationForm,
139
- emailValidationError,
147
+ validationErrors: registrationFormState.validationErrors,
140
148
  handleGoogleInit,
141
149
  handleEmailSubmit,
142
150
  };
@@ -292,7 +300,7 @@ const PortalGoogleRegistrationForm = class {
292
300
  };
293
301
  const sheet = createStyleSheet(styles);
294
302
  const styleString = sheet.toString();
295
- const { handleGoogleInit, handleEmailSubmit, showRegistrationForm, emailValidationError, } = isDemo() ? useGoogleDemo(this) : usePortalGoogleRegistrationForm(this);
303
+ const { handleGoogleInit, handleEmailSubmit, showRegistrationForm, validationErrors, } = isDemo() ? useGoogleDemo(this) : usePortalGoogleRegistrationForm(this);
296
304
  const content = {
297
305
  formData: h$1("slot", { name: "formData" }),
298
306
  googleButton: (h$1("sqm-google-sign-in", { text: this.googleButtonText, onInitComplete: handleGoogleInit })),
@@ -317,14 +325,16 @@ const PortalGoogleRegistrationForm = class {
317
325
  };
318
326
  if (showRegistrationForm.mode === "base") {
319
327
  return (h$1(BaseRegistrationFormView, { states: {
320
- error: emailValidationError,
328
+ validationErrors,
321
329
  }, callbacks: { handleEmailSubmit }, content: content }));
322
330
  }
323
331
  return (h$1(PortalRegistrationFormView, { states: {
324
332
  ...states,
325
333
  emailDisabled: true,
326
334
  hidePasswords: showRegistrationForm.mode === "google",
327
- }, callbacks: callbacks, content: content, refs: refs }));
335
+ }, callbacks: callbacks,
336
+ // Show terms only on first screen
337
+ content: { ...content, terms: null }, refs: refs }));
328
338
  }
329
339
  };
330
340
  function useRegisterDemo(props) {
@@ -360,7 +370,7 @@ function useGoogleDemo(props) {
360
370
  mode: "base",
361
371
  });
362
372
  return cjs({
363
- emailValidationError: false,
373
+ validationErrors: {},
364
374
  handleEmailSubmit: () => setShowRegistrationForm({ mode: "manual" }),
365
375
  showRegistrationForm,
366
376
  handleGoogleInit: () => setShowRegistrationForm({ mode: "google" }),
@@ -24,7 +24,7 @@ import { N as NavigationSidebarItemView } from './sqm-navigation-sidebar-item-vi
24
24
  import { P as PortalEmailVerificationView } from './sqm-portal-email-verification-view-35b4353b.js';
25
25
  import { P as PortalForgotPasswordView } from './sqm-portal-forgot-password-view-3d3182f1.js';
26
26
  import { P as PortalLoginView } from './sqm-portal-login-view-7e49609a.js';
27
- import { B as BaseRegistrationFormView } from './sqm-base-registration-form-view-dafba287.js';
27
+ import { B as BaseRegistrationFormView } from './sqm-base-registration-form-view-d81e316a.js';
28
28
  import { P as PortalRegistrationFormView } from './sqm-portal-registration-form-view-3c1f6000.js';
29
29
  import { P as PortalProfileView } from './sqm-portal-profile-view-93003974.js';
30
30
  import './utilities-5b0ca040.js';
@@ -15636,7 +15636,7 @@ const BaseRegistrationForm_stories = {
15636
15636
  };
15637
15637
  const defaultProps$q = {
15638
15638
  states: {
15639
- error: "",
15639
+ validationErrors: {},
15640
15640
  },
15641
15641
  callbacks: {
15642
15642
  handleEmailSubmit: () => console.log("Submit!"),
@@ -15656,7 +15656,7 @@ const defaultProps$q = {
15656
15656
  const errorProps$a = {
15657
15657
  ...defaultProps$q,
15658
15658
  states: {
15659
- error: "Something went wrong. Please try again.",
15659
+ validationErrors: { error: "Something went wrong. Please try again." },
15660
15660
  },
15661
15661
  };
15662
15662
  const Default$o = () => {
@@ -0,0 +1 @@
1
+ var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var t,s=1,a=arguments.length;s<a;s++){t=arguments[s];for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r))e[r]=t[r]}return e};return __assign.apply(this,arguments)};import{h}from"./index-91e7729f.js";import{c as createStyleSheet}from"./JSS-67b5cff8.js";import{A as AuthWrapper,a as AuthColumn,H as HostBlock,b as AuthButtonsContainer,E as ErrorStyles}from"./mixins-83f90fa1.js";import{T as TextSpanView}from"./sqm-text-span-view-ca32495e.js";var style={Wrapper:AuthWrapper,Column:AuthColumn,HostBlock:HostBlock,":host":{margin:"0 auto",width:"100%"},ButtonsContainer:__assign(__assign({},AuthButtonsContainer),{gap:"var(--sl-spacing-medium)","& > *":{margin:"0 !important"}}),ErrorStyle:ErrorStyles};var vanillaStyle="\nsqm-portal-register {\n margin: 0 auto;\n width: 100%;\n display: block;\n}\n\n:host{\n display: block;\n}\n\n:host([hidden]) {\n display: none;\n}\n";var sheet=createStyleSheet(style);var styleString=sheet.toString();function BaseRegistrationFormView(e){var t,s;var a=e.states,r=e.content,i=e.callbacks;return h("div",{class:sheet.classes.Wrapper},h("style",{type:"text/css"},vanillaStyle,styleString),h(TextSpanView,{type:"h3"},r.pageLabel),h("sl-form",{class:sheet.classes.Column,"onSl-submit":i.handleEmailSubmit,novalidate:true},r.formData,h("sl-input",Object.assign({exportparts:"label: input-label, base: input-base",type:"email",name:"/email",label:r.emailLabel||"Email",required:true,validationError:function(e){var t=e.value;if(!t){return r.requiredFieldErrorMessage}if(!t.includes("@")){return r.invalidEmailErrorMessage}}},((t=a===null||a===void 0?void 0:a.validationErrors)===null||t===void 0?void 0:t.email)?{class:sheet.classes.ErrorStyle,helpText:((s=a===null||a===void 0?void 0:a.validationErrors)===null||s===void 0?void 0:s.email)||r.requiredFieldErrorMessage}:[])),r.terms,h("div",{class:sheet.classes.ButtonsContainer},h("sl-button",{submit:true,exportparts:"base: primarybutton-base",type:"primary",style:{margin:"0"}},r.submitLabel||"Register"),h("sl-menu-divider",{style:{margin:"0"}}),r.googleButton,r.secondaryButton)))}export{BaseRegistrationFormView as B};