@saasquatch/mint-components 1.14.6-0 → 1.14.6-10

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 (83) hide show
  1. package/dist/cjs/{ShadowViewAddon-be112912.js → ShadowViewAddon-d1dda2b0.js} +62 -27
  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 +108 -121
  5. package/dist/cjs/sqm-lead-dropdown-field-view-03a3e03f.js +69 -0
  6. package/dist/cjs/sqm-lead-dropdown-field.cjs.entry.js +81 -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 +84 -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 +3 -1
  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 +199 -0
  17. package/dist/collection/components/sqm-lead-form/sqm-lead-form-view.js +63 -27
  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 +228 -0
  21. package/dist/collection/components/sqm-lead-form/useLeadDropdownField.js +10 -0
  22. package/dist/collection/components/sqm-lead-form/useLeadForm.js +30 -8
  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-9a77dd6b.js → ShadowViewAddon-81771102.js} +62 -27
  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 +105 -118
  29. package/dist/esm/sqm-lead-dropdown-field-view-4c85fe20.js +67 -0
  30. package/dist/esm/sqm-lead-dropdown-field.entry.js +77 -0
  31. package/dist/esm/sqm-lead-input-field-view-f1dd4b77.js +49 -0
  32. package/dist/esm/sqm-lead-input-field.entry.js +80 -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-9a77dd6b.js → ShadowViewAddon-81771102.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-10343b27.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-4056c0ea.system.entry.js +1 -0
  52. package/dist/mint-components/{p-ca9caa59.js → p-460974bf.js} +3 -3
  53. package/dist/mint-components/p-4d5b02af.js +1 -0
  54. package/dist/mint-components/p-59970cb1.system.entry.js +1 -0
  55. package/dist/mint-components/p-6b093d8c.entry.js +1 -0
  56. package/dist/mint-components/p-79e1a189.entry.js +273 -0
  57. package/dist/mint-components/p-87384d9e.system.js +1 -0
  58. package/dist/mint-components/{p-5aafb98a.system.js → p-ad128614.system.js} +1 -1
  59. package/dist/mint-components/{p-aa71fc1a.entry.js → p-ba585a4b.entry.js} +2 -2
  60. package/dist/mint-components/p-c5a55554.entry.js +1 -0
  61. package/dist/mint-components/p-de5356d9.system.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 +5 -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/mint-components/p-a2adc8b8.system.entry.js +0 -1
  82. package/dist/mint-components/p-e62f2051.entry.js +0 -265
  83. package/dist/mint-components/p-f38f77b5.system.entry.js +0 -1
@@ -5,6 +5,7 @@ export default {
5
5
  };
