@justeattakeaway/pie-checkbox 0.5.0 → 0.7.0

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/README.md CHANGED
@@ -71,17 +71,19 @@ import { PieCheckbox } from '@justeattakeaway/pie-checkbox/dist/react';
71
71
 
72
72
  ## Props
73
73
 
74
- | Property | Type | Default | Description |
75
- |---|---|---|---|
76
- | `name` | `string` | - | The name of the checkbox (used as a key/value pair with `value`). This is required in order to work properly with forms. |
77
- | `value` | `string` | 'on' | The value of the input (used as a key/value pair in HTML forms with `name`). If not passed falls back to the html default value "on". |
78
- | `required` | `boolean` | `false` | If true, the checkbox is required to be checked before submitting the form. If it is not in checked state, the component validity state will be invalid. |
79
- | `label` | `string` | '' | Text associated with the checkbox. If there is no label to provide, make sure to pass label, labelledby or describedby to the aria property. |
80
- | `disabled` | `boolean` | `false` | Indicates whether or not the checkbox is disabled. |
81
- | `checked` | `boolean` | `false` | Controls whether or not the checkbox is checked. |
82
- | `defaultChecked` | `boolean` | `false` | Sets the default checked state for the checkbox. This does not directly set the initial checked state when the page loads, use `checked` for that. If the checkbox is inside a form which is reset, the `checked` state will be updated to match `defaultChecked`. |
83
- | `indeterminate` | `boolean` | `false` | Indicates whether the checkbox visually shows a horizontal line in the box instead of a check/tick. It has no impact on whether the checkbox's value is used in a form submission. That is decided by the checked state, regardless of the indeterminate state. |
84
- | `aria` | `object` | {} | accepts `label`, `labeledby` and `describedby` keys with string values. |
74
+ | Property | Type | Default | Description |
75
+ |---|-------------------------------------|-----------|---|
76
+ | `name` | `string` | - | The name of the checkbox (used as a key/value pair with `value`). This is required in order to work properly with forms. |
77
+ | `value` | `string` | `'on'` | The value of the input (used as a key/value pair in HTML forms with `name`). If not passed falls back to the html default value "on". |
78
+ | `required` | `boolean` | `false` | If true, the checkbox is required to be checked before submitting the form. If it is not in checked state, the component validity state will be invalid. |
79
+ | `label` | `string` | `''` | Text associated with the checkbox. If there is no label to provide, make sure to pass label, labelledby or describedby to the aria property. |
80
+ | `disabled` | `boolean` | `false` | Indicates whether or not the checkbox is disabled. |
81
+ | `checked` | `boolean` | `false` | Controls whether or not the checkbox is checked. |
82
+ | `defaultChecked` | `boolean` | `false` | Sets the default checked state for the checkbox. This does not directly set the initial checked state when the page loads, use `checked` for that. If the checkbox is inside a form which is reset, the `checked` state will be updated to match `defaultChecked`. |
83
+ | `indeterminate` | `boolean` | `false` | Indicates whether the checkbox visually shows a horizontal line in the box instead of a check/tick. It has no impact on whether the checkbox's value is used in a form submission. That is decided by the checked state, regardless of the indeterminate state. |
84
+ | `aria` | `object` | {} | accepts `label`, `labeledby` and `describedby` keys with string values. |
85
+ | `assistiveText` | `string` | `''` | Allows assistive text to be displayed below the checkbox element. |
86
+ | `status` | `'default'`, `'error'`, `'success'` | `'default'` | The status of the checkbox component / assistive text. If you use `status` you must provide an `assistiveText` prop value for accessibility purposes. |
85
87
 
86
88
  In your markup or JSX, you can then use these to set the properties for the `pie-checkbox` component:
87
89
 
@@ -12,16 +12,32 @@
12
12
  "kind": "javascript-module",
13
13
  "path": "src/defs.js",
14
14
  "declarations": [
15
+ {
16
+ "kind": "variable",
17
+ "name": "statusTypes",
18
+ "type": {
19
+ "text": "['default', 'success', 'error']"
20
+ },
21
+ "default": "['default', 'success', 'error']"
22
+ },
15
23
  {
16
24
  "kind": "variable",
17
25
  "name": "defaultProps",
18
26
  "type": {
19
27
  "text": "DefaultProps"
20
28
  },
21
- "default": "{\n // a default value for the html <input type=\"checkbox\" /> value attribute.\n // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#value\n value: 'on',\n required: false,\n defaultChecked: false,\n indeterminate: false,\n checked: false,\n}"
29
+ "default": "{\n // a default value for the html <input type=\"checkbox\" /> value attribute.\n // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#value\n value: 'on',\n required: false,\n defaultChecked: false,\n indeterminate: false,\n checked: false,\n status: 'default',\n}"
22
30
  }
23
31
  ],
24
32
  "exports": [
33
+ {
34
+ "kind": "js",
35
+ "name": "statusTypes",
36
+ "declaration": {
37
+ "name": "statusTypes",
38
+ "module": "src/defs.js"
39
+ }
40
+ },
25
41
  {
26
42
  "kind": "js",
27
43
  "name": "defaultProps",
@@ -101,9 +117,6 @@
101
117
  {
102
118
  "kind": "field",
103
119
  "name": "required",
104
- "type": {
105
- "text": "CheckboxProps['required'] | undefined"
106
- },
107
120
  "privacy": "public",
108
121
  "attribute": "required",
109
122
  "reflects": true
@@ -111,9 +124,6 @@
111
124
  {
112
125
  "kind": "field",
113
126
  "name": "indeterminate",
114
- "type": {
115
- "text": "CheckboxProps['indeterminate'] | undefined"
116
- },
117
127
  "privacy": "public",
118
128
  "attribute": "indeterminate",
119
129
  "reflects": true
@@ -135,6 +145,21 @@
135
145
  },
136
146
  "privacy": "private"
137
147
  },
148
+ {
149
+ "kind": "field",
150
+ "name": "assistiveText",
151
+ "type": {
152
+ "text": "CheckboxProps['assistiveText'] | undefined"
153
+ },
154
+ "privacy": "public",
155
+ "attribute": "assistiveText"
156
+ },
157
+ {
158
+ "kind": "field",
159
+ "name": "status",
160
+ "privacy": "public",
161
+ "attribute": "status"
162
+ },
138
163
  {
139
164
  "kind": "field",
140
165
  "name": "validity",
@@ -248,16 +273,10 @@
248
273
  },
249
274
  {
250
275
  "name": "required",
251
- "type": {
252
- "text": "CheckboxProps['required'] | undefined"
253
- },
254
276
  "fieldName": "required"
255
277
  },
256
278
  {
257
279
  "name": "indeterminate",
258
- "type": {
259
- "text": "CheckboxProps['indeterminate'] | undefined"
260
- },
261
280
  "fieldName": "indeterminate"
262
281
  },
263
282
  {
@@ -266,6 +285,17 @@
266
285
  "text": "CheckboxProps['aria']"
267
286
  },
268
287
  "fieldName": "aria"
288
+ },
289
+ {
290
+ "name": "assistiveText",
291
+ "type": {
292
+ "text": "CheckboxProps['assistiveText'] | undefined"
293
+ },
294
+ "fieldName": "assistiveText"
295
+ },
296
+ {
297
+ "name": "status",
298
+ "fieldName": "status"
269
299
  }
270
300
  ],
