@saasquatch/mint-components 1.14.9-0 → 1.14.9

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 (66) hide show
  1. package/dist/cjs/{ShadowViewAddon-3c344355.js → ShadowViewAddon-28865623.js} +12 -4
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/mint-components.cjs.js +1 -1
  4. package/dist/cjs/sqm-big-stat_43.cjs.entry.js +10 -3
  5. package/dist/cjs/sqm-lead-checkbox-field-view-34d94919.js +83 -0
  6. package/dist/cjs/sqm-lead-checkbox-field.cjs.entry.js +81 -0
  7. package/dist/cjs/sqm-lead-input-field.cjs.entry.js +1 -1
  8. package/dist/cjs/sqm-stencilbook.cjs.entry.js +56 -3
  9. package/dist/collection/collection-manifest.json +1 -0
  10. package/dist/collection/components/sqm-checkbox-field/sqm-checkbox-field-view.js +11 -4
  11. package/dist/collection/components/sqm-lead-form/LeadCheckboxField.stories.js +44 -0
  12. package/dist/collection/components/sqm-lead-form/sqm-lead-checkbox-field-view.js +79 -0
  13. package/dist/collection/components/sqm-lead-form/sqm-lead-checkbox-field.js +234 -0
  14. package/dist/collection/components/sqm-lead-form/sqm-lead-form.js +1 -0
  15. package/dist/collection/components/sqm-lead-form/useCheckboxField.js +10 -0
  16. package/dist/collection/components/sqm-lead-form/useLeadForm.js +8 -1
  17. package/dist/collection/components/sqm-portal-register/sqm-portal-register.js +1 -0
  18. package/dist/collection/components/sqm-portal-registration-form/sqm-portal-registration-form.js +1 -0
  19. package/dist/collection/components/sqm-stencilbook/sqm-stencilbook.js +2 -0
  20. package/dist/esm/{ShadowViewAddon-64194d20.js → ShadowViewAddon-f2176779.js} +12 -4
  21. package/dist/esm/loader.js +1 -1
  22. package/dist/esm/mint-components.js +1 -1
  23. package/dist/esm/sqm-big-stat_43.entry.js +10 -3
  24. package/dist/esm/sqm-lead-checkbox-field-view-a8c1c78e.js +81 -0
  25. package/dist/esm/sqm-lead-checkbox-field.entry.js +77 -0
  26. package/dist/esm/sqm-lead-input-field.entry.js +1 -1
  27. package/dist/esm/sqm-stencilbook.entry.js +56 -3
  28. package/dist/esm-es5/ShadowViewAddon-f2176779.js +1 -0
  29. package/dist/esm-es5/loader.js +1 -1
  30. package/dist/esm-es5/mint-components.js +1 -1
  31. package/dist/esm-es5/sqm-big-stat_43.entry.js +1 -1
  32. package/dist/esm-es5/sqm-lead-checkbox-field-view-a8c1c78e.js +1 -0
  33. package/dist/esm-es5/sqm-lead-checkbox-field.entry.js +1 -0
  34. package/dist/esm-es5/sqm-lead-input-field.entry.js +1 -1
  35. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  36. package/dist/mint-components/mint-components.esm.js +1 -1
  37. package/dist/mint-components/p-00df0cac.js +1 -0
  38. package/dist/mint-components/p-0b4cac9f.system.entry.js +1 -0
  39. package/dist/mint-components/p-0d939b73.system.js +1 -0
  40. package/dist/mint-components/{p-d3e72503.entry.js → p-12bba567.entry.js} +1 -1
  41. package/dist/mint-components/p-37996351.system.js +1 -1
  42. package/dist/mint-components/p-48c69c2d.entry.js +1 -0
  43. package/dist/mint-components/p-4cff3345.system.entry.js +1 -0
  44. package/dist/mint-components/{p-0a4f1306.entry.js → p-653a8a7b.entry.js} +10 -10
  45. package/dist/mint-components/{p-fbbb85f0.system.entry.js → p-8c0b7881.system.entry.js} +1 -1
  46. package/dist/mint-components/p-95b88eb6.system.js +1 -0
  47. package/dist/mint-components/p-a01e3c3d.system.entry.js +1 -0
  48. package/dist/mint-components/p-c1b074b6.js +394 -0
  49. package/dist/mint-components/{p-f60d1ae9.entry.js → p-c4ce8578.entry.js} +2 -2
  50. package/dist/types/components/sqm-lead-form/LeadCheckboxField.stories.d.ts +28 -0
  51. package/dist/types/components/sqm-lead-form/sqm-lead-checkbox-field-view.d.ts +15 -0
  52. package/dist/types/components/sqm-lead-form/sqm-lead-checkbox-field.d.ts +46 -0
  53. package/dist/types/components/sqm-lead-form/sqm-lead-form.d.ts +1 -0
  54. package/dist/types/components/sqm-lead-form/useCheckboxField.d.ts +6 -0
  55. package/dist/types/components/sqm-portal-register/sqm-portal-register.d.ts +1 -0
  56. package/dist/types/components/sqm-portal-registration-form/sqm-portal-registration-form.d.ts +1 -0
  57. package/dist/types/components.d.ts +80 -0
  58. package/docs/docs.docx +0 -0
  59. package/docs/raisins.json +1 -1
  60. package/grapesjs/grapesjs.js +1 -1
  61. package/package.json +1 -1
  62. package/dist/esm-es5/ShadowViewAddon-64194d20.js +0 -1
  63. package/dist/mint-components/p-0d94d81a.system.js +0 -1
  64. package/dist/mint-components/p-30a11ec0.js +0 -394
  65. package/dist/mint-components/p-74fdf750.system.entry.js +0 -1
  66. package/dist/mint-components/p-eaf1a8a6.system.entry.js +0 -1
