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

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 (85) hide show
  1. package/dist/cjs/{ShadowViewAddon-c0a5fdf8.js → ShadowViewAddon-f5ca0367.js} +75 -47
  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 +117 -120
  5. package/dist/cjs/sqm-lead-dropdown-field-view-0211d640.js +67 -0
  6. package/dist/cjs/sqm-lead-dropdown-field.cjs.entry.js +81 -0
  7. package/dist/cjs/sqm-lead-input-field-view-5a0b1aed.js +51 -0
  8. package/dist/cjs/sqm-lead-input-field.cjs.entry.js +84 -0
  9. package/dist/cjs/sqm-stencilbook.cjs.entry.js +167 -49
  10. package/dist/cjs/useLeadFormState-c83d2034.js +72 -0
  11. package/dist/collection/collection-manifest.json +3 -1
  12. package/dist/collection/components/sqm-lead-form/LeadForm.stories.js +35 -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 +63 -0
  16. package/dist/collection/components/sqm-lead-form/sqm-lead-dropdown-field.js +199 -0
  17. package/dist/collection/components/sqm-lead-form/sqm-lead-form-view.js +77 -48
  18. package/dist/collection/components/sqm-lead-form/sqm-lead-form.js +150 -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 +228 -0
  21. package/dist/collection/components/sqm-lead-form/useLeadDropdownField.js +10 -0
  22. package/dist/collection/components/sqm-lead-form/useLeadForm.js +36 -7
  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-b360202a.js} +76 -48
  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 +114 -117
  29. package/dist/esm/sqm-lead-dropdown-field-view-62e74a36.js +65 -0
  30. package/dist/esm/sqm-lead-dropdown-field.entry.js +77 -0
  31. package/dist/esm/sqm-lead-input-field-view-9b23f22c.js +49 -0
  32. package/dist/esm/sqm-lead-input-field.entry.js +80 -0
  33. package/dist/esm/sqm-stencilbook.entry.js +167 -49
  34. package/dist/esm/useLeadFormState-9016d812.js +68 -0
  35. package/dist/esm-es5/ShadowViewAddon-b360202a.js +1 -0
  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-62e74a36.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-9b23f22c.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-00590b7a.system.js +1 -0
  47. package/dist/mint-components/p-036e8dad.system.js +1 -0
  48. package/dist/mint-components/{p-8dc110b0.entry.js → p-0f2bbd2a.entry.js} +2 -2
  49. package/dist/mint-components/p-1d704c40.system.js +1 -0
  50. package/dist/mint-components/p-2192104c.entry.js +1 -0
  51. package/dist/mint-components/p-2d15db9b.system.entry.js +1 -0
  52. package/dist/mint-components/{p-373a92a2.js → p-2efc0d36.js} +24 -24
  53. package/dist/mint-components/p-37996351.system.js +1 -1
  54. package/dist/mint-components/p-3e327cc8.system.entry.js +1 -0
  55. package/dist/mint-components/p-789e2217.entry.js +273 -0
  56. package/dist/mint-components/p-84a9e392.system.entry.js +1 -0
  57. package/dist/mint-components/p-8698266c.system.js +1 -0
  58. package/dist/mint-components/p-b54f8e03.entry.js +1 -0
  59. package/dist/mint-components/p-cd10001b.js +1 -0
  60. package/dist/mint-components/p-de5321fc.system.entry.js +1 -0
  61. package/dist/mint-components/p-f6717dd7.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 +8 -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 +6 -1
  74. package/dist/types/components/sqm-lead-form/useLeadInputField.d.ts +6 -0
  75. package/dist/types/components/sqm-referral-iframe/useReferralIframe.d.ts +1 -1
  76. package/dist/types/components.d.ts +194 -12
  77. package/docs/docs.docx +0 -0
  78. package/docs/raisins.json +1 -1
  79. package/grapesjs/grapesjs.js +1 -1
  80. package/package.json +1 -1
  81. package/dist/esm-es5/ShadowViewAddon-aa7177fe.js +0 -1
  82. package/dist/mint-components/p-02a6e0df.system.entry.js +0 -1
  83. package/dist/mint-components/p-0c6ab3ec.system.entry.js +0 -1
  84. package/dist/mint-components/p-6349fb7c.entry.js +0 -265
  85. package/dist/mint-components/p-72e5e84f.system.js +0 -1
@@ -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,39 +88,23 @@ 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,
100
+ firstNameLabel: this.firstNameLabel,
101
+ lastNameLabel: this.lastNameLabel,
77
102
  };
78
103
  return (h(LeadFormView, { states: states, callbacks: callbacks, content: content, refs: refs }));
79
104
  }
80
105
  static get is() { return "sqm-lead-form"; }
81
106
  static get encapsulation() { return "shadow"; }
82
107
  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
