@saasquatch/mint-components 1.14.6-2 → 1.14.6-3

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 (86) hide show
  1. package/dist/cjs/{ShadowViewAddon-c0a5fdf8.js → ShadowViewAddon-40f0bc74.js} +58 -26
  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 +84 -116
  5. package/dist/cjs/sqm-lead-dropdown-field-view-03a3e03f.js +69 -0
  6. package/dist/cjs/sqm-lead-dropdown-field.cjs.entry.js +75 -0
  7. package/dist/cjs/sqm-lead-input-field-view-6344cd93.js +51 -0
  8. package/dist/cjs/sqm-lead-input-field.cjs.entry.js +78 -0
  9. package/dist/cjs/sqm-stencilbook.cjs.entry.js +166 -49
  10. package/dist/cjs/useLeadFormState-c83d2034.js +72 -0
  11. package/dist/collection/collection-manifest.json +2 -0
  12. package/dist/collection/components/sqm-lead-form/LeadForm.stories.js +34 -46
  13. package/dist/collection/components/sqm-lead-form/LeadFormDropdownField.stories.js +59 -0
  14. package/dist/collection/components/sqm-lead-form/LeadInputField.stories.js +48 -0
  15. package/dist/collection/components/sqm-lead-form/sqm-lead-dropdown-field-view.js +65 -0
  16. package/dist/collection/components/sqm-lead-form/sqm-lead-dropdown-field.js +193 -0
  17. package/dist/collection/components/sqm-lead-form/sqm-lead-form-view.js +59 -26
  18. package/dist/collection/components/sqm-lead-form/sqm-lead-form.js +147 -36
  19. package/dist/collection/components/sqm-lead-form/sqm-lead-input-field-view.js +47 -0
  20. package/dist/collection/components/sqm-lead-form/sqm-lead-input-field.js +222 -0
  21. package/dist/collection/components/sqm-lead-form/useLeadDropdownField.js +10 -0
  22. package/dist/collection/components/sqm-lead-form/useLeadForm.js +8 -5
  23. package/dist/collection/components/sqm-lead-form/useLeadInputField.js +10 -0
  24. package/dist/collection/components/sqm-stencilbook/sqm-stencilbook.js +4 -0
  25. package/dist/esm/{ShadowViewAddon-aa7177fe.js → ShadowViewAddon-8a0d9e83.js} +58 -26
  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 +81 -113
  29. package/dist/esm/sqm-lead-dropdown-field-view-4c85fe20.js +67 -0
  30. package/dist/esm/sqm-lead-dropdown-field.entry.js +71 -0
  31. package/dist/esm/sqm-lead-input-field-view-f1dd4b77.js +49 -0
  32. package/dist/esm/sqm-lead-input-field.entry.js +74 -0
  33. package/dist/esm/sqm-stencilbook.entry.js +166 -49
  34. package/dist/esm/useLeadFormState-9016d812.js +68 -0
  35. package/dist/esm-es5/{ShadowViewAddon-aa7177fe.js → ShadowViewAddon-8a0d9e83.js} +1 -1
  36. package/dist/esm-es5/loader.js +1 -1
  37. package/dist/esm-es5/mint-components.js +1 -1
  38. package/dist/esm-es5/sqm-big-stat_42.entry.js +1 -1
  39. package/dist/esm-es5/sqm-lead-dropdown-field-view-4c85fe20.js +1 -0
  40. package/dist/esm-es5/sqm-lead-dropdown-field.entry.js +1 -0
  41. package/dist/esm-es5/sqm-lead-input-field-view-f1dd4b77.js +1 -0
  42. package/dist/esm-es5/sqm-lead-input-field.entry.js +1 -0
  43. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  44. package/dist/esm-es5/useLeadFormState-9016d812.js +1 -0
  45. package/dist/mint-components/mint-components.esm.js +1 -1
  46. package/dist/mint-components/p-13c67985.system.entry.js +1 -0
  47. package/dist/mint-components/p-15f1ff1d.system.js +1 -0
  48. package/dist/mint-components/p-1d704c40.system.js +1 -0
  49. package/dist/mint-components/p-26da31c6.js +1 -0
  50. package/dist/mint-components/p-37996351.system.js +1 -1
  51. package/dist/mint-components/{p-373a92a2.js → p-4139feb5.js} +3 -3
  52. package/dist/mint-components/p-4d5b02af.js +1 -0
  53. package/dist/mint-components/p-87384d9e.system.js +1 -0
  54. package/dist/mint-components/p-875861d7.system.entry.js +1 -0
  55. package/dist/mint-components/p-8af8ab01.system.entry.js +1 -0
  56. package/dist/mint-components/p-9e1570bf.system.entry.js +1 -0
  57. package/dist/mint-components/{p-72e5e84f.system.js → p-ad6420a2.system.js} +1 -1
  58. package/dist/mint-components/p-b8c15858.entry.js +1 -0
  59. package/dist/mint-components/{p-8dc110b0.entry.js → p-cd1c6113.entry.js} +2 -2
  60. package/dist/mint-components/p-e358f0c1.entry.js +265 -0
  61. package/dist/mint-components/p-f59d6012.entry.js +1 -0
  62. package/dist/mint-components/p-f98a4354.js +1 -0
  63. package/dist/types/components/sqm-lead-form/LeadForm.stories.d.ts +1 -0
  64. package/dist/types/components/sqm-lead-form/LeadFormDropdownField.stories.d.ts +9 -0
  65. package/dist/types/components/sqm-lead-form/LeadInputField.stories.d.ts +8 -0
  66. package/dist/types/components/sqm-lead-form/sqm-lead-dropdown-field-view.d.ts +15 -0
  67. package/dist/types/components/sqm-lead-form/sqm-lead-dropdown-field.d.ts +42 -0
  68. package/dist/types/components/sqm-lead-form/sqm-lead-form-view.d.ts +7 -0
  69. package/dist/types/components/sqm-lead-form/sqm-lead-form.d.ts +24 -7
  70. package/dist/types/components/sqm-lead-form/sqm-lead-input-field-view.d.ts +14 -0
  71. package/dist/types/components/sqm-lead-form/sqm-lead-input-field.d.ts +49 -0
  72. package/dist/types/components/sqm-lead-form/useLeadDropdownField.d.ts +6 -0
  73. package/dist/types/components/sqm-lead-form/useLeadForm.d.ts +4 -0
  74. package/dist/types/components/sqm-lead-form/useLeadInputField.d.ts +6 -0
  75. package/dist/types/components.d.ts +194 -12
  76. package/docs/docs.docx +0 -0
  77. package/docs/raisins.json +1 -1
  78. package/grapesjs/grapesjs.js +1 -1
  79. package/package.json +1 -1
  80. package/dist/mint-components/p-02a6e0df.system.entry.js +0 -1
  81. package/dist/mint-components/p-0c6ab3ec.system.entry.js +0 -1
  82. package/dist/mint-components/p-6349fb7c.entry.js +0 -265
  83. package/dist/types/global/android.d.ts +0 -7
  84. package/dist/types/global/demo.d.ts +0 -2
  85. package/dist/types/stories/features.d.ts +0 -4
  86. package/dist/types/stories/templates.d.ts +0 -4
