@lukso/web-components 1.133.0 → 1.134.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/dist/components/index.cjs +13 -3
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +5 -3
- package/dist/components/lukso-button/index.cjs +3 -3
- package/dist/components/lukso-button/index.js +3 -3
- package/dist/components/lukso-card/index.cjs +6 -6
- package/dist/components/lukso-card/index.js +6 -6
- package/dist/components/lukso-checkbox/index.cjs +3 -3
- package/dist/components/lukso-checkbox/index.js +3 -3
- package/dist/components/lukso-checkbox/lukso-checkbox.stories.d.ts.map +1 -1
- package/dist/components/lukso-color-picker/index.cjs +4 -4
- package/dist/components/lukso-color-picker/index.js +4 -4
- package/dist/components/lukso-dropdown/index.cjs +4 -4
- package/dist/components/lukso-dropdown/index.js +4 -4
- package/dist/components/lukso-dropdown-option/index.cjs +2 -2
- package/dist/components/lukso-dropdown-option/index.js +2 -2
- package/dist/components/lukso-footer/index.cjs +2 -2
- package/dist/components/lukso-footer/index.js +2 -2
- package/dist/components/lukso-icon/index.cjs +3 -3
- package/dist/components/lukso-icon/index.js +3 -3
- package/dist/components/lukso-image/index.cjs +4 -4
- package/dist/components/lukso-image/index.js +4 -4
- package/dist/components/lukso-input/index.cjs +3 -3
- package/dist/components/lukso-input/index.js +3 -3
- package/dist/components/lukso-modal/index.cjs +2 -2
- package/dist/components/lukso-modal/index.js +2 -2
- package/dist/components/lukso-navbar/index.cjs +3 -3
- package/dist/components/lukso-navbar/index.js +3 -3
- package/dist/components/lukso-pagination/index.cjs +3 -3
- package/dist/components/lukso-pagination/index.js +3 -3
- package/dist/components/lukso-profile/index.cjs +3 -3
- package/dist/components/lukso-profile/index.js +3 -3
- package/dist/components/lukso-progress/index.cjs +3 -3
- package/dist/components/lukso-progress/index.js +3 -3
- package/dist/components/lukso-radio/index.cjs +284 -0
- package/dist/components/lukso-radio/index.d.ts +34 -0
- package/dist/components/lukso-radio/index.d.ts.map +1 -0
- package/dist/components/lukso-radio/index.js +282 -0
- package/dist/components/lukso-radio/lukso-radio.stories.d.ts +24 -0
- package/dist/components/lukso-radio/lukso-radio.stories.d.ts.map +1 -0
- package/dist/components/lukso-radio-group/index.cjs +197 -0
- package/dist/components/lukso-radio-group/index.d.ts +25 -0
- package/dist/components/lukso-radio-group/index.d.ts.map +1 -0
- package/dist/components/lukso-radio-group/index.js +195 -0
- package/dist/components/lukso-radio-group/lukso-radio-group.stories.d.ts +18 -0
- package/dist/components/lukso-radio-group/lukso-radio-group.stories.d.ts.map +1 -0
- package/dist/components/lukso-sanitize/index.cjs +2 -2
- package/dist/components/lukso-sanitize/index.js +2 -2
- package/dist/components/lukso-search/index.cjs +5 -5
- package/dist/components/lukso-search/index.js +5 -5
- package/dist/components/lukso-select/index.cjs +5 -5
- package/dist/components/lukso-select/index.js +5 -5
- package/dist/components/lukso-share/index.cjs +2 -2
- package/dist/components/lukso-share/index.js +2 -2
- package/dist/components/lukso-switch/index.cjs +3 -3
- package/dist/components/lukso-switch/index.js +3 -3
- package/dist/components/lukso-tag/index.cjs +3 -3
- package/dist/components/lukso-tag/index.js +3 -3
- package/dist/components/lukso-terms/index.cjs +3 -3
- package/dist/components/lukso-terms/index.js +3 -3
- package/dist/components/lukso-test/index.cjs +3 -3
- package/dist/components/lukso-test/index.js +3 -3
- package/dist/components/lukso-textarea/index.cjs +3 -3
- package/dist/components/lukso-textarea/index.js +3 -3
- package/dist/components/lukso-tooltip/index.cjs +3 -3
- package/dist/components/lukso-tooltip/index.js +3 -3
- package/dist/components/lukso-username/index.cjs +4 -4
- package/dist/components/lukso-username/index.js +4 -4
- package/dist/components/lukso-wizard/index.cjs +3 -3
- package/dist/components/lukso-wizard/index.js +3 -3
- package/dist/{directive-helpers-3kxRVVhW.js → directive-helpers-CAIm9TDG.js} +1 -1
- package/dist/{directive-helpers-Claj8QFS.cjs → directive-helpers-DArp4lXT.cjs} +1 -1
- package/dist/{index-Cu5nTnv0.js → index--44JsQ_1.js} +3 -3
- package/dist/index-BMFENeRI.cjs +50 -0
- package/dist/{index-CnPbG4we.cjs → index-CUMvAhRx.cjs} +2 -2
- package/dist/{index-NWJXeIKU.cjs → index-D19a1K8E.cjs} +3 -3
- package/dist/{index-BU2n3O3i.cjs → index-D1v8ZgtZ.cjs} +1 -1
- package/dist/{index-_yzN6-V_.js → index-DHAAIAHr.js} +1 -1
- package/dist/{index-CtLMSY1C.js → index-Dsu77DGF.js} +2 -2
- package/dist/index-axQAcayx.js +41 -0
- package/dist/index.cjs +13 -3
- package/dist/index.js +5 -3
- package/dist/{property-CkmArYBu.js → property-CYbm8aZx.js} +1 -1
- package/dist/{property-COIvMvUb.cjs → property-DGVQMLCH.cjs} +1 -1
- package/dist/shared/tailwind-element/index.cjs +1 -1
- package/dist/shared/tailwind-element/index.js +1 -1
- package/dist/{state-BPlyD0ke.cjs → state-CCMDzTj3.cjs} +1 -1
- package/dist/{state-C2ESTJU7.js → state-hoCBDnpA.js} +1 -1
- package/dist/{style-map-COdlVkYa.js → style-map-Min8ajOg.js} +1 -1
- package/dist/{style-map-DgWKFQAt.cjs → style-map-VlU1Vn2Q.cjs} +1 -1
- package/package.json +11 -1
- package/dist/index-7a66ANzh.cjs +0 -50
- package/dist/index-u03FFuQ-.js +0 -41
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const shared_tailwindElement_index = require('../../index-BMFENeRI.cjs');
|
|
6
|
+
const property = require('../../property-DGVQMLCH.cjs');
|
|
7
|
+
const state = require('../../state-CCMDzTj3.cjs');
|
|
8
|
+
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
12
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
13
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
14
|
+
if (decorator = decorators[i])
|
|
15
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
16
|
+
if (kind && result) __defProp(target, key, result);
|
|
17
|
+
return result;
|
|
18
|
+
};
|
|
19
|
+
exports.LuksoRadioGroup = class LuksoRadioGroup extends shared_tailwindElement_index.TailwindElement {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.name = "";
|
|
23
|
+
this.value = "";
|
|
24
|
+
this.autofocus = false;
|
|
25
|
+
this.focusedIndex = -1;
|
|
26
|
+
this.radios = [];
|
|
27
|
+
}
|
|
28
|
+
// Detect if radio group is laid out horizontally or vertically
|
|
29
|
+
isHorizontalLayout() {
|
|
30
|
+
const firstRadio = this.querySelector("lukso-radio");
|
|
31
|
+
if (!firstRadio) return false;
|
|
32
|
+
const secondRadio = firstRadio.nextElementSibling;
|
|
33
|
+
if (!secondRadio) return false;
|
|
34
|
+
const firstRect = firstRadio.getBoundingClientRect();
|
|
35
|
+
const secondRect = secondRadio.getBoundingClientRect();
|
|
36
|
+
return Math.abs(secondRect.left - firstRect.left) > Math.abs(secondRect.top - firstRect.top);
|
|
37
|
+
}
|
|
38
|
+
handleChange(e) {
|
|
39
|
+
const newValue = e.detail.value;
|
|
40
|
+
this.value = newValue;
|
|
41
|
+
this.updateRadios();
|
|
42
|
+
this.dispatchEvent(
|
|
43
|
+
new CustomEvent("change", {
|
|
44
|
+
detail: { value: this.value },
|
|
45
|
+
bubbles: true,
|
|
46
|
+
composed: true
|
|
47
|
+
})
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
updateRadios() {
|
|
51
|
+
const radios = this.querySelectorAll("lukso-radio");
|
|
52
|
+
for (const el of radios) {
|
|
53
|
+
el.checked = el.value === this.value;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Make sure radios are updated when they become available
|
|
57
|
+
setupInitialState() {
|
|
58
|
+
this.updateRadios();
|
|
59
|
+
setTimeout(() => this.updateRadios(), 50);
|
|
60
|
+
setTimeout(() => this.updateRadios(), 150);
|
|
61
|
+
}
|
|
62
|
+
handleKeydown(e) {
|
|
63
|
+
this.radios = Array.from(this.querySelectorAll("lukso-radio"));
|
|
64
|
+
if (!this.radios.length) return;
|
|
65
|
+
const selectedIndex = this.radios.findIndex(
|
|
66
|
+
(radio) => radio.checked
|
|
67
|
+
);
|
|
68
|
+
if (this.focusedIndex === -1) {
|
|
69
|
+
this.focusedIndex = selectedIndex >= 0 ? selectedIndex : 0;
|
|
70
|
+
}
|
|
71
|
+
let newIndex = this.focusedIndex;
|
|
72
|
+
const isHorizontal = this.isHorizontalLayout();
|
|
73
|
+
switch (e.key) {
|
|
74
|
+
case "ArrowDown":
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
if (!isHorizontal) {
|
|
77
|
+
newIndex = (this.focusedIndex + 1) % this.radios.length;
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
80
|
+
case "ArrowRight":
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
newIndex = (this.focusedIndex + 1) % this.radios.length;
|
|
83
|
+
break;
|
|
84
|
+
case "ArrowUp":
|
|
85
|
+
e.preventDefault();
|
|
86
|
+
if (!isHorizontal) {
|
|
87
|
+
newIndex = (this.focusedIndex - 1 + this.radios.length) % this.radios.length;
|
|
88
|
+
}
|
|
89
|
+
break;
|
|
90
|
+
case "ArrowLeft":
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
newIndex = (this.focusedIndex - 1 + this.radios.length) % this.radios.length;
|
|
93
|
+
break;
|
|
94
|
+
case "Home":
|
|
95
|
+
e.preventDefault();
|
|
96
|
+
newIndex = 0;
|
|
97
|
+
break;
|
|
98
|
+
case "End":
|
|
99
|
+
e.preventDefault();
|
|
100
|
+
newIndex = this.radios.length - 1;
|
|
101
|
+
break;
|
|
102
|
+
default:
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (newIndex !== this.focusedIndex) {
|
|
106
|
+
this.focusedIndex = newIndex;
|
|
107
|
+
const radioToFocus = this.radios[newIndex];
|
|
108
|
+
if (!radioToFocus.isDisabled && !radioToFocus.isReadonly) {
|
|
109
|
+
radioToFocus.focus();
|
|
110
|
+
this.value = radioToFocus.value;
|
|
111
|
+
this.updateRadios();
|
|
112
|
+
this.dispatchEvent(
|
|
113
|
+
new CustomEvent("change", {
|
|
114
|
+
detail: { value: this.value },
|
|
115
|
+
bubbles: true,
|
|
116
|
+
composed: true
|
|
117
|
+
})
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
connectedCallback() {
|
|
123
|
+
super.connectedCallback();
|
|
124
|
+
this.addEventListener("on-change", this.handleChange);
|
|
125
|
+
this.addEventListener("keydown", this.handleKeydown);
|
|
126
|
+
this.setupInitialState();
|
|
127
|
+
if (this.autofocus) {
|
|
128
|
+
setTimeout(() => this.handleGroupFocus(), 50);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
// Called after the first update and subsequent updates
|
|
132
|
+
updated(changedProperties) {
|
|
133
|
+
super.updated?.(changedProperties);
|
|
134
|
+
if (changedProperties.has("value")) {
|
|
135
|
+
this.updateRadios();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
139
|
+
super.attributeChangedCallback(name, oldVal, newVal);
|
|
140
|
+
if (name === "value" && oldVal !== newVal && this.isConnected) {
|
|
141
|
+
this.updateRadios();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
disconnectedCallback() {
|
|
145
|
+
this.removeEventListener("on-change", this.handleChange);
|
|
146
|
+
this.removeEventListener("keydown", this.handleKeydown);
|
|
147
|
+
super.disconnectedCallback();
|
|
148
|
+
}
|
|
149
|
+
// When the group gets focus, we should move focus to the selected radio or first available
|
|
150
|
+
handleGroupFocus() {
|
|
151
|
+
if (!this.isConnected) return;
|
|
152
|
+
const radios = Array.from(
|
|
153
|
+
this.querySelectorAll("lukso-radio")
|
|
154
|
+
);
|
|
155
|
+
if (!radios.length) return;
|
|
156
|
+
const selectedRadio = radios.find(
|
|
157
|
+
(radio) => radio.checked && !radio.isDisabled && !radio.isReadonly
|
|
158
|
+
);
|
|
159
|
+
const firstEnabledRadio = radios.find(
|
|
160
|
+
(radio) => !radio.isDisabled && !radio.isReadonly
|
|
161
|
+
);
|
|
162
|
+
const radioToFocus = selectedRadio || firstEnabledRadio;
|
|
163
|
+
if (radioToFocus) {
|
|
164
|
+
setTimeout(() => radioToFocus.focus(), 0);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
render() {
|
|
168
|
+
return shared_tailwindElement_index.x`
|
|
169
|
+
<div
|
|
170
|
+
role="radiogroup"
|
|
171
|
+
aria-label="${this.name}"
|
|
172
|
+
tabindex="0"
|
|
173
|
+
@focus="${this.handleGroupFocus}"
|
|
174
|
+
>
|
|
175
|
+
<slot></slot>
|
|
176
|
+
</div>
|
|
177
|
+
`;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
__decorateClass([
|
|
181
|
+
property.n({ type: String })
|
|
182
|
+
], exports.LuksoRadioGroup.prototype, "name", 2);
|
|
183
|
+
__decorateClass([
|
|
184
|
+
property.n({ type: String })
|
|
185
|
+
], exports.LuksoRadioGroup.prototype, "value", 2);
|
|
186
|
+
__decorateClass([
|
|
187
|
+
property.n({ type: Boolean })
|
|
188
|
+
], exports.LuksoRadioGroup.prototype, "autofocus", 2);
|
|
189
|
+
__decorateClass([
|
|
190
|
+
state.r()
|
|
191
|
+
], exports.LuksoRadioGroup.prototype, "focusedIndex", 2);
|
|
192
|
+
__decorateClass([
|
|
193
|
+
state.r()
|
|
194
|
+
], exports.LuksoRadioGroup.prototype, "radios", 2);
|
|
195
|
+
exports.LuksoRadioGroup = __decorateClass([
|
|
196
|
+
property.t("lukso-radio-group")
|
|
197
|
+
], exports.LuksoRadioGroup);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TailwindElement } from '../../shared/tailwind-element';
|
|
2
|
+
export declare class LuksoRadioGroup extends TailwindElement {
|
|
3
|
+
name: string;
|
|
4
|
+
value: string;
|
|
5
|
+
autofocus: boolean;
|
|
6
|
+
private focusedIndex;
|
|
7
|
+
private radios;
|
|
8
|
+
private isHorizontalLayout;
|
|
9
|
+
private handleChange;
|
|
10
|
+
private updateRadios;
|
|
11
|
+
private setupInitialState;
|
|
12
|
+
private handleKeydown;
|
|
13
|
+
connectedCallback(): void;
|
|
14
|
+
updated(changedProperties: Map<string, unknown>): void;
|
|
15
|
+
attributeChangedCallback(name: string, oldVal: string, newVal: string): void;
|
|
16
|
+
disconnectedCallback(): void;
|
|
17
|
+
private handleGroupFocus;
|
|
18
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
19
|
+
}
|
|
20
|
+
declare global {
|
|
21
|
+
interface HTMLElementTagNameMap {
|
|
22
|
+
'lukso-radio-group': LuksoRadioGroup;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/lukso-radio-group/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAU3D,qBACa,eAAgB,SAAQ,eAAe;IAElD,IAAI,SAAK;IAGT,KAAK,SAAK;IAGV,SAAS,UAAQ;IAIjB,OAAO,CAAC,YAAY,CAAK;IAGzB,OAAO,CAAC,MAAM,CAAoB;IAGlC,OAAO,CAAC,kBAAkB;IAoB1B,OAAO,CAAC,YAAY;IAepB,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,aAAa;IAqFrB,iBAAiB,IAAI,IAAI;IAezB,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAS/C,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IASrE,oBAAoB,IAAI,IAAI;IAO5B,OAAO,CAAC,gBAAgB;IAuBxB,MAAM;CAYP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,mBAAmB,EAAE,eAAe,CAAA;KACrC;CACF"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { a as TailwindElement, x } from '../../index-axQAcayx.js';
|
|
2
|
+
import { n, t } from '../../property-CYbm8aZx.js';
|
|
3
|
+
import { r } from '../../state-hoCBDnpA.js';
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
8
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
9
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
10
|
+
if (decorator = decorators[i])
|
|
11
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
12
|
+
if (kind && result) __defProp(target, key, result);
|
|
13
|
+
return result;
|
|
14
|
+
};
|
|
15
|
+
let LuksoRadioGroup = class extends TailwindElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.name = "";
|
|
19
|
+
this.value = "";
|
|
20
|
+
this.autofocus = false;
|
|
21
|
+
this.focusedIndex = -1;
|
|
22
|
+
this.radios = [];
|
|
23
|
+
}
|
|
24
|
+
// Detect if radio group is laid out horizontally or vertically
|
|
25
|
+
isHorizontalLayout() {
|
|
26
|
+
const firstRadio = this.querySelector("lukso-radio");
|
|
27
|
+
if (!firstRadio) return false;
|
|
28
|
+
const secondRadio = firstRadio.nextElementSibling;
|
|
29
|
+
if (!secondRadio) return false;
|
|
30
|
+
const firstRect = firstRadio.getBoundingClientRect();
|
|
31
|
+
const secondRect = secondRadio.getBoundingClientRect();
|
|
32
|
+
return Math.abs(secondRect.left - firstRect.left) > Math.abs(secondRect.top - firstRect.top);
|
|
33
|
+
}
|
|
34
|
+
handleChange(e) {
|
|
35
|
+
const newValue = e.detail.value;
|
|
36
|
+
this.value = newValue;
|
|
37
|
+
this.updateRadios();
|
|
38
|
+
this.dispatchEvent(
|
|
39
|
+
new CustomEvent("change", {
|
|
40
|
+
detail: { value: this.value },
|
|
41
|
+
bubbles: true,
|
|
42
|
+
composed: true
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
updateRadios() {
|
|
47
|
+
const radios = this.querySelectorAll("lukso-radio");
|
|
48
|
+
for (const el of radios) {
|
|
49
|
+
el.checked = el.value === this.value;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Make sure radios are updated when they become available
|
|
53
|
+
setupInitialState() {
|
|
54
|
+
this.updateRadios();
|
|
55
|
+
setTimeout(() => this.updateRadios(), 50);
|
|
56
|
+
setTimeout(() => this.updateRadios(), 150);
|
|
57
|
+
}
|
|
58
|
+
handleKeydown(e) {
|
|
59
|
+
this.radios = Array.from(this.querySelectorAll("lukso-radio"));
|
|
60
|
+
if (!this.radios.length) return;
|
|
61
|
+
const selectedIndex = this.radios.findIndex(
|
|
62
|
+
(radio) => radio.checked
|
|
63
|
+
);
|
|
64
|
+
if (this.focusedIndex === -1) {
|
|
65
|
+
this.focusedIndex = selectedIndex >= 0 ? selectedIndex : 0;
|
|
66
|
+
}
|
|
67
|
+
let newIndex = this.focusedIndex;
|
|
68
|
+
const isHorizontal = this.isHorizontalLayout();
|
|
69
|
+
switch (e.key) {
|
|
70
|
+
case "ArrowDown":
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
if (!isHorizontal) {
|
|
73
|
+
newIndex = (this.focusedIndex + 1) % this.radios.length;
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
case "ArrowRight":
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
newIndex = (this.focusedIndex + 1) % this.radios.length;
|
|
79
|
+
break;
|
|
80
|
+
case "ArrowUp":
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
if (!isHorizontal) {
|
|
83
|
+
newIndex = (this.focusedIndex - 1 + this.radios.length) % this.radios.length;
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
case "ArrowLeft":
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
newIndex = (this.focusedIndex - 1 + this.radios.length) % this.radios.length;
|
|
89
|
+
break;
|
|
90
|
+
case "Home":
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
newIndex = 0;
|
|
93
|
+
break;
|
|
94
|
+
case "End":
|
|
95
|
+
e.preventDefault();
|
|
96
|
+
newIndex = this.radios.length - 1;
|
|
97
|
+
break;
|
|
98
|
+
default:
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (newIndex !== this.focusedIndex) {
|
|
102
|
+
this.focusedIndex = newIndex;
|
|
103
|
+
const radioToFocus = this.radios[newIndex];
|
|
104
|
+
if (!radioToFocus.isDisabled && !radioToFocus.isReadonly) {
|
|
105
|
+
radioToFocus.focus();
|
|
106
|
+
this.value = radioToFocus.value;
|
|
107
|
+
this.updateRadios();
|
|
108
|
+
this.dispatchEvent(
|
|
109
|
+
new CustomEvent("change", {
|
|
110
|
+
detail: { value: this.value },
|
|
111
|
+
bubbles: true,
|
|
112
|
+
composed: true
|
|
113
|
+
})
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
connectedCallback() {
|
|
119
|
+
super.connectedCallback();
|
|
120
|
+
this.addEventListener("on-change", this.handleChange);
|
|
121
|
+
this.addEventListener("keydown", this.handleKeydown);
|
|
122
|
+
this.setupInitialState();
|
|
123
|
+
if (this.autofocus) {
|
|
124
|
+
setTimeout(() => this.handleGroupFocus(), 50);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Called after the first update and subsequent updates
|
|
128
|
+
updated(changedProperties) {
|
|
129
|
+
super.updated?.(changedProperties);
|
|
130
|
+
if (changedProperties.has("value")) {
|
|
131
|
+
this.updateRadios();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
135
|
+
super.attributeChangedCallback(name, oldVal, newVal);
|
|
136
|
+
if (name === "value" && oldVal !== newVal && this.isConnected) {
|
|
137
|
+
this.updateRadios();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
disconnectedCallback() {
|
|
141
|
+
this.removeEventListener("on-change", this.handleChange);
|
|
142
|
+
this.removeEventListener("keydown", this.handleKeydown);
|
|
143
|
+
super.disconnectedCallback();
|
|
144
|
+
}
|
|
145
|
+
// When the group gets focus, we should move focus to the selected radio or first available
|
|
146
|
+
handleGroupFocus() {
|
|
147
|
+
if (!this.isConnected) return;
|
|
148
|
+
const radios = Array.from(
|
|
149
|
+
this.querySelectorAll("lukso-radio")
|
|
150
|
+
);
|
|
151
|
+
if (!radios.length) return;
|
|
152
|
+
const selectedRadio = radios.find(
|
|
153
|
+
(radio) => radio.checked && !radio.isDisabled && !radio.isReadonly
|
|
154
|
+
);
|
|
155
|
+
const firstEnabledRadio = radios.find(
|
|
156
|
+
(radio) => !radio.isDisabled && !radio.isReadonly
|
|
157
|
+
);
|
|
158
|
+
const radioToFocus = selectedRadio || firstEnabledRadio;
|
|
159
|
+
if (radioToFocus) {
|
|
160
|
+
setTimeout(() => radioToFocus.focus(), 0);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
render() {
|
|
164
|
+
return x`
|
|
165
|
+
<div
|
|
166
|
+
role="radiogroup"
|
|
167
|
+
aria-label="${this.name}"
|
|
168
|
+
tabindex="0"
|
|
169
|
+
@focus="${this.handleGroupFocus}"
|
|
170
|
+
>
|
|
171
|
+
<slot></slot>
|
|
172
|
+
</div>
|
|
173
|
+
`;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
__decorateClass([
|
|
177
|
+
n({ type: String })
|
|
178
|
+
], LuksoRadioGroup.prototype, "name", 2);
|
|
179
|
+
__decorateClass([
|
|
180
|
+
n({ type: String })
|
|
181
|
+
], LuksoRadioGroup.prototype, "value", 2);
|
|
182
|
+
__decorateClass([
|
|
183
|
+
n({ type: Boolean })
|
|
184
|
+
], LuksoRadioGroup.prototype, "autofocus", 2);
|
|
185
|
+
__decorateClass([
|
|
186
|
+
r()
|
|
187
|
+
], LuksoRadioGroup.prototype, "focusedIndex", 2);
|
|
188
|
+
__decorateClass([
|
|
189
|
+
r()
|
|
190
|
+
], LuksoRadioGroup.prototype, "radios", 2);
|
|
191
|
+
LuksoRadioGroup = __decorateClass([
|
|
192
|
+
t("lukso-radio-group")
|
|
193
|
+
], LuksoRadioGroup);
|
|
194
|
+
|
|
195
|
+
export { LuksoRadioGroup };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Meta } from '@storybook/web-components';
|
|
2
|
+
/** Documentation and examples of div-based `lukso-radio-group` component. */
|
|
3
|
+
declare const meta: Meta;
|
|
4
|
+
export default meta;
|
|
5
|
+
export declare const AutoFocusRadioGroup: () => import('lit-html').TemplateResult<1>;
|
|
6
|
+
/** Default div-based radio group with three options. */
|
|
7
|
+
export declare const DefaultRadioGroup: any;
|
|
8
|
+
/** Radio group with different sizes. */
|
|
9
|
+
export declare const DifferentSizes: () => import('lit-html').TemplateResult<1>;
|
|
10
|
+
/** Radio group with error state on radios. */
|
|
11
|
+
export declare const WithError: () => import('lit-html').TemplateResult<1>;
|
|
12
|
+
/** Radio group with disabled and readonly radios. */
|
|
13
|
+
export declare const DisabledAndReadonly: () => import('lit-html').TemplateResult<1>;
|
|
14
|
+
/** Radio group with custom content. */
|
|
15
|
+
export declare const WithCustomContent: () => import('lit-html').TemplateResult<1>;
|
|
16
|
+
/** Radio group with horizontal layout. */
|
|
17
|
+
export declare const HorizontalLayout: () => import('lit-html').TemplateResult<1>;
|
|
18
|
+
//# sourceMappingURL=lukso-radio-group.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lukso-radio-group.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/lukso-radio-group/lukso-radio-group.stories.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAA;AAErD,OAAO,GAAG,CAAA;AACV,OAAO,gBAAgB,CAAA;AAEvB,+EAA+E;AAC/E,QAAA,MAAM,IAAI,EAAE,IAsDX,CAAA;AAED,eAAe,IAAI,CAAA;AAuBnB,eAAO,MAAM,mBAAmB,4CA6B/B,CAAA;AAED,wDAAwD;AACxD,eAAO,MAAM,iBAAiB,KAAoB,CAAA;AAKlD,wCAAwC;AACxC,eAAO,MAAM,cAAc,4CAwB1B,CAAA;AAED,8CAA8C;AAC9C,eAAO,MAAM,SAAS,4CA4BrB,CAAA;AAED,qDAAqD;AACrD,eAAO,MAAM,mBAAmB,4CA4B/B,CAAA;AAED,uCAAuC;AACvC,eAAO,MAAM,iBAAiB,4CAkC7B,CAAA;AAED,0CAA0C;AAC1C,eAAO,MAAM,gBAAgB,4CA0B5B,CAAA"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const shared_tailwindElement_index = require('../../index-
|
|
6
|
-
const property = require('../../property-
|
|
5
|
+
const shared_tailwindElement_index = require('../../index-BMFENeRI.cjs');
|
|
6
|
+
const property = require('../../property-DGVQMLCH.cjs');
|
|
7
7
|
const directive = require('../../directive-DT5Y-Nw0.cjs');
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E, b as T, a as TailwindElement, x } from '../../index-
|
|
2
|
-
import { n, t as t$1 } from '../../property-
|
|
1
|
+
import { E, b as T, a as TailwindElement, x } from '../../index-axQAcayx.js';
|
|
2
|
+
import { n, t as t$1 } from '../../property-CYbm8aZx.js';
|
|
3
3
|
import { i, t, e as e$1 } from '../../directive-BKuZRRPO.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const components_luksoProfile_index = require('../../index-
|
|
6
|
-
const shared_tailwindElement_index = require('../../index-
|
|
7
|
-
const property = require('../../property-
|
|
8
|
-
const state = require('../../state-
|
|
5
|
+
const components_luksoProfile_index = require('../../index-CUMvAhRx.cjs');
|
|
6
|
+
const shared_tailwindElement_index = require('../../index-BMFENeRI.cjs');
|
|
7
|
+
const property = require('../../property-DGVQMLCH.cjs');
|
|
8
|
+
const state = require('../../state-CCMDzTj3.cjs');
|
|
9
9
|
const index = require('../../index-CaJky2qL.cjs');
|
|
10
10
|
require('../lukso-dropdown/index.cjs');
|
|
11
11
|
require('../lukso-dropdown-option/index.cjs');
|
|
12
12
|
require('../lukso-icon/index.cjs');
|
|
13
13
|
require('../lukso-input/index.cjs');
|
|
14
14
|
require('../lukso-tag/index.cjs');
|
|
15
|
-
const components_luksoUsername_index = require('../../index-
|
|
15
|
+
const components_luksoUsername_index = require('../../index-D19a1K8E.cjs');
|
|
16
16
|
require('../../tailwind-config.cjs');
|
|
17
17
|
require('../../cn-CNdKneQ1.cjs');
|
|
18
18
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { m as makeBlockie } from '../../index-
|
|
2
|
-
import { T as TailwindStyledElement, x, E } from '../../index-
|
|
3
|
-
import { n, t } from '../../property-
|
|
4
|
-
import { r } from '../../state-
|
|
1
|
+
import { m as makeBlockie } from '../../index-Dsu77DGF.js';
|
|
2
|
+
import { T as TailwindStyledElement, x, E } from '../../index-axQAcayx.js';
|
|
3
|
+
import { n, t } from '../../property-CYbm8aZx.js';
|
|
4
|
+
import { r } from '../../state-hoCBDnpA.js';
|
|
5
5
|
import { c as ce } from '../../index-B9iart53.js';
|
|
6
6
|
import '../lukso-dropdown/index.js';
|
|
7
7
|
import '../lukso-dropdown-option/index.js';
|
|
8
8
|
import '../lukso-icon/index.js';
|
|
9
9
|
import '../lukso-input/index.js';
|
|
10
10
|
import '../lukso-tag/index.js';
|
|
11
|
-
import { s as sliceAddress } from '../../index
|
|
11
|
+
import { s as sliceAddress } from '../../index--44JsQ_1.js';
|
|
12
12
|
import '../../tailwind-config.js';
|
|
13
13
|
import '../../cn-Cu9aP49j.js';
|
|
14
14
|
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const shared_tailwindElement_index = require('../../index-
|
|
6
|
-
const property = require('../../property-
|
|
7
|
-
const state = require('../../state-
|
|
5
|
+
const shared_tailwindElement_index = require('../../index-BMFENeRI.cjs');
|
|
6
|
+
const property = require('../../property-DGVQMLCH.cjs');
|
|
7
|
+
const state = require('../../state-CCMDzTj3.cjs');
|
|
8
8
|
const index = require('../../index-CaJky2qL.cjs');
|
|
9
|
-
const components_luksoProfile_index = require('../../index-
|
|
9
|
+
const components_luksoProfile_index = require('../../index-CUMvAhRx.cjs');
|
|
10
10
|
require('../lukso-icon/index.cjs');
|
|
11
|
-
require('../../index-
|
|
11
|
+
require('../../index-D19a1K8E.cjs');
|
|
12
12
|
require('../lukso-dropdown/index.cjs');
|
|
13
13
|
require('../lukso-dropdown-option/index.cjs');
|
|
14
14
|
require('../lukso-sanitize/index.cjs');
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { T as TailwindStyledElement, E, x } from '../../index-
|
|
2
|
-
import { n, t } from '../../property-
|
|
3
|
-
import { r } from '../../state-
|
|
1
|
+
import { T as TailwindStyledElement, E, x } from '../../index-axQAcayx.js';
|
|
2
|
+
import { n, t } from '../../property-CYbm8aZx.js';
|
|
3
|
+
import { r } from '../../state-hoCBDnpA.js';
|
|
4
4
|
import { c as ce } from '../../index-B9iart53.js';
|
|
5
|
-
import { m as makeBlockie } from '../../index-
|
|
5
|
+
import { m as makeBlockie } from '../../index-Dsu77DGF.js';
|
|
6
6
|
import '../lukso-icon/index.js';
|
|
7
|
-
import '../../index
|
|
7
|
+
import '../../index--44JsQ_1.js';
|
|
8
8
|
import '../lukso-dropdown/index.js';
|
|
9
9
|
import '../lukso-dropdown-option/index.js';
|
|
10
10
|
import '../lukso-sanitize/index.js';
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const shared_tailwindElement_index = require('../../index-
|
|
6
|
-
const property = require('../../property-
|
|
5
|
+
const shared_tailwindElement_index = require('../../index-BMFENeRI.cjs');
|
|
6
|
+
const property = require('../../property-DGVQMLCH.cjs');
|
|
7
7
|
|
|
8
8
|
const style = ":host {\n display: inline-flex\n}";
|
|
9
9
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TailwindStyledElement, x } from '../../index-
|
|
2
|
-
import { n, t } from '../../property-
|
|
1
|
+
import { T as TailwindStyledElement, x } from '../../index-axQAcayx.js';
|
|
2
|
+
import { n, t } from '../../property-CYbm8aZx.js';
|
|
3
3
|
|
|
4
4
|
const style = ":host {\n display: inline-flex\n}";
|
|
5
5
|
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const shared_tailwindElement_index = require('../../index-
|
|
6
|
-
const property = require('../../property-
|
|
7
|
-
const styleMap = require('../../style-map-
|
|
5
|
+
const shared_tailwindElement_index = require('../../index-BMFENeRI.cjs');
|
|
6
|
+
const property = require('../../property-DGVQMLCH.cjs');
|
|
7
|
+
const styleMap = require('../../style-map-VlU1Vn2Q.cjs');
|
|
8
8
|
const index = require('../../index-CaJky2qL.cjs');
|
|
9
9
|
const uniqId = require('../../uniq-id-Cszs24DQ.cjs');
|
|
10
10
|
require('../lukso-sanitize/index.cjs');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as TailwindElement, x, E } from '../../index-
|
|
2
|
-
import { n, t } from '../../property-
|
|
3
|
-
import { o } from '../../style-map-
|
|
1
|
+
import { a as TailwindElement, x, E } from '../../index-axQAcayx.js';
|
|
2
|
+
import { n, t } from '../../property-CYbm8aZx.js';
|
|
3
|
+
import { o } from '../../style-map-Min8ajOg.js';
|
|
4
4
|
import { c as ce } from '../../index-B9iart53.js';
|
|
5
5
|
import { u as uniqId } from '../../uniq-id-CGUN-pJV.js';
|
|
6
6
|
import '../lukso-sanitize/index.js';
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const shared_tailwindElement_index = require('../../index-
|
|
6
|
-
const property = require('../../property-
|
|
5
|
+
const shared_tailwindElement_index = require('../../index-BMFENeRI.cjs');
|
|
6
|
+
const property = require('../../property-DGVQMLCH.cjs');
|
|
7
7
|
const index = require('../../index-CaJky2qL.cjs');
|
|
8
|
-
const index$1 = require('../../index-
|
|
8
|
+
const index$1 = require('../../index-D1v8ZgtZ.cjs');
|
|
9
9
|
|
|
10
10
|
const style = ":host {\n display: inline-flex\n}";
|
|
11
11
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { T as TailwindStyledElement, x } from '../../index-
|
|
2
|
-
import { n, t } from '../../property-
|
|
1
|
+
import { T as TailwindStyledElement, x } from '../../index-axQAcayx.js';
|
|
2
|
+
import { n, t } from '../../property-CYbm8aZx.js';
|
|
3
3
|
import { c as ce } from '../../index-B9iart53.js';
|
|
4
|
-
import { c as customStyleMap } from '../../index-
|
|
4
|
+
import { c as customStyleMap } from '../../index-DHAAIAHr.js';
|
|
5
5
|
|
|
6
6
|
const style = ":host {\n display: inline-flex\n}";
|
|
7
7
|
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const shared_tailwindElement_index = require('../../index-
|
|
6
|
-
const property = require('../../property-
|
|
7
|
-
const state = require('../../state-
|
|
5
|
+
const shared_tailwindElement_index = require('../../index-BMFENeRI.cjs');
|
|
6
|
+
const property = require('../../property-DGVQMLCH.cjs');
|
|
7
|
+
const state = require('../../state-CCMDzTj3.cjs');
|
|
8
8
|
const index = require('../../index-D0nCA-7X.cjs');
|
|
9
9
|
require('../lukso-icon/index.cjs');
|
|
10
10
|
require('../lukso-sanitize/index.cjs');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { T as TailwindStyledElement, x } from '../../index-
|
|
2
|
-
import { n, t } from '../../property-
|
|
3
|
-
import { r } from '../../state-
|
|
1
|
+
import { T as TailwindStyledElement, x } from '../../index-axQAcayx.js';
|
|
2
|
+
import { n, t } from '../../property-CYbm8aZx.js';
|
|
3
|
+
import { r } from '../../state-hoCBDnpA.js';
|
|
4
4
|
import { c as customClassMap } from '../../index-F8ll4iy2.js';
|
|
5
5
|
import '../lukso-icon/index.js';
|
|
6
6
|
import '../lukso-sanitize/index.js';
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const shared_tailwindElement_index = require('../../index-
|
|
6
|
-
const property = require('../../property-
|
|
5
|
+
const shared_tailwindElement_index = require('../../index-BMFENeRI.cjs');
|
|
6
|
+
const property = require('../../property-DGVQMLCH.cjs');
|
|
7
7
|
const directive = require('../../directive-DT5Y-Nw0.cjs');
|
|
8
|
-
const directiveHelpers = require('../../directive-helpers-
|
|
8
|
+
const directiveHelpers = require('../../directive-helpers-DArp4lXT.cjs');
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @license
|