108
  "emailLabel": {
108
109
  "type": "string",
109
110
  "mutable": false,
@@ -188,6 +189,27 @@ export class LeadForm {
188
189
  "reflect": false,
189
190
  "defaultValue": "\"Submit\""
190
191
  },
192
+ "resubmitFormLabel": {
193
+ "type": "string",
194
+ "mutable": false,
195
+ "complexType": {
196
+ "original": "string",
197
+ "resolved": "string",
198
+ "references": {}
199
+ },
200
+ "required": false,
201
+ "optional": false,
202
+ "docs": {
203
+ "tags": [{
204
+ "text": "Submit another form button label",
205
+ "name": "uiName"
206
+ }],
207
+ "text": ""
208
+ },
209
+ "attribute": "resubmit-form-label",
210
+ "reflect": false,
211
+ "defaultValue": "\"Refer Another Friend\""
212
+ },
191
213
  "pageLabel": {
192
214
  "type": "string",
193
215
  "mutable": false,
@@ -207,7 +229,7 @@ export class LeadForm {
207
229
  },
208
230
  "attribute": "page-label",
209
231
  "reflect": false,
210
- "defaultValue": "\"Submit your information\""
232
+ "defaultValue": "\"Refer your friend\""
211
233
  },
212
234
  "formKey": {
213
235
  "type": "string",
@@ -227,6 +249,96 @@ export class LeadForm {
227
249
  "reflect": false,
228
250
  "defaultValue": "\"lead-form\""
229
251
  },
252
+ "supportLink": {
253
+ "type": "string",
254
+ "mutable": false,
255
+ "complexType": {
256
+ "original": "string",
257
+ "resolved": "string",
258
+ "references": {}
259
+ },
260
+ "required": false,
261
+ "optional": false,
262
+ "docs": {
263
+ "tags": [],
264
+ "text": "Optional support link for error messages."
265
+ },
266
+ "attribute": "support-link",
267
+ "reflect": false,
268
+ "defaultValue": "\"Support\""
269
+ },
270
+ "submitSuccessHeader": {
271
+ "type": "string",
272
+ "mutable": false,
273
+ "complexType": {
274
+ "original": "string",
275
+ "resolved": "string",
276
+ "references": {}
277
+ },
278
+ "required": false,
279
+ "optional": false,
280
+ "docs": {
281
+ "tags": [],
282
+ "text": "Header text shown on successful submission."
283
+ },
284
+ "attribute": "submit-success-header",
285
+ "reflect": false,
286
+ "defaultValue": "\"Referral submitted\""
287
+ },
288
+ "submitSuccessDescription": {
289
+ "type": "string",
290
+ "mutable": false,
291
+ "complexType": {
292
+ "original": "string",
293
+ "resolved": "string",
294
+ "references": {}
295
+ },
296
+ "required": false,
297
+ "optional": false,
298
+ "docs": {
299
+ "tags": [],
300
+ "text": "Description text shown on successful submission."
301
+ },
302
+ "attribute": "submit-success-description",
303
+ "reflect": false,
304
+ "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.\""
305
+ },
306
+ "submitErrorHeader": {
307
+ "type": "string",
308
+ "mutable": false,
309
+ "complexType": {
310
+ "original": "string",
311
+ "resolved": "string",
312
+ "references": {}
313
+ },
314
+ "required": false,
315
+ "optional": false,
316
+ "docs": {
317
+ "tags": [],
318
+ "text": "Header text shown when an error occurs."
319
+ },
320
+ "attribute": "submit-error-header",
321
+ "reflect": false,
322
+ "defaultValue": "\"An error occurred while submitting\""
323
+ },
324
+ "submitErrorDescription": {
325
+ "type": "string",
326
+ "mutable": false,
327
+ "complexType": {
328
+ "original": "string",
329
+ "resolved": "string",
330
+ "references": {}
331
+ },
332
+ "required": false,
333
+ "optional": false,
334
+ "docs": {
335
+ "tags": [],
336
+ "text": "Description text shown when an error occurs."
337
+ },
338
+ "attribute": "submit-error-description",
339
+ "reflect": false,
340
+ "defaultValue": "\"Please try again later. If the problem continues, contact {supportLink}\""
341
+ },
230
342
  "requiredFieldErrorMessage": {
231
343
  "type": "string",
232
344
  "mutable": false,
@@ -249,7 +361,7 @@ export class LeadForm {
249
361
  },
250
362
  "attribute": "required-field-error-message",
251
363
  "reflect": false,
252
- "defaultValue": "\"Cannot be empty\""
364
+ "defaultValue": "\"Please enter a valid {fieldLabel}\""
253
365
  },
254
366
  "networkErrorMessage": {
255
367
  "type": "string",
@@ -304,7 +416,7 @@ export class LeadForm {
304
416
  "mutable": false,
305
417
  "complexType": {
306
418
  "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; }; }",
419
+ "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
420
  "references": {
309
421
  "DemoData": {
310
422
  "location": "import",
@@ -339,12 +451,14 @@ function useRegisterDemo(props) {
339
451
  states: {
340
452
  error: "",
341
453
  loading: false,
454
+ success: false,
342
455
  },
343
456
  callbacks: {
344
457
  submit: async (_event) => {
345
458
  console.log("submit");
346
459
  },
347
460
  inputFunction: () => { },
461
+ resetForm: () => { },
348
462
  },
349
463
  refs: {
350
464
  formRef: {},
@@ -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-${fieldLabel}`,
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[content.fieldName]) ? {
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[content.fieldName]) ||
44
+ content.requiredFieldErrorMessage,
45
+ }
46
+ : [])))));
47
+ }
@@ -0,0 +1,228 @@
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 {fieldLabel}";
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 {fieldLabel}\""
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
+ content: {
222
+ fieldName: props.fieldName,
223
+ fieldLabel: props.fieldLabel,
224
+ fieldType: props.fieldType,
225
+ requiredFieldErrorMessage: props.requiredFieldErrorMessage,
226
+ },
227
+ }, props.demoData || {}, { arrayMerge: (_, a) => a });
228
+ }
@@ -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, useProgramId, useQuery, useUserIdentity, } 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";
@@ -11,11 +11,25 @@ const SUBMIT_LEAD = gql `
11
11
  }
12
12
  }
13
13
  `;
14
+ const GET_USER_DETAILS = gql `
15
+ query getUser($programId: ID) {
16
+ viewer {
17
+ ... on User {
18
+ referralCode(programId: $programId)
19
+ }
20
+ }
21
+ }
22
+ `;
14
23
  export function useLeadForm(props) {
15
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
24
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
16
25
  const formRef = useRef(null);
17
26
  const { leadFormState, setLeadFormState } = useLeadFormState({});
27
+ const programId = useProgramId();
28
+ const user = useUserIdentity();
29
+ const { data: userDetails } = useQuery(GET_USER_DETAILS, { programId }, !(user === null || user === void 0 ? void 0 : user.jwt) || !programId);
30
+ console.log({ userDetails });
18
31
  const [submitLead, { loading, errors, data }] = useMutation(SUBMIT_LEAD);
32
+ const [success, setSuccess] = useState(false);
19
33
  useEffect(() => {
20
34
  if (!formRef.current)
21
35
  return;
@@ -26,6 +40,7 @@ export function useLeadForm(props) {
26
40
  };
27
41
  }, [formRef.current]);
28
42
  const submit = async (event) => {
43
+ var _a;
29
44
  let formControls = event.target.getFormControls();
30
45
  let formData = {};
31
46
  let validationErrors = {};
@@ -58,7 +73,6 @@ export function useLeadForm(props) {
58
73
  validationErrors: {},
59
74
  });
60
75
  formData = { ...formData };
61
- const redirectPath = props.nextPage;
62
76
  const variables = {
63
77
  key: props.formKey,
64
78
  formData,
@@ -73,8 +87,8 @@ export function useLeadForm(props) {
73
87
  error: "",
74
88
  validationErrors: {},
75
89
  });
76
- if (result.success) {
77
- navigation.push(props.nextPage);
90
+ if ((_a = result === null || result === void 0 ? void 0 : result.submitForm) === null || _a === void 0 ? void 0 : _a.success) {
91
+ setSuccess(true);
78
92
  }
79
93
  }
80
94
  catch (error) {
@@ -93,6 +107,18 @@ export function useLeadForm(props) {
93
107
  const asYouType = new AsYouType("US");
94
108
  e.target.value = asYouType.input(e.target.value);
95
109
  }, []);
110
+ function resetForm() {
111
+ var _a, _b;
112
+ setLeadFormState({
113
+ loading: false,
114
+ error: "",
115
+ validationErrors: {},
116
+ });
117
+ (_b = (_a = formRef.current) === null || _a === void 0 ? void 0 : _a.getFormControls()) === null || _b === void 0 ? void 0 : _b.forEach((c) => {
118
+ c.value = "";
119
+ });
120
+ setSuccess(false);
121
+ }
96
122
  let errorMessage = "";
97
123
  if ((_a = errors === null || errors === void 0 ? void 0 : errors.response) === null || _a === void 0 ? void 0 : _a["error"]) {
98
124
  errorMessage = props.networkErrorMessage;
@@ -104,16 +130,19 @@ export function useLeadForm(props) {
104
130
  errorMessage =
105
131
  ((_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);
106
132
  }
133
+ console.log({ errors, errorMessage });
107
134
  return {
108
135
  states: {
109
136
  loading,
110
137
  error: errorMessage,
138
+ success,
111
139
  leadFormState,
112
- referralCode: "ABC123",
140
+ referralCode: ((_k = userDetails === null || userDetails === void 0 ? void 0 : userDetails.viewer) === null || _k === void 0 ? void 0 : _k.referralCode) || "",
113
141
  },
114
142
  callbacks: {
115
143
  submit,
116
144
  inputFunction,
145
+ resetForm,
117
146
  },
118
147
  refs: {
119
148
  formRef,
@@ -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