@vialiq/web-components 0.3.0 → 0.5.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/README.md +575 -2
- package/button/vi-button.js +1 -1
- package/checkbox/index.d.ts +3 -0
- package/checkbox/index.d.ts.map +1 -0
- package/checkbox/index.js +1 -0
- package/checkbox/vi-checkbox.d.ts +68 -0
- package/checkbox/vi-checkbox.d.ts.map +1 -0
- package/checkbox/vi-checkbox.js +637 -0
- package/index.d.ts +6 -1
- package/index.js +2 -0
- package/input/index.d.ts +1 -1
- package/input/index.d.ts.map +1 -1
- package/input/vi-input.d.ts +7 -0
- package/input/vi-input.d.ts.map +1 -1
- package/input/vi-input.js +52 -7
- package/package.json +23 -3
- package/radio/index.d.ts +5 -0
- package/radio/index.d.ts.map +1 -0
- package/radio/index.js +2 -0
- package/radio/vi-radio-group.d.ts +72 -0
- package/radio/vi-radio-group.d.ts.map +1 -0
- package/radio/vi-radio-group.js +761 -0
- package/radio/vi-radio.d.ts +47 -0
- package/radio/vi-radio.d.ts.map +1 -0
- package/radio/vi-radio.js +538 -0
- package/tooltip/index.d.ts +3 -0
- package/tooltip/index.d.ts.map +1 -0
- package/tooltip/index.js +1 -0
- package/tooltip/vi-tooltip.d.ts +84 -0
- package/tooltip/vi-tooltip.d.ts.map +1 -0
- package/tooltip/vi-tooltip.js +908 -0
|
@@ -0,0 +1,761 @@
|
|
|
1
|
+
import { unsafeCSS, css, html } from 'lit';
|
|
2
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
+
import { V as ValidityMixin } from '../validity-mixin-BjmXwgWk.js';
|
|
4
|
+
import { V as ViElement } from '../vi-element-C6GfDPs3.js';
|
|
5
|
+
|
|
6
|
+
const radioGroupStyles = "@charset \"UTF-8\";@layer reset,components,utilities;@layer components{.radio-group{border:none;margin:0;padding:0;display:flex;flex-direction:column;gap:var(--vi-radio-group-spacing-field-gap, var(--vi-spacing-xs, 8px));width:100%}.radio-group-legend{font-family:var(--vi-font-family-base, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif);font-size:var(--vi-radio-group-label-font-size, var(--vi-font-size-base, 16px));font-weight:var(--vi-font-weight-semibold, 600);color:var(--vi-radio-group-label-color, var(--vi-color-foreground, #111827));padding:0;margin:0;margin-block-end:var(--vi-radio-group-legend-margin-bottom, var(--vi-spacing-xs, 8px))}.radio-group-items{display:flex;gap:var(--vi-radio-group-gap, 8px)}.radio-group-items[orientation=vertical]{flex-direction:column}.radio-group-items[orientation=horizontal]{flex-direction:row;flex-wrap:wrap;gap:var(--vi-radio-group-gap-horizontal, 24px)}.radio-group-helper{display:block;font-family:var(--vi-font-family-base, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif);font-size:var(--vi-radio-group-helper-font-size, var(--vi-font-size-xs, 12px));color:var(--vi-radio-group-helper-color, var(--vi-text-disabled, #9e9e9e))}.radio-group-validation{display:block;font-family:var(--vi-font-family-base, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif);font-size:var(--vi-radio-group-validation-font-size, var(--vi-font-size-xs, 12px));color:var(--vi-radio-group-validation-color, var(--vi-text-disabled, #9e9e9e));margin-block-start:var(--vi-radio-group-validation-margin-top, var(--vi-spacing-xs, 8px))}.radio-group-validation.radio-group-validation--invalid{color:var(--vi-radio-group-error-color, var(--vi-color-error, #ef4444))}.radio-group-validation.radio-group-validation--valid{color:var(--vi-radio-group-success-color, var(--vi-color-success, #489167))}.radio-wrapper{display:inline-flex;align-items:center;gap:var(--vi-radio-label-gap, 8px);cursor:pointer;font-family:var(--vi-font-family-base, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif);font-size:var(--vi-radio-label-font-size, var(--vi-font-size-base, 16px));line-height:var(--vi-line-height-normal, 1.5);color:var(--vi-radio-label-color, var(--vi-color-foreground, #111827));position:relative;-webkit-user-select:none;user-select:none}.radio-input{position:absolute!important;clip-path:inset(50%)!important;overflow:hidden!important;width:1px!important;height:1px!important;margin:-1px!important;padding:0!important;border:0!important;white-space:nowrap!important}.radio-circle{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;width:var(--vi-radio-size, 18px);height:var(--vi-radio-size, 18px);border:var(--vi-border-width-base, 2px) solid var(--vi-radio-border-color, var(--vi-border-04, #bdbdbd));border-radius:50%;background-color:var(--vi-radio-background-color, var(--vi-color-background, #ffffff));transition:border-color .15s ease,box-shadow .15s ease;flex-shrink:0}.radio-dot{box-sizing:border-box;width:var(--vi-radio-dot-size, 8px);height:var(--vi-radio-dot-size, 8px);border-radius:50%;background-color:var(--vi-radio-dot-color, var(--vi-color-primary, #3676d0));transform:scale(0);opacity:0;transition:transform .15s cubic-bezier(.4,0,.2,1),opacity .15s ease}.radio-input:checked+.radio-circle{border-color:var(--vi-radio-border-color-checked, var(--vi-color-primary, #3676d0))}.radio-input:checked+.radio-circle .radio-dot{transform:scale(1);opacity:1}.radio-input:focus-visible+.radio-circle{outline:var(--vi-border-width-base, 2px) solid var(--vi-radio-focus-ring-color, var(--vi-color-primary, #3676d0));outline-offset:2px;box-shadow:0 0 0 3px var(--vi-radio-focus-ring-glow, var(--vi-color-blue-200, #cee6ff))}.radio-wrapper:hover:not(.radio-wrapper--disabled) .radio-circle{border-color:var(--vi-radio-border-color-hover, var(--vi-border-inverse-03, #757575))}.radio-wrapper:hover:not(.radio-wrapper--disabled) .radio-input:checked+.radio-circle{border-color:var(--vi-radio-border-color-checked-hover, var(--vi-color-primary, #3676d0))}.radio-wrapper--disabled{cursor:not-allowed;opacity:var(--vi-radio-disabled-opacity, .5)}.radio-wrapper--disabled .radio-circle{background-color:var(--vi-layer-disabled, #f3f4f6);border-color:var(--vi-border-02, #eeeeee)}.radio-wrapper--disabled .radio-dot{background-color:var(--vi-text-disabled, #9e9e9e)}@media(prefers-reduced-motion:reduce){.radio-circle,.radio-dot{transition:none}}}:host{display:block;outline:none}:host([disabled]){cursor:not-allowed;pointer-events:none}:host([status=invalid]){--vi-radio-group-label-color: var(--vi-color-error, #ef4444)}::slotted(*){font-family:inherit;font-size:inherit;color:inherit}:host([size=xs]){--vi-radio-group-label-font-size: var(--vi-font-size-xs, 12px);--vi-radio-group-legend-margin-bottom: 4px}:host([size=sm]){--vi-radio-group-label-font-size: var(--vi-font-size-sm, 14px);--vi-radio-group-legend-margin-bottom: 6px}:host([size=lg]){--vi-radio-group-label-font-size: var(--vi-font-size-lg, 18px);--vi-radio-group-legend-margin-bottom: 10px}";
|
|
7
|
+
|
|
8
|
+
function applyDecs2203RFactory() {
|
|
9
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
10
|
+
return function addInitializer(initializer) {
|
|
11
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
12
|
+
assertCallable(initializer, "An initializer");
|
|
13
|
+
initializers.push(initializer);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
17
|
+
var kindStr;
|
|
18
|
+
switch(kind){
|
|
19
|
+
case 1:
|
|
20
|
+
kindStr = "accessor";
|
|
21
|
+
break;
|
|
22
|
+
case 2:
|
|
23
|
+
kindStr = "method";
|
|
24
|
+
break;
|
|
25
|
+
case 3:
|
|
26
|
+
kindStr = "getter";
|
|
27
|
+
break;
|
|
28
|
+
case 4:
|
|
29
|
+
kindStr = "setter";
|
|
30
|
+
break;
|
|
31
|
+
default:
|
|
32
|
+
kindStr = "field";
|
|
33
|
+
}
|
|
34
|
+
var ctx = {
|
|
35
|
+
kind: kindStr,
|
|
36
|
+
name: isPrivate ? "#" + name : name,
|
|
37
|
+
static: isStatic,
|
|
38
|
+
private: isPrivate,
|
|
39
|
+
metadata: metadata
|
|
40
|
+
};
|
|
41
|
+
var decoratorFinishedRef = {
|
|
42
|
+
v: false
|
|
43
|
+
};
|
|
44
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
45
|
+
var get, set;
|
|
46
|
+
if (kind === 0) {
|
|
47
|
+
if (isPrivate) {
|
|
48
|
+
get = desc.get;
|
|
49
|
+
set = desc.set;
|
|
50
|
+
} else {
|
|
51
|
+
get = function() {
|
|
52
|
+
return this[name];
|
|
53
|
+
};
|
|
54
|
+
set = function(v) {
|
|
55
|
+
this[name] = v;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
} else if (kind === 2) {
|
|
59
|
+
get = function() {
|
|
60
|
+
return desc.value;
|
|
61
|
+
};
|
|
62
|
+
} else {
|
|
63
|
+
if (kind === 1 || kind === 3) {
|
|
64
|
+
get = function() {
|
|
65
|
+
return desc.get.call(this);
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (kind === 1 || kind === 4) {
|
|
69
|
+
set = function(v) {
|
|
70
|
+
desc.set.call(this, v);
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
ctx.access = get && set ? {
|
|
75
|
+
get: get,
|
|
76
|
+
set: set
|
|
77
|
+
} : get ? {
|
|
78
|
+
get: get
|
|
79
|
+
} : {
|
|
80
|
+
set: set
|
|
81
|
+
};
|
|
82
|
+
try {
|
|
83
|
+
return dec(value, ctx);
|
|
84
|
+
} finally{
|
|
85
|
+
decoratorFinishedRef.v = true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
89
|
+
if (decoratorFinishedRef.v) {
|
|
90
|
+
throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function assertCallable(fn, hint) {
|
|
94
|
+
if (typeof fn !== "function") {
|
|
95
|
+
throw new TypeError(hint + " must be a function");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function assertValidReturnValue(kind, value) {
|
|
99
|
+
var type = typeof value;
|
|
100
|
+
if (kind === 1) {
|
|
101
|
+
if (type !== "object" || value === null) {
|
|
102
|
+
throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
103
|
+
}
|
|
104
|
+
if (value.get !== undefined) {
|
|
105
|
+
assertCallable(value.get, "accessor.get");
|
|
106
|
+
}
|
|
107
|
+
if (value.set !== undefined) {
|
|
108
|
+
assertCallable(value.set, "accessor.set");
|
|
109
|
+
}
|
|
110
|
+
if (value.init !== undefined) {
|
|
111
|
+
assertCallable(value.init, "accessor.init");
|
|
112
|
+
}
|
|
113
|
+
} else if (type !== "function") {
|
|
114
|
+
var hint;
|
|
115
|
+
if (kind === 0) {
|
|
116
|
+
hint = "field";
|
|
117
|
+
} else if (kind === 10) {
|
|
118
|
+
hint = "class";
|
|
119
|
+
} else {
|
|
120
|
+
hint = "method";
|
|
121
|
+
}
|
|
122
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
126
|
+
var decs = decInfo[0];
|
|
127
|
+
var desc, init, value;
|
|
128
|
+
if (isPrivate) {
|
|
129
|
+
if (kind === 0 || kind === 1) {
|
|
130
|
+
desc = {
|
|
131
|
+
get: decInfo[3],
|
|
132
|
+
set: decInfo[4]
|
|
133
|
+
};
|
|
134
|
+
} else if (kind === 3) {
|
|
135
|
+
desc = {
|
|
136
|
+
get: decInfo[3]
|
|
137
|
+
};
|
|
138
|
+
} else if (kind === 4) {
|
|
139
|
+
desc = {
|
|
140
|
+
set: decInfo[3]
|
|
141
|
+
};
|
|
142
|
+
} else {
|
|
143
|
+
desc = {
|
|
144
|
+
value: decInfo[3]
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
} else if (kind !== 0) {
|
|
148
|
+
desc = Object.getOwnPropertyDescriptor(base, name);
|
|
149
|
+
}
|
|
150
|
+
if (kind === 1) {
|
|
151
|
+
value = {
|
|
152
|
+
get: desc.get,
|
|
153
|
+
set: desc.set
|
|
154
|
+
};
|
|
155
|
+
} else if (kind === 2) {
|
|
156
|
+
value = desc.value;
|
|
157
|
+
} else if (kind === 3) {
|
|
158
|
+
value = desc.get;
|
|
159
|
+
} else if (kind === 4) {
|
|
160
|
+
value = desc.set;
|
|
161
|
+
}
|
|
162
|
+
var newValue, get, set;
|
|
163
|
+
if (typeof decs === "function") {
|
|
164
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
165
|
+
if (newValue !== void 0) {
|
|
166
|
+
assertValidReturnValue(kind, newValue);
|
|
167
|
+
if (kind === 0) {
|
|
168
|
+
init = newValue;
|
|
169
|
+
} else if (kind === 1) {
|
|
170
|
+
init = newValue.init;
|
|
171
|
+
get = newValue.get || value.get;
|
|
172
|
+
set = newValue.set || value.set;
|
|
173
|
+
value = {
|
|
174
|
+
get: get,
|
|
175
|
+
set: set
|
|
176
|
+
};
|
|
177
|
+
} else {
|
|
178
|
+
value = newValue;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
for(var i = decs.length - 1; i >= 0; i--){
|
|
183
|
+
var dec = decs[i];
|
|
184
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
185
|
+
if (newValue !== void 0) {
|
|
186
|
+
assertValidReturnValue(kind, newValue);
|
|
187
|
+
var newInit;
|
|
188
|
+
if (kind === 0) {
|
|
189
|
+
newInit = newValue;
|
|
190
|
+
} else if (kind === 1) {
|
|
191
|
+
newInit = newValue.init;
|
|
192
|
+
get = newValue.get || value.get;
|
|
193
|
+
set = newValue.set || value.set;
|
|
194
|
+
value = {
|
|
195
|
+
get: get,
|
|
196
|
+
set: set
|
|
197
|
+
};
|
|
198
|
+
} else {
|
|
199
|
+
value = newValue;
|
|
200
|
+
}
|
|
201
|
+
if (newInit !== void 0) {
|
|
202
|
+
if (init === void 0) {
|
|
203
|
+
init = newInit;
|
|
204
|
+
} else if (typeof init === "function") {
|
|
205
|
+
init = [
|
|
206
|
+
init,
|
|
207
|
+
newInit
|
|
208
|
+
];
|
|
209
|
+
} else {
|
|
210
|
+
init.push(newInit);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (kind === 0 || kind === 1) {
|
|
217
|
+
if (init === void 0) {
|
|
218
|
+
init = function(instance, init) {
|
|
219
|
+
return init;
|
|
220
|
+
};
|
|
221
|
+
} else if (typeof init !== "function") {
|
|
222
|
+
var ownInitializers = init;
|
|
223
|
+
init = function(instance, init) {
|
|
224
|
+
var value = init;
|
|
225
|
+
for(var i = 0; i < ownInitializers.length; i++){
|
|
226
|
+
value = ownInitializers[i].call(instance, value);
|
|
227
|
+
}
|
|
228
|
+
return value;
|
|
229
|
+
};
|
|
230
|
+
} else {
|
|
231
|
+
var originalInitializer = init;
|
|
232
|
+
init = function(instance, init) {
|
|
233
|
+
return originalInitializer.call(instance, init);
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
ret.push(init);
|
|
237
|
+
}
|
|
238
|
+
if (kind !== 0) {
|
|
239
|
+
if (kind === 1) {
|
|
240
|
+
desc.get = value.get;
|
|
241
|
+
desc.set = value.set;
|
|
242
|
+
} else if (kind === 2) {
|
|
243
|
+
desc.value = value;
|
|
244
|
+
} else if (kind === 3) {
|
|
245
|
+
desc.get = value;
|
|
246
|
+
} else if (kind === 4) {
|
|
247
|
+
desc.set = value;
|
|
248
|
+
}
|
|
249
|
+
if (isPrivate) {
|
|
250
|
+
if (kind === 1) {
|
|
251
|
+
ret.push(function(instance, args) {
|
|
252
|
+
return value.get.call(instance, args);
|
|
253
|
+
});
|
|
254
|
+
ret.push(function(instance, args) {
|
|
255
|
+
return value.set.call(instance, args);
|
|
256
|
+
});
|
|
257
|
+
} else if (kind === 2) {
|
|
258
|
+
ret.push(value);
|
|
259
|
+
} else {
|
|
260
|
+
ret.push(function(instance, args) {
|
|
261
|
+
return value.call(instance, args);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
} else {
|
|
265
|
+
Object.defineProperty(base, name, desc);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
270
|
+
var ret = [];
|
|
271
|
+
var protoInitializers;
|
|
272
|
+
var staticInitializers;
|
|
273
|
+
var existingProtoNonFields = new Map();
|
|
274
|
+
var existingStaticNonFields = new Map();
|
|
275
|
+
for(var i = 0; i < decInfos.length; i++){
|
|
276
|
+
var decInfo = decInfos[i];
|
|
277
|
+
if (!Array.isArray(decInfo)) continue;
|
|
278
|
+
var kind = decInfo[1];
|
|
279
|
+
var name = decInfo[2];
|
|
280
|
+
var isPrivate = decInfo.length > 3;
|
|
281
|
+
var isStatic = kind >= 5;
|
|
282
|
+
var base;
|
|
283
|
+
var initializers;
|
|
284
|
+
if (isStatic) {
|
|
285
|
+
base = Class;
|
|
286
|
+
kind = kind - 5;
|
|
287
|
+
staticInitializers = staticInitializers || [];
|
|
288
|
+
initializers = staticInitializers;
|
|
289
|
+
} else {
|
|
290
|
+
base = Class.prototype;
|
|
291
|
+
protoInitializers = protoInitializers || [];
|
|
292
|
+
initializers = protoInitializers;
|
|
293
|
+
}
|
|
294
|
+
if (kind !== 0 && !isPrivate) {
|
|
295
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
296
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
297
|
+
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
|
|
298
|
+
throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
299
|
+
} else if (!existingKind && kind > 2) {
|
|
300
|
+
existingNonFields.set(name, kind);
|
|
301
|
+
} else {
|
|
302
|
+
existingNonFields.set(name, true);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
306
|
+
}
|
|
307
|
+
pushInitializers(ret, protoInitializers);
|
|
308
|
+
pushInitializers(ret, staticInitializers);
|
|
309
|
+
return ret;
|
|
310
|
+
}
|
|
311
|
+
function pushInitializers(ret, initializers) {
|
|
312
|
+
if (initializers) {
|
|
313
|
+
ret.push(function(instance) {
|
|
314
|
+
for(var i = 0; i < initializers.length; i++){
|
|
315
|
+
initializers[i].call(instance);
|
|
316
|
+
}
|
|
317
|
+
return instance;
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
322
|
+
if (classDecs.length > 0) {
|
|
323
|
+
var initializers = [];
|
|
324
|
+
var newClass = targetClass;
|
|
325
|
+
var name = targetClass.name;
|
|
326
|
+
for(var i = classDecs.length - 1; i >= 0; i--){
|
|
327
|
+
var decoratorFinishedRef = {
|
|
328
|
+
v: false
|
|
329
|
+
};
|
|
330
|
+
try {
|
|
331
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
332
|
+
kind: "class",
|
|
333
|
+
name: name,
|
|
334
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
335
|
+
metadata
|
|
336
|
+
});
|
|
337
|
+
} finally{
|
|
338
|
+
decoratorFinishedRef.v = true;
|
|
339
|
+
}
|
|
340
|
+
if (nextNewClass !== undefined) {
|
|
341
|
+
assertValidReturnValue(10, nextNewClass);
|
|
342
|
+
newClass = nextNewClass;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return [
|
|
346
|
+
defineMetadata(newClass, metadata),
|
|
347
|
+
function() {
|
|
348
|
+
for(var i = 0; i < initializers.length; i++){
|
|
349
|
+
initializers[i].call(newClass);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
];
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
function defineMetadata(Class, metadata) {
|
|
356
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
357
|
+
configurable: true,
|
|
358
|
+
enumerable: true,
|
|
359
|
+
value: metadata
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
|
|
363
|
+
if (parentClass !== void 0) {
|
|
364
|
+
var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
365
|
+
}
|
|
366
|
+
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
|
|
367
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
368
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
369
|
+
return {
|
|
370
|
+
e: e,
|
|
371
|
+
get c () {
|
|
372
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
378
|
+
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
379
|
+
}
|
|
380
|
+
function _identity(x) {
|
|
381
|
+
return x;
|
|
382
|
+
}
|
|
383
|
+
var _dec, _initClass, _ValidityMixin, _dec1, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, // ── ValidityMixin contract ───────────────────────────────────────────────
|
|
384
|
+
_init_status, _init_required, _init_validityMessage, // ── Public API ─────────────────────────────────────────────────────────────
|
|
385
|
+
/** Currently selected radio's value. */ _init_value, /** Shared name for all child radios. */ _init_name, /** Disables the entire group. */ _init_disabled, /** Layout direction of the radio group. */ _init_orientation, /** Size scale — controls spacing and propagates to child radios. */ _init_size, /** Allows clearing the selected radio button on double click. */ _init_allowDblclickClear, _initProto;
|
|
386
|
+
let _ViRadioGroup;
|
|
387
|
+
_dec = customElement('vi-radio-group'), _dec1 = property({
|
|
388
|
+
reflect: true
|
|
389
|
+
}), _dec2 = property({
|
|
390
|
+
type: Boolean,
|
|
391
|
+
reflect: true
|
|
392
|
+
}), _dec3 = property({
|
|
393
|
+
attribute: 'validity-message'
|
|
394
|
+
}), _dec4 = property({
|
|
395
|
+
reflect: true
|
|
396
|
+
}), _dec5 = property(), _dec6 = property({
|
|
397
|
+
type: Boolean,
|
|
398
|
+
reflect: true
|
|
399
|
+
}), _dec7 = property({
|
|
400
|
+
reflect: true
|
|
401
|
+
}), _dec8 = property({
|
|
402
|
+
type: String,
|
|
403
|
+
reflect: true
|
|
404
|
+
}), _dec9 = property({
|
|
405
|
+
type: Boolean,
|
|
406
|
+
attribute: 'allow-dblclick-clear',
|
|
407
|
+
reflect: true
|
|
408
|
+
});
|
|
409
|
+
new class extends _identity {
|
|
410
|
+
constructor(){
|
|
411
|
+
super(_ViRadioGroup), _initClass();
|
|
412
|
+
}
|
|
413
|
+
static{
|
|
414
|
+
class ViRadioGroup extends (_ValidityMixin = ValidityMixin(ViElement)) {
|
|
415
|
+
static{
|
|
416
|
+
({ e: [_init_status, _init_required, _init_validityMessage, _init_value, _init_name, _init_disabled, _init_orientation, _init_size, _init_allowDblclickClear, _initProto], c: [_ViRadioGroup, _initClass] } = _apply_decs_2203_r(this, [
|
|
417
|
+
[
|
|
418
|
+
_dec1,
|
|
419
|
+
1,
|
|
420
|
+
"status"
|
|
421
|
+
],
|
|
422
|
+
[
|
|
423
|
+
_dec2,
|
|
424
|
+
1,
|
|
425
|
+
"required"
|
|
426
|
+
],
|
|
427
|
+
[
|
|
428
|
+
_dec3,
|
|
429
|
+
1,
|
|
430
|
+
"validityMessage"
|
|
431
|
+
],
|
|
432
|
+
[
|
|
433
|
+
_dec4,
|
|
434
|
+
1,
|
|
435
|
+
"value"
|
|
436
|
+
],
|
|
437
|
+
[
|
|
438
|
+
_dec5,
|
|
439
|
+
1,
|
|
440
|
+
"name"
|
|
441
|
+
],
|
|
442
|
+
[
|
|
443
|
+
_dec6,
|
|
444
|
+
1,
|
|
445
|
+
"disabled"
|
|
446
|
+
],
|
|
447
|
+
[
|
|
448
|
+
_dec7,
|
|
449
|
+
1,
|
|
450
|
+
"orientation"
|
|
451
|
+
],
|
|
452
|
+
[
|
|
453
|
+
_dec8,
|
|
454
|
+
1,
|
|
455
|
+
"size"
|
|
456
|
+
],
|
|
457
|
+
[
|
|
458
|
+
_dec9,
|
|
459
|
+
1,
|
|
460
|
+
"allowDblclickClear"
|
|
461
|
+
]
|
|
462
|
+
], [
|
|
463
|
+
_dec
|
|
464
|
+
], _ValidityMixin));
|
|
465
|
+
}
|
|
466
|
+
static formAssociated = true;
|
|
467
|
+
static styles = css`
|
|
468
|
+
${unsafeCSS(radioGroupStyles)}
|
|
469
|
+
`;
|
|
470
|
+
_internals = (_initProto(this), this.attachInternals());
|
|
471
|
+
#___private_status_1 = _init_status(this, 'default');
|
|
472
|
+
get status() {
|
|
473
|
+
return this.#___private_status_1;
|
|
474
|
+
}
|
|
475
|
+
set status(_v) {
|
|
476
|
+
this.#___private_status_1 = _v;
|
|
477
|
+
}
|
|
478
|
+
#___private_required_2 = _init_required(this, false);
|
|
479
|
+
get required() {
|
|
480
|
+
return this.#___private_required_2;
|
|
481
|
+
}
|
|
482
|
+
set required(_v) {
|
|
483
|
+
this.#___private_required_2 = _v;
|
|
484
|
+
}
|
|
485
|
+
#___private_validityMessage_3 = _init_validityMessage(this, '');
|
|
486
|
+
get validityMessage() {
|
|
487
|
+
return this.#___private_validityMessage_3;
|
|
488
|
+
}
|
|
489
|
+
set validityMessage(_v) {
|
|
490
|
+
this.#___private_validityMessage_3 = _v;
|
|
491
|
+
}
|
|
492
|
+
#___private_value_4 = _init_value(this, '');
|
|
493
|
+
get value() {
|
|
494
|
+
return this.#___private_value_4;
|
|
495
|
+
}
|
|
496
|
+
set value(_v) {
|
|
497
|
+
this.#___private_value_4 = _v;
|
|
498
|
+
}
|
|
499
|
+
#___private_name_5 = _init_name(this, '');
|
|
500
|
+
get name() {
|
|
501
|
+
return this.#___private_name_5;
|
|
502
|
+
}
|
|
503
|
+
set name(_v) {
|
|
504
|
+
this.#___private_name_5 = _v;
|
|
505
|
+
}
|
|
506
|
+
#___private_disabled_6 = _init_disabled(this, false);
|
|
507
|
+
get disabled() {
|
|
508
|
+
return this.#___private_disabled_6;
|
|
509
|
+
}
|
|
510
|
+
set disabled(_v) {
|
|
511
|
+
this.#___private_disabled_6 = _v;
|
|
512
|
+
}
|
|
513
|
+
#___private_orientation_7 = _init_orientation(this, 'vertical');
|
|
514
|
+
get orientation() {
|
|
515
|
+
return this.#___private_orientation_7;
|
|
516
|
+
}
|
|
517
|
+
set orientation(_v) {
|
|
518
|
+
this.#___private_orientation_7 = _v;
|
|
519
|
+
}
|
|
520
|
+
#___private_size_8 = _init_size(this, 'md');
|
|
521
|
+
get size() {
|
|
522
|
+
return this.#___private_size_8;
|
|
523
|
+
}
|
|
524
|
+
set size(_v) {
|
|
525
|
+
this.#___private_size_8 = _v;
|
|
526
|
+
}
|
|
527
|
+
#___private_allowDblclickClear_9 = _init_allowDblclickClear(this, false);
|
|
528
|
+
get allowDblclickClear() {
|
|
529
|
+
return this.#___private_allowDblclickClear_9;
|
|
530
|
+
}
|
|
531
|
+
set allowDblclickClear(_v) {
|
|
532
|
+
this.#___private_allowDblclickClear_9 = _v;
|
|
533
|
+
}
|
|
534
|
+
_observer;
|
|
535
|
+
_initialValue = '';
|
|
536
|
+
connectedCallback() {
|
|
537
|
+
super.connectedCallback();
|
|
538
|
+
this._initialValue = this.getAttribute('value') ?? '';
|
|
539
|
+
// Set up MutationObserver to react to child vi-radio nodes added/removed dynamically
|
|
540
|
+
this._observer = new MutationObserver(()=>{
|
|
541
|
+
this._updateRadios();
|
|
542
|
+
});
|
|
543
|
+
this._observer.observe(this, {
|
|
544
|
+
childList: true,
|
|
545
|
+
subtree: true,
|
|
546
|
+
attributes: true,
|
|
547
|
+
attributeFilter: [
|
|
548
|
+
'disabled'
|
|
549
|
+
]
|
|
550
|
+
});
|
|
551
|
+
// Sync initial state of child radios
|
|
552
|
+
this._updateRadios();
|
|
553
|
+
// Listen for double-clicks on the host to support clearing
|
|
554
|
+
this.addEventListener('dblclick', this._onDblclick);
|
|
555
|
+
}
|
|
556
|
+
disconnectedCallback() {
|
|
557
|
+
super.disconnectedCallback();
|
|
558
|
+
if (this._observer) {
|
|
559
|
+
this._observer.disconnect();
|
|
560
|
+
}
|
|
561
|
+
this.removeEventListener('dblclick', this._onDblclick);
|
|
562
|
+
}
|
|
563
|
+
updated(changed) {
|
|
564
|
+
super.updated(changed);
|
|
565
|
+
if (changed.has('value')) {
|
|
566
|
+
this._internals.setFormValue(this.value);
|
|
567
|
+
}
|
|
568
|
+
if (changed.has('value') || changed.has('name') || changed.has('disabled') || changed.has('required') || changed.has('size')) {
|
|
569
|
+
this._updateRadios();
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
/** Resets the value and validation state when the parent form resets. */ formResetCallback() {
|
|
573
|
+
this.value = this._initialValue;
|
|
574
|
+
this.status = 'default';
|
|
575
|
+
this.validityMessage = '';
|
|
576
|
+
this._updateRadios();
|
|
577
|
+
}
|
|
578
|
+
/** Keeps disabled in sync when a containing fieldset/form is disabled. */ formDisabledCallback(disabled) {
|
|
579
|
+
this.disabled = disabled;
|
|
580
|
+
}
|
|
581
|
+
_testValidity() {
|
|
582
|
+
if (this.required && !this.value) {
|
|
583
|
+
this.validityMessage = 'Please select an option.';
|
|
584
|
+
return {
|
|
585
|
+
valueMissing: true
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
return {};
|
|
589
|
+
}
|
|
590
|
+
// ── Helper methods ─────────────────────────────────────────────────────────
|
|
591
|
+
_getRadios() {
|
|
592
|
+
return Array.from(this.querySelectorAll('vi-radio'));
|
|
593
|
+
}
|
|
594
|
+
_updateRadios() {
|
|
595
|
+
const radios = this._getRadios();
|
|
596
|
+
// 1. Propagate name, checked, and size attributes to children
|
|
597
|
+
radios.forEach((radio)=>{
|
|
598
|
+
if (this.name && radio.name !== this.name) {
|
|
599
|
+
radio.name = this.name;
|
|
600
|
+
}
|
|
601
|
+
if (this.size && radio.size !== this.size) {
|
|
602
|
+
radio.size = this.size;
|
|
603
|
+
}
|
|
604
|
+
const shouldBeChecked = this.value !== '' && radio.value === this.value;
|
|
605
|
+
if (radio.checked !== shouldBeChecked) {
|
|
606
|
+
radio.checked = shouldBeChecked;
|
|
607
|
+
}
|
|
608
|
+
// Let children recalculate their disabled states
|
|
609
|
+
radio.requestUpdate();
|
|
610
|
+
});
|
|
611
|
+
// 2. Roving tabindex active node determination:
|
|
612
|
+
// - The checked radio (if enabled)
|
|
613
|
+
// - The first enabled radio
|
|
614
|
+
// - Fallback to the first radio
|
|
615
|
+
let activeRadio = radios.find((r)=>r.checked && !r.disabled && !this.disabled);
|
|
616
|
+
if (!activeRadio) {
|
|
617
|
+
activeRadio = radios.find((r)=>!r.disabled && !this.disabled);
|
|
618
|
+
}
|
|
619
|
+
if (!activeRadio && radios.length > 0) {
|
|
620
|
+
activeRadio = radios[0];
|
|
621
|
+
}
|
|
622
|
+
radios.forEach((radio)=>{
|
|
623
|
+
const isRadioActive = radio === activeRadio;
|
|
624
|
+
radio.tabIndex = isRadioActive && !this.disabled && !radio.disabled ? 0 : -1;
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
// ── Event Handlers ─────────────────────────────────────────────────────────
|
|
628
|
+
_handleRadioChecked(e) {
|
|
629
|
+
const targetRadio = e.target;
|
|
630
|
+
if (this.disabled) return;
|
|
631
|
+
const oldValue = this.value;
|
|
632
|
+
this.value = targetRadio.value;
|
|
633
|
+
this._updateRadios();
|
|
634
|
+
if (this.value !== oldValue) {
|
|
635
|
+
this.dispatchEvent(new CustomEvent('vialiq-change', {
|
|
636
|
+
detail: {
|
|
637
|
+
value: this.value
|
|
638
|
+
},
|
|
639
|
+
bubbles: true,
|
|
640
|
+
composed: true
|
|
641
|
+
}));
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
_onKeydown(e) {
|
|
645
|
+
if (this.disabled) return;
|
|
646
|
+
const radios = this._getRadios().filter((r)=>!r.disabled);
|
|
647
|
+
if (radios.length === 0) return;
|
|
648
|
+
const eventTarget = e.target;
|
|
649
|
+
// Find index of the child radio that received the keydown event
|
|
650
|
+
const currentIndex = radios.findIndex((r)=>r === eventTarget || r.contains(eventTarget));
|
|
651
|
+
if (currentIndex === -1) return;
|
|
652
|
+
let nextIndex = currentIndex;
|
|
653
|
+
let shouldPreventDefault = false;
|
|
654
|
+
switch(e.key){
|
|
655
|
+
case 'ArrowDown':
|
|
656
|
+
case 'ArrowRight':
|
|
657
|
+
nextIndex = (currentIndex + 1) % radios.length;
|
|
658
|
+
shouldPreventDefault = true;
|
|
659
|
+
break;
|
|
660
|
+
case 'ArrowUp':
|
|
661
|
+
case 'ArrowLeft':
|
|
662
|
+
nextIndex = (currentIndex - 1 + radios.length) % radios.length;
|
|
663
|
+
shouldPreventDefault = true;
|
|
664
|
+
break;
|
|
665
|
+
case ' ':
|
|
666
|
+
nextIndex = currentIndex;
|
|
667
|
+
shouldPreventDefault = true;
|
|
668
|
+
break;
|
|
669
|
+
default:
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
if (shouldPreventDefault) {
|
|
673
|
+
e.preventDefault();
|
|
674
|
+
}
|
|
675
|
+
const targetRadio = radios[nextIndex];
|
|
676
|
+
if (targetRadio) {
|
|
677
|
+
const oldValue = this.value;
|
|
678
|
+
this.value = targetRadio.value;
|
|
679
|
+
this._updateRadios();
|
|
680
|
+
targetRadio.focus();
|
|
681
|
+
if (this.value !== oldValue) {
|
|
682
|
+
this.dispatchEvent(new CustomEvent('vialiq-change', {
|
|
683
|
+
detail: {
|
|
684
|
+
value: this.value
|
|
685
|
+
},
|
|
686
|
+
bubbles: true,
|
|
687
|
+
composed: true
|
|
688
|
+
}));
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
_onDblclick = (e)=>{
|
|
693
|
+
if (this.disabled || !this.allowDblclickClear) return;
|
|
694
|
+
const targetRadio = e.target.closest('vi-radio');
|
|
695
|
+
if (!targetRadio || targetRadio.disabled) return;
|
|
696
|
+
if (targetRadio.checked && this.value === targetRadio.value) {
|
|
697
|
+
const oldValue = this.value;
|
|
698
|
+
this.value = '';
|
|
699
|
+
this._updateRadios();
|
|
700
|
+
if (this.value !== oldValue) {
|
|
701
|
+
this.dispatchEvent(new CustomEvent('vialiq-change', {
|
|
702
|
+
detail: {
|
|
703
|
+
value: this.value
|
|
704
|
+
},
|
|
705
|
+
bubbles: true,
|
|
706
|
+
composed: true
|
|
707
|
+
}));
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
// ── Render ─────────────────────────────────────────────────────────────────
|
|
712
|
+
get _validationMessage() {
|
|
713
|
+
if (!this.validityMessage) return html``;
|
|
714
|
+
const cls = this.status === 'invalid' ? 'radio-group-validation--invalid' : this.status === 'valid' ? 'radio-group-validation--valid' : '';
|
|
715
|
+
return html`
|
|
716
|
+
<span
|
|
717
|
+
id="validation-message"
|
|
718
|
+
class="radio-group-validation ${cls}"
|
|
719
|
+
part="validation"
|
|
720
|
+
role="alert"
|
|
721
|
+
aria-live="polite"
|
|
722
|
+
>
|
|
723
|
+
${this.validityMessage}
|
|
724
|
+
</span>
|
|
725
|
+
`;
|
|
726
|
+
}
|
|
727
|
+
render() {
|
|
728
|
+
const { required, status, orientation } = this;
|
|
729
|
+
return html`
|
|
730
|
+
<fieldset
|
|
731
|
+
class="radio-group"
|
|
732
|
+
role="radiogroup"
|
|
733
|
+
aria-required=${required ? 'true' : 'false'}
|
|
734
|
+
aria-invalid=${status === 'invalid' ? 'true' : 'false'}
|
|
735
|
+
aria-describedby=${this.validityMessage ? 'validation-message' : undefined}
|
|
736
|
+
aria-errormessage=${status === 'invalid' && this.validityMessage ? 'validation-message' : undefined}
|
|
737
|
+
@vi-radio-checked=${this._handleRadioChecked}
|
|
738
|
+
@keydown=${this._onKeydown}
|
|
739
|
+
>
|
|
740
|
+
<legend class="radio-group-legend" part="legend">
|
|
741
|
+
<slot name="label"></slot>
|
|
742
|
+
</legend>
|
|
743
|
+
<div
|
|
744
|
+
class="radio-group-items"
|
|
745
|
+
part="items"
|
|
746
|
+
orientation=${orientation}
|
|
747
|
+
>
|
|
748
|
+
<slot></slot>
|
|
749
|
+
</div>
|
|
750
|
+
<div class="radio-group-helper" part="helper">
|
|
751
|
+
<slot name="helper"></slot>
|
|
752
|
+
</div>
|
|
753
|
+
${this._validationMessage}
|
|
754
|
+
</fieldset>
|
|
755
|
+
`;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}();
|
|
760
|
+
|
|
761
|
+
export { _ViRadioGroup as ViRadioGroup };
|