@@ -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-3c344355.js');
39
+ const ShadowViewAddon = require('./ShadowViewAddon-28865623.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) {
@@ -42,6 +42,7 @@
42
42
  "./components/sqm-invoice-table/columns/sqm-invoice-table-data-column.js",
43
43
  "./components/sqm-invoice-table/columns/sqm-invoice-table-date-column.js",
44
44
  "./components/sqm-invoice-table/columns/sqm-invoice-table-download-column.js",
45
+ "./components/sqm-lead-form/sqm-lead-checkbox-field.js",
45
46
  "./components/sqm-lead-form/sqm-lead-dropdown-field.js",
46
47
  "./components/sqm-lead-form/sqm-lead-form.js",
47
48
  "./components/sqm-lead-form/sqm-lead-input-field.js",
@@ -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,7 +43,7 @@ jss.setup(preset());
44
43
  const sheet = jss.createStyleSheet(style);
45
44
  const styleString = sheet.toString();
46
45
  export function CheckboxFieldView(props) {
47
- var _a, _b, _c;
46
+ var _a, _b, _c, _d, _e;
48
47
  const { states, content, callbacks } = props;
49
48
  const validationErrors = (_a = states === null || states === void 0 ? void 0 : states.registrationFormState) === null || _a === void 0 ? void 0 : _a.validationErrors;
50
49
  return (h("div", { class: sheet.classes.FieldContainer, part: "sqm-base" },
@@ -54,10 +53,18 @@ export function CheckboxFieldView(props) {
54
53
  h("sl-checkbox", Object.assign({ exportparts: "label: input-label, base: input-base", name: `/${content.checkboxName}`, checked: states.checked, "onSl-change": (e) => {
55
54
  e.target.value = e.target.checked;
56
55
  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({
56
+ } }, (!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), validationError: ({ value }) => {
57
+ if (!value && !content.checkboxOptional) {
58
+ return content.errorMessage;
59
+ }
60
+ } }, (((_e = (_d = states.registrationFormState) === null || _d === void 0 ? void 0 : _d.validationErrors) === null || _e === void 0 ? void 0 : _e[content.checkboxName]) ? {
61
+ class: sheet.classes.ErrorStyle,
62
+ }
63
+ : [])), intl.formatMessage({
58
64
  id: content.checkboxName + "-message",
59
65
  defaultMessage: content.checkboxLabel,
60
66
  }, {
61
67
  labelLink: (h("a", { href: content.checkboxLabelLink, target: "_blank" }, content.checkboxLabelLinkText || content.checkboxLabelLink)),
62
- }))));
68
+ })),
69
+ (validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors[content.checkboxName]) && (h("p", { class: sheet.classes.ErrorMessageStyle }, content.errorMessage))));
63
70
  }
