@rededor/cura 1.8.3-alpha.0 → 2.0.0-alpha.5

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 (62) hide show
  1. package/dist/cjs/{cura-accordion_20.cjs.entry.js → cura-accordion_21.cjs.entry.js} +1705 -20
  2. package/dist/cjs/cura-accordion_21.cjs.entry.js.map +1 -0
  3. package/dist/cjs/cura-alert.cjs.entry.js +4 -3
  4. package/dist/cjs/cura-alert.cjs.entry.js.map +1 -1
  5. package/dist/cjs/cura-alert.entry.cjs.js.map +1 -1
  6. package/dist/cjs/cura.cjs.js +1 -1
  7. package/dist/cjs/loader.cjs.js +1 -1
  8. package/dist/collection/components/cura-alert/cura-alert.js +4 -3
  9. package/dist/collection/components/cura-alert/cura-alert.js.map +1 -1
  10. package/dist/collection/components/cura-dropdown-search/cura-dropdown-search.css +1 -1
  11. package/dist/collection/components/cura-dropdown-search/cura-dropdown-search.js +24 -4
  12. package/dist/collection/components/cura-dropdown-search/cura-dropdown-search.js.map +1 -1
  13. package/dist/collection/components/forms/cura-select/cura-select.css +3 -148
  14. package/dist/collection/components/forms/cura-select/cura-select.js +103 -11
  15. package/dist/collection/components/forms/cura-select/cura-select.js.map +1 -1
  16. package/dist/collection/components/forms/cura-select-options/cura-select-option.css +15 -0
  17. package/dist/components/cura-alert.js +4 -3
  18. package/dist/components/cura-alert.js.map +1 -1
  19. package/dist/components/cura-calendar.js +1 -1
  20. package/dist/components/cura-dropdown-search.js +25 -5
  21. package/dist/components/cura-dropdown-search.js.map +1 -1
  22. package/dist/components/cura-input-date.js +3 -3
  23. package/dist/components/cura-select-option.js +1 -1
  24. package/dist/components/cura-select.js +1 -1
  25. package/dist/components/p-Cs5scX1L.js +2037 -0
  26. package/dist/components/p-Cs5scX1L.js.map +1 -0
  27. package/dist/components/{p-BGnJiNyu.js → p-D6PpdPRJ.js} +4 -4
  28. package/dist/components/{p-BGnJiNyu.js.map → p-D6PpdPRJ.js.map} +1 -1
  29. package/dist/components/{p-DpIu_Oxz.js → p-Dt450DkQ.js} +3 -3
  30. package/dist/components/p-Dt450DkQ.js.map +1 -0
  31. package/dist/cura/cura-alert.entry.esm.js.map +1 -1
  32. package/dist/cura/cura.esm.js +1 -1
  33. package/dist/cura/p-6dfc7c02.entry.js +2 -0
  34. package/dist/cura/p-6dfc7c02.entry.js.map +1 -0
  35. package/dist/cura/p-bdfe9af2.entry.js +2 -0
  36. package/dist/cura/p-bdfe9af2.entry.js.map +1 -0
  37. package/dist/esm/{cura-accordion_20.entry.js → cura-accordion_21.entry.js} +1705 -21
  38. package/dist/esm/cura-accordion_21.entry.js.map +1 -0
  39. package/dist/esm/cura-alert.entry.js +4 -3
  40. package/dist/esm/cura-alert.entry.js.map +1 -1
  41. package/dist/esm/cura.js +1 -1
  42. package/dist/esm/loader.js +1 -1
  43. package/dist/types/components/cura-dropdown-search/cura-dropdown-search.d.ts +2 -0
  44. package/dist/types/components/forms/cura-select/cura-select.d.ts +21 -0
  45. package/package.json +3 -2
  46. package/dist/cjs/cura-accordion_20.cjs.entry.js.map +0 -1
  47. package/dist/cjs/cura-card.cjs.entry.js +0 -81
  48. package/dist/cjs/cura-card.cjs.entry.js.map +0 -1
  49. package/dist/cjs/cura-card.entry.cjs.js.map +0 -1
  50. package/dist/components/p-BTt-pVTn.js +0 -442
  51. package/dist/components/p-BTt-pVTn.js.map +0 -1
  52. package/dist/components/p-DpIu_Oxz.js.map +0 -1
  53. package/dist/cura/cura-card.entry.esm.js.map +0 -1
  54. package/dist/cura/p-6feba852.entry.js +0 -2
  55. package/dist/cura/p-6feba852.entry.js.map +0 -1
  56. package/dist/cura/p-d8aeca82.entry.js +0 -2
  57. package/dist/cura/p-d8aeca82.entry.js.map +0 -1
  58. package/dist/cura/p-deb0b764.entry.js +0 -2
  59. package/dist/cura/p-deb0b764.entry.js.map +0 -1
  60. package/dist/esm/cura-accordion_20.entry.js.map +0 -1
  61. package/dist/esm/cura-card.entry.js +0 -79
  62. package/dist/esm/cura-card.entry.js.map +0 -1
