@saasquatch/mint-components 1.14.7-6 → 1.14.7-8
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/sqm-big-stat_43.cjs.entry.js +8 -1
- package/dist/cjs/{sqm-lead-checkbox-field-view-00116edf.js → sqm-lead-checkbox-field-view-34d94919.js} +2 -3
- package/dist/cjs/sqm-lead-checkbox-field.cjs.entry.js +7 -23
- package/dist/cjs/sqm-stencilbook.cjs.entry.js +1 -11
- package/dist/collection/components/sqm-lead-form/LeadCheckboxField.stories.js +0 -9
- package/dist/collection/components/sqm-lead-form/sqm-lead-checkbox-field-view.js +2 -3
- package/dist/collection/components/sqm-lead-form/sqm-lead-checkbox-field.js +7 -11
- package/dist/collection/components/sqm-lead-form/useCheckboxField.js +1 -14
- package/dist/collection/components/sqm-lead-form/useLeadForm.js +8 -1
- package/dist/esm/sqm-big-stat_43.entry.js +8 -1
- package/dist/esm/{sqm-lead-checkbox-field-view-f2d478ad.js → sqm-lead-checkbox-field-view-a8c1c78e.js} +2 -3
- package/dist/esm/sqm-lead-checkbox-field.entry.js +8 -24
- package/dist/esm/sqm-stencilbook.entry.js +1 -11
- package/dist/esm-es5/sqm-big-stat_43.entry.js +1 -1
- package/dist/esm-es5/sqm-lead-checkbox-field-view-a8c1c78e.js +1 -0
- package/dist/esm-es5/sqm-lead-checkbox-field.entry.js +1 -1
- package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
- package/dist/mint-components/mint-components.esm.js +1 -1
- package/dist/mint-components/p-00df0cac.js +1 -0
- package/dist/mint-components/p-0b4cac9f.system.entry.js +1 -0
- package/dist/mint-components/{p-87499562.system.entry.js → p-1d8c24d9.system.entry.js} +1 -1
- package/dist/mint-components/p-37996351.system.js +1 -1
- package/dist/mint-components/p-48c69c2d.entry.js +1 -0
- package/dist/mint-components/p-5c35ab32.system.entry.js +1 -0
- package/dist/mint-components/{p-851eaf57.entry.js → p-8855bb68.entry.js} +1 -1
- package/dist/mint-components/p-95b88eb6.system.js +1 -0
- package/dist/mint-components/{p-11de051f.entry.js → p-a94b5fc6.entry.js} +2 -2
- package/dist/types/components/sqm-lead-form/LeadCheckboxField.stories.d.ts +0 -6
- package/dist/types/components/sqm-lead-form/sqm-lead-checkbox-field-view.d.ts +0 -4
- package/dist/types/components/sqm-lead-form/useCheckboxField.d.ts +1 -6
- package/docs/docs.docx +0 -0
- package/docs/raisins.json +1 -1
- package/package.json +1 -1
- package/dist/esm-es5/sqm-lead-checkbox-field-view-f2d478ad.js +0 -1
- package/dist/mint-components/p-09f5f6d1.system.js +0 -1
- package/dist/mint-components/p-10a8ecae.system.entry.js +0 -1
- package/dist/mint-components/p-1780910e.entry.js +0 -1
- package/dist/mint-components/p-6cb95e3c.js +0 -1
- package/dist/mint-components/p-89926dbf.system.entry.js +0 -1
|
@@ -1477,7 +1477,14 @@ function useLeadForm(props) {
|
|
|
1477
1477
|
validationErrors: {},
|
|
1478
1478
|
});
|
|
1479
1479
|
(_b = (_a = formRef.current) === null || _a === void 0 ? void 0 : _a.getFormControls()) === null || _b === void 0 ? void 0 : _b.forEach((c) => {
|
|
1480
|
-
|
|
1480
|
+
console.log({ c });
|
|
1481
|
+
if (c.type === "checkbox") {
|
|
1482
|
+
c.checked = false;
|
|
1483
|
+
c.value = false;
|
|
1484
|
+
}
|
|
1485
|
+
else {
|
|
1486
|
+
c.value = "";
|
|
1487
|
+
}
|
|
1481
1488
|
});
|
|
1482
1489
|
setSuccess(false);
|
|
1483
1490
|
}
|
|
@@ -46,7 +46,7 @@ const sheet = JSS.jss.createStyleSheet(style);
|
|
|
46
46
|
const styleString = sheet.toString();
|
|
47
47
|
function LeadCheckboxFieldView(props) {
|
|
48
48
|
var _a, _b, _c, _d, _e;
|
|
49
|
-
const { states, content
|
|
49
|
+
const { states, content } = props;
|
|
50
50
|
const validationErrors = (_a = states === null || states === void 0 ? void 0 : states.leadFormState) === null || _a === void 0 ? void 0 : _a.validationErrors;
|
|
51
51
|
const getRequiredFieldErrorMessage = ({ checkboxLabel, }) => global.intl.formatMessage({
|
|
52
52
|
id: `requiredFieldErrorMessage-${checkboxLabel}`,
|
|
@@ -58,9 +58,8 @@ function LeadCheckboxFieldView(props) {
|
|
|
58
58
|
index.h("style", { type: "text/css" },
|
|
59
59
|
vanillaStyle,
|
|
60
60
|
styleString),
|
|
61
|
-
index.h("sl-checkbox", Object.assign({ exportparts: "label: input-label, base: input-base", name: `/${content.checkboxName}`,
|
|
61
|
+
index.h("sl-checkbox", Object.assign({ exportparts: "label: input-label, base: input-base", name: `/${content.checkboxName}`, "onSl-change": (e) => {
|
|
62
62
|
e.target.value = e.target.checked;
|
|
63
|
-
callbacks.setChecked(e.target.value);
|
|
64
63
|
} }, (!content.checkboxOptional ? { required: false } : []), { 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 }) => {
|
|
65
64
|
if (!value && !content.checkboxOptional) {
|
|
66
65
|
return getRequiredFieldErrorMessage({
|
|
@@ -10,25 +10,13 @@ const cjs = require('./cjs-1066ec21.js');
|
|
|
10
10
|
const utils = require('./utils-6847bc06.js');
|
|
11
11
|
require('./JSS-8503a151.js');
|
|
12
12
|
const useLeadFormState = require('./useLeadFormState-c83d2034.js');
|
|
13
|
-
const sqmLeadCheckboxFieldView = require('./sqm-lead-checkbox-field-view-
|
|
13
|
+
const sqmLeadCheckboxFieldView = require('./sqm-lead-checkbox-field-view-34d94919.js');
|
|
14
14
|
|
|
15
|
-
function useLeadCheckboxField(
|
|
16
|
-
var _a;
|
|
15
|
+
function useLeadCheckboxField() {
|
|
17
16
|
const leadFormState = stencilHooks_module.d(useLeadFormState.LEAD_FORM_STATE_CONTEXT);
|
|
18
|
-
const [checked, setChecked] = stencilHooks_module.useState(false);
|
|
19
|
-
stencilHooks_module.useEffect(() => {
|
|
20
|
-
var _a, _b;
|
|
21
|
-
if ((_a = leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.initialData) === null || _a === void 0 ? void 0 : _a[props.checkboxName]) {
|
|
22
|
-
setChecked(!!((_b = leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.initialData) === null || _b === void 0 ? void 0 : _b[props.checkboxName]));
|
|
23
|
-
}
|
|
24
|
-
}, [(_a = leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.initialData) === null || _a === void 0 ? void 0 : _a[props.checkboxName]]);
|
|
25
17
|
return {
|
|
26
18
|
states: {
|
|
27
19
|
leadFormState,
|
|
28
|
-
checked,
|
|
29
|
-
},
|
|
30
|
-
callbacks: {
|
|
31
|
-
setChecked,
|
|
32
20
|
},
|
|
33
21
|
};
|
|
34
22
|
}
|
|
@@ -55,7 +43,7 @@ const LeadCheckboxField = class {
|
|
|
55
43
|
/**
|
|
56
44
|
* @uiName Unchecked error message
|
|
57
45
|
*/
|
|
58
|
-
this.errorMessage = "
|
|
46
|
+
this.errorMessage = "Must be checked";
|
|
59
47
|
/**
|
|
60
48
|
* @uiName Optional
|
|
61
49
|
*/
|
|
@@ -76,20 +64,16 @@ const LeadCheckboxField = class {
|
|
|
76
64
|
const content = {
|
|
77
65
|
...utils.getProps(this),
|
|
78
66
|
};
|
|
79
|
-
const { states
|
|
67
|
+
const { states } = index_module.isDemo()
|
|
80
68
|
? useLeadCheckboxFieldDemo(this)
|
|
81
|
-
: useLeadCheckboxField(
|
|
82
|
-
return (index.h(sqmLeadCheckboxFieldView.LeadCheckboxFieldView, { states: states, content: content
|
|
69
|
+
: useLeadCheckboxField();
|
|
70
|
+
return (index.h(sqmLeadCheckboxFieldView.LeadCheckboxFieldView, { states: states, content: content }));
|
|
83
71
|
}
|
|
84
72
|
};
|
|
85
73
|
function useLeadCheckboxFieldDemo(props) {
|
|
86
74
|
return cjs.cjs({
|
|
87
75
|
states: {
|
|
88
|
-
|
|
89
|
-
checked: false,
|
|
90
|
-
},
|
|
91
|
-
callbacks: {
|
|
92
|
-
setChecked: () => { },
|
|
76
|
+
leadFormState: {},
|
|
93
77
|
},
|
|
94
78
|
}, props.demoData || {}, { arrayMerge: (_, a) => a });
|
|
95
79
|
}
|
|
@@ -20,7 +20,7 @@ const sqmAssetCardView = require('./sqm-asset-card-view-21ddf04f.js');
|
|
|
20
20
|
const sqmCloseButtonView = require('./sqm-close-button-view-ea3fa23b.js');
|
|
21
21
|
require('./index-8c6255f5.js');
|
|
22
22
|
const emailRegistrationView = require('./email-registration-view-55b378dc.js');
|
|
23
|
-
const sqmLeadCheckboxFieldView = require('./sqm-lead-checkbox-field-view-
|
|
23
|
+
const sqmLeadCheckboxFieldView = require('./sqm-lead-checkbox-field-view-34d94919.js');
|
|
24
24
|
const sqmLeaderboardRankView = require('./sqm-leaderboard-rank-view-d39a55d8.js');
|
|
25
25
|
const sqmLogoutCurrentUserView = require('./sqm-logout-current-user-view-11d57c12.js');
|
|
26
26
|
const sqmNavigationSidebarView = require('./sqm-navigation-sidebar-view-17111896.js');
|
|
@@ -16073,7 +16073,6 @@ const defaultProps$w = {
|
|
|
16073
16073
|
leadFormState: {
|
|
16074
16074
|
validationErrors: {},
|
|
16075
16075
|
},
|
|
16076
|
-
checked: false,
|
|
16077
16076
|
},
|
|
16078
16077
|
content: {
|
|
16079
16078
|
checkboxName: "terms",
|
|
@@ -16082,15 +16081,8 @@ const defaultProps$w = {
|
|
|
16082
16081
|
checkboxLabelLinkText: "Terms and Conditions",
|
|
16083
16082
|
errorMessage: "{checkboxLabel} Must be checked",
|
|
16084
16083
|
},
|
|
16085
|
-
callbacks: {
|
|
16086
|
-
setChecked: () => { },
|
|
16087
|
-
},
|
|
16088
16084
|
};
|
|
16089
16085
|
const Default$u = createHookStory(() => (index.h(sqmLeadCheckboxFieldView.LeadCheckboxFieldView, Object.assign({}, defaultProps$w))));
|
|
16090
|
-
const DefaultChecked$1 = createHookStory(() => (index.h(sqmLeadCheckboxFieldView.LeadCheckboxFieldView, Object.assign({}, defaultProps$w, { states: {
|
|
16091
|
-
...defaultProps$w.states,
|
|
16092
|
-
checked: true,
|
|
16093
|
-
} }))));
|
|
16094
16086
|
const CustomLabel$3 = createHookStory(() => (index.h(sqmLeadCheckboxFieldView.LeadCheckboxFieldView, Object.assign({}, defaultProps$w, { content: {
|
|
16095
16087
|
...defaultProps$w.content,
|
|
16096
16088
|
checkboxLabel: "I Agree",
|
|
@@ -16105,7 +16097,6 @@ const Error$d = createHookStory(() => (index.h(sqmLeadCheckboxFieldView.LeadChec
|
|
|
16105
16097
|
} }))));
|
|
16106
16098
|
const CustomError$3 = createHookStory(() => (index.h(sqmLeadCheckboxFieldView.LeadCheckboxFieldView, Object.assign({}, defaultProps$w, { states: {
|
|
16107
16099
|
...defaultProps$w.states,
|
|
16108
|
-
checked: true,
|
|
16109
16100
|
leadFormState: {
|
|
16110
16101
|
validationErrors: {
|
|
16111
16102
|
terms: "{checkboxLabel} Must be checked",
|
|
@@ -16120,7 +16111,6 @@ const LeadCheckboxField = /*#__PURE__*/Object.freeze({
|
|
|
16120
16111
|
__proto__: null,
|
|
16121
16112
|
'default': LeadCheckboxField_stories,
|
|
16122
16113
|
Default: Default$u,
|
|
16123
|
-
DefaultChecked: DefaultChecked$1,
|
|
16124
16114
|
CustomLabel: CustomLabel$3,
|
|
16125
16115
|
Error: Error$d,
|
|
16126
16116
|
CustomError: CustomError$3
|
|
@@ -9,7 +9,6 @@ const defaultProps = {
|
|
|
9
9
|
leadFormState: {
|
|
10
10
|
validationErrors: {},
|
|
11
11
|
},
|
|
12
|
-
checked: false,
|
|
13
12
|
},
|
|
14
13
|
content: {
|
|
15
14
|
checkboxName: "terms",
|
|
@@ -18,15 +17,8 @@ const defaultProps = {
|
|
|
18
17
|
checkboxLabelLinkText: "Terms and Conditions",
|
|
19
18
|
errorMessage: "{checkboxLabel} Must be checked",
|
|
20
19
|
},
|
|
21
|
-
callbacks: {
|
|
22
|
-
setChecked: () => { },
|
|
23
|
-
},
|
|
24
20
|
};
|
|
25
21
|
export const Default = createHookStory(() => (h(LeadCheckboxFieldView, Object.assign({}, defaultProps))));
|
|
26
|
-
export const DefaultChecked = createHookStory(() => (h(LeadCheckboxFieldView, Object.assign({}, defaultProps, { states: {
|
|
27
|
-
...defaultProps.states,
|
|
28
|
-
checked: true,
|
|
29
|
-
} }))));
|
|
30
22
|
export const CustomLabel = createHookStory(() => (h(LeadCheckboxFieldView, Object.assign({}, defaultProps, { content: {
|
|
31
23
|
...defaultProps.content,
|
|
32
24
|
checkboxLabel: "I Agree",
|
|
@@ -41,7 +33,6 @@ export const Error = createHookStory(() => (h(LeadCheckboxFieldView, Object.assi
|
|
|
41
33
|
} }))));
|
|
42
34
|
export const CustomError = createHookStory(() => (h(LeadCheckboxFieldView, Object.assign({}, defaultProps, { states: {
|
|
43
35
|
...defaultProps.states,
|
|
44
|
-
checked: true,
|
|
45
36
|
leadFormState: {
|
|
46
37
|
validationErrors: {
|
|
47
38
|
terms: "{checkboxLabel} Must be checked",
|
|
@@ -44,7 +44,7 @@ const sheet = jss.createStyleSheet(style);
|
|
|
44
44
|
const styleString = sheet.toString();
|
|
45
45
|
export function LeadCheckboxFieldView(props) {
|
|
46
46
|
var _a, _b, _c, _d, _e;
|
|
47
|
-
const { states, content
|
|
47
|
+
const { states, content } = props;
|
|
48
48
|
const validationErrors = (_a = states === null || states === void 0 ? void 0 : states.leadFormState) === null || _a === void 0 ? void 0 : _a.validationErrors;
|
|
49
49
|
const getRequiredFieldErrorMessage = ({ checkboxLabel, }) => intl.formatMessage({
|
|
50
50
|
id: `requiredFieldErrorMessage-${checkboxLabel}`,
|
|
@@ -56,9 +56,8 @@ export function LeadCheckboxFieldView(props) {
|
|
|
56
56
|
h("style", { type: "text/css" },
|
|
57
57
|
vanillaStyle,
|
|
58
58
|
styleString),
|
|
59
|
-
h("sl-checkbox", Object.assign({ exportparts: "label: input-label, base: input-base", name: `/${content.checkboxName}`,
|
|
59
|
+
h("sl-checkbox", Object.assign({ exportparts: "label: input-label, base: input-base", name: `/${content.checkboxName}`, "onSl-change": (e) => {
|
|
60
60
|
e.target.value = e.target.checked;
|
|
61
|
-
callbacks.setChecked(e.target.value);
|
|
62
61
|
} }, (!content.checkboxOptional ? { required: false } : []), { 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 }) => {
|
|
63
62
|
if (!value && !content.checkboxOptional) {
|
|
64
63
|
return getRequiredFieldErrorMessage({
|
|
@@ -31,7 +31,7 @@ export class LeadCheckboxField {
|
|
|
31
31
|
/**
|
|
32
32
|
* @uiName Unchecked error message
|
|
33
33
|
*/
|
|
34
|
-
this.errorMessage = "
|
|
34
|
+
this.errorMessage = "Must be checked";
|
|
35
35
|
/**
|
|
36
36
|
* @uiName Optional
|
|
37
37
|
*/
|
|
@@ -52,10 +52,10 @@ export class LeadCheckboxField {
|
|
|
52
52
|
const content = {
|
|
53
53
|
...getProps(this),
|
|
54
54
|
};
|
|
55
|
-
const { states
|
|
55
|
+
const { states } = isDemo()
|
|
56
56
|
? useLeadCheckboxFieldDemo(this)
|
|
57
|
-
: useLeadCheckboxField(
|
|
58
|
-
return (h(LeadCheckboxFieldView, { states: states, content: content
|
|
57
|
+
: useLeadCheckboxField();
|
|
58
|
+
return (h(LeadCheckboxFieldView, { states: states, content: content }));
|
|
59
59
|
}
|
|
60
60
|
static get is() { return "sqm-lead-checkbox-field"; }
|
|
61
61
|
static get properties() { return {
|
|
@@ -167,7 +167,7 @@ export class LeadCheckboxField {
|
|
|
167
167
|
},
|
|
168
168
|
"attribute": "error-message",
|
|
169
169
|
"reflect": false,
|
|
170
|
-
"defaultValue": "\"
|
|
170
|
+
"defaultValue": "\"Must be checked\""
|
|
171
171
|
},
|
|
172
172
|
"checkboxOptional": {
|
|
173
173
|
"type": "boolean",
|
|
@@ -195,7 +195,7 @@ export class LeadCheckboxField {
|
|
|
195
195
|
"mutable": false,
|
|
196
196
|
"complexType": {
|
|
197
197
|
"original": "DemoData<LeadCheckboxFieldViewProps>",
|
|
198
|
-
"resolved": "{ states?: { leadFormState?: LeadFormState;
|
|
198
|
+
"resolved": "{ states?: { leadFormState?: LeadFormState; }; content?: { checkboxName: string; checkboxLabel: string; checkboxLabelLink?: string; checkboxLabelLinkText?: string; checkboxOptional?: boolean; errorMessage?: string; }; }",
|
|
199
199
|
"references": {
|
|
200
200
|
"DemoData": {
|
|
201
201
|
"location": "import",
|
|
@@ -228,11 +228,7 @@ export class LeadCheckboxField {
|
|
|
228
228
|
function useLeadCheckboxFieldDemo(props) {
|
|
229
229
|
return deepmerge({
|
|
230
230
|
states: {
|
|
231
|
-
|
|
232
|
-
checked: false,
|
|
233
|
-
},
|
|
234
|
-
callbacks: {
|
|
235
|
-
setChecked: () => { },
|
|
231
|
+
leadFormState: {},
|
|
236
232
|
},
|
|
237
233
|
}, props.demoData || {}, { arrayMerge: (_, a) => a });
|
|
238
234
|
}
|
|
@@ -1,23 +1,10 @@
|
|
|
1
1
|
import { useDomContext } from "@saasquatch/stencil-hooks";
|
|
2
|
-
import { useEffect, useState } from "@saasquatch/universal-hooks";
|
|
3
2
|
import { LEAD_FORM_STATE_CONTEXT } from "./useLeadFormState";
|
|
4
|
-
export function useLeadCheckboxField(
|
|
5
|
-
var _a;
|
|
3
|
+
export function useLeadCheckboxField() {
|
|
6
4
|
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
5
|
return {
|
|
15
6
|
states: {
|
|
16
7
|
leadFormState,
|
|
17
|
-
checked,
|
|
18
|
-
},
|
|
19
|
-
callbacks: {
|
|
20
|
-
setChecked,
|
|
21
8
|
},
|
|
22
9
|
};
|
|
23
10
|
}
|
|
@@ -113,7 +113,14 @@ export function useLeadForm(props) {
|
|
|
113
113
|
validationErrors: {},
|
|
114
114
|
});
|
|
115
115
|
(_b = (_a = formRef.current) === null || _a === void 0 ? void 0 : _a.getFormControls()) === null || _b === void 0 ? void 0 : _b.forEach((c) => {
|
|
116
|
-
|
|
116
|
+
console.log({ c });
|
|
117
|
+
if (c.type === "checkbox") {
|
|
118
|
+
c.checked = false;
|
|
119
|
+
c.value = false;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
c.value = "";
|
|
123
|
+
}
|
|
117
124
|
});
|
|
118
125
|
setSuccess(false);
|
|
119
126
|
}
|
|
@@ -1473,7 +1473,14 @@ function useLeadForm(props) {
|
|
|
1473
1473
|
validationErrors: {},
|
|
1474
1474
|
});
|
|
1475
1475
|
(_b = (_a = formRef.current) === null || _a === void 0 ? void 0 : _a.getFormControls()) === null || _b === void 0 ? void 0 : _b.forEach((c) => {
|
|
1476
|
-
|
|
1476
|
+
console.log({ c });
|
|
1477
|
+
if (c.type === "checkbox") {
|
|
1478
|
+
c.checked = false;
|
|
1479
|
+
c.value = false;
|
|
1480
|
+
}
|
|
1481
|
+
else {
|
|
1482
|
+
c.value = "";
|
|
1483
|
+
}
|
|
1477
1484
|
});
|
|
1478
1485
|
setSuccess(false);
|
|
1479
1486
|
}
|
|
@@ -44,7 +44,7 @@ const sheet = jss.createStyleSheet(style);
|
|
|
44
44
|
const styleString = sheet.toString();
|
|
45
45
|
function LeadCheckboxFieldView(props) {
|
|
46
46
|
var _a, _b, _c, _d, _e;
|
|
47
|
-
const { states, content
|
|
47
|
+
const { states, content } = props;
|
|
48
48
|
const validationErrors = (_a = states === null || states === void 0 ? void 0 : states.leadFormState) === null || _a === void 0 ? void 0 : _a.validationErrors;
|
|
49
49
|
const getRequiredFieldErrorMessage = ({ checkboxLabel, }) => intl.formatMessage({
|
|
50
50
|
id: `requiredFieldErrorMessage-${checkboxLabel}`,
|
|
@@ -56,9 +56,8 @@ function LeadCheckboxFieldView(props) {
|
|
|
56
56
|
h("style", { type: "text/css" },
|
|
57
57
|
vanillaStyle,
|
|
58
58
|
styleString),
|
|
59
|
-
h("sl-checkbox", Object.assign({ exportparts: "label: input-label, base: input-base", name: `/${content.checkboxName}`,
|
|
59
|
+
h("sl-checkbox", Object.assign({ exportparts: "label: input-label, base: input-base", name: `/${content.checkboxName}`, "onSl-change": (e) => {
|
|
60
60
|
e.target.value = e.target.checked;
|
|
61
|
-
callbacks.setChecked(e.target.value);
|
|
62
61
|
} }, (!content.checkboxOptional ? { required: false } : []), { 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 }) => {
|
|
63
62
|
if (!value && !content.checkboxOptional) {
|
|
64
63
|
return getRequiredFieldErrorMessage({
|
|
@@ -1,30 +1,18 @@
|
|
|
1
1
|
import { r as registerInstance, h as h$1 } from './index-91e7729f.js';
|
|
2
|
-
import { i as d,
|
|
2
|
+
import { i as d, n as h } from './stencil-hooks.module-4bc38af4.js';
|
|
3
3
|
import './global-be1f9992.js';
|
|
4
4
|
import { i as isDemo } from './index.module-89a79f66.js';
|
|
5
5
|
import { c as cjs } from './cjs-bdfb4486.js';
|
|
6
6
|
import { a as getMissingProps, g as getProps } from './utils-334c1e34.js';
|
|
7
7
|
import './JSS-67b5cff8.js';
|
|
8
8
|
import { L as LEAD_FORM_STATE_CONTEXT, R as RequiredPropsError } from './useLeadFormState-9016d812.js';
|
|
9
|
-
import { L as LeadCheckboxFieldView } from './sqm-lead-checkbox-field-view-
|
|
9
|
+
import { L as LeadCheckboxFieldView } from './sqm-lead-checkbox-field-view-a8c1c78e.js';
|
|
10
10
|
|
|
11
|
-
function useLeadCheckboxField(
|
|
12
|
-
var _a;
|
|
11
|
+
function useLeadCheckboxField() {
|
|
13
12
|
const leadFormState = d(LEAD_FORM_STATE_CONTEXT);
|
|
14
|
-
const [checked, setChecked] = useState(false);
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
var _a, _b;
|
|
17
|
-
if ((_a = leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.initialData) === null || _a === void 0 ? void 0 : _a[props.checkboxName]) {
|
|
18
|
-
setChecked(!!((_b = leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.initialData) === null || _b === void 0 ? void 0 : _b[props.checkboxName]));
|
|
19
|
-
}
|
|
20
|
-
}, [(_a = leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.initialData) === null || _a === void 0 ? void 0 : _a[props.checkboxName]]);
|
|
21
13
|
return {
|
|
22
14
|
states: {
|
|
23
15
|
leadFormState,
|
|
24
|
-
checked,
|
|
25
|
-
},
|
|
26
|
-
callbacks: {
|
|
27
|
-
setChecked,
|
|
28
16
|
},
|
|
29
17
|
};
|
|
30
18
|
}
|
|
@@ -51,7 +39,7 @@ const LeadCheckboxField = class {
|
|
|
51
39
|
/**
|
|
52
40
|
* @uiName Unchecked error message
|
|
53
41
|
*/
|
|
54
|
-
this.errorMessage = "
|
|
42
|
+
this.errorMessage = "Must be checked";
|
|
55
43
|
/**
|
|
56
44
|
* @uiName Optional
|
|
57
45
|
*/
|
|
@@ -72,20 +60,16 @@ const LeadCheckboxField = class {
|
|
|
72
60
|
const content = {
|
|
73
61
|
...getProps(this),
|
|
74
62
|
};
|
|
75
|
-
const { states
|
|
63
|
+
const { states } = isDemo()
|
|
76
64
|
? useLeadCheckboxFieldDemo(this)
|
|
77
|
-
: useLeadCheckboxField(
|
|
78
|
-
return (h$1(LeadCheckboxFieldView, { states: states, content: content
|
|
65
|
+
: useLeadCheckboxField();
|
|
66
|
+
return (h$1(LeadCheckboxFieldView, { states: states, content: content }));
|
|
79
67
|
}
|
|
80
68
|
};
|
|
81
69
|
function useLeadCheckboxFieldDemo(props) {
|
|
82
70
|
return cjs({
|
|
83
71
|
states: {
|
|
84
|
-
|
|
85
|
-
checked: false,
|
|
86
|
-
},
|
|
87
|
-
callbacks: {
|
|
88
|
-
setChecked: () => { },
|
|
72
|
+
leadFormState: {},
|
|
89
73
|
},
|
|
90
74
|
}, props.demoData || {}, { arrayMerge: (_, a) => a });
|
|
91
75
|
}
|
|
@@ -16,7 +16,7 @@ import { A as AssetCardView } from './sqm-asset-card-view-fe5db3c0.js';
|
|
|
16
16
|
import { C as CloseButtonView } from './sqm-close-button-view-f9819751.js';
|
|
17
17
|
import './index-ffa26b43.js';
|
|
18
18
|
import { E as EmailRegistrationView } from './email-registration-view-a7818cf2.js';
|
|
19
|
-
import { L as LeadCheckboxFieldView } from './sqm-lead-checkbox-field-view-
|
|
19
|
+
import { L as LeadCheckboxFieldView } from './sqm-lead-checkbox-field-view-a8c1c78e.js';
|
|
20
20
|
import { L as LeaderboardRankView } from './sqm-leaderboard-rank-view-753c8d4a.js';
|
|
21
21
|
import { L as LogoutCurrentUserView } from './sqm-logout-current-user-view-8ef8180f.js';
|
|
22
22
|
import { N as NavigationSidebarView } from './sqm-navigation-sidebar-view-9d802b78.js';
|
|
@@ -16069,7 +16069,6 @@ const defaultProps$w = {
|
|
|
16069
16069
|
leadFormState: {
|
|
16070
16070
|
validationErrors: {},
|
|
16071
16071
|
},
|
|
16072
|
-
checked: false,
|
|
16073
16072
|
},
|
|
16074
16073
|
content: {
|
|
16075
16074
|
checkboxName: "terms",
|
|
@@ -16078,15 +16077,8 @@ const defaultProps$w = {
|
|
|
16078
16077
|
checkboxLabelLinkText: "Terms and Conditions",
|
|
16079
16078
|
errorMessage: "{checkboxLabel} Must be checked",
|
|
16080
16079
|
},
|
|
16081
|
-
callbacks: {
|
|
16082
|
-
setChecked: () => { },
|
|
16083
|
-
},
|
|
16084
16080
|
};
|
|
16085
16081
|
const Default$u = createHookStory(() => (h(LeadCheckboxFieldView, Object.assign({}, defaultProps$w))));
|
|
16086
|
-
const DefaultChecked$1 = createHookStory(() => (h(LeadCheckboxFieldView, Object.assign({}, defaultProps$w, { states: {
|
|
16087
|
-
...defaultProps$w.states,
|
|
16088
|
-
checked: true,
|
|
16089
|
-
} }))));
|
|
16090
16082
|
const CustomLabel$3 = createHookStory(() => (h(LeadCheckboxFieldView, Object.assign({}, defaultProps$w, { content: {
|
|
16091
16083
|
...defaultProps$w.content,
|
|
16092
16084
|
checkboxLabel: "I Agree",
|
|
@@ -16101,7 +16093,6 @@ const Error$d = createHookStory(() => (h(LeadCheckboxFieldView, Object.assign({}
|
|
|
16101
16093
|
} }))));
|
|
16102
16094
|
const CustomError$3 = createHookStory(() => (h(LeadCheckboxFieldView, Object.assign({}, defaultProps$w, { states: {
|
|
16103
16095
|
...defaultProps$w.states,
|
|
16104
|
-
checked: true,
|
|
16105
16096
|
leadFormState: {
|
|
16106
16097
|
validationErrors: {
|
|
16107
16098
|
terms: "{checkboxLabel} Must be checked",
|
|
@@ -16116,7 +16107,6 @@ const LeadCheckboxField = /*#__PURE__*/Object.freeze({
|
|
|
16116
16107
|
__proto__: null,
|
|
16117
16108
|
'default': LeadCheckboxField_stories,
|
|
16118
16109
|
Default: Default$u,
|
|
16119
|
-
DefaultChecked: DefaultChecked$1,
|
|
16120
16110
|
CustomLabel: CustomLabel$3,
|
|
16121
16111
|
Error: Error$d,
|
|
16122
16112
|
CustomError: CustomError$3
|