@saasquatch/mint-components 1.14.7-5 → 1.14.7-7

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 (38) hide show
  1. package/dist/cjs/sqm-big-stat_43.cjs.entry.js +7 -1
  2. package/dist/cjs/sqm-lead-checkbox-field-view-34d94919.js +83 -0
  3. package/dist/cjs/sqm-lead-checkbox-field.cjs.entry.js +9 -102
  4. package/dist/cjs/sqm-stencilbook.cjs.entry.js +55 -2
  5. package/dist/collection/components/sqm-lead-form/LeadCheckboxField.stories.js +4 -63
  6. package/dist/collection/components/sqm-lead-form/sqm-lead-checkbox-field-view.js +2 -4
  7. package/dist/collection/components/sqm-lead-form/sqm-lead-checkbox-field.js +7 -11
  8. package/dist/collection/components/sqm-lead-form/useCheckboxField.js +1 -14
  9. package/dist/collection/components/sqm-lead-form/useLeadForm.js +7 -1
  10. package/dist/collection/components/sqm-stencilbook/sqm-stencilbook.js +2 -0
  11. package/dist/esm/sqm-big-stat_43.entry.js +7 -1
  12. package/dist/esm/sqm-lead-checkbox-field-view-a8c1c78e.js +81 -0
  13. package/dist/esm/sqm-lead-checkbox-field.entry.js +13 -106
  14. package/dist/esm/sqm-stencilbook.entry.js +55 -2
  15. package/dist/esm-es5/sqm-big-stat_43.entry.js +1 -1
  16. package/dist/esm-es5/sqm-lead-checkbox-field-view-a8c1c78e.js +1 -0
  17. package/dist/esm-es5/sqm-lead-checkbox-field.entry.js +1 -1
  18. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  19. package/dist/mint-components/mint-components.esm.js +1 -1
  20. package/dist/mint-components/p-00df0cac.js +1 -0
  21. package/dist/mint-components/p-0b4cac9f.system.entry.js +1 -0
  22. package/dist/mint-components/p-1d8c24d9.system.entry.js +1 -0
  23. package/dist/mint-components/p-37996351.system.js +1 -1
  24. package/dist/mint-components/p-48c69c2d.entry.js +1 -0
  25. package/dist/mint-components/p-95b88eb6.system.js +1 -0
  26. package/dist/mint-components/{p-f60d1ae9.entry.js → p-a94b5fc6.entry.js} +2 -2
  27. package/dist/mint-components/p-bddf7783.system.entry.js +1 -0
  28. package/dist/mint-components/{p-851eaf57.entry.js → p-fb0c586d.entry.js} +1 -1
  29. package/dist/types/components/sqm-lead-form/LeadCheckboxField.stories.d.ts +0 -27
  30. package/dist/types/components/sqm-lead-form/sqm-lead-checkbox-field-view.d.ts +0 -4
  31. package/dist/types/components/sqm-lead-form/useCheckboxField.d.ts +1 -6
  32. package/docs/docs.docx +0 -0
  33. package/docs/raisins.json +1 -1
  34. package/package.json +1 -1
  35. package/dist/mint-components/p-10a8ecae.system.entry.js +0 -1
  36. package/dist/mint-components/p-75eea63f.entry.js +0 -1
  37. package/dist/mint-components/p-81fbca73.system.entry.js +0 -1
  38. package/dist/mint-components/p-eaf1a8a6.system.entry.js +0 -1
@@ -1477,7 +1477,13 @@ 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
+ if (c.type === "checkbox") {
1481
+ c.checked = false;
1482
+ c.value = false;
1483
+ }
1484
+ else {
1485
+ c.value = "";
1486
+ }
1481
1487
  });
1482
1488
  setSuccess(false);
1483
1489
  }
