@vonage/vivid 3.0.0-next.92 → 3.0.0-next.93

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.
Files changed (52) hide show
  1. package/accordion/index.js +1 -1
  2. package/accordion-item/index.js +1 -1
  3. package/action-group/index.js +1 -1
  4. package/avatar/index.js +1 -1
  5. package/badge/index.js +1 -1
  6. package/banner/index.js +1 -1
  7. package/breadcrumb-item/index.js +1 -1
  8. package/calendar/index.js +1 -1
  9. package/calendar-event/index.js +1 -1
  10. package/card/index.js +1 -1
  11. package/checkbox/index.js +1 -1
  12. package/dialog/index.js +1 -1
  13. package/fab/index.js +1 -1
  14. package/focus/index.js +1 -1
  15. package/header/index.js +1 -1
  16. package/index.js +5 -3
  17. package/lib/components.d.ts +1 -0
  18. package/lib/listbox/index.d.ts +4 -0
  19. package/lib/listbox/listbox.d.ts +9 -0
  20. package/lib/listbox/listbox.template.d.ts +4 -0
  21. package/listbox/index.js +1105 -0
  22. package/listbox-option/index.js +12 -239
  23. package/menu/index.js +4 -10
  24. package/menu-item/index.js +1 -1
  25. package/nav-disclosure/index.js +1 -1
  26. package/nav-item/index.js +1 -1
  27. package/note/index.js +1 -1
  28. package/number-field/index.js +2 -2
  29. package/package.json +2 -1
  30. package/popup/index.js +1 -1
  31. package/progress/index.js +1 -1
  32. package/progress-ring/index.js +1 -1
  33. package/radio/index.js +1 -1
  34. package/radio-group/index.js +2 -2
  35. package/shared/dom.js +8 -0
  36. package/shared/form-elements.js +1 -1
  37. package/shared/index2.js +1 -1
  38. package/shared/index4.js +1 -1
  39. package/shared/index5.js +220 -1492
  40. package/shared/index6.js +1490 -314
  41. package/shared/index7.js +349 -0
  42. package/shared/key-codes.js +2 -1
  43. package/shared/patterns/form-elements/form-elements.d.ts +1 -1
  44. package/side-drawer/index.js +1 -1
  45. package/styles/core/all.css +1 -1
  46. package/styles/core/theme.css +1 -1
  47. package/styles/core/typography.css +1 -1
  48. package/styles/tokens/theme-dark.css +4 -4
  49. package/styles/tokens/theme-light.css +4 -4
  50. package/text-area/index.js +1 -1
  51. package/text-field/index.js +1 -1
  52. package/tooltip/index.js +2 -2
package/shared/index5.js CHANGED
@@ -1,1525 +1,253 @@
1
- import './index3.js';
2
- import './index2.js';
3
- import { F as FoundationElement, c as __classPrivateFieldGet, j as __classPrivateFieldSet, _ as __decorate, a as attr, b as __metadata, h as html, d as designSystem } from './index.js';
4
- import './icon.js';
1
+ import '../icon/index.js';
2
+ import '../focus/index.js';
3
+ import { F as FoundationElement, O as Observable, _ as __decorate, o as observable, a as attr, b as __metadata, h as html, d as designSystem } from './index.js';
4
+ import { A as AffixIconWithTrailing, a as affixIconTemplateFactory } from './affix.js';
5
+ import { A as ARIAGlobalStatesAndProperties } from './aria-global.js';
6
+ import { S as StartEnd } from './start-end.js';
7
+ import { a as applyMixins } from './apply-mixins.js';
8
+ import { i as isHTMLElement } from './dom.js';
9
+ import { f as focusTemplateFactory } from './focus2.js';
5
10
  import './web.dom-collections.iterator.js';
6
- import './es.object.assign.js';
7
- import { f as keyEscape } from './key-codes.js';
11
+ import './icon.js';
8
12
  import { w as when } from './when.js';
9
- import { r as ref } from './ref.js';
10
13
  import { c as classNames } from './class-names.js';
11
14
 
12
- function getSide(placement) {
13
- return placement.split('-')[0];
14
- }
15
-
16
- function getAlignment(placement) {
17
- return placement.split('-')[1];
18
- }
19
-
20
- function getMainAxisFromPlacement(placement) {
21
- return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
22
- }
23
-
24
- function getLengthFromAxis(axis) {
25
- return axis === 'y' ? 'height' : 'width';
26
- }
27
-
28
- function computeCoordsFromPlacement(_ref, placement, rtl) {
29
- let {
30
- reference,
31
- floating
32
- } = _ref;
33
- const commonX = reference.x + reference.width / 2 - floating.width / 2;
34
- const commonY = reference.y + reference.height / 2 - floating.height / 2;
35
- const mainAxis = getMainAxisFromPlacement(placement);
36
- const length = getLengthFromAxis(mainAxis);
37
- const commonAlign = reference[length] / 2 - floating[length] / 2;
38
- const side = getSide(placement);
39
- const isVertical = mainAxis === 'x';
40
- let coords;
41
-
42
- switch (side) {
43
- case 'top':
44
- coords = {
45
- x: commonX,
46
- y: reference.y - floating.height
47
- };
48
- break;
49
-
50
- case 'bottom':
51
- coords = {
52
- x: commonX,
53
- y: reference.y + reference.height
54
- };
55
- break;
56
-
57
- case 'right':
58
- coords = {
59
- x: reference.x + reference.width,
60
- y: commonY
61
- };
62
- break;
63
-
64
- case 'left':
65
- coords = {
66
- x: reference.x - floating.width,
67
- y: commonY
68
- };
69
- break;
70
-
71
- default:
72
- coords = {
73
- x: reference.x,
74
- y: reference.y
75
- };
76
- }
77
-
78
- switch (getAlignment(placement)) {
79
- case 'start':
80
- coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
81
- break;
82
-
83
- case 'end':
84
- coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
85
- break;
86
- }
87
-
88
- return coords;
89
- }
90
-
91
15
  /**
92
- * Computes the `x` and `y` coordinates that will place the floating element
93
- * next to a reference element when it is given a certain positioning strategy.
16
+ * Determines if the element is a {@link (ListboxOption:class)}
94
17
  *
95
- * This export does not have any `platform` interface logic. You will need to
96
- * write one for the platform you are using Floating UI with.
18
+ * @param element - the element to test.
19
+ * @public
97
20
  */
