@saasquatch/mint-components 1.14.7-1 → 1.14.7-11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/cjs/{ShadowViewAddon-3c344355.js → ShadowViewAddon-f86d2739.js} +3 -1
  2. package/dist/cjs/sqm-big-stat_43.cjs.entry.js +9 -2
  3. package/dist/cjs/sqm-lead-checkbox-field-view-47675f42.js +79 -0
  4. package/dist/cjs/sqm-lead-checkbox-field-view-bb9b7c6c.js +79 -0
  5. package/dist/cjs/sqm-lead-checkbox-field.cjs.entry.js +8 -98
  6. package/dist/cjs/sqm-stencilbook.cjs.entry.js +56 -3
  7. package/dist/collection/components/sqm-checkbox-field/sqm-checkbox-field-view.js +3 -1
  8. package/dist/collection/components/sqm-lead-form/LeadCheckboxField.stories.js +4 -63
  9. package/dist/collection/components/sqm-lead-form/sqm-lead-checkbox-field-view.js +12 -15
  10. package/dist/collection/components/sqm-lead-form/sqm-lead-checkbox-field.js +5 -9
  11. package/dist/collection/components/sqm-lead-form/useCheckboxField.js +1 -14
  12. package/dist/collection/components/sqm-lead-form/useLeadForm.js +8 -1
  13. package/dist/collection/components/sqm-stencilbook/sqm-stencilbook.js +2 -0
  14. package/dist/esm/{ShadowViewAddon-64194d20.js → ShadowViewAddon-fea70c8c.js} +3 -1
  15. package/dist/esm/sqm-big-stat_43.entry.js +9 -2
  16. package/dist/esm/sqm-lead-checkbox-field-view-05823885.js +77 -0
  17. package/dist/esm/sqm-lead-checkbox-field-view-269af7ba.js +77 -0
  18. package/dist/esm/sqm-lead-checkbox-field.entry.js +12 -102
  19. package/dist/esm/sqm-stencilbook.entry.js +56 -3
  20. package/dist/esm-es5/ShadowViewAddon-fea70c8c.js +1 -0
  21. package/dist/esm-es5/sqm-big-stat_43.entry.js +1 -1
  22. package/dist/esm-es5/sqm-lead-checkbox-field-view-05823885.js +1 -0
  23. package/dist/esm-es5/sqm-lead-checkbox-field-view-269af7ba.js +1 -0
  24. package/dist/esm-es5/sqm-lead-checkbox-field.entry.js +1 -1
  25. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  26. package/dist/mint-components/mint-components.esm.js +1 -1
  27. package/dist/mint-components/{p-f60d1ae9.entry.js → p-06180ec8.entry.js} +2 -2
  28. package/dist/mint-components/p-14f86024.system.js +1 -0
  29. package/dist/mint-components/p-20fb7d34.system.js +1 -0
  30. package/dist/mint-components/{p-851eaf57.entry.js → p-268363a8.entry.js} +2 -2
  31. package/dist/mint-components/p-37996351.system.js +1 -1
  32. package/dist/mint-components/p-5640d160.system.entry.js +1 -0
  33. package/dist/mint-components/p-9def94f6.js +394 -0
  34. package/dist/mint-components/p-c1a65f6e.system.entry.js +1 -0
  35. package/dist/mint-components/p-ccddb56d.entry.js +1 -0
  36. package/dist/mint-components/p-d450ee65.system.entry.js +1 -0
  37. package/dist/mint-components/p-dddeeff2.js +1 -0
  38. package/dist/mint-components/sqm-lead-checkbox-field-view-17027655.system.js +1 -0
  39. package/dist/mint-components/sqm-lead-checkbox-field-view-269af7ba.js +77 -0
  40. package/dist/types/components/sqm-lead-form/LeadCheckboxField.stories.d.ts +0 -27
  41. package/dist/types/components/sqm-lead-form/sqm-lead-checkbox-field-view.d.ts +0 -5
  42. package/dist/types/components/sqm-lead-form/useCheckboxField.d.ts +1 -6
  43. package/docs/docs.docx +0 -0
  44. package/package.json +1 -1
  45. package/dist/esm-es5/ShadowViewAddon-64194d20.js +0 -1
  46. package/dist/mint-components/p-0d94d81a.system.js +0 -1
  47. package/dist/mint-components/p-10a8ecae.system.entry.js +0 -1
  48. package/dist/mint-components/p-30a11ec0.js +0 -394
  49. package/dist/mint-components/p-48ad59a8.system.entry.js +0 -1
  50. package/dist/mint-components/p-550346bd.entry.js +0 -1
  51. package/dist/mint-components/p-eaf1a8a6.system.entry.js +0 -1
