@vialiq/web-components 0.13.0 → 0.15.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/index.js CHANGED
@@ -1,9 +1,8 @@
1
- import { V as ViElement } from './vi-element-C6GfDPs3.js';
1
+ export { V as ViElement } from './vi-element-C6GfDPs3.js';
2
2
  export { ViButton } from './button/vi-button.js';
3
3
  export { ViInput } from './input/vi-input.js';
4
4
  export { ViIcon } from './icons/vi-icon.js';
5
- import { registerIcons } from './icons/registry.js';
6
- export { getIcon } from './icons/registry.js';
5
+ export { getIcon, registerIcons } from './icons/registry.js';
7
6
  export { ViRadio } from './radio/vi-radio.js';
8
7
  export { ViRadioGroup } from './radio/vi-radio-group.js';
9
8
  export { ViCheckbox } from './checkbox/vi-checkbox.js';
@@ -11,4411 +10,8 @@ export { ViTooltip } from './tooltip/vi-tooltip.js';
11
10
  export { ViTextarea } from './textarea/vi-textarea.js';
12
11
  export { ViAccordion } from './accordion/vi-accordion.js';
13
12
  export { ViAccordionItem } from './accordion/vi-accordion-item.js';
14
- import { unsafeCSS, css, html } from 'lit';
15
- import { customElement, property, state, queryAssignedElements } from 'lit/decorators.js';
16
- import { checkCircleIcon, triangleWarningIcon, infoIcon, xIcon, lockIcon } from '@vialiq/icons';
17
- import { F as FocusableMixin } from './focusable-mixin-CmxOyPX5.js';
18
- import { V as ValidityMixin } from './validity-mixin-H4aOFJEr.js';
19
-
20
- const badgeStyles = "@charset \"UTF-8\";@layer reset,components,utilities;@layer components{.badge{display:inline-flex;align-items:center;justify-content:center;white-space:nowrap;box-sizing:border-box;font-size:var(--vi-badge-font-size, 11px);font-weight:var(--vi-badge-font-weight, var(--vi-font-weight-semibold, 600));padding:var(--vi-badge-padding, 2px 8px);border-radius:var(--vi-badge-border-radius, 9999px);gap:var(--vi-badge-gap, 4px);border:var(--vi-border-width-thin, 1px) solid transparent}.dot{display:inline-block;width:var(--vi-badge-dot-size, 8px);height:var(--vi-badge-dot-size, 8px);border-radius:50%;background-color:currentColor;flex-shrink:0}.icon{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0}}:host{display:inline-block;vertical-align:middle}:host([hidden]),:host([count=\"0\"]:not([show-zero])){display:none!important}:host([size=sm]){--vi-badge-font-size: 10px;--vi-badge-padding: 0 6px;--vi-badge-gap: 2px;--vi-badge-dot-size: 6px}:host([size=md]){--vi-badge-font-size: 11px;--vi-badge-padding: 2px 8px;--vi-badge-gap: 4px;--vi-badge-dot-size: 8px}:host([size=lg]){--vi-badge-font-size: 13px;--vi-badge-padding: 4px 12px;--vi-badge-gap: 6px;--vi-badge-dot-size: 10px}:host([pill]){--vi-badge-border-radius: 9999px}:host(:not([pill])){--vi-badge-border-radius: var(--vi-border-radius-sm, 2px)}.badge.dot-only{--vi-badge-padding: 4px}:host([variant=neutral]) .badge{background-color:var(--vi-badge-neutral-bg, var(--vi-border-02, #eeeeee));color:var(--vi-badge-neutral-color, var(--vi-text-secondary, #4b5563))}:host([variant=primary]) .badge{background-color:var(--vi-badge-primary-bg, var(--vi-bg-info, #e3f2fd));color:var(--vi-badge-primary-color, var(--vi-text-info, #3676d0))}:host([variant=success]) .badge{background-color:var(--vi-badge-success-bg, var(--vi-bg-success, #e6f9f0));color:var(--vi-badge-success-color, var(--vi-text-success, #265a3d))}:host([variant=warning]) .badge{background-color:var(--vi-badge-warning-bg, var(--vi-bg-warning, #fff8e1));color:var(--vi-badge-warning-color, var(--vi-text-warning, #e68300))}:host([variant=danger]) .badge{background-color:var(--vi-badge-danger-bg, var(--vi-bg-error, #ffebee));color:var(--vi-badge-danger-color, var(--vi-text-error, #db231b))}:host([variant=info]) .badge{background-color:var(--vi-badge-info-bg, var(--vi-bg-info, #e3f2fd));color:var(--vi-badge-info-color, var(--vi-text-info, #3676d0))}:host([outline][variant=neutral]) .badge{background-color:transparent;color:var(--vi-badge-neutral-color, var(--vi-text-secondary, #4b5563));border-color:var(--vi-badge-neutral-border, var(--vi-border-03, #e0e0e0))}:host([outline][variant=primary]) .badge{background-color:transparent;color:var(--vi-badge-primary-color, var(--vi-text-info, #3676d0));border-color:var(--vi-badge-primary-border, var(--vi-color-primary, #3676d0))}:host([outline][variant=success]) .badge{background-color:transparent;color:var(--vi-badge-success-color, var(--vi-text-success, #265a3d));border-color:var(--vi-badge-success-border, var(--vi-color-success, #489167))}:host([outline][variant=warning]) .badge{background-color:transparent;color:var(--vi-badge-warning-color, var(--vi-text-warning, #e68300));border-color:var(--vi-badge-warning-border, var(--vi-color-warning, #ffba00))}:host([outline][variant=danger]) .badge{background-color:transparent;color:var(--vi-badge-danger-color, var(--vi-text-error, #db231b));border-color:var(--vi-badge-danger-border, var(--vi-color-error, #ef4444))}:host([outline][variant=info]) .badge{background-color:transparent;color:var(--vi-badge-info-color, var(--vi-text-info, #3676d0));border-color:var(--vi-badge-info-border, var(--vi-color-info, #3676d0))}.icon{display:inline-flex;flex-shrink:0}.icon[hidden]{display:none}::slotted(vi-icon),::slotted(svg){--vi-icon-size: 1em;width:1em;height:1em}";
21
-
22
- function applyDecs2203RFactory$4() {
23
- function createAddInitializerMethod(initializers, decoratorFinishedRef) {
24
- return function addInitializer(initializer) {
25
- assertNotFinished(decoratorFinishedRef, "addInitializer");
26
- assertCallable(initializer, "An initializer");
27
- initializers.push(initializer);
28
- };
29
- }
30
- function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
31
- var kindStr;
32
- switch(kind){
33
- case 1:
34
- kindStr = "accessor";
35
- break;
36
- case 2:
37
- kindStr = "method";
38
- break;
39
- case 3:
40
- kindStr = "getter";
41
- break;
42
- case 4:
43
- kindStr = "setter";
44
- break;
45
- default:
46
- kindStr = "field";
47
- }
48
- var ctx = {
49
- kind: kindStr,
50
- name: isPrivate ? "#" + name : name,
51
- static: isStatic,
52
- private: isPrivate,
53
- metadata: metadata
54
- };
55
- var decoratorFinishedRef = {
56
- v: false
57
- };
58
- ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
59
- var get, set;
60
- if (kind === 0) {
61
- if (isPrivate) {
62
- get = desc.get;
63
- set = desc.set;
64
- } else {
65
- get = function() {
66
- return this[name];
67
- };
68
- set = function(v) {
69
- this[name] = v;
70
- };
71
- }
72
- } else if (kind === 2) {
73
- get = function() {
74
- return desc.value;
75
- };
76
- } else {
77
- if (kind === 1 || kind === 3) {
78
- get = function() {
79
- return desc.get.call(this);
80
- };
81
- }
82
- if (kind === 1 || kind === 4) {
83
- set = function(v) {
84
- desc.set.call(this, v);
85
- };
86
- }
87
- }
88
- ctx.access = get && set ? {
89
- get: get,
90
- set: set
91
- } : get ? {
92
- get: get
93
- } : {
94
- set: set
95
- };
96
- try {
97
- return dec(value, ctx);
98
- } finally{
99
- decoratorFinishedRef.v = true;
100
- }
101
- }
102
- function assertNotFinished(decoratorFinishedRef, fnName) {
103
- if (decoratorFinishedRef.v) {
104
- throw new Error("attempted to call " + fnName + " after decoration was finished");
105
- }
106
- }
107
- function assertCallable(fn, hint) {
108
- if (typeof fn !== "function") {
109
- throw new TypeError(hint + " must be a function");
110
- }
111
- }
112
- function assertValidReturnValue(kind, value) {
113
- var type = typeof value;
114
- if (kind === 1) {
115
- if (type !== "object" || value === null) {
116
- throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
117
- }
118
- if (value.get !== undefined) {
119
- assertCallable(value.get, "accessor.get");
120
- }
121
- if (value.set !== undefined) {
122
- assertCallable(value.set, "accessor.set");
123
- }
124
- if (value.init !== undefined) {
125
- assertCallable(value.init, "accessor.init");
126
- }
127
- } else if (type !== "function") {
128
- var hint;
129
- if (kind === 0) {
130
- hint = "field";
131
- } else if (kind === 10) {
132
- hint = "class";
133
- } else {
134
- hint = "method";
135
- }
136
- throw new TypeError(hint + " decorators must return a function or void 0");
137
- }
138
- }
139
- function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
140
- var decs = decInfo[0];
141
- var desc, init, value;
142
- if (isPrivate) {
143
- if (kind === 0 || kind === 1) {
144
- desc = {
145
- get: decInfo[3],
146
- set: decInfo[4]
147
- };
148
- } else if (kind === 3) {
149
- desc = {
150
- get: decInfo[3]
151
- };
152
- } else if (kind === 4) {
153
- desc = {
154
- set: decInfo[3]
155
- };
156
- } else {
157
- desc = {
158
- value: decInfo[3]
159
- };
160
- }
161
- } else if (kind !== 0) {
162
- desc = Object.getOwnPropertyDescriptor(base, name);
163
- }
164
- if (kind === 1) {
165
- value = {
166
- get: desc.get,
167
- set: desc.set
168
- };
169
- } else if (kind === 2) {
170
- value = desc.value;
171
- } else if (kind === 3) {
172
- value = desc.get;
173
- } else if (kind === 4) {
174
- value = desc.set;
175
- }
176
- var newValue, get, set;
177
- if (typeof decs === "function") {
178
- newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
179
- if (newValue !== void 0) {
180
- assertValidReturnValue(kind, newValue);
181
- if (kind === 0) {
182
- init = newValue;
183
- } else if (kind === 1) {
184
- init = newValue.init;
185
- get = newValue.get || value.get;
186
- set = newValue.set || value.set;
187
- value = {
188
- get: get,
189
- set: set
190
- };
191
- } else {
192
- value = newValue;
193
- }
194
- }
195
- } else {
196
- for(var i = decs.length - 1; i >= 0; i--){
197
- var dec = decs[i];
198
- newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
199
- if (newValue !== void 0) {
200
- assertValidReturnValue(kind, newValue);
201
- var newInit;
202
- if (kind === 0) {
203
- newInit = newValue;
204
- } else if (kind === 1) {
205
- newInit = newValue.init;
206
- get = newValue.get || value.get;
207
- set = newValue.set || value.set;
208
- value = {
209
- get: get,
210
- set: set
211
- };
212
- } else {
213
- value = newValue;
214
- }
215
- if (newInit !== void 0) {
216
- if (init === void 0) {
217
- init = newInit;
218
- } else if (typeof init === "function") {
219
- init = [
220
- init,
221
- newInit
222
- ];
223
- } else {
224
- init.push(newInit);
225
- }
226
- }
227
- }
228
- }
229
- }
230
- if (kind === 0 || kind === 1) {
231
- if (init === void 0) {
232
- init = function(instance, init) {
233
- return init;
234
- };
235
- } else if (typeof init !== "function") {
236
- var ownInitializers = init;
237
- init = function(instance, init) {
238
- var value = init;
239
- for(var i = 0; i < ownInitializers.length; i++){
240
- value = ownInitializers[i].call(instance, value);
241
- }
242
- return value;
243
- };
244
- } else {
245
- var originalInitializer = init;
246
- init = function(instance, init) {
247
- return originalInitializer.call(instance, init);
248
- };
249
- }
250
- ret.push(init);
251
- }
252
- if (kind !== 0) {
253
- if (kind === 1) {
254
- desc.get = value.get;
255
- desc.set = value.set;
256
- } else if (kind === 2) {
257
- desc.value = value;
258
- } else if (kind === 3) {
259
- desc.get = value;
260
- } else if (kind === 4) {
261
- desc.set = value;
262
- }
263
- if (isPrivate) {
264
- if (kind === 1) {
265
- ret.push(function(instance, args) {
266
- return value.get.call(instance, args);
267
- });
268
- ret.push(function(instance, args) {
269
- return value.set.call(instance, args);
270
- });
271
- } else if (kind === 2) {
272
- ret.push(value);
273
- } else {
274
- ret.push(function(instance, args) {
275
- return value.call(instance, args);
276
- });
277
- }
278
- } else {
279
- Object.defineProperty(base, name, desc);
280
- }
281
- }
282
- }
283
- function applyMemberDecs(Class, decInfos, metadata) {
284
- var ret = [];
285
- var protoInitializers;
286
- var staticInitializers;
287
- var existingProtoNonFields = new Map();
288
- var existingStaticNonFields = new Map();
289
- for(var i = 0; i < decInfos.length; i++){
290
- var decInfo = decInfos[i];
291
- if (!Array.isArray(decInfo)) continue;
292
- var kind = decInfo[1];
293
- var name = decInfo[2];
294
- var isPrivate = decInfo.length > 3;
295
- var isStatic = kind >= 5;
296
- var base;
297
- var initializers;
298
- if (isStatic) {
299
- base = Class;
300
- kind = kind - 5;
301
- staticInitializers = staticInitializers || [];
302
- initializers = staticInitializers;
303
- } else {
304
- base = Class.prototype;
305
- protoInitializers = protoInitializers || [];
306
- initializers = protoInitializers;
307
- }
308
- if (kind !== 0 && !isPrivate) {
309
- var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
310
- var existingKind = existingNonFields.get(name) || 0;
311
- if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
312
- 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);
313
- } else if (!existingKind && kind > 2) {
314
- existingNonFields.set(name, kind);
315
- } else {
316
- existingNonFields.set(name, true);
317
- }
318
- }
319
- applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
320
- }
321
- pushInitializers(ret, protoInitializers);
322
- pushInitializers(ret, staticInitializers);
323
- return ret;
324
- }
325
- function pushInitializers(ret, initializers) {
326
- if (initializers) {
327
- ret.push(function(instance) {
328
- for(var i = 0; i < initializers.length; i++){
329
- initializers[i].call(instance);
330
- }
331
- return instance;
332
- });
333
- }
334
- }
335
- function applyClassDecs(targetClass, classDecs, metadata) {
336
- if (classDecs.length > 0) {
337
- var initializers = [];
338
- var newClass = targetClass;
339
- var name = targetClass.name;
340
- for(var i = classDecs.length - 1; i >= 0; i--){
341
- var decoratorFinishedRef = {
342
- v: false
343
- };
344
- try {
345
- var nextNewClass = classDecs[i](newClass, {
346
- kind: "class",
347
- name: name,
348
- addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
349
- metadata
350
- });
351
- } finally{
352
- decoratorFinishedRef.v = true;
353
- }
354
- if (nextNewClass !== undefined) {
355
- assertValidReturnValue(10, nextNewClass);
356
- newClass = nextNewClass;
357
- }
358
- }
359
- return [
360
- defineMetadata(newClass, metadata),
361
- function() {
362
- for(var i = 0; i < initializers.length; i++){
363
- initializers[i].call(newClass);
364
- }
365
- }
366
- ];
367
- }
368
- }
369
- function defineMetadata(Class, metadata) {
370
- return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
371
- configurable: true,
372
- enumerable: true,
373
- value: metadata
374
- });
375
- }
376
- return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
377
- if (parentClass !== void 0) {
378
- var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
379
- }
380
- var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
381
- var e = applyMemberDecs(targetClass, memberDecs, metadata);
382
- if (!classDecs.length) defineMetadata(targetClass, metadata);
383
- return {
384
- e: e,
385
- get c () {
386
- return applyClassDecs(targetClass, classDecs, metadata);
387
- }
388
- };
389
- };
390
- }
391
- function _apply_decs_2203_r$4(targetClass, memberDecs, classDecs, parentClass) {
392
- return (_apply_decs_2203_r$4 = applyDecs2203RFactory$4())(targetClass, memberDecs, classDecs, parentClass);
393
- }
394
- function _identity$4(x) {
395
- return x;
396
- }
397
- var _dec$4, _initClass$4, _ViElement$2, _dec1$4, _dec2$4, _dec3$4, _dec4$4, _dec5$4, _dec6$4, _dec7$4, _dec8$4, _dec9$4, _dec10$4, /** Colour semantic */ _init_variant$2, /** Size */ _init_size$1, /** Show coloured dot */ _init_dot, /** Fully rounded (pill shape) vs. square */ _init_pill, /** Numeric count to display */ _init_count, /** Show the badge even if the count is zero */ _init_showZero, /** Max count before showing {max}+ */ _init_max, /** Outlined/ghost style */ _init_outline, _init__hasIcon$1, _init__hasDefaultSlot, _initProto$4;
398
- let _ViBadge;
399
- _dec$4 = customElement('vi-badge'), _dec1$4 = property({
400
- type: String,
401
- reflect: true
402
- }), _dec2$4 = property({
403
- type: String,
404
- reflect: true
405
- }), _dec3$4 = property({
406
- type: Boolean,
407
- reflect: true
408
- }), _dec4$4 = property({
409
- type: Boolean,
410
- reflect: true
411
- }), _dec5$4 = property({
412
- type: Number,
413
- reflect: true
414
- }), _dec6$4 = property({
415
- type: Boolean,
416
- reflect: true,
417
- attribute: 'show-zero'
418
- }), _dec7$4 = property({
419
- type: Number
420
- }), _dec8$4 = property({
421
- type: Boolean,
422
- reflect: true
423
- }), _dec9$4 = state(), _dec10$4 = state();
424
- new class extends _identity$4 {
425
- constructor(){
426
- super(_ViBadge), _initClass$4();
427
- }
428
- static{
429
- class ViBadge extends (_ViElement$2 = ViElement) {
430
- static{
431
- ({ e: [_init_variant$2, _init_size$1, _init_dot, _init_pill, _init_count, _init_showZero, _init_max, _init_outline, _init__hasIcon$1, _init__hasDefaultSlot, _initProto$4], c: [_ViBadge, _initClass$4] } = _apply_decs_2203_r$4(this, [
432
- [
433
- _dec1$4,
434
- 1,
435
- "variant"
436
- ],
437
- [
438
- _dec2$4,
439
- 1,
440
- "size"
441
- ],
442
- [
443
- _dec3$4,
444
- 1,
445
- "dot"
446
- ],
447
- [
448
- _dec4$4,
449
- 1,
450
- "pill"
451
- ],
452
- [
453
- _dec5$4,
454
- 1,
455
- "count"
456
- ],
457
- [
458
- _dec6$4,
459
- 1,
460
- "showZero"
461
- ],
462
- [
463
- _dec7$4,
464
- 1,
465
- "max"
466
- ],
467
- [
468
- _dec8$4,
469
- 1,
470
- "outline"
471
- ],
472
- [
473
- _dec9$4,
474
- 1,
475
- "_hasIcon"
476
- ],
477
- [
478
- _dec10$4,
479
- 1,
480
- "_hasDefaultSlot"
481
- ]
482
- ], [
483
- _dec$4
484
- ], _ViElement$2));
485
- }
486
- static styles = css`${unsafeCSS(badgeStyles)}`;
487
- #___private_variant_1 = (_initProto$4(this), _init_variant$2(this, 'neutral'));
488
- get variant() {
489
- return this.#___private_variant_1;
490
- }
491
- set variant(_v) {
492
- this.#___private_variant_1 = _v;
493
- }
494
- #___private_size_2 = _init_size$1(this, 'md');
495
- get size() {
496
- return this.#___private_size_2;
497
- }
498
- set size(_v) {
499
- this.#___private_size_2 = _v;
500
- }
501
- #___private_dot_3 = _init_dot(this, false);
502
- get dot() {
503
- return this.#___private_dot_3;
504
- }
505
- set dot(_v) {
506
- this.#___private_dot_3 = _v;
507
- }
508
- #___private_pill_4 = _init_pill(this, true);
509
- get pill() {
510
- return this.#___private_pill_4;
511
- }
512
- set pill(_v) {
513
- this.#___private_pill_4 = _v;
514
- }
515
- #___private_count_5 = _init_count(this, undefined);
516
- get count() {
517
- return this.#___private_count_5;
518
- }
519
- set count(_v) {
520
- this.#___private_count_5 = _v;
521
- }
522
- #___private_showZero_6 = _init_showZero(this, false);
523
- get showZero() {
524
- return this.#___private_showZero_6;
525
- }
526
- set showZero(_v) {
527
- this.#___private_showZero_6 = _v;
528
- }
529
- #___private_max_7 = _init_max(this, 99);
530
- get max() {
531
- return this.#___private_max_7;
532
- }
533
- set max(_v) {
534
- this.#___private_max_7 = _v;
535
- }
536
- #___private_outline_8 = _init_outline(this, false);
537
- get outline() {
538
- return this.#___private_outline_8;
539
- }
540
- set outline(_v) {
541
- this.#___private_outline_8 = _v;
542
- }
543
- #___private__hasIcon_9 = _init__hasIcon$1(this, false);
544
- get _hasIcon() {
545
- return this.#___private__hasIcon_9;
546
- }
547
- set _hasIcon(_v) {
548
- this.#___private__hasIcon_9 = _v;
549
- }
550
- #___private__hasDefaultSlot_10 = _init__hasDefaultSlot(this, false);
551
- get _hasDefaultSlot() {
552
- return this.#___private__hasDefaultSlot_10;
553
- }
554
- set _hasDefaultSlot(_v) {
555
- this.#___private__hasDefaultSlot_10 = _v;
556
- }
557
- connectedCallback() {
558
- super.connectedCallback();
559
- this.updateAriaHidden();
560
- }
561
- updated(changedProperties) {
562
- super.updated(changedProperties);
563
- if (changedProperties.has('dot') || changedProperties.has('count') || changedProperties.has('showZero') || changedProperties.has('_hasDefaultSlot')) {
564
- this.updateAriaHidden();
565
- }
566
- }
567
- updateAriaHidden() {
568
- const isPurelyDecorative = this.dot && !this._hasDefaultSlot && this.count === undefined && !this.hasAttribute('aria-label') && !this.hasAttribute('aria-labelledby');
569
- if (isPurelyDecorative) {
570
- this.setAttribute('aria-hidden', 'true');
571
- } else {
572
- this.removeAttribute('aria-hidden');
573
- }
574
- }
575
- onIconSlotChange(e) {
576
- const slot = e.target;
577
- this._hasIcon = slot.assignedElements({
578
- flatten: true
579
- }).length > 0;
580
- }
581
- onDefaultSlotChange(e) {
582
- const slot = e.target;
583
- this._hasDefaultSlot = slot.assignedNodes({
584
- flatten: true
585
- }).some((node)=>{
586
- // Check if it's text with actual content or an element
587
- return node.nodeType === Node.TEXT_NODE && node.textContent?.trim().length || node.nodeType === Node.ELEMENT_NODE;
588
- });
589
- this.updateAriaHidden();
590
- }
591
- render() {
592
- let countContent = '';
593
- // If count is defined, render it, and we do not render the default slot content
594
- const hideDefaultSlot = this.count !== undefined;
595
- if (this.count !== undefined) {
596
- countContent = html`${this.count > this.max ? `${this.max}+` : `${this.count}`}`;
597
- }
598
- const dotContent = this.dot ? html`<span part="dot" class="dot"></span>` : '';
599
- return html`
600
- <span class="badge ${this.dot && !this._hasDefaultSlot && this.count === undefined ? 'dot-only' : ''}" part="badge">
601
- <slot
602
- name="icon"
603
- part="icon"
604
- class="icon"
605
- ?hidden=${!this._hasIcon}
606
- @slotchange=${this.onIconSlotChange}
607
- ></slot>
608
- ${dotContent}
609
- ${countContent}
610
- <slot ?hidden=${hideDefaultSlot} @slotchange=${this.onDefaultSlotChange}></slot>
611
- </span>
612
- `;
613
- }
614
- }
615
- }
616
- }();
617
-
618
- const alertStyles = "@charset \"UTF-8\";@layer reset,components,utilities;@layer components{.alert-root{display:flex;align-items:flex-start;box-sizing:border-box;width:100%;border-radius:var(--vi-alert-border-radius, 6px);padding:var(--vi-alert-padding, 12px 16px);gap:var(--vi-alert-gap, 12px);border-width:var(--vi-alert-border-width, 1px);border-style:solid;font-family:var(--vi-font-family-base, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif);font-size:var(--vi-font-size-sm, 14px);line-height:var(--vi-line-height-normal, 1.5)}.alert-icon{display:flex;align-items:center;justify-content:center;flex-shrink:0;padding-top:2px}.alert-content{display:flex;flex-direction:column;flex-grow:1;min-width:0}.alert-title{font-weight:var(--vi-font-weight-semibold, 600);margin-bottom:4px;display:block}.alert-actions{display:flex;align-items:center;gap:var(--vi-spacing-xs, 8px);margin-top:var(--vi-spacing-sm, 16px)}}:host{display:block;width:100%}:host([floating]){position:absolute;top:0;left:0;right:0;z-index:var(--vi-alert-floating-z-index, 10);box-shadow:var(--vi-alert-floating-shadow, 0 4px 12px rgba(0, 0, 0, .12))}:host([hidden]){display:none!important}.alert-root{overflow:hidden}.alert-root[data-variant=neutral]{background-color:var(--vi-alert-neutral-bg, var(--vi-layer-02, #f3f4f6));border-color:var(--vi-alert-neutral-border, var(--vi-border-04, #bdbdbd));color:var(--vi-alert-neutral-text-color, var(--vi-text-primary, #111827))}.alert-root[data-variant=neutral] .alert-title{color:var(--vi-alert-neutral-title-color, var(--vi-text-primary, #111827))}.alert-root[data-variant=neutral] .alert-icon{color:var(--vi-alert-neutral-icon-color, var(--vi-text-secondary, #4b5563))}.alert-root[data-variant=info]{background-color:var(--vi-alert-info-bg, var(--vi-bg-info, #e3f2fd));border-color:var(--vi-alert-info-border, var(--vi-color-info, #3676d0));color:var(--vi-alert-info-text-color, var(--vi-text-info, #3676d0))}.alert-root[data-variant=info] .alert-title{color:var(--vi-alert-info-title-color, var(--vi-text-info, #3676d0))}.alert-root[data-variant=info] .alert-icon{color:var(--vi-alert-info-icon-color, var(--vi-color-info, #3676d0))}.alert-root[data-variant=success]{background-color:var(--vi-alert-success-bg, var(--vi-bg-success, #e6f9f0));border-color:var(--vi-alert-success-border, var(--vi-color-success, #489167));color:var(--vi-alert-success-text-color, var(--vi-text-success, #265a3d))}.alert-root[data-variant=success] .alert-title{color:var(--vi-alert-success-title-color, var(--vi-text-success, #265a3d))}.alert-root[data-variant=success] .alert-icon{color:var(--vi-alert-success-icon-color, var(--vi-color-success, #489167))}.alert-root[data-variant=warning]{background-color:var(--vi-alert-warning-bg, var(--vi-bg-warning, #fff8e1));border-color:var(--vi-alert-warning-border, var(--vi-color-warning, #ffba00));color:var(--vi-alert-warning-text-color, var(--vi-text-warning, #e68300))}.alert-root[data-variant=warning] .alert-title{color:var(--vi-alert-warning-title-color, var(--vi-text-warning, #e68300))}.alert-root[data-variant=warning] .alert-icon{color:var(--vi-alert-warning-icon-color, var(--vi-color-warning, #ffba00))}.alert-root[data-variant=danger]{background-color:var(--vi-alert-danger-bg, var(--vi-bg-error, #ffebee));border-color:var(--vi-alert-danger-border, var(--vi-color-error, #ef4444));color:var(--vi-alert-danger-text-color, var(--vi-text-error, #db231b))}.alert-root[data-variant=danger] .alert-title{color:var(--vi-alert-danger-title-color, var(--vi-text-error, #db231b))}.alert-root[data-variant=danger] .alert-icon{color:var(--vi-alert-danger-icon-color, var(--vi-color-error, #ef4444))}vi-icon,::slotted(vi-icon),::slotted(svg){--vi-icon-size: 1.25em;width:1.25em;height:1.25em}vi-button[part=close-btn]{margin-top:-4px;margin-right:-4px;margin-left:4px}";
619
-
620
- function applyDecs2203RFactory$3() {
621
- function createAddInitializerMethod(initializers, decoratorFinishedRef) {
622
- return function addInitializer(initializer) {
623
- assertNotFinished(decoratorFinishedRef, "addInitializer");
624
- assertCallable(initializer, "An initializer");
625
- initializers.push(initializer);
626
- };
627
- }
628
- function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
629
- var kindStr;
630
- switch(kind){
631
- case 1:
632
- kindStr = "accessor";
633
- break;
634
- case 2:
635
- kindStr = "method";
636
- break;
637
- case 3:
638
- kindStr = "getter";
639
- break;
640
- case 4:
641
- kindStr = "setter";
642
- break;
643
- default:
644
- kindStr = "field";
645
- }
646
- var ctx = {
647
- kind: kindStr,
648
- name: isPrivate ? "#" + name : name,
649
- static: isStatic,
650
- private: isPrivate,
651
- metadata: metadata
652
- };
653
- var decoratorFinishedRef = {
654
- v: false
655
- };
656
- ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
657
- var get, set;
658
- if (kind === 0) {
659
- if (isPrivate) {
660
- get = desc.get;
661
- set = desc.set;
662
- } else {
663
- get = function() {
664
- return this[name];
665
- };
666
- set = function(v) {
667
- this[name] = v;
668
- };
669
- }
670
- } else if (kind === 2) {
671
- get = function() {
672
- return desc.value;
673
- };
674
- } else {
675
- if (kind === 1 || kind === 3) {
676
- get = function() {
677
- return desc.get.call(this);
678
- };
679
- }
680
- if (kind === 1 || kind === 4) {
681
- set = function(v) {
682
- desc.set.call(this, v);
683
- };
684
- }
685
- }
686
- ctx.access = get && set ? {
687
- get: get,
688
- set: set
689
- } : get ? {
690
- get: get
691
- } : {
692
- set: set
693
- };
694
- try {
695
- return dec(value, ctx);
696
- } finally{
697
- decoratorFinishedRef.v = true;
698
- }
699
- }
700
- function assertNotFinished(decoratorFinishedRef, fnName) {
701
- if (decoratorFinishedRef.v) {
702
- throw new Error("attempted to call " + fnName + " after decoration was finished");
703
- }
704
- }
705
- function assertCallable(fn, hint) {
706
- if (typeof fn !== "function") {
707
- throw new TypeError(hint + " must be a function");
708
- }
709
- }
710
- function assertValidReturnValue(kind, value) {
711
- var type = typeof value;
712
- if (kind === 1) {
713
- if (type !== "object" || value === null) {
714
- throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
715
- }
716
- if (value.get !== undefined) {
717
- assertCallable(value.get, "accessor.get");
718
- }
719
- if (value.set !== undefined) {
720
- assertCallable(value.set, "accessor.set");
721
- }
722
- if (value.init !== undefined) {
723
- assertCallable(value.init, "accessor.init");
724
- }
725
- } else if (type !== "function") {
726
- var hint;
727
- if (kind === 0) {
728
- hint = "field";
729
- } else if (kind === 10) {
730
- hint = "class";
731
- } else {
732
- hint = "method";
733
- }
734
- throw new TypeError(hint + " decorators must return a function or void 0");
735
- }
736
- }
737
- function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
738
- var decs = decInfo[0];
739
- var desc, init, value;
740
- if (isPrivate) {
741
- if (kind === 0 || kind === 1) {
742
- desc = {
743
- get: decInfo[3],
744
- set: decInfo[4]
745
- };
746
- } else if (kind === 3) {
747
- desc = {
748
- get: decInfo[3]
749
- };
750
- } else if (kind === 4) {
751
- desc = {
752
- set: decInfo[3]
753
- };
754
- } else {
755
- desc = {
756
- value: decInfo[3]
757
- };
758
- }
759
- } else if (kind !== 0) {
760
- desc = Object.getOwnPropertyDescriptor(base, name);
761
- }
762
- if (kind === 1) {
763
- value = {
764
- get: desc.get,
765
- set: desc.set
766
- };
767
- } else if (kind === 2) {
768
- value = desc.value;
769
- } else if (kind === 3) {
770
- value = desc.get;
771
- } else if (kind === 4) {
772
- value = desc.set;
773
- }
774
- var newValue, get, set;
775
- if (typeof decs === "function") {
776
- newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
777
- if (newValue !== void 0) {
778
- assertValidReturnValue(kind, newValue);
779
- if (kind === 0) {
780
- init = newValue;
781
- } else if (kind === 1) {
782
- init = newValue.init;
783
- get = newValue.get || value.get;
784
- set = newValue.set || value.set;
785
- value = {
786
- get: get,
787
- set: set
788
- };
789
- } else {
790
- value = newValue;
791
- }
792
- }
793
- } else {
794
- for(var i = decs.length - 1; i >= 0; i--){
795
- var dec = decs[i];
796
- newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
797
- if (newValue !== void 0) {
798
- assertValidReturnValue(kind, newValue);
799
- var newInit;
800
- if (kind === 0) {
801
- newInit = newValue;
802
- } else if (kind === 1) {
803
- newInit = newValue.init;
804
- get = newValue.get || value.get;
805
- set = newValue.set || value.set;
806
- value = {
807
- get: get,
808
- set: set
809
- };
810
- } else {
811
- value = newValue;
812
- }
813
- if (newInit !== void 0) {
814
- if (init === void 0) {
815
- init = newInit;
816
- } else if (typeof init === "function") {
817
- init = [
818
- init,
819
- newInit
820
- ];
821
- } else {
822
- init.push(newInit);
823
- }
824
- }
825
- }
826
- }
827
- }
828
- if (kind === 0 || kind === 1) {
829
- if (init === void 0) {
830
- init = function(instance, init) {
831
- return init;
832
- };
833
- } else if (typeof init !== "function") {
834
- var ownInitializers = init;
835
- init = function(instance, init) {
836
- var value = init;
837
- for(var i = 0; i < ownInitializers.length; i++){
838
- value = ownInitializers[i].call(instance, value);
839
- }
840
- return value;
841
- };
842
- } else {
843
- var originalInitializer = init;
844
- init = function(instance, init) {
845
- return originalInitializer.call(instance, init);
846
- };
847
- }
848
- ret.push(init);
849
- }
850
- if (kind !== 0) {
851
- if (kind === 1) {
852
- desc.get = value.get;
853
- desc.set = value.set;
854
- } else if (kind === 2) {
855
- desc.value = value;
856
- } else if (kind === 3) {
857
- desc.get = value;
858
- } else if (kind === 4) {
859
- desc.set = value;
860
- }
861
- if (isPrivate) {
862
- if (kind === 1) {
863
- ret.push(function(instance, args) {
864
- return value.get.call(instance, args);
865
- });
866
- ret.push(function(instance, args) {
867
- return value.set.call(instance, args);
868
- });
869
- } else if (kind === 2) {
870
- ret.push(value);
871
- } else {
872
- ret.push(function(instance, args) {
873
- return value.call(instance, args);
874
- });
875
- }
876
- } else {
877
- Object.defineProperty(base, name, desc);
878
- }
879
- }
880
- }
881
- function applyMemberDecs(Class, decInfos, metadata) {
882
- var ret = [];
883
- var protoInitializers;
884
- var staticInitializers;
885
- var existingProtoNonFields = new Map();
886
- var existingStaticNonFields = new Map();
887
- for(var i = 0; i < decInfos.length; i++){
888
- var decInfo = decInfos[i];
889
- if (!Array.isArray(decInfo)) continue;
890
- var kind = decInfo[1];
891
- var name = decInfo[2];
892
- var isPrivate = decInfo.length > 3;
893
- var isStatic = kind >= 5;
894
- var base;
895
- var initializers;
896
- if (isStatic) {
897
- base = Class;
898
- kind = kind - 5;
899
- staticInitializers = staticInitializers || [];
900
- initializers = staticInitializers;
901
- } else {
902
- base = Class.prototype;
903
- protoInitializers = protoInitializers || [];
904
- initializers = protoInitializers;
905
- }
906
- if (kind !== 0 && !isPrivate) {
907
- var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
908
- var existingKind = existingNonFields.get(name) || 0;
909
- if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
910
- 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);
911
- } else if (!existingKind && kind > 2) {
912
- existingNonFields.set(name, kind);
913
- } else {
914
- existingNonFields.set(name, true);
915
- }
916
- }
917
- applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
918
- }
919
- pushInitializers(ret, protoInitializers);
920
- pushInitializers(ret, staticInitializers);
921
- return ret;
922
- }
923
- function pushInitializers(ret, initializers) {
924
- if (initializers) {
925
- ret.push(function(instance) {
926
- for(var i = 0; i < initializers.length; i++){
927
- initializers[i].call(instance);
928
- }
929
- return instance;
930
- });
931
- }
932
- }
933
- function applyClassDecs(targetClass, classDecs, metadata) {
934
- if (classDecs.length > 0) {
935
- var initializers = [];
936
- var newClass = targetClass;
937
- var name = targetClass.name;
938
- for(var i = classDecs.length - 1; i >= 0; i--){
939
- var decoratorFinishedRef = {
940
- v: false
941
- };
942
- try {
943
- var nextNewClass = classDecs[i](newClass, {
944
- kind: "class",
945
- name: name,
946
- addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
947
- metadata
948
- });
949
- } finally{
950
- decoratorFinishedRef.v = true;
951
- }
952
- if (nextNewClass !== undefined) {
953
- assertValidReturnValue(10, nextNewClass);
954
- newClass = nextNewClass;
955
- }
956
- }
957
- return [
958
- defineMetadata(newClass, metadata),
959
- function() {
960
- for(var i = 0; i < initializers.length; i++){
961
- initializers[i].call(newClass);
962
- }
963
- }
964
- ];
965
- }
966
- }
967
- function defineMetadata(Class, metadata) {
968
- return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
969
- configurable: true,
970
- enumerable: true,
971
- value: metadata
972
- });
973
- }
974
- return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
975
- if (parentClass !== void 0) {
976
- var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
977
- }
978
- var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
979
- var e = applyMemberDecs(targetClass, memberDecs, metadata);
980
- if (!classDecs.length) defineMetadata(targetClass, metadata);
981
- return {
982
- e: e,
983
- get c () {
984
- return applyClassDecs(targetClass, classDecs, metadata);
985
- }
986
- };
987
- };
988
- }
989
- function _apply_decs_2203_r$3(targetClass, memberDecs, classDecs, parentClass) {
990
- return (_apply_decs_2203_r$3 = applyDecs2203RFactory$3())(targetClass, memberDecs, classDecs, parentClass);
991
- }
992
- function _identity$3(x) {
993
- return x;
994
- }
995
- var _dec$3, _initClass$3, _ViElement$1, _dec1$3, _dec2$3, _dec3$3, _dec4$3, _dec5$3, _dec6$3, _dec7$3, _dec8$3, _dec9$3, _dec10$3, _dec11$2, _dec12$1, _dec13$1, /** Colour, icon, ARIA role */ _init_variant$1, /** Bold headline (optional) */ _init_title, /** Show × dismiss button */ _init_dismissible, /** Accessible label for the dismiss button */ _init_dismissLabel, /**
996
- * Enables auto-hiding after a duration (default: 5000ms).
997
- * Note: Setting a positive `duration` or `auto-hide-duration` also implicitly enables auto-hiding.
998
- */ _init_autoHide, /** Auto hide duration in milliseconds (default: 5000ms) */ _init_autoHideDuration, /**
999
- * Alias for auto-hide-duration in milliseconds.
1000
- * Setting a positive duration enables auto-hiding automatically.
1001
- */ _init_duration$1, /** Override the default status icon name */ _init_icon, /** Controls whether the alert is displayed */ _init_open$1, /** Position alert absolutely over parent container without pushing layout */ _init_floating, /** Hide the icon */ _init_noIcon, _init__hasTitleSlot, _init__hasActionsSlot, _initProto$3;
1002
- registerIcons([
1003
- checkCircleIcon,
1004
- triangleWarningIcon,
1005
- infoIcon,
1006
- xIcon,
1007
- lockIcon
1008
- ]);
1009
- let _ViAlert;
1010
- _dec$3 = customElement('vi-alert'), _dec1$3 = property({
1011
- type: String,
1012
- reflect: true
1013
- }), _dec2$3 = property({
1014
- type: String
1015
- }), _dec3$3 = property({
1016
- type: Boolean,
1017
- reflect: true
1018
- }), _dec4$3 = property({
1019
- type: String,
1020
- attribute: 'dismiss-label'
1021
- }), _dec5$3 = property({
1022
- type: Boolean,
1023
- attribute: 'auto-hide',
1024
- reflect: true
1025
- }), _dec6$3 = property({
1026
- type: Number,
1027
- attribute: 'auto-hide-duration'
1028
- }), _dec7$3 = property({
1029
- type: Number
1030
- }), _dec8$3 = property({
1031
- type: String
1032
- }), _dec9$3 = property({
1033
- type: Boolean,
1034
- reflect: true
1035
- }), _dec10$3 = property({
1036
- type: Boolean,
1037
- reflect: true
1038
- }), _dec11$2 = property({
1039
- type: Boolean,
1040
- attribute: 'no-icon',
1041
- reflect: true
1042
- }), _dec12$1 = state(), _dec13$1 = state();
1043
- new class extends _identity$3 {
1044
- constructor(){
1045
- super(_ViAlert), _initClass$3();
1046
- }
1047
- static{
1048
- class ViAlert extends (_ViElement$1 = ViElement) {
1049
- static{
1050
- ({ e: [_init_variant$1, _init_title, _init_dismissible, _init_dismissLabel, _init_autoHide, _init_autoHideDuration, _init_duration$1, _init_icon, _init_open$1, _init_floating, _init_noIcon, _init__hasTitleSlot, _init__hasActionsSlot, _initProto$3], c: [_ViAlert, _initClass$3] } = _apply_decs_2203_r$3(this, [
1051
- [
1052
- _dec1$3,
1053
- 1,
1054
- "variant"
1055
- ],
1056
- [
1057
- _dec2$3,
1058
- 1,
1059
- "title"
1060
- ],
1061
- [
1062
- _dec3$3,
1063
- 1,
1064
- "dismissible"
1065
- ],
1066
- [
1067
- _dec4$3,
1068
- 1,
1069
- "dismissLabel"
1070
- ],
1071
- [
1072
- _dec5$3,
1073
- 1,
1074
- "autoHide"
1075
- ],
1076
- [
1077
- _dec6$3,
1078
- 1,
1079
- "autoHideDuration"
1080
- ],
1081
- [
1082
- _dec7$3,
1083
- 1,
1084
- "duration"
1085
- ],
1086
- [
1087
- _dec8$3,
1088
- 1,
1089
- "icon"
1090
- ],
1091
- [
1092
- _dec9$3,
1093
- 1,
1094
- "open"
1095
- ],
1096
- [
1097
- _dec10$3,
1098
- 1,
1099
- "floating"
1100
- ],
1101
- [
1102
- _dec11$2,
1103
- 1,
1104
- "noIcon"
1105
- ],
1106
- [
1107
- _dec12$1,
1108
- 1,
1109
- "_hasTitleSlot"
1110
- ],
1111
- [
1112
- _dec13$1,
1113
- 1,
1114
- "_hasActionsSlot"
1115
- ]
1116
- ], [
1117
- _dec$3
1118
- ], _ViElement$1));
1119
- }
1120
- static styles = css`
1121
- ${unsafeCSS(alertStyles)}
1122
- `;
1123
- #___private_variant_1 = (_initProto$3(this), _init_variant$1(this, 'info'));
1124
- get variant() {
1125
- return this.#___private_variant_1;
1126
- }
1127
- set variant(_v) {
1128
- this.#___private_variant_1 = _v;
1129
- }
1130
- #___private_title_2 = _init_title(this, '');
1131
- get title() {
1132
- return this.#___private_title_2;
1133
- }
1134
- set title(_v) {
1135
- this.#___private_title_2 = _v;
1136
- }
1137
- #___private_dismissible_3 = _init_dismissible(this, false);
1138
- get dismissible() {
1139
- return this.#___private_dismissible_3;
1140
- }
1141
- set dismissible(_v) {
1142
- this.#___private_dismissible_3 = _v;
1143
- }
1144
- #___private_dismissLabel_4 = _init_dismissLabel(this, 'Dismiss alert');
1145
- get dismissLabel() {
1146
- return this.#___private_dismissLabel_4;
1147
- }
1148
- set dismissLabel(_v) {
1149
- this.#___private_dismissLabel_4 = _v;
1150
- }
1151
- #___private_autoHide_5 = _init_autoHide(this, false);
1152
- get autoHide() {
1153
- return this.#___private_autoHide_5;
1154
- }
1155
- set autoHide(_v) {
1156
- this.#___private_autoHide_5 = _v;
1157
- }
1158
- #___private_autoHideDuration_6 = _init_autoHideDuration(this, 5000);
1159
- get autoHideDuration() {
1160
- return this.#___private_autoHideDuration_6;
1161
- }
1162
- set autoHideDuration(_v) {
1163
- this.#___private_autoHideDuration_6 = _v;
1164
- }
1165
- #___private_duration_7 = _init_duration$1(this, undefined);
1166
- get duration() {
1167
- return this.#___private_duration_7;
1168
- }
1169
- set duration(_v) {
1170
- this.#___private_duration_7 = _v;
1171
- }
1172
- #___private_icon_8 = _init_icon(this, undefined);
1173
- get icon() {
1174
- return this.#___private_icon_8;
1175
- }
1176
- set icon(_v) {
1177
- this.#___private_icon_8 = _v;
1178
- }
1179
- #___private_open_9 = _init_open$1(this, true);
1180
- get open() {
1181
- return this.#___private_open_9;
1182
- }
1183
- set open(_v) {
1184
- this.#___private_open_9 = _v;
1185
- }
1186
- #___private_floating_10 = _init_floating(this, false);
1187
- get floating() {
1188
- return this.#___private_floating_10;
1189
- }
1190
- set floating(_v) {
1191
- this.#___private_floating_10 = _v;
1192
- }
1193
- #___private_noIcon_11 = _init_noIcon(this, false);
1194
- get noIcon() {
1195
- return this.#___private_noIcon_11;
1196
- }
1197
- set noIcon(_v) {
1198
- this.#___private_noIcon_11 = _v;
1199
- }
1200
- #___private__hasTitleSlot_12 = _init__hasTitleSlot(this, false);
1201
- get _hasTitleSlot() {
1202
- return this.#___private__hasTitleSlot_12;
1203
- }
1204
- set _hasTitleSlot(_v) {
1205
- this.#___private__hasTitleSlot_12 = _v;
1206
- }
1207
- #___private__hasActionsSlot_13 = _init__hasActionsSlot(this, false);
1208
- get _hasActionsSlot() {
1209
- return this.#___private__hasActionsSlot_13;
1210
- }
1211
- set _hasActionsSlot(_v) {
1212
- this.#___private__hasActionsSlot_13 = _v;
1213
- }
1214
- _autoHideTimer = null;
1215
- /** Helper to check whether auto-hide is enabled via boolean toggle or duration setting */ get _shouldAutoHide() {
1216
- return this.autoHide || this.duration !== undefined && this.duration > 0;
1217
- }
1218
- connectedCallback() {
1219
- super.connectedCallback();
1220
- this.updateRole();
1221
- if (!this.open) {
1222
- this.hidden = true;
1223
- } else if (this._shouldAutoHide) {
1224
- this._startAutoHideTimer();
1225
- }
1226
- }
1227
- disconnectedCallback() {
1228
- super.disconnectedCallback();
1229
- this._clearAutoHideTimer();
1230
- }
1231
- updated(changedProperties) {
1232
- super.updated(changedProperties);
1233
- if (changedProperties.has('variant')) {
1234
- this.updateRole();
1235
- }
1236
- if (changedProperties.has('open') && changedProperties.get('open') !== undefined) {
1237
- if (this.open) {
1238
- this._handleOpen();
1239
- } else if (!this.hidden) {
1240
- this.handleDismiss();
1241
- }
1242
- }
1243
- if (changedProperties.has('autoHide') || changedProperties.has('autoHideDuration') || changedProperties.has('duration')) {
1244
- if (this.open && this._shouldAutoHide) {
1245
- this._startAutoHideTimer();
1246
- } else {
1247
- this._clearAutoHideTimer();
1248
- }
1249
- }
1250
- }
1251
- updateRole() {
1252
- switch(this.variant){
1253
- case 'warning':
1254
- case 'danger':
1255
- this.setAttribute('role', 'alert');
1256
- break;
1257
- case 'info':
1258
- case 'success':
1259
- this.setAttribute('role', 'status');
1260
- break;
1261
- case 'neutral':
1262
- default:
1263
- this.removeAttribute('role');
1264
- break;
1265
- }
1266
- }
1267
- get defaultIcon() {
1268
- switch(this.variant){
1269
- case 'success':
1270
- return 'check-circle';
1271
- case 'warning':
1272
- case 'danger':
1273
- return 'triangle-warning';
1274
- case 'info':
1275
- default:
1276
- return 'info';
1277
- }
1278
- }
1279
- onTitleSlotChange(e) {
1280
- const slot = e.target;
1281
- this._hasTitleSlot = slot.assignedNodes({
1282
- flatten: true
1283
- }).length > 0;
1284
- }
1285
- onActionsSlotChange(e) {
1286
- const slot = e.target;
1287
- this._hasActionsSlot = slot.assignedNodes({
1288
- flatten: true
1289
- }).length > 0;
1290
- }
1291
- _startAutoHideTimer() {
1292
- this._clearAutoHideTimer();
1293
- const timeout = this.duration ?? this.autoHideDuration;
1294
- if (timeout > 0) {
1295
- this._autoHideTimer = setTimeout(()=>{
1296
- this.hide();
1297
- }, timeout);
1298
- }
1299
- }
1300
- _clearAutoHideTimer() {
1301
- if (this._autoHideTimer !== null) {
1302
- clearTimeout(this._autoHideTimer);
1303
- this._autoHideTimer = null;
1304
- }
1305
- }
1306
- _handleOpen() {
1307
- this.hidden = false;
1308
- if (this.shadowRoot) {
1309
- const root = this.shadowRoot.querySelector('.alert-root');
1310
- if (root && typeof root.getAnimations === 'function') {
1311
- root.getAnimations().forEach((anim)=>anim.cancel());
1312
- }
1313
- }
1314
- if (this._shouldAutoHide) {
1315
- this._startAutoHideTimer();
1316
- }
1317
- this.dispatchEvent(new CustomEvent('vialiq-alert-show', {
1318
- bubbles: true,
1319
- composed: true,
1320
- detail: {
1321
- id: this.id
1322
- }
1323
- }));
1324
- }
1325
- _dismissPromise = null;
1326
- async handleDismiss() {
1327
- this._clearAutoHideTimer();
1328
- if (this._dismissPromise) {
1329
- return this._dismissPromise;
1330
- }
1331
- this._dismissPromise = (async ()=>{
1332
- if (this.shadowRoot) {
1333
- const root = this.shadowRoot.querySelector('.alert-root');
1334
- if (root && typeof root.animate === 'function') {
1335
- try {
1336
- const computed = getComputedStyle(root);
1337
- const currentHeight = root.offsetHeight;
1338
- const currentPadding = computed.padding;
1339
- const currentMargin = computed.margin;
1340
- const animation = root.animate([
1341
- {
1342
- height: `${currentHeight}px`,
1343
- opacity: 1,
1344
- margin: currentMargin,
1345
- padding: currentPadding
1346
- },
1347
- {
1348
- height: '0px',
1349
- opacity: 0,
1350
- margin: '0px',
1351
- padding: '0px'
1352
- }
1353
- ], {
1354
- duration: 200,
1355
- easing: 'ease-out',
1356
- fill: 'forwards'
1357
- });
1358
- await animation.finished;
1359
- } catch {
1360
- // Animation was cancelled or failed; swallow rejection and proceed
1361
- }
1362
- }
1363
- }
1364
- this.hidden = true;
1365
- this.open = false;
1366
- this.dispatchEvent(new CustomEvent('vialiq-alert-close', {
1367
- bubbles: true,
1368
- composed: true,
1369
- detail: {
1370
- id: this.id
1371
- }
1372
- }));
1373
- })();
1374
- try {
1375
- await this._dismissPromise;
1376
- } finally{
1377
- this._dismissPromise = null;
1378
- }
1379
- }
1380
- /** Programmatically shows the alert */ async show() {
1381
- this.open = true;
1382
- await this.updateComplete;
1383
- }
1384
- /** Programmatically hides/dismisses the alert */ async hide() {
1385
- if (this.open) {
1386
- this.open = false;
1387
- await this.updateComplete;
1388
- if (this._dismissPromise) {
1389
- await this._dismissPromise;
1390
- }
1391
- }
1392
- }
1393
- render() {
1394
- return html`
1395
- <div part="alert" class="alert-root" data-variant=${this.variant}>
1396
- ${!this.noIcon ? html`
1397
- <div part="icon" class="alert-icon">
1398
- <slot name="icon">
1399
- <vi-icon
1400
- name=${this.icon || this.defaultIcon}
1401
- aria-hidden="true"
1402
- ></vi-icon>
1403
- </slot>
1404
- </div>
1405
- ` : ''}
1406
-
1407
- <div part="content" class="alert-content">
1408
- <div
1409
- part="title"
1410
- class="alert-title"
1411
- ?hidden=${!(this.title || this._hasTitleSlot)}
1412
- >
1413
- <slot name="title" @slotchange=${this.onTitleSlotChange}>
1414
- ${this.title}
1415
- </slot>
1416
- </div>
1417
-
1418
- <div part="body" class="alert-body">
1419
- <slot></slot>
1420
- </div>
1421
-
1422
- <div
1423
- part="actions"
1424
- class="alert-actions"
1425
- ?hidden=${!this._hasActionsSlot}
1426
- >
1427
- <slot name="actions" @slotchange=${this.onActionsSlotChange}></slot>
1428
- </div>
1429
- </div>
1430
-
1431
- ${this.dismissible ? html`
1432
- <vi-button
1433
- part="close-btn"
1434
- variant="ghost"
1435
- size="sm"
1436
- icon-only
1437
- aria-label=${this.dismissLabel}
1438
- @click=${this.handleDismiss}
1439
- >
1440
- <vi-icon name="x" slot="icon"></vi-icon>
1441
- </vi-button>
1442
- ` : ''}
1443
- </div>
1444
- `;
1445
- }
1446
- }
1447
- }
1448
- }();
1449
-
1450
- const chipStyles = "@charset \"UTF-8\";@layer reset,components,utilities;@layer components{.chip,button{display:inline-flex;align-items:center;box-sizing:border-box;cursor:pointer;-webkit-user-select:none;user-select:none;vertical-align:middle;outline:none;border-style:solid;height:var(--vi-chip-height, var(--vi-chip-height-md, 32px));padding:var(--vi-chip-padding, 0 10px);border-radius:var(--vi-chip-border-radius, 999px);border-width:var(--vi-chip-border-width, 1px);gap:var(--vi-chip-gap, 6px);font-size:var(--vi-chip-font-size, var(--vi-font-size-sm));font-weight:var(--vi-chip-font-weight, var(--vi-font-weight-medium));transition:all var(--vi-chip-transition, .1s ease);background-color:var(--vi-chip-bg-color, var(--vi-layer-02, #f3f4f6));border-color:var(--vi-chip-border-color, var(--vi-border-03, #e0e0e0));color:var(--vi-chip-text-color, var(--vi-color-foreground, #111827))}.chip:focus-visible,button:focus-visible{outline:var(--vi-border-width-base, 2px) solid var(--vi-chip-focus-ring-color, var(--vi-focus, #3676d0));outline-offset:0;box-shadow:0 0 0 3px var(--vi-chip-focus-ring-glow, var(--vi-color-blue-200, #cee6ff))}.chip[aria-disabled=true],button[aria-disabled=true]{cursor:not-allowed}.chip-avatar{display:flex;align-items:center;justify-content:center;overflow:hidden;border-radius:50%;width:calc(100% - 8px);height:calc(100% - 8px);margin-inline-start:-4px}.chip-icon{display:inline-flex;align-items:center}.chip-label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.chip-group{display:flex;align-items:center}}:host{display:inline-block;vertical-align:middle}:host([hidden]){display:none!important}:host([size=sm]) button{--vi-chip-height: var(--vi-chip-height-sm);--vi-chip-font-size: var(--vi-font-size-xs);--vi-chip-padding: 0 8px}:host([size=md]) button{--vi-chip-height: var(--vi-chip-height-md);--vi-chip-font-size: var(--vi-font-size-sm);--vi-chip-padding: 0 10px}:host([size=lg]) button{--vi-chip-height: var(--vi-chip-height-lg);--vi-chip-font-size: var(--vi-font-size-base);--vi-chip-padding: 0 12px}:host([variant=neutral]) button{--vi-chip-bg-color: var(--vi-color-grey-100, #f5f5f5);--vi-chip-border-color: var(--vi-color-grey-300, #e0e0e0);--vi-chip-text-color: var(--vi-color-grey-700, #616161)}:host([variant=neutral]:not([disabled])) button:hover{--vi-chip-bg-color: var(--vi-color-grey-200, #eeeeee);--vi-chip-border-color: var(--vi-color-grey-400, #bdbdbd);--vi-chip-text-color: var(--vi-color-grey-900, #212121)}:host([variant=neutral][selected]) button{--vi-chip-bg-color: var(--vi-color-primary, #3676d0);--vi-chip-border-color: var(--vi-color-primary, #3676d0);--vi-chip-text-color: var(--vi-text-primary-inverse, #ffffff)}:host([variant=neutral][selected]:not([disabled])) button:hover{--vi-chip-bg-color: var(--vi-color-blue-800, #2d5fa8);--vi-chip-border-color: var(--vi-color-blue-800, #2d5fa8)}:host([variant=primary]) button{--vi-chip-bg-color: var(--vi-bg-info, #e3f2fd);--vi-chip-border-color: var(--vi-bg-info, #e3f2fd);--vi-chip-text-color: var(--vi-text-info, #3676d0)}:host([variant=primary]:not([disabled])) button:hover{--vi-chip-bg-color: var(--vi-color-blue-100, #ebf5ff);--vi-chip-border-color: var(--vi-color-blue-200, #cee6ff)}:host([variant=primary][selected]) button{--vi-chip-bg-color: var(--vi-color-info, #3676d0);--vi-chip-border-color: var(--vi-color-info, #3676d0);--vi-chip-text-color: var(--vi-text-primary-inverse, #ffffff)}:host([variant=success]) button{--vi-chip-bg-color: var(--vi-bg-success, #e6f9f0);--vi-chip-border-color: var(--vi-bg-success, #e6f9f0);--vi-chip-text-color: var(--vi-text-success, #265a3d)}:host([variant=success]:not([disabled])) button:hover{--vi-chip-bg-color: var(--vi-color-green-100, #e6f0eb);--vi-chip-border-color: var(--vi-color-green-200, #c0dbcd)}:host([variant=success][selected]) button{--vi-chip-bg-color: var(--vi-color-success, #489167);--vi-chip-border-color: var(--vi-color-success, #489167);--vi-chip-text-color: var(--vi-text-primary-inverse, #ffffff)}:host([variant=warning]) button{--vi-chip-bg-color: var(--vi-bg-warning, #fff8e1);--vi-chip-border-color: var(--vi-bg-warning, #fff8e1);--vi-chip-text-color: var(--vi-text-warning, #e68300)}:host([variant=warning]:not([disabled])) button:hover{--vi-chip-bg-color: var(--vi-color-yellow-100, #ffeab1);--vi-chip-border-color: var(--vi-color-yellow-200, #ffde85)}:host([variant=warning][selected]) button{--vi-chip-bg-color: var(--vi-color-warning, #ffba00);--vi-chip-border-color: var(--vi-color-warning, #ffba00);--vi-chip-text-color: var(--vi-text-primary-inverse, #ffffff)}:host([variant=danger]) button{--vi-chip-bg-color: var(--vi-bg-error, #ffebee);--vi-chip-border-color: var(--vi-bg-error, #ffebee);--vi-chip-text-color: var(--vi-text-error, #db231b)}:host([variant=danger]:not([disabled])) button:hover{--vi-chip-bg-color: var(--vi-color-red-100, #ffccce);--vi-chip-border-color: var(--vi-color-red-200, #f69892)}:host([variant=danger][selected]) button{--vi-chip-bg-color: var(--vi-color-error, #ef4444);--vi-chip-border-color: var(--vi-color-error, #ef4444);--vi-chip-text-color: var(--vi-text-primary-inverse, #ffffff)}:host([variant=info]) button{--vi-chip-bg-color: var(--vi-bg-info, #e3f2fd);--vi-chip-border-color: var(--vi-bg-info, #e3f2fd);--vi-chip-text-color: var(--vi-text-info, #3676d0)}:host([variant=info]:not([disabled])) button:hover{--vi-chip-bg-color: var(--vi-color-blue-100, #ebf5ff);--vi-chip-border-color: var(--vi-color-blue-200, #cee6ff)}:host([variant=info][selected]) button{--vi-chip-bg-color: var(--vi-color-info, #3676d0);--vi-chip-border-color: var(--vi-color-info, #3676d0);--vi-chip-text-color: var(--vi-text-primary-inverse, #ffffff)}:host([disabled]) button{--vi-chip-bg-color: var(--vi-color-grey-50, #fafafa);--vi-chip-border-color: var(--vi-color-grey-200, #eeeeee);--vi-chip-text-color: var(--vi-color-grey-300, #e0e0e0)}.chip-avatar[hidden],.chip-icon[hidden],::slotted([slot=trailing-icon][hidden]){display:none!important}vi-button[part=remove-btn]{margin-inline-start:4px;margin-inline-end:-6px;border-radius:50%;color:inherit}";
1451
-
1452
- function applyDecs2203RFactory$2() {
1453
- function createAddInitializerMethod(initializers, decoratorFinishedRef) {
1454
- return function addInitializer(initializer) {
1455
- assertNotFinished(decoratorFinishedRef, "addInitializer");
1456
- assertCallable(initializer, "An initializer");
1457
- initializers.push(initializer);
1458
- };
1459
- }
1460
- function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
1461
- var kindStr;
1462
- switch(kind){
1463
- case 1:
1464
- kindStr = "accessor";
1465
- break;
1466
- case 2:
1467
- kindStr = "method";
1468
- break;
1469
- case 3:
1470
- kindStr = "getter";
1471
- break;
1472
- case 4:
1473
- kindStr = "setter";
1474
- break;
1475
- default:
1476
- kindStr = "field";
1477
- }
1478
- var ctx = {
1479
- kind: kindStr,
1480
- name: isPrivate ? "#" + name : name,
1481
- static: isStatic,
1482
- private: isPrivate,
1483
- metadata: metadata
1484
- };
1485
- var decoratorFinishedRef = {
1486
- v: false
1487
- };
1488
- ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
1489
- var get, set;
1490
- if (kind === 0) {
1491
- if (isPrivate) {
1492
- get = desc.get;
1493
- set = desc.set;
1494
- } else {
1495
- get = function() {
1496
- return this[name];
1497
- };
1498
- set = function(v) {
1499
- this[name] = v;
1500
- };
1501
- }
1502
- } else if (kind === 2) {
1503
- get = function() {
1504
- return desc.value;
1505
- };
1506
- } else {
1507
- if (kind === 1 || kind === 3) {
1508
- get = function() {
1509
- return desc.get.call(this);
1510
- };
1511
- }
1512
- if (kind === 1 || kind === 4) {
1513
- set = function(v) {
1514
- desc.set.call(this, v);
1515
- };
1516
- }
1517
- }
1518
- ctx.access = get && set ? {
1519
- get: get,
1520
- set: set
1521
- } : get ? {
1522
- get: get
1523
- } : {
1524
- set: set
1525
- };
1526
- try {
1527
- return dec(value, ctx);
1528
- } finally{
1529
- decoratorFinishedRef.v = true;
1530
- }
1531
- }
1532
- function assertNotFinished(decoratorFinishedRef, fnName) {
1533
- if (decoratorFinishedRef.v) {
1534
- throw new Error("attempted to call " + fnName + " after decoration was finished");
1535
- }
1536
- }
1537
- function assertCallable(fn, hint) {
1538
- if (typeof fn !== "function") {
1539
- throw new TypeError(hint + " must be a function");
1540
- }
1541
- }
1542
- function assertValidReturnValue(kind, value) {
1543
- var type = typeof value;
1544
- if (kind === 1) {
1545
- if (type !== "object" || value === null) {
1546
- throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
1547
- }
1548
- if (value.get !== undefined) {
1549
- assertCallable(value.get, "accessor.get");
1550
- }
1551
- if (value.set !== undefined) {
1552
- assertCallable(value.set, "accessor.set");
1553
- }
1554
- if (value.init !== undefined) {
1555
- assertCallable(value.init, "accessor.init");
1556
- }
1557
- } else if (type !== "function") {
1558
- var hint;
1559
- if (kind === 0) {
1560
- hint = "field";
1561
- } else if (kind === 10) {
1562
- hint = "class";
1563
- } else {
1564
- hint = "method";
1565
- }
1566
- throw new TypeError(hint + " decorators must return a function or void 0");
1567
- }
1568
- }
1569
- function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
1570
- var decs = decInfo[0];
1571
- var desc, init, value;
1572
- if (isPrivate) {
1573
- if (kind === 0 || kind === 1) {
1574
- desc = {
1575
- get: decInfo[3],
1576
- set: decInfo[4]
1577
- };
1578
- } else if (kind === 3) {
1579
- desc = {
1580
- get: decInfo[3]
1581
- };
1582
- } else if (kind === 4) {
1583
- desc = {
1584
- set: decInfo[3]
1585
- };
1586
- } else {
1587
- desc = {
1588
- value: decInfo[3]
1589
- };
1590
- }
1591
- } else if (kind !== 0) {
1592
- desc = Object.getOwnPropertyDescriptor(base, name);
1593
- }
1594
- if (kind === 1) {
1595
- value = {
1596
- get: desc.get,
1597
- set: desc.set
1598
- };
1599
- } else if (kind === 2) {
1600
- value = desc.value;
1601
- } else if (kind === 3) {
1602
- value = desc.get;
1603
- } else if (kind === 4) {
1604
- value = desc.set;
1605
- }
1606
- var newValue, get, set;
1607
- if (typeof decs === "function") {
1608
- newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
1609
- if (newValue !== void 0) {
1610
- assertValidReturnValue(kind, newValue);
1611
- if (kind === 0) {
1612
- init = newValue;
1613
- } else if (kind === 1) {
1614
- init = newValue.init;
1615
- get = newValue.get || value.get;
1616
- set = newValue.set || value.set;
1617
- value = {
1618
- get: get,
1619
- set: set
1620
- };
1621
- } else {
1622
- value = newValue;
1623
- }
1624
- }
1625
- } else {
1626
- for(var i = decs.length - 1; i >= 0; i--){
1627
- var dec = decs[i];
1628
- newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
1629
- if (newValue !== void 0) {
1630
- assertValidReturnValue(kind, newValue);
1631
- var newInit;
1632
- if (kind === 0) {
1633
- newInit = newValue;
1634
- } else if (kind === 1) {
1635
- newInit = newValue.init;
1636
- get = newValue.get || value.get;
1637
- set = newValue.set || value.set;
1638
- value = {
1639
- get: get,
1640
- set: set
1641
- };
1642
- } else {
1643
- value = newValue;
1644
- }
1645
- if (newInit !== void 0) {
1646
- if (init === void 0) {
1647
- init = newInit;
1648
- } else if (typeof init === "function") {
1649
- init = [
1650
- init,
1651
- newInit
1652
- ];
1653
- } else {
1654
- init.push(newInit);
1655
- }
1656
- }
1657
- }
1658
- }
1659
- }
1660
- if (kind === 0 || kind === 1) {
1661
- if (init === void 0) {
1662
- init = function(instance, init) {
1663
- return init;
1664
- };
1665
- } else if (typeof init !== "function") {
1666
- var ownInitializers = init;
1667
- init = function(instance, init) {
1668
- var value = init;
1669
- for(var i = 0; i < ownInitializers.length; i++){
1670
- value = ownInitializers[i].call(instance, value);
1671
- }
1672
- return value;
1673
- };
1674
- } else {
1675
- var originalInitializer = init;
1676
- init = function(instance, init) {
1677
- return originalInitializer.call(instance, init);
1678
- };
1679
- }
1680
- ret.push(init);
1681
- }
1682
- if (kind !== 0) {
1683
- if (kind === 1) {
1684
- desc.get = value.get;
1685
- desc.set = value.set;
1686
- } else if (kind === 2) {
1687
- desc.value = value;
1688
- } else if (kind === 3) {
1689
- desc.get = value;
1690
- } else if (kind === 4) {
1691
- desc.set = value;
1692
- }
1693
- if (isPrivate) {
1694
- if (kind === 1) {
1695
- ret.push(function(instance, args) {
1696
- return value.get.call(instance, args);
1697
- });
1698
- ret.push(function(instance, args) {
1699
- return value.set.call(instance, args);
1700
- });
1701
- } else if (kind === 2) {
1702
- ret.push(value);
1703
- } else {
1704
- ret.push(function(instance, args) {
1705
- return value.call(instance, args);
1706
- });
1707
- }
1708
- } else {
1709
- Object.defineProperty(base, name, desc);
1710
- }
1711
- }
1712
- }
1713
- function applyMemberDecs(Class, decInfos, metadata) {
1714
- var ret = [];
1715
- var protoInitializers;
1716
- var staticInitializers;
1717
- var existingProtoNonFields = new Map();
1718
- var existingStaticNonFields = new Map();
1719
- for(var i = 0; i < decInfos.length; i++){
1720
- var decInfo = decInfos[i];
1721
- if (!Array.isArray(decInfo)) continue;
1722
- var kind = decInfo[1];
1723
- var name = decInfo[2];
1724
- var isPrivate = decInfo.length > 3;
1725
- var isStatic = kind >= 5;
1726
- var base;
1727
- var initializers;
1728
- if (isStatic) {
1729
- base = Class;
1730
- kind = kind - 5;
1731
- staticInitializers = staticInitializers || [];
1732
- initializers = staticInitializers;
1733
- } else {
1734
- base = Class.prototype;
1735
- protoInitializers = protoInitializers || [];
1736
- initializers = protoInitializers;
1737
- }
1738
- if (kind !== 0 && !isPrivate) {
1739
- var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
1740
- var existingKind = existingNonFields.get(name) || 0;
1741
- if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
1742
- 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);
1743
- } else if (!existingKind && kind > 2) {
1744
- existingNonFields.set(name, kind);
1745
- } else {
1746
- existingNonFields.set(name, true);
1747
- }
1748
- }
1749
- applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
1750
- }
1751
- pushInitializers(ret, protoInitializers);
1752
- pushInitializers(ret, staticInitializers);
1753
- return ret;
1754
- }
1755
- function pushInitializers(ret, initializers) {
1756
- if (initializers) {
1757
- ret.push(function(instance) {
1758
- for(var i = 0; i < initializers.length; i++){
1759
- initializers[i].call(instance);
1760
- }
1761
- return instance;
1762
- });
1763
- }
1764
- }
1765
- function applyClassDecs(targetClass, classDecs, metadata) {
1766
- if (classDecs.length > 0) {
1767
- var initializers = [];
1768
- var newClass = targetClass;
1769
- var name = targetClass.name;
1770
- for(var i = classDecs.length - 1; i >= 0; i--){
1771
- var decoratorFinishedRef = {
1772
- v: false
1773
- };
1774
- try {
1775
- var nextNewClass = classDecs[i](newClass, {
1776
- kind: "class",
1777
- name: name,
1778
- addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
1779
- metadata
1780
- });
1781
- } finally{
1782
- decoratorFinishedRef.v = true;
1783
- }
1784
- if (nextNewClass !== undefined) {
1785
- assertValidReturnValue(10, nextNewClass);
1786
- newClass = nextNewClass;
1787
- }
1788
- }
1789
- return [
1790
- defineMetadata(newClass, metadata),
1791
- function() {
1792
- for(var i = 0; i < initializers.length; i++){
1793
- initializers[i].call(newClass);
1794
- }
1795
- }
1796
- ];
1797
- }
1798
- }
1799
- function defineMetadata(Class, metadata) {
1800
- return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
1801
- configurable: true,
1802
- enumerable: true,
1803
- value: metadata
1804
- });
1805
- }
1806
- return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
1807
- if (parentClass !== void 0) {
1808
- var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
1809
- }
1810
- var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
1811
- var e = applyMemberDecs(targetClass, memberDecs, metadata);
1812
- if (!classDecs.length) defineMetadata(targetClass, metadata);
1813
- return {
1814
- e: e,
1815
- get c () {
1816
- return applyClassDecs(targetClass, classDecs, metadata);
1817
- }
1818
- };
1819
- };
1820
- }
1821
- function _apply_decs_2203_r$2(targetClass, memberDecs, classDecs, parentClass) {
1822
- return (_apply_decs_2203_r$2 = applyDecs2203RFactory$2())(targetClass, memberDecs, classDecs, parentClass);
1823
- }
1824
- function _identity$2(x) {
1825
- return x;
1826
- }
1827
- var _dec$2, _initClass$2, _FocusableMixin, _dec1$2, _dec2$2, _dec3$2, _dec4$2, _dec5$2, _dec6$2, _dec7$2, _dec8$2, _dec9$2, _dec10$2, _dec11$1, /** Value for group selection tracking. */ _init_value$1, /** Selected / active state. */ _init_selected, /** Disables the chip. */ _init_disabled$1, /** Show × remove button. */ _init_removable, /** Screen reader text for the remove button (default: 'Remove') */ _init_removeAriaLabel, /** Base colour. */ _init_variant, /** Chip size. */ _init_size, _init__inGroup, _init__hasAvatar, _init__hasIcon, _init__hasTrailingIcon, _initProto$2;
1828
- let _ViChip;
1829
- _dec$2 = customElement('vi-chip'), _dec1$2 = property({
1830
- type: String,
1831
- reflect: true
1832
- }), _dec2$2 = property({
1833
- type: Boolean,
1834
- reflect: true
1835
- }), _dec3$2 = property({
1836
- type: Boolean,
1837
- reflect: true
1838
- }), _dec4$2 = property({
1839
- type: Boolean,
1840
- reflect: true
1841
- }), _dec5$2 = property({
1842
- type: String,
1843
- attribute: 'remove-aria-label'
1844
- }), _dec6$2 = property({
1845
- type: String,
1846
- reflect: true
1847
- }), _dec7$2 = property({
1848
- type: String,
1849
- reflect: true
1850
- }), _dec8$2 = state(), _dec9$2 = state(), _dec10$2 = state(), _dec11$1 = state();
1851
- new class extends _identity$2 {
1852
- constructor(){
1853
- super(_ViChip), _initClass$2();
1854
- }
1855
- static{
1856
- class ViChip extends (_FocusableMixin = FocusableMixin(ViElement)) {
1857
- static{
1858
- ({ e: [_init_value$1, _init_selected, _init_disabled$1, _init_removable, _init_removeAriaLabel, _init_variant, _init_size, _init__inGroup, _init__hasAvatar, _init__hasIcon, _init__hasTrailingIcon, _initProto$2], c: [_ViChip, _initClass$2] } = _apply_decs_2203_r$2(this, [
1859
- [
1860
- _dec1$2,
1861
- 1,
1862
- "value"
1863
- ],
1864
- [
1865
- _dec2$2,
1866
- 1,
1867
- "selected"
1868
- ],
1869
- [
1870
- _dec3$2,
1871
- 1,
1872
- "disabled"
1873
- ],
1874
- [
1875
- _dec4$2,
1876
- 1,
1877
- "removable"
1878
- ],
1879
- [
1880
- _dec5$2,
1881
- 1,
1882
- "removeAriaLabel"
1883
- ],
1884
- [
1885
- _dec6$2,
1886
- 1,
1887
- "variant"
1888
- ],
1889
- [
1890
- _dec7$2,
1891
- 1,
1892
- "size"
1893
- ],
1894
- [
1895
- _dec8$2,
1896
- 1,
1897
- "_inGroup"
1898
- ],
1899
- [
1900
- _dec9$2,
1901
- 1,
1902
- "_hasAvatar"
1903
- ],
1904
- [
1905
- _dec10$2,
1906
- 1,
1907
- "_hasIcon"
1908
- ],
1909
- [
1910
- _dec11$1,
1911
- 1,
1912
- "_hasTrailingIcon"
1913
- ]
1914
- ], [
1915
- _dec$2
1916
- ], _FocusableMixin));
1917
- }
1918
- static styles = css`${unsafeCSS(chipStyles)}`;
1919
- get _focusableElement() {
1920
- return this.shadowRoot?.querySelector('button') ?? null;
1921
- }
1922
- #___private_value_1 = (_initProto$2(this), _init_value$1(this, ''));
1923
- get value() {
1924
- return this.#___private_value_1;
1925
- }
1926
- set value(_v) {
1927
- this.#___private_value_1 = _v;
1928
- }
1929
- #___private_selected_2 = _init_selected(this, false);
1930
- get selected() {
1931
- return this.#___private_selected_2;
1932
- }
1933
- set selected(_v) {
1934
- this.#___private_selected_2 = _v;
1935
- }
1936
- #___private_disabled_3 = _init_disabled$1(this, false);
1937
- get disabled() {
1938
- return this.#___private_disabled_3;
1939
- }
1940
- set disabled(_v) {
1941
- this.#___private_disabled_3 = _v;
1942
- }
1943
- #___private_removable_4 = _init_removable(this, false);
1944
- get removable() {
1945
- return this.#___private_removable_4;
1946
- }
1947
- set removable(_v) {
1948
- this.#___private_removable_4 = _v;
1949
- }
1950
- #___private_removeAriaLabel_5 = _init_removeAriaLabel(this, 'Remove');
1951
- get removeAriaLabel() {
1952
- return this.#___private_removeAriaLabel_5;
1953
- }
1954
- set removeAriaLabel(_v) {
1955
- this.#___private_removeAriaLabel_5 = _v;
1956
- }
1957
- #___private_variant_6 = _init_variant(this, 'neutral');
1958
- get variant() {
1959
- return this.#___private_variant_6;
1960
- }
1961
- set variant(_v) {
1962
- this.#___private_variant_6 = _v;
1963
- }
1964
- #___private_size_7 = _init_size(this, 'md');
1965
- get size() {
1966
- return this.#___private_size_7;
1967
- }
1968
- set size(_v) {
1969
- this.#___private_size_7 = _v;
1970
- }
1971
- #___private__inGroup_8 = _init__inGroup(this, false);
1972
- get _inGroup() {
1973
- return this.#___private__inGroup_8;
1974
- }
1975
- set _inGroup(_v) {
1976
- this.#___private__inGroup_8 = _v;
1977
- }
1978
- #___private__hasAvatar_9 = _init__hasAvatar(this, false);
1979
- get _hasAvatar() {
1980
- return this.#___private__hasAvatar_9;
1981
- }
1982
- set _hasAvatar(_v) {
1983
- this.#___private__hasAvatar_9 = _v;
1984
- }
1985
- #___private__hasIcon_10 = _init__hasIcon(this, false);
1986
- get _hasIcon() {
1987
- return this.#___private__hasIcon_10;
1988
- }
1989
- set _hasIcon(_v) {
1990
- this.#___private__hasIcon_10 = _v;
1991
- }
1992
- #___private__hasTrailingIcon_11 = _init__hasTrailingIcon(this, false);
1993
- get _hasTrailingIcon() {
1994
- return this.#___private__hasTrailingIcon_11;
1995
- }
1996
- set _hasTrailingIcon(_v) {
1997
- this.#___private__hasTrailingIcon_11 = _v;
1998
- }
1999
- connectedCallback() {
2000
- super.connectedCallback();
2001
- this._inGroup = this.closest('vi-chip-group') !== null;
2002
- this._syncSlotsFromLightDom();
2003
- }
2004
- firstUpdated(changed) {
2005
- super.firstUpdated(changed);
2006
- this._syncSlots();
2007
- }
2008
- updated(changed) {
2009
- super.updated(changed);
2010
- if (changed.has('disabled')) {
2011
- if (this.disabled) {
2012
- this._setHostFocusable(false);
2013
- } else if (changed.get('disabled') !== undefined) {
2014
- this._setHostFocusable(true);
2015
- }
2016
- }
2017
- }
2018
- _syncSlotsFromLightDom() {
2019
- if (this.querySelector('[slot="avatar"]')) this._hasAvatar = true;
2020
- if (this.querySelector('[slot="icon"]')) this._hasIcon = true;
2021
- if (this.querySelector('[slot="trailing-icon"]')) this._hasTrailingIcon = true;
2022
- }
2023
- _syncSlots() {
2024
- const avatarSlot = this.shadowRoot?.querySelector('slot[name="avatar"]');
2025
- const iconSlot = this.shadowRoot?.querySelector('slot[name="icon"]');
2026
- const trailingSlot = this.shadowRoot?.querySelector('slot[name="trailing-icon"]');
2027
- if (avatarSlot) {
2028
- this._hasAvatar = avatarSlot.assignedElements({
2029
- flatten: true
2030
- }).length > 0;
2031
- }
2032
- if (iconSlot) {
2033
- this._hasIcon = iconSlot.assignedElements({
2034
- flatten: true
2035
- }).length > 0;
2036
- }
2037
- if (trailingSlot) {
2038
- this._hasTrailingIcon = trailingSlot.assignedElements({
2039
- flatten: true
2040
- }).length > 0;
2041
- }
2042
- }
2043
- onAvatarSlotChange(e) {
2044
- const slot = e.target;
2045
- this._hasAvatar = slot.assignedElements({
2046
- flatten: true
2047
- }).length > 0;
2048
- }
2049
- onIconSlotChange(e) {
2050
- const slot = e.target;
2051
- this._hasIcon = slot.assignedElements({
2052
- flatten: true
2053
- }).length > 0;
2054
- }
2055
- onTrailingIconSlotChange(e) {
2056
- const slot = e.target;
2057
- this._hasTrailingIcon = slot.assignedElements({
2058
- flatten: true
2059
- }).length > 0;
2060
- }
2061
- _handleSelect(e) {
2062
- if (this.disabled) {
2063
- e.preventDefault();
2064
- e.stopImmediatePropagation();
2065
- return;
2066
- }
2067
- this.dispatchEvent(new CustomEvent('vialiq-select', {
2068
- detail: {
2069
- value: this.value,
2070
- selected: !this.selected
2071
- },
2072
- bubbles: true,
2073
- composed: true
2074
- }));
2075
- }
2076
- _handleRemove(e) {
2077
- if (this.disabled) {
2078
- e.preventDefault();
2079
- e.stopImmediatePropagation();
2080
- return;
2081
- }
2082
- e.stopPropagation();
2083
- this.dispatchEvent(new CustomEvent('vialiq-remove', {
2084
- detail: {
2085
- value: this.value
2086
- },
2087
- bubbles: true,
2088
- composed: true
2089
- }));
2090
- }
2091
- _handleKeyDown(e) {
2092
- if (this.disabled) return;
2093
- if (e.key === 'Enter' || e.key === ' ') {
2094
- e.preventDefault();
2095
- this._handleSelect(e);
2096
- } else if (this.removable && (e.key === 'Backspace' || e.key === 'Delete')) {
2097
- e.preventDefault();
2098
- this._handleRemove(e);
2099
- }
2100
- }
2101
- render() {
2102
- const role = this._inGroup ? 'option' : 'button';
2103
- const ariaSelected = this._inGroup ? this.selected ? 'true' : 'false' : null;
2104
- const ariaPressed = !this._inGroup ? this.selected ? 'true' : 'false' : null;
2105
- return html`
2106
- <button
2107
- part="chip"
2108
- type="button"
2109
- role=${role}
2110
- aria-selected=${ariaSelected ?? undefined}
2111
- aria-pressed=${ariaPressed ?? undefined}
2112
- aria-disabled=${this.disabled ? 'true' : 'false'}
2113
- tabindex=${this.disabled ? -1 : 0}
2114
- @click=${this._handleSelect}
2115
- @keydown=${this._handleKeyDown}
2116
- >
2117
- <slot name="avatar" class="chip-avatar" @slotchange=${this.onAvatarSlotChange} ?hidden=${!this._hasAvatar}></slot>
2118
- <slot name="icon" class="chip-icon" @slotchange=${this.onIconSlotChange} ?hidden=${this._hasAvatar || !this._hasIcon}></slot>
2119
-
2120
- ${this.selected ? html`<vi-icon part="check-icon" name="check" size="12"></vi-icon>` : ''}
2121
-
2122
- <span part="label" class="chip-label">
2123
- <slot></slot>
2124
- </span>
2125
-
2126
- <slot name="trailing-icon" @slotchange=${this.onTrailingIconSlotChange} ?hidden=${!this._hasTrailingIcon}></slot>
2127
-
2128
- ${this.removable ? html`
2129
- <vi-button
2130
- part="remove-btn"
2131
- variant="ghost"
2132
- size="xs"
2133
- icon-only
2134
- aria-label=${this.removeAriaLabel || 'Remove'}
2135
- @click=${this._handleRemove}
2136
- tabindex=${this.disabled ? -1 : 0}
2137
- >
2138
- <vi-icon name="x" size="12" slot="icon"></vi-icon>
2139
- </vi-button>
2140
- ` : ''}
2141
- </button>
2142
- `;
2143
- }
2144
- }
2145
- }
2146
- }();
2147
-
2148
- const groupStyles = ":host{display:block}:host([hidden]){display:none!important}[part=group]{display:flex;align-items:center}";
2149
-
2150
- function applyDecs2203RFactory$1() {
2151
- function createAddInitializerMethod(initializers, decoratorFinishedRef) {
2152
- return function addInitializer(initializer) {
2153
- assertNotFinished(decoratorFinishedRef, "addInitializer");
2154
- assertCallable(initializer, "An initializer");
2155
- initializers.push(initializer);
2156
- };
2157
- }
2158
- function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
2159
- var kindStr;
2160
- switch(kind){
2161
- case 1:
2162
- kindStr = "accessor";
2163
- break;
2164
- case 2:
2165
- kindStr = "method";
2166
- break;
2167
- case 3:
2168
- kindStr = "getter";
2169
- break;
2170
- case 4:
2171
- kindStr = "setter";
2172
- break;
2173
- default:
2174
- kindStr = "field";
2175
- }
2176
- var ctx = {
2177
- kind: kindStr,
2178
- name: isPrivate ? "#" + name : name,
2179
- static: isStatic,
2180
- private: isPrivate,
2181
- metadata: metadata
2182
- };
2183
- var decoratorFinishedRef = {
2184
- v: false
2185
- };
2186
- ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
2187
- var get, set;
2188
- if (kind === 0) {
2189
- if (isPrivate) {
2190
- get = desc.get;
2191
- set = desc.set;
2192
- } else {
2193
- get = function() {
2194
- return this[name];
2195
- };
2196
- set = function(v) {
2197
- this[name] = v;
2198
- };
2199
- }
2200
- } else if (kind === 2) {
2201
- get = function() {
2202
- return desc.value;
2203
- };
2204
- } else {
2205
- if (kind === 1 || kind === 3) {
2206
- get = function() {
2207
- return desc.get.call(this);
2208
- };
2209
- }
2210
- if (kind === 1 || kind === 4) {
2211
- set = function(v) {
2212
- desc.set.call(this, v);
2213
- };
2214
- }
2215
- }
2216
- ctx.access = get && set ? {
2217
- get: get,
2218
- set: set
2219
- } : get ? {
2220
- get: get
2221
- } : {
2222
- set: set
2223
- };
2224
- try {
2225
- return dec(value, ctx);
2226
- } finally{
2227
- decoratorFinishedRef.v = true;
2228
- }
2229
- }
2230
- function assertNotFinished(decoratorFinishedRef, fnName) {
2231
- if (decoratorFinishedRef.v) {
2232
- throw new Error("attempted to call " + fnName + " after decoration was finished");
2233
- }
2234
- }
2235
- function assertCallable(fn, hint) {
2236
- if (typeof fn !== "function") {
2237
- throw new TypeError(hint + " must be a function");
2238
- }
2239
- }
2240
- function assertValidReturnValue(kind, value) {
2241
- var type = typeof value;
2242
- if (kind === 1) {
2243
- if (type !== "object" || value === null) {
2244
- throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
2245
- }
2246
- if (value.get !== undefined) {
2247
- assertCallable(value.get, "accessor.get");
2248
- }
2249
- if (value.set !== undefined) {
2250
- assertCallable(value.set, "accessor.set");
2251
- }
2252
- if (value.init !== undefined) {
2253
- assertCallable(value.init, "accessor.init");
2254
- }
2255
- } else if (type !== "function") {
2256
- var hint;
2257
- if (kind === 0) {
2258
- hint = "field";
2259
- } else if (kind === 10) {
2260
- hint = "class";
2261
- } else {
2262
- hint = "method";
2263
- }
2264
- throw new TypeError(hint + " decorators must return a function or void 0");
2265
- }
2266
- }
2267
- function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
2268
- var decs = decInfo[0];
2269
- var desc, init, value;
2270
- if (isPrivate) {
2271
- if (kind === 0 || kind === 1) {
2272
- desc = {
2273
- get: decInfo[3],
2274
- set: decInfo[4]
2275
- };
2276
- } else if (kind === 3) {
2277
- desc = {
2278
- get: decInfo[3]
2279
- };
2280
- } else if (kind === 4) {
2281
- desc = {
2282
- set: decInfo[3]
2283
- };
2284
- } else {
2285
- desc = {
2286
- value: decInfo[3]
2287
- };
2288
- }
2289
- } else if (kind !== 0) {
2290
- desc = Object.getOwnPropertyDescriptor(base, name);
2291
- }
2292
- if (kind === 1) {
2293
- value = {
2294
- get: desc.get,
2295
- set: desc.set
2296
- };
2297
- } else if (kind === 2) {
2298
- value = desc.value;
2299
- } else if (kind === 3) {
2300
- value = desc.get;
2301
- } else if (kind === 4) {
2302
- value = desc.set;
2303
- }
2304
- var newValue, get, set;
2305
- if (typeof decs === "function") {
2306
- newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
2307
- if (newValue !== void 0) {
2308
- assertValidReturnValue(kind, newValue);
2309
- if (kind === 0) {
2310
- init = newValue;
2311
- } else if (kind === 1) {
2312
- init = newValue.init;
2313
- get = newValue.get || value.get;
2314
- set = newValue.set || value.set;
2315
- value = {
2316
- get: get,
2317
- set: set
2318
- };
2319
- } else {
2320
- value = newValue;
2321
- }
2322
- }
2323
- } else {
2324
- for(var i = decs.length - 1; i >= 0; i--){
2325
- var dec = decs[i];
2326
- newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
2327
- if (newValue !== void 0) {
2328
- assertValidReturnValue(kind, newValue);
2329
- var newInit;
2330
- if (kind === 0) {
2331
- newInit = newValue;
2332
- } else if (kind === 1) {
2333
- newInit = newValue.init;
2334
- get = newValue.get || value.get;
2335
- set = newValue.set || value.set;
2336
- value = {
2337
- get: get,
2338
- set: set
2339
- };
2340
- } else {
2341
- value = newValue;
2342
- }
2343
- if (newInit !== void 0) {
2344
- if (init === void 0) {
2345
- init = newInit;
2346
- } else if (typeof init === "function") {
2347
- init = [
2348
- init,
2349
- newInit
2350
- ];
2351
- } else {
2352
- init.push(newInit);
2353
- }
2354
- }
2355
- }
2356
- }
2357
- }
2358
- if (kind === 0 || kind === 1) {
2359
- if (init === void 0) {
2360
- init = function(instance, init) {
2361
- return init;
2362
- };
2363
- } else if (typeof init !== "function") {
2364
- var ownInitializers = init;
2365
- init = function(instance, init) {
2366
- var value = init;
2367
- for(var i = 0; i < ownInitializers.length; i++){
2368
- value = ownInitializers[i].call(instance, value);
2369
- }
2370
- return value;
2371
- };
2372
- } else {
2373
- var originalInitializer = init;
2374
- init = function(instance, init) {
2375
- return originalInitializer.call(instance, init);
2376
- };
2377
- }
2378
- ret.push(init);
2379
- }
2380
- if (kind !== 0) {
2381
- if (kind === 1) {
2382
- desc.get = value.get;
2383
- desc.set = value.set;
2384
- } else if (kind === 2) {
2385
- desc.value = value;
2386
- } else if (kind === 3) {
2387
- desc.get = value;
2388
- } else if (kind === 4) {
2389
- desc.set = value;
2390
- }
2391
- if (isPrivate) {
2392
- if (kind === 1) {
2393
- ret.push(function(instance, args) {
2394
- return value.get.call(instance, args);
2395
- });
2396
- ret.push(function(instance, args) {
2397
- return value.set.call(instance, args);
2398
- });
2399
- } else if (kind === 2) {
2400
- ret.push(value);
2401
- } else {
2402
- ret.push(function(instance, args) {
2403
- return value.call(instance, args);
2404
- });
2405
- }
2406
- } else {
2407
- Object.defineProperty(base, name, desc);
2408
- }
2409
- }
2410
- }
2411
- function applyMemberDecs(Class, decInfos, metadata) {
2412
- var ret = [];
2413
- var protoInitializers;
2414
- var staticInitializers;
2415
- var existingProtoNonFields = new Map();
2416
- var existingStaticNonFields = new Map();
2417
- for(var i = 0; i < decInfos.length; i++){
2418
- var decInfo = decInfos[i];
2419
- if (!Array.isArray(decInfo)) continue;
2420
- var kind = decInfo[1];
2421
- var name = decInfo[2];
2422
- var isPrivate = decInfo.length > 3;
2423
- var isStatic = kind >= 5;
2424
- var base;
2425
- var initializers;
2426
- if (isStatic) {
2427
- base = Class;
2428
- kind = kind - 5;
2429
- staticInitializers = staticInitializers || [];
2430
- initializers = staticInitializers;
2431
- } else {
2432
- base = Class.prototype;
2433
- protoInitializers = protoInitializers || [];
2434
- initializers = protoInitializers;
2435
- }
2436
- if (kind !== 0 && !isPrivate) {
2437
- var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
2438
- var existingKind = existingNonFields.get(name) || 0;
2439
- if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
2440
- 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);
2441
- } else if (!existingKind && kind > 2) {
2442
- existingNonFields.set(name, kind);
2443
- } else {
2444
- existingNonFields.set(name, true);
2445
- }
2446
- }
2447
- applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
2448
- }
2449
- pushInitializers(ret, protoInitializers);
2450
- pushInitializers(ret, staticInitializers);
2451
- return ret;
2452
- }
2453
- function pushInitializers(ret, initializers) {
2454
- if (initializers) {
2455
- ret.push(function(instance) {
2456
- for(var i = 0; i < initializers.length; i++){
2457
- initializers[i].call(instance);
2458
- }
2459
- return instance;
2460
- });
2461
- }
2462
- }
2463
- function applyClassDecs(targetClass, classDecs, metadata) {
2464
- if (classDecs.length > 0) {
2465
- var initializers = [];
2466
- var newClass = targetClass;
2467
- var name = targetClass.name;
2468
- for(var i = classDecs.length - 1; i >= 0; i--){
2469
- var decoratorFinishedRef = {
2470
- v: false
2471
- };
2472
- try {
2473
- var nextNewClass = classDecs[i](newClass, {
2474
- kind: "class",
2475
- name: name,
2476
- addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
2477
- metadata
2478
- });
2479
- } finally{
2480
- decoratorFinishedRef.v = true;
2481
- }
2482
- if (nextNewClass !== undefined) {
2483
- assertValidReturnValue(10, nextNewClass);
2484
- newClass = nextNewClass;
2485
- }
2486
- }
2487
- return [
2488
- defineMetadata(newClass, metadata),
2489
- function() {
2490
- for(var i = 0; i < initializers.length; i++){
2491
- initializers[i].call(newClass);
2492
- }
2493
- }
2494
- ];
2495
- }
2496
- }
2497
- function defineMetadata(Class, metadata) {
2498
- return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
2499
- configurable: true,
2500
- enumerable: true,
2501
- value: metadata
2502
- });
2503
- }
2504
- return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
2505
- if (parentClass !== void 0) {
2506
- var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
2507
- }
2508
- var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
2509
- var e = applyMemberDecs(targetClass, memberDecs, metadata);
2510
- if (!classDecs.length) defineMetadata(targetClass, metadata);
2511
- return {
2512
- e: e,
2513
- get c () {
2514
- return applyClassDecs(targetClass, classDecs, metadata);
2515
- }
2516
- };
2517
- };
2518
- }
2519
- function _apply_decs_2203_r$1(targetClass, memberDecs, classDecs, parentClass) {
2520
- return (_apply_decs_2203_r$1 = applyDecs2203RFactory$1())(targetClass, memberDecs, classDecs, parentClass);
2521
- }
2522
- function _identity$1(x) {
2523
- return x;
2524
- }
2525
- var _dec$1, _initClass$1, _ValidityMixin, _dec1$1, _dec2$1, _dec3$1, _dec4$1, _dec5$1, _dec6$1, _dec7$1, _dec8$1, _dec9$1, _dec10$1, /** Currently selected chip values. */ _init_value, /** Allow multiple selections. */ _init_multi, /** Form field name. */ _init_name$1, /** At least one chip must be selected. */ _init_required, /** Disable all chips. */ _init_disabled, /** Chips wrap to next line. */ _init_wrap, /** Gap between chips. */ _init_gap, // ValidityMixin requirements
2526
- _init_status, _init_validityMessage, _init__chips, _initProto$1;
2527
- let _ViChipGroup;
2528
- _dec$1 = customElement('vi-chip-group'), _dec1$1 = property({
2529
- type: Array
2530
- }), _dec2$1 = property({
2531
- type: Boolean
2532
- }), _dec3$1 = property({
2533
- type: String
2534
- }), _dec4$1 = property({
2535
- type: Boolean,
2536
- reflect: true
2537
- }), _dec5$1 = property({
2538
- type: Boolean,
2539
- reflect: true
2540
- }), _dec6$1 = property({
2541
- type: Boolean
2542
- }), _dec7$1 = property({
2543
- type: String
2544
- }), _dec8$1 = property({
2545
- reflect: true
2546
- }), _dec9$1 = property(), _dec10$1 = queryAssignedElements({
2547
- selector: 'vi-chip'
2548
- });
2549
- new class extends _identity$1 {
2550
- constructor(){
2551
- super(_ViChipGroup), _initClass$1();
2552
- }
2553
- static{
2554
- class ViChipGroup extends (_ValidityMixin = ValidityMixin(ViElement)) {
2555
- static{
2556
- ({ e: [_init_value, _init_multi, _init_name$1, _init_required, _init_disabled, _init_wrap, _init_gap, _init_status, _init_validityMessage, _init__chips, _initProto$1], c: [_ViChipGroup, _initClass$1] } = _apply_decs_2203_r$1(this, [
2557
- [
2558
- _dec1$1,
2559
- 1,
2560
- "value"
2561
- ],
2562
- [
2563
- _dec2$1,
2564
- 1,
2565
- "multi"
2566
- ],
2567
- [
2568
- _dec3$1,
2569
- 1,
2570
- "name"
2571
- ],
2572
- [
2573
- _dec4$1,
2574
- 1,
2575
- "required"
2576
- ],
2577
- [
2578
- _dec5$1,
2579
- 1,
2580
- "disabled"
2581
- ],
2582
- [
2583
- _dec6$1,
2584
- 1,
2585
- "wrap"
2586
- ],
2587
- [
2588
- _dec7$1,
2589
- 1,
2590
- "gap"
2591
- ],
2592
- [
2593
- _dec8$1,
2594
- 1,
2595
- "status"
2596
- ],
2597
- [
2598
- _dec9$1,
2599
- 1,
2600
- "validityMessage"
2601
- ],
2602
- [
2603
- _dec10$1,
2604
- 1,
2605
- "_chips"
2606
- ]
2607
- ], [
2608
- _dec$1
2609
- ], _ValidityMixin));
2610
- }
2611
- static styles = css`${unsafeCSS(groupStyles)}`;
2612
- #___private_value_1 = (_initProto$1(this), _init_value(this, []));
2613
- get value() {
2614
- return this.#___private_value_1;
2615
- }
2616
- set value(_v) {
2617
- this.#___private_value_1 = _v;
2618
- }
2619
- #___private_multi_2 = _init_multi(this, true);
2620
- get multi() {
2621
- return this.#___private_multi_2;
2622
- }
2623
- set multi(_v) {
2624
- this.#___private_multi_2 = _v;
2625
- }
2626
- #___private_name_3 = _init_name$1(this, '');
2627
- get name() {
2628
- return this.#___private_name_3;
2629
- }
2630
- set name(_v) {
2631
- this.#___private_name_3 = _v;
2632
- }
2633
- #___private_required_4 = _init_required(this, false);
2634
- get required() {
2635
- return this.#___private_required_4;
2636
- }
2637
- set required(_v) {
2638
- this.#___private_required_4 = _v;
2639
- }
2640
- #___private_disabled_5 = _init_disabled(this, false);
2641
- get disabled() {
2642
- return this.#___private_disabled_5;
2643
- }
2644
- set disabled(_v) {
2645
- this.#___private_disabled_5 = _v;
2646
- }
2647
- #___private_wrap_6 = _init_wrap(this, true);
2648
- get wrap() {
2649
- return this.#___private_wrap_6;
2650
- }
2651
- set wrap(_v) {
2652
- this.#___private_wrap_6 = _v;
2653
- }
2654
- #___private_gap_7 = _init_gap(this, '8px');
2655
- get gap() {
2656
- return this.#___private_gap_7;
2657
- }
2658
- set gap(_v) {
2659
- this.#___private_gap_7 = _v;
2660
- }
2661
- #___private_status_8 = _init_status(this, 'default');
2662
- get status() {
2663
- return this.#___private_status_8;
2664
- }
2665
- set status(_v) {
2666
- this.#___private_status_8 = _v;
2667
- }
2668
- #___private_validityMessage_9 = _init_validityMessage(this, '');
2669
- get validityMessage() {
2670
- return this.#___private_validityMessage_9;
2671
- }
2672
- set validityMessage(_v) {
2673
- this.#___private_validityMessage_9 = _v;
2674
- }
2675
- #___private__chips_10 = _init__chips(this);
2676
- get _chips() {
2677
- return this.#___private__chips_10;
2678
- }
2679
- set _chips(_v) {
2680
- this.#___private__chips_10 = _v;
2681
- }
2682
- _mutationObserver;
2683
- constructor(){
2684
- super();
2685
- this._mutationObserver = new MutationObserver(()=>this._syncChips());
2686
- this.addEventListener('vialiq-select', this._handleChipSelect);
2687
- }
2688
- connectedCallback() {
2689
- super.connectedCallback();
2690
- this._syncInternals();
2691
- }
2692
- disconnectedCallback() {
2693
- super.disconnectedCallback();
2694
- this._mutationObserver.disconnect();
2695
- }
2696
- updated(changed) {
2697
- super.updated(changed);
2698
- if (changed.has('value')) {
2699
- this._syncInternals();
2700
- this._syncChips();
2701
- }
2702
- if (changed.has('disabled')) {
2703
- this._syncChips();
2704
- }
2705
- }
2706
- formResetCallback() {
2707
- this.value = [];
2708
- this.status = 'default';
2709
- this.validityMessage = '';
2710
- }
2711
- formDisabledCallback(disabled) {
2712
- this.disabled = disabled;
2713
- }
2714
- _testValidity() {
2715
- if (this.required && this.value.length === 0) {
2716
- return {
2717
- valueMissing: true
2718
- };
2719
- }
2720
- return {};
2721
- }
2722
- /** Selects all available child chips (if multi is true) */ selectAll() {
2723
- if (!this.multi) return;
2724
- this.value = this._chips.map((chip)=>chip.value).filter((val)=>val !== undefined);
2725
- this.dispatchEvent(new CustomEvent('vialiq-change', {
2726
- detail: {
2727
- value: this.value
2728
- },
2729
- bubbles: true,
2730
- composed: true
2731
- }));
2732
- }
2733
- /** Deselects all child chips */ clearAll() {
2734
- this.value = [];
2735
- this.dispatchEvent(new CustomEvent('vialiq-change', {
2736
- detail: {
2737
- value: this.value
2738
- },
2739
- bubbles: true,
2740
- composed: true
2741
- }));
2742
- }
2743
- _syncInternals() {
2744
- const formData = new FormData();
2745
- this.value.forEach((val)=>formData.append(this.name, val));
2746
- this._internals.setFormValue(formData);
2747
- }
2748
- _syncChips() {
2749
- if (!this._chips) return;
2750
- let hasFocusable = false;
2751
- this._chips.forEach((chip)=>{
2752
- chip.selected = this.value.includes(chip.value);
2753
- if (this.disabled) {
2754
- chip.disabled = true;
2755
- } else {
2756
- chip.disabled = chip.hasAttribute('disabled');
2757
- }
2758
- // Roving tabindex: Only the first selected chip (or the first chip if none selected) is focusable
2759
- if (!chip.disabled && (chip.selected || !hasFocusable && this.value.length === 0)) {
2760
- chip.tabIndex = 0;
2761
- hasFocusable = true;
2762
- } else {
2763
- chip.tabIndex = -1;
2764
- }
2765
- });
2766
- // If no chip was focusable yet (e.g. none selected), make the first non-disabled chip focusable
2767
- if (!hasFocusable && this._chips.length > 0) {
2768
- const firstEnabled = this._chips.find((c)=>!c.disabled);
2769
- if (firstEnabled) firstEnabled.tabIndex = 0;
2770
- }
2771
- }
2772
- _handleSlotChange() {
2773
- this._syncChips();
2774
- // Disconnect old, connect new observers for child mutations
2775
- this._mutationObserver.disconnect();
2776
- this._chips.forEach((chip)=>{
2777
- this._mutationObserver.observe(chip, {
2778
- attributes: true,
2779
- attributeFilter: [
2780
- 'value',
2781
- 'disabled'
2782
- ]
2783
- });
2784
- });
2785
- }
2786
- _handleChipSelect(e) {
2787
- e.stopPropagation(); // Stop the inner event
2788
- const { value, selected } = e.detail;
2789
- let newValue = [
2790
- ...this.value
2791
- ];
2792
- if (this.multi) {
2793
- if (selected) {
2794
- if (!newValue.includes(value)) newValue.push(value);
2795
- } else {
2796
- newValue = newValue.filter((v)=>v !== value);
2797
- }
2798
- } else {
2799
- if (selected) {
2800
- newValue = [
2801
- value
2802
- ];
2803
- } else {
2804
- // In single select, clicking a selected chip could deselect it depending on requirements.
2805
- // Assuming it toggles.
2806
- newValue = [];
2807
- }
2808
- }
2809
- this.value = newValue;
2810
- this.dispatchEvent(new CustomEvent('vialiq-change', {
2811
- detail: {
2812
- value: this.value
2813
- },
2814
- bubbles: true,
2815
- composed: true
2816
- }));
2817
- }
2818
- _handleKeyDown(e) {
2819
- const focusableChips = this._chips.filter((c)=>!c.disabled);
2820
- if (focusableChips.length === 0) return;
2821
- const currentIndex = focusableChips.findIndex((c)=>c === document.activeElement || c.shadowRoot?.activeElement);
2822
- if (currentIndex === -1) return;
2823
- let nextIndex = currentIndex;
2824
- switch(e.key){
2825
- case 'ArrowRight':
2826
- case 'ArrowDown':
2827
- e.preventDefault();
2828
- nextIndex = (currentIndex + 1) % focusableChips.length;
2829
- break;
2830
- case 'ArrowLeft':
2831
- case 'ArrowUp':
2832
- e.preventDefault();
2833
- nextIndex = (currentIndex - 1 + focusableChips.length) % focusableChips.length;
2834
- break;
2835
- case 'Home':
2836
- e.preventDefault();
2837
- nextIndex = 0;
2838
- break;
2839
- case 'End':
2840
- e.preventDefault();
2841
- nextIndex = focusableChips.length - 1;
2842
- break;
2843
- default:
2844
- return; // Let other keys do their thing
2845
- }
2846
- this._chips.forEach((c)=>c.tabIndex = -1);
2847
- const nextChip = focusableChips[nextIndex];
2848
- nextChip.tabIndex = 0;
2849
- nextChip.focus();
2850
- }
2851
- render() {
2852
- const style = `gap: ${this.gap}; flex-wrap: ${this.wrap ? 'wrap' : 'nowrap'};`;
2853
- return html`
2854
- <div
2855
- part="group"
2856
- role="listbox"
2857
- aria-multiselectable=${this.multi ? 'true' : 'false'}
2858
- aria-required=${this.required ? 'true' : 'false'}
2859
- aria-disabled=${this.disabled ? 'true' : 'false'}
2860
- style=${style}
2861
- @keydown=${this._handleKeyDown}
2862
- >
2863
- <slot @slotchange=${this._handleSlotChange}></slot>
2864
- </div>
2865
- `;
2866
- }
2867
- }
2868
- }
2869
- }();
2870
-
2871
- const animationStyles = "@charset \"UTF-8\";@layer reset,components,utilities;:root{--vi-animation-duration-fast: .15s;--vi-animation-duration-base: .3s;--vi-animation-duration-slow: .5s;--vi-animation-easing-standard: cubic-bezier(.2, 0, 0, 1);--vi-animation-easing-entrance: cubic-bezier(0, 0, .2, 1);--vi-animation-easing-exit: cubic-bezier(.4, 0, 1, 1);--vi-animation-easing-bounce: cubic-bezier(.34, 1.56, .64, 1);--vi-animation-expand-max-height: 100vh;--vi-animation-expand-max-width: 100vw}@keyframes vi-fade-in{0%{opacity:0}to{opacity:1}}@keyframes vi-fade-out{0%{opacity:1}to{opacity:0}}@keyframes vi-fade-in-up{0%{opacity:0;transform:translate3d(0,1rem,0)}to{opacity:1;transform:translateZ(0)}}@keyframes vi-fade-in-down{0%{opacity:0;transform:translate3d(0,-1rem,0)}to{opacity:1;transform:translateZ(0)}}@keyframes vi-fade-in-left{0%{opacity:0;transform:translate3d(-1rem,0,0)}to{opacity:1;transform:translateZ(0)}}@keyframes vi-fade-in-right{0%{opacity:0;transform:translate3d(1rem,0,0)}to{opacity:1;transform:translateZ(0)}}@keyframes vi-fade-out-up{0%{opacity:1;transform:translateZ(0)}to{opacity:0;transform:translate3d(0,-1rem,0)}}@keyframes vi-fade-out-down{0%{opacity:1;transform:translateZ(0)}to{opacity:0;transform:translate3d(0,1rem,0)}}@keyframes vi-fade-out-left{0%{opacity:1;transform:translateZ(0)}to{opacity:0;transform:translate3d(-1rem,0,0)}}@keyframes vi-fade-out-right{0%{opacity:1;transform:translateZ(0)}to{opacity:0;transform:translate3d(1rem,0,0)}}@keyframes vi-zoom-in{0%{opacity:0;transform:scale3d(.92,.92,.92)}to{opacity:1;transform:scaleZ(1)}}@keyframes vi-zoom-out{0%{opacity:1;transform:scaleZ(1)}to{opacity:0;transform:scale3d(.92,.92,.92)}}@keyframes vi-scale-up{0%{transform:scale3d(.8,.8,.8)}to{transform:scaleZ(1)}}@keyframes vi-scale-down{0%{transform:scale3d(1.2,1.2,1.2)}to{transform:scaleZ(1)}}@keyframes vi-bounce-in{0%{opacity:0;transform:scale3d(.3,.3,.3)}50%{opacity:.9;transform:scale3d(1.08,1.08,1.08)}75%{transform:scale3d(.95,.95,.95)}to{opacity:1;transform:scaleZ(1)}}@keyframes vi-bounce-out{0%{opacity:1;transform:scaleZ(1)}20%{transform:scale3d(.9,.9,.9)}50%{opacity:1;transform:scale3d(1.1,1.1,1.1)}to{opacity:0;transform:scale3d(.3,.3,.3)}}@keyframes vi-pop-in{0%{opacity:0;transform:scale3d(.8,.8,1)}70%{transform:scale3d(1.05,1.05,1)}to{opacity:1;transform:scaleZ(1)}}@keyframes vi-pop-out{0%{opacity:1;transform:scaleZ(1)}to{opacity:0;transform:scale3d(.8,.8,1)}}@keyframes vi-slide-in-top{0%{transform:translate3d(0,-100%,0)}to{transform:translateZ(0)}}@keyframes vi-slide-in-bottom{0%{transform:translate3d(0,100%,0)}to{transform:translateZ(0)}}@keyframes vi-slide-in-left{0%{transform:translate3d(-100%,0,0)}to{transform:translateZ(0)}}@keyframes vi-slide-in-right{0%{transform:translate3d(100%,0,0)}to{transform:translateZ(0)}}@keyframes vi-slide-out-top{0%{transform:translateZ(0)}to{transform:translate3d(0,-100%,0)}}@keyframes vi-slide-out-bottom{0%{transform:translateZ(0)}to{transform:translate3d(0,100%,0)}}@keyframes vi-slide-out-left{0%{transform:translateZ(0)}to{transform:translate3d(-100%,0,0)}}@keyframes vi-slide-out-right{0%{transform:translateZ(0)}to{transform:translate3d(100%,0,0)}}@keyframes vi-flip-x{0%{transform:perspective(400px) rotateX(90deg);opacity:0}to{transform:perspective(400px) rotateX(0);opacity:1}}@keyframes vi-flip-y{0%{transform:perspective(400px) rotateY(90deg);opacity:0}to{transform:perspective(400px) rotateY(0);opacity:1}}@keyframes vi-perspective-pop{0%{transform:perspective(600px) translateZ(-100px);opacity:0}to{transform:perspective(600px) translateZ(0);opacity:1}}@keyframes vi-expand-vertical{0%{max-height:0;opacity:0}to{max-height:var(--vi-animation-expand-max-height, 100vh);opacity:1}}@keyframes vi-collapse-vertical{0%{max-height:var(--vi-animation-expand-max-height, 100vh);opacity:1}to{max-height:0;opacity:0}}@keyframes vi-expand-horizontal{0%{max-width:0;opacity:0}to{max-width:var(--vi-animation-expand-max-width, 100vw);opacity:1}}@keyframes vi-collapse-horizontal{0%{max-width:var(--vi-animation-expand-max-width, 100vw);opacity:1}to{max-width:0;opacity:0}}@keyframes vi-pulse{0%{transform:scaleZ(1)}50%{transform:scale3d(1.05,1.05,1.05)}to{transform:scaleZ(1)}}@keyframes vi-bounce{0%,20%,53%,80%,to{transform:translateZ(0)}40%,43%{transform:translate3d(0,-12px,0)}70%{transform:translate3d(0,-6px,0)}90%{transform:translate3d(0,-2px,0)}}@keyframes vi-shake{0%,to{transform:translateZ(0)}10%,30%,50%,70%,90%{transform:translate3d(-4px,0,0)}20%,40%,60%,80%{transform:translate3d(4px,0,0)}}@keyframes vi-wobble{0%,to{transform:translateZ(0) rotate(0)}15%{transform:translate3d(-15%,0,0) rotate(-4deg)}30%{transform:translate3d(12%,0,0) rotate(3deg)}45%{transform:translate3d(-9%,0,0) rotate(-2deg)}60%{transform:translate3d(6%,0,0) rotate(1deg)}75%{transform:translate3d(-3%,0,0) rotate(-1deg)}}@keyframes vi-heartbeat{0%{transform:scale(1)}14%{transform:scale(1.15)}28%{transform:scale(1)}42%{transform:scale(1.15)}70%{transform:scale(1)}}@keyframes vi-shimmer{0%{background-position:-200% 0}to{background-position:200% 0}}:host{display:contents}:host([hidden]){display:none!important}";
2872
-
2873
- function applyDecs2203RFactory() {
2874
- function createAddInitializerMethod(initializers, decoratorFinishedRef) {
2875
- return function addInitializer(initializer) {
2876
- assertNotFinished(decoratorFinishedRef, "addInitializer");
2877
- assertCallable(initializer, "An initializer");
2878
- initializers.push(initializer);
2879
- };
2880
- }
2881
- function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
2882
- var kindStr;
2883
- switch(kind){
2884
- case 1:
2885
- kindStr = "accessor";
2886
- break;
2887
- case 2:
2888
- kindStr = "method";
2889
- break;
2890
- case 3:
2891
- kindStr = "getter";
2892
- break;
2893
- case 4:
2894
- kindStr = "setter";
2895
- break;
2896
- default:
2897
- kindStr = "field";
2898
- }
2899
- var ctx = {
2900
- kind: kindStr,
2901
- name: isPrivate ? "#" + name : name,
2902
- static: isStatic,
2903
- private: isPrivate,
2904
- metadata: metadata
2905
- };
2906
- var decoratorFinishedRef = {
2907
- v: false
2908
- };
2909
- ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
2910
- var get, set;
2911
- if (kind === 0) {
2912
- if (isPrivate) {
2913
- get = desc.get;
2914
- set = desc.set;
2915
- } else {
2916
- get = function() {
2917
- return this[name];
2918
- };
2919
- set = function(v) {
2920
- this[name] = v;
2921
- };
2922
- }
2923
- } else if (kind === 2) {
2924
- get = function() {
2925
- return desc.value;
2926
- };
2927
- } else {
2928
- if (kind === 1 || kind === 3) {
2929
- get = function() {
2930
- return desc.get.call(this);
2931
- };
2932
- }
2933
- if (kind === 1 || kind === 4) {
2934
- set = function(v) {
2935
- desc.set.call(this, v);
2936
- };
2937
- }
2938
- }
2939
- ctx.access = get && set ? {
2940
- get: get,
2941
- set: set
2942
- } : get ? {
2943
- get: get
2944
- } : {
2945
- set: set
2946
- };
2947
- try {
2948
- return dec(value, ctx);
2949
- } finally{
2950
- decoratorFinishedRef.v = true;
2951
- }
2952
- }
2953
- function assertNotFinished(decoratorFinishedRef, fnName) {
2954
- if (decoratorFinishedRef.v) {
2955
- throw new Error("attempted to call " + fnName + " after decoration was finished");
2956
- }
2957
- }
2958
- function assertCallable(fn, hint) {
2959
- if (typeof fn !== "function") {
2960
- throw new TypeError(hint + " must be a function");
2961
- }
2962
- }
2963
- function assertValidReturnValue(kind, value) {
2964
- var type = typeof value;
2965
- if (kind === 1) {
2966
- if (type !== "object" || value === null) {
2967
- throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
2968
- }
2969
- if (value.get !== undefined) {
2970
- assertCallable(value.get, "accessor.get");
2971
- }
2972
- if (value.set !== undefined) {
2973
- assertCallable(value.set, "accessor.set");
2974
- }
2975
- if (value.init !== undefined) {
2976
- assertCallable(value.init, "accessor.init");
2977
- }
2978
- } else if (type !== "function") {
2979
- var hint;
2980
- if (kind === 0) {
2981
- hint = "field";
2982
- } else if (kind === 10) {
2983
- hint = "class";
2984
- } else {
2985
- hint = "method";
2986
- }
2987
- throw new TypeError(hint + " decorators must return a function or void 0");
2988
- }
2989
- }
2990
- function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
2991
- var decs = decInfo[0];
2992
- var desc, init, value;
2993
- if (isPrivate) {
2994
- if (kind === 0 || kind === 1) {
2995
- desc = {
2996
- get: decInfo[3],
2997
- set: decInfo[4]
2998
- };
2999
- } else if (kind === 3) {
3000
- desc = {
3001
- get: decInfo[3]
3002
- };
3003
- } else if (kind === 4) {
3004
- desc = {
3005
- set: decInfo[3]
3006
- };
3007
- } else {
3008
- desc = {
3009
- value: decInfo[3]
3010
- };
3011
- }
3012
- } else if (kind !== 0) {
3013
- desc = Object.getOwnPropertyDescriptor(base, name);
3014
- }
3015
- if (kind === 1) {
3016
- value = {
3017
- get: desc.get,
3018
- set: desc.set
3019
- };
3020
- } else if (kind === 2) {
3021
- value = desc.value;
3022
- } else if (kind === 3) {
3023
- value = desc.get;
3024
- } else if (kind === 4) {
3025
- value = desc.set;
3026
- }
3027
- var newValue, get, set;
3028
- if (typeof decs === "function") {
3029
- newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
3030
- if (newValue !== void 0) {
3031
- assertValidReturnValue(kind, newValue);
3032
- if (kind === 0) {
3033
- init = newValue;
3034
- } else if (kind === 1) {
3035
- init = newValue.init;
3036
- get = newValue.get || value.get;
3037
- set = newValue.set || value.set;
3038
- value = {
3039
- get: get,
3040
- set: set
3041
- };
3042
- } else {
3043
- value = newValue;
3044
- }
3045
- }
3046
- } else {
3047
- for(var i = decs.length - 1; i >= 0; i--){
3048
- var dec = decs[i];
3049
- newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
3050
- if (newValue !== void 0) {
3051
- assertValidReturnValue(kind, newValue);
3052
- var newInit;
3053
- if (kind === 0) {
3054
- newInit = newValue;
3055
- } else if (kind === 1) {
3056
- newInit = newValue.init;
3057
- get = newValue.get || value.get;
3058
- set = newValue.set || value.set;
3059
- value = {
3060
- get: get,
3061
- set: set
3062
- };
3063
- } else {
3064
- value = newValue;
3065
- }
3066
- if (newInit !== void 0) {
3067
- if (init === void 0) {
3068
- init = newInit;
3069
- } else if (typeof init === "function") {
3070
- init = [
3071
- init,
3072
- newInit
3073
- ];
3074
- } else {
3075
- init.push(newInit);
3076
- }
3077
- }
3078
- }
3079
- }
3080
- }
3081
- if (kind === 0 || kind === 1) {
3082
- if (init === void 0) {
3083
- init = function(instance, init) {
3084
- return init;
3085
- };
3086
- } else if (typeof init !== "function") {
3087
- var ownInitializers = init;
3088
- init = function(instance, init) {
3089
- var value = init;
3090
- for(var i = 0; i < ownInitializers.length; i++){
3091
- value = ownInitializers[i].call(instance, value);
3092
- }
3093
- return value;
3094
- };
3095
- } else {
3096
- var originalInitializer = init;
3097
- init = function(instance, init) {
3098
- return originalInitializer.call(instance, init);
3099
- };
3100
- }
3101
- ret.push(init);
3102
- }
3103
- if (kind !== 0) {
3104
- if (kind === 1) {
3105
- desc.get = value.get;
3106
- desc.set = value.set;
3107
- } else if (kind === 2) {
3108
- desc.value = value;
3109
- } else if (kind === 3) {
3110
- desc.get = value;
3111
- } else if (kind === 4) {
3112
- desc.set = value;
3113
- }
3114
- if (isPrivate) {
3115
- if (kind === 1) {
3116
- ret.push(function(instance, args) {
3117
- return value.get.call(instance, args);
3118
- });
3119
- ret.push(function(instance, args) {
3120
- return value.set.call(instance, args);
3121
- });
3122
- } else if (kind === 2) {
3123
- ret.push(value);
3124
- } else {
3125
- ret.push(function(instance, args) {
3126
- return value.call(instance, args);
3127
- });
3128
- }
3129
- } else {
3130
- Object.defineProperty(base, name, desc);
3131
- }
3132
- }
3133
- }
3134
- function applyMemberDecs(Class, decInfos, metadata) {
3135
- var ret = [];
3136
- var protoInitializers;
3137
- var staticInitializers;
3138
- var existingProtoNonFields = new Map();
3139
- var existingStaticNonFields = new Map();
3140
- for(var i = 0; i < decInfos.length; i++){
3141
- var decInfo = decInfos[i];
3142
- if (!Array.isArray(decInfo)) continue;
3143
- var kind = decInfo[1];
3144
- var name = decInfo[2];
3145
- var isPrivate = decInfo.length > 3;
3146
- var isStatic = kind >= 5;
3147
- var base;
3148
- var initializers;
3149
- if (isStatic) {
3150
- base = Class;
3151
- kind = kind - 5;
3152
- staticInitializers = staticInitializers || [];
3153
- initializers = staticInitializers;
3154
- } else {
3155
- base = Class.prototype;
3156
- protoInitializers = protoInitializers || [];
3157
- initializers = protoInitializers;
3158
- }
3159
- if (kind !== 0 && !isPrivate) {
3160
- var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
3161
- var existingKind = existingNonFields.get(name) || 0;
3162
- if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
3163
- 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);
3164
- } else if (!existingKind && kind > 2) {
3165
- existingNonFields.set(name, kind);
3166
- } else {
3167
- existingNonFields.set(name, true);
3168
- }
3169
- }
3170
- applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
3171
- }
3172
- pushInitializers(ret, protoInitializers);
3173
- pushInitializers(ret, staticInitializers);
3174
- return ret;
3175
- }
3176
- function pushInitializers(ret, initializers) {
3177
- if (initializers) {
3178
- ret.push(function(instance) {
3179
- for(var i = 0; i < initializers.length; i++){
3180
- initializers[i].call(instance);
3181
- }
3182
- return instance;
3183
- });
3184
- }
3185
- }
3186
- function applyClassDecs(targetClass, classDecs, metadata) {
3187
- if (classDecs.length > 0) {
3188
- var initializers = [];
3189
- var newClass = targetClass;
3190
- var name = targetClass.name;
3191
- for(var i = classDecs.length - 1; i >= 0; i--){
3192
- var decoratorFinishedRef = {
3193
- v: false
3194
- };
3195
- try {
3196
- var nextNewClass = classDecs[i](newClass, {
3197
- kind: "class",
3198
- name: name,
3199
- addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
3200
- metadata
3201
- });
3202
- } finally{
3203
- decoratorFinishedRef.v = true;
3204
- }
3205
- if (nextNewClass !== undefined) {
3206
- assertValidReturnValue(10, nextNewClass);
3207
- newClass = nextNewClass;
3208
- }
3209
- }
3210
- return [
3211
- defineMetadata(newClass, metadata),
3212
- function() {
3213
- for(var i = 0; i < initializers.length; i++){
3214
- initializers[i].call(newClass);
3215
- }
3216
- }
3217
- ];
3218
- }
3219
- }
3220
- function defineMetadata(Class, metadata) {
3221
- return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
3222
- configurable: true,
3223
- enumerable: true,
3224
- value: metadata
3225
- });
3226
- }
3227
- return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
3228
- if (parentClass !== void 0) {
3229
- var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
3230
- }
3231
- var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
3232
- var e = applyMemberDecs(targetClass, memberDecs, metadata);
3233
- if (!classDecs.length) defineMetadata(targetClass, metadata);
3234
- return {
3235
- e: e,
3236
- get c () {
3237
- return applyClassDecs(targetClass, classDecs, metadata);
3238
- }
3239
- };
3240
- };
3241
- }
3242
- function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
3243
- return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
3244
- }
3245
- function _identity(x) {
3246
- return x;
3247
- }
3248
- var _dec, _initClass, _ViElement, _dec1, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _dec18, _init_name, _init_enter, _init_exit, _init_duration, _init_delay, _init_easing, _init_iterations, _init_direction, _init_fill, _init_open, _init_autoPlay, _init_cascade, _init_stagger, _init_staggerSelector, _init_staggerDirection, _init_reducedMotion, _init_keyframes, _init__isAnimating, _initProto;
3249
- /**
3250
- * Explicit exit counterpart map.
3251
- * Replaces fragile string.replace('in','out') which corrupted strings like 'spin' -> 'spout'.
3252
- */ const EXIT_COUNTERPART = {
3253
- 'fade-in': 'fade-out',
3254
- 'fade-in-up': 'fade-out-down',
3255
- 'fade-in-down': 'fade-out-up',
3256
- 'fade-in-left': 'fade-out-right',
3257
- 'fade-in-right': 'fade-out-left',
3258
- 'zoom-in': 'zoom-out',
3259
- 'scale-up': 'scale-down',
3260
- 'bounce-in': 'bounce-out',
3261
- 'pop-in': 'pop-out',
3262
- 'slide-in-top': 'slide-out-top',
3263
- 'slide-in-bottom': 'slide-out-bottom',
3264
- 'slide-in-left': 'slide-out-left',
3265
- 'slide-in-right': 'slide-out-right',
3266
- 'flip-x': 'fade-out',
3267
- 'flip-y': 'fade-out',
3268
- 'perspective-pop': 'fade-out',
3269
- 'expand-vertical': 'collapse-vertical',
3270
- 'expand-horizontal': 'collapse-horizontal'
3271
- };
3272
- /**
3273
- * WAAPI (Web Animations API) keyframe definitions — used by this component's imperative
3274
- * runtime path via `element.animate()`. These are the canonical source for adding or
3275
- * changing a preset. When you add a preset here you MUST also add the matching
3276
- * `@keyframes vi-<name>` rule in `libs/flux-ui/components/_animation.scss`, which serves
3277
- * the parallel CSS-only consumer path (`animation: vi-fade-in 300ms ...`).
3278
- * The two representations cannot share a runtime source without a build-time code-gen step.
3279
- */ const PRESET_KEYFRAMES = {
3280
- 'fade-in': [
3281
- {
3282
- opacity: 0
3283
- },
3284
- {
3285
- opacity: 1
3286
- }
3287
- ],
3288
- 'fade-out': [
3289
- {
3290
- opacity: 1
3291
- },
3292
- {
3293
- opacity: 0
3294
- }
3295
- ],
3296
- 'fade-in-up': [
3297
- {
3298
- opacity: 0,
3299
- transform: 'translate3d(0, 1rem, 0)'
3300
- },
3301
- {
3302
- opacity: 1,
3303
- transform: 'translate3d(0, 0, 0)'
3304
- }
3305
- ],
3306
- 'fade-in-down': [
3307
- {
3308
- opacity: 0,
3309
- transform: 'translate3d(0, -1rem, 0)'
3310
- },
3311
- {
3312
- opacity: 1,
3313
- transform: 'translate3d(0, 0, 0)'
3314
- }
3315
- ],
3316
- 'fade-in-left': [
3317
- {
3318
- opacity: 0,
3319
- transform: 'translate3d(-1rem, 0, 0)'
3320
- },
3321
- {
3322
- opacity: 1,
3323
- transform: 'translate3d(0, 0, 0)'
3324
- }
3325
- ],
3326
- 'fade-in-right': [
3327
- {
3328
- opacity: 0,
3329
- transform: 'translate3d(1rem, 0, 0)'
3330
- },
3331
- {
3332
- opacity: 1,
3333
- transform: 'translate3d(0, 0, 0)'
3334
- }
3335
- ],
3336
- 'fade-out-up': [
3337
- {
3338
- opacity: 1,
3339
- transform: 'translate3d(0, 0, 0)'
3340
- },
3341
- {
3342
- opacity: 0,
3343
- transform: 'translate3d(0, -1rem, 0)'
3344
- }
3345
- ],
3346
- 'fade-out-down': [
3347
- {
3348
- opacity: 1,
3349
- transform: 'translate3d(0, 0, 0)'
3350
- },
3351
- {
3352
- opacity: 0,
3353
- transform: 'translate3d(0, 1rem, 0)'
3354
- }
3355
- ],
3356
- 'fade-out-left': [
3357
- {
3358
- opacity: 1,
3359
- transform: 'translate3d(0, 0, 0)'
3360
- },
3361
- {
3362
- opacity: 0,
3363
- transform: 'translate3d(-1rem, 0, 0)'
3364
- }
3365
- ],
3366
- 'fade-out-right': [
3367
- {
3368
- opacity: 1,
3369
- transform: 'translate3d(0, 0, 0)'
3370
- },
3371
- {
3372
- opacity: 0,
3373
- transform: 'translate3d(1rem, 0, 0)'
3374
- }
3375
- ],
3376
- 'zoom-in': [
3377
- {
3378
- opacity: 0,
3379
- transform: 'scale3d(0.92, 0.92, 0.92)'
3380
- },
3381
- {
3382
- opacity: 1,
3383
- transform: 'scale3d(1, 1, 1)'
3384
- }
3385
- ],
3386
- 'zoom-out': [
3387
- {
3388
- opacity: 1,
3389
- transform: 'scale3d(1, 1, 1)'
3390
- },
3391
- {
3392
- opacity: 0,
3393
- transform: 'scale3d(0.92, 0.92, 0.92)'
3394
- }
3395
- ],
3396
- 'scale-up': [
3397
- {
3398
- transform: 'scale3d(0.8, 0.8, 0.8)'
3399
- },
3400
- {
3401
- transform: 'scale3d(1, 1, 1)'
3402
- }
3403
- ],
3404
- 'scale-down': [
3405
- {
3406
- transform: 'scale3d(1.2, 1.2, 1.2)'
3407
- },
3408
- {
3409
- transform: 'scale3d(1, 1, 1)'
3410
- }
3411
- ],
3412
- 'bounce-in': [
3413
- {
3414
- opacity: 0,
3415
- transform: 'scale3d(0.3, 0.3, 0.3)',
3416
- offset: 0
3417
- },
3418
- {
3419
- opacity: 0.9,
3420
- transform: 'scale3d(1.08, 1.08, 1.08)',
3421
- offset: 0.5
3422
- },
3423
- {
3424
- opacity: 1,
3425
- transform: 'scale3d(0.95, 0.95, 0.95)',
3426
- offset: 0.75
3427
- },
3428
- {
3429
- opacity: 1,
3430
- transform: 'scale3d(1, 1, 1)',
3431
- offset: 1
3432
- }
3433
- ],
3434
- 'bounce-out': [
3435
- {
3436
- opacity: 1,
3437
- transform: 'scale3d(1, 1, 1)',
3438
- offset: 0
3439
- },
3440
- {
3441
- opacity: 1,
3442
- transform: 'scale3d(0.9, 0.9, 0.9)',
3443
- offset: 0.2
3444
- },
3445
- {
3446
- opacity: 1,
3447
- transform: 'scale3d(1.1, 1.1, 1.1)',
3448
- offset: 0.5
3449
- },
3450
- {
3451
- opacity: 0,
3452
- transform: 'scale3d(0.3, 0.3, 0.3)',
3453
- offset: 1
3454
- }
3455
- ],
3456
- 'pop-in': [
3457
- {
3458
- opacity: 0,
3459
- transform: 'scale3d(0.8, 0.8, 1)',
3460
- offset: 0
3461
- },
3462
- {
3463
- opacity: 1,
3464
- transform: 'scale3d(1.05, 1.05, 1)',
3465
- offset: 0.7
3466
- },
3467
- {
3468
- opacity: 1,
3469
- transform: 'scale3d(1, 1, 1)',
3470
- offset: 1
3471
- }
3472
- ],
3473
- 'pop-out': [
3474
- {
3475
- opacity: 1,
3476
- transform: 'scale3d(1, 1, 1)'
3477
- },
3478
- {
3479
- opacity: 0,
3480
- transform: 'scale3d(0.8, 0.8, 1)'
3481
- }
3482
- ],
3483
- 'slide-in-top': [
3484
- {
3485
- transform: 'translate3d(0, -100%, 0)'
3486
- },
3487
- {
3488
- transform: 'translate3d(0, 0, 0)'
3489
- }
3490
- ],
3491
- 'slide-in-bottom': [
3492
- {
3493
- transform: 'translate3d(0, 100%, 0)'
3494
- },
3495
- {
3496
- transform: 'translate3d(0, 0, 0)'
3497
- }
3498
- ],
3499
- 'slide-in-left': [
3500
- {
3501
- transform: 'translate3d(-100%, 0, 0)'
3502
- },
3503
- {
3504
- transform: 'translate3d(0, 0, 0)'
3505
- }
3506
- ],
3507
- 'slide-in-right': [
3508
- {
3509
- transform: 'translate3d(100%, 0, 0)'
3510
- },
3511
- {
3512
- transform: 'translate3d(0, 0, 0)'
3513
- }
3514
- ],
3515
- 'slide-out-top': [
3516
- {
3517
- transform: 'translate3d(0, 0, 0)'
3518
- },
3519
- {
3520
- transform: 'translate3d(0, -100%, 0)'
3521
- }
3522
- ],
3523
- 'slide-out-bottom': [
3524
- {
3525
- transform: 'translate3d(0, 0, 0)'
3526
- },
3527
- {
3528
- transform: 'translate3d(0, 100%, 0)'
3529
- }
3530
- ],
3531
- 'slide-out-left': [
3532
- {
3533
- transform: 'translate3d(0, 0, 0)'
3534
- },
3535
- {
3536
- transform: 'translate3d(-100%, 0, 0)'
3537
- }
3538
- ],
3539
- 'slide-out-right': [
3540
- {
3541
- transform: 'translate3d(0, 0, 0)'
3542
- },
3543
- {
3544
- transform: 'translate3d(100%, 0, 0)'
3545
- }
3546
- ],
3547
- 'flip-x': [
3548
- {
3549
- transform: 'perspective(400px) rotate3d(1, 0, 0, 90deg)',
3550
- opacity: 0
3551
- },
3552
- {
3553
- transform: 'perspective(400px) rotate3d(1, 0, 0, 0deg)',
3554
- opacity: 1
3555
- }
3556
- ],
3557
- 'flip-y': [
3558
- {
3559
- transform: 'perspective(400px) rotate3d(0, 1, 0, 90deg)',
3560
- opacity: 0
3561
- },
3562
- {
3563
- transform: 'perspective(400px) rotate3d(0, 1, 0, 0deg)',
3564
- opacity: 1
3565
- }
3566
- ],
3567
- 'perspective-pop': [
3568
- {
3569
- transform: 'perspective(600px) translateZ(-100px)',
3570
- opacity: 0
3571
- },
3572
- {
3573
- transform: 'perspective(600px) translateZ(0)',
3574
- opacity: 1
3575
- }
3576
- ],
3577
- // Fallbacks — dynamically replaced with scrollHeight/Width in _getKeyframes
3578
- 'expand-vertical': [
3579
- {
3580
- maxHeight: '0px',
3581
- opacity: 0,
3582
- overflow: 'hidden'
3583
- },
3584
- {
3585
- maxHeight: '100vh',
3586
- opacity: 1,
3587
- overflow: 'hidden'
3588
- }
3589
- ],
3590
- 'collapse-vertical': [
3591
- {
3592
- maxHeight: '100vh',
3593
- opacity: 1,
3594
- overflow: 'hidden'
3595
- },
3596
- {
3597
- maxHeight: '0px',
3598
- opacity: 0,
3599
- overflow: 'hidden'
3600
- }
3601
- ],
3602
- 'expand-horizontal': [
3603
- {
3604
- maxWidth: '0px',
3605
- opacity: 0,
3606
- overflow: 'hidden'
3607
- },
3608
- {
3609
- maxWidth: '100vw',
3610
- opacity: 1,
3611
- overflow: 'hidden'
3612
- }
3613
- ],
3614
- 'collapse-horizontal': [
3615
- {
3616
- maxWidth: '100vw',
3617
- opacity: 1,
3618
- overflow: 'hidden'
3619
- },
3620
- {
3621
- maxWidth: '0px',
3622
- opacity: 0,
3623
- overflow: 'hidden'
3624
- }
3625
- ],
3626
- 'pulse': [
3627
- {
3628
- transform: 'scale3d(1, 1, 1)'
3629
- },
3630
- {
3631
- transform: 'scale3d(1.05, 1.05, 1.05)'
3632
- },
3633
- {
3634
- transform: 'scale3d(1, 1, 1)'
3635
- }
3636
- ],
3637
- 'bounce': [
3638
- {
3639
- transform: 'translate3d(0, 0, 0)'
3640
- },
3641
- {
3642
- transform: 'translate3d(0, -12px, 0)'
3643
- },
3644
- {
3645
- transform: 'translate3d(0, 0, 0)'
3646
- },
3647
- {
3648
- transform: 'translate3d(0, -6px, 0)'
3649
- },
3650
- {
3651
- transform: 'translate3d(0, 0, 0)'
3652
- }
3653
- ],
3654
- 'shake': [
3655
- {
3656
- transform: 'translate3d(0, 0, 0)'
3657
- },
3658
- {
3659
- transform: 'translate3d(-4px, 0, 0)'
3660
- },
3661
- {
3662
- transform: 'translate3d(4px, 0, 0)'
3663
- },
3664
- {
3665
- transform: 'translate3d(-4px, 0, 0)'
3666
- },
3667
- {
3668
- transform: 'translate3d(0, 0, 0)'
3669
- }
3670
- ],
3671
- 'wobble': [
3672
- {
3673
- transform: 'translate3d(0, 0, 0) rotate(0deg)'
3674
- },
3675
- {
3676
- transform: 'translate3d(-15%, 0, 0) rotate(-4deg)'
3677
- },
3678
- {
3679
- transform: 'translate3d(12%, 0, 0) rotate(3deg)'
3680
- },
3681
- {
3682
- transform: 'translate3d(-9%, 0, 0) rotate(-2deg)'
3683
- },
3684
- {
3685
- transform: 'translate3d(6%, 0, 0) rotate(1deg)'
3686
- },
3687
- {
3688
- transform: 'translate3d(0, 0, 0) rotate(0deg)'
3689
- }
3690
- ],
3691
- 'heartbeat': [
3692
- {
3693
- transform: 'scale(1)'
3694
- },
3695
- {
3696
- transform: 'scale(1.15)'
3697
- },
3698
- {
3699
- transform: 'scale(1)'
3700
- },
3701
- {
3702
- transform: 'scale(1.15)'
3703
- },
3704
- {
3705
- transform: 'scale(1)'
3706
- }
3707
- ],
3708
- 'shimmer': [
3709
- {
3710
- backgroundPosition: '-200% 0'
3711
- },
3712
- {
3713
- backgroundPosition: '200% 0'
3714
- }
3715
- ]
3716
- };
3717
- const EXPAND_COLLAPSE_PRESETS = new Set([
3718
- 'expand-vertical',
3719
- 'collapse-vertical',
3720
- 'expand-horizontal',
3721
- 'collapse-horizontal'
3722
- ]);
3723
- /** Shuffle indices using Fisher-Yates — no duplicate delay slots. */ function shuffleIndices(length) {
3724
- const arr = Array.from({
3725
- length
3726
- }, (_, i)=>i);
3727
- for(let i = arr.length - 1; i > 0; i--){
3728
- const j = Math.floor(Math.random() * (i + 1));
3729
- [arr[i], arr[j]] = [
3730
- arr[j],
3731
- arr[i]
3732
- ];
3733
- }
3734
- return arr;
3735
- }
3736
- let _ViAnimation;
3737
- _dec = customElement('vi-animation'), _dec1 = property({
3738
- type: String,
3739
- reflect: true
3740
- }), _dec2 = property({
3741
- type: String,
3742
- reflect: true
3743
- }), _dec3 = property({
3744
- type: String,
3745
- reflect: true
3746
- }), _dec4 = property({
3747
- type: Number,
3748
- reflect: true
3749
- }), _dec5 = property({
3750
- type: Number,
3751
- reflect: true
3752
- }), _dec6 = property({
3753
- type: String,
3754
- reflect: true
3755
- }), _dec7 = property({
3756
- type: Number,
3757
- reflect: true
3758
- }), _dec8 = property({
3759
- type: String,
3760
- reflect: true
3761
- }), _dec9 = property({
3762
- type: String,
3763
- reflect: true
3764
- }), _dec10 = property({
3765
- type: Boolean,
3766
- reflect: true
3767
- }), _dec11 = property({
3768
- type: Boolean,
3769
- attribute: 'auto-play',
3770
- reflect: true
3771
- }), _dec12 = property({
3772
- type: Boolean,
3773
- reflect: true
3774
- }), _dec13 = property({
3775
- type: Number,
3776
- reflect: true
3777
- }), _dec14 = property({
3778
- type: String,
3779
- attribute: 'stagger-selector',
3780
- reflect: true
3781
- }), _dec15 = property({
3782
- type: String,
3783
- attribute: 'stagger-direction',
3784
- reflect: true
3785
- }), _dec16 = property({
3786
- type: String,
3787
- attribute: 'reduced-motion',
3788
- reflect: true
3789
- }), _dec17 = property({
3790
- attribute: false
3791
- }), _dec18 = state();
3792
- new class extends _identity {
3793
- constructor(){
3794
- super(_ViAnimation), _initClass();
3795
- }
3796
- static{
3797
- class ViAnimation extends (_ViElement = ViElement) {
3798
- static{
3799
- ({ e: [_init_name, _init_enter, _init_exit, _init_duration, _init_delay, _init_easing, _init_iterations, _init_direction, _init_fill, _init_open, _init_autoPlay, _init_cascade, _init_stagger, _init_staggerSelector, _init_staggerDirection, _init_reducedMotion, _init_keyframes, _init__isAnimating, _initProto], c: [_ViAnimation, _initClass] } = _apply_decs_2203_r(this, [
3800
- [
3801
- _dec1,
3802
- 1,
3803
- "name"
3804
- ],
3805
- [
3806
- _dec2,
3807
- 1,
3808
- "enter"
3809
- ],
3810
- [
3811
- _dec3,
3812
- 1,
3813
- "exit"
3814
- ],
3815
- [
3816
- _dec4,
3817
- 1,
3818
- "duration"
3819
- ],
3820
- [
3821
- _dec5,
3822
- 1,
3823
- "delay"
3824
- ],
3825
- [
3826
- _dec6,
3827
- 1,
3828
- "easing"
3829
- ],
3830
- [
3831
- _dec7,
3832
- 1,
3833
- "iterations"
3834
- ],
3835
- [
3836
- _dec8,
3837
- 1,
3838
- "direction"
3839
- ],
3840
- [
3841
- _dec9,
3842
- 1,
3843
- "fill"
3844
- ],
3845
- [
3846
- _dec10,
3847
- 1,
3848
- "open"
3849
- ],
3850
- [
3851
- _dec11,
3852
- 1,
3853
- "autoPlay"
3854
- ],
3855
- [
3856
- _dec12,
3857
- 1,
3858
- "cascade"
3859
- ],
3860
- [
3861
- _dec13,
3862
- 1,
3863
- "stagger"
3864
- ],
3865
- [
3866
- _dec14,
3867
- 1,
3868
- "staggerSelector"
3869
- ],
3870
- [
3871
- _dec15,
3872
- 1,
3873
- "staggerDirection"
3874
- ],
3875
- [
3876
- _dec16,
3877
- 1,
3878
- "reducedMotion"
3879
- ],
3880
- [
3881
- _dec17,
3882
- 1,
3883
- "keyframes"
3884
- ],
3885
- [
3886
- _dec18,
3887
- 1,
3888
- "_isAnimating"
3889
- ]
3890
- ], [
3891
- _dec
3892
- ], _ViElement));
3893
- }
3894
- static styles = css`${unsafeCSS(animationStyles)}`;
3895
- #___private_name_1 = (_initProto(this), _init_name(this, 'fade-in'));
3896
- get name() {
3897
- return this.#___private_name_1;
3898
- }
3899
- set name(_v) {
3900
- this.#___private_name_1 = _v;
3901
- }
3902
- #___private_enter_2 = _init_enter(this, '');
3903
- get enter() {
3904
- return this.#___private_enter_2;
3905
- }
3906
- set enter(_v) {
3907
- this.#___private_enter_2 = _v;
3908
- }
3909
- #___private_exit_3 = _init_exit(this, '');
3910
- get exit() {
3911
- return this.#___private_exit_3;
3912
- }
3913
- set exit(_v) {
3914
- this.#___private_exit_3 = _v;
3915
- }
3916
- #___private_duration_4 = _init_duration(this, 300);
3917
- get duration() {
3918
- return this.#___private_duration_4;
3919
- }
3920
- set duration(_v) {
3921
- this.#___private_duration_4 = _v;
3922
- }
3923
- #___private_delay_5 = _init_delay(this, 0);
3924
- get delay() {
3925
- return this.#___private_delay_5;
3926
- }
3927
- set delay(_v) {
3928
- this.#___private_delay_5 = _v;
3929
- }
3930
- #___private_easing_6 = _init_easing(this, 'cubic-bezier(0.2, 0, 0, 1)');
3931
- get easing() {
3932
- return this.#___private_easing_6;
3933
- }
3934
- set easing(_v) {
3935
- this.#___private_easing_6 = _v;
3936
- }
3937
- #___private_iterations_7 = _init_iterations(this, 1);
3938
- get iterations() {
3939
- return this.#___private_iterations_7;
3940
- }
3941
- set iterations(_v) {
3942
- this.#___private_iterations_7 = _v;
3943
- }
3944
- #___private_direction_8 = _init_direction(this, 'normal');
3945
- get direction() {
3946
- return this.#___private_direction_8;
3947
- }
3948
- set direction(_v) {
3949
- this.#___private_direction_8 = _v;
3950
- }
3951
- #___private_fill_9 = _init_fill(this, 'forwards');
3952
- get fill() {
3953
- return this.#___private_fill_9;
3954
- }
3955
- set fill(_v) {
3956
- this.#___private_fill_9 = _v;
3957
- }
3958
- #___private_open_10 = _init_open(this, true);
3959
- get open() {
3960
- return this.#___private_open_10;
3961
- }
3962
- set open(_v) {
3963
- this.#___private_open_10 = _v;
3964
- }
3965
- #___private_autoPlay_11 = _init_autoPlay(this, true);
3966
- get autoPlay() {
3967
- return this.#___private_autoPlay_11;
3968
- }
3969
- set autoPlay(_v) {
3970
- this.#___private_autoPlay_11 = _v;
3971
- }
3972
- #___private_cascade_12 = _init_cascade(this, false);
3973
- get cascade() {
3974
- return this.#___private_cascade_12;
3975
- }
3976
- set cascade(_v) {
3977
- this.#___private_cascade_12 = _v;
3978
- }
3979
- #___private_stagger_13 = _init_stagger(this, 50);
3980
- get stagger() {
3981
- return this.#___private_stagger_13;
3982
- }
3983
- set stagger(_v) {
3984
- this.#___private_stagger_13 = _v;
3985
- }
3986
- #___private_staggerSelector_14 = _init_staggerSelector(this, ':scope > *');
3987
- get staggerSelector() {
3988
- return this.#___private_staggerSelector_14;
3989
- }
3990
- set staggerSelector(_v) {
3991
- this.#___private_staggerSelector_14 = _v;
3992
- }
3993
- #___private_staggerDirection_15 = _init_staggerDirection(this, 'normal');
3994
- get staggerDirection() {
3995
- return this.#___private_staggerDirection_15;
3996
- }
3997
- set staggerDirection(_v) {
3998
- this.#___private_staggerDirection_15 = _v;
3999
- }
4000
- #___private_reducedMotion_16 = _init_reducedMotion(this, 'auto');
4001
- get reducedMotion() {
4002
- return this.#___private_reducedMotion_16;
4003
- }
4004
- set reducedMotion(_v) {
4005
- this.#___private_reducedMotion_16 = _v;
4006
- }
4007
- #___private_keyframes_17 = _init_keyframes(this, null);
4008
- get keyframes() {
4009
- return this.#___private_keyframes_17;
4010
- }
4011
- set keyframes(_v) {
4012
- this.#___private_keyframes_17 = _v;
4013
- }
4014
- #___private__isAnimating_18 = _init__isAnimating(this, false);
4015
- get _isAnimating() {
4016
- return this.#___private__isAnimating_18;
4017
- }
4018
- set _isAnimating(_v) {
4019
- this.#___private__isAnimating_18 = _v;
4020
- }
4021
- _activeAnimations = [];
4022
- /**
4023
- * Monotonically incrementing sequence ID. Incremented on every new sequence
4024
- * start (via _cancelSilently). Async continuations check their captured ID
4025
- * against the current to detect stale callbacks.
4026
- */ _sequenceId = 0;
4027
- /**
4028
- * Prevents updated() from re-calling show()/hide() when the imperative API
4029
- * internally mutates this.open to keep it in sync with animation state.
4030
- */ _updateGuard = false;
4031
- /** Cached matchMedia object for prefers-reduced-motion. */ _reducedMotionMQ = null;
4032
- _reducedMotionListener = null;
4033
- // ─── Public getters ───────────────────────────────────────────────────────
4034
- /** Whether an animation sequence is currently running. */ get isAnimating() {
4035
- return this._isAnimating;
4036
- }
4037
- // ─── Lifecycle ────────────────────────────────────────────────────────────
4038
- connectedCallback() {
4039
- super.connectedCallback();
4040
- if (!this.open) {
4041
- this.hidden = true;
4042
- } else if (this.autoPlay) {
4043
- this.updateComplete.then(()=>this.play());
4044
- }
4045
- if (typeof window !== 'undefined') {
4046
- this._reducedMotionMQ = window.matchMedia('(prefers-reduced-motion: reduce)');
4047
- this._reducedMotionListener = ()=>this.requestUpdate();
4048
- this._reducedMotionMQ.addEventListener('change', this._reducedMotionListener);
4049
- }
4050
- }
4051
- disconnectedCallback() {
4052
- super.disconnectedCallback();
4053
- // Cancel in-flight animations to release resources on detached nodes
4054
- this._cancelSilently();
4055
- if (this._reducedMotionMQ && this._reducedMotionListener) {
4056
- this._reducedMotionMQ.removeEventListener('change', this._reducedMotionListener);
4057
- this._reducedMotionMQ = null;
4058
- this._reducedMotionListener = null;
4059
- }
4060
- }
4061
- updated(changedProperties) {
4062
- super.updated(changedProperties);
4063
- // _updateGuard prevents show()/hide() from being called again when the
4064
- // imperative API internally sets this.open to keep property state in sync
4065
- if (this._updateGuard) return;
4066
- if (changedProperties.has('open') && changedProperties.get('open') !== undefined) {
4067
- if (this.open) {
4068
- this.show();
4069
- } else {
4070
- this.hide();
4071
- }
4072
- }
4073
- }
4074
- // ─── Imperative API ───────────────────────────────────────────────────────
4075
- /** Returns a snapshot of the currently running Animation objects. */ getAnimations() {
4076
- return [
4077
- ...this._activeAnimations
4078
- ];
4079
- }
4080
- /**
4081
- * Animate element into view.
4082
- * Fires cancelable `vi-animation-before-show` — call preventDefault() to block.
4083
- */ async show() {
4084
- const allowed = this._dispatchCancelable('vi-animation-before-show', {
4085
- name: this.enter || this.name,
4086
- target: this,
4087
- phase: 'enter'
4088
- });
4089
- if (!allowed) {
4090
- // If show() was triggered by a declarative open=true change while still hidden,
4091
- // revert to a consistent closed state.
4092
- if (this.open && this.hidden) {
4093
- this._withUpdateGuard(()=>{
4094
- this.open = false;
4095
- this.hidden = true;
4096
- });
4097
- }
4098
- return;
4099
- }
4100
- this._withUpdateGuard(()=>{
4101
- if (!this.open) this.open = true;
4102
- this.hidden = false;
4103
- });
4104
- const animName = this.enter || this.name || 'fade-in';
4105
- await this._runAnimationSequence(animName, 'enter', false);
4106
- }
4107
- /**
4108
- * Animate element out of view.
4109
- * Fires cancelable `vi-animation-before-hide` — call preventDefault() to block.
4110
- */ async hide() {
4111
- const exitName = this.exit || EXIT_COUNTERPART[this.name] || 'fade-out';
4112
- const allowed = this._dispatchCancelable('vi-animation-before-hide', {
4113
- name: exitName,
4114
- target: this,
4115
- phase: 'exit'
4116
- });
4117
- if (!allowed) {
4118
- if (!this.open && !this.hidden) {
4119
- this._withUpdateGuard(()=>{
4120
- this.open = true;
4121
- this.hidden = false;
4122
- });
4123
- }
4124
- return;
4125
- }
4126
- await this._runAnimationSequence(exitName, 'exit', true);
4127
- this._withUpdateGuard(()=>{
4128
- if (this.open) this.open = false;
4129
- this.hidden = true;
4130
- });
4131
- }
4132
- /** Toggle between show() and hide(). */ async toggle() {
4133
- if (this.open) {
4134
- await this.hide();
4135
- } else {
4136
- await this.show();
4137
- }
4138
- }
4139
- /** Play the current `name` animation without changing visibility. */ async play() {
4140
- const phase = this.open ? 'enter' : 'custom';
4141
- await this._runAnimationSequence(this.name, phase, false);
4142
- }
4143
- pause() {
4144
- this._activeAnimations.forEach((a)=>a.pause());
4145
- }
4146
- resume() {
4147
- this._activeAnimations.forEach((a)=>a.play());
4148
- }
4149
- reverse() {
4150
- this._activeAnimations.forEach((a)=>a.reverse());
4151
- }
4152
- /**
4153
- * Cancel all running animations and fire `vi-animation-cancel`.
4154
- */ cancel() {
4155
- this._cancelSilently();
4156
- this._dispatch('vi-animation-cancel', {
4157
- name: this.name,
4158
- target: this,
4159
- phase: 'custom'
4160
- });
4161
- }
4162
- /**
4163
- * Jump all running animations to their end state and fire `vi-animation-finish`.
4164
- */ finish() {
4165
- const anims = [
4166
- ...this._activeAnimations
4167
- ];
4168
- // Clear state first so stale callbacks don't double-process
4169
- this._cancelSilently();
4170
- anims.forEach((a)=>{
4171
- try {
4172
- a.finish();
4173
- } catch {}
4174
- });
4175
- this._dispatch('vi-animation-finish', {
4176
- name: this.name,
4177
- target: this,
4178
- phase: 'custom'
4179
- });
4180
- }
4181
- // ─── Private helpers ──────────────────────────────────────────────────────
4182
- /**
4183
- * Cancel all in-flight animations WITHOUT firing a public event.
4184
- * Used for: self-interruption when a new sequence starts, and for lifecycle cleanup.
4185
- */ _cancelSilently() {
4186
- this._sequenceId++; // invalidate any pending async continuations
4187
- this._activeAnimations.forEach((a)=>{
4188
- try {
4189
- a.cancel();
4190
- } catch {}
4191
- });
4192
- this._activeAnimations = [];
4193
- this._isAnimating = false;
4194
- }
4195
- /**
4196
- * Runs a function that mutates reactive properties without triggering
4197
- * the updated() -> show()/hide() feedback loop.
4198
- */ _withUpdateGuard(fn) {
4199
- this._updateGuard = true;
4200
- fn();
4201
- this.updateComplete.then(()=>{
4202
- this._updateGuard = false;
4203
- });
4204
- }
4205
- _getTargetElements() {
4206
- const slot = this.shadowRoot?.querySelector('slot');
4207
- if (!slot) return [
4208
- this
4209
- ];
4210
- const assignedNodes = slot.assignedElements({
4211
- flatten: true
4212
- });
4213
- if (assignedNodes.length === 0) return [
4214
- this
4215
- ];
4216
- if (!this.cascade) return assignedNodes;
4217
- const targetElements = [];
4218
- for (const node of assignedNodes){
4219
- let matched = false;
4220
- try {
4221
- if (node.matches(this.staggerSelector)) {
4222
- targetElements.push(node);
4223
- matched = true;
4224
- }
4225
- const children = Array.from(node.querySelectorAll(this.staggerSelector));
4226
- if (children.length > 0) {
4227
- targetElements.push(...children);
4228
- matched = true;
4229
- }
4230
- } catch {
4231
- return assignedNodes; // graceful fallback to all assigned nodes
4232
- }
4233
- if (!matched) targetElements.push(node);
4234
- }
4235
- return targetElements.length > 0 ? targetElements : assignedNodes;
4236
- }
4237
- /**
4238
- * Returns keyframes for a given animation name.
4239
- * - Consumer keyframes are passed through as-is (Keyframe[] or PropertyIndexedKeyframes).
4240
- * - Expand/collapse presets dynamically read scrollHeight/scrollWidth to avoid magic-number clipping.
4241
- * - Falls back to PRESET_KEYFRAMES, then 'fade-in' if unknown.
4242
- */ _getKeyframes(animName, phase, isReducedMotion, target) {
4243
- // Explicit consumer-supplied keyframes take highest priority
4244
- if (this.keyframes) return this.keyframes;
4245
- // For built-in presets under reduced motion, substitute with safe opacity fades
4246
- if (isReducedMotion) {
4247
- return PRESET_KEYFRAMES[phase === 'exit' ? 'fade-out' : 'fade-in'];
4248
- }
4249
- // Dynamic expand/collapse using actual element dimensions
4250
- if (EXPAND_COLLAPSE_PRESETS.has(animName) && target) {
4251
- const h = target.scrollHeight;
4252
- const w = target.scrollWidth;
4253
- switch(animName){
4254
- case 'expand-vertical':
4255
- return [
4256
- {
4257
- maxHeight: '0px',
4258
- opacity: 0,
4259
- overflow: 'hidden'
4260
- },
4261
- {
4262
- maxHeight: `${h}px`,
4263
- opacity: 1,
4264
- overflow: 'hidden'
4265
- }
4266
- ];
4267
- case 'collapse-vertical':
4268
- return [
4269
- {
4270
- maxHeight: `${h}px`,
4271
- opacity: 1,
4272
- overflow: 'hidden'
4273
- },
4274
- {
4275
- maxHeight: '0px',
4276
- opacity: 0,
4277
- overflow: 'hidden'
4278
- }
4279
- ];
4280
- case 'expand-horizontal':
4281
- return [
4282
- {
4283
- maxWidth: '0px',
4284
- opacity: 0,
4285
- overflow: 'hidden'
4286
- },
4287
- {
4288
- maxWidth: `${w}px`,
4289
- opacity: 1,
4290
- overflow: 'hidden'
4291
- }
4292
- ];
4293
- case 'collapse-horizontal':
4294
- return [
4295
- {
4296
- maxWidth: `${w}px`,
4297
- opacity: 1,
4298
- overflow: 'hidden'
4299
- },
4300
- {
4301
- maxWidth: '0px',
4302
- opacity: 0,
4303
- overflow: 'hidden'
4304
- }
4305
- ];
4306
- }
4307
- }
4308
- return PRESET_KEYFRAMES[animName] ?? PRESET_KEYFRAMES['fade-in'];
4309
- }
4310
- _calculateStaggerDelay(index, total, shuffledOrder) {
4311
- if (!this.cascade || total <= 1) return this.delay;
4312
- let orderIndex = index;
4313
- if (this.staggerDirection === 'reverse') {
4314
- orderIndex = total - 1 - index;
4315
- } else if (this.staggerDirection === 'center') {
4316
- orderIndex = Math.abs((total - 1) / 2 - index);
4317
- } else if (this.staggerDirection === 'random' && shuffledOrder) {
4318
- orderIndex = shuffledOrder[index];
4319
- }
4320
- return this.delay + orderIndex * this.stagger;
4321
- }
4322
- async _runAnimationSequence(animName, phase, isExitPhase) {
4323
- const isReduced = this._shouldReduceMotion();
4324
- const targets = this._getTargetElements();
4325
- if (targets.length === 0) return;
4326
- // Interrupt previous sequence silently (no vi-animation-cancel event)
4327
- this._cancelSilently();
4328
- const mySequenceId = this._sequenceId;
4329
- this._isAnimating = true;
4330
- // 'auto' mode: shorten duration AND substitute keyframes.
4331
- // 'fade-only' mode: substitute keyframes only, original duration is preserved.
4332
- const actualDuration = isReduced && this.reducedMotion !== 'fade-only' ? Math.min(this.duration, 100) : this.duration;
4333
- this._dispatch('vi-animation-start', {
4334
- name: animName,
4335
- target: this,
4336
- phase,
4337
- duration: actualDuration,
4338
- delay: this.delay
4339
- });
4340
- // Pre-compute shuffled order so all elements get unique, non-repeating delay slots
4341
- const shuffledOrder = this.staggerDirection === 'random' ? shuffleIndices(targets.length) : undefined;
4342
- const animationPromises = targets.map((el, index)=>{
4343
- const elementDelay = isReduced ? 0 : this._calculateStaggerDelay(index, targets.length, shuffledOrder);
4344
- const kf = this._getKeyframes(animName, phase, isReduced, el);
4345
- const anim = el.animate(kf, {
4346
- duration: actualDuration,
4347
- delay: elementDelay,
4348
- easing: this.easing,
4349
- iterations: this.iterations,
4350
- direction: this.direction,
4351
- fill: this.fill
4352
- });
4353
- this._activeAnimations.push(anim);
4354
- return anim.finished.then(()=>{
4355
- // For exit animations: commit the end-frame styles to element.style and
4356
- // cancel the WAAPI fill so external CSS can take over later (avoids
4357
- // invisible elements if the element is re-shown via show() or style).
4358
- if (isExitPhase) {
4359
- try {
4360
- anim.commitStyles();
4361
- } catch {}
4362
- try {
4363
- anim.cancel();
4364
- } catch {}
4365
- }
4366
- }, ()=>null);
4367
- });
4368
- await Promise.all(animationPromises);
4369
- // Discard stale result if a newer sequence has already started
4370
- if (this._sequenceId !== mySequenceId) return;
4371
- this._isAnimating = false;
4372
- this._activeAnimations = [];
4373
- this._dispatch('vi-animation-end', {
4374
- name: animName,
4375
- target: this,
4376
- phase,
4377
- completed: true
4378
- });
4379
- }
4380
- /**
4381
- * Returns whether any reduced-motion adaptation should be applied.
4382
- *
4383
- * Both 'auto' and 'fade-only' gate on the OS/browser preference so that the attribute
4384
- * does not override what the user has configured at the system level. The distinction
4385
- * between them is captured in _runAnimationSequence:
4386
- * - 'auto': shorten duration (≤100 ms) + substitute with opacity fade.
4387
- * - 'fade-only': substitute with opacity fade, but keep the original duration.
4388
- * - 'disable': ignore OS preference entirely — always play the full animation.
4389
- */ _shouldReduceMotion() {
4390
- if (this.reducedMotion === 'disable') return false;
4391
- // Gate on the OS/browser preference for both 'auto' and 'fade-only'.
4392
- return this._reducedMotionMQ?.matches ?? (typeof window !== 'undefined' && window.matchMedia('(prefers-reduced-motion: reduce)').matches);
4393
- }
4394
- _dispatch(eventName, detail) {
4395
- this.dispatchEvent(new CustomEvent(eventName, {
4396
- detail,
4397
- bubbles: true,
4398
- composed: true
4399
- }));
4400
- }
4401
- /**
4402
- * Dispatch a cancelable event. Returns true if the animation should proceed
4403
- * (i.e. preventDefault() was NOT called), false if it should be blocked.
4404
- */ _dispatchCancelable(eventName, detail) {
4405
- const event = new CustomEvent(eventName, {
4406
- detail,
4407
- bubbles: true,
4408
- composed: true,
4409
- cancelable: true
4410
- });
4411
- this.dispatchEvent(event);
4412
- return !event.defaultPrevented;
4413
- }
4414
- render() {
4415
- return html`<slot></slot>`;
4416
- }
4417
- }
4418
- }
4419
- }();
4420
-
4421
- export { _ViAlert as ViAlert, _ViAnimation as ViAnimation, _ViBadge as ViBadge, _ViChip as ViChip, _ViChipGroup as ViChipGroup, ViElement, registerIcons };
13
+ export { ViBadge } from './badge/vi-badge.js';
14
+ export { ViAlert } from './alert/vi-alert.js';
15
+ export { ViChip } from './chip/vi-chip.js';
16
+ export { ViChipGroup } from './chip/vi-chip-group.js';
17
+ export { ViAnimation } from './animation/vi-animation.js';