@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.
- package/custom-elements.json +6 -12
- package/dist/index.d.ts +4 -5
- package/dist/index.js +47 -52
- package/dist/react.d.ts +4 -5
- package/package.json +3 -2
- package/src/index.ts +10 -12
package/custom-elements.json
CHANGED
|
@@ -102,17 +102,18 @@
|
|
|
102
102
|
"members": [
|
|
103
103
|
{
|
|
104
104
|
"kind": "field",
|
|
105
|
-
"name": "
|
|
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']
|
|
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 `
|
|
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
|
|
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']
|
|
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
|
-
|
|
55
|
-
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
|
|
61
|
-
_labelSlot: Array<HTMLElement>;
|
|
60
|
+
_slottedChildren: Array<HTMLElement>;
|
|
62
61
|
private _handleDisabled;
|
|
63
62
|
private _handleStatus;
|
|
64
63
|
/**
|
|
65
|
-
* Function that updates the local `
|
|
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
|
|
2
|
-
import { state as
|
|
3
|
-
import { FormControlMixin as m, RtlMixin as y, validPropertyValues as
|
|
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,
|
|
13
|
-
for (var
|
|
14
|
-
(
|
|
15
|
-
return
|
|
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
|
|
17
|
+
const f = "pie-checkbox-group", u = "assistive-text", d = class d extends m(y(x)) {
|
|
18
18
|
constructor() {
|
|
19
|
-
super(...arguments), this.
|
|
19
|
+
super(...arguments), this._hasLabel = !1, this.isInline = p.isInline, this.status = p.status, this.disabled = p.disabled;
|
|
20
20
|
}
|
|
21
21
|
_handleDisabled() {
|
|
22
|
-
|
|
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
|
-
|
|
31
|
-
|
|
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 `
|
|
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
|
|
42
|
-
this.
|
|
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.
|
|
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:
|
|
59
|
-
assistiveText:
|
|
60
|
-
status:
|
|
56
|
+
isInline: i,
|
|
57
|
+
assistiveText: r,
|
|
58
|
+
status: s,
|
|
61
59
|
disabled: a
|
|
62
|
-
} = this,
|
|
60
|
+
} = this, l = {
|
|
63
61
|
"c-checkboxGroup": !0,
|
|
64
|
-
"c-checkboxGroup--inline":
|
|
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(
|
|
68
|
+
aria-describedby="${b(r ? u : void 0)}"
|
|
71
69
|
data-test-id="pie-checkbox-group"
|
|
72
|
-
class="${C(
|
|
70
|
+
class="${C(l)}"
|
|
73
71
|
>
|
|
74
72
|
${this.renderWrappedLabel()}
|
|
75
73
|
<slot></slot>
|
|
76
74
|
</fieldset>
|
|
77
|
-
${
|
|
75
|
+
${r && n`
|
|
78
76
|
<pie-assistive-text
|
|
79
77
|
id="${u}"
|
|
80
|
-
variant=${
|
|
78
|
+
variant=${s}
|
|
81
79
|
class="c-checkboxGroup-assistiveText"
|
|
82
80
|
data-test-id="pie-checkbox-group-assistive-text">
|
|
83
|
-
${
|
|
81
|
+
${r}
|
|
84
82
|
</pie-assistive-text>`}
|
|
85
83
|
`;
|
|
86
84
|
}
|
|
87
85
|
};
|
|
88
|
-
d.styles =
|
|
89
|
-
let
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
],
|
|
93
|
-
|
|
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
|
-
],
|
|
96
|
-
|
|
93
|
+
], t.prototype, "name");
|
|
94
|
+
o([
|
|
97
95
|
c({ type: String })
|
|
98
|
-
],
|
|
99
|
-
|
|
96
|
+
], t.prototype, "assistiveText");
|
|
97
|
+
o([
|
|
100
98
|
c({ type: Boolean })
|
|
101
|
-
],
|
|
102
|
-
|
|
99
|
+
], t.prototype, "isInline");
|
|
100
|
+
o([
|
|
103
101
|
c({ type: String }),
|
|
104
|
-
|
|
105
|
-
],
|
|
106
|
-
|
|
102
|
+
_(f, S, p.status)
|
|
103
|
+
], t.prototype, "status");
|
|
104
|
+
o([
|
|
107
105
|
c({ type: Boolean, reflect: !0 })
|
|
108
|
-
],
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
],
|
|
112
|
-
|
|
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
|
-
|
|
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
|
-
|
|
58
|
-
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
|
|
64
|
-
_labelSlot: Array<HTMLElement>;
|
|
63
|
+
_slottedChildren: Array<HTMLElement>;
|
|
65
64
|
private _handleDisabled;
|
|
66
65
|
private _handleStatus;
|
|
67
66
|
/**
|
|
68
|
-
* Function that updates the local `
|
|
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.
|
|
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.
|
|
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
|
|
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
|
-
|
|
38
|
+
private _hasLabel = false;
|
|
39
39
|
|
|
40
40
|
@property({ type: String })
|
|
41
|
-
public 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
|
|
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
|
|
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
|
|
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 `
|
|
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.
|
|
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
|
|
93
|
-
return this.
|
|
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 {
|