98
-
99
- const computePosition$1 = async (reference, floating, config) => {
100
- const {
101
- placement = 'bottom',
102
- strategy = 'absolute',
103
- middleware = [],
104
- platform
105
- } = config;
106
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
107
-
108
- let rects = await platform.getElementRects({
109
- reference,
110
- floating,
111
- strategy
112
- });
113
- let {
114
- x,
115
- y
116
- } = computeCoordsFromPlacement(rects, placement, rtl);
117
- let statefulPlacement = placement;
118
- let middlewareData = {};
119
- let resetCount = 0;
120
-
121
- for (let i = 0; i < middleware.length; i++) {
122
- const {
123
- name,
124
- fn
125
- } = middleware[i];
126
- const {
127
- x: nextX,
128
- y: nextY,
129
- data,
130
- reset
131
- } = await fn({
132
- x,
133
- y,
134
- initialPlacement: placement,
135
- placement: statefulPlacement,
136
- strategy,
137
- middlewareData,
138
- rects,
139
- platform,
140
- elements: {
141
- reference,
142
- floating
143
- }
144
- });
145
- x = nextX != null ? nextX : x;
146
- y = nextY != null ? nextY : y;
147
- middlewareData = { ...middlewareData,
148
- [name]: { ...middlewareData[name],
149
- ...data
150
- }
151
- };
152
-
153
- if (reset && resetCount <= 50) {
154
- resetCount++;
155
-
156
- if (typeof reset === 'object') {
157
- if (reset.placement) {
158
- statefulPlacement = reset.placement;
159
- }
160
-
161
- if (reset.rects) {
162
- rects = reset.rects === true ? await platform.getElementRects({
163
- reference,
164
- floating,
165
- strategy
166
- }) : reset.rects;
167
- }
168
-
169
- ({
170
- x,
171
- y
172
- } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
173
- }
174
-
175
- i = -1;
176
- continue;
177
- }
178
- }
179
-
180
- return {
181
- x,
182
- y,
183
- placement: statefulPlacement,
184
- strategy,
185
- middlewareData
186
- };
187
- };
188
-
189
- function expandPaddingObject(padding) {
190
- return {
191
- top: 0,
192
- right: 0,
193
- bottom: 0,
194
- left: 0,
195
- ...padding
196
- };
21
+ function isListboxOption(el) {
22
+ return (isHTMLElement(el) &&
23
+ (el.getAttribute("role") === "option" ||
24
+ el instanceof HTMLOptionElement));
197
25
  }
198
-
199
- function getSideObjectFromPadding(padding) {
200
- return typeof padding !== 'number' ? expandPaddingObject(padding) : {
201
- top: padding,
202
- right: padding,
203
- bottom: padding,
204
- left: padding
205
- };
206
- }
207
-
208
- function rectToClientRect(rect) {
209
- return { ...rect,
210
- top: rect.y,
211
- left: rect.x,
212
- right: rect.x + rect.width,
213
- bottom: rect.y + rect.height
214
- };
215
- }
216
-
217
- /**
218
- * Resolves with an object of overflow side offsets that determine how much the
219
- * element is overflowing a given clipping boundary.
220
- * - positive = overflowing the boundary by that number of pixels
221
- * - negative = how many pixels left before it will overflow
222
- * - 0 = lies flush with the boundary
223
- * @see https://floating-ui.com/docs/detectOverflow
224
- */
225
- async function detectOverflow(middlewareArguments, options) {
226
- var _await$platform$isEle;
227
-
228
- if (options === void 0) {
229
- options = {};
230
- }
231
-
232
- const {
233
- x,
234
- y,
235
- platform,
236
- rects,
237
- elements,
238
- strategy
239
- } = middlewareArguments;
240
- const {
241
- boundary = 'clippingAncestors',
242
- rootBoundary = 'viewport',
243
- elementContext = 'floating',
244
- altBoundary = false,
245
- padding = 0
246
- } = options;
247
- const paddingObject = getSideObjectFromPadding(padding);
248
- const altContext = elementContext === 'floating' ? 'reference' : 'floating';
249
- const element = elements[altBoundary ? altContext : elementContext];
250
- const clippingClientRect = rectToClientRect(await platform.getClippingRect({
251
- element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
252
- boundary,
253
- rootBoundary,
254
- strategy
255
- }));
256
- const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
257
- rect: elementContext === 'floating' ? { ...rects.floating,
258
- x,
259
- y
260
- } : rects.reference,
261
- offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
262
- strategy
263
- }) : rects[elementContext]);
264
- return {
265
- top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
266
- bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
267
- left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
268
- right: elementClientRect.right - clippingClientRect.right + paddingObject.right
269
- };
270
- }
271
-
272
- const min$1 = Math.min;
273
- const max$1 = Math.max;
274
-
275
- function within(min$1$1, value, max$1$1) {
276
- return max$1(min$1$1, min$1(value, max$1$1));
277
- }
278
-
279
- /**
280
- * Positions an inner element of the floating element such that it is centered
281
- * to the reference element.
282
- * @see https://floating-ui.com/docs/arrow
283
- */
284
- const arrow = options => ({
285
- name: 'arrow',
286
- options,
287
-
288
- async fn(middlewareArguments) {
289
- // Since `element` is required, we don't Partial<> the type
290
- const {
291
- element,
292
- padding = 0
293
- } = options != null ? options : {};
294
- const {
295
- x,
296
- y,
297
- placement,
298
- rects,
299
- platform
300
- } = middlewareArguments;
301
-
302
- if (element == null) {
303
-
304
- return {};
305
- }
306
-
307
- const paddingObject = getSideObjectFromPadding(padding);
308
- const coords = {
309
- x,
310
- y
311
- };
312
- const axis = getMainAxisFromPlacement(placement);
313
- const alignment = getAlignment(placement);
314
- const length = getLengthFromAxis(axis);
315
- const arrowDimensions = await platform.getDimensions(element);
316
- const minProp = axis === 'y' ? 'top' : 'left';
317
- const maxProp = axis === 'y' ? 'bottom' : 'right';
318
- const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
319
- const startDiff = coords[axis] - rects.reference[axis];
320
- const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
321
- let clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
322
-
323
- if (clientSize === 0) {
324
- clientSize = rects.floating[length];
325
- }
326
-
327
- const centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the floating element if the center
328
- // point is outside the floating element's bounds
329
-
330
- const min = paddingObject[minProp];
331
- const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
332
- const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
333
- const offset = within(min, center, max); // Make sure that arrow points at the reference
334
-
335
- const alignmentPadding = alignment === 'start' ? paddingObject[minProp] : paddingObject[maxProp];
336
- const shouldAddOffset = alignmentPadding > 0 && center !== offset && rects.reference[length] <= rects.floating[length];
337
- const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;
338
- return {
339
- [axis]: coords[axis] - alignmentOffset,
340
- data: {
341
- [axis]: offset,
342
- centerOffset: center - offset
343
- }
344
- };
345
- }
346
-
347
- });
348
-
349
- const hash$1 = {
350
- left: 'right',
351
- right: 'left',
352
- bottom: 'top',
353
- top: 'bottom'
354
- };
355
- function getOppositePlacement(placement) {
356
- return placement.replace(/left|right|bottom|top/g, matched => hash$1[matched]);
357
- }
358
-
359
- function getAlignmentSides(placement, rects, rtl) {
360
- if (rtl === void 0) {
361
- rtl = false;
362
- }
363
-
364
- const alignment = getAlignment(placement);
365
- const mainAxis = getMainAxisFromPlacement(placement);
366
- const length = getLengthFromAxis(mainAxis);
367
- let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
368
-
369
- if (rects.reference[length] > rects.floating[length]) {
370
- mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
371
- }
372
-
373
- return {
374
- main: mainAlignmentSide,
375
- cross: getOppositePlacement(mainAlignmentSide)
376
- };
377
- }
378
-
379
- const hash = {
380
- start: 'end',
381
- end: 'start'
382
- };
383
- function getOppositeAlignmentPlacement(placement) {
384
- return placement.replace(/start|end/g, matched => hash[matched]);
385
- }
386
-
387
- const sides = ['top', 'right', 'bottom', 'left'];
388
-
389
- function getExpandedPlacements(placement) {
390
- const oppositePlacement = getOppositePlacement(placement);
391
- return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
392
- }
393
-
394
26
  /**
395
- * Changes the placement of the floating element to one that will fit if the
396
- * initially specified `placement` does not.
397
- * @see https://floating-ui.com/docs/flip
27
+ * An Option Custom HTML Element.
28
+ * Implements {@link https://www.w3.org/TR/wai-aria-1.1/#option | ARIA option }.
29
+ *
30
+ * @slot start - Content which can be provided before the listbox option content
31
+ * @slot end - Content which can be provided after the listbox option content
32
+ * @slot - The default slot for listbox option content
33
+ * @csspart content - Wraps the listbox option content
34
+ *
35
+ * @public
398
36
  */
