@justeattakeaway/pie-checkbox 0.1.0 → 0.3.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
@@ -15,7 +15,8 @@
15
15
  3. [Importing the component](#importing-the-component)
16
16
  4. [Peer Dependencies](#peer-dependencies)
17
17
  5. [Props](#props)
18
- 6. [Contributing](#contributing)
18
+ 6. [Events](#events)
19
+ 7. [Contributing](#contributing)
19
20
 
20
21
  ## pie-checkbox
21
22
 
@@ -74,18 +75,36 @@ import { PieCheckbox } from '@justeattakeaway/pie-checkbox/dist/react';
74
75
 
75
76
  | Property | Type | Default | Description |
76
77
  |---|---|---|---|
77
- | - | - | - | - |
78
+ | `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. |
79
+ | `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". |
80
+ | `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. |
81
+ | `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. |
82
+ | `disabled` | `boolean` | `false` | Indicates whether or not the checkbox is disabled. |
83
+ | `checked` | `boolean` | `false` | Indicates whether or not the checkbox is checked by default (when the page loads). |
84
+ | `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. |
85
+ | `aria` | `object` | {} | accepts `label`, `labeledby` and `describedby` keys with string values. |
78
86
 
79
87
  In your markup or JSX, you can then use these to set the properties for the `pie-checkbox` component:
80
88
 
81
89
  ```html
82
90
  <!-- Native HTML -->
83
- <pie-checkbox></pie-checkbox>
91
+ <pie-checkbox
92
+ name="mycheckbox"
93
+ label="Checkbox Label">
94
+ </pie-checkbox>
84
95
 
85
96
  <!-- JSX -->
86
- <PieCheckbox></PieCheckbox>
97
+ <PieCheckbox
98
+ name="mycheckbox"
99
+ label="Checkbox Label">
100
+ </PieCheckbox>
87
101
  ```
88
102
 
103
+ ## Events
104
+ | Event | Type | Description |
105
+ |-------|------|-------------|
106
+ | `change` | `CustomEvent` | Triggered after the checked state of a checkbox changes. |
107
+
89
108
  ## Contributing
90
109
 
91
110
  Check out our [contributing guide](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide) for more information on [local development](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide#local-development) and how to run specific [component tests](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide#testing).
@@ -22,7 +22,192 @@
22
22
  "kind": "class",
23
23
  "description": "",
24
24
  "name": "PieCheckbox",
25
- "members": [],
25
+ "slots": [
26
+ {
27
+ "description": "Default slot (checkbox label)",
28
+ "name": ""
29
+ }
30
+ ],
31
+ "members": [
32
+ {
33
+ "kind": "field",
34
+ "name": "shadowRootOptions",
35
+ "type": {
36
+ "text": "object"
37
+ },
38
+ "static": true,
39
+ "default": "{ ...LitElement.shadowRootOptions, delegatesFocus: true }"
40
+ },
41
+ {
42
+ "kind": "field",
43
+ "name": "value",
44
+ "type": {
45
+ "text": "CheckboxProps['value']"
46
+ },
47
+ "privacy": "public",
48
+ "attribute": "value"
49
+ },
50
+ {
51
+ "kind": "field",
52
+ "name": "label",
53
+ "type": {
54
+ "text": "CheckboxProps['label'] | undefined"
55
+ },
56
+ "privacy": "public",
57
+ "attribute": "label"
58
+ },
59
+ {
60
+ "kind": "field",
61
+ "name": "name",
62
+ "type": {
63
+ "text": "CheckboxProps['name'] | undefined"
64
+ },
65
+ "privacy": "public",
66
+ "attribute": "name"
67
+ },
68
+ {
69
+ "kind": "field",
70
+ "name": "checked",
71
+ "type": {
72
+ "text": "CheckboxProps['checked'] | undefined"
73
+ },
74
+ "privacy": "public",
75
+ "attribute": "checked"
76
+ },
77
+ {
78
+ "kind": "field",
79
+ "name": "disabled",
80
+ "type": {
81
+ "text": "CheckboxProps['disabled'] | undefined"
82
+ },
83
+ "privacy": "public",
84
+ "attribute": "disabled",
85
+ "reflects": true
86
+ },
87
+ {
88
+ "kind": "field",
89
+ "name": "required",
90
+ "type": {
91
+ "text": "CheckboxProps['required'] | undefined"
92
+ },
93
+ "privacy": "public",
94
+ "default": "false",
95
+ "attribute": "required",
96
+ "reflects": true
97
+ },
98
+ {
99
+ "kind": "field",
100
+ "name": "indeterminate",
101
+ "type": {
102
+ "text": "CheckboxProps['indeterminate'] | undefined"
103
+ },
104
+ "privacy": "public",
105
+ "default": "false",
106
+ "attribute": "indeterminate"
107
+ },
108
+ {
109
+ "kind": "field",
110
+ "name": "aria",
111
+ "type": {
112
+ "text": "CheckboxProps['aria']"
113
+ },
114
+ "privacy": "public",
115
+ "attribute": "aria"
116
+ },
117
+ {
118
+ "kind": "field",
119
+ "name": "checkbox",
120
+ "type": {
121
+ "text": "HTMLInputElement | undefined"
122
+ },
123
+ "privacy": "private"
124
+ },
125
+ {
126
+ "kind": "field",
127
+ "name": "validity",
128
+ "type": {
129
+ "text": "ValidityState"
130
+ },
131
+ "privacy": "public",
132
+ "description": "(Read-only) returns a ValidityState with the validity states that this element is in.\nhttps://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity",
133
+ "readonly": true
134
+ },
135
+ {
136
+ "kind": "field",
137
+ "name": "handleChange",
138
+ "privacy": "private",
139
+ "description": "The onChange function updates the checkbox state and emits an event for consumers.",
140
+ "parameters": [
141
+ {
142
+ "description": "This should be the change event that was listened for on an input element with `type=\"checkbox\"`.",
143
+ "name": "event",
144
+ "type": {
145
+ "text": "Event"
146
+ }
147
+ }
148
+ ]
149
+ }
150
+ ],
151
+ "attributes": [
152
+ {
153
+ "name": "value",
154
+ "type": {
155
+ "text": "CheckboxProps['value']"
156
+ },
157
+ "fieldName": "value"
158
+ },
159
+ {
160
+ "name": "label",
161
+ "type": {
162
+ "text": "CheckboxProps['label'] | undefined"
163
+ },
164
+ "fieldName": "label"
165
+ },
166
+ {
167
+ "name": "name",
168
+ "type": {
169
+ "text": "CheckboxProps['name'] | undefined"
170
+ },
171
+ "fieldName": "name"
172
+ },
173
+ {
174
+ "name": "checked",
175
+ "type": {
176
+ "text": "CheckboxProps['checked'] | undefined"
177
+ },
178
+ "fieldName": "checked"
179
+ },
180
+ {
181
+ "name": "disabled",
182
+ "type": {
183
+ "text": "CheckboxProps['disabled'] | undefined"
184
+ },
185
+ "fieldName": "disabled"
186
+ },
187
+ {
188
+ "name": "required",
189
+ "type": {
190
+ "text": "CheckboxProps['required'] | undefined"
191
+ },
192
+ "default": "false",
193
+ "fieldName": "required"
194
+ },
195
+ {
196
+ "name": "indeterminate",
197
+ "type": {
198
+ "text": "CheckboxProps['indeterminate'] | undefined"
199
+ },
200
+ "default": "false",
201
+ "fieldName": "indeterminate"
202
+ },
203
+ {
204
+ "name": "aria",
205
+ "type": {
206
+ "text": "CheckboxProps['aria']"
207
+ },
208
+ "fieldName": "aria"
209
+ }
210
+ ],
26
211
  "mixins": [
27
212
  {
28
213
  "name": "RtlMixin",
package/dist/index.d.ts CHANGED
@@ -4,13 +4,77 @@ import type { LitElement } from 'lit';
4
4
  import type { RTLInterface } from '@justeattakeaway/pie-webc-core';
5
5
  import type { TemplateResult } from 'lit-html';
6
6
 
7
+ export declare type AriaProps = {
8
+ label?: string;
9
+ labelledby?: string;
10
+ describedby?: string;
11
+ };
12
+
7
13
  export declare interface CheckboxProps {
14
+ /**
15
+ * The value of the checkbox (used as a key/value pair in HTML forms with `name`).
16
+ */
17
+ value?: string;
18
+ /**
19
+ * The label value of the component
20
+ */
21
+ label?: string;
22
+ /**
23
+ * The name of the checkbox (used as a key/value pair with `value`). This is required in order to work properly with forms.
24
+ */
25
+ name?: string;
26
+ /**
27
+ * Same as the HTML disabled attribute - indicates whether or not the checkbox is disabled.
28
+ */
29
+ disabled?: boolean;
30
+ /**
31
+ * Same as the HTML checked attribute - indicates whether or not the checkbox is checked by default (when the page loads).
32
+ */
33
+ checked?: boolean;
34
+ /**
35
+ * Indicates whether the checkbox visually shows a horizontal line in the box instead of a check/tick.
36
+ * 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.
37
+ */
38
+ indeterminate?: boolean;
39
+ /**
40
+ * If true, the checkbox must be checked for the form to be submittable.
41
+ */
42
+ required?: boolean;
43
+ /**
44
+ * Various ARIA attributes.
45
+ */
46
+ aria?: AriaProps;
8
47
  }
9
48
 
10
49
  /**
11
50
  * @tagname pie-checkbox
51
+ * @slot - Default slot (checkbox label)
12
52
  */
13
53
  export declare class PieCheckbox extends PieCheckbox_base implements CheckboxProps {
54
+ static shadowRootOptions: {
55
+ delegatesFocus: boolean;
56
+ mode: ShadowRootMode;
57
+ slotAssignment?: SlotAssignmentMode | undefined;
58
+ };
59
+ value: CheckboxProps['value'];
60
+ label?: CheckboxProps['label'];
61
+ name?: CheckboxProps['name'];
62
+ checked?: CheckboxProps['checked'];
63
+ disabled?: CheckboxProps['disabled'];
64
+ required?: CheckboxProps['required'];
65
+ indeterminate?: CheckboxProps['indeterminate'];
66
+ aria: CheckboxProps['aria'];
67
+ private checkbox?;
68
+ /**
69
+ * (Read-only) returns a ValidityState with the validity states that this element is in.
70
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity
71
+ */
72
+ get validity(): ValidityState;
73
+ /**
74
+ * The onChange function updates the checkbox state and emits an event for consumers.
75
+ * @param {Event} event - This should be the change event that was listened for on an input element with `type="checkbox"`.
76
+ */
77
+ private handleChange;
14
78
  render(): TemplateResult<1>;
15
79
  static styles: CSSResult;
16
80
  }
package/dist/index.js CHANGED
@@ -1,14 +1,90 @@
1
- import { LitElement as t, html as o, unsafeCSS as n } from "lit";
2
- import { RtlMixin as i, defineCustomElement as r } from "@justeattakeaway/pie-webc-core";
3
- const s = `*,*:after,*:before{box-sizing:inherit}
4
- `, l = "pie-checkbox";
5
- class e extends i(t) {
1
+ import { LitElement as b, html as u, nothing as c, unsafeCSS as m } from "lit";
2
+ import { RtlMixin as f, wrapNativeEvent as v, defineCustomElement as g } from "@justeattakeaway/pie-webc-core";
3
+ import { property as i, query as $ } from "lit/decorators.js";
4
+ import { ifDefined as h } from "lit/directives/if-defined.js";
5
+ const x = `*,*:after,*:before{box-sizing:inherit}
6
+ `;
7
+ var C = Object.defineProperty, O = Object.getOwnPropertyDescriptor, r = (d, n, p, l) => {
8
+ for (var t = l > 1 ? void 0 : l ? O(n, p) : n, a = d.length - 1, s; a >= 0; a--)
9
+ (s = d[a]) && (t = (l ? s(n, p, t) : s(t)) || t);
10
+ return l && t && C(n, p, t), t;
11
+ };
12
+ const S = "pie-checkbox";
13
+ class e extends f(b) {
14
+ constructor() {
15
+ super(...arguments), this.required = !1, this.indeterminate = !1, this.handleChange = (n) => {
16
+ const p = v(n);
17
+ this.dispatchEvent(p);
18
+ };
19
+ }
20
+ /**
21
+ * (Read-only) returns a ValidityState with the validity states that this element is in.
22
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity
23
+ */
24
+ get validity() {
25
+ return this.checkbox.validity;
26
+ }
6
27
  render() {
7
- return o`<h1 data-test-id="pie-checkbox">Hello world!</h1>`;
28
+ const {
29
+ checked: n,
30
+ value: p,
31
+ name: l,
32
+ label: t,
33
+ disabled: a,
34
+ required: s,
35
+ indeterminate: y,
36
+ aria: o
37
+ } = this;
38
+ return u`
39
+ <label>
40
+ <input
41
+ type="checkbox"
42
+ ?checked=${h(n)}
43
+ .value=${h(p)}
44
+ name=${h(l)}
45
+ ?disabled=${a}
46
+ ?required=${s}
47
+ .indeterminate=${y}
48
+ aria-label=${(o == null ? void 0 : o.label) || c}
49
+ aria-labelledby=${t ? c : (o == null ? void 0 : o.labelledby) || c}
50
+ aria-describedby= ${(o == null ? void 0 : o.describedby) || c}
51
+ @change=${this.handleChange}
52
+ data-test-id="pie-checkbox"
53
+ />
54
+ ${t}
55
+ </label>`;
8
56
  }
9
57
  }
10
- e.styles = n(s);
11
- r(l, e);
58
+ e.shadowRootOptions = { ...b.shadowRootOptions, delegatesFocus: !0 };
59
+ e.styles = m(x);
60
+ r([
61
+ i({ type: String })
62
+ ], e.prototype, "value", 2);
63
+ r([
64
+ i({ type: String })
65
+ ], e.prototype, "label", 2);
66
+ r([
67
+ i({ type: String })
68
+ ], e.prototype, "name", 2);
69
+ r([
70
+ i({ type: Boolean })
71
+ ], e.prototype, "checked", 2);
72
+ r([
73
+ i({ type: Boolean, reflect: !0 })
74
+ ], e.prototype, "disabled", 2);
75
+ r([
76
+ i({ type: Boolean, reflect: !0 })
77
+ ], e.prototype, "required", 2);
78
+ r([
79
+ i({ type: Boolean })
80
+ ], e.prototype, "indeterminate", 2);
81
+ r([
82
+ i({ type: Object })
83
+ ], e.prototype, "aria", 2);
84
+ r([
85
+ $("input")
86
+ ], e.prototype, "checkbox", 2);
87
+ g(S, e);
12
88
  export {
13
89
  e as PieCheckbox
14
90
  };
package/dist/react.d.ts CHANGED
@@ -5,15 +5,79 @@ import * as React_2 from 'react';
5
5
  import type { RTLInterface } from '@justeattakeaway/pie-webc-core';
6
6
  import type { TemplateResult } from 'lit-html';
7
7
 
8
+ export declare type AriaProps = {
9
+ label?: string;
10
+ labelledby?: string;
11
+ describedby?: string;
12
+ };
13
+
8
14
  export declare interface CheckboxProps {
15
+ /**
16
+ * The value of the checkbox (used as a key/value pair in HTML forms with `name`).
17
+ */
18
+ value?: string;
19
+ /**
20
+ * The label value of the component
21
+ */
22
+ label?: string;
23
+ /**
24
+ * The name of the checkbox (used as a key/value pair with `value`). This is required in order to work properly with forms.
25
+ */
26
+ name?: string;
27
+ /**
28
+ * Same as the HTML disabled attribute - indicates whether or not the checkbox is disabled.
29
+ */
30
+ disabled?: boolean;
31
+ /**
32
+ * Same as the HTML checked attribute - indicates whether or not the checkbox is checked by default (when the page loads).
33
+ */
34
+ checked?: boolean;
35
+ /**
36
+ * Indicates whether the checkbox visually shows a horizontal line in the box instead of a check/tick.
37
+ * 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.
38
+ */
39
+ indeterminate?: boolean;
40
+ /**
41
+ * If true, the checkbox must be checked for the form to be submittable.
42
+ */
43
+ required?: boolean;
44
+ /**
45
+ * Various ARIA attributes.
46
+ */
47
+ aria?: AriaProps;
9
48
  }
10
49
 
11
50
  export declare const PieCheckbox: React_2.ForwardRefExoticComponent<CheckboxProps & React_2.RefAttributes<PieCheckbox_2> & ReactBaseType>;
12
51
 
13
52
  /**
14
53
  * @tagname pie-checkbox
54
+ * @slot - Default slot (checkbox label)
15
55
  */
16
56
  declare class PieCheckbox_2 extends PieCheckbox_base implements CheckboxProps {
57
+ static shadowRootOptions: {
58
+ delegatesFocus: boolean;
59
+ mode: ShadowRootMode;
60
+ slotAssignment?: SlotAssignmentMode | undefined;
61
+ };
62
+ value: CheckboxProps['value'];
63
+ label?: CheckboxProps['label'];
64
+ name?: CheckboxProps['name'];
65
+ checked?: CheckboxProps['checked'];
66
+ disabled?: CheckboxProps['disabled'];
67
+ required?: CheckboxProps['required'];
68
+ indeterminate?: CheckboxProps['indeterminate'];
69
+ aria: CheckboxProps['aria'];
70
+ private checkbox?;
71
+ /**
72
+ * (Read-only) returns a ValidityState with the validity states that this element is in.
73
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity
74
+ */
75
+ get validity(): ValidityState;
76
+ /**
77
+ * The onChange function updates the checkbox state and emits an event for consumers.
78
+ * @param {Event} event - This should be the change event that was listened for on an input element with `type="checkbox"`.
79
+ */
80
+ private handleChange;
17
81
  render(): TemplateResult<1>;
18
82
  static styles: CSSResult;
19
83
  }
package/dist/react.js CHANGED
@@ -3,13 +3,15 @@ import { createComponent as o } from "@lit/react";
3
3
  import { PieCheckbox as t } from "./index.js";
4
4
  import "lit";
5
5
  import "@justeattakeaway/pie-webc-core";
6
- const c = o({
6
+ import "lit/decorators.js";
7
+ import "lit/directives/if-defined.js";
8
+ const i = o({
7
9
  displayName: "PieCheckbox",
8
10
  elementClass: t,
9
11
  react: e,
10
12
  tagName: "pie-checkbox",
11
13
  events: {}
12
- }), p = c;
14
+ }), x = i;
13
15
  export {
14
- p as PieCheckbox
16
+ x as PieCheckbox
15
17
  };
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.1.0",
4
+ "version": "0.3.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
package/src/defs.ts CHANGED
@@ -1,3 +1,47 @@
1
- // TODO - please remove the eslint disable comment below when you add props to this interface
2
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
3
- export interface CheckboxProps {}
1
+ export type AriaProps = {
2
+ label?: string;
3
+ labelledby?: string;
4
+ describedby?: string;
5
+ };
6
+ export interface CheckboxProps {
7
+ /**
8
+ * The value of the checkbox (used as a key/value pair in HTML forms with `name`).
9
+ */
10
+ value?: string;
11
+
12
+ /**
13
+ * The label value of the component
14
+ */
15
+ label?: string;
16
+
17
+ /**
18
+ * The name of the checkbox (used as a key/value pair with `value`). This is required in order to work properly with forms.
19
+ */
20
+ name?: string;
21
+
22
+ /**
23
+ * Same as the HTML disabled attribute - indicates whether or not the checkbox is disabled.
24
+ */
25
+ disabled?: boolean;
26
+
27
+ /**
28
+ * Same as the HTML checked attribute - indicates whether or not the checkbox is checked by default (when the page loads).
29
+ */
30
+ checked?: boolean;
31
+
32
+ /**
33
+ * Indicates whether the checkbox visually shows a horizontal line in the box instead of a check/tick.
34
+ * 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.
35
+ */
36
+ indeterminate?: boolean;
37
+
38
+ /**
39
+ * If true, the checkbox must be checked for the form to be submittable.
40
+ */
41
+ required?: boolean;
42
+
43
+ /**
44
+ * Various ARIA attributes.
45
+ */
46
+ aria?: AriaProps;
47
+ }
package/src/index.ts CHANGED
@@ -1,5 +1,13 @@
1
- import { LitElement, html, unsafeCSS } from 'lit';
2
- import { RtlMixin, defineCustomElement } from '@justeattakeaway/pie-webc-core';
1
+ import {
2
+ LitElement, html, unsafeCSS, nothing,
3
+ } from 'lit';
4
+ import {
5
+ RtlMixin,
6
+ defineCustomElement,
7
+ wrapNativeEvent,
8
+ } from '@justeattakeaway/pie-webc-core';
9
+ import { property, query } from 'lit/decorators.js';
10
+ import { ifDefined } from 'lit/directives/if-defined.js';
3
11
 
4
12
  import styles from './checkbox.scss?inline';
5
13
  import { CheckboxProps } from './defs';
@@ -11,10 +19,88 @@ const componentSelector = 'pie-checkbox';
11
19
 
12
20
  /**
13
21
  * @tagname pie-checkbox
22
+ * @slot - Default slot (checkbox label)
14
23
  */
15
24
  export class PieCheckbox extends RtlMixin(LitElement) implements CheckboxProps {
25
+ static shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };
26
+
27
+ @property({ type: String })
28
+ public value: CheckboxProps['value'];
29
+
30
+ @property({ type: String })
31
+ public label?: CheckboxProps['label'];
32
+
33
+ @property({ type: String })
34
+ public name?: CheckboxProps['name'];
35
+
36
+ @property({ type: Boolean })
37
+ public checked?: CheckboxProps['checked'];
38
+
39
+ @property({ type: Boolean, reflect: true })
40
+ public disabled?: CheckboxProps['disabled'];
41
+
42
+ @property({ type: Boolean, reflect: true })
43
+ public required?: CheckboxProps['required'] = false;
44
+
45
+ @property({ type: Boolean })
46
+ public indeterminate?: CheckboxProps['indeterminate'] = false;
47
+
48
+ @property({ type: Object })
49
+ public aria: CheckboxProps['aria'];
50
+
51
+ @query('input')
52
+ private checkbox?: HTMLInputElement;
53
+
54
+ /**
55
+ * (Read-only) returns a ValidityState with the validity states that this element is in.
56
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity
57
+ */
58
+ public get validity (): ValidityState {
59
+ return (this.checkbox as HTMLInputElement).validity;
60
+ }
61
+
62
+ /**
63
+ * The onChange function updates the checkbox state and emits an event for consumers.
64
+ * @param {Event} event - This should be the change event that was listened for on an input element with `type="checkbox"`.
65
+ */
66
+ private handleChange = (event: Event) => {
67
+ // This is because some events set `composed` to `false`.
68
+ // Reference: https://javascript.info/shadow-dom-events#event-composed
69
+ const customChangeEvent = wrapNativeEvent(event);
70
+
71
+ this.dispatchEvent(customChangeEvent);
72
+ };
73
+
16
74
  render () {
17
- return html`<h1 data-test-id="pie-checkbox">Hello world!</h1>`;
75
+ const {
76
+ checked,
77
+ value,
78
+ name,
79
+ label,
80
+ disabled,
81
+ required,
82
+ indeterminate,
83
+ aria,
84
+ } = this;
85
+
86
+ return html`
87
+ <label>
88
+ <input
89
+ type="checkbox"
90
+ ?checked=${ifDefined(checked)}
91
+ .value=${ifDefined(value)}
92
+ name=${ifDefined(name)}
93
+ ?disabled=${disabled}
94
+ ?required=${required}
95
+ .indeterminate=${indeterminate}
96
+ aria-label=${aria?.label || nothing}
97
+ aria-labelledby=${label ? nothing : aria?.labelledby || nothing}
98
+ aria-describedby= ${aria?.describedby || nothing}
99
+ @change=${this.handleChange}
100
+ data-test-id="pie-checkbox"
101
+ />
102
+ ${label}
103
+ </label>`;
18
104
  }
19
105
 
20
106
  // Renders a `CSSResult` generated from SCSS by Vite