@@ -0,0 +1,44 @@
1
+ import { h } from "@stencil/core";
2
+ import { createHookStory } from "../sqm-stencilbook/HookStoryAddon";
3
+ import { LeadCheckboxFieldView, } from "./sqm-lead-checkbox-field-view";
4
+ export default {
5
+ title: "Components/Lead Checkbox Field",
6
+ };
7
+ const defaultProps = {
8
+ states: {
9
+ leadFormState: {
10
+ validationErrors: {},
11
+ },
12
+ },
13
+ content: {
14
+ checkboxName: "terms",
15
+ checkboxLabel: "By signing up you agree to the {labelLink}",
16
+ checkboxLabelLink: "https://example.com",
17
+ checkboxLabelLinkText: "Terms and Conditions",
18
+ errorMessage: "{checkboxLabel} Must be checked",
19
+ },
20
+ };
21
+ export const Default = createHookStory(() => (h(LeadCheckboxFieldView, Object.assign({}, defaultProps))));
22
+ export const CustomLabel = createHookStory(() => (h(LeadCheckboxFieldView, Object.assign({}, defaultProps, { content: {
23
+ ...defaultProps.content,
24
+ checkboxLabel: "I Agree",
25
+ } }))));
26
+ export const Error = createHookStory(() => (h(LeadCheckboxFieldView, Object.assign({}, defaultProps, { states: {
27
+ ...defaultProps.states,
28
+ leadFormState: {
29
+ validationErrors: {
30
+ terms: "{checkboxLabel} Must be checked",
31
+ },
32
+ },
33
+ } }))));
34
+ export const CustomError = createHookStory(() => (h(LeadCheckboxFieldView, Object.assign({}, defaultProps, { states: {
35
+ ...defaultProps.states,
36
+ leadFormState: {
37
+ validationErrors: {
38
+ terms: "{checkboxLabel} Must be checked",
39
+ },
40
+ },
41
+ }, content: {
42
+ ...defaultProps.content,
43
+ errorMessage: "This checkbox must be checked to continue",
44
+ } }))));
@@ -0,0 +1,79 @@
1
+ import { h } from "@stencil/core";
2
+ import jss from "jss";
3
+ import preset from "jss-preset-default";
4
+ import { intl } from "../../global/global";
5
+ const style = {
6
+ ErrorStyle: {
7
+ "&::part(control)": {
8
+ borderColor: "var(--sl-color-danger-500)",
9
+ outline: "var(--sl-color-danger-500)",
10
+ },
11
+ "&:host": {
12
+ "--focus-ring": "0 0 0 var(--sl-focus-ring-width) red !important",
13
+ },
14
+ },
15
+ ErrorMessageStyle: {
16
+ margin: 0,
17
+ marginTop: "5px",
18
+ color: "var(--sl-color-danger-500)",
19
+ fontSize: "var(--sl-input-help-text-font-size-medium)",
20
+ fontFamily: "var(--sl-font-sans)",
21
+ fontWeight: "var(--sl-font-weight-normal)",
22
+ },
23
+ FieldContainer: {
24
+ "margin-bottom": "var(--sl-spacing-large)",
25
+ },
26
+ };
27
+ const vanillaStyle = `
28
+ :host {
29
+ margin: 0 auto;
30
+ width: 100%;
31
+ display: block;
32
+ }
33
+ sl-checkbox::part(label){
34
+ font-size: var(--sl-input-label-font-size-small);
35
+ font-weight: var(--sl-font-weight-normal);
36
+ line-height: 20px;
37
+ }
38
+ sl-checkbox::part(base){
39
+ align-items: start;
40
+ }
41
+ `;
42
+ jss.setup(preset());
43
+ const sheet = jss.createStyleSheet(style);
44
+ const styleString = sheet.toString();
45
+ export function LeadCheckboxFieldView(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
+ const getRequiredFieldErrorMessage = ({ checkboxLabel, }) => intl.formatMessage({
50
+ id: `requiredFieldErrorMessage-${checkboxLabel}`,
51
+ defaultMessage: content.errorMessage,
52
+ }, {
53
+ checkboxLabel,
54
+ });
55
+ return (h("div", { class: sheet.classes.FieldContainer, part: "sqm-base" },
56
+ h("style", { type: "text/css" },
57
+ vanillaStyle,
58
+ styleString),
59
+ h("sl-checkbox", Object.assign({ exportparts: "label: input-label, base: input-base", name: `/${content.checkboxName}`, "onSl-change": (e) => {
60
+ e.target.value = e.target.checked;
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({
71
+ id: content.checkboxName + "-message",
72
+ defaultMessage: content.checkboxLabel,
73
+ }, {
74
+ labelLink: (h("a", { href: content.checkboxLabelLink, target: "_blank" }, content.checkboxLabelLinkText || content.checkboxLabelLink)),
75
+ })),
76
+ (validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors[content.checkboxName]) && (h("p", { class: sheet.classes.ErrorMessageStyle }, getRequiredFieldErrorMessage({
77
+ checkboxLabel: content.checkboxLabel,
78
+ })))));
79
+ }
@@ -0,0 +1,234 @@
1
+ import { isDemo } from "@saasquatch/component-boilerplate";
2
+ import { withHooks } from "@saasquatch/stencil-hooks";
3
+ import { Component, h, Prop, State } from "@stencil/core";
4
+ import deepmerge from "deepmerge";
5
+ import { RequiredPropsError } from "../../utils/RequiredPropsError";
6
+ import { getMissingProps, getProps } from "../../utils/utils";
7
+ import { LeadCheckboxFieldView, } from "./sqm-lead-checkbox-field-view";
8
+ import { useLeadCheckboxField } from "./useCheckboxField";
9
+ /**
10
+ * @uiName Lead Form Checkbox Field
11
+ * @validParents ["sqm-lead-form"]
12
+ */
13
+ export class LeadCheckboxField {
14
+ constructor() {
15
+ this.ignored = true;
16
+ /**
17
+ * @uiName Checkbox label
18
+ * @uiWidget textArea
19
+ */
20
+ this.checkboxLabel = "By signing up you agree to the {labelLink}";
21
+ /**
22
+ * Used with link text if the checkbox label contains {labelLink}
23
+ *
24
+ * @uiName Checkbox label link
25
+ */
26
+ this.checkboxLabelLink = "https://example.com";
27
+ /**
28
+ * @uiName Checkbox label link lext
29
+ */
30
+ this.checkboxLabelLinkText = "Terms and Conditions";
31
+ /**
32
+ * @uiName Unchecked error message
33
+ */
34
+ this.errorMessage = "Must be checked";
35
+ /**
36
+ * @uiName Optional
37
+ */
38
+ this.checkboxOptional = false;
39
+ withHooks(this);
40
+ }
41
+ disconnectedCallback() { }
42
+ render() {
43
+ const missingProps = getMissingProps([
44
+ {
45
+ attribute: "checkbox-name",
46
+ value: this.checkboxName,
47
+ },
48
+ ]);
49
+ if (!isDemo() && missingProps) {
50
+ return (h(RequiredPropsError, { missingProps: missingProps, heading: "An error occured while loading this form", subheading: "A technical problem prevented this checkbox field from loading. Please contact us with the link to this page.", description: "Values for the following attributes are missing:" }));
51
+ }
52
+ const content = {
53
+ ...getProps(this),
54
+ };
55
+ const { states } = isDemo()
56
+ ? useLeadCheckboxFieldDemo(this)
57
+ : useLeadCheckboxField();
58
+ return (h(LeadCheckboxFieldView, { states: states, content: content }));
59
+ }
60
+ static get is() { return "sqm-lead-checkbox-field"; }
61
+ static get properties() { return {
62
+ "checkboxName": {
63
+ "type": "string",
64
+ "mutable": false,
65
+ "complexType": {
66
+ "original": "string",
67
+ "resolved": "string",
68
+ "references": {}
69
+ },
70
+ "required": false,
71
+ "optional": false,
72
+ "docs": {
73
+ "tags": [{
74
+ "text": "Checkbox name attribute",
75
+ "name": "uiName"
76
+ }, {
77
+ "text": undefined,
78
+ "name": "required"
79
+ }],
80
+ "text": "This name is used as the key for this form field on submission. The name must be unique within this specific form."
81
+ },
82
+ "attribute": "checkbox-name",
83
+ "reflect": false
84
+ },
85
+ "checkboxLabel": {
86
+ "type": "string",
87
+ "mutable": false,
88
+ "complexType": {
89
+ "original": "string",
90
+ "resolved": "string",
91
+ "references": {}
92
+ },
93
+ "required": false,
94
+ "optional": false,
95
+ "docs": {
96
+ "tags": [{
97
+ "text": "Checkbox label",
98
+ "name": "uiName"
99
+ }, {
100
+ "text": "textArea",
101
+ "name": "uiWidget"
102
+ }],
103
+ "text": ""
104
+ },
105
+ "attribute": "checkbox-label",
106
+ "reflect": false,
107
+ "defaultValue": "\"By signing up you agree to the {labelLink}\""
108
+ },
109
+ "checkboxLabelLink": {
110
+ "type": "string",
111
+ "mutable": false,
112
+ "complexType": {
113
+ "original": "string",
114
+ "resolved": "string",
115
+ "references": {}
116
+ },
117
+ "required": false,
118
+ "optional": true,
119
+ "docs": {
120
+ "tags": [{
121
+ "text": "Checkbox label link",
122
+ "name": "uiName"
123
+ }],
124
+ "text": "Used with link text if the checkbox label contains {labelLink}"
125
+ },
126
+ "attribute": "checkbox-label-link",
127
+ "reflect": false,
128
+ "defaultValue": "\"https://example.com\""
129
+ },
130
+ "checkboxLabelLinkText": {
131
+ "type": "string",
132
+ "mutable": false,
133
+ "complexType": {
134
+ "original": "string",
135
+ "resolved": "string",
136
+ "references": {}
137
+ },
138
+ "required": false,
139
+ "optional": true,
140
+ "docs": {
141
+ "tags": [{
142
+ "text": "Checkbox label link lext",
143
+ "name": "uiName"
144
+ }],
145
+ "text": ""
146
+ },
147
+ "attribute": "checkbox-label-link-text",
148
+ "reflect": false,
149
+ "defaultValue": "\"Terms and Conditions\""
150
+ },
151
+ "errorMessage": {
152
+ "type": "string",
153
+ "mutable": false,
154
+ "complexType": {
155
+ "original": "string",
156
+ "resolved": "string",
157
+ "references": {}
158
+ },
159
+ "required": false,
160
+ "optional": true,
161
+ "docs": {
162
+ "tags": [{
163
+ "text": "Unchecked error message",
164
+ "name": "uiName"
165
+ }],
166
+ "text": ""
167
+ },
168
+ "attribute": "error-message",
169
+ "reflect": false,
170
+ "defaultValue": "\"Must be checked\""
171
+ },
172
+ "checkboxOptional": {
173
+ "type": "boolean",
174
+ "mutable": false,
175
+ "complexType": {
176
+ "original": "boolean",
177
+ "resolved": "boolean",
178
+ "references": {}
179
+ },
180
+ "required": false,
181
+ "optional": true,
182
+ "docs": {
183
+ "tags": [{
184
+ "text": "Optional",
185
+ "name": "uiName"
186
+ }],
187
+ "text": ""
188
+ },
189
+ "attribute": "checkbox-optional",
190
+ "reflect": false,
191
+ "defaultValue": "false"
192
+ },
193
+ "demoData": {
194
+ "type": "unknown",
195
+ "mutable": false,
196
+ "complexType": {
197
+ "original": "DemoData<LeadCheckboxFieldViewProps>",
198
+ "resolved": "{ states?: { leadFormState?: LeadFormState; }; content?: { checkboxName: string; checkboxLabel: string; checkboxLabelLink?: string; checkboxLabelLinkText?: string; checkboxOptional?: boolean; errorMessage?: string; }; }",
199
+ "references": {
200
+ "DemoData": {
201
+ "location": "import",
202
+ "path": "../../global/demo"
203
+ },
204
+ "LeadCheckboxFieldViewProps": {
205
+ "location": "import",
206
+ "path": "./sqm-lead-checkbox-field-view"
207
+ }
208
+ }
209
+ },
210
+ "required": false,
211
+ "optional": true,
212
+ "docs": {
213
+ "tags": [{
214
+ "text": undefined,
215
+ "name": "undocumented"
216
+ }, {
217
+ "text": "object",
218
+ "name": "uiType"
219
+ }],
220
+ "text": ""
221
+ }
222
+ }
223
+ }; }
224
+ static get states() { return {
225
+ "ignored": {}
226
+ }; }
227
+ }
228
+ function useLeadCheckboxFieldDemo(props) {
229
+ return deepmerge({
230
+ states: {
231
+ leadFormState: {},
232
+ },
233
+ }, props.demoData || {}, { arrayMerge: (_, a) => a });
234
+ }
@@ -6,6 +6,7 @@ import { LeadFormView } from "./sqm-lead-form-view";
6
6
  import { useLeadForm } from "./useLeadForm";
7
7
  /**
8
8
  * @uiName Lead Form
9
+ * @canvasRenderer always-replace
9
10
  * @slots [{"name":"formData","title":"Additional Fields"}]
10
11
  */
11
12
  export class LeadForm {
@@ -0,0 +1,10 @@
1
+ import { useDomContext } from "@saasquatch/stencil-hooks";
2
+ import { LEAD_FORM_STATE_CONTEXT } from "./useLeadFormState";
3
+ export function useLeadCheckboxField() {
4
+ const leadFormState = useDomContext(LEAD_FORM_STATE_CONTEXT);
5
+ return {
6
+ states: {
7
+ leadFormState,
8
+ },
9
+ };
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
- c.value = "";
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
  }
@@ -6,6 +6,7 @@ import { PortalRegisterView, } from "./sqm-portal-register-view";
6
6
  import { usePortalRegister } from "./usePortalRegister";
7
7
  /**
8
8
  * @uiName Microsite Registration
9
+ * @canvasRenderer always-replace
9
10
  * @slots [{"name":"formData","title":"Additional Fields"},{"name":"terms","title":"Terms And Conditions Fields"}]
10
11
  */
11
12
  export class PortalRegister {
@@ -6,6 +6,7 @@ import { PortalRegistrationFormView, } from "./sqm-portal-registration-form-view
6
6
  import { usePortalRegistrationForm } from "./usePortalRegistrationForm";
7
7
  /**
8
8
  * @uiName Microsite Registration
9
+ * @canvasRenderer always-replace
9
10
  * @slots [{"name":"formData","title":"Additional Fields"},{"name":"terms","title":"Terms And Conditions Fields"},{"name":"emailOptIn","title":"Email Opt-in Fields"}]
10
11
  */
11
12
  export class PortalRegistrationForm {
@@ -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
@@ -1663,7 +1663,6 @@ function PortalRegisterView(props) {
1663
1663
  const style$4 = {
1664
1664
  ErrorStyle: {
1665
1665
  "&::part(control)": {
1666
- background: "var(--sl-color-danger-10)",
1667
1666
  borderColor: "var(--sl-color-danger-500)",
1668
1667
  outline: "var(--sl-color-danger-500)",
1669
1668
  },
@@ -1702,8 +1701,9 @@ jss.setup(create());
1702
1701
  const sheet$4 = jss.createStyleSheet(style$4);
1703
1702
  const styleString$4 = sheet$4.toString();
1704
1703
  function CheckboxFieldView(props) {
1705
- var _b, _c;
1704
+ var _a, _b, _c, _d, _e;
1706
1705
  const { states, content, callbacks } = props;
1706
+ const validationErrors = (_a = states === null || states === void 0 ? void 0 : states.registrationFormState) === null || _a === void 0 ? void 0 : _a.validationErrors;
1707
1707
  return (h("div", { class: sheet$4.classes.FieldContainer, part: "sqm-base" },
1708
1708
  h("style", { type: "text/css" },
1709
1709
  vanillaStyle$2,
@@ -1711,12 +1711,20 @@ 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), required: false }), intl.formatMessage({
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), validationError: ({ value }) => {
1715
+ if (!value && !content.checkboxOptional) {
1716
+ return content.errorMessage;
1717
+ }
1718
+ } }, (((_e = (_d = states.registrationFormState) === null || _d === void 0 ? void 0 : _d.validationErrors) === null || _e === void 0 ? void 0 : _e[content.checkboxName]) ? {
1719
+ class: sheet$4.classes.ErrorStyle,
1720
+ }
1721
+ : [])), intl.formatMessage({
1715
1722
  id: content.checkboxName + "-message",
1716
1723
  defaultMessage: content.checkboxLabel,
1717
1724
  }, {
1718
1725
  labelLink: (h("a", { href: content.checkboxLabelLink, target: "_blank" }, content.checkboxLabelLinkText || content.checkboxLabelLink)),
1719
- }))));
1726
+ })),
1727
+ (validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors[content.checkboxName]) && (h("p", { class: sheet$4.classes.ErrorMessageStyle }, content.errorMessage))));
1720
1728
  }
1721
1729
 
1722
1730
  function ChangeMarktingView(props) {