399
- const flip = function (options) {
400
- if (options === void 0) {
401
- options = {};
402
- }
403
-
404
- return {
405
- name: 'flip',
406
- options,
407
-
408
- async fn(middlewareArguments) {
409
- var _middlewareData$flip;
410
-
411
- const {
412
- placement,
413
- middlewareData,
414
- rects,
415
- initialPlacement,
416
- platform,
417
- elements
418
- } = middlewareArguments;
419
- const {
420
- mainAxis: checkMainAxis = true,
421
- crossAxis: checkCrossAxis = true,
422
- fallbackPlacements: specifiedFallbackPlacements,
423
- fallbackStrategy = 'bestFit',
424
- flipAlignment = true,
425
- ...detectOverflowOptions
426
- } = options;
427
- const side = getSide(placement);
428
- const isBasePlacement = side === initialPlacement;
429
- const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
430
- const placements = [initialPlacement, ...fallbackPlacements];
431
- const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
432
- const overflows = [];
433
- let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
434
-
435
- if (checkMainAxis) {
436
- overflows.push(overflow[side]);
437
- }
438
-
439
- if (checkCrossAxis) {
440
- const {
441
- main,
442
- cross
443
- } = getAlignmentSides(placement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
444
- overflows.push(overflow[main], overflow[cross]);
445
- }
446
-
447
- overflowsData = [...overflowsData, {
448
- placement,
449
- overflows
450
- }]; // One or more sides is overflowing
451
-
452
- if (!overflows.every(side => side <= 0)) {
453
- var _middlewareData$flip$, _middlewareData$flip2;
454
-
455
- const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
456
- const nextPlacement = placements[nextIndex];
457
-
458
- if (nextPlacement) {
459
- // Try next placement and re-run the lifecycle
460
- return {
461
- data: {
462
- index: nextIndex,
463
- overflows: overflowsData
464
- },
465
- reset: {
466
- placement: nextPlacement
467
- }
468
- };
37
+ class ListboxOption$1 extends FoundationElement {
38
+ constructor(text, value, defaultSelected, selected) {
39
+ super();
40
+ /**
41
+ * The defaultSelected state of the option.
42
+ * @public
43
+ */
44
+ this.defaultSelected = false;
45
+ /**
46
+ * Tracks whether the "selected" property has been changed.
47
+ * @internal
48
+ */
49
+ this.dirtySelected = false;
50
+ /**
51
+ * The checked state of the control.
52
+ *
53
+ * @public
54
+ */
55
+ this.selected = this.defaultSelected;
56
+ /**
57
+ * Track whether the value has been changed from the initial value
58
+ */
59
+ this.dirtyValue = false;
60
+ if (text) {
61
+ this.textContent = text;
469
62
  }
470
-
471
- let resetPlacement = 'bottom';
472
-
473
- switch (fallbackStrategy) {
474
- case 'bestFit':
475
- {
476
- var _overflowsData$map$so;
477
-
478
- const placement = (_overflowsData$map$so = overflowsData.map(d => [d, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0].placement;
479
-
480
- if (placement) {
481
- resetPlacement = placement;
482
- }
483
-
484
- break;
485
- }
486
-
487
- case 'initialPlacement':
488
- resetPlacement = initialPlacement;
489
- break;
63
+ if (value) {
64
+ this.initialValue = value;
490
65
  }
491
-
492
- if (placement !== resetPlacement) {
493
- return {
494
- reset: {
495
- placement: resetPlacement
496
- }
497
- };
66
+ if (defaultSelected) {
67
+ this.defaultSelected = defaultSelected;
498
68
  }
499
- }
500
-
501
- return {};
502
- }
503
-
504
- };
505
- };
506
-
507
- function getSideOffsets(overflow, rect) {
508
- return {
509
- top: overflow.top - rect.height,
510
- right: overflow.right - rect.width,
511
- bottom: overflow.bottom - rect.height,
512
- left: overflow.left - rect.width
513
- };
514
- }
515
-
516
- function isAnySideFullyClipped(overflow) {
517
- return sides.some(side => overflow[side] >= 0);
518
- }
519
-
520
- /**
521
- * Provides data to hide the floating element in applicable situations, such as
522
- * when it is not in the same clipping context as the reference element.
523
- * @see https://floating-ui.com/docs/hide
524
- */
525
- const hide = function (_temp) {
526
- let {
527
- strategy = 'referenceHidden',
528
- ...detectOverflowOptions
529
- } = _temp === void 0 ? {} : _temp;
530
- return {
531
- name: 'hide',
532
-
533
- async fn(middlewareArguments) {
534
- const {
535
- rects
536
- } = middlewareArguments;
537
-
538
- switch (strategy) {
539
- case 'referenceHidden':
540
- {
541
- const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
542
- elementContext: 'reference'
543
- });
544
- const offsets = getSideOffsets(overflow, rects.reference);
545
- return {
546
- data: {
547
- referenceHiddenOffsets: offsets,
548
- referenceHidden: isAnySideFullyClipped(offsets)
549
- }
550
- };
551
- }
552
-
553
- case 'escaped':
554
- {
555
- const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
556
- altBoundary: true
557
- });
558
- const offsets = getSideOffsets(overflow, rects.floating);
559
- return {
560
- data: {
561
- escapedOffsets: offsets,
562
- escaped: isAnySideFullyClipped(offsets)
563
- }
564
- };
565
- }
566
-
567
- default:
568
- {
569
- return {};
570
- }
571
- }
572
- }
573
-
574
- };
575
- };
576
-
577
- async function convertValueToCoords(middlewareArguments, value) {
578
- const {
579
- placement,
580
- platform,
581
- elements
582
- } = middlewareArguments;
583
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
584
- const side = getSide(placement);
585
- const alignment = getAlignment(placement);
586
- const isVertical = getMainAxisFromPlacement(placement) === 'x';
587
- const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
588
- const crossAxisMulti = rtl && isVertical ? -1 : 1;
589
- const rawValue = typeof value === 'function' ? value(middlewareArguments) : value; // eslint-disable-next-line prefer-const
590
-
591
- let {
592
- mainAxis,
593
- crossAxis,
594
- alignmentAxis
595
- } = typeof rawValue === 'number' ? {
596
- mainAxis: rawValue,
597
- crossAxis: 0,
598
- alignmentAxis: null
599
- } : {
600
- mainAxis: 0,
601
- crossAxis: 0,
602
- alignmentAxis: null,
603
- ...rawValue
604
- };
605
-
606
- if (alignment && typeof alignmentAxis === 'number') {
607
- crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
608
- }
609
-
610
- return isVertical ? {
611
- x: crossAxis * crossAxisMulti,
612
- y: mainAxis * mainAxisMulti
613
- } : {
614
- x: mainAxis * mainAxisMulti,
615
- y: crossAxis * crossAxisMulti
616
- };
617
- }
618
- /**
619
- * Displaces the floating element from its reference element.
620
- * @see https://floating-ui.com/docs/offset
621
- */
622
-
623
- const offset = function (value) {
624
- if (value === void 0) {
625
- value = 0;
626
- }
627
-
628
- return {
629
- name: 'offset',
630
- options: value,
631
-
632
- async fn(middlewareArguments) {
633
- const {
634
- x,
635
- y
636
- } = middlewareArguments;
637
- const diffCoords = await convertValueToCoords(middlewareArguments, value);
638
- return {
639
- x: x + diffCoords.x,
640
- y: y + diffCoords.y,
641
- data: diffCoords
642
- };
643
- }
644
-
645
- };
646
- };
647
-
648
- /**
649
- * Provides improved positioning for inline reference elements that can span
650
- * over multiple lines, such as hyperlinks or range selections.
651
- * @see https://floating-ui.com/docs/inline
652
- */
653
- const inline = function (options) {
654
- if (options === void 0) {
655
- options = {};
656
- }
657
-
658
- return {
659
- name: 'inline',
660
- options,
661
-
662
- async fn(middlewareArguments) {
663
- var _await$platform$getCl;
664
-
665
- const {
666
- placement,
667
- elements,
668
- rects,
669
- platform,
670
- strategy
671
- } = middlewareArguments; // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
672
- // ClientRect's bounds, despite the event listener being triggered. A
673
- // padding of 2 seems to handle this issue.
674
-
675
- const {
676
- padding = 2,
677
- x,
678
- y
679
- } = options;
680
- const fallback = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
681
- rect: rects.reference,
682
- offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
683
- strategy
684
- }) : rects.reference);
685
- const clientRects = (_await$platform$getCl = await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) != null ? _await$platform$getCl : [];
686
- const paddingObject = getSideObjectFromPadding(padding);
687
-
688
- function getBoundingClientRect() {
689
- // There are two rects and they are disjoined
690
- if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
691
- var _clientRects$find;
692
-
693
- // Find the first rect in which the point is fully inside
694
- return (_clientRects$find = clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom)) != null ? _clientRects$find : fallback;
695
- } // There are 2 or more connected rects
696
-
697
-
698
- if (clientRects.length >= 2) {
699
- if (getMainAxisFromPlacement(placement) === 'x') {
700
- const firstRect = clientRects[0];
701
- const lastRect = clientRects[clientRects.length - 1];
702
- const isTop = getSide(placement) === 'top';
703
- const top = firstRect.top;
704
- const bottom = lastRect.bottom;
705
- const left = isTop ? firstRect.left : lastRect.left;
706
- const right = isTop ? firstRect.right : lastRect.right;
707
- const width = right - left;
708
- const height = bottom - top;
709
- return {
710
- top,
711
- bottom,
712
- left,
713
- right,
714
- width,
715
- height,
716
- x: left,
717
- y: top
718
- };
719
- }
720
-
721
- const isLeftSide = getSide(placement) === 'left';
722
- const maxRight = max$1(...clientRects.map(rect => rect.right));
723
- const minLeft = min$1(...clientRects.map(rect => rect.left));
724
- const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
725
- const top = measureRects[0].top;
726
- const bottom = measureRects[measureRects.length - 1].bottom;
727
- const left = minLeft;
728
- const right = maxRight;
729
- const width = right - left;
730
- const height = bottom - top;
731
- return {
732
- top,
733
- bottom,
734
- left,
735
- right,
736
- width,
737
- height,
738
- x: left,
739
- y: top
740
- };
69
+ if (selected) {
70
+ this.selected = selected;
741
71
  }
742
-
743
- return fallback;
744
- }
745
-
746
- const resetRects = await platform.getElementRects({
747
- reference: {
748
- getBoundingClientRect
749
- },
750
- floating: elements.floating,
751
- strategy
752
- });
753
-
754
- if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
755
- return {
756
- reset: {
757
- rects: resetRects
758
- }
759
- };
760
- }
761
-
762
- return {};
72
+ this.proxy = new Option(`${this.textContent}`, this.initialValue, this.defaultSelected, this.selected);
73
+ this.proxy.disabled = this.disabled;
74
+ }
75
+ /**
76
+ * Updates the ariaChecked property when the checked property changes.
77
+ *
78
+ * @param prev - the previous checked value
79
+ * @param next - the current checked value
80
+ *
81
+ * @public
82
+ */
83
+ checkedChanged(prev, next) {
84
+ if (typeof next === "boolean") {
85
+ this.ariaChecked = next ? "true" : "false";
86
+ return;
87
+ }
88
+ this.ariaChecked = null;
89
+ }
90
+ /**
91
+ * Updates the proxy's text content when the default slot changes.
92
+ * @param prev - the previous content value
93
+ * @param next - the current content value
94
+ *
95
+ * @internal
96
+ */
97
+ contentChanged(prev, next) {
98
+ if (this.proxy instanceof HTMLOptionElement) {
99
+ this.proxy.textContent = this.textContent;
100
+ }
101
+ this.$emit("contentchange", null, { bubbles: true });
763
102
  }
764
-
765
- };
766
- };
767
-
768
- function isWindow(value) {
769
- return value && value.document && value.location && value.alert && value.setInterval;
770
- }
771
- function getWindow(node) {
772
- if (node == null) {
773
- return window;
774
- }
775
-
776
- if (!isWindow(node)) {
777
- const ownerDocument = node.ownerDocument;
778
- return ownerDocument ? ownerDocument.defaultView || window : window;
779
- }
780
-
781
- return node;
782
- }
783
-
784
- function getComputedStyle$1(element) {
785
- return getWindow(element).getComputedStyle(element);
786
- }
787
-
788
- function getNodeName(node) {
789
- return isWindow(node) ? '' : node ? (node.nodeName || '').toLowerCase() : '';
790
- }
791
-
792
- function getUAString() {
793
- const uaData = navigator.userAgentData;
794
-
795
- if (uaData != null && uaData.brands) {
796
- return uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
797
- }
798
-
799
- return navigator.userAgent;
800
- }
801
-
802
- function isHTMLElement(value) {
803
- return value instanceof getWindow(value).HTMLElement;
804
- }
805
- function isElement(value) {
806
- return value instanceof getWindow(value).Element;
807
- }
808
- function isNode(value) {
809
- return value instanceof getWindow(value).Node;
810
- }
811
- function isShadowRoot(node) {
812
- // Browsers without `ShadowRoot` support
813
- if (typeof ShadowRoot === 'undefined') {
814
- return false;
815
- }
816
-
817
- const OwnElement = getWindow(node).ShadowRoot;
818
- return node instanceof OwnElement || node instanceof ShadowRoot;
819
- }
820
- function isOverflowElement(element) {
821
- // Firefox wants us to check `-x` and `-y` variations as well
822
- const {
823
- overflow,
824
- overflowX,
825
- overflowY
826
- } = getComputedStyle$1(element);
827
- return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
828
- }
829
- function isTableElement(element) {
830
- return ['table', 'td', 'th'].includes(getNodeName(element));
831
- }
832
- function isContainingBlock(element) {
833
- // TODO: Try and use feature detection here instead
834
- const isFirefox = /firefox/i.test(getUAString());
835
- const css = getComputedStyle$1(element); // This is non-exhaustive but covers the most common CSS properties that
836
- // create a containing block.
837
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
838
-
839
- return css.transform !== 'none' || css.perspective !== 'none' || // @ts-ignore (TS 4.1 compat)
840
- css.contain === 'paint' || ['transform', 'perspective'].includes(css.willChange) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false);
841
- }
842
- function isLayoutViewport() {
843
- // Not Safari
844
- return !/^((?!chrome|android).)*safari/i.test(getUAString()); // Feature detection for this fails in various ways
845
- // • Always-visible scrollbar or not
846
- // • Width of <html>, etc.
847
- // const vV = win.visualViewport;
848
- // return vV ? Math.abs(win.innerWidth / vV.scale - vV.width) < 0.5 : true;
849
- }
850
-
851
- const min = Math.min;
852
- const max = Math.max;
853
- const round = Math.round;
854
-
855
- function getBoundingClientRect(element, includeScale, isFixedStrategy) {
856
- var _win$visualViewport$o, _win$visualViewport, _win$visualViewport$o2, _win$visualViewport2;
857
-
858
- if (includeScale === void 0) {
859
- includeScale = false;
860
- }
861
-
862
- if (isFixedStrategy === void 0) {
863
- isFixedStrategy = false;
864
- }
865
-
866
- const clientRect = element.getBoundingClientRect();
867
- let scaleX = 1;
868
- let scaleY = 1;
869
-
870
- if (includeScale && isHTMLElement(element)) {
871
- scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
872
- scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
873
- }
874
-
875
- const win = isElement(element) ? getWindow(element) : window;
876
- const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
877
- const x = (clientRect.left + (addVisualOffsets ? (_win$visualViewport$o = (_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) != null ? _win$visualViewport$o : 0 : 0)) / scaleX;
878
- const y = (clientRect.top + (addVisualOffsets ? (_win$visualViewport$o2 = (_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) != null ? _win$visualViewport$o2 : 0 : 0)) / scaleY;
879
- const width = clientRect.width / scaleX;
880
- const height = clientRect.height / scaleY;
881
- return {
882
- width,
883
- height,
884
- top: y,
885
- right: x + width,
886
- bottom: y + height,
887
- left: x,
888
- x,
889
- y
890
- };
891
- }
892
-
893
- function getDocumentElement(node) {
894
- return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
895
- }
896
-
897
- function getNodeScroll(element) {
898
- if (isElement(element)) {
899
- return {
900
- scrollLeft: element.scrollLeft,
901
- scrollTop: element.scrollTop
902
- };
903
- }
904
-
905
- return {
906
- scrollLeft: element.pageXOffset,
907
- scrollTop: element.pageYOffset
908
- };
909
- }
910
-
911
- function getWindowScrollBarX(element) {
912
- // If <html> has a CSS width greater than the viewport, then this will be
913
- // incorrect for RTL.
914
- return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
915
- }
916
-
917
- function isScaled(element) {
918
- const rect = getBoundingClientRect(element);
919
- return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
920
- }
921
-
922
- function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
923
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
924
- const documentElement = getDocumentElement(offsetParent);
925
- const rect = getBoundingClientRect(element, // @ts-ignore - checked above (TS 4.1 compat)
926
- isOffsetParentAnElement && isScaled(offsetParent), strategy === 'fixed');
927
- let scroll = {
928
- scrollLeft: 0,
929
- scrollTop: 0
930
- };
931
- const offsets = {
932
- x: 0,
933
- y: 0
934
- };
935
-
936
- if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
937
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
938
- scroll = getNodeScroll(offsetParent);
103
+ defaultSelectedChanged() {
104
+ if (!this.dirtySelected) {
105
+ this.selected = this.defaultSelected;
106
+ if (this.proxy instanceof HTMLOptionElement) {
107
+ this.proxy.selected = this.defaultSelected;
108
+ }
109
+ }
939
110
  }
940
-
941
- if (isHTMLElement(offsetParent)) {
942
- const offsetRect = getBoundingClientRect(offsetParent, true);
943
- offsets.x = offsetRect.x + offsetParent.clientLeft;
944
- offsets.y = offsetRect.y + offsetParent.clientTop;
945
- } else if (documentElement) {
946
- offsets.x = getWindowScrollBarX(documentElement);
111
+ disabledChanged(prev, next) {
112
+ this.ariaDisabled = this.disabled ? "true" : "false";
113
+ if (this.proxy instanceof HTMLOptionElement) {
114
+ this.proxy.disabled = this.disabled;
115
+ }
947
116
  }
948
- }
949
-
950
- return {
951
- x: rect.left + scroll.scrollLeft - offsets.x,
952
- y: rect.top + scroll.scrollTop - offsets.y,
953
- width: rect.width,
954
- height: rect.height
955
- };
956
- }
957
-
958
- function getParentNode(node) {
959
- if (getNodeName(node) === 'html') {
960
- return node;
961
- }
962
-
963
- return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
964
- // @ts-ignore
965
- node.assignedSlot || // step into the shadow DOM of the parent of a slotted node
966
- node.parentNode || ( // DOM Element detected
967
- isShadowRoot(node) ? node.host : null) || // ShadowRoot detected
968
- getDocumentElement(node) // fallback
969
-
970
- );
971
- }
972
-
973
- function getTrueOffsetParent(element) {
974
- if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
975
- return null;
976
- }
977
-
978
- return element.offsetParent;
979
- }
980
-
981
- function getContainingBlock(element) {
982
- let currentNode = getParentNode(element);
983
-
984
- if (isShadowRoot(currentNode)) {
985
- currentNode = currentNode.host;
986
- }
987
-
988
- while (isHTMLElement(currentNode) && !['html', 'body'].includes(getNodeName(currentNode))) {
989
- if (isContainingBlock(currentNode)) {
990
- return currentNode;
991
- } else {
992
- currentNode = currentNode.parentNode;
117
+ selectedAttributeChanged() {
118
+ this.defaultSelected = this.selectedAttribute;
119
+ if (this.proxy instanceof HTMLOptionElement) {
120
+ this.proxy.defaultSelected = this.defaultSelected;
121
+ }
993
122
  }
994
- }
995
-
996
- return null;
997
- } // Gets the closest ancestor positioned element. Handles some edge cases,
998
- // such as table ancestors and cross browser bugs.
999
-
1000
-
1001
- function getOffsetParent(element) {
1002
- const window = getWindow(element);
1003
- let offsetParent = getTrueOffsetParent(element);
1004
-
1005
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
1006
- offsetParent = getTrueOffsetParent(offsetParent);
1007
- }
1008
-
1009
- if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
1010
- return window;
1011
- }
1012
-
1013
- return offsetParent || getContainingBlock(element) || window;
1014
- }
1015
-
1016
- function getDimensions(element) {
1017
- if (isHTMLElement(element)) {
1018
- return {
1019
- width: element.offsetWidth,
1020
- height: element.offsetHeight
1021
- };
1022
- }
1023
-
1024
- const rect = getBoundingClientRect(element);
1025
- return {
1026
- width: rect.width,
1027
- height: rect.height
1028
- };
1029
- }
1030
-
1031
- function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1032
- let {
1033
- rect,
1034
- offsetParent,
1035
- strategy
1036
- } = _ref;
1037
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
1038
- const documentElement = getDocumentElement(offsetParent);
1039
-
1040
- if (offsetParent === documentElement) {
1041
- return rect;
1042
- }
1043
-
1044
- let scroll = {
1045
- scrollLeft: 0,
1046
- scrollTop: 0
1047
- };
1048
- const offsets = {
1049
- x: 0,
1050
- y: 0
1051
- };
1052
-
1053
- if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
1054
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1055
- scroll = getNodeScroll(offsetParent);
123
+ selectedChanged() {
124
+ this.ariaSelected = this.selected ? "true" : "false";
125
+ if (!this.dirtySelected) {
126
+ this.dirtySelected = true;
127
+ }
128
+ if (this.proxy instanceof HTMLOptionElement) {
129
+ this.proxy.selected = this.selected;
130
+ }
1056
131
  }