@@ -1713,7 +1713,9 @@ 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), required: false }), global.intl.formatMessage({
1716
+ } }, (!content.checkboxOptional
1717
+ ? { required: false }
1718
+ : { required: true }), { 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
1719
  id: content.checkboxName + "-message",
1718
1720
  defaultMessage: content.checkboxLabel,
1719
1721
  }, {
@@ -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-3c344355.js');
27
+ const ShadowViewAddon = require('./ShadowViewAddon-f86d2739.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
- c.value = "";
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,79 @@
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
64
+ ? { required: false }
65
+ : { 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) }, (((_e = (_d = states.leadFormState) === null || _d === void 0 ? void 0 : _d.validationErrors) === null || _e === void 0 ? void 0 : _e[content.checkboxName]) ? {
66
+ class: sheet.classes.ErrorStyle,
67
+ }
68
+ : [])), global.intl.formatMessage({
69
+ id: content.checkboxName + "-message",
70
+ defaultMessage: content.checkboxLabel,
71
+ }, {
72
+ labelLink: (index.h("a", { href: content.checkboxLabelLink, target: "_blank" }, content.checkboxLabelLinkText || content.checkboxLabelLink)),
73
+ })),
74
+ (validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors[content.checkboxName]) && (index.h("p", { class: sheet.classes.ErrorMessageStyle }, getRequiredFieldErrorMessage({
75
+ checkboxLabel: content.checkboxLabel,
76
+ })))));
77
+ }
78
+
79
+ exports.LeadCheckboxFieldView = LeadCheckboxFieldView;
@@ -0,0 +1,79 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-acf63b7d.js');
4
+ const global = require('./global-eec134b3.js');
5
+ const jssPresetDefault_esm = require('./jss-preset-default.esm-b48f0c33.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
+ jssPresetDefault_esm.jss.setup(jssPresetDefault_esm.create$1());
45
+ const sheet = jssPresetDefault_esm.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
64
+ ? { required: false }
65
+ : { 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) }, (((_e = (_d = states.leadFormState) === null || _d === void 0 ? void 0 : _d.validationErrors) === null || _e === void 0 ? void 0 : _e[content.checkboxName]) ? {
66
+ class: sheet.classes.ErrorStyle,
67
+ }
68
+ : [])), global.intl.formatMessage({
69
+ id: content.checkboxName + "-message",
70
+ defaultMessage: content.checkboxLabel,
71
+ }, {
72
+ labelLink: (index.h("a", { href: content.checkboxLabelLink, target: "_blank" }, content.checkboxLabelLinkText || content.checkboxLabelLink)),
73
+ })),
74
+ (validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors[content.checkboxName]) && (index.h("p", { class: sheet.classes.ErrorMessageStyle }, getRequiredFieldErrorMessage({
75
+ checkboxLabel: content.checkboxLabel,
76
+ })))));
77
+ }
78
+
79
+ exports.LeadCheckboxFieldView = LeadCheckboxFieldView;
@@ -4,105 +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
- const global = require('./global-e31dc4f5.js');
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
- const JSS = require('./JSS-8503a151.js');
11
+ require('./JSS-8503a151.js');
12
12
  const useLeadFormState = require('./useLeadFormState-c83d2034.js');
13
+ const sqmLeadCheckboxFieldView = require('./sqm-lead-checkbox-field-view-47675f42.js');
13
14
 
14
- const style = {
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, _c, _d, _e, _f;
57
- const { states, content, callbacks } = props;
58
- const getRequiredFieldErrorMessage = ({ checkboxLabel, }) => global.intl.formatMessage({
59
- id: `requiredFieldErrorMessage-${checkboxLabel}`,
60
- defaultMessage: content.requiredFieldErrorMessage,
61
- }, {
62
- checkboxLabel,
63
- });
64
- return (index.h("div", { class: sheet.classes.FieldContainer, part: "sqm-base" },
65
- index.h("style", { type: "text/css" },
66
- vanillaStyle,
67
- styleString),
68
- index.h("sl-checkbox", Object.assign({ exportparts: "label: input-label, base: input-base", name: `/${content.checkboxName}`, checked: states.checked, "onSl-change": (e) => {
69
- e.target.value = e.target.checked;
70
- callbacks.setChecked(e.target.value);
71
- } }, (!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 }) => {
72
- if (!value && !content.checkboxOptional) {
73
- return getRequiredFieldErrorMessage({
74
- checkboxLabel: content.checkboxLabel,
75
- });
76
- }
77
- } }, (((_d = (_c = states.leadFormState) === null || _c === void 0 ? void 0 : _c.validationErrors) === null || _d === void 0 ? void 0 : _d[content.checkboxName]) ? {
78
- class: sheet.classes.ErrorStyle,
79
- helpText: ((_f = (_e = states.leadFormState) === null || _e === void 0 ? void 0 : _e.validationErrors) === null || _f === void 0 ? void 0 : _f[content.checkboxName]) || content.requiredFieldErrorMessage,
80
- }
81
- : [])), global.intl.formatMessage({
82
- id: content.checkboxName + "-message",
83
- defaultMessage: content.checkboxLabel,
84
- }, {
85
- labelLink: (index.h("a", { href: content.checkboxLabelLink, target: "_blank" }, content.checkboxLabelLinkText || content.checkboxLabelLink)),
86
- }))));
87
- }
88
-
89
- function useLeadCheckboxField(props) {
90
- var _a;
15
+ function useLeadCheckboxField() {
91
16
  const leadFormState = stencilHooks_module.d(useLeadFormState.LEAD_FORM_STATE_CONTEXT);
92
- const [checked, setChecked] = stencilHooks_module.useState(false);
93
- stencilHooks_module.useEffect(() => {
94
- var _a, _b;
95
- if ((_a = leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.initialData) === null || _a === void 0 ? void 0 : _a[props.checkboxName]) {
96
- setChecked(!!((_b = leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.initialData) === null || _b === void 0 ? void 0 : _b[props.checkboxName]));
97
- }
98
- }, [(_a = leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.initialData) === null || _a === void 0 ? void 0 : _a[props.checkboxName]]);
99
17
  return {
100
18
  states: {
101
19
  leadFormState,
102
- checked,
103
- },
104
- callbacks: {
105
- setChecked,
106
20
  },
107
21
  };
108
22
  }
@@ -150,20 +64,16 @@ const LeadCheckboxField = class {
150
64
  const content = {
151
65
  ...utils.getProps(this),
152
66
  };
153
- const { states, callbacks } = index_module.isDemo()
67
+ const { states } = index_module.isDemo()
154
68
  ? useLeadCheckboxFieldDemo(this)
155
- : useLeadCheckboxField(this);
156
- return (index.h(LeadCheckboxFieldView, { states: states, content: content, callbacks: callbacks }));
69
+ : useLeadCheckboxField();
70
+ return (index.h(sqmLeadCheckboxFieldView.LeadCheckboxFieldView, { states: states, content: content }));
157
71
  }
158
72
  };