@@ -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,108 +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-34d94919.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;
57
- const { states, content, callbacks } = props;
58
- const validationErrors = (_a = states === null || states === void 0 ? void 0 : states.leadFormState) === null || _a === void 0 ? void 0 : _a.validationErrors;
59
- const getRequiredFieldErrorMessage = ({ checkboxLabel, }) => global.intl.formatMessage({
60
- id: `requiredFieldErrorMessage-${checkboxLabel}`,
61
- defaultMessage: content.errorMessage,
62
- }, {
63
- checkboxLabel,
64
- });
65
- return (index.h("div", { class: sheet.classes.FieldContainer, part: "sqm-base" },
66
- index.h("style", { type: "text/css" },
67
- vanillaStyle,
68
- styleString),
69
- index.h("sl-checkbox", Object.assign({ exportparts: "label: input-label, base: input-base", name: `/${content.checkboxName}`, checked: states.checked, "onSl-change": (e) => {
70
- e.target.value = e.target.checked;
71
- callbacks.setChecked(e.target.value);
72
- } }, (!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 }) => {
73
- if (!value && !content.checkboxOptional) {
74
- return getRequiredFieldErrorMessage({
75
- checkboxLabel: content.checkboxLabel,
76
- });
77
- }
78
- } }, (((_e = (_d = states.leadFormState) === null || _d === void 0 ? void 0 : _d.validationErrors) === null || _e === void 0 ? void 0 : _e[content.checkboxName]) ? {
79
- class: sheet.classes.ErrorStyle,
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
- (validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors[content.checkboxName]) && (index.h("p", { class: sheet.classes.ErrorMessageStyle }, getRequiredFieldErrorMessage({
88
- checkboxLabel: content.checkboxLabel,
89
- })))));
90
- }
91
-
92
- function useLeadCheckboxField(props) {
93
- var _a;
15
+ function useLeadCheckboxField() {
94
16
  const leadFormState = stencilHooks_module.d(useLeadFormState.LEAD_FORM_STATE_CONTEXT);
95
- const [checked, setChecked] = stencilHooks_module.useState(false);
96
- stencilHooks_module.useEffect(() => {
97
- var _a, _b;
98
- if ((_a = leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.initialData) === null || _a === void 0 ? void 0 : _a[props.checkboxName]) {
99
- setChecked(!!((_b = leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.initialData) === null || _b === void 0 ? void 0 : _b[props.checkboxName]));
100
- }
101
- }, [(_a = leadFormState === null || leadFormState === void 0 ? void 0 : leadFormState.initialData) === null || _a === void 0 ? void 0 : _a[props.checkboxName]]);
102
17
  return {
103
18
  states: {
104
19
  leadFormState,
105
- checked,
106
- },
107
- callbacks: {
108
- setChecked,
109
20
  },
110
21
  };
111
22
  }
@@ -132,7 +43,7 @@ const LeadCheckboxField = class {
132
43
  /**
133
44
  * @uiName Unchecked error message
134
45
  */
135
- this.errorMessage = "{checkboxLabel} must be checked";
46
+ this.errorMessage = "Must be checked";
136
47
  /**
137
48
  * @uiName Optional
138
49
  */
@@ -153,20 +64,16 @@ const LeadCheckboxField = class {
153
64
  const content = {
154
65
  ...utils.getProps(this),
155
66
  };
156
- const { states, callbacks } = index_module.isDemo()
67
+ const { states } = index_module.isDemo()
157
68
  ? useLeadCheckboxFieldDemo(this)
158
- : useLeadCheckboxField(this);
159
- return (index.h(LeadCheckboxFieldView, { states: states, content: content, callbacks: callbacks }));
69
+ : useLeadCheckboxField();
70
+ return (index.h(sqmLeadCheckboxFieldView.LeadCheckboxFieldView, { states: states, content: content }));
160
71
  }
161
72
  };
162
73
  function useLeadCheckboxFieldDemo(props) {
163
74
  return cjs.cjs({
164
75
  states: {
165
- registrationFormState: {},
166
- checked: false,
167
- },
168
- callbacks: {
169
- setChecked: () => { },
76
+ leadFormState: {},
170
77
  },
171
78
  }, props.demoData || {}, { arrayMerge: (_, a) => a });
172
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');
@@ -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) {
@@ -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
  },
@@ -45,7 +44,7 @@ const sheet = jss.createStyleSheet(style);
45
44
  const styleString = sheet.toString();
46
45
  export function LeadCheckboxFieldView(props) {
47
46
  var _a, _b, _c, _d, _e;
48
- const { states, content, callbacks } = props;
47
+ const { states, content } = props;
49
48
  const validationErrors = (_a = states === null || states === void 0 ? void 0 : states.leadFormState) === null || _a === void 0 ? void 0 : _a.validationErrors;
50
49
  const getRequiredFieldErrorMessage = ({ checkboxLabel, }) => intl.formatMessage({
51
50
  id: `requiredFieldErrorMessage-${checkboxLabel}`,
@@ -57,9 +56,8 @@ export function LeadCheckboxFieldView(props) {
57
56
  h("style", { type: "text/css" },
58
57
  vanillaStyle,
59
58
  styleString),
60
- 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) => {
61
60
  e.target.value = e.target.checked;
62
- callbacks.setChecked(e.target.value);
63
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 }) => {
64
62
  if (!value && !content.checkboxOptional) {
65
63
  return getRequiredFieldErrorMessage({
@@ -31,7 +31,7 @@ export class LeadCheckboxField {
31
31
  /**
32
32
  * @uiName Unchecked error message
33
33
  */
34
- this.errorMessage = "{checkboxLabel} must be checked";
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, 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 {
@@ -167,7 +167,7 @@ export class LeadCheckboxField {
167
167
  },
168
168
  "attribute": "error-message",
169
169
  "reflect": false,
170
- "defaultValue": "\"{checkboxLabel} must be checked\""
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; checked: boolean; }; content?: { checkboxName: string; checkboxLabel: string; checkboxLabelLink?: string; checkboxLabelLinkText?: string; checkboxOptional?: boolean; errorMessage?: 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
  }
@@ -113,7 +113,13 @@ 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
- c.value = "";
116
+ if (c.type === "checkbox") {
117
+ c.checked = false;
118
+ c.value = false;
119
+ }
120
+ else {
121
+ c.value = "";
122
+ }
117
123
  });
118
124
  setSuccess(false);
119
125
  }
@@ -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
@@ -1473,7 +1473,13 @@ 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
- c.value = "";
1476
+ if (c.type === "checkbox") {
1477
+ c.checked = false;
1478
+ c.value = false;
1479
+ }
1480
+ else {
1481
+ c.value = "";
1482
+ }
1477
1483
  });
1478
1484
  setSuccess(false);
1479
1485
  }