1057
-
1058
- if (isHTMLElement(offsetParent)) {
1059
- const offsetRect = getBoundingClientRect(offsetParent, true);
1060
- offsets.x = offsetRect.x + offsetParent.clientLeft;
1061
- offsets.y = offsetRect.y + offsetParent.clientTop;
1062
- } // This doesn't appear to be need to be negated.
1063
- // else if (documentElement) {
1064
- // offsets.x = getWindowScrollBarX(documentElement);
1065
- // }
1066
-
1067
- }
1068
-
1069
- return { ...rect,
1070
- x: rect.x - scroll.scrollLeft + offsets.x,
1071
- y: rect.y - scroll.scrollTop + offsets.y
1072
- };
1073
- }
1074
-
1075
- function getViewportRect(element, strategy) {
1076
- const win = getWindow(element);
1077
- const html = getDocumentElement(element);
1078
- const visualViewport = win.visualViewport;
1079
- let width = html.clientWidth;
1080
- let height = html.clientHeight;
1081
- let x = 0;
1082
- let y = 0;
1083
-
1084
- if (visualViewport) {
1085
- width = visualViewport.width;
1086
- height = visualViewport.height;
1087
- const layoutViewport = isLayoutViewport();
1088
-
1089
- if (layoutViewport || !layoutViewport && strategy === 'fixed') {
1090
- x = visualViewport.offsetLeft;
1091
- y = visualViewport.offsetTop;
132
+ initialValueChanged(previous, next) {
133
+ // If the value is clean and the component is connected to the DOM
134
+ // then set value equal to the attribute value.
135
+ if (!this.dirtyValue) {
136
+ this.value = this.initialValue;
137
+ this.dirtyValue = false;
138
+ }
1092
139
  }
1093
- }
1094
-
1095
- return {
1096
- width,
1097
- height,
1098
- x,
1099
- y
1100
- };
1101
- }
1102
-
1103
- // of the `<html>` and `<body>` rect bounds if horizontally scrollable
1104
-
1105
- function getDocumentRect(element) {
1106
- var _element$ownerDocumen;
1107
-
1108
- const html = getDocumentElement(element);
1109
- const scroll = getNodeScroll(element);
1110
- const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
1111
- const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
1112
- const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
1113
- let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1114
- const y = -scroll.scrollTop;
1115
-
1116
- if (getComputedStyle$1(body || html).direction === 'rtl') {
1117
- x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
1118
- }
1119
-
1120
- return {
1121
- width,
1122
- height,
1123
- x,
1124
- y
1125
- };
1126
- }
1127
-
1128
- function getNearestOverflowAncestor(node) {
1129
- const parentNode = getParentNode(node);
1130
-
1131
- if (['html', 'body', '#document'].includes(getNodeName(parentNode))) {
1132
- // @ts-ignore assume body is always available
1133
- return node.ownerDocument.body;
1134
- }
1135
-
1136
- if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1137
- return parentNode;
1138
- }
1139
-
1140
- return getNearestOverflowAncestor(parentNode);
1141
- }
1142
-
1143
- function getOverflowAncestors(node, list) {
1144
- var _node$ownerDocument;
1145
-
1146
- if (list === void 0) {
1147
- list = [];
1148
- }
1149
-
1150
- const scrollableAncestor = getNearestOverflowAncestor(node);
1151
- const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
1152
- const win = getWindow(scrollableAncestor);
1153
- const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
1154
- const updatedList = list.concat(target);
1155
- return isBody ? updatedList : // @ts-ignore: isBody tells us target will be an HTMLElement here
1156
- updatedList.concat(getOverflowAncestors(target));
1157
- }
1158
-
1159
- function contains(parent, child) {
1160
- const rootNode = child.getRootNode == null ? void 0 : child.getRootNode(); // First, attempt with faster native method
1161
-
1162
- if (parent.contains(child)) {
1163
- return true;
1164
- } // then fallback to custom implementation with Shadow DOM support
1165
- else if (rootNode && isShadowRoot(rootNode)) {
1166
- let next = child;
1167
-
1168
- do {
1169
- // use `===` replace node.isSameNode()
1170
- if (next && parent === next) {
1171
- return true;
1172
- } // @ts-ignore: need a better way to handle this...
1173
-
1174
-
1175
- next = next.parentNode || next.host;
1176
- } while (next);
1177
- }
1178
-
1179
- return false;
1180
- }
1181
-
1182
- function getInnerBoundingClientRect(element, strategy) {
1183
- const clientRect = getBoundingClientRect(element, false, strategy === 'fixed');
1184
- const top = clientRect.top + element.clientTop;
1185
- const left = clientRect.left + element.clientLeft;
1186
- return {
1187
- top,
1188
- left,
1189
- x: left,
1190
- y: top,
1191
- right: left + element.clientWidth,
1192
- bottom: top + element.clientHeight,
1193
- width: element.clientWidth,
1194
- height: element.clientHeight
1195
- };
1196
- }
1197
-
1198
- function getClientRectFromClippingAncestor(element, clippingParent, strategy) {
1199
- if (clippingParent === 'viewport') {
1200
- return rectToClientRect(getViewportRect(element, strategy));
1201
- }
1202
-
1203
- if (isElement(clippingParent)) {
1204
- return getInnerBoundingClientRect(clippingParent, strategy);
1205
- }
1206
-
1207
- return rectToClientRect(getDocumentRect(getDocumentElement(element)));
1208
- } // A "clipping ancestor" is an overflowable container with the characteristic of
1209
- // clipping (or hiding) overflowing elements with a position different from
1210
- // `initial`
1211
-
1212
-
1213
- function getClippingAncestors(element) {
1214
- const clippingAncestors = getOverflowAncestors(element);
1215
- const canEscapeClipping = ['absolute', 'fixed'].includes(getComputedStyle$1(element).position);
1216
- const clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
1217
-
1218
- if (!isElement(clipperElement)) {
1219
- return [];
1220
- } // @ts-ignore isElement check ensures we return Array<Element>
1221
-
1222
-
1223
- return clippingAncestors.filter(clippingAncestors => isElement(clippingAncestors) && contains(clippingAncestors, clipperElement) && getNodeName(clippingAncestors) !== 'body');
1224
- } // Gets the maximum area that the element is visible in due to any number of
1225
- // clipping ancestors
1226
-
1227
-
1228
- function getClippingRect(_ref) {
1229
- let {
1230
- element,
1231
- boundary,
1232
- rootBoundary,
1233
- strategy
1234
- } = _ref;
1235
- const mainClippingAncestors = boundary === 'clippingAncestors' ? getClippingAncestors(element) : [].concat(boundary);
1236
- const clippingAncestors = [...mainClippingAncestors, rootBoundary];
1237
- const firstClippingAncestor = clippingAncestors[0];
1238
- const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1239
- const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1240
- accRect.top = max(rect.top, accRect.top);
1241
- accRect.right = min(rect.right, accRect.right);
1242
- accRect.bottom = min(rect.bottom, accRect.bottom);
1243
- accRect.left = max(rect.left, accRect.left);
1244
- return accRect;
1245
- }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1246
- return {
1247
- width: clippingRect.right - clippingRect.left,
1248
- height: clippingRect.bottom - clippingRect.top,
1249
- x: clippingRect.left,
1250
- y: clippingRect.top
1251
- };
1252
- }
1253
-
1254
- const platform = {
1255
- getClippingRect,
1256
- convertOffsetParentRelativeRectToViewportRelativeRect,
1257
- isElement,
1258
- getDimensions,
1259
- getOffsetParent,
1260
- getDocumentElement,
1261
- getElementRects: _ref => {
1262
- let {
1263
- reference,
1264
- floating,
1265
- strategy
1266
- } = _ref;
1267
- return {
1268
- reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
1269
- floating: { ...getDimensions(floating),
1270
- x: 0,
1271
- y: 0
1272
- }
1273
- };
1274
- },
1275
- getClientRects: element => Array.from(element.getClientRects()),
1276
- isRTL: element => getComputedStyle$1(element).direction === 'rtl'
1277
- };
1278
-
1279
- /**
1280
- * Automatically updates the position of the floating element when necessary.
1281
- * @see https://floating-ui.com/docs/autoUpdate
1282
- */
1283
- function autoUpdate(reference, floating, update, options) {
1284
- if (options === void 0) {
1285
- options = {};
1286
- }
1287
-
1288
- const {
1289
- ancestorScroll: _ancestorScroll = true,
1290
- ancestorResize: _ancestorResize = true,
1291
- elementResize = true,
1292
- animationFrame = false
1293
- } = options;
1294
- const ancestorScroll = _ancestorScroll && !animationFrame;
1295
- const ancestorResize = _ancestorResize && !animationFrame;
1296
- const ancestors = ancestorScroll || ancestorResize ? [...(isElement(reference) ? getOverflowAncestors(reference) : []), ...getOverflowAncestors(floating)] : [];
1297
- ancestors.forEach(ancestor => {
1298
- ancestorScroll && ancestor.addEventListener('scroll', update, {
1299
- passive: true
1300
- });
1301
- ancestorResize && ancestor.addEventListener('resize', update);
1302
- });
1303
- let observer = null;
1304
-
1305
- if (elementResize) {
1306
- let initialUpdate = true;
1307
- observer = new ResizeObserver(() => {
1308
- if (!initialUpdate) {
1309
- update();
1310
- }
1311
-
1312
- initialUpdate = false;
1313
- });
1314
- isElement(reference) && !animationFrame && observer.observe(reference);
1315
- observer.observe(floating);
1316
- }
1317
-
1318
- let frameId;
1319
- let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1320
-
1321
- if (animationFrame) {
1322
- frameLoop();
1323
- }
1324
-
1325
- function frameLoop() {
1326
- const nextRefRect = getBoundingClientRect(reference);
1327
-
1328
- if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
1329
- update();
140
+ get label() {
141
+ var _a;
142
+ return (_a = this.value) !== null && _a !== void 0 ? _a : this.text;
1330
143
  }
1331
-
1332
- prevRefRect = nextRefRect;
1333
- frameId = requestAnimationFrame(frameLoop);
1334
- }
1335
-
1336
- update();
1337
- return () => {
1338
- var _observer;
1339
-
1340
- ancestors.forEach(ancestor => {
1341
- ancestorScroll && ancestor.removeEventListener('scroll', update);
1342
- ancestorResize && ancestor.removeEventListener('resize', update);
1343
- });
1344
- (_observer = observer) == null ? void 0 : _observer.disconnect();
1345
- observer = null;
1346
-
1347
- if (animationFrame) {
1348
- cancelAnimationFrame(frameId);
144
+ get text() {
145
+ var _a, _b;
146
+ return (_b = (_a = this.textContent) === null || _a === void 0 ? void 0 : _a.replace(/\s+/g, " ").trim()) !== null && _b !== void 0 ? _b : "";
1349
147
  }
1350
- };
1351
- }
1352
-
148
+ set value(next) {
149
+ const newValue = `${next !== null && next !== void 0 ? next : ""}`;
150
+ this._value = newValue;
151
+ this.dirtyValue = true;
152
+ if (this.proxy instanceof HTMLOptionElement) {
153
+ this.proxy.value = newValue;
154
+ }
155
+ Observable.notify(this, "value");
156
+ }
157
+ get value() {
158
+ var _a;
159
+ Observable.track(this, "value");
160
+ return (_a = this._value) !== null && _a !== void 0 ? _a : this.text;
161
+ }
162
+ get form() {
163
+ return this.proxy ? this.proxy.form : null;
164
+ }
165
+ }
166
+ __decorate([
167
+ observable
168
+ ], ListboxOption$1.prototype, "checked", void 0);
169
+ __decorate([
170
+ observable
171
+ ], ListboxOption$1.prototype, "content", void 0);
172
+ __decorate([
173
+ observable
174
+ ], ListboxOption$1.prototype, "defaultSelected", void 0);
175
+ __decorate([
176
+ attr({ mode: "boolean" })
177
+ ], ListboxOption$1.prototype, "disabled", void 0);
178
+ __decorate([
179
+ attr({ attribute: "selected", mode: "boolean" })
180
+ ], ListboxOption$1.prototype, "selectedAttribute", void 0);
181
+ __decorate([
182
+ observable
183
+ ], ListboxOption$1.prototype, "selected", void 0);
184
+ __decorate([
185
+ attr({ attribute: "value", mode: "fromView" })
186
+ ], ListboxOption$1.prototype, "initialValue", void 0);
1353
187
  /**
1354
- * Computes the `x` and `y` coordinates that will place the floating element
1355
- * next to a reference element when it is given a certain CSS positioning
1356
- * strategy.
188
+ * States and properties relating to the ARIA `option` role.
189
+ *
190
+ * @public
1357
191
  */
