@saasquatch/mint-components 1.14.6 → 1.14.7-1
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/loader.cjs.js +1 -1
- package/dist/cjs/mint-components.cjs.js +1 -1
- package/dist/cjs/sqm-big-stat_43.cjs.entry.js +1 -1
- package/dist/cjs/sqm-lead-checkbox-field.cjs.entry.js +171 -0
- package/dist/cjs/sqm-lead-input-field.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/sqm-lead-form/LeadCheckboxField.stories.js +103 -0
- package/dist/collection/components/sqm-lead-form/sqm-lead-checkbox-field-view.js +78 -0
- package/dist/collection/components/sqm-lead-form/sqm-lead-checkbox-field.js +238 -0
- package/dist/collection/components/sqm-lead-form/useCheckboxField.js +23 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mint-components.js +1 -1
- package/dist/esm/sqm-big-stat_43.entry.js +1 -1
- package/dist/esm/sqm-lead-checkbox-field.entry.js +167 -0
- package/dist/esm/sqm-lead-input-field.entry.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_43.entry.js +1 -1
- package/dist/esm-es5/sqm-lead-checkbox-field.entry.js +1 -0
- package/dist/esm-es5/sqm-lead-input-field.entry.js +1 -1
- package/dist/mint-components/mint-components.esm.js +1 -1
- package/dist/mint-components/p-10a8ecae.system.entry.js +1 -0
- package/dist/mint-components/{p-d3e72503.entry.js → p-12bba567.entry.js} +1 -1
- package/dist/mint-components/p-37996351.system.js +1 -1
- package/dist/mint-components/p-48ad59a8.system.entry.js +1 -0
- package/dist/mint-components/p-550346bd.entry.js +1 -0
- package/dist/mint-components/{p-0a4f1306.entry.js → p-851eaf57.entry.js} +10 -10
- package/dist/mint-components/{p-fbbb85f0.system.entry.js → p-8c0b7881.system.entry.js} +1 -1
- package/dist/types/components/sqm-lead-form/LeadCheckboxField.stories.d.ts +55 -0
- package/dist/types/components/sqm-lead-form/sqm-lead-checkbox-field-view.d.ts +20 -0
- package/dist/types/components/sqm-lead-form/sqm-lead-checkbox-field.d.ts +46 -0
- package/dist/types/components/sqm-lead-form/useCheckboxField.d.ts +11 -0
- package/dist/types/components.d.ts +80 -0
- 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-74fdf750.system.entry.js +0 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { PortalRegisterView, } from "../sqm-portal-register/sqm-portal-register-view";
|
|
3
|
+
import { createHookStory } from "../sqm-stencilbook/HookStoryAddon";
|
|
4
|
+
import { LeadCheckboxFieldView, } from "./sqm-lead-checkbox-field-view";
|
|
5
|
+
import scenario from "./sqm-checkbox-field.feature";
|
|
6
|
+
export default {
|
|
7
|
+
title: "Components/Checkbox Field",
|
|
8
|
+
parameters: {
|
|
9
|
+
scenario,
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
const defaultProps = {
|
|
13
|
+
states: {
|
|
14
|
+
leadFormState: {
|
|
15
|
+
validationErrors: {},
|
|
16
|
+
},
|
|
17
|
+
checked: false,
|
|
18
|
+
},
|
|
19
|
+
content: {
|
|
20
|
+
checkboxName: "terms",
|
|
21
|
+
checkboxLabel: "By signing up you agree to the {labelLink}",
|
|
22
|
+
checkboxLabelLink: "https://example.com",
|
|
23
|
+
checkboxLabelLinkText: "Terms and Conditions",
|
|
24
|
+
errorMessage: "Must be checked",
|
|
25
|
+
},
|
|
26
|
+
callbacks: {
|
|
27
|
+
setChecked: () => { },
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
const defaultRegisterProps = {
|
|
31
|
+
states: {
|
|
32
|
+
registrationFormState: {},
|
|
33
|
+
error: "",
|
|
34
|
+
loading: false,
|
|
35
|
+
confirmPassword: true,
|
|
36
|
+
hideInputs: false,
|
|
37
|
+
loginPath: "/login",
|
|
38
|
+
},
|
|
39
|
+
callbacks: {
|
|
40
|
+
submit: () => console.log("Submit!"),
|
|
41
|
+
inputFunction: () => { },
|
|
42
|
+
},
|
|
43
|
+
refs: {
|
|
44
|
+
formRef: {},
|
|
45
|
+
},
|
|
46
|
+
content: {
|
|
47
|
+
pageLabel: "Register",
|
|
48
|
+
confirmPasswordLabel: "Confirm Password",
|
|
49
|
+
requiredFieldErrorMessage: "Cannot be empty",
|
|
50
|
+
invalidEmailErrorMessage: "Must be a valid email address",
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
export const Default = createHookStory(() => (h(LeadCheckboxFieldView, Object.assign({}, defaultProps))));
|
|
54
|
+
export const DefaultChecked = createHookStory(() => (h(LeadCheckboxFieldView, Object.assign({}, defaultProps, { states: {
|
|
55
|
+
...defaultProps.states,
|
|
56
|
+
checked: true,
|
|
57
|
+
} }))));
|
|
58
|
+
export const CustomLabel = createHookStory(() => (h(LeadCheckboxFieldView, Object.assign({}, defaultProps, { content: {
|
|
59
|
+
...defaultProps.content,
|
|
60
|
+
checkboxLabel: "I Agree",
|
|
61
|
+
} }))));
|
|
62
|
+
export const Error = createHookStory(() => (h(LeadCheckboxFieldView, Object.assign({}, defaultProps, { states: {
|
|
63
|
+
...defaultProps.states,
|
|
64
|
+
leadFormState: {
|
|
65
|
+
validationErrors: {
|
|
66
|
+
agree: "Must be checked",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
} }))));
|
|
70
|
+
export const CustomError = createHookStory(() => (h(LeadCheckboxFieldView, Object.assign({}, defaultProps, { states: {
|
|
71
|
+
...defaultProps.states,
|
|
72
|
+
leadFormState: {
|
|
73
|
+
validationErrors: {
|
|
74
|
+
agree: "Must be checked",
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
}, content: {
|
|
78
|
+
...defaultProps.content,
|
|
79
|
+
errorMessage: "This checkbox must be checked to continue",
|
|
80
|
+
} }))));
|
|
81
|
+
export const TermsAndConditions = createHookStory(() => (h(PortalRegisterView, Object.assign({}, defaultRegisterProps, {
|
|
82
|
+
//@ts-ignore
|
|
83
|
+
content: {
|
|
84
|
+
...defaultRegisterProps.content,
|
|
85
|
+
terms: (h("p", null,
|
|
86
|
+
h("sqm-checkbox-field", null))),
|
|
87
|
+
} }))));
|
|
88
|
+
export const TermsAndConditionsCustomLabel = createHookStory(() => (h(PortalRegisterView, Object.assign({}, defaultRegisterProps, {
|
|
89
|
+
//@ts-ignore
|
|
90
|
+
content: {
|
|
91
|
+
...defaultRegisterProps.content,
|
|
92
|
+
terms: (h("p", null,
|
|
93
|
+
"By signing up you agree to the",
|
|
94
|
+
" ",
|
|
95
|
+
h("a", { href: "https://example.com", target: "_blank" }, "Terms and Conditions"),
|
|
96
|
+
h("sqm-checkbox-field", { "checkbox-label": "I agree" }))),
|
|
97
|
+
} }))));
|
|
98
|
+
export const TermsAndConditionsLongCustomLabel = createHookStory(() => (h(PortalRegisterView, Object.assign({}, defaultRegisterProps, {
|
|
99
|
+
//@ts-ignore
|
|
100
|
+
content: {
|
|
101
|
+
...defaultRegisterProps.content,
|
|
102
|
+
terms: (h("sqm-checkbox-field", { "checkbox-label": "Participants must be at least 18 years of age and a legal resident of the U.S. or Canada. By signing up to participate in the rewards program, you agree to the {labelLink}.", "checkbox-label-link": "https://www.example.com", "checkbox-label-link-text": "terms", "checkbox-name": "termsAndConditions" })),
|
|
103
|
+
} }))));
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
"&::part(control)": {
|
|
8
|
+
background: "var(--sl-color-danger-10)",
|
|
9
|
+
borderColor: "var(--sl-color-danger-500)",
|
|
10
|
+
outline: "var(--sl-color-danger-500)",
|
|
11
|
+
},
|
|
12
|
+
"&:host": {
|
|
13
|
+
"--focus-ring": "0 0 0 var(--sl-focus-ring-width) red !important",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
ErrorMessageStyle: {
|
|
17
|
+
margin: 0,
|
|
18
|
+
marginTop: "5px",
|
|
19
|
+
color: "var(--sl-color-danger-500)",
|
|
20
|
+
fontSize: "var(--sl-input-help-text-font-size-medium)",
|
|
21
|
+
fontFamily: "var(--sl-font-sans)",
|
|
22
|
+
fontWeight: "var(--sl-font-weight-normal)",
|
|
23
|
+
},
|
|
24
|
+
FieldContainer: {
|
|
25
|
+
"margin-bottom": "var(--sl-spacing-large)",
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
const vanillaStyle = `
|
|
29
|
+
:host {
|
|
30
|
+
margin: 0 auto;
|
|
31
|
+
width: 100%;
|
|
32
|
+
display: block;
|
|
33
|
+
}
|
|
34
|
+
sl-checkbox::part(label){
|
|
35
|
+
font-size: var(--sl-input-label-font-size-small);
|
|
36
|
+
font-weight: var(--sl-font-weight-normal);
|
|
37
|
+
line-height: 20px;
|
|
38
|
+
}
|
|
39
|
+
sl-checkbox::part(base){
|
|
40
|
+
align-items: start;
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
jss.setup(preset());
|
|
44
|
+
const sheet = jss.createStyleSheet(style);
|
|
45
|
+
const styleString = sheet.toString();
|
|
46
|
+
export function LeadCheckboxFieldView(props) {
|
|
47
|
+
var _a, _b, _c, _d, _e, _f;
|
|
48
|
+
const { states, content, callbacks } = props;
|
|
49
|
+
const getRequiredFieldErrorMessage = ({ checkboxLabel, }) => intl.formatMessage({
|
|
50
|
+
id: `requiredFieldErrorMessage-${checkboxLabel}`,
|
|
51
|
+
defaultMessage: content.requiredFieldErrorMessage,
|
|
52
|
+
}, {
|
|
53
|
+
checkboxLabel,
|
|
54
|
+
});
|
|
55
|
+
return (h("div", { class: sheet.classes.FieldContainer, part: "sqm-base" },
|
|
56
|
+
h("style", { type: "text/css" },
|
|
57
|
+
vanillaStyle,
|
|
58
|
+
styleString),
|
|
59
|
+
h("sl-checkbox", Object.assign({ exportparts: "label: input-label, base: input-base", name: `/${content.checkboxName}`, checked: states.checked, "onSl-change": (e) => {
|
|
60
|
+
e.target.value = e.target.checked;
|
|
61
|
+
callbacks.setChecked(e.target.value);
|
|
62
|
+
} }, (!content.checkboxOptional ? { required: false } : []), { 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 }) => {
|
|
63
|
+
if (!value && !content.checkboxOptional) {
|
|
64
|
+
return getRequiredFieldErrorMessage({
|
|
65
|
+
checkboxLabel: content.checkboxLabel,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
} }, (((_d = (_c = states.leadFormState) === null || _c === void 0 ? void 0 : _c.validationErrors) === null || _d === void 0 ? void 0 : _d[content.checkboxName]) ? {
|
|
69
|
+
class: sheet.classes.ErrorStyle,
|
|
70
|
+
helpText: ((_f = (_e = states.leadFormState) === null || _e === void 0 ? void 0 : _e.validationErrors) === null || _f === void 0 ? void 0 : _f[content.checkboxName]) || content.requiredFieldErrorMessage,
|
|
71
|
+
}
|
|
72
|
+
: [])), intl.formatMessage({
|
|
73
|
+
id: content.checkboxName + "-message",
|
|
74
|
+
defaultMessage: content.checkboxLabel,
|
|
75
|
+
}, {
|
|
76
|
+
labelLink: (h("a", { href: content.checkboxLabelLink, target: "_blank" }, content.checkboxLabelLinkText || content.checkboxLabelLink)),
|
|
77
|
+
}))));
|
|
78
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
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 { LeadCheckboxFieldView, } from "./sqm-lead-checkbox-field-view";
|
|
8
|
+
import { useLeadCheckboxField } from "./useCheckboxField";
|
|
9
|
+
/**
|
|
10
|
+
* @uiName Lead Form Checkbox Field
|
|
11
|
+
* @validParents ["sqm-lead-form"]
|
|
12
|
+
*/
|
|
13
|
+
export class LeadCheckboxField {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.ignored = true;
|
|
16
|
+
/**
|
|
17
|
+
* @uiName Checkbox label
|
|
18
|
+
* @uiWidget textArea
|
|
19
|
+
*/
|
|
20
|
+
this.checkboxLabel = "By signing up you agree to the {labelLink}";
|
|
21
|
+
/**
|
|
22
|
+
* Used with link text if the checkbox label contains {labelLink}
|
|
23
|
+
*
|
|
24
|
+
* @uiName Checkbox label link
|
|
25
|
+
*/
|
|
26
|
+
this.checkboxLabelLink = "https://example.com";
|
|
27
|
+
/**
|
|
28
|
+
* @uiName Checkbox label link lext
|
|
29
|
+
*/
|
|
30
|
+
this.checkboxLabelLinkText = "Terms and Conditions";
|
|
31
|
+
/**
|
|
32
|
+
* @uiName Unchecked error message
|
|
33
|
+
*/
|
|
34
|
+
this.errorMessage = "Must be checked";
|
|
35
|
+
/**
|
|
36
|
+
* @uiName Optional
|
|
37
|
+
*/
|
|
38
|
+
this.checkboxOptional = false;
|
|
39
|
+
withHooks(this);
|
|
40
|
+
}
|
|
41
|
+
disconnectedCallback() { }
|
|
42
|
+
render() {
|
|
43
|
+
const missingProps = getMissingProps([
|
|
44
|
+
{
|
|
45
|
+
attribute: "checkbox-name",
|
|
46
|
+
value: this.checkboxName,
|
|
47
|
+
},
|
|
48
|
+
]);
|
|
49
|
+
if (!isDemo() && missingProps) {
|
|
50
|
+
return (h(RequiredPropsError, { missingProps: missingProps, heading: "An error occured while loading this form", subheading: "A technical problem prevented this checkbox field from loading. Please contact us with the link to this page.", description: "Values for the following attributes are missing:" }));
|
|
51
|
+
}
|
|
52
|
+
const content = {
|
|
53
|
+
...getProps(this),
|
|
54
|
+
};
|
|
55
|
+
const { states, callbacks } = isDemo()
|
|
56
|
+
? useLeadCheckboxFieldDemo(this)
|
|
57
|
+
: useLeadCheckboxField(this);
|
|
58
|
+
return (h(LeadCheckboxFieldView, { states: states, content: content, callbacks: callbacks }));
|
|
59
|
+
}
|
|
60
|
+
static get is() { return "sqm-lead-checkbox-field"; }
|
|
61
|
+
static get properties() { return {
|
|
62
|
+
"checkboxName": {
|
|
63
|
+
"type": "string",
|
|
64
|
+
"mutable": false,
|
|
65
|
+
"complexType": {
|
|
66
|
+
"original": "string",
|
|
67
|
+
"resolved": "string",
|
|
68
|
+
"references": {}
|
|
69
|
+
},
|
|
70
|
+
"required": false,
|
|
71
|
+
"optional": false,
|
|
72
|
+
"docs": {
|
|
73
|
+
"tags": [{
|
|
74
|
+
"text": "Checkbox name attribute",
|
|
75
|
+
"name": "uiName"
|
|
76
|
+
}, {
|
|
77
|
+
"text": undefined,
|
|
78
|
+
"name": "required"
|
|
79
|
+
}],
|
|
80
|
+
"text": "This name is used as the key for this form field on submission. The name must be unique within this specific form."
|
|
81
|
+
},
|
|
82
|
+
"attribute": "checkbox-name",
|
|
83
|
+
"reflect": false
|
|
84
|
+
},
|
|
85
|
+
"checkboxLabel": {
|
|
86
|
+
"type": "string",
|
|
87
|
+
"mutable": false,
|
|
88
|
+
"complexType": {
|
|
89
|
+
"original": "string",
|
|
90
|
+
"resolved": "string",
|
|
91
|
+
"references": {}
|
|
92
|
+
},
|
|
93
|
+
"required": false,
|
|
94
|
+
"optional": false,
|
|
95
|
+
"docs": {
|
|
96
|
+
"tags": [{
|
|
97
|
+
"text": "Checkbox label",
|
|
98
|
+
"name": "uiName"
|
|
99
|
+
}, {
|
|
100
|
+
"text": "textArea",
|
|
101
|
+
"name": "uiWidget"
|
|
102
|
+
}],
|
|
103
|
+
"text": ""
|
|
104
|
+
},
|
|
105
|
+
"attribute": "checkbox-label",
|
|
106
|
+
"reflect": false,
|
|
107
|
+
"defaultValue": "\"By signing up you agree to the {labelLink}\""
|
|
108
|
+
},
|
|
109
|
+
"checkboxLabelLink": {
|
|
110
|
+
"type": "string",
|
|
111
|
+
"mutable": false,
|
|
112
|
+
"complexType": {
|
|
113
|
+
"original": "string",
|
|
114
|
+
"resolved": "string",
|
|
115
|
+
"references": {}
|
|
116
|
+
},
|
|
117
|
+
"required": false,
|
|
118
|
+
"optional": true,
|
|
119
|
+
"docs": {
|
|
120
|
+
"tags": [{
|
|
121
|
+
"text": "Checkbox label link",
|
|
122
|
+
"name": "uiName"
|
|
123
|
+
}],
|
|
124
|
+
"text": "Used with link text if the checkbox label contains {labelLink}"
|
|
125
|
+
},
|
|
126
|
+
"attribute": "checkbox-label-link",
|
|
127
|
+
"reflect": false,
|
|
128
|
+
"defaultValue": "\"https://example.com\""
|
|
129
|
+
},
|
|
130
|
+
"checkboxLabelLinkText": {
|
|
131
|
+
"type": "string",
|
|
132
|
+
"mutable": false,
|
|
133
|
+
"complexType": {
|
|
134
|
+
"original": "string",
|
|
135
|
+
"resolved": "string",
|
|
136
|
+
"references": {}
|
|
137
|
+
},
|
|
138
|
+
"required": false,
|
|
139
|
+
"optional": true,
|
|
140
|
+
"docs": {
|
|
141
|
+
"tags": [{
|
|
142
|
+
"text": "Checkbox label link lext",
|
|
143
|
+
"name": "uiName"
|
|
144
|
+
}],
|
|
145
|
+
"text": ""
|
|
146
|
+
},
|
|
147
|
+
"attribute": "checkbox-label-link-text",
|
|
148
|
+
"reflect": false,
|
|
149
|
+
"defaultValue": "\"Terms and Conditions\""
|
|
150
|
+
},
|
|
151
|
+
"errorMessage": {
|
|
152
|
+
"type": "string",
|
|
153
|
+
"mutable": false,
|
|
154
|
+
"complexType": {
|
|
155
|
+
"original": "string",
|
|
156
|
+
"resolved": "string",
|
|
157
|
+
"references": {}
|
|
158
|
+
},
|
|
159
|
+
"required": false,
|
|
160
|
+
"optional": true,
|
|
161
|
+
"docs": {
|
|
162
|
+
"tags": [{
|
|
163
|
+
"text": "Unchecked error message",
|
|
164
|
+
"name": "uiName"
|
|
165
|
+
}],
|
|
166
|
+
"text": ""
|
|
167
|
+
},
|
|
168
|
+
"attribute": "error-message",
|
|
169
|
+
"reflect": false,
|
|
170
|
+
"defaultValue": "\"Must be checked\""
|
|
171
|
+
},
|
|
172
|
+
"checkboxOptional": {
|
|
173
|
+
"type": "boolean",
|
|
174
|
+
"mutable": false,
|
|
175
|
+
"complexType": {
|
|
176
|
+
"original": "boolean",
|
|
177
|
+
"resolved": "boolean",
|
|
178
|
+
"references": {}
|
|
179
|
+
},
|
|
180
|
+
"required": false,
|
|
181
|
+
"optional": true,
|
|
182
|
+
"docs": {
|
|
183
|
+
"tags": [{
|
|
184
|
+
"text": "Optional",
|
|
185
|
+
"name": "uiName"
|
|
186
|
+
}],
|
|
187
|
+
"text": ""
|
|
188
|
+
},
|
|
189
|
+
"attribute": "checkbox-optional",
|
|
190
|
+
"reflect": false,
|
|
191
|
+
"defaultValue": "false"
|
|
192
|
+
},
|
|
193
|
+
"demoData": {
|
|
194
|
+
"type": "unknown",
|
|
195
|
+
"mutable": false,
|
|
196
|
+
"complexType": {
|
|
197
|
+
"original": "DemoData<LeadCheckboxFieldViewProps>",
|
|
198
|
+
"resolved": "{ states?: { leadFormState?: LeadFormState; checked: boolean; }; content?: { checkboxName: string; checkboxLabel: string; checkboxLabelLink?: string; checkboxLabelLinkText?: string; checkboxOptional?: boolean; errorMessage?: string; requiredFieldErrorMessage?: string; }; }",
|
|
199
|
+
"references": {
|
|
200
|
+
"DemoData": {
|
|
201
|
+
"location": "import",
|
|
202
|
+
"path": "../../global/demo"
|
|
203
|
+
},
|
|
204
|
+
"LeadCheckboxFieldViewProps": {
|
|
205
|
+
"location": "import",
|
|
206
|
+
"path": "./sqm-lead-checkbox-field-view"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
"required": false,
|
|
211
|
+
"optional": true,
|
|
212
|
+
"docs": {
|
|
213
|
+
"tags": [{
|
|
214
|
+
"text": undefined,
|
|
215
|
+
"name": "undocumented"
|
|
216
|
+
}, {
|
|
217
|
+
"text": "object",
|
|
218
|
+
"name": "uiType"
|
|
219
|
+
}],
|
|
220
|
+
"text": ""
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}; }
|
|
224
|
+
static get states() { return {
|
|
225
|
+
"ignored": {}
|
|
226
|
+
}; }
|
|
227
|
+
}
|
|
228
|
+
function useLeadCheckboxFieldDemo(props) {
|
|
229
|
+
return deepmerge({
|
|
230
|
+
states: {
|
|
231
|
+
registrationFormState: {},
|
|
232
|
+
checked: false,
|
|
233
|
+
},
|
|
234
|
+
callbacks: {
|
|
235
|
+
setChecked: () => { },
|
|
236
|
+
},
|
|
237
|
+
}, props.demoData || {}, { arrayMerge: (_, a) => a });
|
|
238
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useDomContext } from "@saasquatch/stencil-hooks";
|
|
2
|
+
import { useEffect, useState } from "@saasquatch/universal-hooks";
|
|
3
|
+
import { LEAD_FORM_STATE_CONTEXT } from "./useLeadFormState";
|
|
4
|
+
export function useLeadCheckboxField(props) {
|
|
5
|
+
var _a;
|
|
6
|
+
const leadFormState = useDomContext(LEAD_FORM_STATE_CONTEXT);
|
|
7
|
+
const [checked, setChecked] = useState(false);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
if ((_a = leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.initialData) === null || _a === void 0 ? void 0 : _a[props.checkboxName]) {
|
|
11
|
+
setChecked(!!((_b = leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.initialData) === null || _b === void 0 ? void 0 : _b[props.checkboxName]));
|
|
12
|
+
}
|
|
13
|
+
}, [(_a = leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.initialData) === null || _a === void 0 ? void 0 : _a[props.checkboxName]]);
|
|
14
|
+
return {
|
|
15
|
+
states: {
|
|
16
|
+
leadFormState,
|
|
17
|
+
checked,
|
|
18
|
+
},
|
|
19
|
+
callbacks: {
|
|
20
|
+
setChecked,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|