@@ -0,0 +1,2037 @@
1
+ import { p as proxyCustomElement, H, e as createEvent, h, d as Host } from './p-D1cPOZpG.js';
2
+ import { d as defineCustomElement$2 } from './p-B5aO1chh.js';
3
+ import { d as defineCustomElement$1 } from './p-DR1RHrEX.js';
4
+
5
+ /**
6
+ * Custom positioning reference element.
7
+ * @see https://floating-ui.com/docs/virtual-elements
8
+ */
9
+
10
+ const min = Math.min;
11
+ const max = Math.max;
12
+ const round = Math.round;
13
+ const floor = Math.floor;
14
+ const createCoords = v => ({
15
+ x: v,
16
+ y: v
17
+ });
18
+ const oppositeSideMap = {
19
+ left: 'right',
20
+ right: 'left',
21
+ bottom: 'top',
22
+ top: 'bottom'
23
+ };
24
+ const oppositeAlignmentMap = {
25
+ start: 'end',
26
+ end: 'start'
27
+ };
28
+ function clamp(start, value, end) {
29
+ return max(start, min(value, end));
30
+ }
31
+ function evaluate(value, param) {
32
+ return typeof value === 'function' ? value(param) : value;
33
+ }
34
+ function getSide(placement) {
35
+ return placement.split('-')[0];
36
+ }
37
+ function getAlignment(placement) {
38
+ return placement.split('-')[1];
39
+ }
40
+ function getOppositeAxis(axis) {
41
+ return axis === 'x' ? 'y' : 'x';
42
+ }
43
+ function getAxisLength(axis) {
44
+ return axis === 'y' ? 'height' : 'width';
45
+ }
46
+ function getSideAxis(placement) {
47
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
48
+ }
49
+ function getAlignmentAxis(placement) {
50
+ return getOppositeAxis(getSideAxis(placement));
51
+ }
52
+ function getAlignmentSides(placement, rects, rtl) {
53
+ if (rtl === void 0) {
54
+ rtl = false;
55
+ }
56
+ const alignment = getAlignment(placement);
57
+ const alignmentAxis = getAlignmentAxis(placement);
58
+ const length = getAxisLength(alignmentAxis);
59
+ let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
60
+ if (rects.reference[length] > rects.floating[length]) {
61
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
62
+ }
63
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
64
+ }
65
+ function getExpandedPlacements(placement) {
66
+ const oppositePlacement = getOppositePlacement(placement);
67
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
68
+ }
69
+ function getOppositeAlignmentPlacement(placement) {
70
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
71
+ }
72
+ function getSideList(side, isStart, rtl) {
73
+ const lr = ['left', 'right'];
74
+ const rl = ['right', 'left'];
75
+ const tb = ['top', 'bottom'];
76
+ const bt = ['bottom', 'top'];
77
+ switch (side) {
78
+ case 'top':
79
+ case 'bottom':
80
+ if (rtl) return isStart ? rl : lr;
81
+ return isStart ? lr : rl;
82
+ case 'left':
83
+ case 'right':
84
+ return isStart ? tb : bt;
85
+ default:
86
+ return [];
87
+ }
88
+ }
89
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
90
+ const alignment = getAlignment(placement);
91
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
92
+ if (alignment) {
93
+ list = list.map(side => side + "-" + alignment);
94
+ if (flipAlignment) {
95
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
96
+ }
97
+ }
98
+ return list;
99
+ }
100
+ function getOppositePlacement(placement) {
101
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
102
+ }
103
+ function expandPaddingObject(padding) {
104
+ return {
105
+ top: 0,
106
+ right: 0,
107
+ bottom: 0,
108
+ left: 0,
109
+ ...padding
110
+ };
111
+ }
112
+ function getPaddingObject(padding) {
113
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
114
+ top: padding,
115
+ right: padding,
116
+ bottom: padding,
117
+ left: padding
118
+ };
119
+ }
120
+ function rectToClientRect(rect) {
121
+ const {
122
+ x,
123
+ y,
124
+ width,
125
+ height
126
+ } = rect;
127
+ return {
128
+ width,
129
+ height,
130
+ top: y,
131
+ left: x,
132
+ right: x + width,
133
+ bottom: y + height,
134
+ x,
135
+ y
136
+ };
137
+ }
138
+
139
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
140
+ let {
141
+ reference,
142
+ floating
143
+ } = _ref;
144
+ const sideAxis = getSideAxis(placement);
145
+ const alignmentAxis = getAlignmentAxis(placement);
146
+ const alignLength = getAxisLength(alignmentAxis);
147
+ const side = getSide(placement);
148
+ const isVertical = sideAxis === 'y';
149
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
150
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
151
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
152
+ let coords;
153
+ switch (side) {
154
+ case 'top':
155
+ coords = {
156
+ x: commonX,
157
+ y: reference.y - floating.height
158
+ };
159
+ break;
160
+ case 'bottom':
161
+ coords = {
162
+ x: commonX,
163
+ y: reference.y + reference.height
164
+ };
165
+ break;
166
+ case 'right':
167
+ coords = {
168
+ x: reference.x + reference.width,
169
+ y: commonY
170
+ };
171
+ break;
172
+ case 'left':
173
+ coords = {
174
+ x: reference.x - floating.width,
175
+ y: commonY
176
+ };
177
+ break;
178
+ default:
179
+ coords = {
180
+ x: reference.x,
181
+ y: reference.y
182
+ };
183
+ }
184
+ switch (getAlignment(placement)) {
185
+ case 'start':
186
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
187
+ break;
188
+ case 'end':
189
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
190
+ break;
191
+ }
192
+ return coords;
193
+ }
194
+
195
+ /**
196
+ * Computes the `x` and `y` coordinates that will place the floating element
197
+ * next to a given reference element.
198
+ *
199
+ * This export does not have any `platform` interface logic. You will need to
200
+ * write one for the platform you are using Floating UI with.
201
+ */
202
+ const computePosition$1 = async (reference, floating, config) => {
203
+ const {
204
+ placement = 'bottom',
205
+ strategy = 'absolute',
206
+ middleware = [],
207
+ platform
208
+ } = config;
209
+ const validMiddleware = middleware.filter(Boolean);
210
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
211
+ let rects = await platform.getElementRects({
212
+ reference,
213
+ floating,
214
+ strategy
215
+ });
216
+ let {
217
+ x,
218
+ y
219
+ } = computeCoordsFromPlacement(rects, placement, rtl);
220
+ let statefulPlacement = placement;
221
+ let middlewareData = {};
222
+ let resetCount = 0;
223
+ for (let i = 0; i < validMiddleware.length; i++) {
224
+ const {
225
+ name,
226
+ fn
227
+ } = validMiddleware[i];
228
+ const {
229
+ x: nextX,
230
+ y: nextY,
231
+ data,
232
+ reset
233
+ } = await fn({
234
+ x,
235
+ y,
236
+ initialPlacement: placement,
237
+ placement: statefulPlacement,
238
+ strategy,
239
+ middlewareData,
240
+ rects,
241
+ platform,
242
+ elements: {
243
+ reference,
244
+ floating
245
+ }
246
+ });
247
+ x = nextX != null ? nextX : x;
248
+ y = nextY != null ? nextY : y;
249
+ middlewareData = {
250
+ ...middlewareData,
251
+ [name]: {
252
+ ...middlewareData[name],
253
+ ...data
254
+ }
255
+ };
256
+ if (reset && resetCount <= 50) {
257
+ resetCount++;
258
+ if (typeof reset === 'object') {
259
+ if (reset.placement) {
260
+ statefulPlacement = reset.placement;
261
+ }
262
+ if (reset.rects) {
263
+ rects = reset.rects === true ? await platform.getElementRects({
264
+ reference,
265
+ floating,
266
+ strategy
267
+ }) : reset.rects;
268
+ }
269
+ ({
270
+ x,
271
+ y
272
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
273
+ }
274
+ i = -1;
275
+ }
276
+ }
277
+ return {
278
+ x,
279
+ y,
280
+ placement: statefulPlacement,
281
+ strategy,
282
+ middlewareData
283
+ };
284
+ };
285
+
286
+ /**
287
+ * Resolves with an object of overflow side offsets that determine how much the
288
+ * element is overflowing a given clipping boundary on each side.
289
+ * - positive = overflowing the boundary by that number of pixels
290
+ * - negative = how many pixels left before it will overflow
291
+ * - 0 = lies flush with the boundary
292
+ * @see https://floating-ui.com/docs/detectOverflow
293
+ */
294
+ async function detectOverflow(state, options) {
295
+ var _await$platform$isEle;
296
+ if (options === void 0) {
297
+ options = {};
298
+ }
299
+ const {
300
+ x,
301
+ y,
302
+ platform,
303
+ rects,
304
+ elements,
305
+ strategy
306
+ } = state;
307
+ const {
308
+ boundary = 'clippingAncestors',
309
+ rootBoundary = 'viewport',
310
+ elementContext = 'floating',
311
+ altBoundary = false,
312
+ padding = 0
313
+ } = evaluate(options, state);
314
+ const paddingObject = getPaddingObject(padding);
315
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
316
+ const element = elements[altBoundary ? altContext : elementContext];
317
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
318
+ 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))),
319
+ boundary,
320
+ rootBoundary,
321
+ strategy
322
+ }));
323
+ const rect = elementContext === 'floating' ? {
324
+ x,
325
+ y,
326
+ width: rects.floating.width,
327
+ height: rects.floating.height
328
+ } : rects.reference;
329
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
330
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
331
+ x: 1,
332
+ y: 1
333
+ } : {
334
+ x: 1,
335
+ y: 1
336
+ };
337
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
338
+ elements,
339
+ rect,
340
+ offsetParent,
341
+ strategy
342
+ }) : rect);
343
+ return {
344
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
345
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
346
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
347
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
348
+ };
349
+ }
350
+
351
+ /**
352
+ * Optimizes the visibility of the floating element by flipping the `placement`
353
+ * in order to keep it in view when the preferred placement(s) will overflow the
354
+ * clipping boundary. Alternative to `autoPlacement`.
355
+ * @see https://floating-ui.com/docs/flip
356
+ */
357
+ const flip$1 = function (options) {
358
+ if (options === void 0) {
359
+ options = {};
360
+ }
361
+ return {
362
+ name: 'flip',
363
+ options,
364
+ async fn(state) {
365
+ var _middlewareData$arrow, _middlewareData$flip;
366
+ const {
367
+ placement,
368
+ middlewareData,
369
+ rects,
370
+ initialPlacement,
371
+ platform,
372
+ elements
373
+ } = state;
374
+ const {
375
+ mainAxis: checkMainAxis = true,
376
+ crossAxis: checkCrossAxis = true,
377
+ fallbackPlacements: specifiedFallbackPlacements,
378
+ fallbackStrategy = 'bestFit',
379
+ fallbackAxisSideDirection = 'none',
380
+ flipAlignment = true,
381
+ ...detectOverflowOptions
382
+ } = evaluate(options, state);
383
+
384
+ // If a reset by the arrow was caused due to an alignment offset being
385
+ // added, we should skip any logic now since `flip()` has already done its
386
+ // work.
387
+ // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
388
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
389
+ return {};
390
+ }
391
+ const side = getSide(placement);
392
+ const initialSideAxis = getSideAxis(initialPlacement);
393
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
394
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
395
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
396
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
397
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
398
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
399
+ }
400
+ const placements = [initialPlacement, ...fallbackPlacements];
401
+ const overflow = await detectOverflow(state, detectOverflowOptions);
402
+ const overflows = [];
403
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
404
+ if (checkMainAxis) {
405
+ overflows.push(overflow[side]);
406
+ }
407
+ if (checkCrossAxis) {
408
+ const sides = getAlignmentSides(placement, rects, rtl);
409
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
410
+ }
411
+ overflowsData = [...overflowsData, {
412
+ placement,
413
+ overflows
414
+ }];
415
+
416
+ // One or more sides is overflowing.
417
+ if (!overflows.every(side => side <= 0)) {
418
+ var _middlewareData$flip2, _overflowsData$filter;
419
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
420
+ const nextPlacement = placements[nextIndex];
421
+ if (nextPlacement) {
422
+ // Try next placement and re-run the lifecycle.
423
+ return {
424
+ data: {
425
+ index: nextIndex,
426
+ overflows: overflowsData
427
+ },
428
+ reset: {
429
+ placement: nextPlacement
430
+ }
431
+ };
432
+ }
433
+
434
+ // First, find the candidates that fit on the mainAxis side of overflow,
435
+ // then find the placement that fits the best on the main crossAxis side.
436
+ let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
437
+
438
+ // Otherwise fallback.
439
+ if (!resetPlacement) {
440
+ switch (fallbackStrategy) {
441
+ case 'bestFit':
442
+ {
443
+ var _overflowsData$filter2;
444
+ const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
445
+ if (hasFallbackAxisSideDirection) {
446
+ const currentSideAxis = getSideAxis(d.placement);
447
+ return currentSideAxis === initialSideAxis ||
448
+ // Create a bias to the `y` side axis due to horizontal
449
+ // reading directions favoring greater width.
450
+ currentSideAxis === 'y';
451
+ }
452
+ return true;
453
+ }).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
454
+ if (placement) {
455
+ resetPlacement = placement;
456
+ }
457
+ break;
458
+ }
459
+ case 'initialPlacement':
460
+ resetPlacement = initialPlacement;
461
+ break;
462
+ }
463
+ }
464
+ if (placement !== resetPlacement) {
465
+ return {
466
+ reset: {
467
+ placement: resetPlacement
468
+ }
469
+ };
470
+ }
471
+ }
472
+ return {};
473
+ }
474
+ };
475
+ };
476
+
477
+ // For type backwards-compatibility, the `OffsetOptions` type was also
478
+ // Derivable.
479
+
480
+ async function convertValueToCoords(state, options) {
481
+ const {
482
+ placement,
483
+ platform,
484
+ elements
485
+ } = state;
486
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
487
+ const side = getSide(placement);
488
+ const alignment = getAlignment(placement);
489
+ const isVertical = getSideAxis(placement) === 'y';
490
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
491
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
492
+ const rawValue = evaluate(options, state);
493
+
494
+ // eslint-disable-next-line prefer-const
495
+ let {
496
+ mainAxis,
497
+ crossAxis,
498
+ alignmentAxis
499
+ } = typeof rawValue === 'number' ? {
500
+ mainAxis: rawValue,
501
+ crossAxis: 0,
502
+ alignmentAxis: null
503
+ } : {
504
+ mainAxis: 0,
505
+ crossAxis: 0,
506
+ alignmentAxis: null,
507
+ ...rawValue
508
+ };
509
+ if (alignment && typeof alignmentAxis === 'number') {
510
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
511
+ }
512
+ return isVertical ? {
513
+ x: crossAxis * crossAxisMulti,
514
+ y: mainAxis * mainAxisMulti
515
+ } : {
516
+ x: mainAxis * mainAxisMulti,
517
+ y: crossAxis * crossAxisMulti
518
+ };
519
+ }
520
+
521
+ /**
522
+ * Modifies the placement by translating the floating element along the
523
+ * specified axes.
524
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
525
+ * object may be passed.
526
+ * @see https://floating-ui.com/docs/offset
527
+ */
528
+ const offset$1 = function (options) {
529
+ if (options === void 0) {
530
+ options = 0;
531
+ }
532
+ return {
533
+ name: 'offset',
534
+ options,
535
+ async fn(state) {
536
+ var _middlewareData$offse, _middlewareData$arrow;
537
+ const {
538
+ x,
539
+ y,
540
+ placement,
541
+ middlewareData
542
+ } = state;
543
+ const diffCoords = await convertValueToCoords(state, options);
544
+
545
+ // If the placement is the same and the arrow caused an alignment offset
546
+ // then we don't need to change the positioning coordinates.
547
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
548
+ return {};
549
+ }
550
+ return {
551
+ x: x + diffCoords.x,
552
+ y: y + diffCoords.y,
553
+ data: {
554
+ ...diffCoords,
555
+ placement
556
+ }
557
+ };
558
+ }
559
+ };
560
+ };
561
+
562
+ /**
563
+ * Optimizes the visibility of the floating element by shifting it in order to
564
+ * keep it in view when it will overflow the clipping boundary.
565
+ * @see https://floating-ui.com/docs/shift
566
+ */
567
+ const shift$1 = function (options) {
568
+ if (options === void 0) {
569
+ options = {};
570
+ }
571
+ return {
572
+ name: 'shift',
573
+ options,
574
+ async fn(state) {
575
+ const {
576
+ x,
577
+ y,
578
+ placement
579
+ } = state;
580
+ const {
581
+ mainAxis: checkMainAxis = true,
582
+ crossAxis: checkCrossAxis = false,
583
+ limiter = {
584
+ fn: _ref => {
585
+ let {
586
+ x,
587
+ y
588
+ } = _ref;
589
+ return {
590
+ x,
591
+ y
592
+ };
593
+ }
594
+ },
595
+ ...detectOverflowOptions
596
+ } = evaluate(options, state);
597
+ const coords = {
598
+ x,
599
+ y
600
+ };
601
+ const overflow = await detectOverflow(state, detectOverflowOptions);
602
+ const crossAxis = getSideAxis(getSide(placement));
603
+ const mainAxis = getOppositeAxis(crossAxis);
604
+ let mainAxisCoord = coords[mainAxis];
605
+ let crossAxisCoord = coords[crossAxis];
606
+ if (checkMainAxis) {
607
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
608
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
609
+ const min = mainAxisCoord + overflow[minSide];
610
+ const max = mainAxisCoord - overflow[maxSide];
611
+ mainAxisCoord = clamp(min, mainAxisCoord, max);
612
+ }
613
+ if (checkCrossAxis) {
614
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
615
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
616
+ const min = crossAxisCoord + overflow[minSide];
617
+ const max = crossAxisCoord - overflow[maxSide];
618
+ crossAxisCoord = clamp(min, crossAxisCoord, max);
619
+ }
620
+ const limitedCoords = limiter.fn({
621
+ ...state,
622
+ [mainAxis]: mainAxisCoord,
623
+ [crossAxis]: crossAxisCoord
624
+ });
625
+ return {
626
+ ...limitedCoords,
627
+ data: {
628
+ x: limitedCoords.x - x,
629
+ y: limitedCoords.y - y
630
+ }
631
+ };
632
+ }
633
+ };
634
+ };
635
+
636
+ /**
637
+ * Provides data that allows you to change the size of the floating element —
638
+ * for instance, prevent it from overflowing the clipping boundary or match the
639
+ * width of the reference element.
640
+ * @see https://floating-ui.com/docs/size
641
+ */
642
+ const size$1 = function (options) {
643
+ if (options === void 0) {
644
+ options = {};
645
+ }
646
+ return {
647
+ name: 'size',
648
+ options,
649
+ async fn(state) {
650
+ const {
651
+ placement,
652
+ rects,
653
+ platform,
654
+ elements
655
+ } = state;
656
+ const {
657
+ apply = () => {},
658
+ ...detectOverflowOptions
659
+ } = evaluate(options, state);
660
+ const overflow = await detectOverflow(state, detectOverflowOptions);
661
+ const side = getSide(placement);
662
+ const alignment = getAlignment(placement);
663
+ const isYAxis = getSideAxis(placement) === 'y';
664
+ const {
665
+ width,
666
+ height
667
+ } = rects.floating;
668
+ let heightSide;
669
+ let widthSide;
670
+ if (side === 'top' || side === 'bottom') {
671
+ heightSide = side;
672
+ widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
673
+ } else {
674
+ widthSide = side;
675
+ heightSide = alignment === 'end' ? 'top' : 'bottom';
676
+ }
677
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
678
+ const maximumClippingWidth = width - overflow.left - overflow.right;
679
+ const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
680
+ const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
681
+ const noShift = !state.middlewareData.shift;
682
+ let availableHeight = overflowAvailableHeight;
683
+ let availableWidth = overflowAvailableWidth;
684
+ if (isYAxis) {
685
+ availableWidth = alignment || noShift ? min(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth;
686
+ } else {
687
+ availableHeight = alignment || noShift ? min(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight;
688
+ }
689
+ if (noShift && !alignment) {
690
+ const xMin = max(overflow.left, 0);
691
+ const xMax = max(overflow.right, 0);
692
+ const yMin = max(overflow.top, 0);
693
+ const yMax = max(overflow.bottom, 0);
694
+ if (isYAxis) {
695
+ availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
696
+ } else {
697
+ availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
698
+ }
699
+ }
700
+ await apply({
701
+ ...state,
702
+ availableWidth,
703
+ availableHeight
704
+ });
705
+ const nextDimensions = await platform.getDimensions(elements.floating);
706
+ if (width !== nextDimensions.width || height !== nextDimensions.height) {
707
+ return {
708
+ reset: {
709
+ rects: true
710
+ }
711
+ };
712
+ }
713
+ return {};
714
+ }
715
+ };
716
+ };
717
+
718
+ function getNodeName(node) {
719
+ if (isNode(node)) {
720
+ return (node.nodeName || '').toLowerCase();
721
+ }
722
+ // Mocked nodes in testing environments may not be instances of Node. By
723
+ // returning `#document` an infinite loop won't occur.
724
+ // https://github.com/floating-ui/floating-ui/issues/2317
725
+ return '#document';
726
+ }
727
+ function getWindow(node) {
728
+ var _node$ownerDocument;
729
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
730
+ }
731
+ function getDocumentElement(node) {
732
+ var _ref;
733
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
734
+ }
735
+ function isNode(value) {
736
+ return value instanceof Node || value instanceof getWindow(value).Node;
737
+ }
738
+ function isElement(value) {
739
+ return value instanceof Element || value instanceof getWindow(value).Element;
740
+ }
741
+ function isHTMLElement(value) {
742
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
743
+ }
744
+ function isShadowRoot(value) {
745
+ // Browsers without `ShadowRoot` support.
746
+ if (typeof ShadowRoot === 'undefined') {
747
+ return false;
748
+ }
749
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
750
+ }
751
+ function isOverflowElement(element) {
752
+ const {
753
+ overflow,
754
+ overflowX,
755
+ overflowY,
756
+ display
757
+ } = getComputedStyle(element);
758
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
759
+ }
760
+ function isTableElement(element) {
761
+ return ['table', 'td', 'th'].includes(getNodeName(element));
762
+ }
763
+ function isTopLayer(element) {
764
+ return [':popover-open', ':modal'].some(selector => {
765
+ try {
766
+ return element.matches(selector);
767
+ } catch (e) {
768
+ return false;
769
+ }
770
+ });
771
+ }
772
+ function isContainingBlock(elementOrCss) {
773
+ const webkit = isWebKit();
774
+ const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
775
+
776
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
777
+ return css.transform !== 'none' || css.perspective !== 'none' || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
778
+ }
779
+ function getContainingBlock(element) {
780
+ let currentNode = getParentNode(element);
781
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
782
+ if (isContainingBlock(currentNode)) {
783
+ return currentNode;
784
+ } else if (isTopLayer(currentNode)) {
785
+ return null;
786
+ }
787
+ currentNode = getParentNode(currentNode);
788
+ }
789
+ return null;
790
+ }
791
+ function isWebKit() {
792
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
793
+ return CSS.supports('-webkit-backdrop-filter', 'none');
794
+ }
795
+ function isLastTraversableNode(node) {
796
+ return ['html', 'body', '#document'].includes(getNodeName(node));
797
+ }
798
+ function getComputedStyle(element) {
799
+ return getWindow(element).getComputedStyle(element);
800
+ }
801
+ function getNodeScroll(element) {
802
+ if (isElement(element)) {
803
+ return {
804
+ scrollLeft: element.scrollLeft,
805
+ scrollTop: element.scrollTop
806
+ };
807
+ }
808
+ return {
809
+ scrollLeft: element.scrollX,
810
+ scrollTop: element.scrollY
811
+ };
812
+ }
813
+ function getParentNode(node) {
814
+ if (getNodeName(node) === 'html') {
815
+ return node;
816
+ }
817
+ const result =
818
+ // Step into the shadow DOM of the parent of a slotted node.
819
+ node.assignedSlot ||
820
+ // DOM Element detected.
821
+ node.parentNode ||
822
+ // ShadowRoot detected.
823
+ isShadowRoot(node) && node.host ||
824
+ // Fallback.
825
+ getDocumentElement(node);
826
+ return isShadowRoot(result) ? result.host : result;
827
+ }
828
+ function getNearestOverflowAncestor(node) {
829
+ const parentNode = getParentNode(node);
830
+ if (isLastTraversableNode(parentNode)) {
831
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
832
+ }
833
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
834
+ return parentNode;
835
+ }
836
+ return getNearestOverflowAncestor(parentNode);
837
+ }
838
+ function getOverflowAncestors(node, list, traverseIframes) {
839
+ var _node$ownerDocument2;
840
+ if (list === void 0) {
841
+ list = [];
842
+ }
843
+ if (traverseIframes === void 0) {
844
+ traverseIframes = true;
845
+ }
846
+ const scrollableAncestor = getNearestOverflowAncestor(node);
847
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
848
+ const win = getWindow(scrollableAncestor);
849
+ if (isBody) {
850
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []);
851
+ }
852
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
853
+ }
854
+
855
+ function getCssDimensions(element) {
856
+ const css = getComputedStyle(element);
857
+ // In testing environments, the `width` and `height` properties are empty
858
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
859
+ let width = parseFloat(css.width) || 0;
860
+ let height = parseFloat(css.height) || 0;
861
+ const hasOffset = isHTMLElement(element);
862
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
863
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
864
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
865
+ if (shouldFallback) {
866
+ width = offsetWidth;
867
+ height = offsetHeight;
868
+ }
869
+ return {
870
+ width,
871
+ height,
872
+ $: shouldFallback
873
+ };
874
+ }
875
+
876
+ function unwrapElement(element) {
877
+ return !isElement(element) ? element.contextElement : element;
878
+ }
879
+
880
+ function getScale(element) {
881
+ const domElement = unwrapElement(element);
882
+ if (!isHTMLElement(domElement)) {
883
+ return createCoords(1);
884
+ }
885
+ const rect = domElement.getBoundingClientRect();
886
+ const {
887
+ width,
888
+ height,
889
+ $
890
+ } = getCssDimensions(domElement);
891
+ let x = ($ ? round(rect.width) : rect.width) / width;
892
+ let y = ($ ? round(rect.height) : rect.height) / height;
893
+
894
+ // 0, NaN, or Infinity should always fallback to 1.
895
+
896
+ if (!x || !Number.isFinite(x)) {
897
+ x = 1;
898
+ }
899
+ if (!y || !Number.isFinite(y)) {
900
+ y = 1;
901
+ }
902
+ return {
903
+ x,
904
+ y
905
+ };
906
+ }
907
+
908
+ const noOffsets = /*#__PURE__*/createCoords(0);
909
+ function getVisualOffsets(element) {
910
+ const win = getWindow(element);
911
+ if (!isWebKit() || !win.visualViewport) {
912
+ return noOffsets;
913
+ }
914
+ return {
915
+ x: win.visualViewport.offsetLeft,
916
+ y: win.visualViewport.offsetTop
917
+ };
918
+ }
919
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
920
+ if (isFixed === void 0) {
921
+ isFixed = false;
922
+ }
923
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
924
+ return false;
925
+ }
926
+ return isFixed;
927
+ }
928
+
929
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
930
+ if (includeScale === void 0) {
931
+ includeScale = false;
932
+ }
933
+ if (isFixedStrategy === void 0) {
934
+ isFixedStrategy = false;
935
+ }
936
+ const clientRect = element.getBoundingClientRect();
937
+ const domElement = unwrapElement(element);
938
+ let scale = createCoords(1);
939
+ if (includeScale) {
940
+ if (offsetParent) {
941
+ if (isElement(offsetParent)) {
942
+ scale = getScale(offsetParent);
943
+ }
944
+ } else {
945
+ scale = getScale(element);
946
+ }
947
+ }
948
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
949
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
950
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
951
+ let width = clientRect.width / scale.x;
952
+ let height = clientRect.height / scale.y;
953
+ if (domElement) {
954
+ const win = getWindow(domElement);
955
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
956
+ let currentWin = win;
957
+ let currentIFrame = currentWin.frameElement;
958
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
959
+ const iframeScale = getScale(currentIFrame);
960
+ const iframeRect = currentIFrame.getBoundingClientRect();
961
+ const css = getComputedStyle(currentIFrame);
962
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
963
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
964
+ x *= iframeScale.x;
965
+ y *= iframeScale.y;
966
+ width *= iframeScale.x;
967
+ height *= iframeScale.y;
968
+ x += left;
969
+ y += top;
970
+ currentWin = getWindow(currentIFrame);
971
+ currentIFrame = currentWin.frameElement;
972
+ }
973
+ }
974
+ return rectToClientRect({
975
+ width,
976
+ height,
977
+ x,
978
+ y
979
+ });
980
+ }
981
+
982
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
983
+ let {
984
+ elements,
985
+ rect,
986
+ offsetParent,
987
+ strategy
988
+ } = _ref;
989
+ const isFixed = strategy === 'fixed';
990
+ const documentElement = getDocumentElement(offsetParent);
991
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
992
+ if (offsetParent === documentElement || topLayer && isFixed) {
993
+ return rect;
994
+ }
995
+ let scroll = {
996
+ scrollLeft: 0,
997
+ scrollTop: 0
998
+ };
999
+ let scale = createCoords(1);
1000
+ const offsets = createCoords(0);
1001
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1002
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1003
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1004
+ scroll = getNodeScroll(offsetParent);
1005
+ }
1006
+ if (isHTMLElement(offsetParent)) {
1007
+ const offsetRect = getBoundingClientRect(offsetParent);
1008
+ scale = getScale(offsetParent);
1009
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1010
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1011
+ }
1012
+ }
1013
+ return {
1014
+ width: rect.width * scale.x,
1015
+ height: rect.height * scale.y,
1016
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
1017
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
1018
+ };
1019
+ }
1020
+
1021
+ function getClientRects(element) {
1022
+ return Array.from(element.getClientRects());
1023
+ }
1024
+
1025
+ function getWindowScrollBarX(element) {
1026
+ // If <html> has a CSS width greater than the viewport, then this will be
1027
+ // incorrect for RTL.
1028
+ return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
1029
+ }
1030
+
1031
+ // Gets the entire size of the scrollable document area, even extending outside
1032
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
1033
+ function getDocumentRect(element) {
1034
+ const html = getDocumentElement(element);
1035
+ const scroll = getNodeScroll(element);
1036
+ const body = element.ownerDocument.body;
1037
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1038
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1039
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1040
+ const y = -scroll.scrollTop;
1041
+ if (getComputedStyle(body).direction === 'rtl') {
1042
+ x += max(html.clientWidth, body.clientWidth) - width;
1043
+ }
1044
+ return {
1045
+ width,
1046
+ height,
1047
+ x,
1048
+ y
1049
+ };
1050
+ }
1051
+
1052
+ function getViewportRect(element, strategy) {
1053
+ const win = getWindow(element);
1054
+ const html = getDocumentElement(element);
1055
+ const visualViewport = win.visualViewport;
1056
+ let width = html.clientWidth;
1057
+ let height = html.clientHeight;
1058
+ let x = 0;
1059
+ let y = 0;
1060
+ if (visualViewport) {
1061
+ width = visualViewport.width;
1062
+ height = visualViewport.height;
1063
+ const visualViewportBased = isWebKit();
1064
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
1065
+ x = visualViewport.offsetLeft;
1066
+ y = visualViewport.offsetTop;
1067
+ }
1068
+ }
1069
+ return {
1070
+ width,
1071
+ height,
1072
+ x,
1073
+ y
1074
+ };
1075
+ }
1076
+
1077
+ // Returns the inner client rect, subtracting scrollbars if present.
1078
+ function getInnerBoundingClientRect(element, strategy) {
1079
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
1080
+ const top = clientRect.top + element.clientTop;
1081
+ const left = clientRect.left + element.clientLeft;
1082
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
1083
+ const width = element.clientWidth * scale.x;
1084
+ const height = element.clientHeight * scale.y;
1085
+ const x = left * scale.x;
1086
+ const y = top * scale.y;
1087
+ return {
1088
+ width,
1089
+ height,
1090
+ x,
1091
+ y
1092
+ };
1093
+ }
1094
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1095
+ let rect;
1096
+ if (clippingAncestor === 'viewport') {
1097
+ rect = getViewportRect(element, strategy);
1098
+ } else if (clippingAncestor === 'document') {
1099
+ rect = getDocumentRect(getDocumentElement(element));
1100
+ } else if (isElement(clippingAncestor)) {
1101
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1102
+ } else {
1103
+ const visualOffsets = getVisualOffsets(element);
1104
+ rect = {
1105
+ ...clippingAncestor,
1106
+ x: clippingAncestor.x - visualOffsets.x,
1107
+ y: clippingAncestor.y - visualOffsets.y
1108
+ };
1109
+ }
1110
+ return rectToClientRect(rect);
1111
+ }
1112
+ function hasFixedPositionAncestor(element, stopNode) {
1113
+ const parentNode = getParentNode(element);
1114
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1115
+ return false;
1116
+ }
1117
+ return getComputedStyle(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
1118
+ }
1119
+
1120
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
1121
+ // clipping (or hiding) child elements. This returns all clipping ancestors
1122
+ // of the given element up the tree.
1123
+ function getClippingElementAncestors(element, cache) {
1124
+ const cachedResult = cache.get(element);
1125
+ if (cachedResult) {
1126
+ return cachedResult;
1127
+ }
1128
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
1129
+ let currentContainingBlockComputedStyle = null;
1130
+ const elementIsFixed = getComputedStyle(element).position === 'fixed';
1131
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
1132
+
1133
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1134
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1135
+ const computedStyle = getComputedStyle(currentNode);
1136
+ const currentNodeIsContaining = isContainingBlock(currentNode);
1137
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1138
+ currentContainingBlockComputedStyle = null;
1139
+ }
1140
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1141
+ if (shouldDropCurrentNode) {
1142
+ // Drop non-containing blocks.
1143
+ result = result.filter(ancestor => ancestor !== currentNode);
1144
+ } else {
1145
+ // Record last containing block for next iteration.
1146
+ currentContainingBlockComputedStyle = computedStyle;
1147
+ }
1148
+ currentNode = getParentNode(currentNode);
1149
+ }
1150
+ cache.set(element, result);
1151
+ return result;
1152
+ }
1153
+
1154
+ // Gets the maximum area that the element is visible in due to any number of
1155
+ // clipping ancestors.
1156
+ function getClippingRect(_ref) {
1157
+ let {
1158
+ element,
1159
+ boundary,
1160
+ rootBoundary,
1161
+ strategy
1162
+ } = _ref;
1163
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1164
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1165
+ const firstClippingAncestor = clippingAncestors[0];
1166
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1167
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1168
+ accRect.top = max(rect.top, accRect.top);
1169
+ accRect.right = min(rect.right, accRect.right);
1170
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1171
+ accRect.left = max(rect.left, accRect.left);
1172
+ return accRect;
1173
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1174
+ return {
1175
+ width: clippingRect.right - clippingRect.left,
1176
+ height: clippingRect.bottom - clippingRect.top,
1177
+ x: clippingRect.left,
1178
+ y: clippingRect.top
1179
+ };
1180
+ }
1181
+
1182
+ function getDimensions(element) {
1183
+ const {
1184
+ width,
1185
+ height
1186
+ } = getCssDimensions(element);
1187
+ return {
1188
+ width,
1189
+ height
1190
+ };
1191
+ }
1192
+
1193
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1194
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1195
+ const documentElement = getDocumentElement(offsetParent);
1196
+ const isFixed = strategy === 'fixed';
1197
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1198
+ let scroll = {
1199
+ scrollLeft: 0,
1200
+ scrollTop: 0
1201
+ };
1202
+ const offsets = createCoords(0);
1203
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1204
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1205
+ scroll = getNodeScroll(offsetParent);
1206
+ }
1207
+ if (isOffsetParentAnElement) {
1208
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1209
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1210
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1211
+ } else if (documentElement) {
1212
+ offsets.x = getWindowScrollBarX(documentElement);
1213
+ }
1214
+ }
1215
+ const x = rect.left + scroll.scrollLeft - offsets.x;
1216
+ const y = rect.top + scroll.scrollTop - offsets.y;
1217
+ return {
1218
+ x,
1219
+ y,
1220
+ width: rect.width,
1221
+ height: rect.height
1222
+ };
1223
+ }
1224
+
1225
+ function isStaticPositioned(element) {
1226
+ return getComputedStyle(element).position === 'static';
1227
+ }
1228
+
1229
+ function getTrueOffsetParent(element, polyfill) {
1230
+ if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
1231
+ return null;
1232
+ }
1233
+ if (polyfill) {
1234
+ return polyfill(element);
1235
+ }
1236
+ return element.offsetParent;
1237
+ }
1238
+
1239
+ // Gets the closest ancestor positioned element. Handles some edge cases,
1240
+ // such as table ancestors and cross browser bugs.
1241
+ function getOffsetParent(element, polyfill) {
1242
+ const win = getWindow(element);
1243
+ if (isTopLayer(element)) {
1244
+ return win;
1245
+ }
1246
+ if (!isHTMLElement(element)) {
1247
+ let svgOffsetParent = getParentNode(element);
1248
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
1249
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
1250
+ return svgOffsetParent;
1251
+ }
1252
+ svgOffsetParent = getParentNode(svgOffsetParent);
1253
+ }
1254
+ return win;
1255
+ }
1256
+ let offsetParent = getTrueOffsetParent(element, polyfill);
1257
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
1258
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1259
+ }
1260
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
1261
+ return win;
1262
+ }
1263
+ return offsetParent || getContainingBlock(element) || win;
1264
+ }
1265
+
1266
+ const getElementRects = async function (data) {
1267
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1268
+ const getDimensionsFn = this.getDimensions;
1269
+ const floatingDimensions = await getDimensionsFn(data.floating);
1270
+ return {
1271
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1272
+ floating: {
1273
+ x: 0,
1274
+ y: 0,
1275
+ width: floatingDimensions.width,
1276
+ height: floatingDimensions.height
1277
+ }
1278
+ };
1279
+ };
1280
+
1281
+ function isRTL(element) {
1282
+ return getComputedStyle(element).direction === 'rtl';
1283
+ }
1284
+
1285
+ const platform = {
1286
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1287
+ getDocumentElement,
1288
+ getClippingRect,
1289
+ getOffsetParent,
1290
+ getElementRects,
1291
+ getClientRects,
1292
+ getDimensions,
1293
+ getScale,
1294
+ isElement,
1295
+ isRTL
1296
+ };
1297
+
1298
+ // https://samthor.au/2021/observing-dom/
1299
+ function observeMove(element, onMove) {
1300
+ let io = null;
1301
+ let timeoutId;
1302
+ const root = getDocumentElement(element);
1303
+ function cleanup() {
1304
+ var _io;
1305
+ clearTimeout(timeoutId);
1306
+ (_io = io) == null || _io.disconnect();
1307
+ io = null;
1308
+ }
1309
+ function refresh(skip, threshold) {
1310
+ if (skip === void 0) {
1311
+ skip = false;
1312
+ }
1313
+ if (threshold === void 0) {
1314
+ threshold = 1;
1315
+ }
1316
+ cleanup();
1317
+ const {
1318
+ left,
1319
+ top,
1320
+ width,
1321
+ height
1322
+ } = element.getBoundingClientRect();
1323
+ if (!skip) {
1324
+ onMove();
1325
+ }
1326
+ if (!width || !height) {
1327
+ return;
1328
+ }
1329
+ const insetTop = floor(top);
1330
+ const insetRight = floor(root.clientWidth - (left + width));
1331
+ const insetBottom = floor(root.clientHeight - (top + height));
1332
+ const insetLeft = floor(left);
1333
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
1334
+ const options = {
1335
+ rootMargin,
1336
+ threshold: max(0, min(1, threshold)) || 1
1337
+ };
1338
+ let isFirstUpdate = true;
1339
+ function handleObserve(entries) {
1340
+ const ratio = entries[0].intersectionRatio;
1341
+ if (ratio !== threshold) {
1342
+ if (!isFirstUpdate) {
1343
+ return refresh();
1344
+ }
1345
+ if (!ratio) {
1346
+ // If the reference is clipped, the ratio is 0. Throttle the refresh
1347
+ // to prevent an infinite loop of updates.
1348
+ timeoutId = setTimeout(() => {
1349
+ refresh(false, 1e-7);
1350
+ }, 1000);
1351
+ } else {
1352
+ refresh(false, ratio);
1353
+ }
1354
+ }
1355
+ isFirstUpdate = false;
1356
+ }
1357
+
1358
+ // Older browsers don't support a `document` as the root and will throw an
1359
+ // error.
1360
+ try {
1361
+ io = new IntersectionObserver(handleObserve, {
1362
+ ...options,
1363
+ // Handle <iframe>s
1364
+ root: root.ownerDocument
1365
+ });
1366
+ } catch (e) {
1367
+ io = new IntersectionObserver(handleObserve, options);
1368
+ }
1369
+ io.observe(element);
1370
+ }
1371
+ refresh(true);
1372
+ return cleanup;
1373
+ }
1374
+
1375
+ /**
1376
+ * Automatically updates the position of the floating element when necessary.
1377
+ * Should only be called when the floating element is mounted on the DOM or
1378
+ * visible on the screen.
1379
+ * @returns cleanup function that should be invoked when the floating element is
1380
+ * removed from the DOM or hidden from the screen.
1381
+ * @see https://floating-ui.com/docs/autoUpdate
1382
+ */
1383
+ function autoUpdate(reference, floating, update, options) {
1384
+ if (options === void 0) {
1385
+ options = {};
1386
+ }
1387
+ const {
1388
+ ancestorScroll = true,
1389
+ ancestorResize = true,
1390
+ elementResize = typeof ResizeObserver === 'function',
1391
+ layoutShift = typeof IntersectionObserver === 'function',
1392
+ animationFrame = false
1393
+ } = options;
1394
+ const referenceEl = unwrapElement(reference);
1395
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
1396
+ ancestors.forEach(ancestor => {
1397
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
1398
+ passive: true
1399
+ });
1400
+ ancestorResize && ancestor.addEventListener('resize', update);
1401
+ });
1402
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
1403
+ let reobserveFrame = -1;
1404
+ let resizeObserver = null;
1405
+ if (elementResize) {
1406
+ resizeObserver = new ResizeObserver(_ref => {
1407
+ let [firstEntry] = _ref;
1408
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
1409
+ // Prevent update loops when using the `size` middleware.
1410
+ // https://github.com/floating-ui/floating-ui/issues/1740
1411
+ resizeObserver.unobserve(floating);
1412
+ cancelAnimationFrame(reobserveFrame);
1413
+ reobserveFrame = requestAnimationFrame(() => {
1414
+ var _resizeObserver;
1415
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
1416
+ });
1417
+ }
1418
+ update();
1419
+ });
1420
+ if (referenceEl && !animationFrame) {
1421
+ resizeObserver.observe(referenceEl);
1422
+ }
1423
+ resizeObserver.observe(floating);
1424
+ }
1425
+ let frameId;
1426
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1427
+ if (animationFrame) {
1428
+ frameLoop();
1429
+ }
1430
+ function frameLoop() {
1431
+ const nextRefRect = getBoundingClientRect(reference);
1432
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
1433
+ update();
1434
+ }
1435
+ prevRefRect = nextRefRect;
1436
+ frameId = requestAnimationFrame(frameLoop);
1437
+ }
1438
+ update();
1439
+ return () => {
1440
+ var _resizeObserver2;
1441
+ ancestors.forEach(ancestor => {
1442
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
1443
+ ancestorResize && ancestor.removeEventListener('resize', update);
1444
+ });
1445
+ cleanupIo == null || cleanupIo();
1446
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
1447
+ resizeObserver = null;
1448
+ if (animationFrame) {
1449
+ cancelAnimationFrame(frameId);
1450
+ }
1451
+ };
1452
+ }
1453
+
1454
+ /**
1455
+ * Modifies the placement by translating the floating element along the
1456
+ * specified axes.
1457
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
1458
+ * object may be passed.
1459
+ * @see https://floating-ui.com/docs/offset
1460
+ */
1461
+ const offset = offset$1;
1462
+
1463
+ /**
1464
+ * Optimizes the visibility of the floating element by shifting it in order to
1465
+ * keep it in view when it will overflow the clipping boundary.
1466
+ * @see https://floating-ui.com/docs/shift
1467
+ */
1468
+ const shift = shift$1;
1469
+
1470
+ /**
1471
+ * Optimizes the visibility of the floating element by flipping the `placement`
1472
+ * in order to keep it in view when the preferred placement(s) will overflow the
1473
+ * clipping boundary. Alternative to `autoPlacement`.
1474
+ * @see https://floating-ui.com/docs/flip
1475
+ */
1476
+ const flip = flip$1;
1477
+
1478
+ /**
1479
+ * Provides data that allows you to change the size of the floating element —
1480
+ * for instance, prevent it from overflowing the clipping boundary or match the
1481
+ * width of the reference element.
1482
+ * @see https://floating-ui.com/docs/size
1483
+ */
1484
+ const size = size$1;
1485
+
1486
+ /**
1487
+ * Computes the `x` and `y` coordinates that will place the floating element
1488
+ * next to a given reference element.
1489
+ */
1490
+ const computePosition = (reference, floating, options) => {
1491
+ // This caches the expensive `getClippingElementAncestors` function so that
1492
+ // multiple lifecycle resets re-use the same result. It only lives for a
1493
+ // single call. If other functions become expensive, we can add them as well.
1494
+ const cache = new Map();
1495
+ const mergedOptions = {
1496
+ platform,
1497
+ ...options
1498
+ };
1499
+ const platformWithCache = {
1500
+ ...mergedOptions.platform,
1501
+ _c: cache
1502
+ };
1503
+ return computePosition$1(reference, floating, {
1504
+ ...mergedOptions,
1505
+ platform: platformWithCache
1506
+ });
1507
+ };
1508
+
1509
+ const curaSelectCss = ":host{display:block;position:relative;font-family:var(--font-family)}.wrapper{width:100%;user-select:none;text-align:left !important}.wrapper cura-label{margin-bottom:8px}.wrapper .helper-text{margin-top:8px;color:var(--neutral-dark)}.wrapper .cura-input-field{width:100%;height:40px;display:flex;flex-direction:row;align-items:center;background-color:var(--neutral-purewhite);border:2px solid var(--neutral-medium);border-radius:4px;color:var(--primary-base);letter-spacing:0.32px;line-height:20px;overflow:hidden;box-sizing:border-box}.wrapper .cura-input-field input{flex:1;width:100%;height:100%;background:transparent;border:none;outline:none;color:var(--neutral-dark);font-family:var(--font-family);font-weight:var(--font-weight-medium);font-size:14px;box-sizing:border-box;padding:0px 12px 0px 8px}.wrapper .cura-input-field input::placeholder{color:var(--neutral-dark)}.wrapper .cura-input-field .feedback-icon{padding-left:12px}.wrapper .cura-input-field .up-down-icon{order:3;padding-right:6px;cursor:pointer;pointer-events:all}.wrapper .cura-input-field .up-down-button{background-color:transparent;border:none}.wrapper .cura-input-field input{padding:0px 12px 0px 8px;cursor:pointer}.wrapper .cura-input-field.open{border-radius:4px 4px 0 0 !important}.wrapper.transparent{background-color:transparent;padding:0px;max-height:80px}.wrapper.transparent .cura-input-field{width:100%;height:40px;display:flex;flex-direction:row;align-items:center;background-color:var(--neutral-purewhite);border:2px solid var(--neutral-medium);border-radius:4px;color:var(--primary-base);letter-spacing:0.32px;line-height:20px;overflow:hidden;box-sizing:border-box;background-color:transparent !important;border:none !important;border-radius:0;height:27px}.wrapper.transparent .cura-input-field input{flex:1;width:100%;height:100%;background:transparent;border:none;outline:none;color:var(--neutral-dark);font-family:var(--font-family);font-weight:var(--font-weight-medium);font-size:14px;box-sizing:border-box;padding:0px 12px 0px 8px}.wrapper.transparent .cura-input-field input::placeholder{color:var(--neutral-dark)}.wrapper.transparent .cura-input-field .feedback-icon{padding-left:12px}.wrapper.transparent .cura-input-field input{color:var(--neutral-black) !important;font-size:16px;font-weight:var(--font-weight-bold) !important;padding:0}.wrapper.transparent .cura-input-field input::placeholder{color:var(--neutral-black)}.wrapper.transparent .cura-input-field .feedback-icon{order:3;margin:0 20px 0 0}.wrapper.transparent:focus-within .cura-input-field{border:none !important;background-color:transparent !important}.wrapper.transparent:focus-within .cura-input-field input{border:none !important;outline:none}.wrapper.transparent .helper-text{margin-top:0px}.wrapper:hover:not(.disabled):not(.isLoading):not(.success):not(.error):not(.isFocused):not(.readOnly):not(.transparent) .cura-input-field{border-color:var(--neutral-dark)}.wrapper:hover:not(.disabled):not(.isLoading):not(.success):not(.error):not(.isFocused):not(.readOnly):not(.transparent) .cura-input-field input{color:var(--neutral-dark)}.wrapper:hover:not(.disabled):not(.isLoading):not(.success):not(.error):not(.isFocused):not(.readOnly):not(.transparent) .cura-input-field input::placeholder{color:var(--neutral-dark)}.wrapper:focus-within:not(.selection) .cura-input-field{border:2px solid var(--info-base) !important;background-color:var(--neutral-purewhite);outline:none}.wrapper:focus-within:not(.selection) .cura-input-field input{color:var(--neutral-black) !important}.wrapper:focus-within.selection .cura-input-field{border-radius:4px 4px 0px 0px}.wrapper.success .cura-input-field{width:100%;height:40px;display:flex;flex-direction:row;align-items:center;background-color:var(--neutral-purewhite);border:2px solid var(--neutral-medium);border-radius:4px;color:var(--primary-base);letter-spacing:0.32px;line-height:20px;overflow:hidden;box-sizing:border-box}.wrapper.success .cura-input-field input{flex:1;width:100%;height:100%;background:transparent;border:none;outline:none;color:var(--neutral-dark);font-family:var(--font-family);font-weight:var(--font-weight-medium);font-size:14px;box-sizing:border-box;padding:0px 12px 0px 8px}.wrapper.success .cura-input-field input::placeholder{color:var(--neutral-dark)}.wrapper.success .cura-input-field .feedback-icon{padding-left:12px}.wrapper.success .cura-input-field input{color:var(--success-darker) !important}.wrapper.success .cura-input-field input::placeholder{color:var(--success-darker) !important}.wrapper.success:not(.transparent) .cura-input-field{width:100%;height:40px;display:flex;flex-direction:row;align-items:center;background-color:var(--neutral-purewhite);border:2px solid var(--neutral-medium);border-radius:4px;color:var(--primary-base);letter-spacing:0.32px;line-height:20px;overflow:hidden;box-sizing:border-box;border:2px solid var(--success-dark) !important;background-color:var(--success-lighter) !important}.wrapper.success:not(.transparent) .cura-input-field input{flex:1;width:100%;height:100%;background:transparent;border:none;outline:none;color:var(--neutral-dark);font-family:var(--font-family);font-weight:var(--font-weight-medium);font-size:14px;box-sizing:border-box;padding:0px 12px 0px 8px}.wrapper.success:not(.transparent) .cura-input-field input::placeholder{color:var(--neutral-dark)}.wrapper.success:not(.transparent) .cura-input-field .feedback-icon{padding-left:12px}.wrapper.error .cura-input-field{width:100%;height:40px;display:flex;flex-direction:row;align-items:center;background-color:var(--neutral-purewhite);border:2px solid var(--neutral-medium);border-radius:4px;color:var(--primary-base);letter-spacing:0.32px;line-height:20px;overflow:hidden;box-sizing:border-box}.wrapper.error .cura-input-field input{flex:1;width:100%;height:100%;background:transparent;border:none;outline:none;color:var(--neutral-dark);font-family:var(--font-family);font-weight:var(--font-weight-medium);font-size:14px;box-sizing:border-box;padding:0px 12px 0px 8px}.wrapper.error .cura-input-field input::placeholder{color:var(--neutral-dark)}.wrapper.error .cura-input-field .feedback-icon{padding-left:12px}.wrapper.error .cura-input-field input{color:var(--error-darker) !important}.wrapper.error .cura-input-field input::placeholder{color:var(--error-darker) !important}.wrapper.error:not(.transparent) .cura-input-field{width:100%;height:40px;display:flex;flex-direction:row;align-items:center;background-color:var(--neutral-purewhite);border:2px solid var(--neutral-medium);border-radius:4px;color:var(--primary-base);letter-spacing:0.32px;line-height:20px;overflow:hidden;box-sizing:border-box;border:2px solid var(--error-dark) !important;background-color:var(--error-lighter) !important}.wrapper.error:not(.transparent) .cura-input-field input{flex:1;width:100%;height:100%;background:transparent;border:none;outline:none;color:var(--neutral-dark);font-family:var(--font-family);font-weight:var(--font-weight-medium);font-size:14px;box-sizing:border-box;padding:0px 12px 0px 8px}.wrapper.error:not(.transparent) .cura-input-field input::placeholder{color:var(--neutral-dark)}.wrapper.error:not(.transparent) .cura-input-field .feedback-icon{padding-left:12px}.wrapper.disabled .cura-input-field{background-color:var(--neutral-white);border:2px solid var(--neutral-base)}.wrapper.disabled .cura-input-field input{color:var(--neutral-medium)}.wrapper.disabled .cura-input-field input::placeholder{color:var(--neutral-medium)}.required{color:red}.menu{position:fixed;left:0;top:0;box-sizing:border-box;background:#fff;border:2px solid var(--neutral-light);border-radius:4px;z-index:1000;max-height:var(--max-height);overflow:hidden;border-top:transparent;align-items:center;scrollbar-color:var(--neutral-medium) var(--neutral-black-20);overflow-y:auto;box-shadow:0px 4px 8px 0px rgba(38, 38, 38, 0.16)}.menu.open{border-radius:0 !important;padding:12px}";
1510
+
1511
+ const CuraSelect = /*@__PURE__*/ proxyCustomElement(class CuraSelect extends H {
1512
+ constructor() {
1513
+ super();
1514
+ this.__registerHost();
1515
+ this.__attachShadow();
1516
+ this.selected = createEvent(this, "selected");
1517
+ this.searchTermInput = createEvent(this, "searchTermInput");
1518
+ this.internals = this.attachInternals();
1519
+ /**
1520
+ * The label text for the select component.
1521
+ * Reflects as an attribute in the DOM.
1522
+ */
1523
+ this.label = '';
1524
+ /**
1525
+ * Placeholder text for the input field.
1526
+ * Reflects as an attribute in the DOM.
1527
+ */
1528
+ this.placeholder = '';
1529
+ /**
1530
+ * Current value of the select component.
1531
+ * Reflects as an attribute in the DOM and is mutable.
1532
+ */
1533
+ this.value = '';
1534
+ /**
1535
+ * Display mode of the select component.
1536
+ * Can be 'default' or 'transparent'.
1537
+ */
1538
+ this.mode = 'default';
1539
+ /**
1540
+ * Size of the select component.
1541
+ * Can be 'small', 'medium', or 'large'.
1542
+ */
1543
+ this.size = 'medium';
1544
+ /**
1545
+ * Status of the select component.
1546
+ * Can be 'success', 'error', or 'default'.
1547
+ */
1548
+ this.status = 'default';
1549
+ /**
1550
+ * Whether the select component is disabled.
1551
+ * Reflects as an attribute in the DOM.
1552
+ */
1553
+ this.disabled = false;
1554
+ /**
1555
+ * Whether the select component is required.
1556
+ * Reflects as an attribute in the DOM.
1557
+ */
1558
+ this.required = false;
1559
+ /**
1560
+ * Enable / Disable search at options by term.
1561
+ * Default: false
1562
+ */
1563
+ this.searchBehavior = false;
1564
+ /**
1565
+ * The search will be sensitive to accents.
1566
+ * Default: true
1567
+ */
1568
+ this.caseSensitive = true;
1569
+ /**
1570
+ * CSS max-height property for dropdown item.
1571
+ * Can also be used by css property --max-height.
1572
+ * Default: 285px
1573
+ */
1574
+ this.maxHeight = '285px';
1575
+ /**
1576
+ * Internal state: Whether the input is hovered.
1577
+ * Default: false
1578
+ */
1579
+ this.isHovered = false;
1580
+ /**
1581
+ * Internal state: Whether the input is focused.
1582
+ * Default: false
1583
+ */
1584
+ this.isFocused = false;
1585
+ /**
1586
+ * Internal state: Whether the dropdown menu is open.
1587
+ * Default: false
1588
+ */
1589
+ this.isOpen = false;
1590
+ this.isPositioned = false;
1591
+ this.menuStyle = {
1592
+ top: '0px',
1593
+ left: '0px',
1594
+ width: '0px',
1595
+ maxHeight: this.maxHeight,
1596
+ };
1597
+ this.activeIndex = -1;
1598
+ this.preferredPlacement = 'bottom';
1599
+ this.textInput = '';
1600
+ this.floatingPlacement = 'bottom-start';
1601
+ /**
1602
+ * Styles to be applied to the component.
1603
+ */
1604
+ this.styles = {};
1605
+ /**
1606
+ * Theme object containing font and color information.
1607
+ */
1608
+ this.theme = window.CuraAPI.theme;
1609
+ /**
1610
+ * Handles mutations observed by the MutationObserver.
1611
+ * Updates the selected option or filters options based on the mutation type.
1612
+ */
1613
+ this.handleMutations = (mutations) => {
1614
+ mutations.forEach(mutation => {
1615
+ if (mutation.type === 'attributes') {
1616
+ if (mutation.attributeName === 'selected')
1617
+ this.updateSelectedOption();
1618
+ }
1619
+ });
1620
+ };
1621
+ /**
1622
+ * Handles the selection of an option.
1623
+ */
1624
+ this.onOptiselected = (event) => {
1625
+ const selectedOption = event.target;
1626
+ this.clearSelectedAttributes();
1627
+ selectedOption.setAttribute('selected', 'true');
1628
+ };
1629
+ this.handleKeyNavigation = (event) => {
1630
+ var _a;
1631
+ const { code: keyCode } = event;
1632
+ if (!this.isOpen && keyCode === 'ArrowDown') {
1633
+ this.openMenu();
1634
+ this.activeIndex = 0;
1635
+ return;
1636
+ }
1637
+ if (keyCode === 'ArrowDown') {
1638
+ event.preventDefault();
1639
+ this.updateActiveIndex(1);
1640
+ }
1641
+ if (keyCode === 'ArrowUp') {
1642
+ event.preventDefault();
1643
+ this.updateActiveIndex(-1);
1644
+ }
1645
+ if (keyCode === 'Enter' || keyCode === 'Space') {
1646
+ (_a = this.options[this.activeIndex]) === null || _a === void 0 ? void 0 : _a.click();
1647
+ }
1648
+ if (keyCode === 'Escape') {
1649
+ this.closeMenu();
1650
+ }
1651
+ };
1652
+ this.handleInputChange = (e) => {
1653
+ this.textInput = e.target.value;
1654
+ if (this.searchBehavior) {
1655
+ if (this.textInput.length > 0 && !this.isOpen)
1656
+ this.openMenu();
1657
+ if (this.textInput.length === 0 && this.isOpen)
1658
+ this.closeMenu();
1659
+ }
1660
+ this.internals.setFormValue(this.textInput);
1661
+ };
1662
+ this.handleClick = (event) => {
1663
+ if (this.disabled)
1664
+ return event.preventDefault();
1665
+ const target = event.target;
1666
+ if (target.tagName === 'CURA-SELECT-OPTION')
1667
+ return this.onOptiselected(event);
1668
+ this.isOpen ? this.closeMenu() : this.openMenu();
1669
+ };
1670
+ this.handleClickOutside = (event) => {
1671
+ const path = (event.composedPath && event.composedPath()) || [];
1672
+ const clickedOutside = !path.includes(this.host) && !(this.menuElement && path.includes(this.menuElement));
1673
+ if (clickedOutside) {
1674
+ this.closeMenu();
1675
+ }
1676
+ };
1677
+ this.handleViewportChange = () => {
1678
+ if (!this.isOpen)
1679
+ return;
1680
+ this.updateMenuPosition();
1681
+ };
1682
+ }
1683
+ updateOptionHighlights(newActiveINdex) {
1684
+ this.options.forEach((option, index) => (option.active = index === newActiveINdex));
1685
+ }
1686
+ /**
1687
+ * Filters the options based on the current input value.
1688
+ */
1689
+ filterOptions(newText) {
1690
+ this.searchTermInput.emit(newText);
1691
+ if (!this.isOpen || !this.searchBehavior) {
1692
+ return;
1693
+ }
1694
+ const removeAccents = (str) => {
1695
+ return str.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
1696
+ };
1697
+ let searchTerm = newText;
1698
+ if (!this.caseSensitive) {
1699
+ searchTerm = removeAccents(searchTerm).toLocaleLowerCase();
1700
+ }
1701
+ this.options.forEach(option => {
1702
+ let optionValue = option.textContent || '';
1703
+ if (!this.caseSensitive) {
1704
+ optionValue = removeAccents(optionValue === null || optionValue === void 0 ? void 0 : optionValue.toLowerCase());
1705
+ }
1706
+ const isVisible = optionValue.includes(searchTerm);
1707
+ option.style.display = isVisible ? 'block' : 'none';
1708
+ });
1709
+ }
1710
+ /**
1711
+ * Callback for form association.
1712
+ */
1713
+ formAssociatedCallback(form) {
1714
+ form.ariaLabel = this.label;
1715
+ }
1716
+ /**
1717
+ * Callback to restore the switch state from the form.
1718
+ */
1719
+ formStateRestoreCallback(state) {
1720
+ this.textInput = state.value;
1721
+ this.updateSelectedOption();
1722
+ }
1723
+ /**
1724
+ * Callback to reset the switch state when the form is reset.
1725
+ */
1726
+ formResetCallback() {
1727
+ this.textInput = '';
1728
+ this.clearSelectedAttributes();
1729
+ this.internals.setFormValue('');
1730
+ this.internals.setValidity({});
1731
+ }
1732
+ /**
1733
+ * Callback to update the switch's disabled state when the form's disabled state changes.
1734
+ */
1735
+ formDisabledCallback(disabled) {
1736
+ this.disabled = disabled;
1737
+ }
1738
+ /**
1739
+ * Lifecycle method called before the component is rendered.
1740
+ * Initializes the options for the select component.
1741
+ */
1742
+ componentWillLoad() {
1743
+ this.initializeOptions();
1744
+ }
1745
+ /**
1746
+ * Lifecycle method called after the component is rendered.
1747
+ * Initializes select-related functionality.
1748
+ */
1749
+ componentDidLoad() {
1750
+ // this.initializeOptions();
1751
+ this.setupMutationObserver();
1752
+ this.addOutsideClickListener();
1753
+ this.addPositionListeners();
1754
+ }
1755
+ /**
1756
+ * Lifecycle method called when the component is connected to the DOM.
1757
+ * Applies styles based on the theme.
1758
+ */
1759
+ connectedCallback() {
1760
+ this.applyStyles();
1761
+ }
1762
+ /**
1763
+ * Lifecycle method called when the component is disconnected from the DOM.
1764
+ * Disconnects the MutationObserver if it exists.
1765
+ */
1766
+ disconnectedCallback() {
1767
+ var _a, _b;
1768
+ (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
1769
+ this.removeOutsideClickListener();
1770
+ this.removePositionListeners();
1771
+ (_b = this.cleanupAutoUpdate) === null || _b === void 0 ? void 0 : _b.call(this);
1772
+ }
1773
+ initializeOptions() {
1774
+ var _a;
1775
+ this.options = this.host.querySelectorAll('cura-select-option');
1776
+ this.options.forEach(option => {
1777
+ option.setAttribute('size', this.size);
1778
+ const isSelected = this.value === option.value;
1779
+ option.setAttribute('selected', JSON.stringify(isSelected));
1780
+ if (isSelected) {
1781
+ this.value = option.value;
1782
+ this.internals.setFormValue(option.value);
1783
+ }
1784
+ });
1785
+ this.textInput = ((_a = Array.from(this.options).find(option => option.value === this.value)) === null || _a === void 0 ? void 0 : _a.textContent) || this.textInput;
1786
+ }
1787
+ /**
1788
+ * Applies styles to the component based on the theme.
1789
+ */
1790
+ applyStyles() {
1791
+ const { fonts, colors } = this.theme;
1792
+ const fontWeights = fonts.getWeights();
1793
+ this.styles = Object.assign(Object.assign({}, this.styles), { '--font-weight-medium': fontWeights.medium, '--font-weight-bold': fontWeights.bold, '--font-weight-regular': fontWeights.regular, '--font-color': fonts.getColor(), '--font-family': fonts.getFamily(), '--font-size': fonts.getSize() });
1794
+ const colorKeys = [
1795
+ 'primary-base',
1796
+ 'neutral-purewhite',
1797
+ 'neutral-white',
1798
+ 'neutral-black',
1799
+ 'neutral-medium',
1800
+ 'neutral-light',
1801
+ 'neutral-base',
1802
+ 'neutral-dark',
1803
+ 'success-dark',
1804
+ 'success-darker',
1805
+ 'success-lighter',
1806
+ 'error-lighter',
1807
+ 'error-dark',
1808
+ 'error-darker',
1809
+ 'error-base',
1810
+ 'info-base',
1811
+ ];
1812
+ colorKeys.forEach(key => {
1813
+ this.styles[`--${key}`] = colors.getColor(key);
1814
+ });
1815
+ }
1816
+ /**
1817
+ * Sets up a MutationObserver to watch for changes in the component.
1818
+ */
1819
+ setupMutationObserver() {
1820
+ this.mutationObserver = new MutationObserver(this.handleMutations);
1821
+ this.mutationObserver.observe(this.host, { attributes: true, subtree: true, attributeFilter: ['selected', 'value'] });
1822
+ }
1823
+ handleValueChange(newValue) {
1824
+ this.clearSelectedAttributes();
1825
+ const selectedOption = this.host.querySelector(`cura-select-option[value="${newValue}"]`);
1826
+ if (!selectedOption) {
1827
+ return;
1828
+ }
1829
+ selectedOption.setAttribute('selected', 'true');
1830
+ }
1831
+ updateSelectedOption() {
1832
+ const selectedOptionElement = this.host.querySelector('cura-select-option[selected]');
1833
+ if (!selectedOptionElement) {
1834
+ return;
1835
+ }
1836
+ this.value = selectedOptionElement.value;
1837
+ this.internals.setFormValue(this.value);
1838
+ if (this.textInput !== selectedOptionElement.textContent) {
1839
+ this.textInput = selectedOptionElement.textContent;
1840
+ this.closeMenu();
1841
+ this.selected.emit(selectedOptionElement.value);
1842
+ }
1843
+ }
1844
+ /**
1845
+ * Clears the 'selected' attribute from all options.
1846
+ */
1847
+ clearSelectedAttributes() {
1848
+ this.options.forEach(option => option.removeAttribute('selected'));
1849
+ }
1850
+ updateActiveIndex(direction) {
1851
+ if (this.options.length === 0)
1852
+ return;
1853
+ this.activeIndex = (this.activeIndex + direction + this.options.length) % this.options.length;
1854
+ }
1855
+ getClasses() {
1856
+ return {
1857
+ wrapper: true,
1858
+ label: !!this.label,
1859
+ disabled: this.disabled,
1860
+ transparent: this.mode === 'transparent',
1861
+ [this.size.toLowerCase()]: true,
1862
+ [this.status.toLowerCase()]: true,
1863
+ };
1864
+ }
1865
+ /**
1866
+ * Determines the color based on the item type and component state.
1867
+ */
1868
+ getColor(item) {
1869
+ if (this.disabled)
1870
+ return 'neutral-medium';
1871
+ const isStatusDefault = this.status === 'default';
1872
+ const isHoveredOrFocused = this.isFocused || this.isHovered;
1873
+ if (item === 'label') {
1874
+ if (!isStatusDefault || isHoveredOrFocused)
1875
+ return 'neutral-black';
1876
+ return 'neutral-dark';
1877
+ }
1878
+ if (isHoveredOrFocused && isStatusDefault)
1879
+ return 'neutral-black';
1880
+ if (this.status === 'success')
1881
+ return 'success-dark';
1882
+ if (this.status === 'error')
1883
+ return 'error-dark';
1884
+ return 'neutral-dark';
1885
+ }
1886
+ /**
1887
+ * Renders the icon based on the component's status.
1888
+ */
1889
+ renderIcon() {
1890
+ if (this.status === 'default' && !this.iconName)
1891
+ return null;
1892
+ const icon = { default: this.iconName, success: 'checkCircle', error: 'alertCircle' }[this.status];
1893
+ return h("cura-icon", { class: "feedback-icon", name: icon, iconset: "default", size: this.size === 'large' ? 20 : 16, color: this.getColor('icon'), style: this.styles });
1894
+ }
1895
+ openMenu() {
1896
+ this.isOpen = true;
1897
+ this.isPositioned = false;
1898
+ requestAnimationFrame(() => this.setupFloating());
1899
+ }
1900
+ closeMenu() {
1901
+ var _a;
1902
+ this.isOpen = false;
1903
+ this.isPositioned = false;
1904
+ (_a = this.cleanupAutoUpdate) === null || _a === void 0 ? void 0 : _a.call(this);
1905
+ }
1906
+ addOutsideClickListener() {
1907
+ document.addEventListener('click', this.handleClickOutside);
1908
+ }
1909
+ removeOutsideClickListener() {
1910
+ document.removeEventListener('click', this.handleClickOutside);
1911
+ }
1912
+ addPositionListeners() {
1913
+ window.addEventListener('resize', this.handleViewportChange, { passive: true });
1914
+ window.addEventListener('scroll', this.handleViewportChange, true);
1915
+ }
1916
+ removePositionListeners() {
1917
+ window.removeEventListener('resize', this.handleViewportChange);
1918
+ window.removeEventListener('scroll', this.handleViewportChange, true);
1919
+ }
1920
+ parseMaxHeight() {
1921
+ const numeric = parseFloat(this.maxHeight);
1922
+ return Number.isFinite(numeric) ? numeric : 285;
1923
+ }
1924
+ setupFloating() {
1925
+ var _a;
1926
+ if (!this.inputWrapper || !this.menuElement)
1927
+ return;
1928
+ (_a = this.cleanupAutoUpdate) === null || _a === void 0 ? void 0 : _a.call(this);
1929
+ this.cleanupAutoUpdate = autoUpdate(this.inputWrapper, this.menuElement, () => {
1930
+ this.updateMenuPosition();
1931
+ });
1932
+ this.updateMenuPosition();
1933
+ }
1934
+ updateMenuPosition() {
1935
+ if (!this.inputWrapper || !this.menuElement)
1936
+ return;
1937
+ computePosition(this.inputWrapper, this.menuElement, {
1938
+ strategy: 'fixed',
1939
+ placement: this.floatingPlacement,
1940
+ middleware: [
1941
+ offset(0),
1942
+ flip(),
1943
+ shift({ padding: 8 }),
1944
+ size({
1945
+ apply: ({ rects, availableHeight }) => {
1946
+ this.menuStyle = Object.assign(Object.assign({}, this.menuStyle), { width: `${rects.reference.width}px`, maxHeight: `${Math.min(availableHeight, this.parseMaxHeight())}px` });
1947
+ },
1948
+ }),
1949
+ ],
1950
+ }).then(({ x, y, placement }) => {
1951
+ this.preferredPlacement = placement.startsWith('top') ? 'top' : 'bottom';
1952
+ this.menuStyle = Object.assign(Object.assign({}, this.menuStyle), { top: `${y}px`, left: `${x}px` });
1953
+ this.isPositioned = true;
1954
+ });
1955
+ }
1956
+ render() {
1957
+ return (h(Host, { key: '8a05e5365062b5a2da4f10d7e3ca04f9d3136fba', style: this.styles, role: "combobox", "aria-label": this.label, "aria-required": String(this.required), "aria-disabled": String(this.disabled), "aria-invalid": String(this.status === 'error') }, h("div", { key: 'ab28fd73d68ccdc5ad6dd6cc7f79d879eaf25818', class: this.getClasses(), onMouseEnter: () => (this.isHovered = true), onMouseLeave: () => (this.isHovered = false), onClick: this.handleClick }, this.label && (h("cura-label", { key: '5405aa3706b07640fdfdaa681ad22ea9c5fd9997', class: "label", weight: "bold", size: this.size === 'large' ? 'small' : 'xsmall', color: this.getColor('label') }, this.label, " ", this.required && h("span", { key: '39b37aefbf4e61572607d891eb63c737c332793c', class: "required" }, "* "))), h("div", { key: 'c339ab1ff49699fb0a348a169ba7f545b89bd593', class: {
1958
+ 'cura-input-field': true,
1959
+ 'open': this.isOpen,
1960
+ }, ref: el => (this.inputWrapper = el) }, this.renderIcon(), h("input", { key: '5118ad409b6b9c48c856670857d3cae26d28fd46', type: "text", autocomplete: "off", onFocus: () => (this.isFocused = true), onBlur: () => (this.isFocused = false), onKeyDown: this.handleKeyNavigation, "aria-required": String(this.required), "aria-disabled": String(this.disabled), "aria-invalid": String(this.status === 'error'), onInput: this.handleInputChange, style: this.styles, placeholder: this.placeholder, disabled: this.disabled, required: this.required, value: this.textInput, readonly: this.searchBehavior ? null : true }), h("button", { key: '53bddc2b1e56462a9181ce99749d98568f1c5dd9', class: "up-down-button" }, h("cura-icon", { key: '01cb20504d2e0506e7210d33e3ca75978a598eff', name: this.isOpen ? 'up' : 'down', class: "up-down-icon", color: this.disabled ? 'neutral-dark' : 'primary-base', size: 16, iconset: "default" }))), h("cura-label", { key: '550c24779f690ebd16bec881770b200ce06f5390', class: "helper-text", size: "xsmall", color: this.getColor('text'), weight: this.mode === 'transparent' ? 'bold' : 'regular' }, h("slot", { key: '530f64f99df6328d3a49a449f8f924e57bb03f21' })), this.isOpen && (h("div", { key: '3ee7a6439c98a0837a3f39d27646ed7a55c630b3', class: {
1961
+ menu: true,
1962
+ open: this.isOpen,
1963
+ [this.preferredPlacement]: true,
1964
+ }, ref: el => (this.menuElement = el), style: {
1965
+ '--max-height': this.maxHeight,
1966
+ top: this.menuStyle.top,
1967
+ left: this.menuStyle.left,
1968
+ width: this.menuStyle.width,
1969
+ maxHeight: this.menuStyle.maxHeight,
1970
+ visibility: this.isPositioned ? 'visible' : 'hidden',
1971
+ opacity: this.isPositioned ? '1' : '0',
1972
+ pointerEvents: this.isPositioned ? 'auto' : 'none',
1973
+ } }, h("slot", { key: '84c3bb501966175635102b2ccbfa0cf43d2112f1', name: "option" }))))));
1974
+ }
1975
+ static get formAssociated() { return true; }
1976
+ get host() { return this; }
1977
+ static get watchers() { return {
1978
+ "activeIndex": ["updateOptionHighlights"],
1979
+ "textInput": ["filterOptions"],
1980
+ "value": ["handleValueChange"]
1981
+ }; }
1982
+ static get style() { return curaSelectCss; }
1983
+ }, [65, "cura-select", {
1984
+ "label": [513],
1985
+ "placeholder": [513],
1986
+ "value": [1537],
1987
+ "mode": [513],
1988
+ "size": [513],
1989
+ "iconName": [1, "icon-name"],
1990
+ "status": [1537],
1991
+ "disabled": [516],
1992
+ "required": [516],
1993
+ "searchBehavior": [516, "search-behavior"],
1994
+ "caseSensitive": [516, "case-sensitive"],
1995
+ "maxHeight": [513, "max-height"],
1996
+ "isHovered": [32],
1997
+ "isFocused": [32],
1998
+ "isOpen": [32],
1999
+ "isPositioned": [32],
2000
+ "menuStyle": [32],
2001
+ "options": [32],
2002
+ "activeIndex": [32],
2003
+ "preferredPlacement": [32],
2004
+ "textInput": [32]
2005
+ }, undefined, {
2006
+ "activeIndex": ["updateOptionHighlights"],
2007
+ "textInput": ["filterOptions"],
2008
+ "value": ["handleValueChange"]
2009
+ }]);
2010
+ function defineCustomElement() {
2011
+ if (typeof customElements === "undefined") {
2012
+ return;
2013
+ }
2014
+ const components = ["cura-select", "cura-icon", "cura-label"];
2015
+ components.forEach(tagName => { switch (tagName) {
2016
+ case "cura-select":
2017
+ if (!customElements.get(tagName)) {
2018
+ customElements.define(tagName, CuraSelect);
2019
+ }
2020
+ break;
2021
+ case "cura-icon":
2022
+ if (!customElements.get(tagName)) {
2023
+ defineCustomElement$2();
2024
+ }
2025
+ break;
2026
+ case "cura-label":
2027
+ if (!customElements.get(tagName)) {
2028
+ defineCustomElement$1();
2029
+ }
2030
+ break;
2031
+ } });
2032
+ }
2033
+
2034
+ export { CuraSelect as C, defineCustomElement as d };
2035
+ //# sourceMappingURL=p-Cs5scX1L.js.map
2036
+
2037
+ //# sourceMappingURL=p-Cs5scX1L.js.map