1358
-
1359
- const computePosition = (reference, floating, options) => computePosition$1(reference, floating, {
1360
- platform,
1361
- ...options
1362
- });
1363
-
1364
- var _Popup_instances, _Popup_arrowPosition_get, _Popup_padding_get, _Popup_distance_get, _Popup_strategy_get, _Popup_middleware_get, _Popup_cleanup, _Popup_anchorEl, _Popup_assignPopupPosition, _Popup_assignArrowPosition, _Popup_getAnchorById, _Popup_handleKeydown;
1365
- class Popup extends FoundationElement {
1366
- constructor() {
1367
- super();
1368
- _Popup_instances.add(this);
1369
- _Popup_cleanup.set(this, void 0);
1370
- _Popup_anchorEl.set(this, void 0);
1371
- this.open = false;
1372
- this.dismissible = false;
1373
- this.arrow = false;
1374
- this.alternate = false;
1375
- _Popup_handleKeydown.set(this, event => {
1376
- if (event.key === keyEscape) {
1377
- this.open = false;
1378
- }
1379
- });
1380
- }
1381
- openChanged(_, newValue) {
1382
- newValue ? this.$emit('open') : this.$emit('close');
1383
- }
1384
- disconnectedCallback() {
1385
- var _a, _b;
1386
- super.disconnectedCallback();
1387
- (_a = __classPrivateFieldGet(this, _Popup_anchorEl, "f")) === null || _a === void 0 ? void 0 : _a.removeEventListener('keydown', __classPrivateFieldGet(this, _Popup_handleKeydown, "f"));
1388
- (_b = __classPrivateFieldGet(this, _Popup_cleanup, "f")) === null || _b === void 0 ? void 0 : _b.call(this);
1389
- }
1390
- attributeChangedCallback(name, oldValue, newValue) {
1391
- var _a, _b, _c;
1392
- super.attributeChangedCallback(name, oldValue, newValue);
1393
- switch (name) {
1394
- case 'anchor':
1395
- {
1396
- (_a = __classPrivateFieldGet(this, _Popup_anchorEl, "f")) === null || _a === void 0 ? void 0 : _a.removeEventListener('keydown', __classPrivateFieldGet(this, _Popup_handleKeydown, "f"));
1397
- __classPrivateFieldSet(this, _Popup_anchorEl, __classPrivateFieldGet(this, _Popup_instances, "m", _Popup_getAnchorById).call(this), "f");
1398
- (_b = __classPrivateFieldGet(this, _Popup_anchorEl, "f")) === null || _b === void 0 ? void 0 : _b.addEventListener('keydown', __classPrivateFieldGet(this, _Popup_handleKeydown, "f"));
1399
- break;
1400
- }
1401
- }
1402
- if (__classPrivateFieldGet(this, _Popup_anchorEl, "f") && this.popupEl) {
1403
- __classPrivateFieldSet(this, _Popup_cleanup, autoUpdate(__classPrivateFieldGet(this, _Popup_anchorEl, "f"), this.popupEl, () => this.updatePosition()), "f");
1404
- } else {
1405
- (_c = __classPrivateFieldGet(this, _Popup_cleanup, "f")) === null || _c === void 0 ? void 0 : _c.call(this);
1406
- }
1407
- }
1408
- async updatePosition() {
1409
- if (!this.open || !__classPrivateFieldGet(this, _Popup_anchorEl, "f")) {
1410
- return;
1411
- }
1412
- const positionData = await computePosition(__classPrivateFieldGet(this, _Popup_anchorEl, "f"), this.popupEl, {
1413
- placement: this.placement,
1414
- strategy: __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_strategy_get),
1415
- middleware: __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_middleware_get)
1416
- });
1417
- __classPrivateFieldGet(this, _Popup_instances, "m", _Popup_assignPopupPosition).call(this, positionData);
1418
- if (this.arrow) {
1419
- __classPrivateFieldGet(this, _Popup_instances, "m", _Popup_assignArrowPosition).call(this, positionData);
1420
- }
1421
- }
1422
- }
1423
- _Popup_cleanup = new WeakMap(), _Popup_anchorEl = new WeakMap(), _Popup_handleKeydown = new WeakMap(), _Popup_instances = new WeakSet(), _Popup_arrowPosition_get = function _Popup_arrowPosition_get() {
1424
- return {
1425
- top: 'bottom',
1426
- right: 'left',
1427
- bottom: 'top',
1428
- left: 'right'
1429
- };
1430
- }, _Popup_padding_get = function _Popup_padding_get() {
1431
- return 0;
1432
- }, _Popup_distance_get = function _Popup_distance_get() {
1433
- return 12;
1434
- }, _Popup_strategy_get = function _Popup_strategy_get() {
1435
- return 'fixed';
1436
- }, _Popup_middleware_get = function _Popup_middleware_get() {
1437
- const middleware = [flip(), hide(), inline()];
1438
- if (this.arrow) {
1439
- middleware.push(arrow({
1440
- element: this.arrowEl,
1441
- padding: __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_padding_get)
1442
- }), offset(__classPrivateFieldGet(this, _Popup_instances, "a", _Popup_distance_get)));
1443
- }
1444
- return middleware;
1445
- }, _Popup_assignPopupPosition = function _Popup_assignPopupPosition(data) {
1446
- const {
1447
- x: popupX,
1448
- y: popupY
1449
- } = data;
1450
- const {
1451
- referenceHidden
1452
- } = data.middlewareData.hide;
1453
- Object.assign(this.popupEl.style, {
1454
- left: `${popupX}px`,
1455
- top: `${popupY}px`,
1456
- visibility: referenceHidden ? 'hidden' : 'visible'
1457
- });
1458
- }, _Popup_assignArrowPosition = function _Popup_assignArrowPosition(data) {
1459
- const {
1460
- x: arrowX,
1461
- y: arrowY
1462
- } = data.middlewareData.arrow;
1463
- const side = __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_arrowPosition_get)[data.placement.split('-')[0]];
1464
- Object.assign(this.arrowEl.style, {
1465
- left: `${arrowX}px`,
1466
- top: `${arrowY}px`,
1467
- right: '',
1468
- bottom: '',
1469
- [side]: '-4px'
1470
- });
1471
- }, _Popup_getAnchorById = function _Popup_getAnchorById() {
1472
- return document.getElementById(this.anchor);
1473
- };
1474
- __decorate([attr({
1475
- mode: 'boolean'
1476
- }), __metadata("design:type", Object)], Popup.prototype, "open", void 0);
1477
- __decorate([attr({
1478
- mode: 'boolean'
1479
- }), __metadata("design:type", Object)], Popup.prototype, "dismissible", void 0);
1480
- __decorate([attr({
1481
- mode: 'boolean'
1482
- }), __metadata("design:type", Object)], Popup.prototype, "arrow", void 0);
192
+ class DelegatesARIAListboxOption {
193
+ }
194
+ __decorate([
195
+ observable
196
+ ], DelegatesARIAListboxOption.prototype, "ariaChecked", void 0);
197
+ __decorate([
198
+ observable
199
+ ], DelegatesARIAListboxOption.prototype, "ariaPosInSet", void 0);
200
+ __decorate([
201
+ observable
202
+ ], DelegatesARIAListboxOption.prototype, "ariaSelected", void 0);
203
+ __decorate([
204
+ observable
205
+ ], DelegatesARIAListboxOption.prototype, "ariaSetSize", void 0);
206
+ applyMixins(DelegatesARIAListboxOption, ARIAGlobalStatesAndProperties);
207
+ applyMixins(ListboxOption$1, StartEnd, DelegatesARIAListboxOption);
208
+
209
+ class ListboxOption extends ListboxOption$1 {}
1483
210
  __decorate([attr({
1484
- mode: 'boolean'
1485
- }), __metadata("design:type", Object)], Popup.prototype, "alternate", void 0);
1486
- __decorate([attr({
1487
- mode: 'fromView'
1488
- }), __metadata("design:type", String)], Popup.prototype, "placement", void 0);
1489
- __decorate([attr, __metadata("design:type", String)], Popup.prototype, "anchor", void 0);
1490
-
1491
- var css_248z = ".control {\n background: var(--vvd-color-surface-4dp);\n border-radius: inherit;\n contain: layout;\n inline-size: fit-content;\n}\n.control:not(.open) {\n display: none;\n}\n\n.popup-wrapper {\n position: fixed;\n border-radius: 6px;\n}\n\n.popup-content {\n display: grid;\n color: var(--vvd-color-canvas-text); /* neutral-100 */\n}\n.dismissible .popup-content {\n align-content: start;\n grid-template-columns: 1fr auto;\n}\n\n.arrow {\n position: absolute;\n z-index: -1;\n width: 8px;\n height: 8px;\n background: var(--vvd-color-surface-4dp);\n transform: rotate(45deg);\n}\n\n.dismissible-button {\n align-self: flex-start;\n margin-block-start: 4px;\n margin-inline-end: 4px;\n}";
211
+ attribute: 'text'
212
+ }), __metadata("design:type", String)], ListboxOption.prototype, "optionText", void 0);
213
+ applyMixins(ListboxOption, AffixIconWithTrailing);
1492
214
 