@@ -11,13 +11,6 @@ import { useLeadForm } from "./useLeadForm";
11
11
  export class LeadForm {
12
12
  constructor() {
13
13
  this.ignored = true;
14
- /**
15
- * Redirect participants to this page from their verification email
16
- *
17
- * @uiName Submission redirect
18
- * @uiWidget pageSelect
19
- */
20
- this.nextPage = "/";
21
14
  /**
22
15
  * @uiName Email field label
23
16
  */
@@ -34,18 +27,42 @@ export class LeadForm {
34
27
  * @uiName Submit button text
35
28
  */
36
29
  this.submitLabel = "Submit";
30
+ /**
31
+ * @uiName Submit another form button label
32
+ */
33
+ this.resubmitFormLabel = "Refer Another Friend";
37
34
  /**
38
35
  * @uiName Header text
39
36
  */
40
- this.pageLabel = "Submit your information";
37
+ this.pageLabel = "Refer your friend";
41
38
  this.formKey = "lead-form";
39
+ /**
40
+ * Optional support link for error messages.
41
+ */
42
+ this.supportLink = "Support";
43
+ /**
44
+ * Header text shown on successful submission.
45
+ */
46
+ this.submitSuccessHeader = "Referral submitted";
47
+ /**
48
+ * Description text shown on successful submission.
49
+ */
50
+ 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
+ /**
52
+ * Header text shown when an error occurs.
53
+ */
54
+ this.submitErrorHeader = "An error occurred while submitting";
55
+ /**
56
+ * Description text shown when an error occurs.
57
+ */
58
+ this.submitErrorDescription = "Please try again later. If the problem continues, contact {supportLink}";
42
59
  /**
43
60
  * The message to be displayed when a required field is not filled.
44
61
  *
45
62
  * @uiName Required field message
46
63
  * @uiWidget textArea
47
64
  */
48
- this.requiredFieldErrorMessage = "Cannot be empty";
65
+ this.requiredFieldErrorMessage = "Please enter a valid {fieldLabel}";
49
66
  /**
50
67
  * The message to be displayed when a the form submission fails unexpectedly.
51
68
  *
@@ -71,7 +88,13 @@ export class LeadForm {
71
88
  formData: h("slot", { name: "formData" }),
72
89
  emailLabel: this.emailLabel,
73
90
  submitLabel: this.submitLabel,
91
+ resubmitFormLabel: this.resubmitFormLabel,
74
92
  pageLabel: this.pageLabel,
93
+ supportLink: this.supportLink,
94
+ submitSuccessHeader: this.submitSuccessHeader,
95
+ submitSuccessDescription: this.submitSuccessDescription,
96
+ submitErrorHeader: this.submitErrorHeader,
97
+ submitErrorDescription: this.submitErrorDescription,
75
98
  invalidEmailErrorMessage: this.invalidEmailErrorMessage,
76
99
  requiredFieldErrorMessage: this.requiredFieldErrorMessage,
77
100
  };
@@ -80,30 +103,6 @@ export class LeadForm {
80
103
  static get is() { return "sqm-lead-form"; }
81
104
  static get encapsulation() { return "shadow"; }
82
105
  static get properties() { return {
83
- "nextPage": {
84
- "type": "string",
85
- "mutable": false,
86
- "complexType": {
87
- "original": "string",
88
- "resolved": "string",
89
- "references": {}
90
- },
91
- "required": false,
92
- "optional": false,
93
- "docs": {
94
- "tags": [{
95
- "text": "Submission redirect",
96
- "name": "uiName"
97
- }, {
98
- "text": "pageSelect",
99
- "name": "uiWidget"
100
- }],
101
- "text": "Redirect participants to this page from their verification email"
102
- },
103
- "attribute": "next-page",
104
- "reflect": false,
105
- "defaultValue": "\"/\""
106
- },
107
106
  "emailLabel": {
108
107
  "type": "string",
109
108
  "mutable": false,
@@ -188,6 +187,27 @@ export class LeadForm {
188
187
  "reflect": false,
189
188
  "defaultValue": "\"Submit\""
190
189
  },
190
+ "resubmitFormLabel": {
191
+ "type": "string",
192
+ "mutable": false,
193
+ "complexType": {
194
+ "original": "string",
195
+ "resolved": "string",
196
+ "references": {}
197
+ },
198
+ "required": false,
199
+ "optional": false,
200
+ "docs": {
201
+ "tags": [{
202
+ "text": "Submit another form button label",
203
+ "name": "uiName"
204
+ }],
205
+ "text": ""
206
+ },
207
+ "attribute": "resubmit-form-label",
208
+ "reflect": false,
209
+ "defaultValue": "\"Refer Another Friend\""
210
+ },
191
211
  "pageLabel": {
192
212
  "type": "string",
193
213
  "mutable": false,
@@ -207,7 +227,7 @@ export class LeadForm {
207
227
  },
208
228
  "attribute": "page-label",
209
229
  "reflect": false,
210
- "defaultValue": "\"Submit your information\""
230
+ "defaultValue": "\"Refer your friend\""
211
231
  },
212
232
  "formKey": {
213
233
  "type": "string",
@@ -227,6 +247,96 @@ export class LeadForm {
227
247
  "reflect": false,
228
248
  "defaultValue": "\"lead-form\""
229
249
  },
250
+ "supportLink": {
251
+ "type": "string",
252
+ "mutable": false,
253
+ "complexType": {
254
+ "original": "string",
255
+ "resolved": "string",
256
+ "references": {}
257
+ },
258
+ "required": false,
259
+ "optional": false,
260
+ "docs": {
261
+ "tags": [],
262
+ "text": "Optional support link for error messages."
263
+ },
264
+ "attribute": "support-link",
265
+ "reflect": false,
266
+ "defaultValue": "\"Support\""
267
+ },
268
+ "submitSuccessHeader": {
269
+ "type": "string",
270
+ "mutable": false,
271
+ "complexType": {
272
+ "original": "string",
273
+ "resolved": "string",
274
+ "references": {}
275
+ },
276
+ "required": false,
277
+ "optional": false,
278
+ "docs": {
279
+ "tags": [],
280
+ "text": "Header text shown on successful submission."
281
+ },
282
+ "attribute": "submit-success-header",
283
+ "reflect": false,
284
+ "defaultValue": "\"Referral submitted\""
285
+ },
286
+ "submitSuccessDescription": {
287
+ "type": "string",
288
+ "mutable": false,
289
+ "complexType": {
290
+ "original": "string",
291
+ "resolved": "string",
292
+ "references": {}
293
+ },
294
+ "required": false,
295
+ "optional": false,
296
+ "docs": {
297
+ "tags": [],
298
+ "text": "Description text shown on successful submission."
299
+ },
300
+ "attribute": "submit-success-description",
301
+ "reflect": false,
302
+ "defaultValue": "\"Our team will contact your friend to see if they\u2019re a good fit. In the meantime, you can track this referral on Activity page.\""
303
+ },
304
+ "submitErrorHeader": {
305
+ "type": "string",
306
+ "mutable": false,
307
+ "complexType": {
308
+ "original": "string",
309
+ "resolved": "string",
310
+ "references": {}
311
+ },
312
+ "required": false,
313
+ "optional": false,
314
+ "docs": {
315
+ "tags": [],
316
+ "text": "Header text shown when an error occurs."
317
+ },
318
+ "attribute": "submit-error-header",
319
+ "reflect": false,
320
+ "defaultValue": "\"An error occurred while submitting\""
321
+ },
322
+ "submitErrorDescription": {
323
+ "type": "string",
324
+ "mutable": false,
325
+ "complexType": {
326
+ "original": "string",
327
+ "resolved": "string",
328
+ "references": {}
329
+ },
330
+ "required": false,
331
+ "optional": false,
332
+ "docs": {
333
+ "tags": [],
334
+ "text": "Description text shown when an error occurs."
335
+ },
336
+ "attribute": "submit-error-description",
337
+ "reflect": false,
338
+ "defaultValue": "\"Please try again later. If the problem continues, contact {supportLink}\""
339
+ },
230
340
  "requiredFieldErrorMessage": {
231
341
  "type": "string",
232
342
  "mutable": false,
@@ -249,7 +359,7 @@ export class LeadForm {
249
359
  },
250
360
  "attribute": "required-field-error-message",
251
361
  "reflect": false,
252
- "defaultValue": "\"Cannot be empty\""
362
+ "defaultValue": "\"Please enter a valid {fieldLabel}\""
253
363
  },
254
364
  "networkErrorMessage": {
255
365
  "type": "string",
@@ -304,7 +414,7 @@ export class LeadForm {
304
414
  "mutable": false,
305
415
  "complexType": {
306
416
  "original": "DemoData<LeadFormViewProps>",
307
- "resolved": "{ states?: { error: string; loading: boolean; leadFormState: LeadFormState; referralCode: string; }; refs?: { formRef: any; }; content?: { formData?: VNode; emailLabel?: string; firstNameLabel?: string; lastNameLabel?: string; submitLabel?: string; pageLabel?: string; requiredFieldErrorMessage: string; invalidEmailErrorMessage: string; }; }",
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; }; }",
308
418
  "references": {
309
419
  "DemoData": {
310
420
  "location": "import",
@@ -339,6 +449,7 @@ function useRegisterDemo(props) {
339
449
  states: {
340
450
  error: "",
341
451
  loading: false,
452
+ success: false,
342
453
  },
343
454
  callbacks: {
344
455
  submit: async (_event) => {
@@ -0,0 +1,47 @@
1
+ import { h } from "@stencil/core";
2
+ import jss from "jss";
3
+ import preset from "jss-preset-default";
4
+ import { intl } from "../../global/global";
5
+ import { ErrorStyles } from "../../global/mixins";
6
+ const style = {
7
+ ErrorStyle: ErrorStyles,
8
+ FieldContainer: {
9
+ "margin-bottom": "var(--sl-spacing-large)",
10
+ },
11
+ };
12
+ const vanillaStyle = `
13
+ :host {
14
+ margin: 0 auto;
15
+ width: 100%;
16
+ display: block;
17
+ }
18
+ `;
19
+ jss.setup(preset());
20
+ const sheet = jss.createStyleSheet(style);
21
+ const styleString = sheet.toString();
22
+ export function LeadInputFieldView(props) {
23
+ var _a, _b, _c, _d, _e, _f;
24
+ const { states, content } = props;
25
+ const getRequiredFieldErrorMessage = ({ fieldLabel, }) => intl.formatMessage({
26
+ id: "requiredFieldErrorMessage",
27
+ defaultMessage: content.requiredFieldErrorMessage,
28
+ }, {
29
+ fieldLabel,
30
+ });
31
+ return (h("div", { part: "sqm-base" },
32
+ h("style", { type: "text/css" },
33
+ vanillaStyle,
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) {
37
+ return getRequiredFieldErrorMessage({
38
+ fieldLabel: content.fieldLabel,
39
+ });
40
+ }
41
+ } }, (((_d = (_c = states.leadFormState) === null || _c === void 0 ? void 0 : _c.validationErrors) === null || _d === void 0 ? void 0 : _d.firstName) ? {
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) ||
44
+ content.requiredFieldErrorMessage,
45
+ }
46
+ : [])))));
47
+ }
@@ -0,0 +1,222 @@
1
+ import { isDemo } from "@saasquatch/component-boilerplate";
2
+ import { withHooks } from "@saasquatch/stencil-hooks";
3
+ import { Component, h, Prop, State } from "@stencil/core";
4
+ import deepmerge from "deepmerge";
5
+ import { RequiredPropsError } from "../../utils/RequiredPropsError";
6
+ import { getMissingProps, getProps } from "../../utils/utils";
7
+ import { LeadInputFieldView, } from "./sqm-lead-input-field-view";
8
+ import { useLeadInputField } from "./useLeadInputField";
9
+ /**
10
+ * @uiName Lead Form Input Field
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
+ */
15
+ export class LeadInputField {
16
+ constructor() {
17
+ this.ignored = true;
18
+ /**
19
+ * @uiName Input type
20
+ * @uiType string
21
+ * @uiEnum ["text", "date", "tel"]
22
+ * @uiEnumNames ["Text", "Date", "Phone Number"]
23
+ */
24
+ this.fieldType = "text";
25
+ /**
26
+ * The message to be displayed when a required field is not filled.
27
+ *
28
+ * @uiName Required field message
29
+ * @uiWidget textArea
30
+ */
31
+ this.requiredFieldErrorMessage = "Please enter a {fieldName}";
32
+ /**
33
+ * @uiName Optional
34
+ * @default
35
+ */
36
+ this.fieldOptional = false;
37
+ withHooks(this);
38
+ }
39
+ disconnectedCallback() { }
40
+ render() {
41
+ const content = {
42
+ ...getProps(this),
43
+ };
44
+ const missingProps = getMissingProps([
45
+ {
46
+ attribute: "field-name",
47
+ value: this.fieldName,
48
+ },
49
+ ]);
50
+ if (!isDemo() && missingProps) {
51
+ return (h(RequiredPropsError, { missingProps: missingProps, heading: "An error occured while loading this form", subheading: "A technical problem prevented this input field from loading. Please contact us with the link to this page.", description: "Values for the following attributes are missing:" }));
52
+ }
53
+ const { states } = isDemo()
54
+ ? useLeadInputFieldDemo(this)
55
+ : useLeadInputField();
56
+ return (h(LeadInputFieldView, { states: states, content: content }));
57
+ }
58
+ static get is() { return "sqm-lead-input-field"; }
59
+ static get properties() { return {
60
+ "fieldName": {
61
+ "type": "string",
62
+ "mutable": false,
63
+ "complexType": {
64
+ "original": "string",
65
+ "resolved": "string",
66
+ "references": {}
67
+ },
68
+ "required": false,
69
+ "optional": false,
70
+ "docs": {
71
+ "tags": [{
72
+ "text": "Input name attribute",
73
+ "name": "uiName"
74
+ }, {
75
+ "text": undefined,
76
+ "name": "required"
77
+ }],
78
+ "text": "This name is used as the key for this form field on submission. The name must be unique within this specific form."
79
+ },
80
+ "attribute": "field-name",
81
+ "reflect": false
82
+ },
83
+ "fieldLabel": {
84
+ "type": "string",
85
+ "mutable": false,
86
+ "complexType": {
87
+ "original": "string",
88
+ "resolved": "string",
89
+ "references": {}
90
+ },
91
+ "required": false,
92
+ "optional": false,
93
+ "docs": {
94
+ "tags": [{
95
+ "text": "Input label",
96
+ "name": "uiName"
97
+ }],
98
+ "text": ""
99
+ },
100
+ "attribute": "field-label",
101
+ "reflect": false
102
+ },
103
+ "fieldType": {
104
+ "type": "string",
105
+ "mutable": false,
106
+ "complexType": {
107
+ "original": "\"text\" | \"date\" | \"tel\"",
108
+ "resolved": "\"date\" | \"tel\" | \"text\"",
109
+ "references": {}
110
+ },
111
+ "required": false,
112
+ "optional": false,
113
+ "docs": {
114
+ "tags": [{
115
+ "text": "Input type",
116
+ "name": "uiName"
117
+ }, {
118
+ "text": "string",
119
+ "name": "uiType"
120
+ }, {
121
+ "text": "[\"text\", \"date\", \"tel\"]",
122
+ "name": "uiEnum"
123
+ }, {
124
+ "text": "[\"Text\", \"Date\", \"Phone Number\"]",
125
+ "name": "uiEnumNames"
126
+ }],
127
+ "text": ""
128
+ },
129
+ "attribute": "field-type",
130
+ "reflect": false,
131
+ "defaultValue": "\"text\""
132
+ },
133
+ "requiredFieldErrorMessage": {
134
+ "type": "string",
135
+ "mutable": false,
136
+ "complexType": {
137
+ "original": "string",
138
+ "resolved": "string",
139
+ "references": {}
140
+ },
141
+ "required": false,
142
+ "optional": false,
143
+ "docs": {
144
+ "tags": [{
145
+ "text": "Required field message",
146
+ "name": "uiName"
147
+ }, {
148
+ "text": "textArea",
149
+ "name": "uiWidget"
150
+ }],
151
+ "text": "The message to be displayed when a required field is not filled."
152
+ },
153
+ "attribute": "required-field-error-message",
154
+ "reflect": false,
155
+ "defaultValue": "\"Please enter a {fieldName}\""
156
+ },
157
+ "fieldOptional": {
158
+ "type": "boolean",
159
+ "mutable": false,
160
+ "complexType": {
161
+ "original": "boolean",
162
+ "resolved": "boolean",
163
+ "references": {}
164
+ },
165
+ "required": false,
166
+ "optional": true,
167
+ "docs": {
168
+ "tags": [{
169
+ "text": "Optional",
170
+ "name": "uiName"
171
+ }, {
172
+ "text": undefined,
173
+ "name": "default"
174
+ }],
175
+ "text": ""
176
+ },
177
+ "attribute": "field-optional",
178
+ "reflect": false,
179
+ "defaultValue": "false"
180
+ },
181
+ "demoData": {
182
+ "type": "unknown",
183
+ "mutable": false,
184
+ "complexType": {
185
+ "original": "DemoData<LeadInputFieldViewProps>",
186
+ "resolved": "{ states?: { leadFormState?: LeadFormState; }; content?: { fieldName: string; fieldLabel: string; fieldType: \"text\" | \"date\" | \"tel\"; fieldOptional?: boolean; requiredFieldErrorMessage: string; }; }",
187
+ "references": {
188
+ "DemoData": {
189
+ "location": "import",
190
+ "path": "../../global/demo"
191
+ },
192
+ "LeadInputFieldViewProps": {
193
+ "location": "import",
194
+ "path": "./sqm-lead-input-field-view"
195
+ }
196
+ }
197
+ },
198
+ "required": false,
199
+ "optional": true,
200
+ "docs": {
201
+ "tags": [{
202
+ "text": undefined,
203
+ "name": "undocumented"
204
+ }, {
205
+ "text": "object",
206
+ "name": "uiType"
207
+ }],
208
+ "text": ""
209
+ }
210
+ }
211
+ }; }
212
+ static get states() { return {
213
+ "ignored": {}
214
+ }; }
215
+ }
216
+ function useLeadInputFieldDemo(props) {
217
+ return deepmerge({
218
+ states: {
219
+ leadForState: {},
220
+ },
221
+ }, props.demoData || {}, { arrayMerge: (_, a) => a });
222
+ }
@@ -0,0 +1,10 @@
1
+ import { useDomContext } from "@saasquatch/stencil-hooks";
2
+ import { LEAD_FORM_STATE_CONTEXT } from "./useLeadFormState";
3
+ export function useLeadDropdownField() {
4
+ const leadFormState = useDomContext(LEAD_FORM_STATE_CONTEXT);
5
+ return {
6
+ states: {
7
+ leadFormState,
8
+ },
9
+ };
10
+ }
@@ -1,5 +1,5 @@
1
- import { navigation, useMutation } from "@saasquatch/component-boilerplate";
2
- import { useCallback, useEffect, useRef } from "@saasquatch/universal-hooks";
1
+ import { useMutation } from "@saasquatch/component-boilerplate";
2
+ import { useCallback, useEffect, useRef, useState, } from "@saasquatch/universal-hooks";
3
3
  import { gql } from "graphql-request";
4
4
  import jsonpointer from "jsonpointer";
5
5
  import { AsYouType } from "libphonenumber-js";
@@ -16,6 +16,7 @@ export function useLeadForm(props) {
16
16
  const formRef = useRef(null);
17
17
  const { leadFormState, setLeadFormState } = useLeadFormState({});
18
18
  const [submitLead, { loading, errors, data }] = useMutation(SUBMIT_LEAD);
19
+ const [success, setSuccess] = useState(false);
19
20
  useEffect(() => {
20
21
  if (!formRef.current)
21
22
  return;
@@ -26,6 +27,7 @@ export function useLeadForm(props) {
26
27
  };
27
28
  }, [formRef.current]);
28
29
  const submit = async (event) => {
30
+ var _a, _b;
29
31
  let formControls = event.target.getFormControls();
30
32
  let formData = {};
31
33
  let validationErrors = {};
@@ -58,7 +60,6 @@ export function useLeadForm(props) {
58
60
  validationErrors: {},
59
61
  });
60
62
  formData = { ...formData };
61
- const redirectPath = props.nextPage;
62
63
  const variables = {
63
64
  key: props.formKey,
64
65
  formData,
@@ -73,8 +74,9 @@ export function useLeadForm(props) {
73
74
  error: "",
74
75
  validationErrors: {},
75
76
  });
76
- if (result.success) {
77
- navigation.push(props.nextPage);
77
+ console.log({ success: result.data.submitForm.success });
78
+ if ((_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) {
79
+ setSuccess(true);
78
80
  }
79
81
  }
80
82
  catch (error) {
@@ -108,6 +110,7 @@ export function useLeadForm(props) {
108
110
  states: {
109
111
  loading,
110
112
  error: errorMessage,
113
+ success,
111
114
  leadFormState,
112
115
  referralCode: "ABC123",
113
116
  },
@@ -0,0 +1,10 @@
1
+ import { useDomContext } from "@saasquatch/stencil-hooks";
2
+ import { LEAD_FORM_STATE_CONTEXT } from "./useLeadFormState";
3
+ export function useLeadInputField() {
4
+ const leadFormState = useDomContext(LEAD_FORM_STATE_CONTEXT);
5
+ return {
6
+ states: {
7
+ leadFormState,
8
+ },
9
+ };
10
+ }
@@ -98,6 +98,8 @@ import * as PortalRegistrationForm from "../sqm-portal-registration-form/PortalR
98
98
  import * as PortalGoogleRegistrationFormStories from "../sqm-portal-google-registration-form/PortalGoogleRegistrationForm.stories";
99
99
  import * as QRCode from "../sqm-qr-code/QRCode.stories";
100
100
  import * as LeadForm from "../sqm-lead-form/LeadForm.stories";
101
+ import * as LeadInputField from "../sqm-lead-form/LeadInputField.stories";
102
+ import * as LeadFormDropdownField from "../sqm-lead-form/LeadFormDropdownField.stories";
101
103
  import * as Themes from "./Themes";
102
104
  import { CucumberAddon } from "./CucumberAddon";
103
105
  import { HookStoryAddon } from "./HookStoryAddon";
@@ -201,6 +203,8 @@ const stories = [
201
203
  PayoutStatusAlert,
202
204
  QRCode,
203
205
  LeadForm,
206
+ LeadInputField,
207
+ LeadFormDropdownField,
204
208
  ];
205
209
  /**
206
210
  * For internal documentation