@justeattakeaway/pie-checkbox-group 0.7.3 → 0.7.5

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.
@@ -102,17 +102,18 @@
102
102
  "members": [
103
103
  {
104
104
  "kind": "field",
105
- "name": "hasLabel",
105
+ "name": "_hasLabel",
106
106
  "type": {
107
107
  "text": "boolean"
108
108
  },
109
+ "privacy": "private",
109
110
  "default": "false"
110
111
  },
111
112
  {
112
113
  "kind": "field",
113
114
  "name": "name",
114
115
  "type": {
115
- "text": "CheckboxGroupProps['name'] | undefined"
116
+ "text": "CheckboxGroupProps['name']"
116
117
  },
117
118
  "privacy": "public",
118
119
  "attribute": "name"
@@ -148,13 +149,6 @@
148
149
  {
149
150
  "kind": "field",
150
151
  "name": "_slottedChildren",
151
- "type": {
152
- "text": "Array<HTMLElement> | undefined"
153
- }
154
- },
155
- {
156
- "kind": "field",
157
- "name": "_labelSlot",
158
152
  "type": {
159
153
  "text": "Array<HTMLElement>"
160
154
  }
@@ -191,7 +185,7 @@
191
185
  }
192
186
  }
193
187
  ],
194
- "description": "Function that updates the local `hasLabel` state in case\nwhen the label slot receives content."
188
+ "description": "Function that updates the local `_hasLabel` state in case\nwhen the label slot receives content."
195
189
  },
