@saasquatch/mint-components 1.14.6-9 → 1.14.7-0

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 (96) hide show
  1. package/dist/cjs/{ShadowViewAddon-d1dda2b0.js → ShadowViewAddon-3c344355.js} +116 -49
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/mint-components.cjs.js +1 -1
  4. package/dist/cjs/{sqm-big-stat_42.cjs.entry.js → sqm-big-stat_43.cjs.entry.js} +117 -24
  5. package/dist/cjs/sqm-lead-checkbox-field.cjs.entry.js +155 -0
  6. package/dist/cjs/{sqm-lead-input-field-view-6344cd93.js → sqm-lead-input-field-view-89308aab.js} +7 -7
  7. package/dist/cjs/sqm-lead-input-field.cjs.entry.js +6 -2
  8. package/dist/cjs/sqm-stencilbook.cjs.entry.js +17 -10
  9. package/dist/collection/collection-manifest.json +2 -1
  10. package/dist/collection/components/sqm-dropdown-field/sqm-dropdown-field-view.js +1 -1
  11. package/dist/collection/components/sqm-lead-form/LeadCheckboxField.stories.js +103 -0
  12. package/dist/collection/components/sqm-lead-form/LeadForm.stories.js +5 -2
  13. package/dist/collection/components/sqm-lead-form/LeadFormDropdownField.stories.js +3 -0
  14. package/dist/collection/components/sqm-lead-form/LeadInputField.stories.js +1 -0
  15. package/dist/collection/components/sqm-lead-form/sqm-lead-checkbox-field-view.js +62 -0
  16. package/dist/collection/components/sqm-lead-form/sqm-lead-checkbox-field.js +238 -0
  17. package/dist/collection/components/sqm-lead-form/sqm-lead-dropdown-field-view.js +10 -10
  18. package/dist/collection/components/sqm-lead-form/sqm-lead-dropdown-field.js +57 -5
  19. package/dist/collection/components/sqm-lead-form/sqm-lead-form-view.js +55 -51
  20. package/dist/collection/components/sqm-lead-form/sqm-lead-form.js +65 -35
  21. package/dist/collection/components/sqm-lead-form/sqm-lead-input-field-view.js +7 -7
  22. package/dist/collection/components/sqm-lead-form/sqm-lead-input-field.js +28 -5
  23. package/dist/collection/components/sqm-lead-form/useCheckboxField.js +23 -0
  24. package/dist/collection/components/sqm-lead-form/useLeadForm.js +15 -10
  25. package/dist/esm/{ShadowViewAddon-81771102.js → ShadowViewAddon-64194d20.js} +117 -51
  26. package/dist/esm/loader.js +1 -1
  27. package/dist/esm/mint-components.js +1 -1
  28. package/dist/esm/{sqm-big-stat_42.entry.js → sqm-big-stat_43.entry.js} +118 -26
  29. package/dist/esm/sqm-lead-checkbox-field.entry.js +151 -0
  30. package/dist/esm/{sqm-lead-input-field-view-f1dd4b77.js → sqm-lead-input-field-view-4ede5d7f.js} +7 -7
  31. package/dist/esm/sqm-lead-input-field.entry.js +6 -2
  32. package/dist/esm/sqm-stencilbook.entry.js +12 -5
  33. package/dist/esm-es5/ShadowViewAddon-64194d20.js +1 -0
  34. package/dist/esm-es5/loader.js +1 -1
  35. package/dist/esm-es5/mint-components.js +1 -1
  36. package/dist/esm-es5/sqm-big-stat_43.entry.js +1 -0
  37. package/dist/esm-es5/sqm-lead-checkbox-field.entry.js +1 -0
  38. package/dist/esm-es5/sqm-lead-input-field-view-4ede5d7f.js +1 -0
  39. package/dist/esm-es5/sqm-lead-input-field.entry.js +1 -1
  40. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  41. package/dist/mint-components/mint-components.esm.js +1 -1
  42. package/dist/mint-components/p-01dd541f.system.js +1 -0
  43. package/dist/mint-components/p-0d94d81a.system.js +1 -0
  44. package/dist/mint-components/p-10a8ecae.system.entry.js +1 -0
  45. package/dist/mint-components/p-12bba567.entry.js +1 -0
  46. package/dist/mint-components/p-214c7807.entry.js +1 -0
  47. package/dist/mint-components/{p-460974bf.js → p-30a11ec0.js} +24 -24
  48. package/dist/mint-components/p-37996351.system.js +1 -1
  49. package/dist/mint-components/p-589962db.system.entry.js +1 -0
  50. package/dist/mint-components/p-6ba44ca9.js +1 -0
  51. package/dist/mint-components/{p-b2ff8561.entry.js → p-851eaf57.entry.js} +21 -21
  52. package/dist/mint-components/p-8c0b7881.system.entry.js +1 -0
  53. package/dist/mint-components/p-eaf1a8a6.system.entry.js +1 -0
  54. package/dist/mint-components/{p-ba585a4b.entry.js → p-f60d1ae9.entry.js} +2 -2
  55. package/dist/types/components/sqm-lead-form/LeadCheckboxField.stories.d.ts +55 -0
  56. package/dist/types/components/sqm-lead-form/LeadFormDropdownField.stories.d.ts +1 -0
  57. package/dist/types/components/sqm-lead-form/sqm-lead-checkbox-field-view.d.ts +19 -0
  58. package/dist/types/components/sqm-lead-form/sqm-lead-checkbox-field.d.ts +46 -0
  59. package/dist/types/components/sqm-lead-form/sqm-lead-dropdown-field-view.d.ts +3 -1
  60. package/dist/types/components/sqm-lead-form/sqm-lead-dropdown-field.d.ts +11 -4
  61. package/dist/types/components/sqm-lead-form/sqm-lead-form-view.d.ts +2 -1
  62. package/dist/types/components/sqm-lead-form/sqm-lead-form.d.ts +19 -10
  63. package/dist/types/components/sqm-lead-form/sqm-lead-input-field-view.d.ts +1 -0
  64. package/dist/types/components/sqm-lead-form/sqm-lead-input-field.d.ts +4 -2
  65. package/dist/types/components/sqm-lead-form/useCheckboxField.d.ts +11 -0
  66. package/dist/types/components/sqm-lead-form/useLeadForm.d.ts +1 -0
  67. package/dist/types/components/sqm-referral-iframe/useReferralIframe.d.ts +1 -1
  68. package/dist/types/components.d.ts +143 -19
  69. package/docs/docs.docx +0 -0
  70. package/docs/raisins.json +1 -1
  71. package/grapesjs/grapesjs.js +1 -1
  72. package/package.json +1 -1
  73. package/dist/cjs/sqm-lead-dropdown-field-view-03a3e03f.js +0 -69
  74. package/dist/cjs/sqm-lead-dropdown-field.cjs.entry.js +0 -81
  75. package/dist/esm/sqm-lead-dropdown-field-view-4c85fe20.js +0 -67
  76. package/dist/esm/sqm-lead-dropdown-field.entry.js +0 -77
  77. package/dist/esm-es5/ShadowViewAddon-81771102.js +0 -1
  78. package/dist/esm-es5/sqm-big-stat_42.entry.js +0 -1
  79. package/dist/esm-es5/sqm-lead-dropdown-field-view-4c85fe20.js +0 -1
  80. package/dist/esm-es5/sqm-lead-dropdown-field.entry.js +0 -1
  81. package/dist/esm-es5/sqm-lead-input-field-view-f1dd4b77.js +0 -1
  82. package/dist/mint-components/p-15f1ff1d.system.js +0 -1
  83. package/dist/mint-components/p-26da31c6.js +0 -1
  84. package/dist/mint-components/p-4056c0ea.system.entry.js +0 -1
  85. package/dist/mint-components/p-4d5b02af.js +0 -1
  86. package/dist/mint-components/p-59970cb1.system.entry.js +0 -1
  87. package/dist/mint-components/p-6b093d8c.entry.js +0 -1
  88. package/dist/mint-components/p-7094012d.system.entry.js +0 -1
  89. package/dist/mint-components/p-87384d9e.system.js +0 -1
  90. package/dist/mint-components/p-ad128614.system.js +0 -1
  91. package/dist/mint-components/p-c5a55554.entry.js +0 -1
  92. package/dist/mint-components/p-de5356d9.system.entry.js +0 -1
  93. package/dist/types/global/android.d.ts +0 -7
  94. package/dist/types/global/demo.d.ts +0 -2
  95. package/dist/types/stories/features.d.ts +0 -4
  96. package/dist/types/stories/templates.d.ts +0 -4
