@justeattakeaway/pie-radio-group 0.7.2 → 0.8.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/custom-elements.json +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +64 -51
- package/dist/react.d.ts +2 -2
- package/package.json +7 -6
- package/src/index.ts +2 -2
package/custom-elements.json
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
|
|
|
2
2
|
import type { CSSResult } from 'lit';
|
|
3
3
|
import type { FormControlInterface } from '@justeattakeaway/pie-webc-core';
|
|
4
4
|
import type { GenericConstructor } from '@justeattakeaway/pie-webc-core';
|
|
5
|
-
import
|
|
5
|
+
import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
|
|
6
6
|
import type { PropertyValues } from 'lit';
|
|
7
7
|
import type { RTLInterface } from '@justeattakeaway/pie-webc-core';
|
|
8
8
|
import type { TemplateResult } from 'lit';
|
|
@@ -147,7 +147,7 @@ export declare class PieRadioGroup extends PieRadioGroup_base implements RadioGr
|
|
|
147
147
|
static styles: CSSResult;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
declare const PieRadioGroup_base: GenericConstructor<FormControlInterface> & GenericConstructor<RTLInterface> & typeof
|
|
150
|
+
declare const PieRadioGroup_base: GenericConstructor<FormControlInterface> & GenericConstructor<RTLInterface> & typeof PieElement;
|
|
151
151
|
|
|
152
152
|
export declare interface RadioGroupProps {
|
|
153
153
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,25 +1,38 @@
|
|
|
1
|
-
import { LitElement as
|
|
2
|
-
import {
|
|
3
|
-
import { FormControlMixin as
|
|
4
|
-
import { ifDefined as
|
|
5
|
-
import { classMap as
|
|
1
|
+
import { LitElement as m, html as p, nothing as u, unsafeCSS as v } from "lit";
|
|
2
|
+
import { property as l, state as y, queryAssignedElements as C, query as w } from "lit/decorators.js";
|
|
3
|
+
import { FormControlMixin as x, RtlMixin as S, wrapNativeEvent as T, validPropertyValues as A, defineCustomElement as L } from "@justeattakeaway/pie-webc-core";
|
|
4
|
+
import { ifDefined as E } from "lit/directives/if-defined.js";
|
|
5
|
+
import { classMap as R } from "lit/directives/class-map.js";
|
|
6
6
|
import "@justeattakeaway/pie-assistive-text";
|
|
7
|
-
|
|
7
|
+
var k = Object.defineProperty, F = (h, e, t, i) => {
|
|
8
|
+
for (var s = void 0, a = h.length - 1, r; a >= 0; a--)
|
|
9
|
+
(r = h[a]) && (s = r(e, t, s) || s);
|
|
10
|
+
return s && k(e, t, s), s;
|
|
11
|
+
};
|
|
12
|
+
class _ extends m {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments), this.v = "0.8.0";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
F([
|
|
18
|
+
l({ type: String, reflect: !0 })
|
|
19
|
+
], _.prototype, "v");
|
|
20
|
+
const $ = "*,*:after,*:before{box-sizing:inherit}.c-radioGroup{--radio-group-gap: var(--dt-spacing-c);--radio-group-gap--inline: var(--dt-spacing-c) var(--dt-spacing-e);margin:0;padding:0;border:0;min-width:0;display:flex;flex-flow:column wrap;gap:var(--radio-group-gap)}.c-radioGroup>legend{margin-block-end:var(--dt-spacing-b)}.c-radioGroup.c-radioGroup--inline{flex-flow:row wrap;gap:var(--radio-group-gap--inline)}.c-radioGroup.c-radioGroup--hasAssistiveText{margin-block-end:var(--dt-spacing-a)}", I = ["default", "success", "error"], D = "pie-radio-group-disabled", c = {
|
|
8
21
|
status: "default",
|
|
9
22
|
disabled: !1,
|
|
10
23
|
isInline: !1,
|
|
11
24
|
value: ""
|
|
12
25
|
};
|
|
13
|
-
var
|
|
14
|
-
for (var
|
|
15
|
-
(
|
|
16
|
-
return
|
|
26
|
+
var G = Object.defineProperty, d = (h, e, t, i) => {
|
|
27
|
+
for (var s = void 0, a = h.length - 1, r; a >= 0; a--)
|
|
28
|
+
(r = h[a]) && (s = r(e, t, s) || s);
|
|
29
|
+
return s && G(e, t, s), s;
|
|
17
30
|
};
|
|
18
|
-
const
|
|
19
|
-
var
|
|
20
|
-
const o = (
|
|
31
|
+
const g = "pie-radio-group", f = "assistive-text";
|
|
32
|
+
var n;
|
|
33
|
+
const o = (n = class extends x(S(_)) {
|
|
21
34
|
constructor() {
|
|
22
|
-
super(...arguments), this._hasLabel = !1, this.value =
|
|
35
|
+
super(...arguments), this._hasLabel = !1, this.value = c.value, this.isInline = c.isInline, this.disabled = c.disabled, this.status = c.status;
|
|
23
36
|
}
|
|
24
37
|
/**
|
|
25
38
|
* Dispatches a custom event to notify each slotted child radio element
|
|
@@ -27,7 +40,7 @@ const o = (r = class extends w(x(g)) {
|
|
|
27
40
|
* @private
|
|
28
41
|
*/
|
|
29
42
|
_handleDisabled() {
|
|
30
|
-
this._slottedChildren.forEach((e) => e.dispatchEvent(new CustomEvent(
|
|
43
|
+
this._slottedChildren.forEach((e) => e.dispatchEvent(new CustomEvent(D, {
|
|
31
44
|
bubbles: !1,
|
|
32
45
|
composed: !1,
|
|
33
46
|
detail: { disabled: this.disabled }
|
|
@@ -60,8 +73,8 @@ const o = (r = class extends w(x(g)) {
|
|
|
60
73
|
e.stopPropagation();
|
|
61
74
|
const t = e.target;
|
|
62
75
|
this._handleRadioSelection(t.value);
|
|
63
|
-
const
|
|
64
|
-
this.dispatchEvent(
|
|
76
|
+
const i = T(e);
|
|
77
|
+
this.dispatchEvent(i);
|
|
65
78
|
}
|
|
66
79
|
/**
|
|
67
80
|
* Updates the `_hasLabel` state when content is added to the label slot.
|
|
@@ -84,7 +97,7 @@ const o = (r = class extends w(x(g)) {
|
|
|
84
97
|
* @private
|
|
85
98
|
*/
|
|
86
99
|
_renderWrappedLabel() {
|
|
87
|
-
return this._hasLabel ?
|
|
100
|
+
return this._hasLabel ? p`<legend><slot name='label' @slotchange=${this._handleLabelSlotChange}></slot></legend>` : p`<slot name='label' @slotchange=${this._handleLabelSlotChange}></slot>`;
|
|
88
101
|
}
|
|
89
102
|
_applyNameToChildren() {
|
|
90
103
|
this._slottedChildren.forEach((e) => {
|
|
@@ -104,7 +117,7 @@ const o = (r = class extends w(x(g)) {
|
|
|
104
117
|
* Updates the state of `_wasShiftTabPressed` based on the last `Tab` key press.
|
|
105
118
|
*/
|
|
106
119
|
_updateShiftTabState(e) {
|
|
107
|
-
e.key === "Tab" && (
|
|
120
|
+
e.key === "Tab" && (n._wasShiftTabPressed = e.shiftKey);
|
|
108
121
|
}
|
|
109
122
|
/**
|
|
110
123
|
* Handles the `focusin` event to manage focus within the radio group.
|
|
@@ -114,10 +127,10 @@ const o = (r = class extends w(x(g)) {
|
|
|
114
127
|
* and focuses the checked option, the first option, or the last option as needed.
|
|
115
128
|
*/
|
|
116
129
|
_handleFocusIn(e) {
|
|
117
|
-
var
|
|
130
|
+
var s;
|
|
118
131
|
if (this !== e.target) return;
|
|
119
|
-
const t =
|
|
120
|
-
|
|
132
|
+
const t = n._wasShiftTabPressed, i = ((s = this._slottedChildren) == null ? void 0 : s.find((a) => a.checked)) || (t ? this._slottedChildren.at(-1) : this._slottedChildren[0]);
|
|
133
|
+
i && (i.focus(), this._toggleFieldsetTabindex(!1));
|
|
121
134
|
}
|
|
122
135
|
/**
|
|
123
136
|
* Handles the `focusout` event to restore the `tabindex` on the radio group's `fieldset`.
|
|
@@ -133,8 +146,8 @@ const o = (r = class extends w(x(g)) {
|
|
|
133
146
|
e ? this._fieldset.setAttribute("tabindex", "0") : this._fieldset.removeAttribute("tabindex");
|
|
134
147
|
}
|
|
135
148
|
_moveFocus(e, t) {
|
|
136
|
-
const
|
|
137
|
-
this._focusAndClickOption(this._slottedChildren[
|
|
149
|
+
const i = (e + t + this._slottedChildren.length) % this._slottedChildren.length;
|
|
150
|
+
this._focusAndClickOption(this._slottedChildren[i]);
|
|
138
151
|
}
|
|
139
152
|
/**
|
|
140
153
|
* Determines if a key press indicates forward navigation within the radio group.
|
|
@@ -174,15 +187,15 @@ const o = (r = class extends w(x(g)) {
|
|
|
174
187
|
* the default browser behaviour (e.g., scrolling) when arrow keys are used for navigation.
|
|
175
188
|
*/
|
|
176
189
|
_handleKeyDown(e) {
|
|
177
|
-
const t = this._slottedChildren.find((
|
|
190
|
+
const t = this._slottedChildren.find((s) => s === document.activeElement);
|
|
178
191
|
if (!t)
|
|
179
192
|
return;
|
|
180
|
-
const
|
|
181
|
-
|
|
193
|
+
const i = this._slottedChildren.indexOf(t);
|
|
194
|
+
i !== -1 && (["ArrowRight", "ArrowDown", "ArrowLeft", "ArrowUp"].includes(e.code) && e.preventDefault(), this._isForwardKey(e) ? this._moveFocus(i, 1) : this._isBackwardKey(e) && this._moveFocus(i, -1));
|
|
182
195
|
}
|
|
183
196
|
_focusAndClickOption(e) {
|
|
184
|
-
var t,
|
|
185
|
-
e.focus(), (
|
|
197
|
+
var t, i;
|
|
198
|
+
e.focus(), (i = (t = e.shadowRoot) == null ? void 0 : t.querySelector("input")) == null || i.click(), this._toggleFieldsetTabindex(!1);
|
|
186
199
|
}
|
|
187
200
|
disconnectedCallback() {
|
|
188
201
|
super.disconnectedCallback(), this._abortController.abort();
|
|
@@ -191,38 +204,38 @@ const o = (r = class extends w(x(g)) {
|
|
|
191
204
|
const {
|
|
192
205
|
name: e,
|
|
193
206
|
isInline: t,
|
|
194
|
-
disabled:
|
|
195
|
-
status:
|
|
207
|
+
disabled: i,
|
|
208
|
+
status: s,
|
|
196
209
|
assistiveText: a
|
|
197
|
-
} = this,
|
|
210
|
+
} = this, r = !!(a != null && a.length), b = {
|
|
198
211
|
"c-radioGroup": !0,
|
|
199
212
|
"c-radioGroup--inline": t,
|
|
200
|
-
"c-radioGroup--hasAssistiveText":
|
|
213
|
+
"c-radioGroup--hasAssistiveText": r
|
|
201
214
|
};
|
|
202
|
-
return
|
|
215
|
+
return p`
|
|
203
216
|
<fieldset
|
|
204
217
|
role="radiogroup"
|
|
205
218
|
tabindex="0"
|
|
206
|
-
name=${
|
|
207
|
-
?disabled=${
|
|
219
|
+
name=${E(e)}
|
|
220
|
+
?disabled=${i}
|
|
208
221
|
data-test-id="pie-radio-group-fieldset"
|
|
209
|
-
aria-describedby=${
|
|
210
|
-
class="${
|
|
222
|
+
aria-describedby=${r ? f : u}
|
|
223
|
+
class="${R(b)}">
|
|
211
224
|
${this._renderWrappedLabel()}
|
|
212
225
|
<slot @slotchange=${this._handleRadioSlotChange}></slot>
|
|
213
226
|
</fieldset>
|
|
214
|
-
${
|
|
227
|
+
${r ? p`
|
|
215
228
|
<pie-assistive-text
|
|
216
229
|
id=${f}
|
|
217
|
-
variant=${
|
|
230
|
+
variant=${s}
|
|
218
231
|
data-test-id="pie-radio-group-assistive-text">
|
|
219
232
|
${a}
|
|
220
233
|
</pie-assistive-text>` : u}
|
|
221
234
|
`;
|
|
222
235
|
}
|
|
223
|
-
},
|
|
236
|
+
}, n._wasShiftTabPressed = !1, n.styles = v($), n);
|
|
224
237
|
d([
|
|
225
|
-
|
|
238
|
+
y()
|
|
226
239
|
], o.prototype, "_hasLabel");
|
|
227
240
|
d([
|
|
228
241
|
l({ type: String })
|
|
@@ -241,19 +254,19 @@ d([
|
|
|
241
254
|
], o.prototype, "assistiveText");
|
|
242
255
|
d([
|
|
243
256
|
l({ type: String }),
|
|
244
|
-
|
|
257
|
+
A(g, I, c.status)
|
|
245
258
|
], o.prototype, "status");
|
|
246
259
|
d([
|
|
247
|
-
|
|
260
|
+
C({ selector: "pie-radio" })
|
|
248
261
|
], o.prototype, "_slottedChildren");
|
|
249
262
|
d([
|
|
250
|
-
|
|
263
|
+
w("fieldset")
|
|
251
264
|
], o.prototype, "_fieldset");
|
|
252
|
-
let
|
|
253
|
-
|
|
265
|
+
let O = o;
|
|
266
|
+
L(g, O);
|
|
254
267
|
export {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
268
|
+
D as ON_RADIO_GROUP_DISABLED,
|
|
269
|
+
O as PieRadioGroup,
|
|
270
|
+
c as defaultProps,
|
|
271
|
+
I as statusTypes
|
|
259
272
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
|
|
|
2
2
|
import type { CSSResult } from 'lit';
|
|
3
3
|
import type { FormControlInterface } from '@justeattakeaway/pie-webc-core';
|
|
4
4
|
import type { GenericConstructor } from '@justeattakeaway/pie-webc-core';
|
|
5
|
-
import
|
|
5
|
+
import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
|
|
6
6
|
import type { PropertyValues } from 'lit';
|
|
7
7
|
import * as React_2 from 'react';
|
|
8
8
|
import type { RTLInterface } from '@justeattakeaway/pie-webc-core';
|
|
@@ -150,7 +150,7 @@ declare class PieRadioGroup_2 extends PieRadioGroup_base implements RadioGroupPr
|
|
|
150
150
|
static styles: CSSResult;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
declare const PieRadioGroup_base: GenericConstructor<FormControlInterface> & GenericConstructor<RTLInterface> & typeof
|
|
153
|
+
declare const PieRadioGroup_base: GenericConstructor<FormControlInterface> & GenericConstructor<RTLInterface> & typeof PieElement;
|
|
154
154
|
|
|
155
155
|
declare type PieRadioGroupEvents = {
|
|
156
156
|
onChange?: (event: CustomEvent) => void;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-radio-group",
|
|
3
3
|
"description": "PIE Design System Radio Group built using Web Components",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -33,14 +33,15 @@
|
|
|
33
33
|
"license": "Apache-2.0",
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@custom-elements-manifest/analyzer": "0.9.0",
|
|
36
|
-
"@justeattakeaway/pie-components-config": "0.
|
|
37
|
-
"@justeattakeaway/pie-css": "0.
|
|
38
|
-
"@justeattakeaway/pie-
|
|
36
|
+
"@justeattakeaway/pie-components-config": "0.19.0",
|
|
37
|
+
"@justeattakeaway/pie-css": "0.16.0",
|
|
38
|
+
"@justeattakeaway/pie-monorepo-utils": "0.5.0",
|
|
39
|
+
"@justeattakeaway/pie-radio": "0.10.0",
|
|
39
40
|
"cem-plugin-module-file-extensions": "0.0.5"
|
|
40
41
|
},
|
|
41
42
|
"dependencies": {
|
|
42
|
-
"@justeattakeaway/pie-assistive-text": "0.
|
|
43
|
-
"@justeattakeaway/pie-webc-core": "0.
|
|
43
|
+
"@justeattakeaway/pie-assistive-text": "0.9.0",
|
|
44
|
+
"@justeattakeaway/pie-webc-core": "0.25.0"
|
|
44
45
|
},
|
|
45
46
|
"volta": {
|
|
46
47
|
"extends": "../../../package.json"
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
LitElement,
|
|
3
2
|
html,
|
|
4
3
|
unsafeCSS,
|
|
5
4
|
nothing,
|
|
6
5
|
type PropertyValues,
|
|
7
6
|
type TemplateResult,
|
|
8
7
|
} from 'lit';
|
|
8
|
+
import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
|
|
9
9
|
import {
|
|
10
10
|
property, query, queryAssignedElements, state,
|
|
11
11
|
} from 'lit/decorators.js';
|
|
@@ -39,7 +39,7 @@ const assistiveTextId = 'assistive-text';
|
|
|
39
39
|
* @slot label - The label slot
|
|
40
40
|
* @event {CustomEvent} change - when one of the radios state is changed.
|
|
41
41
|
*/
|
|
42
|
-
export class PieRadioGroup extends FormControlMixin(RtlMixin(
|
|
42
|
+
export class PieRadioGroup extends FormControlMixin(RtlMixin(PieElement)) implements RadioGroupProps {
|
|
43
43
|
@state()
|
|
44
44
|
private _hasLabel = false;
|
|
45
45
|
|