196
190
  {
197
191
  "kind": "method",
@@ -199,7 +193,7 @@
199
193
  "privacy": "private",
200
194
  "return": {
201
195
  "type": {
202
- "text": "TemplateResult | typeof nothing"
196
+ "text": "TemplateResult"
203
197
  }
204
198
  },
205
199
  "description": "Template for the label slot to correctly wrap it into a legend element when it has content.\nCalled within the main render function."
@@ -225,7 +219,7 @@
225
219
  {
226
220
  "name": "name",
227
221
  "type": {
228
- "text": "CheckboxGroupProps['name'] | undefined"
222
+ "text": "CheckboxGroupProps['name']"
229
223
  },
230
224
  "fieldName": "name"
231
225
  },
package/dist/index.d.ts CHANGED
@@ -51,18 +51,17 @@ export declare const ON_CHECKBOX_GROUP_ERROR = "pie-checkbox-group-error";
51
51
  * @event {CustomEvent} pie-checkbox-group-error - triggered after the state of the checkbox group changes to error.
52
52
  */
53
53
  export declare class PieCheckboxGroup extends PieCheckboxGroup_base implements CheckboxGroupProps {
54
- hasLabel: boolean;
55
- name?: CheckboxGroupProps['name'];
54
+ private _hasLabel;
55
+ name: CheckboxGroupProps['name'];
56
56
  assistiveText?: CheckboxGroupProps['assistiveText'];
57
57
  isInline: boolean;
58
58
  status: "default" | "error" | "success";
59
59
  disabled: boolean;
60
- _slottedChildren: Array<HTMLElement> | undefined;
61
- _labelSlot: Array<HTMLElement>;
60
+ _slottedChildren: Array<HTMLElement>;
62
61
  private _handleDisabled;
63
62
  private _handleStatus;
64
63
  /**
65
- * Function that updates the local `hasLabel` state in case
64
+ * Function that updates the local `_hasLabel` state in case
66
65
  * when the label slot receives content.
67
66
  * @private
68
67
  */
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { LitElement as g, html as n, unsafeCSS as k } from "lit";
2
- import { state as v, property as c, queryAssignedElements as f } from "lit/decorators.js";
3
- import { FormControlMixin as m, RtlMixin as y, validPropertyValues as G, defineCustomElement as _ } from "@justeattakeaway/pie-webc-core";
1
+ import { LitElement as x, html as n, unsafeCSS as g } from "lit";
2
+ import { state as k, property as c, queryAssignedElements as v } from "lit/decorators.js";
3
+ import { FormControlMixin as m, RtlMixin as y, validPropertyValues as _, defineCustomElement as G } from "@justeattakeaway/pie-webc-core";
4
4
  import { ifDefined as b } from "lit/directives/if-defined.js";
5
5
  import { classMap as C } from "lit/directives/class-map.js";
6
6
  import "@justeattakeaway/pie-assistive-text";
@@ -9,37 +9,35 @@ const E = "*,*:after,*:before{box-sizing:inherit}.c-checkboxGroup{--checkbox-gro
9
9
  disabled: !1,
10
10
  isInline: !1
11
11
  };
12
- var L = Object.defineProperty, i = (h, e, t, l) => {
13
- for (var o = void 0, a = h.length - 1, r; a >= 0; a--)
14
- (r = h[a]) && (o = r(e, t, o) || o);
15
- return o && L(e, t, o), o;
12
+ var L = Object.defineProperty, o = (h, e, i, r) => {
13
+ for (var s = void 0, a = h.length - 1, l; a >= 0; a--)
14
+ (l = h[a]) && (s = l(e, i, s) || s);
15
+ return s && L(e, i, s), s;
16
16
  };
17
- const x = "pie-checkbox-group", u = "assistive-text", d = class d extends m(y(g)) {
17
+ const f = "pie-checkbox-group", u = "assistive-text", d = class d extends m(y(x)) {
18
18
  constructor() {
19
- super(...arguments), this.hasLabel = !1, this.isInline = p.isInline, this.status = p.status, this.disabled = p.disabled;
19
+ super(...arguments), this._hasLabel = !1, this.isInline = p.isInline, this.status = p.status, this.disabled = p.disabled;
20
20
  }
21
21
  _handleDisabled() {
22
- var e;
23
- (e = this._slottedChildren) == null || e.forEach((t) => t.dispatchEvent(new CustomEvent($, {
22
+ this._slottedChildren.forEach((e) => e.dispatchEvent(new CustomEvent($, {
24
23
  bubbles: !1,
25
24
  composed: !1,
26
25
  detail: { disabled: this.disabled }
27
26
  })));
28
27
  }
29
28
  _handleStatus() {
30
- var e;
31
- (e = this._slottedChildren) == null || e.forEach((t) => {
32
- t.setAttribute("status", this.status), this.status === "error" && this.assistiveText && (t.setAttribute("assistiveText", this.assistiveText), t.dispatchEvent(new CustomEvent(T, { bubbles: !1, composed: !1, detail: { error: !0 } })));
29
+ this._slottedChildren.forEach((e) => {
30
+ e.setAttribute("status", this.status), this.status === "error" && this.assistiveText && (e.setAttribute("assistiveText", this.assistiveText), e.dispatchEvent(new CustomEvent(T, { bubbles: !1, composed: !1, detail: { error: !0 } })));
33
31
  });
34
32
  }
35
33
  /**
36
- * Function that updates the local `hasLabel` state in case
34
+ * Function that updates the local `_hasLabel` state in case
37
35
  * when the label slot receives content.
38
36
  * @private
39
37
  */
40
38
  handleSlotChange(e) {
41
- const t = e.target.assignedNodes({ flatten: !0 });
42
- this.hasLabel = t.length > 0;
39
+ const i = e.target.assignedNodes({ flatten: !0 });
40
+ this._hasLabel = i.length > 0;
43
41
  }
44
42
  /**
45
43
  * Template for the label slot to correctly wrap it into a legend element when it has content.
@@ -47,7 +45,7 @@ const x = "pie-checkbox-group", u = "assistive-text", d = class d extends m(y(g)
47
45
  * @private
48
46
  */
49
47
  renderWrappedLabel() {
50
- return this.hasLabel ? n`<legend><slot name='label' @slotchange=${this.handleSlotChange}></slot></legend>` : n`<slot name='label' @slotchange=${this.handleSlotChange}></slot>`;
48
+ return this._hasLabel ? n`<legend><slot name='label' @slotchange=${this.handleSlotChange}></slot></legend>` : n`<slot name='label' @slotchange=${this.handleSlotChange}></slot>`;
51
49
  }
52
50
  updated(e) {
53
51
  e.has("disabled") && this._handleDisabled(), e.has("status") && this._handleStatus();
@@ -55,68 +53,65 @@ const x = "pie-checkbox-group", u = "assistive-text", d = class d extends m(y(g)
55
53
  render() {
56
54
  const {
57
55
  name: e,
58
- isInline: t,
59
- assistiveText: l,
60
- status: o,
56
+ isInline: i,
57
+ assistiveText: r,
58
+ status: s,
61
59
  disabled: a
62
- } = this, r = {
60
+ } = this, l = {
63
61
  "c-checkboxGroup": !0,
64
- "c-checkboxGroup--inline": t
62
+ "c-checkboxGroup--inline": i
65
63
  };
66
64
  return n`
67
65
  <fieldset
68
66
  name=${b(e)}
69
67
  ?disabled=${a}
70
- aria-describedby="${b(l ? u : void 0)}"
68
+ aria-describedby="${b(r ? u : void 0)}"
71
69
  data-test-id="pie-checkbox-group"
72
- class="${C(r)}"
70
+ class="${C(l)}"
73
71
  >
74
72
  ${this.renderWrappedLabel()}
75
73
  <slot></slot>
76
74
  </fieldset>
77
- ${l && n`
75
+ ${r && n`
78
76
  <pie-assistive-text
79
77
  id="${u}"
80
- variant=${o}
78
+ variant=${s}
81
79
  class="c-checkboxGroup-assistiveText"
82
80
  data-test-id="pie-checkbox-group-assistive-text">
83
- ${l}
81
+ ${r}
84
82
  </pie-assistive-text>`}
85
83
  `;
86
84
  }
87
85
  };
88
- d.styles = k(E);
89
- let s = d;
90
- i([
91
- v()
92
- ], s.prototype, "hasLabel");
93
- i([
86
+ d.styles = g(E);
87
+ let t = d;
88
+ o([
89
+ k()
90
+ ], t.prototype, "_hasLabel");
91
+ o([
94
92
  c({ type: String })
95
- ], s.prototype, "name");
96
- i([
93
+ ], t.prototype, "name");
94
+ o([
97
95
  c({ type: String })
98
- ], s.prototype, "assistiveText");
99
- i([
96
+ ], t.prototype, "assistiveText");
97
+ o([
100
98
  c({ type: Boolean })
101
- ], s.prototype, "isInline");
102
- i([
99
+ ], t.prototype, "isInline");
100
+ o([
103
101
  c({ type: String }),
104
- G(x, S, p.status)
105
- ], s.prototype, "status");
106
- i([
102
+ _(f, S, p.status)
103
+ ], t.prototype, "status");
104
+ o([
107
105
  c({ type: Boolean, reflect: !0 })
108
- ], s.prototype, "disabled");
109
- i([
110
- f({ selector: "pie-checkbox" })
111
- ], s.prototype, "_slottedChildren");
112
- i([
113
- f({ slot: "label" })
114
- ], s.prototype, "_labelSlot");
115
- _(x, s);
106
+ ], t.prototype, "disabled");
107
+ o([
108
+ v({ selector: "pie-checkbox" })
109
+ ], t.prototype, "_slottedChildren");
110
+ G(f, t);
116
111
  export {
117
112
  $ as ON_CHECKBOX_GROUP_DISABLED,
118
113
  T as ON_CHECKBOX_GROUP_ERROR,
119
- s as PieCheckboxGroup,
114
+ t as PieCheckboxGroup,
120
115
  p as defaultProps,
121
116
  S as statusTypes
122
117
  };
package/dist/react.d.ts CHANGED
@@ -54,18 +54,17 @@ export declare const PieCheckboxGroup: React_2.ForwardRefExoticComponent<Checkbo
54
54
  * @event {CustomEvent} pie-checkbox-group-error - triggered after the state of the checkbox group changes to error.
55
55
  */
56
56
  declare class PieCheckboxGroup_2 extends PieCheckboxGroup_base implements CheckboxGroupProps {
57
- hasLabel: boolean;
58
- name?: CheckboxGroupProps['name'];
57
+ private _hasLabel;
58
+ name: CheckboxGroupProps['name'];
59
59
  assistiveText?: CheckboxGroupProps['assistiveText'];
60
60
  isInline: boolean;
61
61
  status: "default" | "error" | "success";
62
62
  disabled: boolean;
63
- _slottedChildren: Array<HTMLElement> | undefined;
64
- _labelSlot: Array<HTMLElement>;
63
+ _slottedChildren: Array<HTMLElement>;
65
64
  private _handleDisabled;
66
65
  private _handleStatus;
67
66
  /**
68
- * Function that updates the local `hasLabel` state in case
67
+ * Function that updates the local `_hasLabel` state in case
69
68
  * when the label slot receives content.
70
69
  * @private
71
70
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-checkbox-group",
3
3
  "description": "PIE Design System Checkbox Group built using Web Components",
4
- "version": "0.7.3",
4
+ "version": "0.7.5",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -36,12 +36,13 @@
36
36
  "license": "Apache-2.0",
37
37
  "devDependencies": {
38
38
  "@custom-elements-manifest/analyzer": "0.9.0",
39
+ "@justeattakeaway/pie-checkbox": "0.13.5",
39
40
  "@justeattakeaway/pie-components-config": "0.18.0",
40
41
  "@justeattakeaway/pie-css": "0.13.1",
41
42
  "cem-plugin-module-file-extensions": "0.0.5"
42
43
  },
43
44
  "dependencies": {
44
- "@justeattakeaway/pie-assistive-text": "0.7.4",
45
+ "@justeattakeaway/pie-assistive-text": "0.7.5",
45
46
  "@justeattakeaway/pie-webc-core": "0.24.2"
46
47
  },
47
48
  "volta": {
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import {
2
- LitElement, html, unsafeCSS, type PropertyValues, type nothing, type TemplateResult,
2
+ LitElement, html, unsafeCSS, type PropertyValues, type TemplateResult,
3
3
  } from 'lit';
4
4
  import { property, queryAssignedElements, state } from 'lit/decorators.js';
5
5
  import {
@@ -35,10 +35,10 @@ const assistiveTextId = 'assistive-text';
35
35
  */
36
36
  export class PieCheckboxGroup extends FormControlMixin(RtlMixin(LitElement)) implements CheckboxGroupProps {
37
37
  @state()
38
- hasLabel = false;
38
+ private _hasLabel = false;
39
39
 
40
40
  @property({ type: String })
41
- public name?: CheckboxGroupProps['name'];
41
+ public name: CheckboxGroupProps['name'];
42
42
 
43
43
  @property({ type: String })
44
44
  public assistiveText?: CheckboxGroupProps['assistiveText'];
@@ -53,18 +53,16 @@ export class PieCheckboxGroup extends FormControlMixin(RtlMixin(LitElement)) imp
53
53
  @property({ type: Boolean, reflect: true })
54
54
  public disabled = defaultProps.disabled;
55
55
 
56
- @queryAssignedElements({ selector: 'pie-checkbox' }) _slottedChildren: Array<HTMLElement> | undefined;
57
-
58
- @queryAssignedElements({ slot: 'label' }) _labelSlot!: Array<HTMLElement>;
56
+ @queryAssignedElements({ selector: 'pie-checkbox' }) _slottedChildren!: Array<HTMLElement>;
59
57
 
60
58
  private _handleDisabled () : void {
61
- this._slottedChildren?.forEach((child) => child.dispatchEvent(new CustomEvent(ON_CHECKBOX_GROUP_DISABLED, {
59
+ this._slottedChildren.forEach((child) => child.dispatchEvent(new CustomEvent(ON_CHECKBOX_GROUP_DISABLED, {
62
60
  bubbles: false, composed: false, detail: { disabled: this.disabled },
63
61
  })));
64
62
  }
65
63
 
66
64
  private _handleStatus () : void {
67
- this._slottedChildren?.forEach((child) => {
65
+ this._slottedChildren.forEach((child) => {
68
66
  child.setAttribute('status', this.status);
69
67
 
70
68
  if (this.status === 'error' && this.assistiveText) {
@@ -75,13 +73,13 @@ export class PieCheckboxGroup extends FormControlMixin(RtlMixin(LitElement)) imp
75
73
  }
76
74
 
77
75
  /**
78
- * Function that updates the local `hasLabel` state in case
76
+ * Function that updates the local `_hasLabel` state in case
79
77
  * when the label slot receives content.
80
78
  * @private
81
79
  */
82
80
  private handleSlotChange (e: { target: HTMLSlotElement; }) {
83
81
  const childNodes = e.target.assignedNodes({ flatten: true });
84
- this.hasLabel = childNodes.length > 0;
82
+ this._hasLabel = childNodes.length > 0;
85
83
  }
86
84
 
87
85
  /**
@@ -89,8 +87,8 @@ export class PieCheckboxGroup extends FormControlMixin(RtlMixin(LitElement)) imp
89
87
  * Called within the main render function.
90
88
  * @private
91
89
  */
92
- private renderWrappedLabel (): TemplateResult | typeof nothing {
93
- return this.hasLabel ? html`<legend><slot name='label' @slotchange=${this.handleSlotChange}></slot></legend>` : html`<slot name='label' @slotchange=${this.handleSlotChange}></slot>`;
90
+ private renderWrappedLabel (): TemplateResult {
91
+ return this._hasLabel ? html`<legend><slot name='label' @slotchange=${this.handleSlotChange}></slot></legend>` : html`<slot name='label' @slotchange=${this.handleSlotChange}></slot>`;
94
92
  }
95
93
 
96
94
  protected updated (_changedProperties: PropertyValues<this>): void {