6
6
  const defaultProps = {
7
7
  states: {
8
+ success: false,
8
9
  leadFormState: {},
9
10
  error: "",
10
11
  loading: false,
@@ -18,75 +19,61 @@ const defaultProps = {
18
19
  formRef: {},
19
20
  },
20
21
  content: {
22
+ submitLabel: "Submit",
21
23
  pageLabel: "Submit your information",
24
+ resubmitFormLabel: "Refer Another Friend",
22
25
  requiredFieldErrorMessage: "Cannot be empty",
23
26
  invalidEmailErrorMessage: "Must be a valid email address",
27
+ submitSuccessHeader: "Referral submitted",
28
+ 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.",
29
+ submitErrorHeader: "An error occurred while submitting",
30
+ submitErrorDescription: "Please try again later. If the problem continues, contact Support",
24
31
  },
25
32
  };
26
- const errorProps = {
33
+ const successProps = {
34
+ ...defaultProps,
27
35
  states: {
28
- error: "Something went wrong. Please try again.",
29
- leadFormState: {},
30
- loading: false,
31
- referralCode: "ABC123",
32
- },
33
- callbacks: {
34
- submit: () => console.log("Submit!"),
35
- inputFunction: () => { },
36
- },
37
- refs: {
38
- formRef: {},
36
+ ...defaultProps.states,
37
+ success: true,
38
+ error: null,
39
39
  },
40
40
  content: {
41
- pageLabel: "Submit your information",
42
- requiredFieldErrorMessage: "Cannot be empty",
43
- invalidEmailErrorMessage: "Must be a valid email address",
41
+ ...defaultProps.content,
42
+ pageLabel: "Refer your friend",
43
+ },
44
+ };
45
+ const errorProps = {
46
+ ...defaultProps,
47
+ states: {
48
+ ...defaultProps.states,
49
+ error: "Something went wrong. Please try again.",
50
+ leadFormState: {
51
+ validationErrors: {
52
+ firstName: "Please enter a first name",
53
+ lastName: "Please enter a last name",
54
+ email: "Please enter a valid email",
55
+ },
56
+ },
44
57
  },
45
58
  };
46
59
  const loadingProps = {
60
+ ...defaultProps,
47
61
  states: {
48
- leadFormState: {},
49
- error: "",
62
+ ...defaultProps.states,
50
63
  loading: true,
51
- referralCode: "ABC123",
52
- },
53
- callbacks: {
54
- submit: () => console.log("Submit!"),
55
- inputFunction: () => { },
56
- },
57
- refs: {
58
- formRef: {},
59
- },
60
- content: {
61
- pageLabel: "Submit your information",
62
- requiredFieldErrorMessage: "Cannot be empty",
63
- invalidEmailErrorMessage: "Must be a valid email address",
64
64
  },
65
65
  };
66
66
  const slottedProps = {
67
- states: {
68
- leadFormState: {},
69
- error: "",
70
- loading: false,
71
- referralCode: "ABC123",
72
- },
73
- callbacks: {
74
- submit: () => console.log("Submit!"),
75
- inputFunction: () => { },
76
- },
77
- refs: {
78
- formRef: {},
79
- },
67
+ ...defaultProps,
80
68
  content: {
81
- pageLabel: "Submit your information",
82
- requiredFieldErrorMessage: "Cannot be empty",
83
- invalidEmailErrorMessage: "Must be a valid email address",
69
+ ...defaultProps.content,
84
70
  formData: (h("div", null,
85
71
  h("sl-input", { style: { marginBottom: "var(--sl-spacing-x-large)" }, exportparts: "label: input-label, base: input-base", label: "Slotted Input", required: true }),
86
72
  h("sl-input", { exportparts: "label: input-label, base: input-base", label: "Slotted Input 2", required: true }))),
87
73
  },
88
74
  };
89
75
  export const Default = () => h(LeadFormView, Object.assign({}, defaultProps));
76
+ export const LeadSubmitSuccess = () => h(LeadFormView, Object.assign({}, successProps));
90
77
  export const LeadSubmitWithError = () => h(LeadFormView, Object.assign({}, errorProps));
91
78
  export const LeadSubmitLoading = () => h(LeadFormView, Object.assign({}, loadingProps));
92
79
  export const FieldsHidden = () => {
@@ -94,6 +81,7 @@ export const FieldsHidden = () => {
94
81
  states: {
95
82
  leadFormState: {},
96
83
  error: "",
84
+ success: false,
97
85
  loading: true,
98
86
  referralCode: "ABC123",
99
87
  },
@@ -0,0 +1,59 @@
1
+ import { h } from "@stencil/core";
2
+ import { LeadDropdownFieldView, } from "./sqm-lead-dropdown-field-view";
3
+ export default {
4
+ title: "Components/Lead Form Dropdown Field",
5
+ };
6
+ const defaultProps = {
7
+ states: {
8
+ leadFormState: {
9
+ validationErrors: {},
10
+ loading: false,
11
+ disabled: false,
12
+ initialData: {},
13
+ },
14
+ },
15
+ content: {
16
+ dropdownName: "country",
17
+ dropdownLabel: "Country",
18
+ requiredFieldErrorMessage: "Please select a country",
19
+ dropdownOptional: false,
20
+ selectOptions: [
21
+ h("sl-menu-item", { value: "red" }, "Canada"),
22
+ h("sl-menu-item", { value: "blue" }, "United States"),
23
+ h("sl-menu-item", { value: "green" }, "Mexico"),
24
+ ],
25
+ },
26
+ };
27
+ export const Default = () => h(LeadDropdownFieldView, Object.assign({}, defaultProps));
28
+ export const WithError = () => (h(LeadDropdownFieldView, Object.assign({}, defaultProps, { states: {
29
+ ...defaultProps.states,
30
+ leadFormState: {
31
+ ...defaultProps.states.leadFormState,
32
+ validationErrors: {
33
+ country: "Please select a country",
34
+ },
35
+ },
36
+ } })));
37
+ export const Disabled = () => (h(LeadDropdownFieldView, Object.assign({}, defaultProps, { states: {
38
+ ...defaultProps.states,
39
+ leadFormState: {
40
+ ...defaultProps.states.leadFormState,
41
+ disabled: true,
42
+ },
43
+ } })));
44
+ export const Loading = () => (h(LeadDropdownFieldView, Object.assign({}, defaultProps, { states: {
45
+ ...defaultProps.states,
46
+ leadFormState: {
47
+ ...defaultProps.states.leadFormState,
48
+ loading: true,
49
+ },
50
+ } })));
51
+ export const WithInitialValue = () => (h(LeadDropdownFieldView, Object.assign({}, defaultProps, { states: {
52
+ ...defaultProps.states,
53
+ leadFormState: {
54
+ ...defaultProps.states.leadFormState,
55
+ initialData: {
56
+ country: "Canada",
57
+ },
58
+ },
59
+ } })));
@@ -0,0 +1,48 @@
1
+ import { h } from "@stencil/core";
2
+ import { LeadInputFieldView, } from "./sqm-lead-input-field-view";
3
+ export default {
4
+ title: "Components/Lead Form Input Field",
5
+ };
6
+ const defaultProps = {
7
+ states: {
8
+ leadFormState: {
9
+ validationErrors: {},
10
+ loading: false,
11
+ disabled: false,
12
+ initialData: {},
13
+ },
14
+ },
15
+ content: {
16
+ fieldName: "firstName",
17
+ fieldLabel: "First Name",
18
+ fieldType: "text",
19
+ requiredFieldErrorMessage: "Please {fieldAction} a {fieldLabel}",
20
+ fieldOptional: false,
21
+ },
22
+ };
23
+ export const Default = () => h(LeadInputFieldView, Object.assign({}, defaultProps));
24
+ export const WithError = () => (h(LeadInputFieldView, Object.assign({}, defaultProps, { states: {
25
+ ...defaultProps.states,
26
+ leadFormState: {
27
+ ...defaultProps.states.leadFormState,
28
+ validationErrors: {
29
+ firstName: "Please enter a first name",
30
+ },
31
+ },
32
+ } })));
33
+ export const Disabled = () => (h(LeadInputFieldView, Object.assign({}, defaultProps, { states: {
34
+ ...defaultProps.states,
35
+ leadFormState: {
36
+ ...defaultProps.states.leadFormState,
37
+ disabled: true,
38
+ },
39
+ } })));
40
+ export const WithInitialValue = () => (h(LeadInputFieldView, Object.assign({}, defaultProps, { states: {
41
+ ...defaultProps.states,
42
+ leadFormState: {
43
+ ...defaultProps.states.leadFormState,
44
+ initialData: {
45
+ firstName: "Jane",
46
+ },
47
+ },
48
+ } })));
@@ -0,0 +1,65 @@
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
+ const style = {
6
+ ErrorStyle: {
7
+ "--sl-input-border-color": "var(--sl-color-danger-500)",
8
+ "--sl-input-background-color": "var(--sl-color-danger-10)",
9
+ "--sl-input-border-color-focus": "var(--sl-color-danger-500)",
10
+ "--sl-input-border-color-hover": "var(--sl-color-danger-500)",
11
+ },
12
+ ErrorMessageStyle: {
13
+ margin: 0,
14
+ color: "var(--sl-color-danger-500)",
15
+ fontSize: "var(--sl-input-help-text-font-size-medium)",
16
+ },
17
+ FieldContainer: {
18
+ "margin-bottom": "var(--sl-spacing-large)",
19
+ },
20
+ };
21
+ const vanillaStyle = `
22
+ :host {
23
+ margin: 0 auto;
24
+ width: 100%;
25
+ display: block;
26
+ }
27
+ sl-select::part(label){
28
+ font-size: var(--sl-input-label-font-size-small);
29
+ font-weight: var(--sl-font-weight-semibold);
30
+ }
31
+ `;
32
+ jss.setup(preset());
33
+ const sheet = jss.createStyleSheet(style);
34
+ const styleString = sheet.toString();
35
+ export function LeadDropdownFieldView(props) {
36
+ var _a, _b, _c, _d, _e, _f, _g;
37
+ const { states, content } = props;
38
+ const validationErrors = (_a = states === null || states === void 0 ? void 0 : states.leadFormState) === null || _a === void 0 ? void 0 : _a.validationErrors;
39
+ const getRequiredFieldErrorMessage = ({ dropdownLabel, }) => intl.formatMessage({
40
+ id: "requiredFieldErrorMessage",
41
+ defaultMessage: content.requiredFieldErrorMessage,
42
+ }, {
43
+ dropdownLabel,
44
+ });
45
+ return (h("div", { class: sheet.classes.FieldContainer, part: "sqm-base" },
46
+ h("style", { type: "text/css" },
47
+ vanillaStyle,
48
+ styleString),
49
+ h("sl-select", Object.assign({ exportparts: "label: input-label, base: input-base", label: content.dropdownLabel, name: `/${content.dropdownName}` }, (!content.dropdownOptional ? { required: true } : []), { disabled: ((_b = states.leadFormState) === null || _b === void 0 ? void 0 : _b.loading) || ((_c = states.leadFormState) === null || _c === void 0 ? void 0 : _c.disabled), validationError: ({ value }) => {
50
+ if (!value) {
51
+ return getRequiredFieldErrorMessage({
52
+ dropdownLabel: content.dropdownLabel,
53
+ });
54
+ }
55
+ } }, (((_e = (_d = states.leadFormState) === null || _d === void 0 ? void 0 : _d.validationErrors) === null || _e === void 0 ? void 0 : _e.firstName) ? {
56
+ class: sheet.classes.ErrorStyle,
57
+ helpText: ((_g = (_f = states.leadFormState) === null || _f === void 0 ? void 0 : _f.validationErrors) === null || _g === void 0 ? void 0 : _g.firstName) ||
58
+ content.requiredFieldErrorMessage,
59
+ }
60
+ : [])), content.selectOptions),
61
+ (validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors[content.dropdownName]) && (h("p", { class: sheet.classes.ErrorMessageStyle }, intl.formatMessage({
62
+ id: `errorMessage-${content.dropdownName}`,
63
+ defaultMessage: content.requiredFieldErrorMessage,
64
+ })))));
65
+ }
@@ -0,0 +1,199 @@
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 { LeadDropdownFieldView, } from "./sqm-lead-dropdown-field-view";
8
+ import { useLeadDropdownField } from "./useLeadDropdownField";
9
+ /**
10
+ * @uiName Lead Form Dropdown Field
11
+ * @validParents ["sqm-lead-form"]
12
+ * @slots [{"name":"", "title":"Drop Down Option"}]
13
+ * @exampleGroup Microsite Components
14
+ * @example Lead Form Dropdown Field - <sqm-lead-dropdown-field dropdown-label="Select an option" required-field-error-message="Please select an option"><sl-menu-item value="option-1">Option 1</sl-menu-item><sl-menu-item value="option-2">Option 2</sl-menu-item><sl-menu-item value="option-3">Option 3</sl-menu-item></sqm-lead-dropdown-field>
15
+ */
16
+ export class LeadDropdownField {
17
+ constructor() {
18
+ this.ignored = true;
19
+ /**
20
+ * @uiName Dropdown label
21
+ */
22
+ this.dropdownLabel = "Select an option";
23
+ /**
24
+ * The message to be displayed when a required field is not filled.
25
+ *
26
+ * @uiName Required field message
27
+ * @uiWidget textArea
28
+ */
29
+ this.requiredFieldErrorMessage = "Please select a {dropdownLabel}";
30
+ /**
31
+ * @uiName Optional
32
+ * @default
33
+ */
34
+ this.dropdownOptional = false;
35
+ withHooks(this);
36
+ }
37
+ disconnectedCallback() { }
38
+ render() {
39
+ const missingProps = getMissingProps([
40
+ {
41
+ attribute: "dropdown-name",
42
+ value: this.dropdownName,
43
+ },
44
+ ]);
45
+ if (!isDemo() && missingProps) {
46
+ return (h(RequiredPropsError, { missingProps: missingProps, heading: "An error occured while loading this form", subheading: "A technical problem prevented this drop down field from loading. Please contact us with the link to this page.", description: "Values for the following attributes are missing:" },
47
+ h("slot", null)));
48
+ }
49
+ const content = {
50
+ ...getProps(this),
51
+ selectOptions: h("slot", null),
52
+ };
53
+ const { states } = isDemo()
54
+ ? useLeadDropdownFieldDemo(this)
55
+ : useLeadDropdownField();
56
+ return (h(LeadDropdownFieldView, { states: states, content: content }));
57
+ }
58
+ static get is() { return "sqm-lead-dropdown-field"; }
59
+ static get properties() { return {
60
+ "dropdownName": {
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": "Dropdown 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": "dropdown-name",
81
+ "reflect": false
82
+ },
83
+ "dropdownLabel": {
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": "Dropdown label",
96
+ "name": "uiName"
97
+ }],
98
+ "text": ""
99
+ },
100
+ "attribute": "dropdown-label",
101
+ "reflect": false,
102
+ "defaultValue": "\"Select an option\""
103
+ },
104
+ "requiredFieldErrorMessage": {
105
+ "type": "string",
106
+ "mutable": false,
107
+ "complexType": {
108
+ "original": "string",
109
+ "resolved": "string",
110
+ "references": {}
111
+ },
112
+ "required": false,
113
+ "optional": false,
114
+ "docs": {
115
+ "tags": [{
116
+ "text": "Required field message",
117
+ "name": "uiName"
118
+ }, {
119
+ "text": "textArea",
120
+ "name": "uiWidget"
121
+ }],
122
+ "text": "The message to be displayed when a required field is not filled."
123
+ },
124
+ "attribute": "required-field-error-message",
125
+ "reflect": false,
126
+ "defaultValue": "\"Please select a {dropdownLabel}\""
127
+ },
128
+ "dropdownOptional": {
129
+ "type": "boolean",
130
+ "mutable": false,
131
+ "complexType": {
132
+ "original": "boolean",
133
+ "resolved": "boolean",
134
+ "references": {}
135
+ },
136
+ "required": false,
137
+ "optional": true,
138
+ "docs": {
139
+ "tags": [{
140
+ "text": "Optional",
141
+ "name": "uiName"
142
+ }, {
143
+ "text": undefined,
144
+ "name": "default"
145
+ }],
146
+ "text": ""
147
+ },
148
+ "attribute": "dropdown-optional",
149
+ "reflect": false,
150
+ "defaultValue": "false"
151
+ },
152
+ "demoData": {
153
+ "type": "unknown",
154
+ "mutable": false,
155
+ "complexType": {
156
+ "original": "DemoData<DropdownFieldViewProps>",
157
+ "resolved": "{ states?: { leadFormState?: LeadFormState; }; content?: { dropdownName: string; dropdownLabel: string; dropdownOptional?: boolean; requiredFieldErrorMessage?: string; selectOptions?: VNode | VNode[]; }; }",
158
+ "references": {
159
+ "DemoData": {
160
+ "location": "import",
161
+ "path": "../../global/demo"
162
+ },
163
+ "DropdownFieldViewProps": {
164
+ "location": "import",
165
+ "path": "./sqm-lead-dropdown-field-view"
166
+ }
167
+ }
168
+ },
169
+ "required": false,
170
+ "optional": true,
171
+ "docs": {
172
+ "tags": [{
173
+ "text": undefined,
174
+ "name": "undocumented"
175
+ }, {
176
+ "text": "object",
177
+ "name": "uiType"
178
+ }],
179
+ "text": ""
180
+ }
181
+ }
182
+ }; }
183
+ static get states() { return {
184
+ "ignored": {}
185
+ }; }
186
+ }
187
+ function useLeadDropdownFieldDemo(props) {
188
+ return deepmerge({
189
+ states: {
190
+ leadFormState: {},
191
+ },
192
+ content: {
193
+ dropdownName: props.dropdownName,
194
+ dropdownLabel: props.dropdownLabel,
195
+ requiredFieldErrorMessage: props.requiredFieldErrorMessage,
196
+ dropdownOptional: props.dropdownOptional,
197
+ },
198
+ }, props.demoData || {}, { arrayMerge: (_, a) => a });
199
+ }
@@ -2,6 +2,7 @@ import { h } from "@stencil/core";
2
2
  import { AuthButtonsContainer, AuthColumn, AuthWrapper, ErrorStyles, HostBlock, } from "../../global/mixins";
3
3
  import { createStyleSheet } from "../../styling/JSS";
4
4
  import { TextSpanView } from "../sqm-text-span/sqm-text-span-view";
5
+ import { intl } from "../../global/global";
5
6
  const style = {
6
7
  Wrapper: { ...AuthWrapper, "max-width": "600px" },
7
8
  Column: AuthColumn,
@@ -10,7 +11,24 @@ const style = {
10
11
  margin: "0 auto",
11
12
  width: "100%",
12
13
  },
14
+ NameFieldWrapper: {
15
+ display: "flex",
16
+ gap: "var(--sl-spacing-medium)",
17
+ },
18
+ ContinueButton: { maxWidth: "169px" },
13
19
  ButtonsContainer: AuthButtonsContainer,
20
+ SuccessAlertContainer: {
21
+ "&::part(base)": {
22
+ backgroundColor: "var(--sl-color-green-100)",
23
+ borderTop: "none",
24
+ },
25
+ },
26
+ ErrorAlertContainer: {
27
+ "&::part(base)": {
28
+ backgroundColor: "var(--sl-color-red-100)",
29
+ borderTop: "none",
30
+ },
31
+ },
14
32
  ErrorStyle: ErrorStyles,
15
33
  };
16
34
  const vanillaStyle = `
@@ -31,53 +49,71 @@ sqm-portal-register {
31
49
  const sheet = createStyleSheet(style);
32
50
  const styleString = sheet.toString();
33
51
  export function LeadFormView(props) {
34
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
52
+ var _a, _b, _c, _d;
35
53
  const { states, refs, callbacks, content } = props;
54
+ console.log({ states });
36
55
  if (states.error) {
37
56
  window.scrollTo({ top: 0, left: 0, behavior: "smooth" });
38
57
  }
58
+ const getRequiredFieldErrorMessage = ({ fieldLabel, }) => intl.formatMessage({
59
+ id: "requiredFieldErrorMessage",
60
+ defaultMessage: content.requiredFieldErrorMessage,
61
+ }, {
62
+ fieldLabel,
63
+ });
64
+ if (states.success) {
65
+ return (h("div", { class: sheet.classes.Wrapper, part: "sqm-base" },
66
+ h("style", { type: "text/css" },
67
+ vanillaStyle,
68
+ styleString),
69
+ h(TextSpanView, { type: "h3" }, content.pageLabel),
70
+ h("sqm-form-message", { exportparts: "success-icon" },
71
+ h("b", null, content.submitSuccessHeader),
72
+ h("br", null),
73
+ 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
+ }
39
80
  return (h("div", { class: sheet.classes.Wrapper, part: "sqm-base" },
40
81
  h("style", { type: "text/css" },
41
82
  vanillaStyle,
42
83
  styleString),
43
84
  h(TextSpanView, { type: "h3" }, content.pageLabel),
44
85
  h("sl-form", { class: sheet.classes.Column, "onSl-submit": callbacks.submit, ref: (el) => (refs.formRef.current = el), novalidate: true },
45
- states.error && (h("sqm-form-message", { type: "error", exportparts: "erroralert-icon" },
46
- h("div", { part: "erroralert-text" }, props.states.error))),
47
- h("sl-input", Object.assign({ exportparts: "label: input-label, base: input-base", type: "text", name: "/lastName", label: content.firstNameLabel || "First Name", disabled: states.loading, required: true, validationError: ({ value }) => {
48
- if (!value) {
49
- return content.requiredFieldErrorMessage;
50
- }
51
- } }, (((_b = (_a = states.leadFormState) === null || _a === void 0 ? void 0 : _a.validationErrors) === null || _b === void 0 ? void 0 : _b.firstName) ? {
52
- class: sheet.classes.ErrorStyle,
53
- helpText: ((_d = (_c = states.leadFormState) === null || _c === void 0 ? void 0 : _c.validationErrors) === null || _d === void 0 ? void 0 : _d.firstName) ||
54
- content.requiredFieldErrorMessage,
55
- }
56
- : []))),
57
- h("sl-input", Object.assign({ exportparts: "label: input-label, base: input-base", type: "text", name: "/lastName", label: content.lastNameLabel || "Last Name", disabled: states.loading, required: true, validationError: ({ value }) => {
58
- if (!value) {
59
- return content.requiredFieldErrorMessage;
60
- }
61
- } }, (((_f = (_e = states.leadFormState) === null || _e === void 0 ? void 0 : _e.validationErrors) === null || _f === void 0 ? void 0 : _f.lastName) ? {
62
- class: sheet.classes.ErrorStyle,
63
- helpText: ((_h = (_g = states.leadFormState) === null || _g === void 0 ? void 0 : _g.validationErrors) === null || _h === void 0 ? void 0 : _h.lastName) ||
64
- content.requiredFieldErrorMessage,
65
- }
66
- : []))),
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" })),
67
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 }) => {
68
100
  if (!value) {
69
- return content.requiredFieldErrorMessage;
101
+ return getRequiredFieldErrorMessage({
102
+ fieldLabel: content.emailLabel || "Email",
103
+ });
70
104
  }
71
105
  // this matches shoelace validation, but could be better
72
106
  if (!value.includes("@")) {
73
107
  return content.invalidEmailErrorMessage;
74
108
  }
75
- } }, (((_k = (_j = states.leadFormState) === null || _j === void 0 ? void 0 : _j.validationErrors) === null || _k === void 0 ? void 0 : _k.email) ? {
109
+ } }, (((_b = (_a = states.leadFormState) === null || _a === void 0 ? void 0 : _a.validationErrors) === null || _b === void 0 ? void 0 : _b.email) ? {
76
110
  class: sheet.classes.ErrorStyle,
77
- helpText: ((_m = (_l = states.leadFormState) === null || _l === void 0 ? void 0 : _l.validationErrors) === null || _m === void 0 ? void 0 : _m.email) ||
111
+ helpText: ((_d = (_c = states.leadFormState) === null || _c === void 0 ? void 0 : _c.validationErrors) === null || _d === void 0 ? void 0 : _d.email) ||
78
112
  content.requiredFieldErrorMessage,
79
113
  }
80
114
  : []))),
81
115
  h("input", { type: "hidden", hidden: true, name: "/rsReferralCode", value: states.referralCode }),
82
- content.formData)));
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
119
  }