@justeattakeaway/pie-checkbox 0.3.0 → 0.3.1

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.
@@ -11,8 +11,26 @@
11
11
  {
12
12
  "kind": "javascript-module",
13
13
  "path": "src/defs.js",
14
- "declarations": [],
15
- "exports": []
14
+ "declarations": [
15
+ {
16
+ "kind": "variable",
17
+ "name": "defaultProps",
18
+ "type": {
19
+ "text": "DefaultProps"
20
+ },
21
+ "default": "{\n required: false,\n indeterminate: false,\n}"
22
+ }
23
+ ],
24
+ "exports": [
25
+ {
26
+ "kind": "js",
27
+ "name": "defaultProps",
28
+ "declaration": {
29
+ "name": "defaultProps",
30
+ "module": "src/defs.js"
31
+ }
32
+ }
33
+ ]
16
34
  },
17
35
  {
18
36
  "kind": "javascript-module",
@@ -91,7 +109,6 @@
91
109
  "text": "CheckboxProps['required'] | undefined"
92
110
  },
93
111
  "privacy": "public",
94
- "default": "false",
95
112
  "attribute": "required",
96
113
  "reflects": true
97
114
  },
@@ -102,7 +119,6 @@
102
119
  "text": "CheckboxProps['indeterminate'] | undefined"
103
120
  },
104
121
  "privacy": "public",
105
- "default": "false",
106
122
  "attribute": "indeterminate"
107
123
  },
108
124
  {
@@ -189,7 +205,6 @@
189
205
  "type": {
190
206
  "text": "CheckboxProps['required'] | undefined"
191
207
  },
192
- "default": "false",
193
208
  "fieldName": "required"
194
209
  },
195
210
  {
@@ -197,7 +212,6 @@
197
212
  "type": {
198
213
  "text": "CheckboxProps['indeterminate'] | undefined"
199
214
  },
200
- "default": "false",
201
215
  "fieldName": "indeterminate"
202
216
  },
