@saasquatch/mint-components 1.14.6-1 → 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.
- package/dist/cjs/{ShadowViewAddon-c0a5fdf8.js → ShadowViewAddon-40f0bc74.js} +58 -26
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mint-components.cjs.js +1 -1
- package/dist/cjs/sqm-big-stat_42.cjs.entry.js +85 -117
- package/dist/cjs/sqm-lead-dropdown-field-view-03a3e03f.js +69 -0
- package/dist/cjs/sqm-lead-dropdown-field.cjs.entry.js +75 -0
- package/dist/cjs/sqm-lead-input-field-view-6344cd93.js +51 -0
- package/dist/cjs/sqm-lead-input-field.cjs.entry.js +78 -0
- package/dist/cjs/sqm-stencilbook.cjs.entry.js +166 -49
- package/dist/cjs/useLeadFormState-c83d2034.js +72 -0
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/sqm-lead-form/LeadForm.stories.js +34 -46
- package/dist/collection/components/sqm-lead-form/LeadFormDropdownField.stories.js +59 -0
- package/dist/collection/components/sqm-lead-form/LeadInputField.stories.js +48 -0
- package/dist/collection/components/sqm-lead-form/sqm-lead-dropdown-field-view.js +65 -0
- package/dist/collection/components/sqm-lead-form/sqm-lead-dropdown-field.js +193 -0
- package/dist/collection/components/sqm-lead-form/sqm-lead-form-view.js +59 -26
- package/dist/collection/components/sqm-lead-form/sqm-lead-form.js +147 -36
- package/dist/collection/components/sqm-lead-form/sqm-lead-input-field-view.js +47 -0
- package/dist/collection/components/sqm-lead-form/sqm-lead-input-field.js +222 -0
- package/dist/collection/components/sqm-lead-form/useLeadDropdownField.js +10 -0
- package/dist/collection/components/sqm-lead-form/useLeadForm.js +9 -6
- package/dist/collection/components/sqm-lead-form/useLeadInputField.js +10 -0
- package/dist/collection/components/sqm-stencilbook/sqm-stencilbook.js +4 -0
- package/dist/esm/{ShadowViewAddon-aa7177fe.js → ShadowViewAddon-8a0d9e83.js} +58 -26
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mint-components.js +1 -1
- package/dist/esm/sqm-big-stat_42.entry.js +82 -114
- package/dist/esm/sqm-lead-dropdown-field-view-4c85fe20.js +67 -0
- package/dist/esm/sqm-lead-dropdown-field.entry.js +71 -0
- package/dist/esm/sqm-lead-input-field-view-f1dd4b77.js +49 -0
- package/dist/esm/sqm-lead-input-field.entry.js +74 -0
- package/dist/esm/sqm-stencilbook.entry.js +166 -49
- package/dist/esm/useLeadFormState-9016d812.js +68 -0
- package/dist/esm-es5/{ShadowViewAddon-aa7177fe.js → ShadowViewAddon-8a0d9e83.js} +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/mint-components.js +1 -1
- package/dist/esm-es5/sqm-big-stat_42.entry.js +1 -1
- package/dist/esm-es5/sqm-lead-dropdown-field-view-4c85fe20.js +1 -0
- package/dist/esm-es5/sqm-lead-dropdown-field.entry.js +1 -0
- package/dist/esm-es5/sqm-lead-input-field-view-f1dd4b77.js +1 -0
- package/dist/esm-es5/sqm-lead-input-field.entry.js +1 -0
- package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
- package/dist/esm-es5/useLeadFormState-9016d812.js +1 -0
- package/dist/mint-components/mint-components.esm.js +1 -1
- package/dist/mint-components/p-13c67985.system.entry.js +1 -0
- package/dist/mint-components/p-15f1ff1d.system.js +1 -0
- package/dist/mint-components/p-1d704c40.system.js +1 -0
- package/dist/mint-components/p-26da31c6.js +1 -0
- package/dist/mint-components/p-37996351.system.js +1 -1
- package/dist/mint-components/{p-373a92a2.js → p-4139feb5.js} +3 -3
- package/dist/mint-components/p-4d5b02af.js +1 -0
- package/dist/mint-components/p-87384d9e.system.js +1 -0
- package/dist/mint-components/p-875861d7.system.entry.js +1 -0
- package/dist/mint-components/p-8af8ab01.system.entry.js +1 -0
- package/dist/mint-components/p-9e1570bf.system.entry.js +1 -0
- package/dist/mint-components/{p-72e5e84f.system.js → p-ad6420a2.system.js} +1 -1
- package/dist/mint-components/p-b8c15858.entry.js +1 -0
- package/dist/mint-components/{p-8dc110b0.entry.js → p-cd1c6113.entry.js} +2 -2
- package/dist/mint-components/p-e358f0c1.entry.js +265 -0
- package/dist/mint-components/p-f59d6012.entry.js +1 -0
- package/dist/mint-components/p-f98a4354.js +1 -0
- package/dist/types/components/sqm-lead-form/LeadForm.stories.d.ts +1 -0
- package/dist/types/components/sqm-lead-form/LeadFormDropdownField.stories.d.ts +9 -0
- package/dist/types/components/sqm-lead-form/LeadInputField.stories.d.ts +8 -0
- package/dist/types/components/sqm-lead-form/sqm-lead-dropdown-field-view.d.ts +15 -0
- package/dist/types/components/sqm-lead-form/sqm-lead-dropdown-field.d.ts +42 -0
- package/dist/types/components/sqm-lead-form/sqm-lead-form-view.d.ts +7 -0
- package/dist/types/components/sqm-lead-form/sqm-lead-form.d.ts +24 -7
- package/dist/types/components/sqm-lead-form/sqm-lead-input-field-view.d.ts +14 -0
- package/dist/types/components/sqm-lead-form/sqm-lead-input-field.d.ts +49 -0
- package/dist/types/components/sqm-lead-form/useLeadDropdownField.d.ts +6 -0
- package/dist/types/components/sqm-lead-form/useLeadForm.d.ts +4 -0
- package/dist/types/components/sqm-lead-form/useLeadInputField.d.ts +6 -0
- package/dist/types/components.d.ts +194 -12
- package/docs/docs.docx +0 -0
- package/docs/raisins.json +1 -1
- package/grapesjs/grapesjs.js +1 -1
- package/package.json +1 -1
- package/dist/mint-components/p-02a6e0df.system.entry.js +0 -1
- package/dist/mint-components/p-cde11800.system.entry.js +0 -1
- package/dist/mint-components/p-ede3d2f9.entry.js +0 -265
- package/dist/types/global/android.d.ts +0 -7
- package/dist/types/global/demo.d.ts +0 -2
- package/dist/types/stories/features.d.ts +0 -4
- package/dist/types/stories/templates.d.ts +0 -4
|
@@ -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,193 @@
|
|
|
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
|
+
}, props.demoData || {}, { arrayMerge: (_, a) => a });
|
|
193
|
+
}
|
|
@@ -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,50 +49,65 @@ 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
|
|
52
|
+
var _a, _b, _c, _d;
|
|
35
53
|
const { states, refs, callbacks, content } = props;
|
|
36
54
|
if (states.error) {
|
|
37
55
|
window.scrollTo({ top: 0, left: 0, behavior: "smooth" });
|
|
38
56
|
}
|
|
57
|
+
const getRequiredFieldErrorMessage = ({ fieldLabel, }) => intl.formatMessage({
|
|
58
|
+
id: "requiredFieldErrorMessage",
|
|
59
|
+
defaultMessage: content.requiredFieldErrorMessage,
|
|
60
|
+
}, {
|
|
61
|
+
fieldLabel,
|
|
62
|
+
});
|
|
63
|
+
if (states.success) {
|
|
64
|
+
return (h("div", { class: sheet.classes.Wrapper, part: "sqm-base" },
|
|
65
|
+
h("style", { type: "text/css" },
|
|
66
|
+
vanillaStyle,
|
|
67
|
+
styleString),
|
|
68
|
+
h(TextSpanView, { type: "h3" }, content.pageLabel),
|
|
69
|
+
h("sqm-form-message", { exportparts: "success-icon" },
|
|
70
|
+
h("b", null, content.submitSuccessHeader),
|
|
71
|
+
h("br", null),
|
|
72
|
+
h("div", { part: "successalert-text" }, content.submitSuccessDescription)),
|
|
73
|
+
h("sl-button", {
|
|
74
|
+
// AL: TODO add button to allow user to submit another form
|
|
75
|
+
class: sheet.classes.ContinueButton,
|
|
76
|
+
// onClick={callbacks.submitAnotherForm}
|
|
77
|
+
loading: states.loading, exportparts: "base: primarybutton-base", type: "default" }, content.resubmitFormLabel)));
|
|
78
|
+
}
|
|
39
79
|
return (h("div", { class: sheet.classes.Wrapper, part: "sqm-base" },
|
|
40
80
|
h("style", { type: "text/css" },
|
|
41
81
|
vanillaStyle,
|
|
42
82
|
styleString),
|
|
43
83
|
h(TextSpanView, { type: "h3" }, content.pageLabel),
|
|
44
84
|
h("sl-form", { class: sheet.classes.Column, "onSl-submit": callbacks.submit, ref: (el) => (refs.formRef.current = el), novalidate: true },
|
|
45
|
-
states.error && (h("
|
|
46
|
-
h("
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
:
|
|
57
|
-
|
|
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
|
-
: []))),
|
|
85
|
+
states.error && (h("sl-alert", { exportparts: "base: alert-base, icon:alert-icon", type: "danger", class: sheet.classes.ErrorAlertContainer, open: true },
|
|
86
|
+
h("sl-icon", { slot: "icon", name: "exclamation-octagon" }),
|
|
87
|
+
h("b", null, content.submitErrorHeader),
|
|
88
|
+
h("br", null),
|
|
89
|
+
intl.formatMessage({
|
|
90
|
+
id: "submitErrorDescription",
|
|
91
|
+
defaultMessage: content.submitErrorDescription,
|
|
92
|
+
}, {
|
|
93
|
+
supportLink: (h("a", { target: "_blank", href: `mailto:advocate-support@impact.com` }, content.supportLink)),
|
|
94
|
+
}))),
|
|
95
|
+
h("div", { class: sheet.classes.NameFieldWrapper },
|
|
96
|
+
h("sqm-lead-input-field", { style: { width: "50%" }, "field-label": "First Name", "field-name": "firstName" }),
|
|
97
|
+
h("sqm-lead-input-field", { style: { width: "50%" }, "field-label": "Last Name", "field-name": "lastName" })),
|
|
67
98
|
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
99
|
if (!value) {
|
|
69
|
-
return
|
|
100
|
+
return getRequiredFieldErrorMessage({
|
|
101
|
+
fieldLabel: content.emailLabel || "Email",
|
|
102
|
+
});
|
|
70
103
|
}
|
|
71
104
|
// this matches shoelace validation, but could be better
|
|
72
105
|
if (!value.includes("@")) {
|
|
73
106
|
return content.invalidEmailErrorMessage;
|
|
74
107
|
}
|
|
75
|
-
} }, (((
|
|
108
|
+
} }, (((_b = (_a = states.leadFormState) === null || _a === void 0 ? void 0 : _a.validationErrors) === null || _b === void 0 ? void 0 : _b.email) ? {
|
|
76
109
|
class: sheet.classes.ErrorStyle,
|
|
77
|
-
helpText: ((
|
|
110
|
+
helpText: ((_d = (_c = states.leadFormState) === null || _c === void 0 ? void 0 : _c.validationErrors) === null || _d === void 0 ? void 0 : _d.email) ||
|
|
78
111
|
content.requiredFieldErrorMessage,
|
|
79
112
|
}
|
|
80
113
|
: []))),
|