@sankhyalabs/ezui 5.22.0-dev.96 → 5.22.0-dev.97

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 (55) hide show
  1. package/dist/cjs/ez-card-item_2.cjs.entry.js +1416 -7
  2. package/dist/cjs/ez-chip.cjs.entry.js +1 -1
  3. package/dist/cjs/ez-popover-plus_3.cjs.entry.js +198 -0
  4. package/dist/cjs/ez-scroller_2.cjs.entry.js +1 -1
  5. package/dist/cjs/ez-search.cjs.entry.js +28 -158
  6. package/dist/cjs/ezui.cjs.js +1 -1
  7. package/dist/cjs/index-a7b0c73d.js +4 -4
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/cjs/searchFormatters-b7e1ed1e.js +23 -0
  10. package/dist/collection/collection-manifest.json +2 -1
  11. package/dist/collection/components/ez-card-item/ez-card-item.css +1 -3
  12. package/dist/collection/components/ez-chip/ez-chip.css +5 -1
  13. package/dist/collection/components/ez-popover-plus/ez-popover-plus.js +49 -2
  14. package/dist/collection/components/ez-popover-plus/subcomponent/ez-popover-core.css +2 -2
  15. package/dist/collection/components/ez-popover-plus/subcomponent/ez-popover-core.js +72 -12
  16. package/dist/collection/components/ez-scroller/ez-scroller.css +3 -0
  17. package/dist/collection/components/ez-search/ez-search.css +0 -219
  18. package/dist/collection/components/ez-search/ez-search.js +28 -167
  19. package/dist/collection/components/ez-search/subcomponent/search-list/search-list.css +227 -0
  20. package/dist/collection/components/ez-search/subcomponent/search-list/search-list.js +289 -0
  21. package/dist/collection/components/ez-search/utils/searchFormatters.js +18 -0
  22. package/dist/custom-elements/index.d.ts +6 -0
  23. package/dist/custom-elements/index.js +169 -177
  24. package/dist/esm/ez-card-item_2.entry.js +1416 -7
  25. package/dist/esm/ez-chip.entry.js +1 -1
  26. package/dist/esm/ez-popover-plus_3.entry.js +192 -0
  27. package/dist/esm/ez-scroller_2.entry.js +1 -1
  28. package/dist/esm/ez-search.entry.js +29 -159
  29. package/dist/esm/ezui.js +1 -1
  30. package/dist/esm/index-baa5e267.js +4 -4
  31. package/dist/esm/loader.js +1 -1
  32. package/dist/esm/searchFormatters-8229207e.js +20 -0
  33. package/dist/ezui/ezui.esm.js +1 -1
  34. package/dist/ezui/p-288631d1.entry.js +1 -0
  35. package/dist/ezui/p-31da1b57.entry.js +1 -0
  36. package/dist/ezui/p-40a60148.js +1 -0
  37. package/dist/ezui/p-5aca7386.entry.js +1 -0
  38. package/dist/ezui/p-b7706b43.entry.js +1 -0
  39. package/dist/ezui/{p-17be134a.entry.js → p-e06a9886.entry.js} +1 -1
  40. package/dist/types/components/ez-popover-plus/ez-popover-plus.d.ts +9 -1
  41. package/dist/types/components/ez-popover-plus/subcomponent/ez-popover-core.d.ts +12 -2
  42. package/dist/types/components/ez-search/ez-search.d.ts +3 -13
  43. package/dist/types/components/ez-search/subcomponent/search-list/search-list.d.ts +23 -0
  44. package/dist/types/components/ez-search/utils/searchFormatters.d.ts +2 -0
  45. package/dist/types/components.d.ts +72 -4
  46. package/package.json +1 -1
  47. package/react/components.d.ts +1 -0
  48. package/react/components.js +1 -0
  49. package/react/components.js.map +1 -1
  50. package/dist/cjs/ez-popover-core_2.cjs.entry.js +0 -1504
  51. package/dist/esm/ez-popover-core_2.entry.js +0 -1499
  52. package/dist/ezui/p-58783dcf.entry.js +0 -1
  53. package/dist/ezui/p-65f471bc.entry.js +0 -1
  54. package/dist/ezui/p-7bd15498.entry.js +0 -1
  55. package/dist/ezui/p-990b4318.entry.js +0 -1