271
301
  "mixins": [
package/dist/index.d.ts CHANGED
@@ -10,7 +10,6 @@ import type { TemplateResult } from 'lit-html';
10
10
  export declare type AriaProps = {
11
11
  label?: string;
12
12
  labelledby?: string;
13
- describedby?: string;
14
13
  };
15
14
 
16
15
  export declare interface CheckboxProps {
@@ -51,9 +50,17 @@ export declare interface CheckboxProps {
51
50
  * Various ARIA attributes.
52
51
  */
53
52
  aria?: AriaProps;
53
+ /**
54
+ * An optional assistive text to display below the input element. Must be provided when the status is success or error.
55
+ */
56
+ assistiveText?: string;
57
+ /**
58
+ * The status of the checkbox component / assistive text. Can be default, success or error.
59
+ */
60
+ status?: typeof statusTypes[number];
54
61
  }
55
62
 
56
- export declare type DefaultProps = ComponentDefaultPropsGeneric<CheckboxProps, 'value' | 'required' | 'indeterminate' | 'checked' | 'defaultChecked'>;
63
+ export declare type DefaultProps = ComponentDefaultPropsGeneric<CheckboxProps, 'value' | 'required' | 'indeterminate' | 'checked' | 'defaultChecked' | 'status'>;
57
64
 
58
65
  export declare const defaultProps: DefaultProps;
59
66
 
@@ -73,10 +80,12 @@ export declare class PieCheckbox extends PieCheckbox_base implements CheckboxPro
73
80
  checked: boolean;
74
81
  defaultChecked: boolean;
75
82
  disabled?: CheckboxProps['disabled'];
76
- required?: CheckboxProps['required'];
77
- indeterminate?: CheckboxProps['indeterminate'];
83
+ required: boolean;
84
+ indeterminate: boolean;
78
85
  aria: CheckboxProps['aria'];
79
86
  private checkbox;
87
+ assistiveText?: CheckboxProps['assistiveText'];
88
+ status: "default" | "error" | "success";
80
89
  /**
81
90
  * (Read-only) returns a ValidityState with the validity states that this element is in.
82
91
  * https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity
@@ -112,4 +121,6 @@ export declare class PieCheckbox extends PieCheckbox_base implements CheckboxPro
112
121
 
113
122
  declare const PieCheckbox_base: GenericConstructor<FormControlInterface> & GenericConstructor<RTLInterface> & typeof LitElement;
114
123
 
124
+ export declare const statusTypes: readonly ["default", "success", "error"];
125
+
115
126
  export { }
package/dist/index.js CHANGED
@@ -1,27 +1,29 @@
1
- import { LitElement as u, html as f, nothing as h, unsafeCSS as b } from "lit";
2
- import { FormControlMixin as y, RtlMixin as k, wrapNativeEvent as v, defineCustomElement as C } from "@justeattakeaway/pie-webc-core";
3
- import { live as g } from "lit/directives/live.js";
4
- import { property as s, query as x } from "lit/decorators.js";
5
- import { ifDefined as $ } from "lit/directives/if-defined.js";
6
- const F = `*,*:after,*:before{box-sizing:inherit}
7
- `, d = {
1
+ import { LitElement as g, html as u, nothing as h, unsafeCSS as w } from "lit";
2
+ import { property as c, query as $ } from "lit/decorators.js";
3
+ import { ifDefined as f } from "lit/directives/if-defined.js";
4
+ import { live as x } from "lit/directives/live.js";
5
+ import { FormControlMixin as C, RtlMixin as F, wrapNativeEvent as E, validPropertyValues as S, defineCustomElement as q } from "@justeattakeaway/pie-webc-core";
6
+ import "@justeattakeaway/pie-assistive-text";
7
+ const A = `*,*:after,*:before{box-sizing:inherit}@keyframes checkboxCheck{0%{width:0;height:0;border-color:#fff;transform:translateZ(0) rotate(45deg)}33%{width:8px;height:0;transform:translateZ(0) rotate(45deg)}to{width:8px;height:16px;border-color:#fff;border-bottom-right-radius:2px;transform:translate3d(0,-16px,0) rotate(45deg)}}@keyframes scaleDown{0%{transform:scale(.7)}to{transform:scale(0)}}@keyframes scaleUp{0%{transform:scale(0)}33%{transform:scale(.5)}to{transform:scale(1)}}.c-checkbox-tick{content:"";display:flex;flex:0 0 auto;width:var(--checkbox-width);height:var(--checkbox-height);margin:var(--checkbox-margin);border:1px solid var(--checkbox-border-color);border-radius:var(--checkbox-radius);background-color:var(--checkbox-bg-color)}@media (prefers-reduced-motion: no-preference){.c-checkbox-tick{transition:background-color var(--dt-motion-timing-100) var(--checkbox-motion-easing);animation:scaleDown var(--dt-motion-timing-100) var(--checkbox-motion-easing)}}.c-checkbox-tick[data-pie-disabled]{--checkbox-bg-color: var(--dt-color-container-strong);--checkbox-border-color: var(--dt-color-disabled-01)}.c-checkbox-tick[data-pie-status=error]{--checkbox-border-color: var(--dt-color-support-error)}@media (prefers-reduced-motion: no-preference){.c-checkbox-tick[data-pie-checked]{animation:scaleUp var(--dt-motion-timing-100) var(--checkbox-motion-easing)}}.c-checkbox-tick[data-pie-checked]:not([data-pie-disabled]){--checkbox-bg-color: var(--dt-color-interactive-brand);--checkbox-border-color: var(--dt-color-interactive-brand)}.c-checkbox-tick[data-pie-checked][data-pie-status=error]{--checkbox-border-color: var(--dt-color-support-error);--checkbox-bg-color: var(--dt-color-support-error)}.c-checkbox-tick[data-pie-checked]:before{content:"";position:relative;top:55%;left:14%;border-right:2px solid transparent;border-bottom:2px solid transparent;transform:rotate(45deg);transform-origin:0% 100%;animation:checkboxCheck var(--dt-motion-timing-150) var(--checkbox-motion-easing) forwards}@media (prefers-reduced-motion: reduce){.c-checkbox-tick[data-pie-checked]:before{animation:none;width:8px;height:16px;border-color:#fff;border-bottom-right-radius:2px;transform:translate3d(0,-16px,0) rotate(45deg)}}@media only percy{.c-checkbox-tick[data-pie-checked]:before{animation:none;width:8px;height:16px;border-color:#fff;border-bottom-right-radius:2px;transform:translate3d(0,-16px,0) rotate(45deg)}}.c-checkbox-tick[data-pie-indeterminate]:not([data-pie-disabled]){--checkbox-bg-color: var(--dt-color-interactive-brand);--checkbox-border-color: var(--dt-color-interactive-brand)}.c-checkbox-tick[data-pie-indeterminate][data-pie-status=error]{--checkbox-border-color: var(--dt-color-support-error);--checkbox-bg-color: var(--dt-color-support-error)}.c-checkbox-tick[data-pie-indeterminate]:after{width:16px}@media (prefers-reduced-motion: no-preference){.c-checkbox-tick[data-pie-indeterminate]:after{transition:width var(--dt-motion-timing-100) var(--checkbox-motion-easing) var(--dt-motion-timing-100)}}.c-checkbox-text{display:inline;flex:1 1 auto;align-self:center;min-width:0;margin-inline-start:var(--checkbox-gap);white-space:normal;color:var(--checkbox-content-color);font-size:var(--checkbox-font-size);font-weight:var(--checkbox-font-weight)}.c-checkbox-tick:after{content:"";position:relative;top:47%;left:14%;width:0;height:2px;background-color:#fff}.c-checkbox{--checkbox-height: 24px;--checkbox-width: 24px;--checkbox-radius: var(--dt-radius-rounded-a);--checkbox-margin: 1px;--checkbox-gap: var(--dt-spacing-b);--checkbox-font-size: var(--dt-font-body-l-size);--checkbox-font-weight: var(--dt-font-weight-regular);--checkbox-bg-color: var(--dt-color-container-default);--checkbox-border-color: var(--dt-color-interactive-form);--checkbox-content-color: var(--dt-color-content-default);--checkbox-motion-easing: var(--dt-motion-easing-persistent-functional);display:flex;flex-direction:column}.c-checkbox input{display:block;position:absolute;height:1px;width:1px;overflow:hidden;clip:rect(1px,1px,1px,1px);clip-path:inset(1px);white-space:nowrap}.c-checkbox label{display:flex;max-width:100%;white-space:nowrap;cursor:pointer}.c-checkbox:hover .c-checkbox-tick{--checkbox-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + calc(-1 * var(--dt-color-hover-01))));transition:background-color var(--dt-motion-timing-200) var(--checkbox-motion-easing)}.c-checkbox:active .c-checkbox-tick{--checkbox-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + calc(-1 * var(--dt-color-active-01))));transition:background-color var(--dt-motion-timing-100) var(--checkbox-motion-easing)}.c-checkbox[data-pie-disabled] label{cursor:default;pointer-events:none}.c-checkbox input:focus-visible+label .c-checkbox-tick{box-shadow:0 0 0 2px var(--dt-color-focus-inner),0 0 0 4px var(--dt-color-focus-outer);outline:none}.c-checkbox[data-pie-disabled]:hover .c-checkbox-tick,.c-checkbox[data-pie-disabled]:active .c-checkbox-tick{--checkbox-bg-color: var(--dt-color-container-strong);--checkbox-border-color: var(--dt-color-disabled-01)}.c-checkbox[data-pie-status=error]:hover .c-checkbox-tick{--checkbox-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + calc(-1 * var(--dt-color-hover-01))))}.c-checkbox[data-pie-status=error]:active .c-checkbox-tick{--checkbox-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + calc(-1 * var(--dt-color-active-01))))}.c-checkbox[data-pie-checked]:not([data-pie-disabled]):hover .c-checkbox-tick,.c-checkbox[data-pie-indeterminate]:not([data-pie-disabled]):hover .c-checkbox-tick{--checkbox-bg-color: hsl(var(--dt-color-interactive-brand-h), var(--dt-color-interactive-brand-s), calc(var(--dt-color-interactive-brand-l) + calc(-1 * var(--dt-color-hover-01))));--checkbox-border-color: hsl(var(--dt-color-interactive-brand-h), var(--dt-color-interactive-brand-s), calc(var(--dt-color-interactive-brand-l) + calc(-1 * var(--dt-color-hover-01))))}.c-checkbox[data-pie-checked][data-pie-status=error]:hover .c-checkbox-tick,.c-checkbox[data-pie-indeterminate][data-pie-status=error]:hover .c-checkbox-tick{--checkbox-bg-color: hsl(var(--dt-color-support-error-h), var(--dt-color-support-error-s), calc(var(--dt-color-support-error-l) + calc(-1 * var(--dt-color-hover-01))));--checkbox-border-color: hsl(var(--dt-color-support-error-h), var(--dt-color-support-error-s), calc(var(--dt-color-support-error-l) + calc(-1 * var(--dt-color-hover-01))))}.c-checkbox[data-pie-checked]:not([data-pie-disabled]):active .c-checkbox-tick,.c-checkbox[data-pie-indeterminate]:not([data-pie-disabled]):active .c-checkbox-tick{--checkbox-bg-color: hsl(var(--dt-color-interactive-brand-h), var(--dt-color-interactive-brand-s), calc(var(--dt-color-interactive-brand-l) + calc(-1 * var(--dt-color-active-01))));--checkbox-border-color: hsl(var(--dt-color-interactive-brand-h), var(--dt-color-interactive-brand-s), calc(var(--dt-color-interactive-brand-l) + calc(-1 * var(--dt-color-active-01))))}.c-checkbox[data-pie-checked][data-pie-status=error]:active .c-checkbox-tick,.c-checkbox[data-pie-indeterminate][data-pie-status=error]:active .c-checkbox-tick{--checkbox-bg-color: hsl(var(--dt-color-support-error-h), var(--dt-color-support-error-s), calc(var(--dt-color-support-error-l) + calc(-1 * var(--dt-color-active-01))));--checkbox-border-color: hsl(var(--dt-color-support-error-h), var(--dt-color-support-error-s), calc(var(--dt-color-support-error-l) + calc(-1 * var(--dt-color-active-01))))}
8
+ `, O = ["default", "success", "error"], n = {
8
9
  // a default value for the html <input type="checkbox" /> value attribute.
9
10
  // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#value
10
11
  value: "on",
11
12
  required: !1,
12
13
  defaultChecked: !1,
13
14
  indeterminate: !1,
14
- checked: !1
15
+ checked: !1,
16
+ status: "default"
15
17
  };
16
- var E = Object.defineProperty, q = Object.getOwnPropertyDescriptor, r = (p, e, n, a) => {
17
- for (var o = a > 1 ? void 0 : a ? q(e, n) : e, c = p.length - 1, l; c >= 0; c--)
18
- (l = p[c]) && (o = (a ? l(e, n, o) : l(o)) || o);
19
- return a && o && E(e, n, o), o;
18
+ var P = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, o = (b, e, d, i) => {
19
+ for (var r = i > 1 ? void 0 : i ? _(e, d) : e, a = b.length - 1, s; a >= 0; a--)
20
+ (s = b[a]) && (r = (i ? s(e, d, r) : s(r)) || r);
21
+ return i && r && P(e, d, r), r;
20
22
  };
21
- const A = "pie-checkbox";
22
- class t extends y(k(u)) {
23
+ const y = "pie-checkbox", m = "assistive-text";
24
+ class t extends C(F(g)) {
23
25
  constructor() {
24
- super(...arguments), this.value = d.value, this.checked = d.checked, this.defaultChecked = d.defaultChecked, this.required = d.required, this.indeterminate = d.indeterminate;
26
+ super(...arguments), this.value = n.value, this.checked = n.checked, this.defaultChecked = n.defaultChecked, this.required = n.required, this.indeterminate = n.indeterminate, this.status = n.status;
25
27
  }
26
28
  /**
27
29
  * (Read-only) returns a ValidityState with the validity states that this element is in.
@@ -56,10 +58,10 @@ class t extends y(k(u)) {
56
58
  * @param {Event} event - This should be the change event that was listened for on an input element with `type="checkbox"`.
57
59
  */
58
60
  handleChange(e) {
59
- const { checked: n } = e == null ? void 0 : e.currentTarget;
60
- this.checked = n;
61
- const a = v(e);
62
- this.dispatchEvent(a), this.handleFormAssociation();
61
+ const { checked: d } = e == null ? void 0 : e.currentTarget;
62
+ this.checked = d;
63
+ const i = E(e);
64
+ this.dispatchEvent(i), this.handleFormAssociation();
63
65
  }
64
66
  /**
65
67
  * Called when the form that contains this component is reset.
@@ -76,68 +78,99 @@ class t extends y(k(u)) {
76
78
  render() {
77
79
  const {
78
80
  checked: e,
79
- value: n,
80
- name: a,
81
- label: o,
82
- disabled: c,
83
- required: l,
84
- indeterminate: m,
85
- aria: i
81
+ value: d,
82
+ name: i,
83
+ label: r,
84
+ disabled: a,
85
+ required: s,
86
+ indeterminate: p,
87
+ aria: l,
88
+ assistiveText: k,
89
+ status: v
86
90
  } = this;
87
- return f`
88
- <label data-test-id="checkbox-component">
91
+ return u`
92
+ <div
93
+ class="c-checkbox"
94
+ data-pie-status=${!a && v}
95
+ ?data-pie-disabled=${x(a)}
96
+ ?data-pie-checked=${e}
97
+ ?data-pie-indeterminate=${p && !e}>
89
98
  <input
90
99
  type="checkbox"
91
- .value=${n}
92
- .checked=${g(e)}
93
- name=${$(a)}
94
- ?disabled=${c}
95
- ?required=${l}
96
- .indeterminate=${!!m}
97
- aria-label=${(i == null ? void 0 : i.label) || h}
98
- aria-labelledby=${o ? h : (i == null ? void 0 : i.labelledby) || h}
99
- aria-describedby= ${(i == null ? void 0 : i.describedby) || h}
100
+ id="inputId"
101
+ .value=${d}
102
+ .checked=${x(e)}
103
+ name=${f(i)}
104
+ ?disabled=${a}
105
+ ?required=${s}
106
+ .indeterminate=${p}
107
+ aria-label=${(l == null ? void 0 : l.label) || h}
108
+ aria-labelledby=${r ? h : (l == null ? void 0 : l.labelledby) || h}
109
+ aria-describedby=${f(k ? m : void 0)}
100
110
  @change=${this.handleChange}
101
111
  data-test-id="checkbox-input"
102
112
  />
103
- ${o}
104
- </label>`;
113
+ <label for="inputId" data-test-id="checkbox-component">
114
+ <span
115
+ class="c-checkbox-tick"
116
+ ?data-pie-checked=${e}
117
+ ?data-pie-disabled=${x(a)}
118
+ data-pie-status=${!a && v}
119
+ ?data-pie-indeterminate=${p && !e}></span>
120
+ <span class="c-checkbox-text">${r}</span>
121
+ </label>
122
+ ${k ? u`
123
+ <pie-assistive-text
124
+ id="${m}"
125
+ variant=${v}
126
+ data-test-id="pie-checkbox-assistive-text">
127
+ ${k}
128
+ </pie-assistive-text>` : h}
129
+ </div>`;
105
130
  }
106
131
  }
107
- t.shadowRootOptions = { ...u.shadowRootOptions, delegatesFocus: !0 };
108
- t.styles = b(F);
109
- r([
110
- s({ type: String })
132
+ t.shadowRootOptions = { ...g.shadowRootOptions, delegatesFocus: !0 };
133
+ t.styles = w(A);
134
+ o([
135
+ c({ type: String })
111
136
  ], t.prototype, "value", 2);
112
- r([
113
- s({ type: String })
137
+ o([
138
+ c({ type: String })
114
139
  ], t.prototype, "label", 2);
115
- r([
116
- s({ type: String })
140
+ o([
141
+ c({ type: String })
117
142
  ], t.prototype, "name", 2);
118
- r([
119
- s({ type: Boolean, reflect: !0 })
143
+ o([
144
+ c({ type: Boolean, reflect: !0 })
120
145
  ], t.prototype, "checked", 2);
121
- r([
122
- s({ type: Boolean, reflect: !0 })
146
+ o([
147
+ c({ type: Boolean, reflect: !0 })
123
148
  ], t.prototype, "defaultChecked", 2);
124
- r([
125
- s({ type: Boolean, reflect: !0 })
149
+ o([
150
+ c({ type: Boolean, reflect: !0 })
126
151
  ], t.prototype, "disabled", 2);
127
- r([
128
- s({ type: Boolean, reflect: !0 })
152
+ o([
153
+ c({ type: Boolean, reflect: !0 })
129
154
  ], t.prototype, "required", 2);
130
- r([
131
- s({ type: Boolean, reflect: !0 })
155
+ o([
156
+ c({ type: Boolean, reflect: !0 })
132
157
  ], t.prototype, "indeterminate", 2);
133
- r([
134
- s({ type: Object })
158
+ o([
159
+ c({ type: Object })
135
160
  ], t.prototype, "aria", 2);
136
- r([
137
- x('input[type="checkbox"]')
161
+ o([
162
+ $('input[type="checkbox"]')
138
163
  ], t.prototype, "checkbox", 2);
139
- C(A, t);
164
+ o([
165
+ c({ type: String })
166
+ ], t.prototype, "assistiveText", 2);
167
+ o([
168
+ c({ type: String }),
169
+ S(y, O, n.status)
170
+ ], t.prototype, "status", 2);
171
+ q(y, t);
140
172
  export {
141
173
  t as PieCheckbox,
142
- d as defaultProps
174
+ n as defaultProps,
175
+ O as statusTypes
143
176
  };
package/dist/react.d.ts CHANGED
@@ -11,7 +11,6 @@ import type { TemplateResult } from 'lit-html';
11
11
  export declare type AriaProps = {
12
12
  label?: string;
13
13
  labelledby?: string;
14
- describedby?: string;
15
14
  };
16
15
 
17
16
  export declare interface CheckboxProps {
@@ -52,9 +51,17 @@ export declare interface CheckboxProps {
52
51
  * Various ARIA attributes.
53
52
  */
54
53
  aria?: AriaProps;
54
+ /**
55
+ * An optional assistive text to display below the input element. Must be provided when the status is success or error.
56
+ */
57
+ assistiveText?: string;
58
+ /**
59
+ * The status of the checkbox component / assistive text. Can be default, success or error.
60
+ */
61
+ status?: typeof statusTypes[number];
55
62
  }
56
63
 
57
- export declare type DefaultProps = ComponentDefaultPropsGeneric<CheckboxProps, 'value' | 'required' | 'indeterminate' | 'checked' | 'defaultChecked'>;
64
+ export declare type DefaultProps = ComponentDefaultPropsGeneric<CheckboxProps, 'value' | 'required' | 'indeterminate' | 'checked' | 'defaultChecked' | 'status'>;
58
65
 
59
66
  export declare const defaultProps: DefaultProps;
60
67
 
@@ -76,10 +83,12 @@ declare class PieCheckbox_2 extends PieCheckbox_base implements CheckboxProps {
76
83
  checked: boolean;
77
84
  defaultChecked: boolean;
78
85
  disabled?: CheckboxProps['disabled'];
79
- required?: CheckboxProps['required'];
80
- indeterminate?: CheckboxProps['indeterminate'];
86
+ required: boolean;
87
+ indeterminate: boolean;
81
88
  aria: CheckboxProps['aria'];
82
89
  private checkbox;
90
+ assistiveText?: CheckboxProps['assistiveText'];
91
+ status: "default" | "error" | "success";
83
92
  /**
84
93
  * (Read-only) returns a ValidityState with the validity states that this element is in.
85
94
  * https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity
@@ -121,4 +130,6 @@ declare type PieCheckboxEvents = {
121
130
 
122
131
  declare type ReactBaseType = React_2.InputHTMLAttributes<HTMLInputElement>;
123
132
 
133
+ export declare const statusTypes: readonly ["default", "success", "error"];
134
+
124
135
  export { }
package/dist/react.js CHANGED
@@ -1,12 +1,13 @@
1
1
  import * as e from "react";
2
2
  import { createComponent as o } from "@lit/react";
3
3
  import { PieCheckbox as t } from "./index.js";
4
- import { defaultProps as b } from "./index.js";
4
+ import { defaultProps as k, statusTypes as P } from "./index.js";
5
5
  import "lit";
6
- import "@justeattakeaway/pie-webc-core";
7
- import "lit/directives/live.js";
8
6
  import "lit/decorators.js";
9
7
  import "lit/directives/if-defined.js";
8
+ import "lit/directives/live.js";
9
+ import "@justeattakeaway/pie-webc-core";
10
+ import "@justeattakeaway/pie-assistive-text";
10
11
  const r = o({
11
12
  displayName: "PieCheckbox",
12
13
  elementClass: t,
@@ -16,8 +17,9 @@ const r = o({
16
17
  onChange: "change"
17
18
  // when checked state is changed.
18
19
  }
19
- }), h = r;
20
+ }), x = r;
20
21
  export {
21
- h as PieCheckbox,
22
- b as defaultProps
22
+ x as PieCheckbox,
23
+ k as defaultProps,
24
+ P as statusTypes
23
25
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-checkbox",
3
3
  "description": "PIE Design System Checkbox built using Web Components",
4
- "version": "0.5.0",
4
+ "version": "0.7.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -40,6 +40,7 @@
40
40
  "cem-plugin-module-file-extensions": "0.0.5"
41
41
  },
42
42
  "dependencies": {
43
+ "@justeattakeaway/pie-assistive-text": "0.5.0",
43
44
  "@justeattakeaway/pie-webc-core": "0.23.0"
44
45
  },
45
46
  "volta": {
package/src/checkbox.scss CHANGED
@@ -1 +1,299 @@
1
1
  @use '@justeattakeaway/pie-css/scss' as p;
2
+
3
+ @keyframes checkboxCheck {
4
+ 0% {
5
+ width: 0;
6
+ height: 0;
7
+ border-color: #fff;
8
+
9
+ transform: translate3d(0, 0, 0) rotate(45deg);
10
+ }
11
+
12
+ 33% {
13
+ width: 8px;
14
+ height: 0;
15
+
16
+ transform: translate3d(0, 0, 0) rotate(45deg);
17
+ }
18
+
19
+ 100% {
20
+ width: 8px;
21
+ height: 16px;
22
+ border-color: #fff;
23
+ border-bottom-right-radius: 2px;
24
+
25
+
26
+ transform: translate3d(0, -16px, 0) rotate(45deg);
27
+ }
28
+ }
29
+
30
+ @keyframes scaleDown {
31
+ 0% {
32
+ transform: scale(0.7);
33
+ }
34
+
35
+ 100% {
36
+ transform: scale(0);
37
+ }
38
+ }
39
+
40
+ @keyframes scaleUp {
41
+ 0% {
42
+ transform: scale(0);
43
+ }
44
+
45
+ 33% {
46
+ transform: scale(0.5);
47
+ }
48
+
49
+ 100% {
50
+ transform: scale(1);
51
+ }
52
+ }
53
+
54
+ .c-checkbox-tick {
55
+ content: "";
56
+ display: flex;
57
+
58
+ flex: 0 0 auto;
59
+
60
+ width: var(--checkbox-width);
61
+ height: var(--checkbox-height);
62
+
63
+ margin: var(--checkbox-margin);
64
+
65
+ border: 1px solid var(--checkbox-border-color);
66
+ border-radius: var(--checkbox-radius);
67
+ background-color: var(--checkbox-bg-color);
68
+
69
+ @media (prefers-reduced-motion: no-preference) {
70
+ transition: background-color var(--dt-motion-timing-100) var(--checkbox-motion-easing);
71
+
72
+ animation: scaleDown var(--dt-motion-timing-100) var(--checkbox-motion-easing);
73
+ }
74
+
75
+ &[data-pie-disabled] {
76
+ --checkbox-bg-color: var(--dt-color-container-strong);
77
+ --checkbox-border-color: var(--dt-color-disabled-01);
78
+ }
79
+
80
+ &[data-pie-status="error"] {
81
+ --checkbox-border-color: var(--dt-color-support-error);
82
+ }
83
+
84
+ &[data-pie-checked] {
85
+ @media (prefers-reduced-motion: no-preference) {
86
+ animation: scaleUp var(--dt-motion-timing-100) var(--checkbox-motion-easing);
87
+ }
88
+
89
+ &:not([data-pie-disabled]) {
90
+ --checkbox-bg-color: var(--dt-color-interactive-brand);
91
+ --checkbox-border-color: var(--dt-color-interactive-brand);
92
+ }
93
+
94
+ &[data-pie-status="error"] {
95
+ --checkbox-border-color: var(--dt-color-support-error);
96
+ --checkbox-bg-color: var(--dt-color-support-error);
97
+ }
98
+ }
99
+
100
+ &[data-pie-checked]:before {
101
+ content: "";
102
+
103
+ position: relative;
104
+ top: 55%;
105
+ left: 14%;
106
+
107
+ border-right: 2px solid transparent;
108
+ border-bottom: 2px solid transparent;
109
+
110
+ transform: rotate(45deg);
111
+ transform-origin: 0% 100%;
112
+
113
+ animation: checkboxCheck var(--dt-motion-timing-150) var(--checkbox-motion-easing) forwards;
114
+
115
+ @media (prefers-reduced-motion: reduce) {
116
+ animation: none;
117
+ width: 8px;
118
+ height: 16px;
119
+ border-color: #fff;
120
+ border-bottom-right-radius: 2px;
121
+
122
+ transform: translate3d(0, -16px, 0) rotate(45deg);
123
+ }
124
+
125
+ @media only percy {
126
+ animation: none;
127
+
128
+ width: 8px;
129
+ height: 16px;
130
+ border-color: #fff;
131
+ border-bottom-right-radius: 2px;
132
+
133
+ transform: translate3d(0, -16px, 0) rotate(45deg);
134
+ }
135
+ }
136
+
137
+ &[data-pie-indeterminate] {
138
+ &:not([data-pie-disabled]) {
139
+ --checkbox-bg-color: var(--dt-color-interactive-brand);
140
+ --checkbox-border-color: var(--dt-color-interactive-brand);
141
+ }
142
+
143
+ &[data-pie-status="error"] {
144
+ --checkbox-border-color: var(--dt-color-support-error);
145
+ --checkbox-bg-color: var(--dt-color-support-error);
146
+ }
147
+ }
148
+
149
+ &[data-pie-indeterminate]:after {
150
+ width: 16px;
151
+
152
+ @media (prefers-reduced-motion: no-preference) {
153
+ transition: width var(--dt-motion-timing-100) var(--checkbox-motion-easing) var(--dt-motion-timing-100);
154
+ }
155
+ }
156
+ }
157
+
158
+ .c-checkbox-text {
159
+ display: inline;
160
+ flex: 1 1 auto;
161
+ align-self: center;
162
+ min-width: 0;
163
+ margin-inline-start: var(--checkbox-gap);
164
+ white-space: normal;
165
+ color: var(--checkbox-content-color);
166
+ font-size: var(--checkbox-font-size);
167
+ font-weight: var(--checkbox-font-weight);
168
+ }
169
+
170
+ // initial styles for indeterminate state
171
+ .c-checkbox-tick:after {
172
+ content: "";
173
+
174
+ position: relative;
175
+ top: 47%;
176
+ left: 14%;
177
+ width: 0;
178
+ height: 2px;
179
+ background-color: white;
180
+ }
181
+
182
+ .c-checkbox {
183
+ --checkbox-height: 24px;
184
+ --checkbox-width: 24px;
185
+ --checkbox-radius: var(--dt-radius-rounded-a);
186
+ --checkbox-margin: 1px;
187
+ --checkbox-gap: var(--dt-spacing-b);
188
+ --checkbox-font-size: var(--dt-font-body-l-size);
189
+ --checkbox-font-weight: var(--dt-font-weight-regular);
190
+ --checkbox-bg-color: var(--dt-color-container-default);
191
+ --checkbox-border-color: var(--dt-color-interactive-form);
192
+ --checkbox-content-color: var(--dt-color-content-default);
193
+ --checkbox-motion-easing: var(--dt-motion-easing-persistent-functional);
194
+
195
+ display: flex;
196
+ flex-direction: column;
197
+
198
+ input {
199
+ display: block;
200
+ position: absolute;
201
+ height: 1px;
202
+ width: 1px;
203
+ overflow: hidden;
204
+ clip: rect(1px, 1px, 1px, 1px);
205
+ clip-path: inset(1px);
206
+ white-space: nowrap;
207
+ }
208
+
209
+ label {
210
+ display: flex;
211
+ max-width: 100%;
212
+ white-space: nowrap;
213
+ cursor: pointer;
214
+ }
215
+
216
+ &:hover {
217
+ .c-checkbox-tick {
218
+ --checkbox-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + calc(-1 * var(--dt-color-hover-01))));
219
+
220
+ transition: background-color var(--dt-motion-timing-200) var(--checkbox-motion-easing);
221
+ }
222
+ }
223
+
224
+ &:active {
225
+ .c-checkbox-tick {
226
+ --checkbox-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + calc(-1 * var(--dt-color-active-01))));
227
+
228
+ transition: background-color var(--dt-motion-timing-100) var(--checkbox-motion-easing);
229
+ }
230
+ }
231
+
232
+ &[data-pie-disabled] {
233
+ label {
234
+ cursor: default;
235
+ pointer-events: none;
236
+ }
237
+ }
238
+
239
+ input:focus-visible + label {
240
+ .c-checkbox-tick {
241
+ @include p.focus;
242
+ }
243
+ }
244
+
245
+ &[data-pie-disabled] {
246
+ &:hover,
247
+ &:active {
248
+ .c-checkbox-tick {
249
+ --checkbox-bg-color: var(--dt-color-container-strong);
250
+ --checkbox-border-color: var(--dt-color-disabled-01);
251
+ }
252
+ }
253
+ }
254
+
255
+ &[data-pie-status="error"] {
256
+ &:hover {
257
+ .c-checkbox-tick {
258
+ --checkbox-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + calc(-1 * var(--dt-color-hover-01))));
259
+ }
260
+ }
261
+
262
+ &:active {
263
+ .c-checkbox-tick {
264
+ --checkbox-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + calc(-1 * var(--dt-color-active-01))));
265
+ }
266
+ }
267
+ }
268
+
269
+ &[data-pie-checked],
270
+ &[data-pie-indeterminate] {
271
+ &:not([data-pie-disabled]):hover {
272
+ .c-checkbox-tick {
273
+ --checkbox-bg-color: hsl(var(--dt-color-interactive-brand-h), var(--dt-color-interactive-brand-s), calc(var(--dt-color-interactive-brand-l) + calc(-1 * var(--dt-color-hover-01))));
274
+ --checkbox-border-color: hsl(var(--dt-color-interactive-brand-h), var(--dt-color-interactive-brand-s), calc(var(--dt-color-interactive-brand-l) + calc(-1 * var(--dt-color-hover-01))));
275
+ }
276
+ }
277
+
278
+ &[data-pie-status="error"]:hover {
279
+ .c-checkbox-tick {
280
+ --checkbox-bg-color: hsl(var(--dt-color-support-error-h), var(--dt-color-support-error-s), calc(var(--dt-color-support-error-l) + calc(-1 * var(--dt-color-hover-01))));
281
+ --checkbox-border-color: hsl(var(--dt-color-support-error-h), var(--dt-color-support-error-s), calc(var(--dt-color-support-error-l) + calc(-1 * var(--dt-color-hover-01))));
282
+ }
283
+ }
284
+
285
+ &:not([data-pie-disabled]):active {
286
+ .c-checkbox-tick {
287
+ --checkbox-bg-color: hsl(var(--dt-color-interactive-brand-h), var(--dt-color-interactive-brand-s), calc(var(--dt-color-interactive-brand-l) + calc(-1 * var(--dt-color-active-01))));
288
+ --checkbox-border-color: hsl(var(--dt-color-interactive-brand-h), var(--dt-color-interactive-brand-s), calc(var(--dt-color-interactive-brand-l) + calc(-1 * var(--dt-color-active-01))));
289
+ }
290
+ }
291
+
292
+ &[data-pie-status="error"]:active {
293
+ .c-checkbox-tick {
294
+ --checkbox-bg-color: hsl(var(--dt-color-support-error-h), var(--dt-color-support-error-s), calc(var(--dt-color-support-error-l) + calc(-1 * var(--dt-color-active-01))));
295
+ --checkbox-border-color: hsl(var(--dt-color-support-error-h), var(--dt-color-support-error-s), calc(var(--dt-color-support-error-l) + calc(-1 * var(--dt-color-active-01))));
296
+ }
297
+ }
298
+ }
299
+ }
package/src/defs.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
2
2
 
3
+ export const statusTypes = ['default', 'success', 'error'] as const;
4
+
3
5
  export type AriaProps = {
4
6
  label?: string;
5
7
  labelledby?: string;
6
- describedby?: string;
7
8
  };
8
9
  export interface CheckboxProps {
9
10
  /**
@@ -51,9 +52,19 @@ export interface CheckboxProps {
51
52
  * Various ARIA attributes.
52
53
  */
53
54
  aria?: AriaProps;
55
+
56
+ /**
57
+ * An optional assistive text to display below the input element. Must be provided when the status is success or error.
58
+ */
59
+ assistiveText?: string;
60
+
61
+ /**
62
+ * The status of the checkbox component / assistive text. Can be default, success or error.
63
+ */
64
+ status?: typeof statusTypes[number];
54
65
  }
55
66
 
56
- export type DefaultProps = ComponentDefaultPropsGeneric<CheckboxProps, 'value' | 'required' | 'indeterminate' | 'checked' | 'defaultChecked'>;
67
+ export type DefaultProps = ComponentDefaultPropsGeneric<CheckboxProps, 'value' | 'required' | 'indeterminate' | 'checked' | 'defaultChecked' | 'status'>;
57
68
 
58
69
  export const defaultProps: DefaultProps = {
59
70
  // a default value for the html <input type="checkbox" /> value attribute.
@@ -63,4 +74,5 @@ export const defaultProps: DefaultProps = {
63
74
  defaultChecked: false,
64
75
  indeterminate: false,
65
76
  checked: false,
77
+ status: 'default',
66
78
  };
package/src/index.ts CHANGED
@@ -1,23 +1,27 @@
1
1
  import {
2
2
  LitElement, html, unsafeCSS, PropertyValues, nothing,
3
3
  } from 'lit';
4
+ import { property, query } from 'lit/decorators.js';
5
+ import { ifDefined } from 'lit/directives/if-defined.js';
6
+ import { live } from 'lit/directives/live.js';
7
+
4
8
  import {
5
9
  RtlMixin,
6
10
  defineCustomElement,
7
11
  wrapNativeEvent,
8
12
  FormControlMixin,
13
+ validPropertyValues,
9
14
  } from '@justeattakeaway/pie-webc-core';
10
- import { live } from 'lit/directives/live.js';
11
- import { property, query } from 'lit/decorators.js';
12
- import { ifDefined } from 'lit/directives/if-defined.js';
15
+ import '@justeattakeaway/pie-assistive-text';
13
16
 
14
17
  import styles from './checkbox.scss?inline';
15
- import { CheckboxProps, defaultProps } from './defs';
18
+ import { CheckboxProps, defaultProps, statusTypes } from './defs';
16
19
 
17
20
  // Valid values available to consumers
18
21
  export * from './defs';
19
22
 
20
23
  const componentSelector = 'pie-checkbox';
24
+ const assistiveTextIdValue = 'assistive-text';
21
25
 
22
26
  /**
23
27
  * @tagname pie-checkbox
@@ -45,10 +49,10 @@ export class PieCheckbox extends FormControlMixin(RtlMixin(LitElement)) implemen
45
49
  public disabled?: CheckboxProps['disabled'];
46
50
 
47
51
  @property({ type: Boolean, reflect: true })
48
- public required?: CheckboxProps['required'] = defaultProps.required;
52
+ public required = defaultProps.required;
49
53
 
50
54
  @property({ type: Boolean, reflect: true })
51
- public indeterminate?: CheckboxProps['indeterminate'] = defaultProps.indeterminate;
55
+ public indeterminate = defaultProps.indeterminate;
52
56
 
53
57
  @property({ type: Object })
54
58
  public aria: CheckboxProps['aria'];
@@ -56,6 +60,13 @@ export class PieCheckbox extends FormControlMixin(RtlMixin(LitElement)) implemen
56
60
  @query('input[type="checkbox"]')
57
61
  private checkbox!: HTMLInputElement;
58
62
 
63
+ @property({ type: String })
64
+ public assistiveText?: CheckboxProps['assistiveText'];
65
+
66
+ @property({ type: String })
67
+ @validPropertyValues(componentSelector, statusTypes, defaultProps.status)
68
+ public status = defaultProps.status;
69
+
59
70
  /**
60
71
  * (Read-only) returns a ValidityState with the validity states that this element is in.
61
72
  * https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity
@@ -139,26 +150,49 @@ export class PieCheckbox extends FormControlMixin(RtlMixin(LitElement)) implemen
139
150
  required,
140
151
  indeterminate,
141
152
  aria,
153
+ assistiveText,
154
+ status,
142
155
  } = this;
143
156
 
144
157
  return html`
145
- <label data-test-id="checkbox-component">
158
+ <div
159
+ class="c-checkbox"
160
+ data-pie-status=${!disabled && status}
161
+ ?data-pie-disabled=${live(disabled)}
162
+ ?data-pie-checked=${checked}
163
+ ?data-pie-indeterminate=${indeterminate && !checked}>
146
164
  <input
147
165
  type="checkbox"
166
+ id="inputId"
148
167
  .value=${value}
149
168
  .checked=${live(checked)}
150
169
  name=${ifDefined(name)}
151
170
  ?disabled=${disabled}
152
171
  ?required=${required}
153
- .indeterminate=${!!indeterminate}
172
+ .indeterminate=${indeterminate}
154
173
  aria-label=${aria?.label || nothing}
155
174
  aria-labelledby=${label ? nothing : aria?.labelledby || nothing}
156
- aria-describedby= ${aria?.describedby || nothing}
175
+ aria-describedby=${ifDefined(assistiveText ? assistiveTextIdValue : undefined)}
157
176
  @change=${this.handleChange}
158
177
  data-test-id="checkbox-input"
159
178
  />
160
- ${label}
161
- </label>`;
179
+ <label for="inputId" data-test-id="checkbox-component">
180
+ <span
181
+ class="c-checkbox-tick"
182
+ ?data-pie-checked=${checked}
183
+ ?data-pie-disabled=${live(disabled)}
184
+ data-pie-status=${!disabled && status}
185
+ ?data-pie-indeterminate=${indeterminate && !checked}></span>
186
+ <span class="c-checkbox-text">${label}</span>
187
+ </label>
188
+ ${assistiveText ? html`
189
+ <pie-assistive-text
190
+ id="${assistiveTextIdValue}"
191
+ variant=${status}
192
+ data-test-id="pie-checkbox-assistive-text">
193
+ ${assistiveText}
194
+ </pie-assistive-text>` : nothing}
195
+ </div>`;
162
196
  }
163
197
 
164
198
  // Renders a `CSSResult` generated from SCSS by Vite