1493
215
  let _ = t => t,
1494
216
  _t,
1495
- _t2,
1496
- _t3;
217
+ _t2;
1497
218
  const getClasses = ({
1498
- open,
1499
- dismissible,
1500
- alternate
1501
- }) => classNames('control', ['open', Boolean(open)], ['dismissible', Boolean(dismissible)], ['alternate', Boolean(alternate)]);
1502
- const popupTemplate = () => html(_t || (_t = _`
1503
- <vwc-elevation>
1504
- <!--the popup-wrapper is needed for alternating the inside of the popup nd not its shadow-->
1505
- <div class="popup-wrapper" ${0}>
1506
- <div class="${0}" aria-hidden="${0}"
1507
- part="${0}">
1508
- <div class="popup-content">
1509
- <slot></slot>
1510
- ${0}
1511
- </div>
1512
- ${0}
1513
- </div>
1514
- </div>
1515
- </vwc-elevation>`), ref('popupEl'), getClasses, x => x.open ? 'false' : 'true', x => x.alternate ? 'vvd-theme-alternate' : '', when(x => x.dismissible, html(_t2 || (_t2 = _`<vwc-button density="condensed" @click="${0}"
1516
- class="dismissible-button" icon="close-small-solid" shape="pill"></vwc-button>`), x => x.open = false)), when(x => x.arrow, html(_t3 || (_t3 = _`<div class="arrow" ${0}></div>`), ref('arrowEl'))));
219
+ icon,
220
+ disabled,
221
+ selected,
222
+ checked
223
+ }) => classNames('base', ['disabled', disabled], ['selected', Boolean(selected)], ['active', Boolean(checked)], ['icon', Boolean(icon)]);
224
+ const ListboxOptionTemplate = context => {
225
+ const affixIconTemplate = affixIconTemplateFactory(context);
226
+ const focusTemplate = focusTemplateFactory(context);
227
+ return html(_t || (_t = _`
228
+ <template
229
+ aria-checked="${0}"
230
+ aria-disabled="${0}"
231
+ aria-posinset="${0}"
232
+ aria-selected="${0}"
233
+ aria-setsize="${0}"
234
+ role="option">
235
+ <div class="${0}">
236
+ ${0}
237
+ ${0}
238
+ ${0}
239
+ </div>
240
+ </template>
241
+ `), x => x.ariaChecked, x => x.ariaDisabled, x => x.ariaPosInSet, x => x.ariaSelected, x => x.ariaSetSize, getClasses, () => focusTemplate, x => affixIconTemplate(x.icon), when(x => x.optionText, html(_t2 || (_t2 = _`<div class="text">${0}</div>`), x => x.optionText)));
242
+ };
243
+
244
+ var css_248z = "/**\n * Do not edit directly\n * Generated on Mon, 07 Nov 2022 11:12:43 GMT\n */\n.base {\n position: relative; /* this is needed for the focus */\n display: flex;\n box-sizing: border-box;\n align-items: center;\n background-color: var(--_appearance-color-fill);\n border-radius: 6px;\n box-shadow: inset 0 0 0 1px var(--_appearance-color-outline);\n color: var(--_appearance-color-text);\n font: var(--vvd-typography-base);\n gap: 8px;\n hyphens: auto;\n inline-size: 100%;\n min-block-size: calc(1px * (40 + 8 * clamp(-1, var(--vvd-size-density, 0), 1)));\n padding-block: 10px;\n padding-inline: 8px;\n vertical-align: middle;\n word-break: break-word;\n}\n.base {\n --_connotation-color-primary: var(--vvd-color-canvas-text);\n --_connotation-color-primary-text: var(--vvd-color-canvas);\n --_connotation-color-primary-increment: var(--vvd-color-neutral-800);\n --_connotation-color-faint: var(--vvd-color-neutral-50);\n --_connotation-color-soft: var(--vvd-color-neutral-100);\n}\n.base {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: transparent;\n}\n.base:where(:hover, .hover):where(:not(:disabled, .disabled)) {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: var(--_connotation-color-faint);\n --_appearance-color-outline: transparent;\n}\n.base:where(:disabled, .disabled) {\n --_appearance-color-text: var(--vvd-color-neutral-400);\n --_appearance-color-fill: transparent;\n --_appearance-color-outline: transparent;\n}\n.base:where(:active, .active):where(:not(:disabled, .disabled)) {\n --_appearance-color-text: var(--_connotation-color-primary);\n --_appearance-color-fill: var(--_connotation-color-soft);\n --_appearance-color-outline: transparent;\n}\n.base:where(.selected, [aria-current]):where(:not(:disabled, .disabled, :hover, .hover)) {\n --_appearance-color-text: var(--_connotation-color-primary-text);\n --_appearance-color-fill: var(--_connotation-color-primary);\n --_appearance-color-outline: transparent;\n}\n.base:where(.selected, [aria-current]):where(:hover, .hover) {\n --_appearance-color-text: var(--_connotation-color-primary-text);\n --_appearance-color-fill: var(--_connotation-color-primary-increment);\n --_appearance-color-outline: transparent;\n}\n@supports (user-select: none) {\n .base {\n user-select: none;\n }\n}\n.base:not(.disabled) {\n cursor: pointer;\n}\n.base.disabled {\n cursor: not-allowed;\n}\n.base .text {\n font: var(--vvd-typography-base);\n}\n\n.icon {\n font-size: 20px;\n}\n\n.focus-indicator {\n --focus-stroke-color: var(--vvd-color-neutral-500);\n --focus-stroke-gap-color: transparent;\n}\n:host(:not([aria-checked=true])) .focus-indicator {\n display: none;\n}";
1517
245
 
1518
- const vividPopup = Popup.compose({
1519
- baseName: 'popup',
1520
- template: popupTemplate,
246
+ const vividListboxOption = ListboxOption.compose({
247
+ baseName: 'option',
248
+ template: ListboxOptionTemplate,
1521
249
  styles: css_248z
1522
250
  });
1523
- designSystem.register(vividPopup());
251
+ designSystem.register(vividListboxOption());
1524
252
 
1525
- export { Popup as P, vividPopup as v };
253
+ export { isListboxOption as i, vividListboxOption as v };