@sankhyalabs/ezui 5.22.0-dev.95 → 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 (61) 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-combo-box-list_3.cjs.entry.js +32 -11
  4. package/dist/cjs/ez-popover-plus_3.cjs.entry.js +198 -0
  5. package/dist/cjs/ez-scroller_2.cjs.entry.js +1 -1
  6. package/dist/cjs/ez-search.cjs.entry.js +28 -158
  7. package/dist/cjs/ezui.cjs.js +1 -1
  8. package/dist/cjs/index-a7b0c73d.js +4 -4
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/cjs/searchFormatters-b7e1ed1e.js +23 -0
  11. package/dist/collection/collection-manifest.json +2 -1
  12. package/dist/collection/components/ez-card-item/ez-card-item.css +1 -3
  13. package/dist/collection/components/ez-chip/ez-chip.css +5 -1
  14. package/dist/collection/components/ez-combo-box/ez-combo-box-list/ez-combo-box-list.js +33 -12
  15. package/dist/collection/components/ez-popover-plus/ez-popover-plus.js +49 -2
  16. package/dist/collection/components/ez-popover-plus/subcomponent/ez-popover-core.css +2 -2
  17. package/dist/collection/components/ez-popover-plus/subcomponent/ez-popover-core.js +72 -12
  18. package/dist/collection/components/ez-scroller/ez-scroller.css +3 -0
  19. package/dist/collection/components/ez-search/ez-search.css +0 -219
  20. package/dist/collection/components/ez-search/ez-search.js +28 -167
  21. package/dist/collection/components/ez-search/subcomponent/search-list/search-list.css +227 -0
  22. package/dist/collection/components/ez-search/subcomponent/search-list/search-list.js +289 -0
  23. package/dist/collection/components/ez-search/utils/searchFormatters.js +18 -0
  24. package/dist/custom-elements/index.d.ts +6 -0
  25. package/dist/custom-elements/index.js +201 -188
  26. package/dist/esm/ez-card-item_2.entry.js +1416 -7
  27. package/dist/esm/ez-chip.entry.js +1 -1
  28. package/dist/esm/ez-combo-box-list_3.entry.js +32 -11
  29. package/dist/esm/ez-popover-plus_3.entry.js +192 -0
  30. package/dist/esm/ez-scroller_2.entry.js +1 -1
  31. package/dist/esm/ez-search.entry.js +29 -159
  32. package/dist/esm/ezui.js +1 -1
  33. package/dist/esm/index-baa5e267.js +4 -4
  34. package/dist/esm/loader.js +1 -1
  35. package/dist/esm/searchFormatters-8229207e.js +20 -0
  36. package/dist/ezui/ezui.esm.js +1 -1
  37. package/dist/ezui/p-288631d1.entry.js +1 -0
  38. package/dist/ezui/p-31da1b57.entry.js +1 -0
  39. package/dist/ezui/p-40a60148.js +1 -0
  40. package/dist/ezui/p-5aca7386.entry.js +1 -0
  41. package/dist/ezui/p-b7706b43.entry.js +1 -0
  42. package/dist/ezui/p-c297aa52.entry.js +1 -0
  43. package/dist/ezui/{p-17be134a.entry.js → p-e06a9886.entry.js} +1 -1
  44. package/dist/types/components/ez-combo-box/ez-combo-box-list/ez-combo-box-list.d.ts +1 -1
  45. package/dist/types/components/ez-popover-plus/ez-popover-plus.d.ts +9 -1
  46. package/dist/types/components/ez-popover-plus/subcomponent/ez-popover-core.d.ts +12 -2
  47. package/dist/types/components/ez-search/ez-search.d.ts +3 -13
  48. package/dist/types/components/ez-search/subcomponent/search-list/search-list.d.ts +23 -0
  49. package/dist/types/components/ez-search/utils/searchFormatters.d.ts +2 -0
  50. package/dist/types/components.d.ts +73 -5
  51. package/package.json +1 -1
  52. package/react/components.d.ts +1 -0
  53. package/react/components.js +1 -0
  54. package/react/components.js.map +1 -1
  55. package/dist/cjs/ez-popover-core_2.cjs.entry.js +0 -1504
  56. package/dist/esm/ez-popover-core_2.entry.js +0 -1499
  57. package/dist/ezui/p-15134d97.entry.js +0 -1
  58. package/dist/ezui/p-58783dcf.entry.js +0 -1
  59. package/dist/ezui/p-65f471bc.entry.js +0 -1
  60. package/dist/ezui/p-7bd15498.entry.js +0 -1
  61. package/dist/ezui/p-990b4318.entry.js +0 -1
