@sankhyalabs/ezui 5.22.0-dev.83 → 5.22.0-dev.85

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