203
217
  {
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
1
2
  import type { CSSResult } from 'lit';
2
3
  import type { GenericConstructor } from '@justeattakeaway/pie-webc-core';
3
4
  import type { LitElement } from 'lit';
@@ -46,6 +47,10 @@ export declare interface CheckboxProps {
46
47
  aria?: AriaProps;
47
48
  }
48
49
 
50
+ export declare type DefaultProps = ComponentDefaultPropsGeneric<CheckboxProps, 'required' | 'indeterminate'>;
51
+
52
+ export declare const defaultProps: DefaultProps;
53
+
49
54
  /**
50
55
  * @tagname pie-checkbox
51
56
  * @slot - Default slot (checkbox label)
package/dist/index.js CHANGED
@@ -1,19 +1,22 @@
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";
1
+ import { LitElement as y, html as m, nothing as d, unsafeCSS as f } from "lit";
2
+ import { RtlMixin as v, wrapNativeEvent as g, defineCustomElement as $ } from "@justeattakeaway/pie-webc-core";
3
+ import { property as n, query as x } from "lit/decorators.js";
4
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;
5
+ const q = `*,*:after,*:before{box-sizing:inherit}
6
+ `, b = {
7
+ required: !1,
8
+ indeterminate: !1
11
9
  };
12
- const S = "pie-checkbox";
13
- class e extends f(b) {
10
+ var C = Object.defineProperty, O = Object.getOwnPropertyDescriptor, o = (c, i, p, a) => {
11
+ for (var t = a > 1 ? void 0 : a ? O(i, p) : i, l = c.length - 1, s; l >= 0; l--)
12
+ (s = c[l]) && (t = (a ? s(i, p, t) : s(t)) || t);
13
+ return a && t && C(i, p, t), t;
14
+ };
15
+ const P = "pie-checkbox";
16
+ class e extends v(y) {
14
17
  constructor() {
15
- super(...arguments), this.required = !1, this.indeterminate = !1, this.handleChange = (n) => {
16
- const p = v(n);
18
+ super(...arguments), this.required = b.required, this.indeterminate = b.indeterminate, this.handleChange = (i) => {
19
+ const p = g(i);
17
20
  this.dispatchEvent(p);
18
21
  };
19
22
  }
@@ -26,28 +29,28 @@ class e extends f(b) {
26
29
  }
27
30
  render() {
28
31
  const {
29
- checked: n,
32
+ checked: i,
30
33
  value: p,
31
- name: l,
34
+ name: a,
32
35
  label: t,
33
- disabled: a,
36
+ disabled: l,
34
37
  required: s,
35
- indeterminate: y,
36
- aria: o
38
+ indeterminate: u,
39
+ aria: r
37
40
  } = this;
38
- return u`
41
+ return m`
39
42
  <label>
40
43
  <input
41
44
  type="checkbox"
42
- ?checked=${h(n)}
45
+ ?checked=${h(i)}
43
46
  .value=${h(p)}
44
- name=${h(l)}
45
- ?disabled=${a}
47
+ name=${h(a)}
48
+ ?disabled=${l}
46
49
  ?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}
50
+ .indeterminate=${u}
51
+ aria-label=${(r == null ? void 0 : r.label) || d}
52
+ aria-labelledby=${t ? d : (r == null ? void 0 : r.labelledby) || d}
53
+ aria-describedby= ${(r == null ? void 0 : r.describedby) || d}
51
54
  @change=${this.handleChange}
52
55
  data-test-id="pie-checkbox"
53
56
  />
@@ -55,36 +58,37 @@ class e extends f(b) {
55
58
  </label>`;
56
59
  }
57
60
  }
58
- e.shadowRootOptions = { ...b.shadowRootOptions, delegatesFocus: !0 };
59
- e.styles = m(x);
60
- r([
61
- i({ type: String })
61
+ e.shadowRootOptions = { ...y.shadowRootOptions, delegatesFocus: !0 };
62
+ e.styles = f(q);
63
+ o([
64
+ n({ type: String })
62
65
  ], e.prototype, "value", 2);
63
- r([
64
- i({ type: String })
66
+ o([
67
+ n({ type: String })
65
68
  ], e.prototype, "label", 2);
66
- r([
67
- i({ type: String })
69
+ o([
70
+ n({ type: String })
68
71
  ], e.prototype, "name", 2);
69
- r([
70
- i({ type: Boolean })
72
+ o([
73
+ n({ type: Boolean })
71
74
  ], e.prototype, "checked", 2);
72
- r([
73
- i({ type: Boolean, reflect: !0 })
75
+ o([
76
+ n({ type: Boolean, reflect: !0 })
74
77
  ], e.prototype, "disabled", 2);
75
- r([
76
- i({ type: Boolean, reflect: !0 })
78
+ o([
79
+ n({ type: Boolean, reflect: !0 })
77
80
  ], e.prototype, "required", 2);
78
- r([
79
- i({ type: Boolean })
81
+ o([
82
+ n({ type: Boolean })
80
83
  ], e.prototype, "indeterminate", 2);
81
- r([
82
- i({ type: Object })
84
+ o([
85
+ n({ type: Object })
83
86
  ], e.prototype, "aria", 2);
84
- r([
85
- $("input")
87
+ o([
88
+ x("input")
86
89
  ], e.prototype, "checkbox", 2);
87
- g(S, e);
90
+ $(P, e);
88
91
  export {
89
- e as PieCheckbox
92
+ e as PieCheckbox,
93
+ b as defaultProps
90
94
  };
package/dist/react.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
1
2
  import type { CSSResult } from 'lit';
2
3
  import type { GenericConstructor } from '@justeattakeaway/pie-webc-core';
3
4
  import type { LitElement } from 'lit';
@@ -47,6 +48,10 @@ export declare interface CheckboxProps {
47
48
  aria?: AriaProps;
48
49
  }
49
50
 
51
+ export declare type DefaultProps = ComponentDefaultPropsGeneric<CheckboxProps, 'required' | 'indeterminate'>;
52
+
53
+ export declare const defaultProps: DefaultProps;
54
+
50
55
  export declare const PieCheckbox: React_2.ForwardRefExoticComponent<CheckboxProps & React_2.RefAttributes<PieCheckbox_2> & ReactBaseType>;
51
56
 
52
57
  /**
package/dist/react.js CHANGED
@@ -1,17 +1,19 @@
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 h } from "./index.js";
4
5
  import "lit";
5
6
  import "@justeattakeaway/pie-webc-core";
6
7
  import "lit/decorators.js";
7
8
  import "lit/directives/if-defined.js";
8
- const i = o({
9
+ const r = o({
9
10
  displayName: "PieCheckbox",
10
11
  elementClass: t,
11
12
  react: e,
12
13
  tagName: "pie-checkbox",
13
14
  events: {}
14
- }), x = i;
15
+ }), x = r;
15
16
  export {
16
- x as PieCheckbox
17
+ x as PieCheckbox,
18
+ h as defaultProps
17
19
  };
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.3.0",
4
+ "version": "0.3.1",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -40,7 +40,7 @@
40
40
  "cem-plugin-module-file-extensions": "0.0.5"
41
41
  },
42
42
  "dependencies": {
43
- "@justeattakeaway/pie-webc-core": "0.22.0"
43
+ "@justeattakeaway/pie-webc-core": "0.23.0"
44
44
  },
45
45
  "volta": {
46
46
  "extends": "../../../package.json"
package/src/defs.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
2
+
1
3
  export type AriaProps = {
2
4
  label?: string;
3
5
  labelledby?: string;
@@ -45,3 +47,11 @@ export interface CheckboxProps {
45
47
  */
46
48
  aria?: AriaProps;
47
49
  }
50
+
51
+ export type DefaultProps = ComponentDefaultPropsGeneric<CheckboxProps, 'required' | 'indeterminate'>;
52
+
53
+ export const defaultProps: DefaultProps = {
54
+ required: false,
55
+ indeterminate: false,
56
+ };
57
+
package/src/index.ts CHANGED
@@ -10,7 +10,7 @@ import { property, query } from 'lit/decorators.js';
10
10
  import { ifDefined } from 'lit/directives/if-defined.js';
11
11
 
12
12
  import styles from './checkbox.scss?inline';
13
- import { CheckboxProps } from './defs';
13
+ import { CheckboxProps, defaultProps } from './defs';
14
14
 
15
15
  // Valid values available to consumers
16
16
  export * from './defs';
@@ -40,10 +40,10 @@ export class PieCheckbox extends RtlMixin(LitElement) implements CheckboxProps {
40
40
  public disabled?: CheckboxProps['disabled'];
41
41
 
42
42
  @property({ type: Boolean, reflect: true })
43
- public required?: CheckboxProps['required'] = false;
43
+ public required?: CheckboxProps['required'] = defaultProps.required;
44
44
 
45
45
  @property({ type: Boolean })
46
- public indeterminate?: CheckboxProps['indeterminate'] = false;
46
+ public indeterminate?: CheckboxProps['indeterminate'] = defaultProps.indeterminate;
47
47
 
48
48
  @property({ type: Object })
49
49
  public aria: CheckboxProps['aria'];