@lukso/web-components 1.132.1 → 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 +55 -39
- package/dist/components/lukso-tooltip/index.d.ts +3 -3
- package/dist/components/lukso-tooltip/index.d.ts.map +1 -1
- package/dist/components/lukso-tooltip/index.js +55 -39
- package/dist/components/lukso-tooltip/lukso-tooltip.stories.d.ts +2 -2
- package/dist/components/lukso-tooltip/lukso-tooltip.stories.d.ts.map +1 -1
- 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-BbrBWb9B.js → directive-helpers-CAIm9TDG.js} +1 -1
- package/dist/{directive-helpers-D3mI9lsC.cjs → directive-helpers-DArp4lXT.cjs} +1 -1
- package/dist/{index-BKL0rD0t.js → index--44JsQ_1.js} +3 -3
- package/dist/index-BMFENeRI.cjs +50 -0
- package/dist/{index-CBUB36kH.cjs → index-CUMvAhRx.cjs} +2 -2
- package/dist/{index-B-jWYFR1.cjs → index-D19a1K8E.cjs} +3 -3
- package/dist/{index-BqVcbfZx.cjs → index-D1v8ZgtZ.cjs} +1 -1
- package/dist/{index-DvI1czUV.js → index-DHAAIAHr.js} +1 -1
- package/dist/{index-BwDu-qJI.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-BqHUZDET.js → property-CYbm8aZx.js} +1 -1
- package/dist/{property-BmOVhAsp.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-CfjNOKrO.cjs → state-CCMDzTj3.cjs} +1 -1
- package/dist/{state-C3Y3QGjX.js → state-hoCBDnpA.js} +1 -1
- package/dist/{style-map-DpzNuCXP.js → style-map-Min8ajOg.js} +1 -1
- package/dist/{style-map-DUOdo8Aw.cjs → style-map-VlU1Vn2Q.cjs} +1 -1
- package/dist/tailwind-config.cjs +2 -4
- package/dist/tailwind-config.d.ts +0 -1
- package/dist/tailwind-config.d.ts.map +1 -1
- package/dist/tailwind-config.js +3 -4
- package/package.json +11 -1
- package/tools/cn.cjs +1 -1
- package/tools/cn.js +1 -1
- package/tools/index.cjs +1 -1
- package/tools/index.js +1 -1
- package/tools/{tailwind-config-D8JGUH4g.js → tailwind-config-BItOO0YF.js} +3 -4
- package/tools/{tailwind-config-gyBGSi2Z.cjs → tailwind-config-bTE79eTG.cjs} +2 -4
- package/tools/tailwind-config.cjs +1 -2
- package/tools/tailwind-config.d.ts +0 -1
- package/tools/tailwind-config.d.ts.map +1 -1
- package/tools/tailwind-config.js +1 -1
- package/dist/index-BitOdrRJ.cjs +0 -50
- package/dist/index-DqnJ63Q8.js +0 -41
|
@@ -0,0 +1,284 @@
|
|
|
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
|
+
const index = require('../../index-CaJky2qL.cjs');
|
|
9
|
+
require('../../tailwind-config.cjs');
|
|
10
|
+
const cn = require('../../cn-CNdKneQ1.cjs');
|
|
11
|
+
|
|
12
|
+
var __defProp = Object.defineProperty;
|
|
13
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
14
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
15
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
16
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
17
|
+
if (decorator = decorators[i])
|
|
18
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
19
|
+
if (kind && result) __defProp(target, key, result);
|
|
20
|
+
return result;
|
|
21
|
+
};
|
|
22
|
+
exports.LuksoRadio = class LuksoRadio extends shared_tailwindElement_index.TailwindElement {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
this.name = "";
|
|
26
|
+
this.id = "";
|
|
27
|
+
this.value = "";
|
|
28
|
+
this.size = "medium";
|
|
29
|
+
this.error = "";
|
|
30
|
+
this.checked = false;
|
|
31
|
+
this.customClass = "";
|
|
32
|
+
this.isReadonly = false;
|
|
33
|
+
this.isDisabled = false;
|
|
34
|
+
this.hasFocus = false;
|
|
35
|
+
this.hasHighlight = false;
|
|
36
|
+
this.radioStyles = index.ce({
|
|
37
|
+
slots: {
|
|
38
|
+
container: "flex items-center gap-2 select-none outline-none",
|
|
39
|
+
radio: `
|
|
40
|
+
relative bg-neutral-100 justify-center items-center flex
|
|
41
|
+
border border-solid rounded-full border-neutral-35
|
|
42
|
+
outline-none transition transition-all duration-150 appearance-none shrink-0
|
|
43
|
+
`,
|
|
44
|
+
indicator: "rounded-full absolute appearance-none transition duration-300 ease-in",
|
|
45
|
+
content: "text-neutral-20 block",
|
|
46
|
+
errorText: "paragraph-inter-12-regular text-red-65 pt-2"
|
|
47
|
+
},
|
|
48
|
+
variants: {
|
|
49
|
+
size: {
|
|
50
|
+
medium: {
|
|
51
|
+
radio: "h-[40px] w-[40px]",
|
|
52
|
+
indicator: "w-[26px] h-[26px]",
|
|
53
|
+
content: "paragraph-inter-16-regular"
|
|
54
|
+
},
|
|
55
|
+
small: {
|
|
56
|
+
radio: "h-[32px] w-[32px]",
|
|
57
|
+
indicator: "w-[20px] h-[20px]",
|
|
58
|
+
content: "paragraph-inter-16-regular"
|
|
59
|
+
},
|
|
60
|
+
"x-small": {
|
|
61
|
+
radio: "h-[28px] w-[28px]",
|
|
62
|
+
indicator: "w-[17px] h-[17px]",
|
|
63
|
+
content: "paragraph-inter-12-semi-bold"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
hasError: {
|
|
67
|
+
true: {
|
|
68
|
+
radio: "border-red-65",
|
|
69
|
+
content: "text-red-65"
|
|
70
|
+
},
|
|
71
|
+
false: {
|
|
72
|
+
radio: "border-neutral-90"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
hasHighlight: {
|
|
76
|
+
true: {
|
|
77
|
+
radio: "border-neutral-35"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
isDisabled: {
|
|
81
|
+
true: {
|
|
82
|
+
radio: "border-neutral-90",
|
|
83
|
+
content: "text-neutral-90",
|
|
84
|
+
indicator: "bg-neutral-90",
|
|
85
|
+
container: "cursor-not-allowed"
|
|
86
|
+
},
|
|
87
|
+
false: {
|
|
88
|
+
indicator: "bg-green-54"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
isReadonly: {
|
|
92
|
+
true: {
|
|
93
|
+
container: "cursor-not-allowed"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
isChecked: {
|
|
97
|
+
true: {},
|
|
98
|
+
false: {}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
compoundVariants: [
|
|
102
|
+
{
|
|
103
|
+
hasHighlight: true,
|
|
104
|
+
hasError: true,
|
|
105
|
+
class: {
|
|
106
|
+
radio: "border-red-65"
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
isDisabled: true,
|
|
111
|
+
class: {
|
|
112
|
+
container: "cursor-not-allowed"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
// Expose the focus method for programmatic focusing
|
|
119
|
+
focus() {
|
|
120
|
+
const radioElement = this.renderRoot.querySelector('[role="radio"]');
|
|
121
|
+
if (radioElement instanceof HTMLElement) {
|
|
122
|
+
radioElement.focus();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
checkedIndicatorTemplate() {
|
|
126
|
+
const { indicator } = this.radioStyles({
|
|
127
|
+
size: this.size,
|
|
128
|
+
isDisabled: this.isDisabled,
|
|
129
|
+
isChecked: this.checked
|
|
130
|
+
});
|
|
131
|
+
return shared_tailwindElement_index.x`
|
|
132
|
+
<div class=${cn.cn(indicator(), this.checked ? "" : "hidden")}></div>
|
|
133
|
+
`;
|
|
134
|
+
}
|
|
135
|
+
radioTemplate() {
|
|
136
|
+
const { radio } = this.radioStyles({
|
|
137
|
+
size: this.size,
|
|
138
|
+
hasError: !!this.error,
|
|
139
|
+
hasHighlight: this.hasHighlight,
|
|
140
|
+
isDisabled: this.isDisabled
|
|
141
|
+
});
|
|
142
|
+
return shared_tailwindElement_index.x`
|
|
143
|
+
<div class=${cn.cn(radio(), this.customClass)}>
|
|
144
|
+
${this.checkedIndicatorTemplate()}
|
|
145
|
+
</div>
|
|
146
|
+
`;
|
|
147
|
+
}
|
|
148
|
+
errorTemplate() {
|
|
149
|
+
const { errorText } = this.radioStyles();
|
|
150
|
+
return shared_tailwindElement_index.x` <div class=${errorText()}>${this.error}</div> `;
|
|
151
|
+
}
|
|
152
|
+
contentTemplate() {
|
|
153
|
+
const { content } = this.radioStyles({
|
|
154
|
+
size: this.size,
|
|
155
|
+
hasError: !!this.error,
|
|
156
|
+
isDisabled: this.isDisabled
|
|
157
|
+
});
|
|
158
|
+
return shared_tailwindElement_index.x`
|
|
159
|
+
<div class=${content()}>
|
|
160
|
+
<slot></slot>
|
|
161
|
+
</div>
|
|
162
|
+
`;
|
|
163
|
+
}
|
|
164
|
+
render() {
|
|
165
|
+
const { container } = this.radioStyles({
|
|
166
|
+
isDisabled: this.isDisabled,
|
|
167
|
+
isReadonly: this.isReadonly
|
|
168
|
+
});
|
|
169
|
+
return shared_tailwindElement_index.x`
|
|
170
|
+
<div>
|
|
171
|
+
<div
|
|
172
|
+
class=${container()}
|
|
173
|
+
@mouseenter=${this.handleMouseOver}
|
|
174
|
+
@mouseleave=${this.handleMouseOut}
|
|
175
|
+
@click=${!this.isDisabled && !this.isReadonly ? this.handleClick : void 0}
|
|
176
|
+
@keydown=${this.handleKeydown}
|
|
177
|
+
@focus=${this.handleFocus}
|
|
178
|
+
@blur=${this.handleBlur}
|
|
179
|
+
aria-checked=${this.checked}
|
|
180
|
+
role="radio"
|
|
181
|
+
tabindex=${!this.isDisabled && !this.isReadonly ? "0" : "-1"}
|
|
182
|
+
aria-disabled=${this.isDisabled}
|
|
183
|
+
aria-readonly=${this.isReadonly}
|
|
184
|
+
aria-labelledby="${this.id || `radio-${this.value}`}"
|
|
185
|
+
id="${this.id || `radio-${this.value}`}"
|
|
186
|
+
part="radio"
|
|
187
|
+
>
|
|
188
|
+
${this.radioTemplate()} ${this.contentTemplate()}
|
|
189
|
+
</div>
|
|
190
|
+
${this.error ? this.errorTemplate() : shared_tailwindElement_index.E}
|
|
191
|
+
</div>
|
|
192
|
+
`;
|
|
193
|
+
}
|
|
194
|
+
handleKeydown(event) {
|
|
195
|
+
if (this.isDisabled || this.isReadonly) return;
|
|
196
|
+
if (event.key === " " || event.key === "Enter") {
|
|
197
|
+
event.preventDefault();
|
|
198
|
+
this.handleClick(event);
|
|
199
|
+
}
|
|
200
|
+
if ([
|
|
201
|
+
"ArrowUp",
|
|
202
|
+
"ArrowDown",
|
|
203
|
+
"ArrowLeft",
|
|
204
|
+
"ArrowRight",
|
|
205
|
+
"Home",
|
|
206
|
+
"End"
|
|
207
|
+
].includes(event.key)) {
|
|
208
|
+
const radioGroup = this.closest("lukso-radio-group");
|
|
209
|
+
if (radioGroup) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
handleFocus() {
|
|
215
|
+
this.hasFocus = true;
|
|
216
|
+
this.hasHighlight = true;
|
|
217
|
+
}
|
|
218
|
+
handleBlur() {
|
|
219
|
+
this.hasFocus = false;
|
|
220
|
+
this.hasHighlight = false;
|
|
221
|
+
}
|
|
222
|
+
async handleClick(event) {
|
|
223
|
+
if (this.isReadonly || this.isDisabled) return;
|
|
224
|
+
this.checked = true;
|
|
225
|
+
await this.updateComplete;
|
|
226
|
+
this.dispatchEvent(
|
|
227
|
+
new CustomEvent("on-change", {
|
|
228
|
+
detail: {
|
|
229
|
+
value: this.value,
|
|
230
|
+
checked: true,
|
|
231
|
+
event
|
|
232
|
+
},
|
|
233
|
+
bubbles: true,
|
|
234
|
+
composed: true
|
|
235
|
+
})
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
handleMouseOver() {
|
|
239
|
+
if (!this.isReadonly && !this.isDisabled) {
|
|
240
|
+
this.hasHighlight = true;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
handleMouseOut() {
|
|
244
|
+
if (!this.hasFocus) {
|
|
245
|
+
this.hasHighlight = false;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
__decorateClass([
|
|
250
|
+
property.n({ type: String })
|
|
251
|
+
], exports.LuksoRadio.prototype, "name", 2);
|
|
252
|
+
__decorateClass([
|
|
253
|
+
property.n({ type: String })
|
|
254
|
+
], exports.LuksoRadio.prototype, "id", 2);
|
|
255
|
+
__decorateClass([
|
|
256
|
+
property.n({ type: String })
|
|
257
|
+
], exports.LuksoRadio.prototype, "value", 2);
|
|
258
|
+
__decorateClass([
|
|
259
|
+
property.n({ type: String })
|
|
260
|
+
], exports.LuksoRadio.prototype, "size", 2);
|
|
261
|
+
__decorateClass([
|
|
262
|
+
property.n({ type: String })
|
|
263
|
+
], exports.LuksoRadio.prototype, "error", 2);
|
|
264
|
+
__decorateClass([
|
|
265
|
+
property.n({ type: Boolean })
|
|
266
|
+
], exports.LuksoRadio.prototype, "checked", 2);
|
|
267
|
+
__decorateClass([
|
|
268
|
+
property.n({ type: String, attribute: "custom-class" })
|
|
269
|
+
], exports.LuksoRadio.prototype, "customClass", 2);
|
|
270
|
+
__decorateClass([
|
|
271
|
+
property.n({ type: Boolean, attribute: "is-readonly" })
|
|
272
|
+
], exports.LuksoRadio.prototype, "isReadonly", 2);
|
|
273
|
+
__decorateClass([
|
|
274
|
+
property.n({ type: Boolean, attribute: "is-disabled" })
|
|
275
|
+
], exports.LuksoRadio.prototype, "isDisabled", 2);
|
|
276
|
+
__decorateClass([
|
|
277
|
+
state.r()
|
|
278
|
+
], exports.LuksoRadio.prototype, "hasFocus", 2);
|
|
279
|
+
__decorateClass([
|
|
280
|
+
state.r()
|
|
281
|
+
], exports.LuksoRadio.prototype, "hasHighlight", 2);
|
|
282
|
+
exports.LuksoRadio = __decorateClass([
|
|
283
|
+
property.t("lukso-radio")
|
|
284
|
+
], exports.LuksoRadio);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TailwindElement } from '../../shared/tailwind-element';
|
|
2
|
+
export type RadioSize = 'x-small' | 'small' | 'medium';
|
|
3
|
+
export declare class LuksoRadio extends TailwindElement {
|
|
4
|
+
name: string;
|
|
5
|
+
id: string;
|
|
6
|
+
value: string;
|
|
7
|
+
size: RadioSize;
|
|
8
|
+
error: string;
|
|
9
|
+
checked: boolean;
|
|
10
|
+
customClass: string;
|
|
11
|
+
isReadonly: boolean;
|
|
12
|
+
isDisabled: boolean;
|
|
13
|
+
private hasFocus;
|
|
14
|
+
private hasHighlight;
|
|
15
|
+
focus(): void;
|
|
16
|
+
private radioStyles;
|
|
17
|
+
checkedIndicatorTemplate(): unknown;
|
|
18
|
+
radioTemplate(): unknown;
|
|
19
|
+
errorTemplate(): import('lit-html').TemplateResult<1>;
|
|
20
|
+
contentTemplate(): import('lit-html').TemplateResult<1>;
|
|
21
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
22
|
+
private handleKeydown;
|
|
23
|
+
private handleFocus;
|
|
24
|
+
private handleBlur;
|
|
25
|
+
private handleClick;
|
|
26
|
+
private handleMouseOver;
|
|
27
|
+
private handleMouseOut;
|
|
28
|
+
}
|
|
29
|
+
declare global {
|
|
30
|
+
interface HTMLElementTagNameMap {
|
|
31
|
+
'lukso-radio': LuksoRadio;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/lukso-radio/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAG3D,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAA;AAEtD,qBACa,UAAW,SAAQ,eAAe;IAE7C,IAAI,SAAK;IAGT,EAAE,SAAK;IAGP,KAAK,SAAK;IAGV,IAAI,EAAE,SAAS,CAAW;IAG1B,KAAK,SAAK;IAGV,OAAO,UAAQ;IAGf,WAAW,SAAK;IAGhB,UAAU,UAAQ;IAGlB,UAAU,UAAQ;IAGlB,OAAO,CAAC,QAAQ,CAAQ;IAGxB,OAAO,CAAC,YAAY,CAAQ;IAGrB,KAAK;IAOZ,OAAO,CAAC,WAAW,CAiFjB;IAEF,wBAAwB,IAAI,OAAO;IAYnC,aAAa,IAAI,OAAO;IAexB,aAAa;IAKb,eAAe;IAcf,MAAM;IAkCN,OAAO,CAAC,aAAa;IAiCrB,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,UAAU;YAKJ,WAAW;IAqBzB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,cAAc;CAKvB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,UAAU,CAAA;KAC1B;CACF"}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { a as TailwindElement, x, E } from '../../index-axQAcayx.js';
|
|
2
|
+
import { n, t } from '../../property-CYbm8aZx.js';
|
|
3
|
+
import { r } from '../../state-hoCBDnpA.js';
|
|
4
|
+
import { c as ce } from '../../index-B9iart53.js';
|
|
5
|
+
import '../../tailwind-config.js';
|
|
6
|
+
import { c as cn } from '../../cn-Cu9aP49j.js';
|
|
7
|
+
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
11
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
12
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
13
|
+
if (decorator = decorators[i])
|
|
14
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
15
|
+
if (kind && result) __defProp(target, key, result);
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
18
|
+
let LuksoRadio = class extends TailwindElement {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.name = "";
|
|
22
|
+
this.id = "";
|
|
23
|
+
this.value = "";
|
|
24
|
+
this.size = "medium";
|
|
25
|
+
this.error = "";
|
|
26
|
+
this.checked = false;
|
|
27
|
+
this.customClass = "";
|
|
28
|
+
this.isReadonly = false;
|
|
29
|
+
this.isDisabled = false;
|
|
30
|
+
this.hasFocus = false;
|
|
31
|
+
this.hasHighlight = false;
|
|
32
|
+
this.radioStyles = ce({
|
|
33
|
+
slots: {
|
|
34
|
+
container: "flex items-center gap-2 select-none outline-none",
|
|
35
|
+
radio: `
|
|
36
|
+
relative bg-neutral-100 justify-center items-center flex
|
|
37
|
+
border border-solid rounded-full border-neutral-35
|
|
38
|
+
outline-none transition transition-all duration-150 appearance-none shrink-0
|
|
39
|
+
`,
|
|
40
|
+
indicator: "rounded-full absolute appearance-none transition duration-300 ease-in",
|
|
41
|
+
content: "text-neutral-20 block",
|
|
42
|
+
errorText: "paragraph-inter-12-regular text-red-65 pt-2"
|
|
43
|
+
},
|
|
44
|
+
variants: {
|
|
45
|
+
size: {
|
|
46
|
+
medium: {
|
|
47
|
+
radio: "h-[40px] w-[40px]",
|
|
48
|
+
indicator: "w-[26px] h-[26px]",
|
|
49
|
+
content: "paragraph-inter-16-regular"
|
|
50
|
+
},
|
|
51
|
+
small: {
|
|
52
|
+
radio: "h-[32px] w-[32px]",
|
|
53
|
+
indicator: "w-[20px] h-[20px]",
|
|
54
|
+
content: "paragraph-inter-16-regular"
|
|
55
|
+
},
|
|
56
|
+
"x-small": {
|
|
57
|
+
radio: "h-[28px] w-[28px]",
|
|
58
|
+
indicator: "w-[17px] h-[17px]",
|
|
59
|
+
content: "paragraph-inter-12-semi-bold"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
hasError: {
|
|
63
|
+
true: {
|
|
64
|
+
radio: "border-red-65",
|
|
65
|
+
content: "text-red-65"
|
|
66
|
+
},
|
|
67
|
+
false: {
|
|
68
|
+
radio: "border-neutral-90"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
hasHighlight: {
|
|
72
|
+
true: {
|
|
73
|
+
radio: "border-neutral-35"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
isDisabled: {
|
|
77
|
+
true: {
|
|
78
|
+
radio: "border-neutral-90",
|
|
79
|
+
content: "text-neutral-90",
|
|
80
|
+
indicator: "bg-neutral-90",
|
|
81
|
+
container: "cursor-not-allowed"
|
|
82
|
+
},
|
|
83
|
+
false: {
|
|
84
|
+
indicator: "bg-green-54"
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
isReadonly: {
|
|
88
|
+
true: {
|
|
89
|
+
container: "cursor-not-allowed"
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
isChecked: {
|
|
93
|
+
true: {},
|
|
94
|
+
false: {}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
compoundVariants: [
|
|
98
|
+
{
|
|
99
|
+
hasHighlight: true,
|
|
100
|
+
hasError: true,
|
|
101
|
+
class: {
|
|
102
|
+
radio: "border-red-65"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
isDisabled: true,
|
|
107
|
+
class: {
|
|
108
|
+
container: "cursor-not-allowed"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
// Expose the focus method for programmatic focusing
|
|
115
|
+
focus() {
|
|
116
|
+
const radioElement = this.renderRoot.querySelector('[role="radio"]');
|
|
117
|
+
if (radioElement instanceof HTMLElement) {
|
|
118
|
+
radioElement.focus();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
checkedIndicatorTemplate() {
|
|
122
|
+
const { indicator } = this.radioStyles({
|
|
123
|
+
size: this.size,
|
|
124
|
+
isDisabled: this.isDisabled,
|
|
125
|
+
isChecked: this.checked
|
|
126
|
+
});
|
|
127
|
+
return x`
|
|
128
|
+
<div class=${cn(indicator(), this.checked ? "" : "hidden")}></div>
|
|
129
|
+
`;
|
|
130
|
+
}
|
|
131
|
+
radioTemplate() {
|
|
132
|
+
const { radio } = this.radioStyles({
|
|
133
|
+
size: this.size,
|
|
134
|
+
hasError: !!this.error,
|
|
135
|
+
hasHighlight: this.hasHighlight,
|
|
136
|
+
isDisabled: this.isDisabled
|
|
137
|
+
});
|
|
138
|
+
return x`
|
|
139
|
+
<div class=${cn(radio(), this.customClass)}>
|
|
140
|
+
${this.checkedIndicatorTemplate()}
|
|
141
|
+
</div>
|
|
142
|
+
`;
|
|
143
|
+
}
|
|
144
|
+
errorTemplate() {
|
|
145
|
+
const { errorText } = this.radioStyles();
|
|
146
|
+
return x` <div class=${errorText()}>${this.error}</div> `;
|
|
147
|
+
}
|
|
148
|
+
contentTemplate() {
|
|
149
|
+
const { content } = this.radioStyles({
|
|
150
|
+
size: this.size,
|
|
151
|
+
hasError: !!this.error,
|
|
152
|
+
isDisabled: this.isDisabled
|
|
153
|
+
});
|
|
154
|
+
return x`
|
|
155
|
+
<div class=${content()}>
|
|
156
|
+
<slot></slot>
|
|
157
|
+
</div>
|
|
158
|
+
`;
|
|
159
|
+
}
|
|
160
|
+
render() {
|
|
161
|
+
const { container } = this.radioStyles({
|
|
162
|
+
isDisabled: this.isDisabled,
|
|
163
|
+
isReadonly: this.isReadonly
|
|
164
|
+
});
|
|
165
|
+
return x`
|
|
166
|
+
<div>
|
|
167
|
+
<div
|
|
168
|
+
class=${container()}
|
|
169
|
+
@mouseenter=${this.handleMouseOver}
|
|
170
|
+
@mouseleave=${this.handleMouseOut}
|
|
171
|
+
@click=${!this.isDisabled && !this.isReadonly ? this.handleClick : void 0}
|
|
172
|
+
@keydown=${this.handleKeydown}
|
|
173
|
+
@focus=${this.handleFocus}
|
|
174
|
+
@blur=${this.handleBlur}
|
|
175
|
+
aria-checked=${this.checked}
|
|
176
|
+
role="radio"
|
|
177
|
+
tabindex=${!this.isDisabled && !this.isReadonly ? "0" : "-1"}
|
|
178
|
+
aria-disabled=${this.isDisabled}
|
|
179
|
+
aria-readonly=${this.isReadonly}
|
|
180
|
+
aria-labelledby="${this.id || `radio-${this.value}`}"
|
|
181
|
+
id="${this.id || `radio-${this.value}`}"
|
|
182
|
+
part="radio"
|
|
183
|
+
>
|
|
184
|
+
${this.radioTemplate()} ${this.contentTemplate()}
|
|
185
|
+
</div>
|
|
186
|
+
${this.error ? this.errorTemplate() : E}
|
|
187
|
+
</div>
|
|
188
|
+
`;
|
|
189
|
+
}
|
|
190
|
+
handleKeydown(event) {
|
|
191
|
+
if (this.isDisabled || this.isReadonly) return;
|
|
192
|
+
if (event.key === " " || event.key === "Enter") {
|
|
193
|
+
event.preventDefault();
|
|
194
|
+
this.handleClick(event);
|
|
195
|
+
}
|
|
196
|
+
if ([
|
|
197
|
+
"ArrowUp",
|
|
198
|
+
"ArrowDown",
|
|
199
|
+
"ArrowLeft",
|
|
200
|
+
"ArrowRight",
|
|
201
|
+
"Home",
|
|
202
|
+
"End"
|
|
203
|
+
].includes(event.key)) {
|
|
204
|
+
const radioGroup = this.closest("lukso-radio-group");
|
|
205
|
+
if (radioGroup) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
handleFocus() {
|
|
211
|
+
this.hasFocus = true;
|
|
212
|
+
this.hasHighlight = true;
|
|
213
|
+
}
|
|
214
|
+
handleBlur() {
|
|
215
|
+
this.hasFocus = false;
|
|
216
|
+
this.hasHighlight = false;
|
|
217
|
+
}
|
|
218
|
+
async handleClick(event) {
|
|
219
|
+
if (this.isReadonly || this.isDisabled) return;
|
|
220
|
+
this.checked = true;
|
|
221
|
+
await this.updateComplete;
|
|
222
|
+
this.dispatchEvent(
|
|
223
|
+
new CustomEvent("on-change", {
|
|
224
|
+
detail: {
|
|
225
|
+
value: this.value,
|
|
226
|
+
checked: true,
|
|
227
|
+
event
|
|
228
|
+
},
|
|
229
|
+
bubbles: true,
|
|
230
|
+
composed: true
|
|
231
|
+
})
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
handleMouseOver() {
|
|
235
|
+
if (!this.isReadonly && !this.isDisabled) {
|
|
236
|
+
this.hasHighlight = true;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
handleMouseOut() {
|
|
240
|
+
if (!this.hasFocus) {
|
|
241
|
+
this.hasHighlight = false;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
__decorateClass([
|
|
246
|
+
n({ type: String })
|
|
247
|
+
], LuksoRadio.prototype, "name", 2);
|
|
248
|
+
__decorateClass([
|
|
249
|
+
n({ type: String })
|
|
250
|
+
], LuksoRadio.prototype, "id", 2);
|
|
251
|
+
__decorateClass([
|
|
252
|
+
n({ type: String })
|
|
253
|
+
], LuksoRadio.prototype, "value", 2);
|
|
254
|
+
__decorateClass([
|
|
255
|
+
n({ type: String })
|
|
256
|
+
], LuksoRadio.prototype, "size", 2);
|
|
257
|
+
__decorateClass([
|
|
258
|
+
n({ type: String })
|
|
259
|
+
], LuksoRadio.prototype, "error", 2);
|
|
260
|
+
__decorateClass([
|
|
261
|
+
n({ type: Boolean })
|
|
262
|
+
], LuksoRadio.prototype, "checked", 2);
|
|
263
|
+
__decorateClass([
|
|
264
|
+
n({ type: String, attribute: "custom-class" })
|
|
265
|
+
], LuksoRadio.prototype, "customClass", 2);
|
|
266
|
+
__decorateClass([
|
|
267
|
+
n({ type: Boolean, attribute: "is-readonly" })
|
|
268
|
+
], LuksoRadio.prototype, "isReadonly", 2);
|
|
269
|
+
__decorateClass([
|
|
270
|
+
n({ type: Boolean, attribute: "is-disabled" })
|
|
271
|
+
], LuksoRadio.prototype, "isDisabled", 2);
|
|
272
|
+
__decorateClass([
|
|
273
|
+
r()
|
|
274
|
+
], LuksoRadio.prototype, "hasFocus", 2);
|
|
275
|
+
__decorateClass([
|
|
276
|
+
r()
|
|
277
|
+
], LuksoRadio.prototype, "hasHighlight", 2);
|
|
278
|
+
LuksoRadio = __decorateClass([
|
|
279
|
+
t("lukso-radio")
|
|
280
|
+
], LuksoRadio);
|
|
281
|
+
|
|
282
|
+
export { LuksoRadio };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Meta } from '@storybook/web-components';
|
|
2
|
+
/** Documentation and examples of `lukso-radio` component. */
|
|
3
|
+
declare const meta: Meta;
|
|
4
|
+
export default meta;
|
|
5
|
+
export declare const DefaultInput: any;
|
|
6
|
+
/** Example of checked radio. */
|
|
7
|
+
export declare const CheckedInput: any;
|
|
8
|
+
/** Example of disabled radio. */
|
|
9
|
+
export declare const DisabledInput: any;
|
|
10
|
+
/** Example of readonly radio. */
|
|
11
|
+
export declare const ReadonlyInput: any;
|
|
12
|
+
/** Example of radio with error. */
|
|
13
|
+
export declare const ErrorInput: any;
|
|
14
|
+
/** Example of small size radio. */
|
|
15
|
+
export declare const SmallSize: any;
|
|
16
|
+
/** Example of x-small size radio. */
|
|
17
|
+
export declare const XSmallSize: any;
|
|
18
|
+
/** Example of different sizes. */
|
|
19
|
+
export declare const Sizes: () => import('lit-html').TemplateResult<1>;
|
|
20
|
+
/** Example of radio with profiles. */
|
|
21
|
+
export declare const WithProfiles: () => import('lit-html').TemplateResult<1>;
|
|
22
|
+
/** Example of radio with custom content. */
|
|
23
|
+
export declare const WithCustomContent: () => import('lit-html').TemplateResult<1>;
|
|
24
|
+
//# sourceMappingURL=lukso-radio.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lukso-radio.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/lukso-radio/lukso-radio.stories.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAA;AAErD,OAAO,SAAS,CAAA;AAEhB,+DAA+D;AAC/D,QAAA,MAAM,IAAI,EAAE,IAqHX,CAAA;AAED,eAAe,IAAI,CAAA;AAqCnB,eAAO,MAAM,YAAY,KAAoB,CAAA;AAK7C,iCAAiC;AACjC,eAAO,MAAM,YAAY,KAAoB,CAAA;AAK7C,kCAAkC;AAClC,eAAO,MAAM,aAAa,KAAoB,CAAA;AAK9C,kCAAkC;AAClC,eAAO,MAAM,aAAa,KAAoB,CAAA;AAK9C,oCAAoC;AACpC,eAAO,MAAM,UAAU,KAAoB,CAAA;AAK3C,oCAAoC;AACpC,eAAO,MAAM,SAAS,KAAoB,CAAA;AAM1C,sCAAsC;AACtC,eAAO,MAAM,UAAU,KAAoB,CAAA;AAM3C,mCAAmC;AACnC,eAAO,MAAM,KAAK,4CAuCjB,CAAA;AAED,uCAAuC;AACvC,eAAO,MAAM,YAAY,4CAoCxB,CAAA;AAED,6CAA6C;AAC7C,eAAO,MAAM,iBAAiB,4CAwC7B,CAAA"}
|