@saasquatch/mint-components 1.14.7-0 → 1.14.7-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.
- package/dist/cjs/{ShadowViewAddon-3c344355.js → ShadowViewAddon-d79686c7.js} +1 -1
- package/dist/cjs/sqm-big-stat_43.cjs.entry.js +9 -2
- package/dist/cjs/sqm-lead-checkbox-field-view-34d94919.js +83 -0
- package/dist/cjs/sqm-lead-checkbox-field.cjs.entry.js +8 -82
- package/dist/cjs/sqm-stencilbook.cjs.entry.js +56 -3
- package/dist/collection/components/sqm-checkbox-field/sqm-checkbox-field-view.js +1 -1
- package/dist/collection/components/sqm-lead-form/LeadCheckboxField.stories.js +4 -63
- package/dist/collection/components/sqm-lead-form/sqm-lead-checkbox-field-view.js +24 -7
- package/dist/collection/components/sqm-lead-form/sqm-lead-checkbox-field.js +5 -9
- package/dist/collection/components/sqm-lead-form/useCheckboxField.js +1 -14
- package/dist/collection/components/sqm-lead-form/useLeadForm.js +8 -1
- package/dist/collection/components/sqm-stencilbook/sqm-stencilbook.js +2 -0
- package/dist/esm/{ShadowViewAddon-64194d20.js → ShadowViewAddon-88ca6579.js} +1 -1
- package/dist/esm/sqm-big-stat_43.entry.js +9 -2
- package/dist/esm/sqm-lead-checkbox-field-view-a8c1c78e.js +81 -0
- package/dist/esm/sqm-lead-checkbox-field.entry.js +12 -86
- package/dist/esm/sqm-stencilbook.entry.js +56 -3
- package/dist/esm-es5/ShadowViewAddon-88ca6579.js +1 -0
- 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-0a6dd9ce.system.entry.js +1 -0
- package/dist/mint-components/p-0b4cac9f.system.entry.js +1 -0
- package/dist/mint-components/p-2011095e.js +394 -0
- package/dist/mint-components/p-2ad84d3e.system.entry.js +1 -0
- 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-8a8750b2.system.js +1 -0
- package/dist/mint-components/p-95b88eb6.system.js +1 -0
- package/dist/mint-components/{p-f60d1ae9.entry.js → p-9743b3d1.entry.js} +2 -2
- package/dist/mint-components/{p-851eaf57.entry.js → p-c45a40b0.entry.js} +2 -2
- package/dist/types/components/sqm-lead-form/LeadCheckboxField.stories.d.ts +0 -27
- 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/dist/types/global/android.d.ts +7 -0
- package/dist/types/global/demo.d.ts +2 -0
- package/dist/types/stories/features.d.ts +4 -0
- package/dist/types/stories/templates.d.ts +4 -0
- package/docs/docs.docx +0 -0
- package/package.json +1 -1
- package/dist/esm-es5/ShadowViewAddon-64194d20.js +0 -1
- package/dist/mint-components/p-0d94d81a.system.js +0 -1
- package/dist/mint-components/p-10a8ecae.system.entry.js +0 -1
- package/dist/mint-components/p-214c7807.entry.js +0 -1
- package/dist/mint-components/p-30a11ec0.js +0 -394
- package/dist/mint-components/p-589962db.system.entry.js +0 -1
- package/dist/mint-components/p-eaf1a8a6.system.entry.js +0 -1
|
@@ -1713,7 +1713,7 @@ function CheckboxFieldView(props) {
|
|
|
1713
1713
|
index.h("sl-checkbox", Object.assign({ exportparts: "label: input-label, base: input-base", name: `/${content.checkboxName}`, checked: states.checked, "onSl-change": (e) => {
|
|
1714
1714
|
e.target.value = e.target.checked;
|
|
1715
1715
|
callbacks.setChecked(e.target.value);
|
|
1716
|
-
} }, (!content.checkboxOptional ? { required: false } : []), { disabled: ((_b = states.registrationFormState) === null || _b === void 0 ? void 0 : _b.loading) || ((_c = states.registrationFormState) === null || _c === void 0 ? void 0 : _c.disabled)
|
|
1716
|
+
} }, (!content.checkboxOptional ? { required: false } : []), { disabled: ((_b = states.registrationFormState) === null || _b === void 0 ? void 0 : _b.loading) || ((_c = states.registrationFormState) === null || _c === void 0 ? void 0 : _c.disabled) }), global.intl.formatMessage({
|
|
1717
1717
|
id: content.checkboxName + "-message",
|
|
1718
1718
|
defaultMessage: content.checkboxLabel,
|
|
1719
1719
|
}, {
|
|
@@ -24,7 +24,7 @@ const sqmPortalLoginView = require('./sqm-portal-login-view-761a4d8e.js');
|
|
|
24
24
|
const usePortalLogin = require('./usePortalLogin-63d896d1.js');
|
|
25
25
|
const AsYouType = require('./AsYouType-6788393a.js');
|
|
26
26
|
const utilities = require('./utilities-78f5e169.js');
|
|
27
|
-
const ShadowViewAddon = require('./ShadowViewAddon-
|
|
27
|
+
const ShadowViewAddon = require('./ShadowViewAddon-d79686c7.js');
|
|
28
28
|
require('./sqm-portal-container-view-4f15143a.js');
|
|
29
29
|
const usePayoutStatus = require('./usePayoutStatus-feeac99b.js');
|
|
30
30
|
|
|
@@ -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
|
+
var _a;
|
|
1481
|
+
if (((_a = c.input) === null || _a === void 0 ? void 0 : _a.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
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index-a29c60ef.js');
|
|
4
|
+
const global = require('./global-e31dc4f5.js');
|
|
5
|
+
const JSS = require('./JSS-8503a151.js');
|
|
6
|
+
|
|
7
|
+
const style = {
|
|
8
|
+
ErrorStyle: {
|
|
9
|
+
"&::part(control)": {
|
|
10
|
+
borderColor: "var(--sl-color-danger-500)",
|
|
11
|
+
outline: "var(--sl-color-danger-500)",
|
|
12
|
+
},
|
|
13
|
+
"&:host": {
|
|
14
|
+
"--focus-ring": "0 0 0 var(--sl-focus-ring-width) red !important",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
ErrorMessageStyle: {
|
|
18
|
+
margin: 0,
|
|
19
|
+
marginTop: "5px",
|
|
20
|
+
color: "var(--sl-color-danger-500)",
|
|
21
|
+
fontSize: "var(--sl-input-help-text-font-size-medium)",
|
|
22
|
+
fontFamily: "var(--sl-font-sans)",
|
|
23
|
+
fontWeight: "var(--sl-font-weight-normal)",
|
|
24
|
+
},
|
|
25
|
+
FieldContainer: {
|
|
26
|
+
"margin-bottom": "var(--sl-spacing-large)",
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
const vanillaStyle = `
|
|
30
|
+
:host {
|
|
31
|
+
margin: 0 auto;
|
|
32
|
+
width: 100%;
|
|
33
|
+
display: block;
|
|
34
|
+
}
|
|
35
|
+
sl-checkbox::part(label){
|
|
36
|
+
font-size: var(--sl-input-label-font-size-small);
|
|
37
|
+
font-weight: var(--sl-font-weight-normal);
|
|
38
|
+
line-height: 20px;
|
|
39
|
+
}
|
|
40
|
+
sl-checkbox::part(base){
|
|
41
|
+
align-items: start;
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
JSS.jss.setup(JSS.create());
|
|
45
|
+
const sheet = JSS.jss.createStyleSheet(style);
|
|
46
|
+
const styleString = sheet.toString();
|
|
47
|
+
function LeadCheckboxFieldView(props) {
|
|
48
|
+
var _a, _b, _c, _d, _e;
|
|
49
|
+
const { states, content } = props;
|
|
50
|
+
const validationErrors = (_a = states === null || states === void 0 ? void 0 : states.leadFormState) === null || _a === void 0 ? void 0 : _a.validationErrors;
|
|
51
|
+
const getRequiredFieldErrorMessage = ({ checkboxLabel, }) => global.intl.formatMessage({
|
|
52
|
+
id: `requiredFieldErrorMessage-${checkboxLabel}`,
|
|
53
|
+
defaultMessage: content.errorMessage,
|
|
54
|
+
}, {
|
|
55
|
+
checkboxLabel,
|
|
56
|
+
});
|
|
57
|
+
return (index.h("div", { class: sheet.classes.FieldContainer, part: "sqm-base" },
|
|
58
|
+
index.h("style", { type: "text/css" },
|
|
59
|
+
vanillaStyle,
|
|
60
|
+
styleString),
|
|
61
|
+
index.h("sl-checkbox", Object.assign({ exportparts: "label: input-label, base: input-base", name: `/${content.checkboxName}`, "onSl-change": (e) => {
|
|
62
|
+
e.target.value = e.target.checked;
|
|
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 }) => {
|
|
64
|
+
if (!value && !content.checkboxOptional) {
|
|
65
|
+
return getRequiredFieldErrorMessage({
|
|
66
|
+
checkboxLabel: content.checkboxLabel,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
} }, (((_e = (_d = states.leadFormState) === null || _d === void 0 ? void 0 : _d.validationErrors) === null || _e === void 0 ? void 0 : _e[content.checkboxName]) ? {
|
|
70
|
+
class: sheet.classes.ErrorStyle,
|
|
71
|
+
}
|
|
72
|
+
: [])), global.intl.formatMessage({
|
|
73
|
+
id: content.checkboxName + "-message",
|
|
74
|
+
defaultMessage: content.checkboxLabel,
|
|
75
|
+
}, {
|
|
76
|
+
labelLink: (index.h("a", { href: content.checkboxLabelLink, target: "_blank" }, content.checkboxLabelLinkText || content.checkboxLabelLink)),
|
|
77
|
+
})),
|
|
78
|
+
(validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors[content.checkboxName]) && (index.h("p", { class: sheet.classes.ErrorMessageStyle }, getRequiredFieldErrorMessage({
|
|
79
|
+
checkboxLabel: content.checkboxLabel,
|
|
80
|
+
})))));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
exports.LeadCheckboxFieldView = LeadCheckboxFieldView;
|
|
@@ -4,89 +4,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-a29c60ef.js');
|
|
6
6
|
const stencilHooks_module = require('./stencil-hooks.module-3a336b0f.js');
|
|
7
|
-
|
|
7
|
+
require('./global-e31dc4f5.js');
|
|
8
8
|
const index_module = require('./index.module-ee84433d.js');
|
|
9
9
|
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-34d94919.js');
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
ErrorStyle: {
|
|
16
|
-
"&::part(control)": {
|
|
17
|
-
background: "var(--sl-color-danger-10)",
|
|
18
|
-
borderColor: "var(--sl-color-danger-500)",
|
|
19
|
-
outline: "var(--sl-color-danger-500)",
|
|
20
|
-
},
|
|
21
|
-
"&:host": {
|
|
22
|
-
"--focus-ring": "0 0 0 var(--sl-focus-ring-width) red !important",
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
ErrorMessageStyle: {
|
|
26
|
-
margin: 0,
|
|
27
|
-
marginTop: "5px",
|
|
28
|
-
color: "var(--sl-color-danger-500)",
|
|
29
|
-
fontSize: "var(--sl-input-help-text-font-size-medium)",
|
|
30
|
-
fontFamily: "var(--sl-font-sans)",
|
|
31
|
-
fontWeight: "var(--sl-font-weight-normal)",
|
|
32
|
-
},
|
|
33
|
-
FieldContainer: {
|
|
34
|
-
"margin-bottom": "var(--sl-spacing-large)",
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
const vanillaStyle = `
|
|
38
|
-
:host {
|
|
39
|
-
margin: 0 auto;
|
|
40
|
-
width: 100%;
|
|
41
|
-
display: block;
|
|
42
|
-
}
|
|
43
|
-
sl-checkbox::part(label){
|
|
44
|
-
font-size: var(--sl-input-label-font-size-small);
|
|
45
|
-
font-weight: var(--sl-font-weight-normal);
|
|
46
|
-
line-height: 20px;
|
|
47
|
-
}
|
|
48
|
-
sl-checkbox::part(base){
|
|
49
|
-
align-items: start;
|
|
50
|
-
}
|
|
51
|
-
`;
|
|
52
|
-
JSS.jss.setup(JSS.create());
|
|
53
|
-
const sheet = JSS.jss.createStyleSheet(style);
|
|
54
|
-
const styleString = sheet.toString();
|
|
55
|
-
function LeadCheckboxFieldView(props) {
|
|
56
|
-
var _a, _b;
|
|
57
|
-
const { states, content, callbacks } = props;
|
|
58
|
-
return (index.h("div", { class: sheet.classes.FieldContainer, part: "sqm-base" },
|
|
59
|
-
index.h("style", { type: "text/css" },
|
|
60
|
-
vanillaStyle,
|
|
61
|
-
styleString),
|
|
62
|
-
index.h("sl-checkbox", Object.assign({ exportparts: "label: input-label, base: input-base", name: `/${content.checkboxName}`, checked: states.checked, "onSl-change": (e) => {
|
|
63
|
-
e.target.value = e.target.checked;
|
|
64
|
-
callbacks.setChecked(e.target.value);
|
|
65
|
-
} }, (!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), required: false }), global.intl.formatMessage({
|
|
66
|
-
id: content.checkboxName + "-message",
|
|
67
|
-
defaultMessage: content.checkboxLabel,
|
|
68
|
-
}, {
|
|
69
|
-
labelLink: (index.h("a", { href: content.checkboxLabelLink, target: "_blank" }, content.checkboxLabelLinkText || content.checkboxLabelLink)),
|
|
70
|
-
}))));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function useLeadCheckboxField(props) {
|
|
74
|
-
var _a;
|
|
15
|
+
function useLeadCheckboxField() {
|
|
75
16
|
const leadFormState = stencilHooks_module.d(useLeadFormState.LEAD_FORM_STATE_CONTEXT);
|
|
76
|
-
const [checked, setChecked] = stencilHooks_module.useState(false);
|
|
77
|
-
stencilHooks_module.useEffect(() => {
|
|
78
|
-
var _a, _b;
|
|
79
|
-
if ((_a = leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.initialData) === null || _a === void 0 ? void 0 : _a[props.checkboxName]) {
|
|
80
|
-
setChecked(!!((_b = leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.initialData) === null || _b === void 0 ? void 0 : _b[props.checkboxName]));
|
|
81
|
-
}
|
|
82
|
-
}, [(_a = leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.initialData) === null || _a === void 0 ? void 0 : _a[props.checkboxName]]);
|
|
83
17
|
return {
|
|
84
18
|
states: {
|
|
85
19
|
leadFormState,
|
|
86
|
-
checked,
|
|
87
|
-
},
|
|
88
|
-
callbacks: {
|
|
89
|
-
setChecked,
|
|
90
20
|
},
|
|
91
21
|
};
|
|
92
22
|
}
|
|
@@ -134,20 +64,16 @@ const LeadCheckboxField = class {
|
|
|
134
64
|
const content = {
|
|
135
65
|
...utils.getProps(this),
|
|
136
66
|
};
|
|
137
|
-
const { states
|
|
67
|
+
const { states } = index_module.isDemo()
|
|
138
68
|
? useLeadCheckboxFieldDemo(this)
|
|
139
|
-
: useLeadCheckboxField(
|
|
140
|
-
return (index.h(LeadCheckboxFieldView, { states: states, content: content
|
|
69
|
+
: useLeadCheckboxField();
|
|
70
|
+
return (index.h(sqmLeadCheckboxFieldView.LeadCheckboxFieldView, { states: states, content: content }));
|
|
141
71
|
}
|
|
142
72
|
};
|
|
143
73
|
function useLeadCheckboxFieldDemo(props) {
|
|
144
74
|
return cjs.cjs({
|
|
145
75
|
states: {
|
|
146
|
-
|
|
147
|
-
checked: false,
|
|
148
|
-
},
|
|
149
|
-
callbacks: {
|
|
150
|
-
setChecked: () => { },
|
|
76
|
+
leadFormState: {},
|
|
151
77
|
},
|
|
152
78
|
}, props.demoData || {}, { arrayMerge: (_, a) => a });
|
|
153
79
|
}
|
|
@@ -20,6 +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-34d94919.js');
|
|
23
24
|
const sqmLeaderboardRankView = require('./sqm-leaderboard-rank-view-d39a55d8.js');
|
|
24
25
|
const sqmLogoutCurrentUserView = require('./sqm-logout-current-user-view-11d57c12.js');
|
|
25
26
|
const sqmNavigationSidebarView = require('./sqm-navigation-sidebar-view-17111896.js');
|
|
@@ -35,7 +36,7 @@ const sqmPortalResetPasswordView = require('./sqm-portal-reset-password-view-fe6
|
|
|
35
36
|
const sqmPortalVerifyEmailView = require('./sqm-portal-verify-email-view-7b678f34.js');
|
|
36
37
|
require('./ErrorView-b2fcf954.js');
|
|
37
38
|
const sqmQrCodeView = require('./sqm-qr-code-view-15dfc0b6.js');
|
|
38
|
-
const ShadowViewAddon = require('./ShadowViewAddon-
|
|
39
|
+
const ShadowViewAddon = require('./ShadowViewAddon-d79686c7.js');
|
|
39
40
|
const sqmPortalContainerView = require('./sqm-portal-container-view-4f15143a.js');
|
|
40
41
|
const sqmInvoiceTableView = require('./sqm-invoice-table-view-0f7fa309.js');
|
|
41
42
|
const sqmLeadInputFieldView = require('./sqm-lead-input-field-view-89308aab.js');
|
|
@@ -16064,6 +16065,57 @@ const LeadFormDropdownField = /*#__PURE__*/Object.freeze({
|
|
|
16064
16065
|
WithInitialValue: WithInitialValue$1
|
|
16065
16066
|
});
|
|
16066
16067
|
|
|
16068
|
+
const LeadCheckboxField_stories = {
|
|
16069
|
+
title: "Components/Lead Checkbox Field",
|
|
16070
|
+
};
|
|
16071
|
+
const defaultProps$w = {
|
|
16072
|
+
states: {
|
|
16073
|
+
leadFormState: {
|
|
16074
|
+
validationErrors: {},
|
|
16075
|
+
},
|
|
16076
|
+
},
|
|
16077
|
+
content: {
|
|
16078
|
+
checkboxName: "terms",
|
|
16079
|
+
checkboxLabel: "By signing up you agree to the {labelLink}",
|
|
16080
|
+
checkboxLabelLink: "https://example.com",
|
|
16081
|
+
checkboxLabelLinkText: "Terms and Conditions",
|
|
16082
|
+
errorMessage: "{checkboxLabel} Must be checked",
|
|
16083
|
+
},
|
|
16084
|
+
};
|
|
16085
|
+
const Default$u = createHookStory(() => (index.h(sqmLeadCheckboxFieldView.LeadCheckboxFieldView, Object.assign({}, defaultProps$w))));
|
|
16086
|
+
const CustomLabel$3 = createHookStory(() => (index.h(sqmLeadCheckboxFieldView.LeadCheckboxFieldView, Object.assign({}, defaultProps$w, { content: {
|
|
16087
|
+
...defaultProps$w.content,
|
|
16088
|
+
checkboxLabel: "I Agree",
|
|
16089
|
+
} }))));
|
|
16090
|
+
const Error$d = createHookStory(() => (index.h(sqmLeadCheckboxFieldView.LeadCheckboxFieldView, Object.assign({}, defaultProps$w, { states: {
|
|
16091
|
+
...defaultProps$w.states,
|
|
16092
|
+
leadFormState: {
|
|
16093
|
+
validationErrors: {
|
|
16094
|
+
terms: "{checkboxLabel} Must be checked",
|
|
16095
|
+
},
|
|
16096
|
+
},
|
|
16097
|
+
} }))));
|
|
16098
|
+
const CustomError$3 = createHookStory(() => (index.h(sqmLeadCheckboxFieldView.LeadCheckboxFieldView, Object.assign({}, defaultProps$w, { states: {
|
|
16099
|
+
...defaultProps$w.states,
|
|
16100
|
+
leadFormState: {
|
|
16101
|
+
validationErrors: {
|
|
16102
|
+
terms: "{checkboxLabel} Must be checked",
|
|
16103
|
+
},
|
|
16104
|
+
},
|
|
16105
|
+
}, content: {
|
|
16106
|
+
...defaultProps$w.content,
|
|
16107
|
+
errorMessage: "This checkbox must be checked to continue",
|
|
16108
|
+
} }))));
|
|
16109
|
+
|
|
16110
|
+
const LeadCheckboxField = /*#__PURE__*/Object.freeze({
|
|
16111
|
+
__proto__: null,
|
|
16112
|
+
'default': LeadCheckboxField_stories,
|
|
16113
|
+
Default: Default$u,
|
|
16114
|
+
CustomLabel: CustomLabel$3,
|
|
16115
|
+
Error: Error$d,
|
|
16116
|
+
CustomError: CustomError$3
|
|
16117
|
+
});
|
|
16118
|
+
|
|
16067
16119
|
/**
|
|
16068
16120
|
*
|
|
16069
16121
|
* Themes
|
|
@@ -16076,7 +16128,7 @@ const LeadFormDropdownField = /*#__PURE__*/Object.freeze({
|
|
|
16076
16128
|
*
|
|
16077
16129
|
*/
|
|
16078
16130
|
//
|
|
16079
|
-
const Default$
|
|
16131
|
+
const Default$v = `
|
|
16080
16132
|
// No CSS
|
|
16081
16133
|
`;
|
|
16082
16134
|
const Orangey = `
|
|
@@ -16110,7 +16162,7 @@ const Klip = `
|
|
|
16110
16162
|
|
|
16111
16163
|
const Themes = /*#__PURE__*/Object.freeze({
|
|
16112
16164
|
__proto__: null,
|
|
16113
|
-
Default: Default$
|
|
16165
|
+
Default: Default$v,
|
|
16114
16166
|
Orangey: Orangey,
|
|
16115
16167
|
Netflix: Netflix,
|
|
16116
16168
|
SaaSquatchCorporate: SaaSquatchCorporate,
|
|
@@ -18804,6 +18856,7 @@ const stories = [
|
|
|
18804
18856
|
LeadForm,
|
|
18805
18857
|
LeadInputField,
|
|
18806
18858
|
LeadFormDropdownField,
|
|
18859
|
+
LeadCheckboxField,
|
|
18807
18860
|
];
|
|
18808
18861
|
const StencilStorybook = class {
|
|
18809
18862
|
constructor(hostRef) {
|
|
@@ -54,7 +54,7 @@ export function CheckboxFieldView(props) {
|
|
|
54
54
|
h("sl-checkbox", Object.assign({ exportparts: "label: input-label, base: input-base", name: `/${content.checkboxName}`, checked: states.checked, "onSl-change": (e) => {
|
|
55
55
|
e.target.value = e.target.checked;
|
|
56
56
|
callbacks.setChecked(e.target.value);
|
|
57
|
-
} }, (!content.checkboxOptional ? { required: false } : []), { disabled: ((_b = states.registrationFormState) === null || _b === void 0 ? void 0 : _b.loading) || ((_c = states.registrationFormState) === null || _c === void 0 ? void 0 : _c.disabled)
|
|
57
|
+
} }, (!content.checkboxOptional ? { required: false } : []), { disabled: ((_b = states.registrationFormState) === null || _b === void 0 ? void 0 : _b.loading) || ((_c = states.registrationFormState) === null || _c === void 0 ? void 0 : _c.disabled) }), intl.formatMessage({
|
|
58
58
|
id: content.checkboxName + "-message",
|
|
59
59
|
defaultMessage: content.checkboxLabel,
|
|
60
60
|
}, {
|
|
@@ -1,60 +1,24 @@
|
|
|
1
1
|
import { h } from "@stencil/core";
|
|
2
|
-
import { PortalRegisterView, } from "../sqm-portal-register/sqm-portal-register-view";
|
|
3
2
|
import { createHookStory } from "../sqm-stencilbook/HookStoryAddon";
|
|
4
3
|
import { LeadCheckboxFieldView, } from "./sqm-lead-checkbox-field-view";
|
|
5
|
-
import scenario from "./sqm-checkbox-field.feature";
|
|
6
4
|
export default {
|
|
7
|
-
title: "Components/Checkbox Field",
|
|
8
|
-
parameters: {
|
|
9
|
-
scenario,
|
|
10
|
-
},
|
|
5
|
+
title: "Components/Lead Checkbox Field",
|
|
11
6
|
};
|
|
12
7
|
const defaultProps = {
|
|
13
8
|
states: {
|
|
14
9
|
leadFormState: {
|
|
15
10
|
validationErrors: {},
|
|
16
11
|
},
|
|
17
|
-
checked: false,
|
|
18
12
|
},
|
|
19
13
|
content: {
|
|
20
14
|
checkboxName: "terms",
|
|
21
15
|
checkboxLabel: "By signing up you agree to the {labelLink}",
|
|
22
16
|
checkboxLabelLink: "https://example.com",
|
|
23
17
|
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",
|
|
18
|
+
errorMessage: "{checkboxLabel} Must be checked",
|
|
51
19
|
},
|
|
52
20
|
};
|
|
53
21
|
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
22
|
export const CustomLabel = createHookStory(() => (h(LeadCheckboxFieldView, Object.assign({}, defaultProps, { content: {
|
|
59
23
|
...defaultProps.content,
|
|
60
24
|
checkboxLabel: "I Agree",
|
|
@@ -63,7 +27,7 @@ export const Error = createHookStory(() => (h(LeadCheckboxFieldView, Object.assi
|
|
|
63
27
|
...defaultProps.states,
|
|
64
28
|
leadFormState: {
|
|
65
29
|
validationErrors: {
|
|
66
|
-
|
|
30
|
+
terms: "{checkboxLabel} Must be checked",
|
|
67
31
|
},
|
|
68
32
|
},
|
|
69
33
|
} }))));
|
|
@@ -71,33 +35,10 @@ export const CustomError = createHookStory(() => (h(LeadCheckboxFieldView, Objec
|
|
|
71
35
|
...defaultProps.states,
|
|
72
36
|
leadFormState: {
|
|
73
37
|
validationErrors: {
|
|
74
|
-
|
|
38
|
+
terms: "{checkboxLabel} Must be checked",
|
|
75
39
|
},
|
|
76
40
|
},
|
|
77
41
|
}, content: {
|
|
78
42
|
...defaultProps.content,
|
|
79
43
|
errorMessage: "This checkbox must be checked to continue",
|
|
80
44
|
} }))));
|
|
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
|
-
} }))));
|
|
@@ -5,7 +5,6 @@ import { intl } from "../../global/global";
|
|
|
5
5
|
const style = {
|
|
6
6
|
ErrorStyle: {
|
|
7
7
|
"&::part(control)": {
|
|
8
|
-
background: "var(--sl-color-danger-10)",
|
|
9
8
|
borderColor: "var(--sl-color-danger-500)",
|
|
10
9
|
outline: "var(--sl-color-danger-500)",
|
|
11
10
|
},
|
|
@@ -44,19 +43,37 @@ jss.setup(preset());
|
|
|
44
43
|
const sheet = jss.createStyleSheet(style);
|
|
45
44
|
const styleString = sheet.toString();
|
|
46
45
|
export function LeadCheckboxFieldView(props) {
|
|
47
|
-
var _a, _b;
|
|
48
|
-
const { states, content
|
|
46
|
+
var _a, _b, _c, _d, _e;
|
|
47
|
+
const { states, content } = props;
|
|
48
|
+
const validationErrors = (_a = states === null || states === void 0 ? void 0 : states.leadFormState) === null || _a === void 0 ? void 0 : _a.validationErrors;
|
|
49
|
+
const getRequiredFieldErrorMessage = ({ checkboxLabel, }) => intl.formatMessage({
|
|
50
|
+
id: `requiredFieldErrorMessage-${checkboxLabel}`,
|
|
51
|
+
defaultMessage: content.errorMessage,
|
|
52
|
+
}, {
|
|
53
|
+
checkboxLabel,
|
|
54
|
+
});
|
|
49
55
|
return (h("div", { class: sheet.classes.FieldContainer, part: "sqm-base" },
|
|
50
56
|
h("style", { type: "text/css" },
|
|
51
57
|
vanillaStyle,
|
|
52
58
|
styleString),
|
|
53
|
-
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) => {
|
|
54
60
|
e.target.value = e.target.checked;
|
|
55
|
-
|
|
56
|
-
|
|
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 }) => {
|
|
62
|
+
if (!value && !content.checkboxOptional) {
|
|
63
|
+
return getRequiredFieldErrorMessage({
|
|
64
|
+
checkboxLabel: content.checkboxLabel,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
} }, (((_e = (_d = states.leadFormState) === null || _d === void 0 ? void 0 : _d.validationErrors) === null || _e === void 0 ? void 0 : _e[content.checkboxName]) ? {
|
|
68
|
+
class: sheet.classes.ErrorStyle,
|
|
69
|
+
}
|
|
70
|
+
: [])), intl.formatMessage({
|
|
57
71
|
id: content.checkboxName + "-message",
|
|
58
72
|
defaultMessage: content.checkboxLabel,
|
|
59
73
|
}, {
|
|
60
74
|
labelLink: (h("a", { href: content.checkboxLabelLink, target: "_blank" }, content.checkboxLabelLinkText || content.checkboxLabelLink)),
|
|
61
|
-
}))
|
|
75
|
+
})),
|
|
76
|
+
(validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors[content.checkboxName]) && (h("p", { class: sheet.classes.ErrorMessageStyle }, getRequiredFieldErrorMessage({
|
|
77
|
+
checkboxLabel: content.checkboxLabel,
|
|
78
|
+
})))));
|
|
62
79
|
}
|
|
@@ -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 {
|
|
@@ -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
|
+
var _a;
|
|
117
|
+
if (((_a = c.input) === null || _a === void 0 ? void 0 : _a.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
|
}
|
|
@@ -100,6 +100,7 @@ import * as QRCode from "../sqm-qr-code/QRCode.stories";
|
|
|
100
100
|
import * as LeadForm from "../sqm-lead-form/LeadForm.stories";
|
|
101
101
|
import * as LeadInputField from "../sqm-lead-form/LeadInputField.stories";
|
|
102
102
|
import * as LeadFormDropdownField from "../sqm-lead-form/LeadFormDropdownField.stories";
|
|
103
|
+
import * as LeadCheckboxField from "../sqm-lead-form/LeadCheckboxField.stories";
|
|
103
104
|
import * as Themes from "./Themes";
|
|
104
105
|
import { CucumberAddon } from "./CucumberAddon";
|
|
105
106
|
import { HookStoryAddon } from "./HookStoryAddon";
|
|
@@ -205,6 +206,7 @@ const stories = [
|
|
|
205
206
|
LeadForm,
|
|
206
207
|
LeadInputField,
|
|
207
208
|
LeadFormDropdownField,
|
|
209
|
+
LeadCheckboxField,
|
|
208
210
|
];
|
|
209
211
|
/**
|
|
210
212
|
* For internal documentation
|
|
@@ -1711,7 +1711,7 @@ function CheckboxFieldView(props) {
|
|
|
1711
1711
|
h("sl-checkbox", Object.assign({ exportparts: "label: input-label, base: input-base", name: `/${content.checkboxName}`, checked: states.checked, "onSl-change": (e) => {
|
|
1712
1712
|
e.target.value = e.target.checked;
|
|
1713
1713
|
callbacks.setChecked(e.target.value);
|
|
1714
|
-
} }, (!content.checkboxOptional ? { required: false } : []), { disabled: ((_b = states.registrationFormState) === null || _b === void 0 ? void 0 : _b.loading) || ((_c = states.registrationFormState) === null || _c === void 0 ? void 0 : _c.disabled)
|
|
1714
|
+
} }, (!content.checkboxOptional ? { required: false } : []), { disabled: ((_b = states.registrationFormState) === null || _b === void 0 ? void 0 : _b.loading) || ((_c = states.registrationFormState) === null || _c === void 0 ? void 0 : _c.disabled) }), intl.formatMessage({
|
|
1715
1715
|
id: content.checkboxName + "-message",
|
|
1716
1716
|
defaultMessage: content.checkboxLabel,
|
|
1717
1717
|
}, {
|
|
@@ -20,7 +20,7 @@ import { P as PortalLoginView } from './sqm-portal-login-view-7e49609a.js';
|
|
|
20
20
|
import { u as usePortalLogin } from './usePortalLogin-ef647a50.js';
|
|
21
21
|
import { A as AsYouType } from './AsYouType-46f67d0d.js';
|
|
22
22
|
import { i as isEmpty } from './utilities-5b0ca040.js';
|
|
23
|
-
import { b as useDemoBigStat, W as useBigStat, B as BigStatView, U as autoColorScaleCss, J as CardFeedView, i as CheckboxFieldView, K as CouponCodeView, D as DropdownFieldView, E as EditProfileView, H as HeroView, I as InputFieldView, Q as LeadDropdownFieldView, O as LeadFormView, X as withShadowView, L as LeaderboardView, N as NameFieldsView, C as ChangeMarktingView, d as PortalChangePasswordView, h as PortalFooterView, P as PortalFrameView, e as PortalRegisterView, R as ReferralIframeView, Y as demoRewardExchange, j as RewardExchangeView, a as useShareButton, S as ShareButtonView, u as useShareLink, c as StatContainerView, T as TaskCardView } from './ShadowViewAddon-
|
|
23
|
+
import { b as useDemoBigStat, W as useBigStat, B as BigStatView, U as autoColorScaleCss, J as CardFeedView, i as CheckboxFieldView, K as CouponCodeView, D as DropdownFieldView, E as EditProfileView, H as HeroView, I as InputFieldView, Q as LeadDropdownFieldView, O as LeadFormView, X as withShadowView, L as LeaderboardView, N as NameFieldsView, C as ChangeMarktingView, d as PortalChangePasswordView, h as PortalFooterView, P as PortalFrameView, e as PortalRegisterView, R as ReferralIframeView, Y as demoRewardExchange, j as RewardExchangeView, a as useShareButton, S as ShareButtonView, u as useShareLink, c as StatContainerView, T as TaskCardView } from './ShadowViewAddon-88ca6579.js';
|
|
24
24
|
import './sqm-portal-container-view-1683ae32.js';
|
|
25
25
|
import { u as usePayoutStatus } from './usePayoutStatus-fed17fc9.js';
|
|
26
26
|
|
|
@@ -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
|
+
var _a;
|
|
1477
|
+
if (((_a = c.input) === null || _a === void 0 ? void 0 : _a.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
|
}
|