159
73
  function useLeadCheckboxFieldDemo(props) {
160
74
  return cjs.cjs({
161
75
  states: {
162
- registrationFormState: {},
163
- checked: false,
164
- },
165
- callbacks: {
166
- setChecked: () => { },
76
+ leadFormState: {},
167
77
  },
168
78
  }, props.demoData || {}, { arrayMerge: (_, a) => a });
169
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-47675f42.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-3c344355.js');
39
+ const ShadowViewAddon = require('./ShadowViewAddon-f86d2739.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$u = `
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$u,
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,9 @@ 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), required: false }), intl.formatMessage({
57
+ } }, (!content.checkboxOptional
58
+ ? { required: false }
59
+ : { required: true }), { 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
60
  id: content.checkboxName + "-message",
59
61
  defaultMessage: content.checkboxLabel,
60
62
  }, {
@@ -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
- agree: "Must be checked",
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
- agree: "Must be checked",
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,11 +43,12 @@ 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, _c, _d, _e, _f;
48
- const { states, content, callbacks } = props;
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
49
  const getRequiredFieldErrorMessage = ({ checkboxLabel, }) => intl.formatMessage({
50
50
  id: `requiredFieldErrorMessage-${checkboxLabel}`,
51
- defaultMessage: content.requiredFieldErrorMessage,
51
+ defaultMessage: content.errorMessage,
52
52
  }, {
53
53
  checkboxLabel,
54
54
  });
@@ -56,23 +56,20 @@ 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}`, checked: states.checked, "onSl-change": (e) => {
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
- } }, (!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]) ? {
61
+ } }, (!content.checkboxOptional
62
+ ? { required: false }
63
+ : { 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) }, (((_e = (_d = states.leadFormState) === null || _d === void 0 ? void 0 : _d.validationErrors) === null || _e === void 0 ? void 0 : _e[content.checkboxName]) ? {
69
64
  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
65
  }
72
66
  : [])), intl.formatMessage({
73
67
  id: content.checkboxName + "-message",
74
68
  defaultMessage: content.checkboxLabel,
75
69
  }, {
76
70
  labelLink: (h("a", { href: content.checkboxLabelLink, target: "_blank" }, content.checkboxLabelLinkText || content.checkboxLabelLink)),
77
- }))));
71
+ })),
72
+ (validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors[content.checkboxName]) && (h("p", { class: sheet.classes.ErrorMessageStyle }, getRequiredFieldErrorMessage({
73
+ checkboxLabel: content.checkboxLabel,
74
+ })))));
78
75
  }
@@ -52,10 +52,10 @@ export class LeadCheckboxField {
52
52
  const content = {
53
53
  ...getProps(this),
54
54
  };
55
- const { states, callbacks } = isDemo()
55
+ const { states } = isDemo()
56
56
  ? useLeadCheckboxFieldDemo(this)
57
- : useLeadCheckboxField(this);
58
- return (h(LeadCheckboxFieldView, { states: states, content: content, callbacks: callbacks }));
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; checked: boolean; }; content?: { checkboxName: string; checkboxLabel: string; checkboxLabelLink?: string; checkboxLabelLinkText?: string; checkboxOptional?: boolean; errorMessage?: string; requiredFieldErrorMessage?: string; }; }",
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
- registrationFormState: {},
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(props) {
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
  }