@@ -1,1499 +0,0 @@
1
- import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-baa5e267.js';
2
-
3
- /**
4
- * Custom positioning reference element.
5
- * @see https://floating-ui.com/docs/virtual-elements
6
- */
7
- const min = Math.min;
8
- const max = Math.max;
9
- const round = Math.round;
10
- const createCoords = v => ({
11
- x: v,
12
- y: v
13
- });
14
- const oppositeSideMap = {
15
- left: 'right',
16
- right: 'left',
17
- bottom: 'top',
18
- top: 'bottom'
19
- };
20
- const oppositeAlignmentMap = {
21
- start: 'end',
22
- end: 'start'
23
- };
24
- function clamp(start, value, end) {
25
- return max(start, min(value, end));
26
- }
27
- function evaluate(value, param) {
28
- return typeof value === 'function' ? value(param) : value;
29
- }
30
- function getSide(placement) {
31
- return placement.split('-')[0];
32
- }
33
- function getAlignment(placement) {
34
- return placement.split('-')[1];
35
- }
36
- function getOppositeAxis(axis) {
37
- return axis === 'x' ? 'y' : 'x';
38
- }
39
- function getAxisLength(axis) {
40
- return axis === 'y' ? 'height' : 'width';
41
- }
42
- function getSideAxis(placement) {
43
- return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
44
- }
45
- function getAlignmentAxis(placement) {
46
- return getOppositeAxis(getSideAxis(placement));
47
- }
48
- function getAlignmentSides(placement, rects, rtl) {
49
- if (rtl === void 0) {
50
- rtl = false;
51
- }
52
- const alignment = getAlignment(placement);
53
- const alignmentAxis = getAlignmentAxis(placement);
54
- const length = getAxisLength(alignmentAxis);
55
- let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
56
- if (rects.reference[length] > rects.floating[length]) {
57
- mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
58
- }
59
- return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
60
- }
61
- function getExpandedPlacements(placement) {
62
- const oppositePlacement = getOppositePlacement(placement);
63
- return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
64
- }
65
- function getOppositeAlignmentPlacement(placement) {
66
- return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
67
- }
68
- function getSideList(side, isStart, rtl) {
69
- const lr = ['left', 'right'];
70
- const rl = ['right', 'left'];
71
- const tb = ['top', 'bottom'];
72
- const bt = ['bottom', 'top'];
73
- switch (side) {
74
- case 'top':
75
- case 'bottom':
76
- if (rtl) return isStart ? rl : lr;
77
- return isStart ? lr : rl;
78
- case 'left':
79
- case 'right':
80
- return isStart ? tb : bt;
81
- default:
82
- return [];
83
- }
84
- }
85
- function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
86
- const alignment = getAlignment(placement);
87
- let list = getSideList(getSide(placement), direction === 'start', rtl);
88
- if (alignment) {
89
- list = list.map(side => side + "-" + alignment);
90
- if (flipAlignment) {
91
- list = list.concat(list.map(getOppositeAlignmentPlacement));
92
- }
93
- }
94
- return list;
95
- }
96
- function getOppositePlacement(placement) {
97
- return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
98
- }
99
- function expandPaddingObject(padding) {
100
- return {
101
- top: 0,
102
- right: 0,
103
- bottom: 0,
104
- left: 0,
105
- ...padding
106
- };
107
- }
108
- function getPaddingObject(padding) {
109
- return typeof padding !== 'number' ? expandPaddingObject(padding) : {
110
- top: padding,
111
- right: padding,
112
- bottom: padding,
113
- left: padding
114
- };
115
- }
116
- function rectToClientRect(rect) {
117
- const {
118
- x,
119
- y,
120
- width,
121
- height
122
- } = rect;
123
- return {
124
- width,
125
- height,
126
- top: y,
127
- left: x,
128
- right: x + width,
129
- bottom: y + height,
130
- x,
131
- y
132
- };
133
- }
134
-
135
- function computeCoordsFromPlacement(_ref, placement, rtl) {
136
- let {
137
- reference,
138
- floating
139
- } = _ref;
140
- const sideAxis = getSideAxis(placement);
141
- const alignmentAxis = getAlignmentAxis(placement);
142
- const alignLength = getAxisLength(alignmentAxis);
143
- const side = getSide(placement);
144
- const isVertical = sideAxis === 'y';
145
- const commonX = reference.x + reference.width / 2 - floating.width / 2;
146
- const commonY = reference.y + reference.height / 2 - floating.height / 2;
147
- const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
148
- let coords;
149
- switch (side) {
150
- case 'top':
151
- coords = {
152
- x: commonX,
153
- y: reference.y - floating.height
154
- };
155
- break;
156
- case 'bottom':
157
- coords = {
158
- x: commonX,
159
- y: reference.y + reference.height
160
- };
161
- break;
162
- case 'right':
163
- coords = {
164
- x: reference.x + reference.width,
165
- y: commonY
166
- };
167
- break;
168
- case 'left':
169
- coords = {
170
- x: reference.x - floating.width,
171
- y: commonY
172
- };
173
- break;
174
- default:
175
- coords = {
176
- x: reference.x,
177
- y: reference.y
178
- };
179
- }
180
- switch (getAlignment(placement)) {
181
- case 'start':
182
- coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
183
- break;
184
- case 'end':
185
- coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
186
- break;
187
- }
188
- return coords;
189
- }
190
-
191
- /**
192
- * Computes the `x` and `y` coordinates that will place the floating element
193
- * next to a given reference element.
194
- *
195
- * This export does not have any `platform` interface logic. You will need to
196
- * write one for the platform you are using Floating UI with.
197
- */
198
- const computePosition$1 = async (reference, floating, config) => {
199
- const {
200
- placement = 'bottom',
201
- strategy = 'absolute',
202
- middleware = [],
203
- platform
204
- } = config;
205
- const validMiddleware = middleware.filter(Boolean);
206
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
207
- let rects = await platform.getElementRects({
208
- reference,
209
- floating,
210
- strategy
211
- });
212
- let {
213
- x,
214
- y
215
- } = computeCoordsFromPlacement(rects, placement, rtl);
216
- let statefulPlacement = placement;
217
- let middlewareData = {};
218
- let resetCount = 0;
219
- for (let i = 0; i < validMiddleware.length; i++) {
220
- const {
221
- name,
222
- fn
223
- } = validMiddleware[i];
224
- const {
225
- x: nextX,
226
- y: nextY,
227
- data,
228
- reset
229
- } = await fn({
230
- x,
231
- y,
232
- initialPlacement: placement,
233
- placement: statefulPlacement,
234
- strategy,
235
- middlewareData,
236
- rects,
237
- platform,
238
- elements: {
239
- reference,
240
- floating
241
- }
242
- });
243
- x = nextX != null ? nextX : x;
244
- y = nextY != null ? nextY : y;
245
- middlewareData = {
246
- ...middlewareData,
247
- [name]: {
248
- ...middlewareData[name],
249
- ...data
250
- }
251
- };
252
- if (reset && resetCount <= 50) {
253
- resetCount++;
254
- if (typeof reset === 'object') {
255
- if (reset.placement) {
256
- statefulPlacement = reset.placement;
257
- }
258
- if (reset.rects) {
259
- rects = reset.rects === true ? await platform.getElementRects({
260
- reference,
261
- floating,
262
- strategy
263
- }) : reset.rects;
264
- }
265
- ({
266
- x,
267
- y
268
- } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
269
- }
270
- i = -1;
271
- }
272
- }
273
- return {
274
- x,
275
- y,
276
- placement: statefulPlacement,
277
- strategy,
278
- middlewareData
279
- };
280
- };
281
-
282
- /**
283
- * Resolves with an object of overflow side offsets that determine how much the
284
- * element is overflowing a given clipping boundary on each side.
285
- * - positive = overflowing the boundary by that number of pixels
286
- * - negative = how many pixels left before it will overflow
287
- * - 0 = lies flush with the boundary
288
- * @see https://floating-ui.com/docs/detectOverflow
289
- */
290
- async function detectOverflow(state, options) {
291
- var _await$platform$isEle;
292
- if (options === void 0) {
293
- options = {};
294
- }
295
- const {
296
- x,
297
- y,
298
- platform,
299
- rects,
300
- elements,
301
- strategy
302
- } = state;
303
- const {
304
- boundary = 'clippingAncestors',
305
- rootBoundary = 'viewport',
306
- elementContext = 'floating',
307
- altBoundary = false,
308
- padding = 0
309
- } = evaluate(options, state);
310
- const paddingObject = getPaddingObject(padding);
311
- const altContext = elementContext === 'floating' ? 'reference' : 'floating';
312
- const element = elements[altBoundary ? altContext : elementContext];
313
- const clippingClientRect = rectToClientRect(await platform.getClippingRect({
314
- 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))),
315
- boundary,
316
- rootBoundary,
317
- strategy
318
- }));
319
- const rect = elementContext === 'floating' ? {
320
- x,
321
- y,
322
- width: rects.floating.width,
323
- height: rects.floating.height
324
- } : rects.reference;
325
- const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
326
- const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
327
- x: 1,
328
- y: 1
329
- } : {
330
- x: 1,
331
- y: 1
332
- };
333
- const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
334
- elements,
335
- rect,
336
- offsetParent,
337
- strategy
338
- }) : rect);
339
- return {
340
- top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
341
- bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
342
- left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
343
- right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
344
- };
345
- }
346
-
347
- /**
348
- * Optimizes the visibility of the floating element by flipping the `placement`
349
- * in order to keep it in view when the preferred placement(s) will overflow the
350
- * clipping boundary. Alternative to `autoPlacement`.
351
- * @see https://floating-ui.com/docs/flip
352
- */
353
- const flip$1 = function (options) {
354
- if (options === void 0) {
355
- options = {};
356
- }
357
- return {
358
- name: 'flip',
359
- options,
360
- async fn(state) {
361
- var _middlewareData$arrow, _middlewareData$flip;
362
- const {
363
- placement,
364
- middlewareData,
365
- rects,
366
- initialPlacement,
367
- platform,
368
- elements
369
- } = state;
370
- const {
371
- mainAxis: checkMainAxis = true,
372
- crossAxis: checkCrossAxis = true,
373
- fallbackPlacements: specifiedFallbackPlacements,
374
- fallbackStrategy = 'bestFit',
375
- fallbackAxisSideDirection = 'none',
376
- flipAlignment = true,
377
- ...detectOverflowOptions
378
- } = evaluate(options, state);
379
-
380
- // If a reset by the arrow was caused due to an alignment offset being
381
- // added, we should skip any logic now since `flip()` has already done its
382
- // work.
383
- // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
384
- if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
385
- return {};
386
- }
387
- const side = getSide(placement);
388
- const initialSideAxis = getSideAxis(initialPlacement);
389
- const isBasePlacement = getSide(initialPlacement) === initialPlacement;
390
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
391
- const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
392
- const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
393
- if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
394
- fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
395
- }
396
- const placements = [initialPlacement, ...fallbackPlacements];
397
- const overflow = await detectOverflow(state, detectOverflowOptions);
398
- const overflows = [];
399
- let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
400
- if (checkMainAxis) {
401
- overflows.push(overflow[side]);
402
- }
403
- if (checkCrossAxis) {
404
- const sides = getAlignmentSides(placement, rects, rtl);
405
- overflows.push(overflow[sides[0]], overflow[sides[1]]);
406
- }
407
- overflowsData = [...overflowsData, {
408
- placement,
409
- overflows
410
- }];
411
-
412
- // One or more sides is overflowing.
413
- if (!overflows.every(side => side <= 0)) {
414
- var _middlewareData$flip2, _overflowsData$filter;
415
- const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
416
- const nextPlacement = placements[nextIndex];
417
- if (nextPlacement) {
418
- // Try next placement and re-run the lifecycle.
419
- return {
420
- data: {
421
- index: nextIndex,
422
- overflows: overflowsData
423
- },
424
- reset: {
425
- placement: nextPlacement
426
- }
427
- };
428
- }
429
-
430
- // First, find the candidates that fit on the mainAxis side of overflow,
431
- // then find the placement that fits the best on the main crossAxis side.
432
- 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;
433
-
434
- // Otherwise fallback.
435
- if (!resetPlacement) {
436
- switch (fallbackStrategy) {
437
- case 'bestFit':
438
- {
439
- var _overflowsData$filter2;
440
- const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
441
- if (hasFallbackAxisSideDirection) {
442
- const currentSideAxis = getSideAxis(d.placement);
443
- return currentSideAxis === initialSideAxis ||
444
- // Create a bias to the `y` side axis due to horizontal
445
- // reading directions favoring greater width.
446
- currentSideAxis === 'y';
447
- }
448
- return true;
449
- }).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];
450
- if (placement) {
451
- resetPlacement = placement;
452
- }
453
- break;
454
- }
455
- case 'initialPlacement':
456
- resetPlacement = initialPlacement;
457
- break;
458
- }
459
- }
460
- if (placement !== resetPlacement) {
461
- return {
462
- reset: {
463
- placement: resetPlacement
464
- }
465
- };
466
- }
467
- }
468
- return {};
469
- }
470
- };
471
- };
472
-
473
- /**
474
- * Optimizes the visibility of the floating element by shifting it in order to
475
- * keep it in view when it will overflow the clipping boundary.
476
- * @see https://floating-ui.com/docs/shift
477
- */
478
- const shift$1 = function (options) {
479
- if (options === void 0) {
480
- options = {};
481
- }
482
- return {
483
- name: 'shift',
484
- options,
485
- async fn(state) {
486
- const {
487
- x,
488
- y,
489
- placement
490
- } = state;
491
- const {
492
- mainAxis: checkMainAxis = true,
493
- crossAxis: checkCrossAxis = false,
494
- limiter = {
495
- fn: _ref => {
496
- let {
497
- x,
498
- y
499
- } = _ref;
500
- return {
501
- x,
502
- y
503
- };
504
- }
505
- },
506
- ...detectOverflowOptions
507
- } = evaluate(options, state);
508
- const coords = {
509
- x,
510
- y
511
- };
512
- const overflow = await detectOverflow(state, detectOverflowOptions);
513
- const crossAxis = getSideAxis(getSide(placement));
514
- const mainAxis = getOppositeAxis(crossAxis);
515
- let mainAxisCoord = coords[mainAxis];
516
- let crossAxisCoord = coords[crossAxis];
517
- if (checkMainAxis) {
518
- const minSide = mainAxis === 'y' ? 'top' : 'left';
519
- const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
520
- const min = mainAxisCoord + overflow[minSide];
521
- const max = mainAxisCoord - overflow[maxSide];
522
- mainAxisCoord = clamp(min, mainAxisCoord, max);
523
- }
524
- if (checkCrossAxis) {
525
- const minSide = crossAxis === 'y' ? 'top' : 'left';
526
- const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
527
- const min = crossAxisCoord + overflow[minSide];
528
- const max = crossAxisCoord - overflow[maxSide];
529
- crossAxisCoord = clamp(min, crossAxisCoord, max);
530
- }
531
- const limitedCoords = limiter.fn({
532
- ...state,
533
- [mainAxis]: mainAxisCoord,
534
- [crossAxis]: crossAxisCoord
535
- });
536
- return {
537
- ...limitedCoords,
538
- data: {
539
- x: limitedCoords.x - x,
540
- y: limitedCoords.y - y,
541
- enabled: {
542
- [mainAxis]: checkMainAxis,
543
- [crossAxis]: checkCrossAxis
544
- }
545
- }
546
- };
547
- }
548
- };
549
- };
550
-
551
- function hasWindow() {
552
- return typeof window !== 'undefined';
553
- }
554
- function getNodeName(node) {
555
- if (isNode(node)) {
556
- return (node.nodeName || '').toLowerCase();
557
- }
558
- // Mocked nodes in testing environments may not be instances of Node. By
559
- // returning `#document` an infinite loop won't occur.
560
- // https://github.com/floating-ui/floating-ui/issues/2317
561
- return '#document';
562
- }
563
- function getWindow(node) {
564
- var _node$ownerDocument;
565
- return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
566
- }
567
- function getDocumentElement(node) {
568
- var _ref;
569
- return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
570
- }
571
- function isNode(value) {
572
- if (!hasWindow()) {
573
- return false;
574
- }
575
- return value instanceof Node || value instanceof getWindow(value).Node;
576
- }
577
- function isElement(value) {
578
- if (!hasWindow()) {
579
- return false;
580
- }
581
- return value instanceof Element || value instanceof getWindow(value).Element;
582
- }
583
- function isHTMLElement(value) {
584
- if (!hasWindow()) {
585
- return false;
586
- }
587
- return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
588
- }
589
- function isShadowRoot(value) {
590
- if (!hasWindow() || typeof ShadowRoot === 'undefined') {
591
- return false;
592
- }
593
- return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
594
- }
595
- function isOverflowElement(element) {
596
- const {
597
- overflow,
598
- overflowX,
599
- overflowY,
600
- display
601
- } = getComputedStyle(element);
602
- return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
603
- }
604
- function isTableElement(element) {
605
- return ['table', 'td', 'th'].includes(getNodeName(element));
606
- }
607
- function isTopLayer(element) {
608
- return [':popover-open', ':modal'].some(selector => {
609
- try {
610
- return element.matches(selector);
611
- } catch (e) {
612
- return false;
613
- }
614
- });
615
- }
616
- function isContainingBlock(elementOrCss) {
617
- const webkit = isWebKit();
618
- const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
619
-
620
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
621
- // https://drafts.csswg.org/css-transforms-2/#individual-transforms
622
- 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));
623
- }
624
- function getContainingBlock(element) {
625
- let currentNode = getParentNode(element);
626
- while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
627
- if (isContainingBlock(currentNode)) {
628
- return currentNode;
629
- } else if (isTopLayer(currentNode)) {
630
- return null;
631
- }
632
- currentNode = getParentNode(currentNode);
633
- }
634
- return null;
635
- }
636
- function isWebKit() {
637
- if (typeof CSS === 'undefined' || !CSS.supports) return false;
638
- return CSS.supports('-webkit-backdrop-filter', 'none');
639
- }
640
- function isLastTraversableNode(node) {
641
- return ['html', 'body', '#document'].includes(getNodeName(node));
642
- }
643
- function getComputedStyle(element) {
644
- return getWindow(element).getComputedStyle(element);
645
- }
646
- function getNodeScroll(element) {
647
- if (isElement(element)) {
648
- return {
649
- scrollLeft: element.scrollLeft,
650
- scrollTop: element.scrollTop
651
- };
652
- }
653
- return {
654
- scrollLeft: element.scrollX,
655
- scrollTop: element.scrollY
656
- };
657
- }
658
- function getParentNode(node) {
659
- if (getNodeName(node) === 'html') {
660
- return node;
661
- }
662
- const result =
663
- // Step into the shadow DOM of the parent of a slotted node.
664
- node.assignedSlot ||
665
- // DOM Element detected.
666
- node.parentNode ||
667
- // ShadowRoot detected.
668
- isShadowRoot(node) && node.host ||
669
- // Fallback.
670
- getDocumentElement(node);
671
- return isShadowRoot(result) ? result.host : result;
672
- }
673
- function getNearestOverflowAncestor(node) {
674
- const parentNode = getParentNode(node);
675
- if (isLastTraversableNode(parentNode)) {
676
- return node.ownerDocument ? node.ownerDocument.body : node.body;
677
- }
678
- if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
679
- return parentNode;
680
- }
681
- return getNearestOverflowAncestor(parentNode);
682
- }
683
- function getOverflowAncestors(node, list, traverseIframes) {
684
- var _node$ownerDocument2;
685
- if (list === void 0) {
686
- list = [];
687
- }
688
- if (traverseIframes === void 0) {
689
- traverseIframes = true;
690
- }
691
- const scrollableAncestor = getNearestOverflowAncestor(node);
692
- const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
693
- const win = getWindow(scrollableAncestor);
694
- if (isBody) {
695
- const frameElement = getFrameElement(win);
696
- return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
697
- }
698
- return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
699
- }
700
- function getFrameElement(win) {
701
- return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
702
- }
703
-
704
- function getCssDimensions(element) {
705
- const css = getComputedStyle(element);
706
- // In testing environments, the `width` and `height` properties are empty
707
- // strings for SVG elements, returning NaN. Fallback to `0` in this case.
708
- let width = parseFloat(css.width) || 0;
709
- let height = parseFloat(css.height) || 0;
710
- const hasOffset = isHTMLElement(element);
711
- const offsetWidth = hasOffset ? element.offsetWidth : width;
712
- const offsetHeight = hasOffset ? element.offsetHeight : height;
713
- const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
714
- if (shouldFallback) {
715
- width = offsetWidth;
716
- height = offsetHeight;
717
- }
718
- return {
719
- width,
720
- height,
721
- $: shouldFallback
722
- };
723
- }
724
-
725
- function unwrapElement(element) {
726
- return !isElement(element) ? element.contextElement : element;
727
- }
728
-
729
- function getScale(element) {
730
- const domElement = unwrapElement(element);
731
- if (!isHTMLElement(domElement)) {
732
- return createCoords(1);
733
- }
734
- const rect = domElement.getBoundingClientRect();
735
- const {
736
- width,
737
- height,
738
- $
739
- } = getCssDimensions(domElement);
740
- let x = ($ ? round(rect.width) : rect.width) / width;
741
- let y = ($ ? round(rect.height) : rect.height) / height;
742
-
743
- // 0, NaN, or Infinity should always fallback to 1.
744
-
745
- if (!x || !Number.isFinite(x)) {
746
- x = 1;
747
- }
748
- if (!y || !Number.isFinite(y)) {
749
- y = 1;
750
- }
751
- return {
752
- x,
753
- y
754
- };
755
- }
756
-
757
- const noOffsets = /*#__PURE__*/createCoords(0);
758
- function getVisualOffsets(element) {
759
- const win = getWindow(element);
760
- if (!isWebKit() || !win.visualViewport) {
761
- return noOffsets;
762
- }
763
- return {
764
- x: win.visualViewport.offsetLeft,
765
- y: win.visualViewport.offsetTop
766
- };
767
- }
768
- function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
769
- if (isFixed === void 0) {
770
- isFixed = false;
771
- }
772
- if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
773
- return false;
774
- }
775
- return isFixed;
776
- }
777
-
778
- function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
779
- if (includeScale === void 0) {
780
- includeScale = false;
781
- }
782
- if (isFixedStrategy === void 0) {
783
- isFixedStrategy = false;
784
- }
785
- const clientRect = element.getBoundingClientRect();
786
- const domElement = unwrapElement(element);
787
- let scale = createCoords(1);
788
- if (includeScale) {
789
- if (offsetParent) {
790
- if (isElement(offsetParent)) {
791
- scale = getScale(offsetParent);
792
- }
793
- } else {
794
- scale = getScale(element);
795
- }
796
- }
797
- const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
798
- let x = (clientRect.left + visualOffsets.x) / scale.x;
799
- let y = (clientRect.top + visualOffsets.y) / scale.y;
800
- let width = clientRect.width / scale.x;
801
- let height = clientRect.height / scale.y;
802
- if (domElement) {
803
- const win = getWindow(domElement);
804
- const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
805
- let currentWin = win;
806
- let currentIFrame = getFrameElement(currentWin);
807
- while (currentIFrame && offsetParent && offsetWin !== currentWin) {
808
- const iframeScale = getScale(currentIFrame);
809
- const iframeRect = currentIFrame.getBoundingClientRect();
810
- const css = getComputedStyle(currentIFrame);
811
- const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
812
- const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
813
- x *= iframeScale.x;
814
- y *= iframeScale.y;
815
- width *= iframeScale.x;
816
- height *= iframeScale.y;
817
- x += left;
818
- y += top;
819
- currentWin = getWindow(currentIFrame);
820
- currentIFrame = getFrameElement(currentWin);
821
- }
822
- }
823
- return rectToClientRect({
824
- width,
825
- height,
826
- x,
827
- y
828
- });
829
- }
830
-
831
- // If <html> has a CSS width greater than the viewport, then this will be
832
- // incorrect for RTL.
833
- function getWindowScrollBarX(element, rect) {
834
- const leftScroll = getNodeScroll(element).scrollLeft;
835
- if (!rect) {
836
- return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
837
- }
838
- return rect.left + leftScroll;
839
- }
840
-
841
- function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
842
- if (ignoreScrollbarX === void 0) {
843
- ignoreScrollbarX = false;
844
- }
845
- const htmlRect = documentElement.getBoundingClientRect();
846
- const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 :
847
- // RTL <body> scrollbar.
848
- getWindowScrollBarX(documentElement, htmlRect));
849
- const y = htmlRect.top + scroll.scrollTop;
850
- return {
851
- x,
852
- y
853
- };
854
- }
855
-
856
- function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
857
- let {
858
- elements,
859
- rect,
860
- offsetParent,
861
- strategy
862
- } = _ref;
863
- const isFixed = strategy === 'fixed';
864
- const documentElement = getDocumentElement(offsetParent);
865
- const topLayer = elements ? isTopLayer(elements.floating) : false;
866
- if (offsetParent === documentElement || topLayer && isFixed) {
867
- return rect;
868
- }
869
- let scroll = {
870
- scrollLeft: 0,
871
- scrollTop: 0
872
- };
873
- let scale = createCoords(1);
874
- const offsets = createCoords(0);
875
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
876
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
877
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
878
- scroll = getNodeScroll(offsetParent);
879
- }
880
- if (isHTMLElement(offsetParent)) {
881
- const offsetRect = getBoundingClientRect(offsetParent);
882
- scale = getScale(offsetParent);
883
- offsets.x = offsetRect.x + offsetParent.clientLeft;
884
- offsets.y = offsetRect.y + offsetParent.clientTop;
885
- }
886
- }
887
- const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
888
- return {
889
- width: rect.width * scale.x,
890
- height: rect.height * scale.y,
891
- x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
892
- y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
893
- };
894
- }
895
-
896
- function getClientRects(element) {
897
- return Array.from(element.getClientRects());
898
- }
899
-
900
- // Gets the entire size of the scrollable document area, even extending outside
901
- // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
902
- function getDocumentRect(element) {
903
- const html = getDocumentElement(element);
904
- const scroll = getNodeScroll(element);
905
- const body = element.ownerDocument.body;
906
- const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
907
- const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
908
- let x = -scroll.scrollLeft + getWindowScrollBarX(element);
909
- const y = -scroll.scrollTop;
910
- if (getComputedStyle(body).direction === 'rtl') {
911
- x += max(html.clientWidth, body.clientWidth) - width;
912
- }
913
- return {
914
- width,
915
- height,
916
- x,
917
- y
918
- };
919
- }
920
-
921
- function getViewportRect(element, strategy) {
922
- const win = getWindow(element);
923
- const html = getDocumentElement(element);
924
- const visualViewport = win.visualViewport;
925
- let width = html.clientWidth;
926
- let height = html.clientHeight;
927
- let x = 0;
928
- let y = 0;
929
- if (visualViewport) {
930
- width = visualViewport.width;
931
- height = visualViewport.height;
932
- const visualViewportBased = isWebKit();
933
- if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
934
- x = visualViewport.offsetLeft;
935
- y = visualViewport.offsetTop;
936
- }
937
- }
938
- return {
939
- width,
940
- height,
941
- x,
942
- y
943
- };
944
- }
945
-
946
- // Returns the inner client rect, subtracting scrollbars if present.
947
- function getInnerBoundingClientRect(element, strategy) {
948
- const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
949
- const top = clientRect.top + element.clientTop;
950
- const left = clientRect.left + element.clientLeft;
951
- const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
952
- const width = element.clientWidth * scale.x;
953
- const height = element.clientHeight * scale.y;
954
- const x = left * scale.x;
955
- const y = top * scale.y;
956
- return {
957
- width,
958
- height,
959
- x,
960
- y
961
- };
962
- }
963
- function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
964
- let rect;
965
- if (clippingAncestor === 'viewport') {
966
- rect = getViewportRect(element, strategy);
967
- } else if (clippingAncestor === 'document') {
968
- rect = getDocumentRect(getDocumentElement(element));
969
- } else if (isElement(clippingAncestor)) {
970
- rect = getInnerBoundingClientRect(clippingAncestor, strategy);
971
- } else {
972
- const visualOffsets = getVisualOffsets(element);
973
- rect = {
974
- x: clippingAncestor.x - visualOffsets.x,
975
- y: clippingAncestor.y - visualOffsets.y,
976
- width: clippingAncestor.width,
977
- height: clippingAncestor.height
978
- };
979
- }
980
- return rectToClientRect(rect);
981
- }
982
- function hasFixedPositionAncestor(element, stopNode) {
983
- const parentNode = getParentNode(element);
984
- if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
985
- return false;
986
- }
987
- return getComputedStyle(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
988
- }
989
-
990
- // A "clipping ancestor" is an `overflow` element with the characteristic of
991
- // clipping (or hiding) child elements. This returns all clipping ancestors
992
- // of the given element up the tree.
993
- function getClippingElementAncestors(element, cache) {
994
- const cachedResult = cache.get(element);
995
- if (cachedResult) {
996
- return cachedResult;
997
- }
998
- let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
999
- let currentContainingBlockComputedStyle = null;
1000
- const elementIsFixed = getComputedStyle(element).position === 'fixed';
1001
- let currentNode = elementIsFixed ? getParentNode(element) : element;
1002
-
1003
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1004
- while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1005
- const computedStyle = getComputedStyle(currentNode);
1006
- const currentNodeIsContaining = isContainingBlock(currentNode);
1007
- if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1008
- currentContainingBlockComputedStyle = null;
1009
- }
1010
- const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1011
- if (shouldDropCurrentNode) {
1012
- // Drop non-containing blocks.
1013
- result = result.filter(ancestor => ancestor !== currentNode);
1014
- } else {
1015
- // Record last containing block for next iteration.
1016
- currentContainingBlockComputedStyle = computedStyle;
1017
- }
1018
- currentNode = getParentNode(currentNode);
1019
- }
1020
- cache.set(element, result);
1021
- return result;
1022
- }
1023
-
1024
- // Gets the maximum area that the element is visible in due to any number of
1025
- // clipping ancestors.
1026
- function getClippingRect(_ref) {
1027
- let {
1028
- element,
1029
- boundary,
1030
- rootBoundary,
1031
- strategy
1032
- } = _ref;
1033
- const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1034
- const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1035
- const firstClippingAncestor = clippingAncestors[0];
1036
- const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1037
- const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1038
- accRect.top = max(rect.top, accRect.top);
1039
- accRect.right = min(rect.right, accRect.right);
1040
- accRect.bottom = min(rect.bottom, accRect.bottom);
1041
- accRect.left = max(rect.left, accRect.left);
1042
- return accRect;
1043
- }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1044
- return {
1045
- width: clippingRect.right - clippingRect.left,
1046
- height: clippingRect.bottom - clippingRect.top,
1047
- x: clippingRect.left,
1048
- y: clippingRect.top
1049
- };
1050
- }
1051
-
1052
- function getDimensions(element) {
1053
- const {
1054
- width,
1055
- height
1056
- } = getCssDimensions(element);
1057
- return {
1058
- width,
1059
- height
1060
- };
1061
- }
1062
-
1063
- function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1064
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
1065
- const documentElement = getDocumentElement(offsetParent);
1066
- const isFixed = strategy === 'fixed';
1067
- const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1068
- let scroll = {
1069
- scrollLeft: 0,
1070
- scrollTop: 0
1071
- };
1072
- const offsets = createCoords(0);
1073
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1074
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1075
- scroll = getNodeScroll(offsetParent);
1076
- }
1077
- if (isOffsetParentAnElement) {
1078
- const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1079
- offsets.x = offsetRect.x + offsetParent.clientLeft;
1080
- offsets.y = offsetRect.y + offsetParent.clientTop;
1081
- } else if (documentElement) {
1082
- // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
1083
- // Firefox with layout.scrollbar.side = 3 in about:config to test this.
1084
- offsets.x = getWindowScrollBarX(documentElement);
1085
- }
1086
- }
1087
- const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1088
- const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
1089
- const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
1090
- return {
1091
- x,
1092
- y,
1093
- width: rect.width,
1094
- height: rect.height
1095
- };
1096
- }
1097
-
1098
- function isStaticPositioned(element) {
1099
- return getComputedStyle(element).position === 'static';
1100
- }
1101
-
1102
- function getTrueOffsetParent(element, polyfill) {
1103
- if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
1104
- return null;
1105
- }
1106
- if (polyfill) {
1107
- return polyfill(element);
1108
- }
1109
- let rawOffsetParent = element.offsetParent;
1110
-
1111
- // Firefox returns the <html> element as the offsetParent if it's non-static,
1112
- // while Chrome and Safari return the <body> element. The <body> element must
1113
- // be used to perform the correct calculations even if the <html> element is
1114
- // non-static.
1115
- if (getDocumentElement(element) === rawOffsetParent) {
1116
- rawOffsetParent = rawOffsetParent.ownerDocument.body;
1117
- }
1118
- return rawOffsetParent;
1119
- }
1120
-
1121
- // Gets the closest ancestor positioned element. Handles some edge cases,
1122
- // such as table ancestors and cross browser bugs.
1123
- function getOffsetParent(element, polyfill) {
1124
- const win = getWindow(element);
1125
- if (isTopLayer(element)) {
1126
- return win;
1127
- }
1128
- if (!isHTMLElement(element)) {
1129
- let svgOffsetParent = getParentNode(element);
1130
- while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
1131
- if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
1132
- return svgOffsetParent;
1133
- }
1134
- svgOffsetParent = getParentNode(svgOffsetParent);
1135
- }
1136
- return win;
1137
- }
1138
- let offsetParent = getTrueOffsetParent(element, polyfill);
1139
- while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
1140
- offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1141
- }
1142
- if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
1143
- return win;
1144
- }
1145
- return offsetParent || getContainingBlock(element) || win;
1146
- }
1147
-
1148
- const getElementRects = async function (data) {
1149
- const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1150
- const getDimensionsFn = this.getDimensions;
1151
- const floatingDimensions = await getDimensionsFn(data.floating);
1152
- return {
1153
- reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1154
- floating: {
1155
- x: 0,
1156
- y: 0,
1157
- width: floatingDimensions.width,
1158
- height: floatingDimensions.height
1159
- }
1160
- };
1161
- };
1162
-
1163
- function isRTL(element) {
1164
- return getComputedStyle(element).direction === 'rtl';
1165
- }
1166
-
1167
- const platform = {
1168
- convertOffsetParentRelativeRectToViewportRelativeRect,
1169
- getDocumentElement,
1170
- getClippingRect,
1171
- getOffsetParent,
1172
- getElementRects,
1173
- getClientRects,
1174
- getDimensions,
1175
- getScale,
1176
- isElement,
1177
- isRTL
1178
- };
1179
-
1180
- /**
1181
- * Optimizes the visibility of the floating element by shifting it in order to
1182
- * keep it in view when it will overflow the clipping boundary.
1183
- * @see https://floating-ui.com/docs/shift
1184
- */
1185
- const shift = shift$1;
1186
-
1187
- /**
1188
- * Optimizes the visibility of the floating element by flipping the `placement`
1189
- * in order to keep it in view when the preferred placement(s) will overflow the
1190
- * clipping boundary. Alternative to `autoPlacement`.
1191
- * @see https://floating-ui.com/docs/flip
1192
- */
1193
- const flip = flip$1;
1194
-
1195
- /**
1196
- * Computes the `x` and `y` coordinates that will place the floating element
1197
- * next to a given reference element.
1198
- */
1199
- const computePosition = (reference, floating, options) => {
1200
- // This caches the expensive `getClippingElementAncestors` function so that
1201
- // multiple lifecycle resets re-use the same result. It only lives for a
1202
- // single call. If other functions become expensive, we can add them as well.
1203
- const cache = new Map();
1204
- const mergedOptions = {
1205
- platform,
1206
- ...options
1207
- };
1208
- const platformWithCache = {
1209
- ...mergedOptions.platform,
1210
- _c: cache
1211
- };
1212
- return computePosition$1(reference, floating, {
1213
- ...mergedOptions,
1214
- platform: platformWithCache
1215
- });
1216
- };
1217
-
1218
- 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)}";
1219
-
1220
- const EzPopoverCore = class {
1221
- constructor(hostRef) {
1222
- registerInstance(this, hostRef);
1223
- this.ezVisibilityChange = createEvent(this, "ezVisibilityChange", 7);
1224
- this.TIME_DEBOUNCE = 500;
1225
- this.autoClose = true;
1226
- this.boxWidth = "fit-content";
1227
- this.opened = false;
1228
- this.overlayType = "light";
1229
- this.anchorElement = undefined;
1230
- this.options = { horizontalGap: 0, verticalGap: 0, fromRight: false };
1231
- }
1232
- async observeOpened(newValue, oldValue) {
1233
- if (newValue === oldValue)
1234
- return;
1235
- if (newValue) {
1236
- this.openPopover();
1237
- }
1238
- else {
1239
- this.hidePopover();
1240
- }
1241
- this.ezVisibilityChange.emit(newValue);
1242
- return;
1243
- }
1244
- /**
1245
- * Atualiza a posição do popover.
1246
- */
1247
- async updatePosition(top, left) {
1248
- this.updateOptionPosition(top, left);
1249
- await this.updatePositionPopover();
1250
- }
1251
- /**
1252
- * Exibe o ez-popover.
1253
- */
1254
- async show(top, left) {
1255
- this.updateOptionPosition(top, left);
1256
- this.opened = true;
1257
- }
1258
- /**
1259
- * Ancora a exibição do popOver a um elemento HTML.
1260
- */
1261
- async showUnder(element, options) {
1262
- if (options) {
1263
- this.options = options;
1264
- }
1265
- this.anchorElement = element;
1266
- this.opened = true;
1267
- }
1268
- /**
1269
- * Oculta o ez-popover.
1270
- */
1271
- async hide() {
1272
- this.opened = false;
1273
- }
1274
- /**
1275
- * Altera as opções.
1276
- */
1277
- async setOptions(options) {
1278
- Object.assign(this.options, options);
1279
- }
1280
- /**
1281
- * Altera o elemento de ancoragem.
1282
- */
1283
- async setAnchorElement(anchor) {
1284
- this.anchorElement = anchor;
1285
- }
1286
- parseSizePixel(sizePixel, defaultValue) {
1287
- if (!sizePixel) {
1288
- return defaultValue !== null && defaultValue !== void 0 ? defaultValue : 0;
1289
- }
1290
- if (typeof sizePixel === "string") {
1291
- return Number(sizePixel.replace("px", ""));
1292
- }
1293
- return sizePixel !== null && sizePixel !== void 0 ? sizePixel : 0;
1294
- }
1295
- updateOptionPosition(top, left) {
1296
- Object.assign(this.options, {
1297
- horizontalGap: this.parseSizePixel(left, this.options.horizontalGap),
1298
- verticalGap: this.parseSizePixel(top, this.options.verticalGap),
1299
- });
1300
- }
1301
- async updatePositionPopover() {
1302
- if (!this._box || !this.opened) {
1303
- return;
1304
- }
1305
- if (!this.anchorElement) {
1306
- this.anchorElement = this._host;
1307
- }
1308
- if (typeof this.anchorElement === 'string') {
1309
- this.anchorElement = document.getElementById(this.anchorElement);
1310
- }
1311
- await computePosition(this.anchorElement, this._box, {
1312
- placement: this.options.fromRight ? 'bottom-end' : 'bottom-start',
1313
- middleware: [flip(), shift({ padding: 5 })],
1314
- strategy: 'fixed',
1315
- }).then(({ x, y, placement }) => {
1316
- const newTop = placement.includes("bottom") ? y + this.options.verticalGap : y - this.options.verticalGap;
1317
- const newLeft = placement.includes("start") ? x + this.options.horizontalGap : x - this.options.horizontalGap;
1318
- Object.assign(this._box.style, {
1319
- top: `${newTop}px`,
1320
- left: `${newLeft}px`,
1321
- });
1322
- });
1323
- }
1324
- hidePopover() {
1325
- if (!this._box) {
1326
- return;
1327
- }
1328
- this._box.style.display = '';
1329
- this.hideOverlay();
1330
- this.ezVisibilityChange.emit(false);
1331
- }
1332
- async openPopover() {
1333
- if (!this._box) {
1334
- return;
1335
- }
1336
- if (this.opened) {
1337
- this._box.style.display = 'flex';
1338
- this._box.style.visibility = 'hidden';
1339
- await this.updatePositionPopover();
1340
- this.openOverlay();
1341
- this.ezVisibilityChange.emit(true);
1342
- this._box.style.visibility = 'visible';
1343
- }
1344
- }
1345
- openOverlay() {
1346
- if (!this._overlay || !this._overlayIsActive) {
1347
- return;
1348
- }
1349
- this._overlay.style.display = 'block';
1350
- }
1351
- hideOverlay() {
1352
- if (!this._overlay) {
1353
- return;
1354
- }
1355
- this._overlay.style.display = 'none';
1356
- }
1357
- checkStatusOverlay() {
1358
- if (this.overlayType !== "none") {
1359
- return true;
1360
- }
1361
- if (this.overlayType === "none" && this.autoClose) {
1362
- return true;
1363
- }
1364
- return false;
1365
- }
1366
- updatePositionDebounce() {
1367
- if (!this.opened) {
1368
- return;
1369
- }
1370
- clearTimeout(this._timeoutDebounce);
1371
- this._timeoutDebounce = setTimeout(() => {
1372
- this.updatePositionPopover();
1373
- }, this.TIME_DEBOUNCE);
1374
- }
1375
- componentWillLoad() {
1376
- window.addEventListener('scroll', this.updatePositionDebounce.bind(this), true);
1377
- window.addEventListener('resize', this.updatePositionDebounce.bind(this), true);
1378
- }
1379
- componentDidLoad() {
1380
- this._overlayIsActive = this.checkStatusOverlay();
1381
- this._resizeObserver = new ResizeObserver(this.updatePositionPopover.bind(this));
1382
- this._resizeObserver.observe(this._box);
1383
- this.openPopover();
1384
- }
1385
- disconnectedCallback() {
1386
- window.removeEventListener('scroll', this.updatePositionDebounce.bind(this), true);
1387
- window.removeEventListener('resize', this.updatePositionDebounce.bind(this), true);
1388
- this._resizeObserver.disconnect();
1389
- }
1390
- render() {
1391
- return (h(Host, null, h("div", { ref: el => this._overlay = el, onClick: () => this.hide(), class: `popover__overlay popover__overlay--${this.overlayType}` }), h("section", { ref: el => this._box = el, class: {
1392
- "popover__box": true,
1393
- "popover__box--fit-content": this.boxWidth === "fit-content",
1394
- "popover__box--full-width": this.boxWidth !== "fit-content",
1395
- } }, h("slot", null))));
1396
- }
1397
- get _host() { return getElement(this); }
1398
- static get watchers() { return {
1399
- "opened": ["observeOpened"]
1400
- }; }
1401
- };
1402
- EzPopoverCore.style = ezPopoverCoreCss;
1403
-
1404
- const ezPopoverPlusCss = ":host{display:none}";
1405
-
1406
- const EzPopoverPlus = class {
1407
- constructor(hostRef) {
1408
- registerInstance(this, hostRef);
1409
- this.ezVisibilityChange = createEvent(this, "ezVisibilityChange", 7);
1410
- this.autoClose = true;
1411
- this.boxWidth = "fit-content";
1412
- this.opened = false;
1413
- this.overlayType = "light";
1414
- this.anchorElement = undefined;
1415
- this.options = { horizontalGap: 0, verticalGap: 0, fromRight: false };
1416
- }
1417
- listenerEzVisibilityChange({ detail }) {
1418
- this.ezVisibilityChange.emit(detail);
1419
- }
1420
- async observeOpened(newValue) {
1421
- if (newValue && !this._popOverCore) {
1422
- this.renderPopoverCore();
1423
- }
1424
- this._popOverCore.opened = newValue;
1425
- }
1426
- /**
1427
- * Atualiza a posição do popover.
1428
- */
1429
- async updatePosition(top, left) {
1430
- var _a;
1431
- await ((_a = this._popOverCore) === null || _a === void 0 ? void 0 : _a.updatePosition(top, left));
1432
- }
1433
- /**
1434
- * Exibe o ez-popover.
1435
- */
1436
- async show(top, left) {
1437
- if (!this._popOverCore) {
1438
- this.renderPopoverCore();
1439
- }
1440
- await this._popOverCore.show(top, left);
1441
- }
1442
- /**
1443
- * Ancora a exibição do popOver a um elemento HTML.
1444
- */
1445
- async showUnder(element, options) {
1446
- if (!this._popOverCore) {
1447
- this.renderPopoverCore();
1448
- }
1449
- await this._popOverCore.showUnder(element, options);
1450
- }
1451
- /**
1452
- * Oculta o ez-popover.
1453
- */
1454
- async hide() {
1455
- var _a;
1456
- await ((_a = this._popOverCore) === null || _a === void 0 ? void 0 : _a.hide());
1457
- }
1458
- /**
1459
- * Altera as opções.
1460
- */
1461
- async setOptions(options) {
1462
- var _a;
1463
- await ((_a = this._popOverCore) === null || _a === void 0 ? void 0 : _a.setOptions(options));
1464
- }
1465
- /**
1466
- * Altera o elemento de ancoragem.
1467
- */
1468
- async setAnchorElement(anchor) {
1469
- var _a;
1470
- await ((_a = this._popOverCore) === null || _a === void 0 ? void 0 : _a.setAnchorElement(anchor));
1471
- }
1472
- renderPopoverCore() {
1473
- this._popOverCore = document.createElement('ez-popover-core');
1474
- this._popOverCore.opened = this.opened;
1475
- this._popOverCore.anchorElement = this.anchorElement;
1476
- this._popOverCore.autoClose = this.autoClose;
1477
- this._popOverCore.boxWidth = this.boxWidth;
1478
- this._popOverCore.overlayType = this.overlayType;
1479
- this._popOverCore.options = this.options;
1480
- const firstChild = this._host.children.item(0);
1481
- if (firstChild) {
1482
- this._popOverCore.appendChild(firstChild);
1483
- }
1484
- else {
1485
- console.warn('O slot do popover está vazio. Adicione conteúdo ao slot para exibição correta.');
1486
- }
1487
- document.body.appendChild(this._popOverCore);
1488
- }
1489
- render() {
1490
- return (h(Host, null, h("slot", null)));
1491
- }
1492
- get _host() { return getElement(this); }
1493
- static get watchers() { return {
1494
- "opened": ["observeOpened"]
1495
- }; }
1496
- };
1497
- EzPopoverPlus.style = ezPopoverPlusCss;
1498
-
1499
- export { EzPopoverCore as ez_popover_core, EzPopoverPlus as ez_popover_plus };