@@ -1,1504 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const index = require('./index-a7b0c73d.js');
6
-
7
- /**
8
- * Custom positioning reference element.
9
- * @see https://floating-ui.com/docs/virtual-elements
10
- */
11
- const min = Math.min;
12
- const max = Math.max;
13
- const round = Math.round;
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
- /**
478
- * Optimizes the visibility of the floating element by shifting it in order to
479
- * keep it in view when it will overflow the clipping boundary.
480
- * @see https://floating-ui.com/docs/shift
481
- */
482
- const shift$1 = function (options) {
483
- if (options === void 0) {
484
- options = {};
485
- }
486
- return {
487
- name: 'shift',
488
- options,
489
- async fn(state) {
490
- const {
491
- x,
492
- y,
493
- placement
494
- } = state;
495
- const {
496
- mainAxis: checkMainAxis = true,
497
- crossAxis: checkCrossAxis = false,
498
- limiter = {
499
- fn: _ref => {
500
- let {
501
- x,
502
- y
503
- } = _ref;
504
- return {
505
- x,
506
- y
507
- };
508
- }
509
- },
510
- ...detectOverflowOptions
511
- } = evaluate(options, state);
512
- const coords = {
513
- x,
514
- y
515
- };
516
- const overflow = await detectOverflow(state, detectOverflowOptions);
517
- const crossAxis = getSideAxis(getSide(placement));
518
- const mainAxis = getOppositeAxis(crossAxis);
519
- let mainAxisCoord = coords[mainAxis];
520
- let crossAxisCoord = coords[crossAxis];
521
- if (checkMainAxis) {
522
- const minSide = mainAxis === 'y' ? 'top' : 'left';
523
- const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
524
- const min = mainAxisCoord + overflow[minSide];
525
- const max = mainAxisCoord - overflow[maxSide];
526
- mainAxisCoord = clamp(min, mainAxisCoord, max);
527
- }
528
- if (checkCrossAxis) {
529
- const minSide = crossAxis === 'y' ? 'top' : 'left';
530
- const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
531
- const min = crossAxisCoord + overflow[minSide];
532
- const max = crossAxisCoord - overflow[maxSide];
533
- crossAxisCoord = clamp(min, crossAxisCoord, max);
534
- }
535
- const limitedCoords = limiter.fn({
536
- ...state,
537
- [mainAxis]: mainAxisCoord,
538
- [crossAxis]: crossAxisCoord
539
- });
540
- return {
541
- ...limitedCoords,
542
- data: {
543
- x: limitedCoords.x - x,
544
- y: limitedCoords.y - y,
545
- enabled: {
546
- [mainAxis]: checkMainAxis,
547
- [crossAxis]: checkCrossAxis
548
- }
549
- }
550
- };
551
- }
552
- };
553
- };
554
-
555
- function hasWindow() {
556
- return typeof window !== 'undefined';
557
- }
558
- function getNodeName(node) {
559
- if (isNode(node)) {
560
- return (node.nodeName || '').toLowerCase();
561
- }
562
- // Mocked nodes in testing environments may not be instances of Node. By
563
- // returning `#document` an infinite loop won't occur.
564
- // https://github.com/floating-ui/floating-ui/issues/2317
565
- return '#document';
566
- }
567
- function getWindow(node) {
568
- var _node$ownerDocument;
569
- return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
570
- }
571
- function getDocumentElement(node) {
572
- var _ref;
573
- return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
574
- }
575
- function isNode(value) {
576
- if (!hasWindow()) {
577
- return false;
578
- }
579
- return value instanceof Node || value instanceof getWindow(value).Node;
580
- }
581
- function isElement(value) {
582
- if (!hasWindow()) {
583
- return false;
584
- }
585
- return value instanceof Element || value instanceof getWindow(value).Element;
586
- }
587
- function isHTMLElement(value) {
588
- if (!hasWindow()) {
589
- return false;
590
- }
591
- return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
592
- }
593
- function isShadowRoot(value) {
594
- if (!hasWindow() || typeof ShadowRoot === 'undefined') {
595
- return false;
596
- }
597
- return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
598
- }
599
- function isOverflowElement(element) {
600
- const {
601
- overflow,
602
- overflowX,
603
- overflowY,
604
- display
605
- } = getComputedStyle(element);
606
- return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
607
- }
608
- function isTableElement(element) {
609
- return ['table', 'td', 'th'].includes(getNodeName(element));
610
- }
611
- function isTopLayer(element) {
612
- return [':popover-open', ':modal'].some(selector => {
613
- try {
614
- return element.matches(selector);
615
- } catch (e) {
616
- return false;
617
- }
618
- });
619
- }
620
- function isContainingBlock(elementOrCss) {
621
- const webkit = isWebKit();
622
- const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
623
-
624
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
625
- // https://drafts.csswg.org/css-transforms-2/#individual-transforms
626
- return ['transform', 'translate', 'scale', 'rotate', 'perspective'].some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
627
- }
628
- function getContainingBlock(element) {
629
- let currentNode = getParentNode(element);
630
- while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
631
- if (isContainingBlock(currentNode)) {
632
- return currentNode;
633
- } else if (isTopLayer(currentNode)) {
634
- return null;
635
- }
636
- currentNode = getParentNode(currentNode);
637
- }
638
- return null;
639
- }
640
- function isWebKit() {
641
- if (typeof CSS === 'undefined' || !CSS.supports) return false;
642
- return CSS.supports('-webkit-backdrop-filter', 'none');
643
- }
644
- function isLastTraversableNode(node) {
645
- return ['html', 'body', '#document'].includes(getNodeName(node));
646
- }
647
- function getComputedStyle(element) {
648
- return getWindow(element).getComputedStyle(element);
649
- }
650
- function getNodeScroll(element) {
651
- if (isElement(element)) {
652
- return {
653
- scrollLeft: element.scrollLeft,
654
- scrollTop: element.scrollTop
655
- };
656
- }
657
- return {
658
- scrollLeft: element.scrollX,
659
- scrollTop: element.scrollY
660
- };
661
- }
662
- function getParentNode(node) {
663
- if (getNodeName(node) === 'html') {
664
- return node;
665
- }
666
- const result =
667
- // Step into the shadow DOM of the parent of a slotted node.
668
- node.assignedSlot ||
669
- // DOM Element detected.
670
- node.parentNode ||
671
- // ShadowRoot detected.
672
- isShadowRoot(node) && node.host ||
673
- // Fallback.
674
- getDocumentElement(node);
675
- return isShadowRoot(result) ? result.host : result;
676
- }
677
- function getNearestOverflowAncestor(node) {
678
- const parentNode = getParentNode(node);
679
- if (isLastTraversableNode(parentNode)) {
680
- return node.ownerDocument ? node.ownerDocument.body : node.body;
681
- }
682
- if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
683
- return parentNode;
684
- }
685
- return getNearestOverflowAncestor(parentNode);
686
- }
687
- function getOverflowAncestors(node, list, traverseIframes) {
688
- var _node$ownerDocument2;
689
- if (list === void 0) {
690
- list = [];
691
- }
692
- if (traverseIframes === void 0) {
693
- traverseIframes = true;
694
- }
695
- const scrollableAncestor = getNearestOverflowAncestor(node);
696
- const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
697
- const win = getWindow(scrollableAncestor);
698
- if (isBody) {
699
- const frameElement = getFrameElement(win);
700
- return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
701
- }
702
- return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
703
- }
704
- function getFrameElement(win) {
705
- return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
706
- }
707
-
708
- function getCssDimensions(element) {
709
- const css = getComputedStyle(element);
710
- // In testing environments, the `width` and `height` properties are empty
711
- // strings for SVG elements, returning NaN. Fallback to `0` in this case.
712
- let width = parseFloat(css.width) || 0;
713
- let height = parseFloat(css.height) || 0;
714
- const hasOffset = isHTMLElement(element);
715
- const offsetWidth = hasOffset ? element.offsetWidth : width;
716
- const offsetHeight = hasOffset ? element.offsetHeight : height;
717
- const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
718
- if (shouldFallback) {
719
- width = offsetWidth;
720
- height = offsetHeight;
721
- }
722
- return {
723
- width,
724
- height,
725
- $: shouldFallback
726
- };
727
- }
728
-
729
- function unwrapElement(element) {
730
- return !isElement(element) ? element.contextElement : element;
731
- }
732
-
733
- function getScale(element) {
734
- const domElement = unwrapElement(element);
735
- if (!isHTMLElement(domElement)) {
736
- return createCoords(1);
737
- }
738
- const rect = domElement.getBoundingClientRect();
739
- const {
740
- width,
741
- height,
742
- $
743
- } = getCssDimensions(domElement);
744
- let x = ($ ? round(rect.width) : rect.width) / width;
745
- let y = ($ ? round(rect.height) : rect.height) / height;
746
-
747
- // 0, NaN, or Infinity should always fallback to 1.
748
-
749
- if (!x || !Number.isFinite(x)) {
750
- x = 1;
751
- }
752
- if (!y || !Number.isFinite(y)) {
753
- y = 1;
754
- }
755
- return {
756
- x,
757
- y
758
- };
759
- }
760
-
761
- const noOffsets = /*#__PURE__*/createCoords(0);
762
- function getVisualOffsets(element) {
763
- const win = getWindow(element);
764
- if (!isWebKit() || !win.visualViewport) {
765
- return noOffsets;
766
- }
767
- return {
768
- x: win.visualViewport.offsetLeft,
769
- y: win.visualViewport.offsetTop
770
- };
771
- }
772
- function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
773
- if (isFixed === void 0) {
774
- isFixed = false;
775
- }
776
- if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
777
- return false;
778
- }
779
- return isFixed;
780
- }
781
-
782
- function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
783
- if (includeScale === void 0) {
784
- includeScale = false;
785
- }
786
- if (isFixedStrategy === void 0) {
787
- isFixedStrategy = false;
788
- }
789
- const clientRect = element.getBoundingClientRect();
790
- const domElement = unwrapElement(element);
791
- let scale = createCoords(1);
792
- if (includeScale) {
793
- if (offsetParent) {
794
- if (isElement(offsetParent)) {
795
- scale = getScale(offsetParent);
796
- }
797
- } else {
798
- scale = getScale(element);
799
- }
800
- }
801
- const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
802
- let x = (clientRect.left + visualOffsets.x) / scale.x;
803
- let y = (clientRect.top + visualOffsets.y) / scale.y;
804
- let width = clientRect.width / scale.x;
805
- let height = clientRect.height / scale.y;
806
- if (domElement) {
807
- const win = getWindow(domElement);
808
- const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
809
- let currentWin = win;
810
- let currentIFrame = getFrameElement(currentWin);
811
- while (currentIFrame && offsetParent && offsetWin !== currentWin) {
812
- const iframeScale = getScale(currentIFrame);
813
- const iframeRect = currentIFrame.getBoundingClientRect();
814
- const css = getComputedStyle(currentIFrame);
815
- const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
816
- const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
817
- x *= iframeScale.x;
818
- y *= iframeScale.y;
819
- width *= iframeScale.x;
820
- height *= iframeScale.y;
821
- x += left;
822
- y += top;
823
- currentWin = getWindow(currentIFrame);
824
- currentIFrame = getFrameElement(currentWin);
825
- }
826
- }
827
- return rectToClientRect({
828
- width,
829
- height,
830
- x,
831
- y
832
- });
833
- }
834
-
835
- // If <html> has a CSS width greater than the viewport, then this will be
836
- // incorrect for RTL.
837
- function getWindowScrollBarX(element, rect) {
838
- const leftScroll = getNodeScroll(element).scrollLeft;
839
- if (!rect) {
840
- return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
841
- }
842
- return rect.left + leftScroll;
843
- }
844
-
845
- function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
846
- if (ignoreScrollbarX === void 0) {
847
- ignoreScrollbarX = false;
848
- }
849
- const htmlRect = documentElement.getBoundingClientRect();
850
- const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 :
851
- // RTL <body> scrollbar.
852
- getWindowScrollBarX(documentElement, htmlRect));
853
- const y = htmlRect.top + scroll.scrollTop;
854
- return {
855
- x,
856
- y
857
- };
858
- }
859
-
860
- function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
861
- let {
862
- elements,
863
- rect,
864
- offsetParent,
865
- strategy
866
- } = _ref;
867
- const isFixed = strategy === 'fixed';
868
- const documentElement = getDocumentElement(offsetParent);
869
- const topLayer = elements ? isTopLayer(elements.floating) : false;
870
- if (offsetParent === documentElement || topLayer && isFixed) {
871
- return rect;
872
- }
873
- let scroll = {
874
- scrollLeft: 0,
875
- scrollTop: 0
876
- };
877
- let scale = createCoords(1);
878
- const offsets = createCoords(0);
879
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
880
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
881
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
882
- scroll = getNodeScroll(offsetParent);
883
- }
884
- if (isHTMLElement(offsetParent)) {
885
- const offsetRect = getBoundingClientRect(offsetParent);
886
- scale = getScale(offsetParent);
887
- offsets.x = offsetRect.x + offsetParent.clientLeft;
888
- offsets.y = offsetRect.y + offsetParent.clientTop;
889
- }
890
- }
891
- const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
892
- return {
893
- width: rect.width * scale.x,
894
- height: rect.height * scale.y,
895
- x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
896
- y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
897
- };
898
- }
899
-
900
- function getClientRects(element) {
901
- return Array.from(element.getClientRects());
902
- }
903
-
904
- // Gets the entire size of the scrollable document area, even extending outside
905
- // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
906
- function getDocumentRect(element) {
907
- const html = getDocumentElement(element);
908
- const scroll = getNodeScroll(element);
909
- const body = element.ownerDocument.body;
910
- const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
911
- const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
912
- let x = -scroll.scrollLeft + getWindowScrollBarX(element);
913
- const y = -scroll.scrollTop;
914
- if (getComputedStyle(body).direction === 'rtl') {
915
- x += max(html.clientWidth, body.clientWidth) - width;
916
- }
917
- return {
918
- width,
919
- height,
920
- x,
921
- y
922
- };
923
- }
924
-
925
- function getViewportRect(element, strategy) {
926
- const win = getWindow(element);
927
- const html = getDocumentElement(element);
928
- const visualViewport = win.visualViewport;
929
- let width = html.clientWidth;
930
- let height = html.clientHeight;
931
- let x = 0;
932
- let y = 0;
933
- if (visualViewport) {
934
- width = visualViewport.width;
935
- height = visualViewport.height;
936
- const visualViewportBased = isWebKit();
937
- if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
938
- x = visualViewport.offsetLeft;
939
- y = visualViewport.offsetTop;
940
- }
941
- }
942
- return {
943
- width,
944
- height,
945
- x,
946
- y
947
- };
948
- }
949
-
950
- // Returns the inner client rect, subtracting scrollbars if present.
951
- function getInnerBoundingClientRect(element, strategy) {
952
- const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
953
- const top = clientRect.top + element.clientTop;
954
- const left = clientRect.left + element.clientLeft;
955
- const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
956
- const width = element.clientWidth * scale.x;
957
- const height = element.clientHeight * scale.y;
958
- const x = left * scale.x;
959
- const y = top * scale.y;
960
- return {
961
- width,
962
- height,
963
- x,
964
- y
965
- };
966
- }
967
- function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
968
- let rect;
969
- if (clippingAncestor === 'viewport') {
970
- rect = getViewportRect(element, strategy);
971
- } else if (clippingAncestor === 'document') {
972
- rect = getDocumentRect(getDocumentElement(element));
973
- } else if (isElement(clippingAncestor)) {
974
- rect = getInnerBoundingClientRect(clippingAncestor, strategy);
975
- } else {
976
- const visualOffsets = getVisualOffsets(element);
977
- rect = {
978
- x: clippingAncestor.x - visualOffsets.x,
979
- y: clippingAncestor.y - visualOffsets.y,
980
- width: clippingAncestor.width,
981
- height: clippingAncestor.height
982
- };
983
- }
984
- return rectToClientRect(rect);
985
- }
986
- function hasFixedPositionAncestor(element, stopNode) {
987
- const parentNode = getParentNode(element);
988
- if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
989
- return false;
990
- }
991
- return getComputedStyle(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
992
- }
993
-
994
- // A "clipping ancestor" is an `overflow` element with the characteristic of
995
- // clipping (or hiding) child elements. This returns all clipping ancestors
996
- // of the given element up the tree.
997
- function getClippingElementAncestors(element, cache) {
998
- const cachedResult = cache.get(element);
999
- if (cachedResult) {
1000
- return cachedResult;
1001
- }
1002
- let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
1003
- let currentContainingBlockComputedStyle = null;
1004
- const elementIsFixed = getComputedStyle(element).position === 'fixed';
1005
- let currentNode = elementIsFixed ? getParentNode(element) : element;
1006
-
1007
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1008
- while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1009
- const computedStyle = getComputedStyle(currentNode);
1010
- const currentNodeIsContaining = isContainingBlock(currentNode);
1011
- if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1012
- currentContainingBlockComputedStyle = null;
1013
- }
1014
- const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1015
- if (shouldDropCurrentNode) {
1016
- // Drop non-containing blocks.
1017
- result = result.filter(ancestor => ancestor !== currentNode);
1018
- } else {
1019
- // Record last containing block for next iteration.
1020
- currentContainingBlockComputedStyle = computedStyle;
1021
- }
1022
- currentNode = getParentNode(currentNode);
1023
- }
1024
- cache.set(element, result);
1025
- return result;
1026
- }
1027
-
1028
- // Gets the maximum area that the element is visible in due to any number of
1029
- // clipping ancestors.
1030
- function getClippingRect(_ref) {
1031
- let {
1032
- element,
1033
- boundary,
1034
- rootBoundary,
1035
- strategy
1036
- } = _ref;
1037
- const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1038
- const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1039
- const firstClippingAncestor = clippingAncestors[0];
1040
- const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1041
- const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1042
- accRect.top = max(rect.top, accRect.top);
1043
- accRect.right = min(rect.right, accRect.right);
1044
- accRect.bottom = min(rect.bottom, accRect.bottom);
1045
- accRect.left = max(rect.left, accRect.left);
1046
- return accRect;
1047
- }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1048
- return {
1049
- width: clippingRect.right - clippingRect.left,
1050
- height: clippingRect.bottom - clippingRect.top,
1051
- x: clippingRect.left,
1052
- y: clippingRect.top
1053
- };
1054
- }
1055
-
1056
- function getDimensions(element) {
1057
- const {
1058
- width,
1059
- height
1060
- } = getCssDimensions(element);
1061
- return {
1062
- width,
1063
- height
1064
- };
1065
- }
1066
-
1067
- function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1068
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
1069
- const documentElement = getDocumentElement(offsetParent);
1070
- const isFixed = strategy === 'fixed';
1071
- const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1072
- let scroll = {
1073
- scrollLeft: 0,
1074
- scrollTop: 0
1075
- };
1076
- const offsets = createCoords(0);
1077
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1078
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1079
- scroll = getNodeScroll(offsetParent);
1080
- }
1081
- if (isOffsetParentAnElement) {
1082
- const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1083
- offsets.x = offsetRect.x + offsetParent.clientLeft;
1084
- offsets.y = offsetRect.y + offsetParent.clientTop;
1085
- } else if (documentElement) {
1086
- // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
1087
- // Firefox with layout.scrollbar.side = 3 in about:config to test this.
1088
- offsets.x = getWindowScrollBarX(documentElement);
1089
- }
1090
- }
1091
- const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1092
- const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
1093
- const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
1094
- return {
1095
- x,
1096
- y,
1097
- width: rect.width,
1098
- height: rect.height
1099
- };
1100
- }
1101
-
1102
- function isStaticPositioned(element) {
1103
- return getComputedStyle(element).position === 'static';
1104
- }
1105
-
1106
- function getTrueOffsetParent(element, polyfill) {
1107
- if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
1108
- return null;
1109
- }
1110
- if (polyfill) {
1111
- return polyfill(element);
1112
- }
1113
- let rawOffsetParent = element.offsetParent;
1114
-
1115
- // Firefox returns the <html> element as the offsetParent if it's non-static,
1116
- // while Chrome and Safari return the <body> element. The <body> element must
1117
- // be used to perform the correct calculations even if the <html> element is
1118
- // non-static.
1119
- if (getDocumentElement(element) === rawOffsetParent) {
1120
- rawOffsetParent = rawOffsetParent.ownerDocument.body;
1121
- }
1122
- return rawOffsetParent;
1123
- }
1124
-
1125
- // Gets the closest ancestor positioned element. Handles some edge cases,
1126
- // such as table ancestors and cross browser bugs.
1127
- function getOffsetParent(element, polyfill) {
1128
- const win = getWindow(element);
1129
- if (isTopLayer(element)) {
1130
- return win;
1131
- }
1132
- if (!isHTMLElement(element)) {
1133
- let svgOffsetParent = getParentNode(element);
1134
- while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
1135
- if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
1136
- return svgOffsetParent;
1137
- }
1138
- svgOffsetParent = getParentNode(svgOffsetParent);
1139
- }
1140
- return win;
1141
- }
1142
- let offsetParent = getTrueOffsetParent(element, polyfill);
1143
- while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
1144
- offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1145
- }
1146
- if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
1147
- return win;
1148
- }
1149
- return offsetParent || getContainingBlock(element) || win;
1150
- }
1151
-
1152
- const getElementRects = async function (data) {
1153
- const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1154
- const getDimensionsFn = this.getDimensions;
1155
- const floatingDimensions = await getDimensionsFn(data.floating);
1156
- return {
1157
- reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1158
- floating: {
1159
- x: 0,
1160
- y: 0,
1161
- width: floatingDimensions.width,
1162
- height: floatingDimensions.height
1163
- }
1164
- };
1165
- };
1166
-
1167
- function isRTL(element) {
1168
- return getComputedStyle(element).direction === 'rtl';
1169
- }
1170
-
1171
- const platform = {
1172
- convertOffsetParentRelativeRectToViewportRelativeRect,
1173
- getDocumentElement,
1174
- getClippingRect,
1175
- getOffsetParent,
1176
- getElementRects,
1177
- getClientRects,
1178
- getDimensions,
1179
- getScale,
1180
- isElement,
1181
- isRTL
1182
- };
1183
-
1184
- /**
1185
- * Optimizes the visibility of the floating element by shifting it in order to
1186
- * keep it in view when it will overflow the clipping boundary.
1187
- * @see https://floating-ui.com/docs/shift
1188
- */
1189
- const shift = shift$1;
1190
-
1191
- /**
1192
- * Optimizes the visibility of the floating element by flipping the `placement`
1193
- * in order to keep it in view when the preferred placement(s) will overflow the
1194
- * clipping boundary. Alternative to `autoPlacement`.
1195
- * @see https://floating-ui.com/docs/flip
1196
- */
1197
- const flip = flip$1;
1198
-
1199
- /**
1200
- * Computes the `x` and `y` coordinates that will place the floating element
1201
- * next to a given reference element.
1202
- */
1203
- const computePosition = (reference, floating, options) => {
1204
- // This caches the expensive `getClippingElementAncestors` function so that
1205
- // multiple lifecycle resets re-use the same result. It only lives for a
1206
- // single call. If other functions become expensive, we can add them as well.
1207
- const cache = new Map();
1208
- const mergedOptions = {
1209
- platform,
1210
- ...options
1211
- };
1212
- const platformWithCache = {
1213
- ...mergedOptions.platform,
1214
- _c: cache
1215
- };
1216
- return computePosition$1(reference, floating, {
1217
- ...mergedOptions,
1218
- platform: platformWithCache
1219
- });
1220
- };
1221
-
1222
- const ezPopoverCoreCss = ":host{--ez-popover__box--border-radius:var(--border--radius-medium, 12px);--ez-popover__box--box-shadow:var(--shadow, 0px 0px 16px 0px #000);--ez-popover__box--background-color:var(--background--xlight, #fff);--ez-popover__box--z-index:var(--most-visible, 4);position:relative;display:flex;user-select:none}.popover__overlay{display:none;position:fixed;padding:0;top:0px;left:0px;width:100%;height:100vh;box-sizing:border-box;z-index:var(--more-visible--2x, 3)}.popover__overlay--light{background-color:rgba(var(--rgb-background--overlay), var(--opacity--bright))}.popover__overlay--medium{background-color:rgba(var(--rgb-background--overlay), var(--opacity--soft));backdrop-filter:blur(var(--background-blur--medium))}.popover__box{display:none;position:fixed;top:0;left:0;z-index:var(--ez-popover__box--z-index);flex-direction:column;height:fit-content;background-color:var(--ez-popover__box--background-color);border-radius:var(--ez-popover__box--border-radius);box-shadow:var(--ez-popover__box--box-shadow)}.popover__box--fit-content{width:fit-content}.popover__box--full-width{width:calc(100% - 10px)}";
1223
-
1224
- const EzPopoverCore = class {
1225
- constructor(hostRef) {
1226
- index.registerInstance(this, hostRef);
1227
- this.ezVisibilityChange = index.createEvent(this, "ezVisibilityChange", 7);
1228
- this.TIME_DEBOUNCE = 500;
1229
- this.autoClose = true;
1230
- this.boxWidth = "fit-content";
1231
- this.opened = false;
1232
- this.overlayType = "light";
1233
- this.anchorElement = undefined;
1234
- this.options = { horizontalGap: 0, verticalGap: 0, fromRight: false };
1235
- }
1236
- async observeOpened(newValue, oldValue) {
1237
- if (newValue === oldValue)
1238
- return;
1239
- if (newValue) {
1240
- this.openPopover();
1241
- }
1242
- else {
1243
- this.hidePopover();
1244
- }
1245
- this.ezVisibilityChange.emit(newValue);
1246
- return;
1247
- }
1248
- /**
1249
- * Atualiza a posição do popover.
1250
- */
1251
- async updatePosition(top, left) {
1252
- this.updateOptionPosition(top, left);
1253
- await this.updatePositionPopover();
1254
- }
1255
- /**
1256
- * Exibe o ez-popover.
1257
- */
1258
- async show(top, left) {
1259
- this.updateOptionPosition(top, left);
1260
- this.opened = true;
1261
- }
1262
- /**
1263
- * Ancora a exibição do popOver a um elemento HTML.
1264
- */
1265
- async showUnder(element, options) {
1266
- if (options) {
1267
- this.options = options;
1268
- }
1269
- this.anchorElement = element;
1270
- this.opened = true;
1271
- }
1272
- /**
1273
- * Oculta o ez-popover.
1274
- */
1275
- async hide() {
1276
- this.opened = false;
1277
- }
1278
- /**
1279
- * Altera as opções.
1280
- */
1281
- async setOptions(options) {
1282
- Object.assign(this.options, options);
1283
- }
1284
- /**
1285
- * Altera o elemento de ancoragem.
1286
- */
1287
- async setAnchorElement(anchor) {
1288
- this.anchorElement = anchor;
1289
- }
1290
- parseSizePixel(sizePixel, defaultValue) {
1291
- if (!sizePixel) {
1292
- return defaultValue !== null && defaultValue !== void 0 ? defaultValue : 0;
1293
- }
1294
- if (typeof sizePixel === "string") {
1295
- return Number(sizePixel.replace("px", ""));
1296
- }
1297
- return sizePixel !== null && sizePixel !== void 0 ? sizePixel : 0;
1298
- }
1299
- updateOptionPosition(top, left) {
1300
- Object.assign(this.options, {
1301
- horizontalGap: this.parseSizePixel(left, this.options.horizontalGap),
1302
- verticalGap: this.parseSizePixel(top, this.options.verticalGap),
1303
- });
1304
- }
1305
- async updatePositionPopover() {
1306
- if (!this._box || !this.opened) {
1307
- return;
1308
- }
1309
- if (!this.anchorElement) {
1310
- this.anchorElement = this._host;
1311
- }
1312
- if (typeof this.anchorElement === 'string') {
1313
- this.anchorElement = document.getElementById(this.anchorElement);
1314
- }
1315
- await computePosition(this.anchorElement, this._box, {
1316
- placement: this.options.fromRight ? 'bottom-end' : 'bottom-start',
1317
- middleware: [flip(), shift({ padding: 5 })],
1318
- strategy: 'fixed',
1319
- }).then(({ x, y, placement }) => {
1320
- const newTop = placement.includes("bottom") ? y + this.options.verticalGap : y - this.options.verticalGap;
1321
- const newLeft = placement.includes("start") ? x + this.options.horizontalGap : x - this.options.horizontalGap;
1322
- Object.assign(this._box.style, {
1323
- top: `${newTop}px`,
1324
- left: `${newLeft}px`,
1325
- });
1326
- });
1327
- }
1328
- hidePopover() {
1329
- if (!this._box) {
1330
- return;
1331
- }
1332
- this._box.style.display = '';
1333
- this.hideOverlay();
1334
- this.ezVisibilityChange.emit(false);
1335
- }
1336
- async openPopover() {
1337
- if (!this._box) {
1338
- return;
1339
- }
1340
- if (this.opened) {
1341
- this._box.style.display = 'flex';
1342
- this._box.style.visibility = 'hidden';
1343
- await this.updatePositionPopover();
1344
- this.openOverlay();
1345
- this.ezVisibilityChange.emit(true);
1346
- this._box.style.visibility = 'visible';
1347
- }
1348
- }
1349
- openOverlay() {
1350
- if (!this._overlay || !this._overlayIsActive) {
1351
- return;
1352
- }
1353
- this._overlay.style.display = 'block';
1354
- }
1355
- hideOverlay() {
1356
- if (!this._overlay) {
1357
- return;
1358
- }
1359
- this._overlay.style.display = 'none';
1360
- }
1361
- checkStatusOverlay() {
1362
- if (this.overlayType !== "none") {
1363
- return true;
1364
- }
1365
- if (this.overlayType === "none" && this.autoClose) {
1366
- return true;
1367
- }
1368
- return false;
1369
- }
1370
- updatePositionDebounce() {
1371
- if (!this.opened) {
1372
- return;
1373
- }
1374
- clearTimeout(this._timeoutDebounce);
1375
- this._timeoutDebounce = setTimeout(() => {
1376
- this.updatePositionPopover();
1377
- }, this.TIME_DEBOUNCE);
1378
- }
1379
- componentWillLoad() {
1380
- window.addEventListener('scroll', this.updatePositionDebounce.bind(this), true);
1381
- window.addEventListener('resize', this.updatePositionDebounce.bind(this), true);
1382
- }
1383
- componentDidLoad() {
1384
- this._overlayIsActive = this.checkStatusOverlay();
1385
- this._resizeObserver = new ResizeObserver(this.updatePositionPopover.bind(this));
1386
- this._resizeObserver.observe(this._box);
1387
- this.openPopover();
1388
- }
1389
- disconnectedCallback() {
1390
- window.removeEventListener('scroll', this.updatePositionDebounce.bind(this), true);
1391
- window.removeEventListener('resize', this.updatePositionDebounce.bind(this), true);
1392
- this._resizeObserver.disconnect();
1393
- }
1394
- render() {
1395
- return (index.h(index.Host, null, index.h("div", { ref: el => this._overlay = el, onClick: () => this.hide(), class: `popover__overlay popover__overlay--${this.overlayType}` }), index.h("section", { ref: el => this._box = el, class: {
1396
- "popover__box": true,
1397
- "popover__box--fit-content": this.boxWidth === "fit-content",
1398
- "popover__box--full-width": this.boxWidth !== "fit-content",
1399
- } }, index.h("slot", null))));
1400
- }
1401
- get _host() { return index.getElement(this); }
1402
- static get watchers() { return {
1403
- "opened": ["observeOpened"]
1404
- }; }
1405
- };
1406
- EzPopoverCore.style = ezPopoverCoreCss;
1407
-
1408
- const ezPopoverPlusCss = ":host{display:none}";
1409
-
1410
- const EzPopoverPlus = class {
1411
- constructor(hostRef) {
1412
- index.registerInstance(this, hostRef);
1413
- this.ezVisibilityChange = index.createEvent(this, "ezVisibilityChange", 7);
1414
- this.autoClose = true;
1415
- this.boxWidth = "fit-content";
1416
- this.opened = false;
1417
- this.overlayType = "light";
1418
- this.anchorElement = undefined;
1419
- this.options = { horizontalGap: 0, verticalGap: 0, fromRight: false };
1420
- }
1421
- listenerEzVisibilityChange({ detail }) {
1422
- this.ezVisibilityChange.emit(detail);
1423
- }
1424
- async observeOpened(newValue) {
1425
- if (newValue && !this._popOverCore) {
1426
- this.renderPopoverCore();
1427
- }
1428
- this._popOverCore.opened = newValue;
1429
- }
1430
- /**
1431
- * Atualiza a posição do popover.
1432
- */
1433
- async updatePosition(top, left) {
1434
- var _a;
1435
- await ((_a = this._popOverCore) === null || _a === void 0 ? void 0 : _a.updatePosition(top, left));
1436
- }
1437
- /**
1438
- * Exibe o ez-popover.
1439
- */
1440
- async show(top, left) {
1441
- if (!this._popOverCore) {
1442
- this.renderPopoverCore();
1443
- }
1444
- await this._popOverCore.show(top, left);
1445
- }
1446
- /**
1447
- * Ancora a exibição do popOver a um elemento HTML.
1448
- */
1449
- async showUnder(element, options) {
1450
- if (!this._popOverCore) {
1451
- this.renderPopoverCore();
1452
- }
1453
- await this._popOverCore.showUnder(element, options);
1454
- }
1455
- /**
1456
- * Oculta o ez-popover.
1457
- */
1458
- async hide() {
1459
- var _a;
1460
- await ((_a = this._popOverCore) === null || _a === void 0 ? void 0 : _a.hide());
1461
- }
1462
- /**
1463
- * Altera as opções.
1464
- */
1465
- async setOptions(options) {
1466
- var _a;
1467
- await ((_a = this._popOverCore) === null || _a === void 0 ? void 0 : _a.setOptions(options));
1468
- }
1469
- /**
1470
- * Altera o elemento de ancoragem.
1471
- */
1472
- async setAnchorElement(anchor) {
1473
- var _a;
1474
- await ((_a = this._popOverCore) === null || _a === void 0 ? void 0 : _a.setAnchorElement(anchor));
1475
- }
1476
- renderPopoverCore() {
1477
- this._popOverCore = document.createElement('ez-popover-core');
1478
- this._popOverCore.opened = this.opened;
1479
- this._popOverCore.anchorElement = this.anchorElement;
1480
- this._popOverCore.autoClose = this.autoClose;
1481
- this._popOverCore.boxWidth = this.boxWidth;
1482
- this._popOverCore.overlayType = this.overlayType;
1483
- this._popOverCore.options = this.options;
1484
- const firstChild = this._host.children.item(0);
1485
- if (firstChild) {
1486
- this._popOverCore.appendChild(firstChild);
1487
- }
1488
- else {
1489
- console.warn('O slot do popover está vazio. Adicione conteúdo ao slot para exibição correta.');
1490
- }
1491
- document.body.appendChild(this._popOverCore);
1492
- }
1493
- render() {
1494
- return (index.h(index.Host, null, index.h("slot", null)));
1495
- }
1496
- get _host() { return index.getElement(this); }
1497
- static get watchers() { return {
1498
- "opened": ["observeOpened"]
1499
- }; }
1500
- };
1501
- EzPopoverPlus.style = ezPopoverPlusCss;
1502
-
1503
- exports.ez_popover_core = EzPopoverCore;
1504
- exports.ez_popover_plus = EzPopoverPlus;