@@ -1,10 +1,15 @@
1
- import { h } from "@stencil/core";
1
+ import { Fragment, h } from "@stencil/core";
2
+ import { intl } from "../../global/global";
2
3
  import { AuthButtonsContainer, AuthColumn, AuthWrapper, ErrorStyles, HostBlock, } from "../../global/mixins";
3
4
  import { createStyleSheet } from "../../styling/JSS";
4
5
  import { TextSpanView } from "../sqm-text-span/sqm-text-span-view";
5
- import { intl } from "../../global/global";
6
6
  const style = {
7
- Wrapper: { ...AuthWrapper, "max-width": "600px" },
7
+ Wrapper: {
8
+ ...AuthWrapper,
9
+ "max-width": "600px",
10
+ border: "none",
11
+ margin: "0",
12
+ },
8
13
  Column: AuthColumn,
9
14
  HostBlock: HostBlock,
10
15
  ":host": {
@@ -14,6 +19,7 @@ const style = {
14
19
  NameFieldWrapper: {
15
20
  display: "flex",
16
21
  gap: "var(--sl-spacing-medium)",
22
+ marginBottom: "0 !important",
17
23
  },
18
24
  ContinueButton: { maxWidth: "169px" },
19
25
  ButtonsContainer: AuthButtonsContainer,
@@ -29,6 +35,10 @@ const style = {
29
35
  borderTop: "none",
30
36
  },
31
37
  },
38
+ NameInput: {
39
+ marginBottom: "0",
40
+ width: "50%",
41
+ },
32
42
  ErrorStyle: ErrorStyles,
33
43
  };
34
44
  const vanillaStyle = `
@@ -51,7 +61,6 @@ const styleString = sheet.toString();
51
61
  export function LeadFormView(props) {
52
62
  var _a, _b, _c, _d;
53
63
  const { states, refs, callbacks, content } = props;
54
- console.log({ states });
55
64
  if (states.error) {
56
65
  window.scrollTo({ top: 0, left: 0, behavior: "smooth" });
57
66
  }
@@ -61,8 +70,8 @@ export function LeadFormView(props) {
61
70
  }, {
62
71
  fieldLabel,
63
72
  });
64
- if (states.success) {
65
- return (h("div", { class: sheet.classes.Wrapper, part: "sqm-base" },
73
+ return (h(Fragment, null,
74
+ states.success && (h("div", { class: sheet.classes.Wrapper, part: "sqm-base" },
66
75
  h("style", { type: "text/css" },
67
76
  vanillaStyle,
68
77
  styleString),
@@ -71,49 +80,44 @@ export function LeadFormView(props) {
71
80
  h("b", null, content.submitSuccessHeader),
72
81
  h("br", null),
73
82
  h("div", { part: "successalert-text" }, content.submitSuccessDescription)),
74
- h("sl-button", {
75
- // AL: TODO add button to allow user to submit another form
76
- class: sheet.classes.ContinueButton,
77
- // onClick={callbacks.submitAnotherForm}
78
- loading: states.loading, exportparts: "base: primarybutton-base", type: "default" }, content.resubmitFormLabel)));
79
- }
80
- return (h("div", { class: sheet.classes.Wrapper, part: "sqm-base" },
81
- h("style", { type: "text/css" },
82
- vanillaStyle,
83
- styleString),
84
- h(TextSpanView, { type: "h3" }, content.pageLabel),
85
- h("sl-form", { class: sheet.classes.Column, "onSl-submit": callbacks.submit, ref: (el) => (refs.formRef.current = el), novalidate: true },
86
- states.error && (h("sl-alert", { exportparts: "base: alert-base, icon:alert-icon", type: "danger", class: sheet.classes.ErrorAlertContainer, open: true },
87
- h("sl-icon", { slot: "icon", name: "exclamation-octagon" }),
88
- h("b", null, content.submitErrorHeader),
89
- h("br", null),
90
- intl.formatMessage({
91
- id: "submitErrorDescription",
92
- defaultMessage: content.submitErrorDescription,
93
- }, {
94
- supportLink: (h("a", { target: "_blank", href: `mailto:advocate-support@impact.com` }, content.supportLink)),
95
- }))),
96
- h("div", { class: sheet.classes.NameFieldWrapper },
97
- h("sqm-lead-input-field", { style: { width: "50%" }, "field-label": "First Name", "field-name": "firstName" }),
98
- h("sqm-lead-input-field", { style: { width: "50%" }, "field-label": "Last Name", "field-name": "lastName" })),
99
- h("sl-input", Object.assign({ exportparts: "label: input-label, base: input-base", type: "email", name: "/email", label: content.emailLabel || "Email", disabled: states.loading, required: true, validationError: ({ value }) => {
100
- if (!value) {
101
- return getRequiredFieldErrorMessage({
102
- fieldLabel: content.emailLabel || "Email",
103
- });
104
- }
105
- // this matches shoelace validation, but could be better
106
- if (!value.includes("@")) {
107
- return content.invalidEmailErrorMessage;
108
- }
109
- } }, (((_b = (_a = states.leadFormState) === null || _a === void 0 ? void 0 : _a.validationErrors) === null || _b === void 0 ? void 0 : _b.email) ? {
110
- class: sheet.classes.ErrorStyle,
111
- helpText: ((_d = (_c = states.leadFormState) === null || _c === void 0 ? void 0 : _c.validationErrors) === null || _d === void 0 ? void 0 : _d.email) ||
112
- content.requiredFieldErrorMessage,
113
- }
114
- : []))),
115
- h("input", { type: "hidden", hidden: true, name: "/rsReferralCode", value: states.referralCode }),
116
- content.formData,
117
- h("div", { class: sheet.classes.ButtonsContainer },
118
- h("sl-button", { submit: true, loading: states.loading, exportparts: "base: primarybutton-base", type: "primary" }, content.submitLabel || "Register")))));
83
+ h("sl-button", { class: sheet.classes.ContinueButton, onClick: callbacks.resetForm, loading: states.loading, exportparts: "base: primarybutton-base", type: "default" }, content.resubmitFormLabel))),
84
+ h("div", { class: sheet.classes.Wrapper, part: "sqm-base", style: { display: states.success ? "none" : "block" } },
85
+ h("style", { type: "text/css" },
86
+ vanillaStyle,
87
+ styleString),
88
+ h(TextSpanView, { type: "h3" }, content.pageLabel),
89
+ h("sl-form", { class: sheet.classes.Column, "onSl-submit": callbacks.submit, ref: (el) => (refs.formRef.current = el), novalidate: true },
90
+ states.error && (h("sl-alert", { exportparts: "base: alert-base, icon:alert-icon", type: "danger", class: sheet.classes.ErrorAlertContainer, open: true },
91
+ h("sl-icon", { slot: "icon", name: "exclamation-octagon" }),
92
+ h("b", null, content.submitErrorHeader),
93
+ h("br", null),
94
+ intl.formatMessage({
95
+ id: "submitErrorDescription",
96
+ defaultMessage: content.submitErrorDescription,
97
+ }, {
98
+ supportLink: (h("a", { target: "_blank", href: `mailto:advocate-support@impact.com` }, content.supportLinkText)),
99
+ }))),
100
+ h("div", { class: sheet.classes.NameFieldWrapper },
101
+ h("sqm-lead-input-field", { class: sheet.classes.NameInput, "field-label": content.firstNameLabel || "First Name", "field-name": "firstName" }),
102
+ h("sqm-lead-input-field", { class: sheet.classes.NameInput, "field-label": content.lastNameLabel || "Last Name", "field-name": "lastName" })),
103
+ h("sl-input", Object.assign({ exportparts: "label: input-label, base: input-base", type: "email", name: "/email", label: content.emailLabel || "Email", disabled: states.loading, required: true, validationError: ({ value }) => {
104
+ if (!value) {
105
+ return getRequiredFieldErrorMessage({
106
+ fieldLabel: content.emailLabel || "Email",
107
+ });
108
+ }
109
+ // this matches shoelace validation, but could be better
110
+ if (!value.includes("@")) {
111
+ return content.invalidEmailErrorMessage;
112
+ }
113
+ } }, (((_b = (_a = states.leadFormState) === null || _a === void 0 ? void 0 : _a.validationErrors) === null || _b === void 0 ? void 0 : _b.email) ? {
114
+ class: sheet.classes.ErrorStyle,
115
+ helpText: ((_d = (_c = states.leadFormState) === null || _c === void 0 ? void 0 : _c.validationErrors) === null || _d === void 0 ? void 0 : _d.email) ||
116
+ content.requiredFieldErrorMessage,
117
+ }
118
+ : []))),
119
+ h("input", { type: "hidden", hidden: true, name: "/referralCode", value: states.referralCode }),
120
+ content.formData,
121
+ h("div", { class: sheet.classes.ButtonsContainer },
122
+ h("sl-button", { submit: true, loading: states.loading, exportparts: "base: primarybutton-base", type: "primary" }, content.submitLabel || "Register"))))));
119
123
  }
@@ -6,7 +6,7 @@ import { LeadFormView } from "./sqm-lead-form-view";
6
6
  import { useLeadForm } from "./useLeadForm";
7
7
  /**
8
8
  * @uiName Lead Form
9
- * @slots [{"name":"formData","title":"Additional Fields"},{"name":"terms","title":"Terms And Conditions Fields"}]
9
+ * @slots [{"name":"formData","title":"Additional Fields"}]
10
10
  */
11
11
  export class LeadForm {
12
12
  constructor() {
@@ -18,11 +18,11 @@ export class LeadForm {
18
18
  /**
19
19
  * @uiName First Name field label
20
20
  */
21
- this.firstNameLabel = "First Name";
21
+ this.firstNameLabel = "First name";
22
22
  /**
23
23
  * @uiName Last Name field label
24
24
  */
25
- this.lastNameLabel = "Last Name";
25
+ this.lastNameLabel = "Last name";
26
26
  /**
27
27
  * @uiName Submit button text
28
28
  */
@@ -35,43 +35,52 @@ export class LeadForm {
35
35
  * @uiName Header text
36
36
  */
37
37
  this.pageLabel = "Refer your friend";
38
+ /**
39
+ * Key of the form to connect to. Create and manage forms in the /advocate dashboard under Data > Forms.
40
+ * @uiName Form key
41
+ */
38
42
  this.formKey = "lead-form";
39
43
  /**
40
- * Optional support link for error messages.
44
+ * Optional support link text for error messages.
45
+ * @uiName Support link text
41
46
  */
42
- this.supportLink = "Support";
47
+ this.supportLinkText = "Support";
43
48
  /**
44
- * Header text shown on successful submission.
49
+ * Header text shown on successful lead submission.
50
+ * @uiName Submit success header
45
51
  */
46
- this.submitSuccessHeader = "Referral submitted";
52
+ this.submitSuccessHeader = "Lead submitted";
47
53
  /**
48
- * Description text shown on successful submission.
54
+ * Description text shown on successful lead submission.
55
+ * @uiName Submit success description
49
56
  */
50
57
  this.submitSuccessDescription = "Our team will contact your friend to see if they’re a good fit. In the meantime, you can track this referral on Activity page.";
51
58
  /**
52
- * Header text shown when an error occurs.
59
+ * Header text shown if an error occurs.
60
+ * @uiName Submit error header
53
61
  */
54
62
  this.submitErrorHeader = "An error occurred while submitting";
55
63
  /**
56
- * Description text shown when an error occurs.
64
+ * Description text shown if an error occurs.
65
+ * @uiName Submit error description
57
66
  */
58
67
  this.submitErrorDescription = "Please try again later. If the problem continues, contact {supportLink}";
59
68
  /**
60
- * The message to be displayed when a required field is not filled.
69
+ * The message to be displayed if a required field is not filled.
61
70
  *
62
71
  * @uiName Required field message
63
72
  * @uiWidget textArea
64
73
  */
65
74
  this.requiredFieldErrorMessage = "Please enter a valid {fieldLabel}";
66
75
  /**
67
- * The message to be displayed when a the form submission fails unexpectedly.
76
+ * The message to be displayed if a the form submission fails unexpectedly.
68
77
  *
69
78
  * @uiName Network error message
70
79
  * @uiWidget textArea
71
80
  */
72
81
  this.networkErrorMessage = "Network request failed.";
73
82
  /**
74
- * The message to be displayed when the email used is invalid or blocked.
83
+ * The message to be displayed if the email used is invalid.
75
84
  *
76
85
  * @uiName Invalid email message
77
86
  * @uiWidget textArea
@@ -90,13 +99,15 @@ export class LeadForm {
90
99
  submitLabel: this.submitLabel,
91
100
  resubmitFormLabel: this.resubmitFormLabel,
92
101
  pageLabel: this.pageLabel,
93
- supportLink: this.supportLink,
102
+ supportLinkText: this.supportLinkText,
94
103
  submitSuccessHeader: this.submitSuccessHeader,
95
104
  submitSuccessDescription: this.submitSuccessDescription,
96
105
  submitErrorHeader: this.submitErrorHeader,
97
106
  submitErrorDescription: this.submitErrorDescription,
98
107
  invalidEmailErrorMessage: this.invalidEmailErrorMessage,
99
108
  requiredFieldErrorMessage: this.requiredFieldErrorMessage,
109
+ firstNameLabel: this.firstNameLabel,
110
+ lastNameLabel: this.lastNameLabel,
100
111
  };
101
112
  return (h(LeadFormView, { states: states, callbacks: callbacks, content: content, refs: refs }));
102
113
  }
@@ -143,7 +154,7 @@ export class LeadForm {
143
154
  },
144
155
  "attribute": "first-name-label",
145
156
  "reflect": false,
146
- "defaultValue": "\"First Name\""
157
+ "defaultValue": "\"First name\""
147
158
  },
148
159
  "lastNameLabel": {
149
160
  "type": "string",
@@ -164,7 +175,7 @@ export class LeadForm {
164
175
  },
165
176
  "attribute": "last-name-label",
166
177
  "reflect": false,
167
- "defaultValue": "\"Last Name\""
178
+ "defaultValue": "\"Last name\""
168
179
  },
169
180
  "submitLabel": {
170
181
  "type": "string",
@@ -240,14 +251,17 @@ export class LeadForm {
240
251
  "required": false,
241
252
  "optional": false,
242
253
  "docs": {
243
- "tags": [],
244
- "text": ""
254
+ "tags": [{
255
+ "text": "Form key",
256
+ "name": "uiName"
257
+ }],
258
+ "text": "Key of the form to connect to. Create and manage forms in the /advocate dashboard under Data > Forms."
245
259
  },
246
260
  "attribute": "form-key",
247
261
  "reflect": false,
248
262
  "defaultValue": "\"lead-form\""
249
263
  },
250
- "supportLink": {
264
+ "supportLinkText": {
251
265
  "type": "string",
252
266
  "mutable": false,
253
267
  "complexType": {
@@ -258,10 +272,13 @@ export class LeadForm {
258
272
  "required": false,
259
273
  "optional": false,
260
274
  "docs": {
261
- "tags": [],
262
- "text": "Optional support link for error messages."
275
+ "tags": [{
276
+ "text": "Support link text",
277
+ "name": "uiName"
278
+ }],
279
+ "text": "Optional support link text for error messages."
263
280
  },
264
- "attribute": "support-link",
281
+ "attribute": "support-link-text",
265
282
  "reflect": false,
266
283
  "defaultValue": "\"Support\""
267
284
  },
@@ -276,12 +293,15 @@ export class LeadForm {
276
293
  "required": false,
277
294
  "optional": false,
278
295
  "docs": {
279
- "tags": [],
280
- "text": "Header text shown on successful submission."
296
+ "tags": [{
297
+ "text": "Submit success header",
298
+ "name": "uiName"
299
+ }],
300
+ "text": "Header text shown on successful lead submission."
281
301
  },
282
302
  "attribute": "submit-success-header",
283
303
  "reflect": false,
284
- "defaultValue": "\"Referral submitted\""
304
+ "defaultValue": "\"Lead submitted\""
285
305
  },
286
306
  "submitSuccessDescription": {
287
307
  "type": "string",
@@ -294,8 +314,11 @@ export class LeadForm {
294
314
  "required": false,
295
315
  "optional": false,
296
316
  "docs": {
297
- "tags": [],
298
- "text": "Description text shown on successful submission."
317
+ "tags": [{
318
+ "text": "Submit success description",
319
+ "name": "uiName"
320
+ }],
321
+ "text": "Description text shown on successful lead submission."
299
322
  },
300
323
  "attribute": "submit-success-description",
301
324
  "reflect": false,
@@ -312,8 +335,11 @@ export class LeadForm {
312
335
  "required": false,
313
336
  "optional": false,
314
337
  "docs": {
315
- "tags": [],
316
- "text": "Header text shown when an error occurs."
338
+ "tags": [{
339
+ "text": "Submit error header",
340
+ "name": "uiName"
341
+ }],
342
+ "text": "Header text shown if an error occurs."
317
343
  },
318
344
  "attribute": "submit-error-header",
319
345
  "reflect": false,
@@ -330,8 +356,11 @@ export class LeadForm {
330
356
  "required": false,
331
357
  "optional": false,
332
358
  "docs": {
333
- "tags": [],
334
- "text": "Description text shown when an error occurs."
359
+ "tags": [{
360
+ "text": "Submit error description",
361
+ "name": "uiName"
362
+ }],
363
+ "text": "Description text shown if an error occurs."
335
364
  },
336
365
  "attribute": "submit-error-description",
337
366
  "reflect": false,
@@ -355,7 +384,7 @@ export class LeadForm {
355
384
  "text": "textArea",
356
385
  "name": "uiWidget"
357
386
  }],
358
- "text": "The message to be displayed when a required field is not filled."
387
+ "text": "The message to be displayed if a required field is not filled."
359
388
  },
360
389
  "attribute": "required-field-error-message",
361
390
  "reflect": false,
@@ -379,7 +408,7 @@ export class LeadForm {
379
408
  "text": "textArea",
380
409
  "name": "uiWidget"
381
410
  }],
382
- "text": "The message to be displayed when a the form submission fails unexpectedly."
411
+ "text": "The message to be displayed if a the form submission fails unexpectedly."
383
412
  },
384
413
  "attribute": "network-error-message",
385
414
  "reflect": false,
@@ -403,7 +432,7 @@ export class LeadForm {
403
432
  "text": "textArea",
404
433
  "name": "uiWidget"
405
434
  }],
406
- "text": "The message to be displayed when the email used is invalid or blocked."
435
+ "text": "The message to be displayed if the email used is invalid."
407
436
  },
408
437
  "attribute": "invalid-email-error-message",
409
438
  "reflect": false,
@@ -414,7 +443,7 @@ export class LeadForm {
414
443
  "mutable": false,
415
444
  "complexType": {
416
445
  "original": "DemoData<LeadFormViewProps>",
417
- "resolved": "{ states?: { error: string; success: boolean; loading: boolean; leadFormState: LeadFormState; referralCode: string; }; refs?: { formRef: any; }; content?: { formData?: VNode; emailLabel?: string; firstNameLabel?: string; lastNameLabel?: string; submitLabel?: string; resubmitFormLabel?: string; pageLabel?: string; supportLink?: string; submitSuccessHeader?: string; submitSuccessDescription?: string; submitErrorHeader?: string; submitErrorDescription?: string; requiredFieldErrorMessage: string; invalidEmailErrorMessage: string; }; }",
446
+ "resolved": "{ states?: { error: string; success: boolean; loading: boolean; leadFormState: LeadFormState; referralCode: string; }; refs?: { formRef: any; }; content?: { formData?: VNode; emailLabel?: string; firstNameLabel?: string; lastNameLabel?: string; submitLabel?: string; resubmitFormLabel?: string; pageLabel?: string; supportLinkText?: string; submitSuccessHeader?: string; submitSuccessDescription?: string; submitErrorHeader?: string; submitErrorDescription?: string; requiredFieldErrorMessage: string; invalidEmailErrorMessage: string; }; }",
418
447
  "references": {
419
448
  "DemoData": {
420
449
  "location": "import",
@@ -456,6 +485,7 @@ function useRegisterDemo(props) {
456
485
  console.log("submit");
457
486
  },
458
487
  inputFunction: () => { },
488
+ resetForm: () => { },
459
489
  },
460
490
  refs: {
461
491
  formRef: {},
@@ -6,7 +6,7 @@ import { ErrorStyles } from "../../global/mixins";
6
6
  const style = {
7
7
  ErrorStyle: ErrorStyles,
8
8
  FieldContainer: {
9
- "margin-bottom": "var(--sl-spacing-large)",
9
+ "margin-bottom": "var(--sl-spacing-medium)",
10
10
  },
11
11
  };
12
12
  const vanillaStyle = `
@@ -23,24 +23,24 @@ export function LeadInputFieldView(props) {
23
23
  var _a, _b, _c, _d, _e, _f;
24
24
  const { states, content } = props;
25
25
  const getRequiredFieldErrorMessage = ({ fieldLabel, }) => intl.formatMessage({
26
- id: "requiredFieldErrorMessage",
26
+ id: `requiredFieldErrorMessage-${fieldLabel}`,
27
27
  defaultMessage: content.requiredFieldErrorMessage,
28
28
  }, {
29
29
  fieldLabel,
30
30
  });
31
- return (h("div", { part: "sqm-base" },
31
+ return (h("div", { class: sheet.classes.FieldContainer, part: "sqm-base" },
32
32
  h("style", { type: "text/css" },
33
33
  vanillaStyle,
34
34
  styleString),
35
- h("sl-input", Object.assign({ exportparts: "label: input-label, base: input-base", name: `/${content.fieldName}`, type: content.fieldType, label: content.fieldLabel }, (!content.fieldOptional ? { required: true } : []), { disabled: ((_a = states.leadFormState) === null || _a === void 0 ? void 0 : _a.loading) || ((_b = states.leadFormState) === null || _b === void 0 ? void 0 : _b.disabled), validationError: ({ value }) => {
36
- if (!value) {
35
+ h("sl-input", Object.assign({ exportparts: "label: input-label, base: input-base", name: `/${content.fieldName}`, type: content.fieldType, label: `${content.fieldLabel}${content.fieldOptional ? ` ${content.optionalLabel}` : ""}` }, (!content.fieldOptional ? { required: true } : []), { disabled: ((_a = states.leadFormState) === null || _a === void 0 ? void 0 : _a.loading) || ((_b = states.leadFormState) === null || _b === void 0 ? void 0 : _b.disabled), validationError: ({ value }) => {
36
+ if (!value && !content.fieldOptional) {
37
37
  return getRequiredFieldErrorMessage({
38
38
  fieldLabel: content.fieldLabel,
39
39
  });
40
40
  }
41
- } }, (((_d = (_c = states.leadFormState) === null || _c === void 0 ? void 0 : _c.validationErrors) === null || _d === void 0 ? void 0 : _d.firstName) ? {
41
+ } }, (((_d = (_c = states.leadFormState) === null || _c === void 0 ? void 0 : _c.validationErrors) === null || _d === void 0 ? void 0 : _d[content.fieldName]) ? {
42
42
  class: sheet.classes.ErrorStyle,
43
- helpText: ((_f = (_e = states.leadFormState) === null || _e === void 0 ? void 0 : _e.validationErrors) === null || _f === void 0 ? void 0 : _f.firstName) ||
43
+ helpText: ((_f = (_e = states.leadFormState) === null || _e === void 0 ? void 0 : _e.validationErrors) === null || _f === void 0 ? void 0 : _f[content.fieldName]) ||
44
44
  content.requiredFieldErrorMessage,
45
45
  }
46
46
  : [])))));
@@ -9,12 +9,14 @@ import { useLeadInputField } from "./useLeadInputField";
9
9
  /**
10
10
  * @uiName Lead Form Input Field
11
11
  * @validParents ["sqm-lead-form"]
12
- * @exampleGroup Microsite Components
13
- * @example Lead Form Input Field - <sqm-input-field input-label="Field Label" field-type="text" error-message="Cannot be empty"></sqm-input-field>
14
12
  */
15
13
  export class LeadInputField {
16
14
  constructor() {
17
15
  this.ignored = true;
16
+ /**
17
+ * @uiName Optional label
18
+ */
19
+ this.optionalLabel = "(optional)";
18
20
  /**
19
21
  * @uiName Input type
20
22
  * @uiType string
@@ -28,7 +30,7 @@ export class LeadInputField {
28
30
  * @uiName Required field message
29
31
  * @uiWidget textArea
30
32
  */
31
- this.requiredFieldErrorMessage = "Please enter a {fieldName}";
33
+ this.requiredFieldErrorMessage = "Please enter a {fieldLabel}";
32
34
  /**
33
35
  * @uiName Optional
34
36
  * @default
@@ -100,6 +102,27 @@ export class LeadInputField {
100
102
  "attribute": "field-label",
101
103
  "reflect": false
102
104
  },
105
+ "optionalLabel": {
106
+ "type": "string",
107
+ "mutable": false,
108
+ "complexType": {
109
+ "original": "string",
110
+ "resolved": "string",
111
+ "references": {}
112
+ },
113
+ "required": false,
114
+ "optional": false,
115
+ "docs": {
116
+ "tags": [{
117
+ "text": "Optional label",
118
+ "name": "uiName"
119
+ }],
120
+ "text": ""
121
+ },
122
+ "attribute": "optional-label",
123
+ "reflect": false,
124
+ "defaultValue": "\"(optional)\""
125
+ },
103
126
  "fieldType": {
104
127
  "type": "string",
105
128
  "mutable": false,
@@ -152,7 +175,7 @@ export class LeadInputField {
152
175
  },
153
176
  "attribute": "required-field-error-message",
154
177
  "reflect": false,
155
- "defaultValue": "\"Please enter a {fieldName}\""
178
+ "defaultValue": "\"Please enter a {fieldLabel}\""
156
179
  },
157
180
  "fieldOptional": {
158
181
  "type": "boolean",
@@ -183,7 +206,7 @@ export class LeadInputField {
183
206
  "mutable": false,
184
207
  "complexType": {
185
208
  "original": "DemoData<LeadInputFieldViewProps>",
186
- "resolved": "{ states?: { leadFormState?: LeadFormState; }; content?: { fieldName: string; fieldLabel: string; fieldType: \"text\" | \"date\" | \"tel\"; fieldOptional?: boolean; requiredFieldErrorMessage: string; }; }",
209
+ "resolved": "{ states?: { leadFormState?: LeadFormState; }; content?: { fieldName: string; fieldLabel: string; optionalLabel: string; fieldType: \"text\" | \"date\" | \"tel\"; fieldOptional?: boolean; requiredFieldErrorMessage: string; }; }",
187
210
  "references": {
188
211
  "DemoData": {
189
212
  "location": "import",
@@ -0,0 +1,23 @@
1
+ import { useDomContext } from "@saasquatch/stencil-hooks";
2
+ import { useEffect, useState } from "@saasquatch/universal-hooks";
3
+ import { LEAD_FORM_STATE_CONTEXT } from "./useLeadFormState";
4
+ export function useLeadCheckboxField(props) {
5
+ var _a;
6
+ const leadFormState = useDomContext(LEAD_FORM_STATE_CONTEXT);
7
+ const [checked, setChecked] = useState(false);
8
+ useEffect(() => {
9
+ var _a, _b;
10
+ if ((_a = leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.initialData) === null || _a === void 0 ? void 0 : _a[props.checkboxName]) {
11
+ setChecked(!!((_b = leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.initialData) === null || _b === void 0 ? void 0 : _b[props.checkboxName]));
12
+ }
13
+ }, [(_a = leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.initialData) === null || _a === void 0 ? void 0 : _a[props.checkboxName]]);
14
+ return {
15
+ states: {
16
+ leadFormState,
17
+ checked,
18
+ },
19
+ callbacks: {
20
+ setChecked,
21
+ },
22
+ };
23
+ }
@@ -27,7 +27,6 @@ export function useLeadForm(props) {
27
27
  const programId = useProgramId();
28
28
  const user = useUserIdentity();
29
29
  const { data: userDetails } = useQuery(GET_USER_DETAILS, { programId }, !(user === null || user === void 0 ? void 0 : user.jwt) || !programId);
30
- console.log({ userDetails });
31
30
  const [submitLead, { loading, errors, data }] = useMutation(SUBMIT_LEAD);
32
31
  const [success, setSuccess] = useState(false);
33
32
  useEffect(() => {
@@ -40,7 +39,7 @@ export function useLeadForm(props) {
40
39
  };
41
40
  }, [formRef.current]);
42
41
  const submit = async (event) => {
43
- var _a, _b, _c, _d;
42
+ var _a;
44
43
  let formControls = event.target.getFormControls();
45
44
  let formData = {};
46
45
  let validationErrors = {};
@@ -72,17 +71,12 @@ export function useLeadForm(props) {
72
71
  error: "",
73
72
  validationErrors: {},
74
73
  });
75
- formData = { ...formData };
76
74
  const variables = {
77
75
  key: props.formKey,
78
76
  formData,
79
77
  };
80
78
  try {
81
79
  const result = await submitLead({ formSubmissionInput: variables });
82
- console.log({
83
- success: (_b = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.submitForm) === null || _b === void 0 ? void 0 : _b.success,
84
- isError: result instanceof Error,
85
- });
86
80
  if (result instanceof Error) {
87
81
  throw result;
88
82
  }
@@ -91,12 +85,11 @@ export function useLeadForm(props) {
91
85
  error: "",
92
86
  validationErrors: {},
93
87
  });
94
- if ((_d = (_c = result === null || result === void 0 ? void 0 : result.data) === null || _c === void 0 ? void 0 : _c.submitForm) === null || _d === void 0 ? void 0 : _d.success) {
88
+ if ((_a = result === null || result === void 0 ? void 0 : result.submitForm) === null || _a === void 0 ? void 0 : _a.success) {
95
89
  setSuccess(true);
96
90
  }
97
91
  }
98
92
  catch (error) {
99
- console.log({ error });
100
93
  setLeadFormState({
101
94
  loading: false,
102
95
  error: props.networkErrorMessage,
@@ -112,6 +105,18 @@ export function useLeadForm(props) {
112
105
  const asYouType = new AsYouType("US");
113
106
  e.target.value = asYouType.input(e.target.value);
114
107
  }, []);
108
+ function resetForm() {
109
+ var _a, _b;
110
+ setLeadFormState({
111
+ loading: false,
112
+ error: "",
113
+ validationErrors: {},
114
+ });
115
+ (_b = (_a = formRef.current) === null || _a === void 0 ? void 0 : _a.getFormControls()) === null || _b === void 0 ? void 0 : _b.forEach((c) => {
116
+ c.value = "";
117
+ });
118
+ setSuccess(false);
119
+ }
115
120
  let errorMessage = "";
116
121
  if ((_a = errors === null || errors === void 0 ? void 0 : errors.response) === null || _a === void 0 ? void 0 : _a["error"]) {
117
122
  errorMessage = props.networkErrorMessage;
@@ -123,7 +128,6 @@ export function useLeadForm(props) {
123
128
  errorMessage =
124
129
  ((_f = (_e = (_d = (_c = errors === null || errors === void 0 ? void 0 : errors.response) === null || _c === void 0 ? void 0 : _c.errors) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.extensions) === null || _f === void 0 ? void 0 : _f.message) || ((_j = (_h = (_g = errors === null || errors === void 0 ? void 0 : errors.response) === null || _g === void 0 ? void 0 : _g.errors) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.message) || (leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.error);
125
130
  }
126
- console.log({ errors, errorMessage });
127
131
  return {
128
132
  states: {
129
133
  loading,
@@ -135,6 +139,7 @@ export function useLeadForm(props) {
135
139
  callbacks: {
136
140
  submit,
137
141
  inputFunction,
142
+ resetForm,
138
143
  },
139
144
  refs: {
140
145
  formRef,