@quartzds/core 1.0.0-beta.1

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 (160) hide show
  1. package/README.md +136 -0
  2. package/components/floating-ui.dom.esm.js +1402 -0
  3. package/components/floating-ui.dom.esm.js.map +1 -0
  4. package/components/helpers.js +174 -0
  5. package/components/helpers.js.map +1 -0
  6. package/components/icon.js +175 -0
  7. package/components/icon.js.map +1 -0
  8. package/components/index.d.ts +52 -0
  9. package/components/index.js +117 -0
  10. package/components/index.js.map +1 -0
  11. package/components/label.js +55 -0
  12. package/components/label.js.map +1 -0
  13. package/components/qds-button.d.ts +11 -0
  14. package/components/qds-button.js +148 -0
  15. package/components/qds-button.js.map +1 -0
  16. package/components/qds-checkbox.d.ts +11 -0
  17. package/components/qds-checkbox.js +156 -0
  18. package/components/qds-checkbox.js.map +1 -0
  19. package/components/qds-dropdown.d.ts +11 -0
  20. package/components/qds-dropdown.js +259 -0
  21. package/components/qds-dropdown.js.map +1 -0
  22. package/components/qds-icon.d.ts +11 -0
  23. package/components/qds-icon.js +13 -0
  24. package/components/qds-icon.js.map +1 -0
  25. package/components/qds-inline-link.d.ts +11 -0
  26. package/components/qds-inline-link.js +89 -0
  27. package/components/qds-inline-link.js.map +1 -0
  28. package/components/qds-input.d.ts +11 -0
  29. package/components/qds-input.js +244 -0
  30. package/components/qds-input.js.map +1 -0
  31. package/components/qds-label.d.ts +11 -0
  32. package/components/qds-label.js +13 -0
  33. package/components/qds-label.js.map +1 -0
  34. package/components/qds-radio.d.ts +11 -0
  35. package/components/qds-radio.js +109 -0
  36. package/components/qds-radio.js.map +1 -0
  37. package/components/qds-switch.d.ts +11 -0
  38. package/components/qds-switch.js +119 -0
  39. package/components/qds-switch.js.map +1 -0
  40. package/components/qds-title.d.ts +11 -0
  41. package/components/qds-title.js +94 -0
  42. package/components/qds-title.js.map +1 -0
  43. package/components/qds-tooltip.d.ts +11 -0
  44. package/components/qds-tooltip.js +325 -0
  45. package/components/qds-tooltip.js.map +1 -0
  46. package/dist/cjs/floating-ui.dom.esm-71fa96af.js +1410 -0
  47. package/dist/cjs/floating-ui.dom.esm-71fa96af.js.map +1 -0
  48. package/dist/cjs/helpers-0b23af3f.js +184 -0
  49. package/dist/cjs/helpers-0b23af3f.js.map +1 -0
  50. package/dist/cjs/index-f19b2823.js +2030 -0
  51. package/dist/cjs/index-f19b2823.js.map +1 -0
  52. package/dist/cjs/index.cjs.js +115 -0
  53. package/dist/cjs/index.cjs.js.map +1 -0
  54. package/dist/cjs/library-4803c801.js +62 -0
  55. package/dist/cjs/library-4803c801.js.map +1 -0
  56. package/dist/cjs/loader.cjs.js +29 -0
  57. package/dist/cjs/loader.cjs.js.map +1 -0
  58. package/dist/cjs/qds-button.cjs.entry.js +110 -0
  59. package/dist/cjs/qds-button.cjs.entry.js.map +1 -0
  60. package/dist/cjs/qds-checkbox.cjs.entry.js +116 -0
  61. package/dist/cjs/qds-checkbox.cjs.entry.js.map +1 -0
  62. package/dist/cjs/qds-dropdown.cjs.entry.js +227 -0
  63. package/dist/cjs/qds-dropdown.cjs.entry.js.map +1 -0
  64. package/dist/cjs/qds-icon.cjs.entry.js +113 -0
  65. package/dist/cjs/qds-icon.cjs.entry.js.map +1 -0
  66. package/dist/cjs/qds-inline-link.cjs.entry.js +61 -0
  67. package/dist/cjs/qds-inline-link.cjs.entry.js.map +1 -0
  68. package/dist/cjs/qds-input.cjs.entry.js +200 -0
  69. package/dist/cjs/qds-input.cjs.entry.js.map +1 -0
  70. package/dist/cjs/qds-label.cjs.entry.js +39 -0
  71. package/dist/cjs/qds-label.cjs.entry.js.map +1 -0
  72. package/dist/cjs/qds-radio.cjs.entry.js +74 -0
  73. package/dist/cjs/qds-radio.cjs.entry.js.map +1 -0
  74. package/dist/cjs/qds-switch.cjs.entry.js +79 -0
  75. package/dist/cjs/qds-switch.cjs.entry.js.map +1 -0
  76. package/dist/cjs/qds-title.cjs.entry.js +66 -0
  77. package/dist/cjs/qds-title.cjs.entry.js.map +1 -0
  78. package/dist/cjs/qds-tooltip.cjs.entry.js +284 -0
  79. package/dist/cjs/qds-tooltip.cjs.entry.js.map +1 -0
  80. package/dist/cjs/qds.cjs.js +33 -0
  81. package/dist/cjs/qds.cjs.js.map +1 -0
  82. package/dist/custom-elements.json +3976 -0
  83. package/dist/docs.d.ts +148 -0
  84. package/dist/docs.json +3918 -0
  85. package/dist/esm/floating-ui.dom.esm-f96ac766.js +1402 -0
  86. package/dist/esm/floating-ui.dom.esm-f96ac766.js.map +1 -0
  87. package/dist/esm/helpers-5c189a19.js +174 -0
  88. package/dist/esm/helpers-5c189a19.js.map +1 -0
  89. package/dist/esm/index-1bc8e218.js +2000 -0
  90. package/dist/esm/index-1bc8e218.js.map +1 -0
  91. package/dist/esm/index.js +106 -0
  92. package/dist/esm/index.js.map +1 -0
  93. package/dist/esm/library-aa6893c0.js +58 -0
  94. package/dist/esm/library-aa6893c0.js.map +1 -0
  95. package/dist/esm/loader.js +25 -0
  96. package/dist/esm/loader.js.map +1 -0
  97. package/dist/esm/polyfills/core-js.js +11 -0
  98. package/dist/esm/polyfills/css-shim.js +1 -0
  99. package/dist/esm/polyfills/dom.js +79 -0
  100. package/dist/esm/polyfills/es5-html-element.js +1 -0
  101. package/dist/esm/polyfills/index.js +34 -0
  102. package/dist/esm/polyfills/system.js +6 -0
  103. package/dist/esm/qds-button.entry.js +106 -0
  104. package/dist/esm/qds-button.entry.js.map +1 -0
  105. package/dist/esm/qds-checkbox.entry.js +112 -0
  106. package/dist/esm/qds-checkbox.entry.js.map +1 -0
  107. package/dist/esm/qds-dropdown.entry.js +223 -0
  108. package/dist/esm/qds-dropdown.entry.js.map +1 -0
  109. package/dist/esm/qds-icon.entry.js +109 -0
  110. package/dist/esm/qds-icon.entry.js.map +1 -0
  111. package/dist/esm/qds-inline-link.entry.js +57 -0
  112. package/dist/esm/qds-inline-link.entry.js.map +1 -0
  113. package/dist/esm/qds-input.entry.js +196 -0
  114. package/dist/esm/qds-input.entry.js.map +1 -0
  115. package/dist/esm/qds-label.entry.js +35 -0
  116. package/dist/esm/qds-label.entry.js.map +1 -0
  117. package/dist/esm/qds-radio.entry.js +70 -0
  118. package/dist/esm/qds-radio.entry.js.map +1 -0
  119. package/dist/esm/qds-switch.entry.js +75 -0
  120. package/dist/esm/qds-switch.entry.js.map +1 -0
  121. package/dist/esm/qds-title.entry.js +62 -0
  122. package/dist/esm/qds-title.entry.js.map +1 -0
  123. package/dist/esm/qds-tooltip.entry.js +280 -0
  124. package/dist/esm/qds-tooltip.entry.js.map +1 -0
  125. package/dist/esm/qds.js +28 -0
  126. package/dist/esm/qds.js.map +1 -0
  127. package/dist/types/components/button/button.d.ts +209 -0
  128. package/dist/types/components/checkbox/checkbox.d.ts +136 -0
  129. package/dist/types/components/create-story.d.ts +5 -0
  130. package/dist/types/components/dropdown/dropdown.d.ts +135 -0
  131. package/dist/types/components/icon/default-library.d.ts +4 -0
  132. package/dist/types/components/icon/icon.d.ts +31 -0
  133. package/dist/types/components/icon/library.d.ts +19 -0
  134. package/dist/types/components/icon/request.d.ts +12 -0
  135. package/dist/types/components/icon/system-library.d.ts +4 -0
  136. package/dist/types/components/inline-link/inline-link.d.ts +208 -0
  137. package/dist/types/components/input/input.d.ts +386 -0
  138. package/dist/types/components/label/label.d.ts +33 -0
  139. package/dist/types/components/radio/radio.d.ts +110 -0
  140. package/dist/types/components/switch/switch.d.ts +115 -0
  141. package/dist/types/components/title/title.d.ts +42 -0
  142. package/dist/types/components/tooltip/tooltip.d.ts +147 -0
  143. package/dist/types/components.d.ts +1692 -0
  144. package/dist/types/helpers.d.ts +49 -0
  145. package/dist/types/index.d.ts +4 -0
  146. package/dist/types/qds-test.d.ts +18 -0
  147. package/dist/types/stencil-public-runtime.d.ts +1638 -0
  148. package/dist/types/utils.d.ts +65 -0
  149. package/dist/vscode.html-custom-data.json +947 -0
  150. package/hydrate/index.d.ts +218 -0
  151. package/hydrate/index.js +9690 -0
  152. package/hydrate/package.json +6 -0
  153. package/loader/cdn.js +7 -0
  154. package/loader/index.cjs.js +7 -0
  155. package/loader/index.d.ts +21 -0
  156. package/loader/index.es2017.js +7 -0
  157. package/loader/index.js +8 -0
  158. package/loader/package.json +11 -0
  159. package/package.json +231 -0
  160. package/styles/core.css +379 -0
@@ -0,0 +1,1402 @@
1
+ /*!
2
+ * SPDX-FileCopyrightText: © 2023 Schneider Electric
3
+ *
4
+ * SPDX-License-Identifier: LGPL-2.1-only
5
+ */
6
+ function getAlignment(placement) {
7
+ return placement.split('-')[1];
8
+ }
9
+
10
+ function getLengthFromAxis(axis) {
11
+ return axis === 'y' ? 'height' : 'width';
12
+ }
13
+
14
+ function getSide(placement) {
15
+ return placement.split('-')[0];
16
+ }
17
+
18
+ function getMainAxisFromPlacement(placement) {
19
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
20
+ }
21
+
22
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
23
+ let {
24
+ reference,
25
+ floating
26
+ } = _ref;
27
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
28
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
29
+ const mainAxis = getMainAxisFromPlacement(placement);
30
+ const length = getLengthFromAxis(mainAxis);
31
+ const commonAlign = reference[length] / 2 - floating[length] / 2;
32
+ const side = getSide(placement);
33
+ const isVertical = mainAxis === 'x';
34
+ let coords;
35
+ switch (side) {
36
+ case 'top':
37
+ coords = {
38
+ x: commonX,
39
+ y: reference.y - floating.height
40
+ };
41
+ break;
42
+ case 'bottom':
43
+ coords = {
44
+ x: commonX,
45
+ y: reference.y + reference.height
46
+ };
47
+ break;
48
+ case 'right':
49
+ coords = {
50
+ x: reference.x + reference.width,
51
+ y: commonY
52
+ };
53
+ break;
54
+ case 'left':
55
+ coords = {
56
+ x: reference.x - floating.width,
57
+ y: commonY
58
+ };
59
+ break;
60
+ default:
61
+ coords = {
62
+ x: reference.x,
63
+ y: reference.y
64
+ };
65
+ }
66
+ switch (getAlignment(placement)) {
67
+ case 'start':
68
+ coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
69
+ break;
70
+ case 'end':
71
+ coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
72
+ break;
73
+ }
74
+ return coords;
75
+ }
76
+
77
+ /**
78
+ * Computes the `x` and `y` coordinates that will place the floating element
79
+ * next to a reference element when it is given a certain positioning strategy.
80
+ *
81
+ * This export does not have any `platform` interface logic. You will need to
82
+ * write one for the platform you are using Floating UI with.
83
+ */
84
+ const computePosition$1 = async (reference, floating, config) => {
85
+ const {
86
+ placement = 'bottom',
87
+ strategy = 'absolute',
88
+ middleware = [],
89
+ platform
90
+ } = config;
91
+ const validMiddleware = middleware.filter(Boolean);
92
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
93
+ let rects = await platform.getElementRects({
94
+ reference,
95
+ floating,
96
+ strategy
97
+ });
98
+ let {
99
+ x,
100
+ y
101
+ } = computeCoordsFromPlacement(rects, placement, rtl);
102
+ let statefulPlacement = placement;
103
+ let middlewareData = {};
104
+ let resetCount = 0;
105
+ for (let i = 0; i < validMiddleware.length; i++) {
106
+ const {
107
+ name,
108
+ fn
109
+ } = validMiddleware[i];
110
+ const {
111
+ x: nextX,
112
+ y: nextY,
113
+ data,
114
+ reset
115
+ } = await fn({
116
+ x,
117
+ y,
118
+ initialPlacement: placement,
119
+ placement: statefulPlacement,
120
+ strategy,
121
+ middlewareData,
122
+ rects,
123
+ platform,
124
+ elements: {
125
+ reference,
126
+ floating
127
+ }
128
+ });
129
+ x = nextX != null ? nextX : x;
130
+ y = nextY != null ? nextY : y;
131
+ middlewareData = {
132
+ ...middlewareData,
133
+ [name]: {
134
+ ...middlewareData[name],
135
+ ...data
136
+ }
137
+ };
138
+ if (reset && resetCount <= 50) {
139
+ resetCount++;
140
+ if (typeof reset === 'object') {
141
+ if (reset.placement) {
142
+ statefulPlacement = reset.placement;
143
+ }
144
+ if (reset.rects) {
145
+ rects = reset.rects === true ? await platform.getElementRects({
146
+ reference,
147
+ floating,
148
+ strategy
149
+ }) : reset.rects;
150
+ }
151
+ ({
152
+ x,
153
+ y
154
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
155
+ }
156
+ i = -1;
157
+ continue;
158
+ }
159
+ }
160
+ return {
161
+ x,
162
+ y,
163
+ placement: statefulPlacement,
164
+ strategy,
165
+ middlewareData
166
+ };
167
+ };
168
+
169
+ function expandPaddingObject(padding) {
170
+ return {
171
+ top: 0,
172
+ right: 0,
173
+ bottom: 0,
174
+ left: 0,
175
+ ...padding
176
+ };
177
+ }
178
+
179
+ function getSideObjectFromPadding(padding) {
180
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
181
+ top: padding,
182
+ right: padding,
183
+ bottom: padding,
184
+ left: padding
185
+ };
186
+ }
187
+
188
+ function rectToClientRect(rect) {
189
+ return {
190
+ ...rect,
191
+ top: rect.y,
192
+ left: rect.x,
193
+ right: rect.x + rect.width,
194
+ bottom: rect.y + rect.height
195
+ };
196
+ }
197
+
198
+ /**
199
+ * Resolves with an object of overflow side offsets that determine how much the
200
+ * element is overflowing a given clipping boundary on each side.
201
+ * - positive = overflowing the boundary by that number of pixels
202
+ * - negative = how many pixels left before it will overflow
203
+ * - 0 = lies flush with the boundary
204
+ * @see https://floating-ui.com/docs/detectOverflow
205
+ */
206
+ async function detectOverflow(state, options) {
207
+ var _await$platform$isEle;
208
+ if (options === void 0) {
209
+ options = {};
210
+ }
211
+ const {
212
+ x,
213
+ y,
214
+ platform,
215
+ rects,
216
+ elements,
217
+ strategy
218
+ } = state;
219
+ const {
220
+ boundary = 'clippingAncestors',
221
+ rootBoundary = 'viewport',
222
+ elementContext = 'floating',
223
+ altBoundary = false,
224
+ padding = 0
225
+ } = options;
226
+ const paddingObject = getSideObjectFromPadding(padding);
227
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
228
+ const element = elements[altBoundary ? altContext : elementContext];
229
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
230
+ 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))),
231
+ boundary,
232
+ rootBoundary,
233
+ strategy
234
+ }));
235
+ const rect = elementContext === 'floating' ? {
236
+ ...rects.floating,
237
+ x,
238
+ y
239
+ } : rects.reference;
240
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
241
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
242
+ x: 1,
243
+ y: 1
244
+ } : {
245
+ x: 1,
246
+ y: 1
247
+ };
248
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
249
+ rect,
250
+ offsetParent,
251
+ strategy
252
+ }) : rect);
253
+ return {
254
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
255
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
256
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
257
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
258
+ };
259
+ }
260
+
261
+ const min$1 = Math.min;
262
+ const max$1 = Math.max;
263
+
264
+ function within(min$1$1, value, max$1$1) {
265
+ return max$1(min$1$1, min$1(value, max$1$1));
266
+ }
267
+
268
+ /**
269
+ * Provides data to position an inner element of the floating element so that it
270
+ * appears centered to the reference element.
271
+ * @see https://floating-ui.com/docs/arrow
272
+ */
273
+ const arrow = options => ({
274
+ name: 'arrow',
275
+ options,
276
+ async fn(state) {
277
+ // Since `element` is required, we don't Partial<> the type.
278
+ const {
279
+ element,
280
+ padding = 0
281
+ } = options || {};
282
+ const {
283
+ x,
284
+ y,
285
+ placement,
286
+ rects,
287
+ platform,
288
+ elements
289
+ } = state;
290
+ if (element == null) {
291
+ return {};
292
+ }
293
+ const paddingObject = getSideObjectFromPadding(padding);
294
+ const coords = {
295
+ x,
296
+ y
297
+ };
298
+ const axis = getMainAxisFromPlacement(placement);
299
+ const length = getLengthFromAxis(axis);
300
+ const arrowDimensions = await platform.getDimensions(element);
301
+ const isYAxis = axis === 'y';
302
+ const minProp = isYAxis ? 'top' : 'left';
303
+ const maxProp = isYAxis ? 'bottom' : 'right';
304
+ const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
305
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
306
+ const startDiff = coords[axis] - rects.reference[axis];
307
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
308
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
309
+
310
+ // DOM platform can return `window` as the `offsetParent`.
311
+ if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
312
+ clientSize = elements.floating[clientProp] || rects.floating[length];
313
+ }
314
+ const centerToReference = endDiff / 2 - startDiff / 2;
315
+
316
+ // Make sure the arrow doesn't overflow the floating element if the center
317
+ // point is outside the floating element's bounds.
318
+ const min = paddingObject[minProp];
319
+ const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
320
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
321
+ const offset = within(min, center, max);
322
+
323
+ // If the reference is small enough that the arrow's padding causes it to
324
+ // to point to nothing for an aligned placement, adjust the offset of the
325
+ // floating element itself. This stops `shift()` from taking action, but can
326
+ // be worked around by calling it again after the `arrow()` if desired.
327
+ const shouldAddOffset = getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min ? paddingObject[minProp] : paddingObject[maxProp]) - arrowDimensions[length] / 2 < 0;
328
+ const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;
329
+ return {
330
+ [axis]: coords[axis] - alignmentOffset,
331
+ data: {
332
+ [axis]: offset,
333
+ centerOffset: center - offset
334
+ }
335
+ };
336
+ }
337
+ });
338
+
339
+ const oppositeSideMap = {
340
+ left: 'right',
341
+ right: 'left',
342
+ bottom: 'top',
343
+ top: 'bottom'
344
+ };
345
+ function getOppositePlacement(placement) {
346
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
347
+ }
348
+
349
+ function getAlignmentSides(placement, rects, rtl) {
350
+ if (rtl === void 0) {
351
+ rtl = false;
352
+ }
353
+ const alignment = getAlignment(placement);
354
+ const mainAxis = getMainAxisFromPlacement(placement);
355
+ const length = getLengthFromAxis(mainAxis);
356
+ let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
357
+ if (rects.reference[length] > rects.floating[length]) {
358
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
359
+ }
360
+ return {
361
+ main: mainAlignmentSide,
362
+ cross: getOppositePlacement(mainAlignmentSide)
363
+ };
364
+ }
365
+
366
+ const oppositeAlignmentMap = {
367
+ start: 'end',
368
+ end: 'start'
369
+ };
370
+ function getOppositeAlignmentPlacement(placement) {
371
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
372
+ }
373
+
374
+ function getExpandedPlacements(placement) {
375
+ const oppositePlacement = getOppositePlacement(placement);
376
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
377
+ }
378
+
379
+ function getSideList(side, isStart, rtl) {
380
+ const lr = ['left', 'right'];
381
+ const rl = ['right', 'left'];
382
+ const tb = ['top', 'bottom'];
383
+ const bt = ['bottom', 'top'];
384
+ switch (side) {
385
+ case 'top':
386
+ case 'bottom':
387
+ if (rtl) return isStart ? rl : lr;
388
+ return isStart ? lr : rl;
389
+ case 'left':
390
+ case 'right':
391
+ return isStart ? tb : bt;
392
+ default:
393
+ return [];
394
+ }
395
+ }
396
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
397
+ const alignment = getAlignment(placement);
398
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
399
+ if (alignment) {
400
+ list = list.map(side => side + "-" + alignment);
401
+ if (flipAlignment) {
402
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
403
+ }
404
+ }
405
+ return list;
406
+ }
407
+
408
+ /**
409
+ * Optimizes the visibility of the floating element by flipping the `placement`
410
+ * in order to keep it in view when the preferred placement(s) will overflow the
411
+ * clipping boundary. Alternative to `autoPlacement`.
412
+ * @see https://floating-ui.com/docs/flip
413
+ */
414
+ const flip = function (options) {
415
+ if (options === void 0) {
416
+ options = {};
417
+ }
418
+ return {
419
+ name: 'flip',
420
+ options,
421
+ async fn(state) {
422
+ var _middlewareData$flip;
423
+ const {
424
+ placement,
425
+ middlewareData,
426
+ rects,
427
+ initialPlacement,
428
+ platform,
429
+ elements
430
+ } = state;
431
+ const {
432
+ mainAxis: checkMainAxis = true,
433
+ crossAxis: checkCrossAxis = true,
434
+ fallbackPlacements: specifiedFallbackPlacements,
435
+ fallbackStrategy = 'bestFit',
436
+ fallbackAxisSideDirection = 'none',
437
+ flipAlignment = true,
438
+ ...detectOverflowOptions
439
+ } = options;
440
+ const side = getSide(placement);
441
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
442
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
443
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
444
+ if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
445
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
446
+ }
447
+ const placements = [initialPlacement, ...fallbackPlacements];
448
+ const overflow = await detectOverflow(state, detectOverflowOptions);
449
+ const overflows = [];
450
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
451
+ if (checkMainAxis) {
452
+ overflows.push(overflow[side]);
453
+ }
454
+ if (checkCrossAxis) {
455
+ const {
456
+ main,
457
+ cross
458
+ } = getAlignmentSides(placement, rects, rtl);
459
+ overflows.push(overflow[main], overflow[cross]);
460
+ }
461
+ overflowsData = [...overflowsData, {
462
+ placement,
463
+ overflows
464
+ }];
465
+
466
+ // One or more sides is overflowing.
467
+ if (!overflows.every(side => side <= 0)) {
468
+ var _middlewareData$flip2, _overflowsData$filter;
469
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
470
+ const nextPlacement = placements[nextIndex];
471
+ if (nextPlacement) {
472
+ // Try next placement and re-run the lifecycle.
473
+ return {
474
+ data: {
475
+ index: nextIndex,
476
+ overflows: overflowsData
477
+ },
478
+ reset: {
479
+ placement: nextPlacement
480
+ }
481
+ };
482
+ }
483
+
484
+ // First, find the candidates that fit on the mainAxis side of overflow,
485
+ // then find the placement that fits the best on the main crossAxis side.
486
+ 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;
487
+
488
+ // Otherwise fallback.
489
+ if (!resetPlacement) {
490
+ switch (fallbackStrategy) {
491
+ case 'bestFit':
492
+ {
493
+ var _overflowsData$map$so;
494
+ const placement = (_overflowsData$map$so = overflowsData.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$map$so[0];
495
+ if (placement) {
496
+ resetPlacement = placement;
497
+ }
498
+ break;
499
+ }
500
+ case 'initialPlacement':
501
+ resetPlacement = initialPlacement;
502
+ break;
503
+ }
504
+ }
505
+ if (placement !== resetPlacement) {
506
+ return {
507
+ reset: {
508
+ placement: resetPlacement
509
+ }
510
+ };
511
+ }
512
+ }
513
+ return {};
514
+ }
515
+ };
516
+ };
517
+
518
+ async function convertValueToCoords(state, value) {
519
+ const {
520
+ placement,
521
+ platform,
522
+ elements
523
+ } = state;
524
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
525
+ const side = getSide(placement);
526
+ const alignment = getAlignment(placement);
527
+ const isVertical = getMainAxisFromPlacement(placement) === 'x';
528
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
529
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
530
+ const rawValue = typeof value === 'function' ? value(state) : value;
531
+
532
+ // eslint-disable-next-line prefer-const
533
+ let {
534
+ mainAxis,
535
+ crossAxis,
536
+ alignmentAxis
537
+ } = typeof rawValue === 'number' ? {
538
+ mainAxis: rawValue,
539
+ crossAxis: 0,
540
+ alignmentAxis: null
541
+ } : {
542
+ mainAxis: 0,
543
+ crossAxis: 0,
544
+ alignmentAxis: null,
545
+ ...rawValue
546
+ };
547
+ if (alignment && typeof alignmentAxis === 'number') {
548
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
549
+ }
550
+ return isVertical ? {
551
+ x: crossAxis * crossAxisMulti,
552
+ y: mainAxis * mainAxisMulti
553
+ } : {
554
+ x: mainAxis * mainAxisMulti,
555
+ y: crossAxis * crossAxisMulti
556
+ };
557
+ }
558
+
559
+ /**
560
+ * Modifies the placement by translating the floating element along the
561
+ * specified axes.
562
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
563
+ * object may be passed.
564
+ * @see https://floating-ui.com/docs/offset
565
+ */
566
+ const offset = function (value) {
567
+ if (value === void 0) {
568
+ value = 0;
569
+ }
570
+ return {
571
+ name: 'offset',
572
+ options: value,
573
+ async fn(state) {
574
+ const {
575
+ x,
576
+ y
577
+ } = state;
578
+ const diffCoords = await convertValueToCoords(state, value);
579
+ return {
580
+ x: x + diffCoords.x,
581
+ y: y + diffCoords.y,
582
+ data: diffCoords
583
+ };
584
+ }
585
+ };
586
+ };
587
+
588
+ function getCrossAxis(axis) {
589
+ return axis === 'x' ? 'y' : 'x';
590
+ }
591
+
592
+ /**
593
+ * Optimizes the visibility of the floating element by shifting it in order to
594
+ * keep it in view when it will overflow the clipping boundary.
595
+ * @see https://floating-ui.com/docs/shift
596
+ */
597
+ const shift = function (options) {
598
+ if (options === void 0) {
599
+ options = {};
600
+ }
601
+ return {
602
+ name: 'shift',
603
+ options,
604
+ async fn(state) {
605
+ const {
606
+ x,
607
+ y,
608
+ placement
609
+ } = state;
610
+ const {
611
+ mainAxis: checkMainAxis = true,
612
+ crossAxis: checkCrossAxis = false,
613
+ limiter = {
614
+ fn: _ref => {
615
+ let {
616
+ x,
617
+ y
618
+ } = _ref;
619
+ return {
620
+ x,
621
+ y
622
+ };
623
+ }
624
+ },
625
+ ...detectOverflowOptions
626
+ } = options;
627
+ const coords = {
628
+ x,
629
+ y
630
+ };
631
+ const overflow = await detectOverflow(state, detectOverflowOptions);
632
+ const mainAxis = getMainAxisFromPlacement(getSide(placement));
633
+ const crossAxis = getCrossAxis(mainAxis);
634
+ let mainAxisCoord = coords[mainAxis];
635
+ let crossAxisCoord = coords[crossAxis];
636
+ if (checkMainAxis) {
637
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
638
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
639
+ const min = mainAxisCoord + overflow[minSide];
640
+ const max = mainAxisCoord - overflow[maxSide];
641
+ mainAxisCoord = within(min, mainAxisCoord, max);
642
+ }
643
+ if (checkCrossAxis) {
644
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
645
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
646
+ const min = crossAxisCoord + overflow[minSide];
647
+ const max = crossAxisCoord - overflow[maxSide];
648
+ crossAxisCoord = within(min, crossAxisCoord, max);
649
+ }
650
+ const limitedCoords = limiter.fn({
651
+ ...state,
652
+ [mainAxis]: mainAxisCoord,
653
+ [crossAxis]: crossAxisCoord
654
+ });
655
+ return {
656
+ ...limitedCoords,
657
+ data: {
658
+ x: limitedCoords.x - x,
659
+ y: limitedCoords.y - y
660
+ }
661
+ };
662
+ }
663
+ };
664
+ };
665
+ /**
666
+ * Built-in `limiter` that will stop `shift()` at a certain point.
667
+ */
668
+ const limitShift = function (options) {
669
+ if (options === void 0) {
670
+ options = {};
671
+ }
672
+ return {
673
+ options,
674
+ fn(state) {
675
+ const {
676
+ x,
677
+ y,
678
+ placement,
679
+ rects,
680
+ middlewareData
681
+ } = state;
682
+ const {
683
+ offset = 0,
684
+ mainAxis: checkMainAxis = true,
685
+ crossAxis: checkCrossAxis = true
686
+ } = options;
687
+ const coords = {
688
+ x,
689
+ y
690
+ };
691
+ const mainAxis = getMainAxisFromPlacement(placement);
692
+ const crossAxis = getCrossAxis(mainAxis);
693
+ let mainAxisCoord = coords[mainAxis];
694
+ let crossAxisCoord = coords[crossAxis];
695
+ const rawOffset = typeof offset === 'function' ? offset(state) : offset;
696
+ const computedOffset = typeof rawOffset === 'number' ? {
697
+ mainAxis: rawOffset,
698
+ crossAxis: 0
699
+ } : {
700
+ mainAxis: 0,
701
+ crossAxis: 0,
702
+ ...rawOffset
703
+ };
704
+ if (checkMainAxis) {
705
+ const len = mainAxis === 'y' ? 'height' : 'width';
706
+ const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
707
+ const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
708
+ if (mainAxisCoord < limitMin) {
709
+ mainAxisCoord = limitMin;
710
+ } else if (mainAxisCoord > limitMax) {
711
+ mainAxisCoord = limitMax;
712
+ }
713
+ }
714
+ if (checkCrossAxis) {
715
+ var _middlewareData$offse, _middlewareData$offse2;
716
+ const len = mainAxis === 'y' ? 'width' : 'height';
717
+ const isOriginSide = ['top', 'left'].includes(getSide(placement));
718
+ const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
719
+ const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
720
+ if (crossAxisCoord < limitMin) {
721
+ crossAxisCoord = limitMin;
722
+ } else if (crossAxisCoord > limitMax) {
723
+ crossAxisCoord = limitMax;
724
+ }
725
+ }
726
+ return {
727
+ [mainAxis]: mainAxisCoord,
728
+ [crossAxis]: crossAxisCoord
729
+ };
730
+ }
731
+ };
732
+ };
733
+
734
+ function getWindow(node) {
735
+ var _node$ownerDocument;
736
+ return ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
737
+ }
738
+
739
+ function getComputedStyle$1(element) {
740
+ return getWindow(element).getComputedStyle(element);
741
+ }
742
+
743
+ function isNode(value) {
744
+ return value instanceof getWindow(value).Node;
745
+ }
746
+ function getNodeName(node) {
747
+ return isNode(node) ? (node.nodeName || '').toLowerCase() : '';
748
+ }
749
+
750
+ let uaString;
751
+ function getUAString() {
752
+ if (uaString) {
753
+ return uaString;
754
+ }
755
+ const uaData = navigator.userAgentData;
756
+ if (uaData && Array.isArray(uaData.brands)) {
757
+ uaString = uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
758
+ return uaString;
759
+ }
760
+ return navigator.userAgent;
761
+ }
762
+
763
+ function isHTMLElement(value) {
764
+ return value instanceof getWindow(value).HTMLElement;
765
+ }
766
+ function isElement(value) {
767
+ return value instanceof getWindow(value).Element;
768
+ }
769
+ function isShadowRoot(node) {
770
+ // Browsers without `ShadowRoot` support.
771
+ if (typeof ShadowRoot === 'undefined') {
772
+ return false;
773
+ }
774
+ const OwnElement = getWindow(node).ShadowRoot;
775
+ return node instanceof OwnElement || node instanceof ShadowRoot;
776
+ }
777
+ function isOverflowElement(element) {
778
+ const {
779
+ overflow,
780
+ overflowX,
781
+ overflowY,
782
+ display
783
+ } = getComputedStyle$1(element);
784
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
785
+ }
786
+ function isTableElement(element) {
787
+ return ['table', 'td', 'th'].includes(getNodeName(element));
788
+ }
789
+ function isContainingBlock(element) {
790
+ // TODO: Try to use feature detection here instead.
791
+ const isFirefox = /firefox/i.test(getUAString());
792
+ const css = getComputedStyle$1(element);
793
+ const backdropFilter = css.backdropFilter || css.WebkitBackdropFilter;
794
+
795
+ // This is non-exhaustive but covers the most common CSS properties that
796
+ // create a containing block.
797
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
798
+ return css.transform !== 'none' || css.perspective !== 'none' || (backdropFilter ? backdropFilter !== 'none' : false) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective'].some(value => css.willChange.includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => {
799
+ // Add type check for old browsers.
800
+ const contain = css.contain;
801
+ return contain != null ? contain.includes(value) : false;
802
+ });
803
+ }
804
+
805
+ /**
806
+ * Determines whether or not `.getBoundingClientRect()` is affected by visual
807
+ * viewport offsets. In Safari, the `x`/`y` offsets are values relative to the
808
+ * visual viewport, while in other engines, they are values relative to the
809
+ * layout viewport.
810
+ */
811
+ function isClientRectVisualViewportBased() {
812
+ // TODO: Try to use feature detection here instead. Feature detection for
813
+ // this can fail in various ways, making the userAgent check the most
814
+ // reliable:
815
+ // • Always-visible scrollbar or not
816
+ // • Width of <html>
817
+
818
+ // Is Safari.
819
+ return /^((?!chrome|android).)*safari/i.test(getUAString());
820
+ }
821
+ function isLastTraversableNode(node) {
822
+ return ['html', 'body', '#document'].includes(getNodeName(node));
823
+ }
824
+
825
+ const min = Math.min;
826
+ const max = Math.max;
827
+ const round = Math.round;
828
+
829
+ function getCssDimensions(element) {
830
+ const css = getComputedStyle$1(element);
831
+ // In testing environments, the `width` and `height` properties are empty
832
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
833
+ let width = parseFloat(css.width) || 0;
834
+ let height = parseFloat(css.height) || 0;
835
+ const hasOffset = isHTMLElement(element);
836
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
837
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
838
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
839
+ if (shouldFallback) {
840
+ width = offsetWidth;
841
+ height = offsetHeight;
842
+ }
843
+ return {
844
+ width,
845
+ height,
846
+ fallback: shouldFallback
847
+ };
848
+ }
849
+
850
+ function unwrapElement(element) {
851
+ return !isElement(element) ? element.contextElement : element;
852
+ }
853
+
854
+ const FALLBACK_SCALE = {
855
+ x: 1,
856
+ y: 1
857
+ };
858
+ function getScale(element) {
859
+ const domElement = unwrapElement(element);
860
+ if (!isHTMLElement(domElement)) {
861
+ return FALLBACK_SCALE;
862
+ }
863
+ const rect = domElement.getBoundingClientRect();
864
+ const {
865
+ width,
866
+ height,
867
+ fallback
868
+ } = getCssDimensions(domElement);
869
+ let x = (fallback ? round(rect.width) : rect.width) / width;
870
+ let y = (fallback ? round(rect.height) : rect.height) / height;
871
+
872
+ // 0, NaN, or Infinity should always fallback to 1.
873
+
874
+ if (!x || !Number.isFinite(x)) {
875
+ x = 1;
876
+ }
877
+ if (!y || !Number.isFinite(y)) {
878
+ y = 1;
879
+ }
880
+ return {
881
+ x,
882
+ y
883
+ };
884
+ }
885
+
886
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
887
+ var _win$visualViewport, _win$visualViewport2;
888
+ if (includeScale === void 0) {
889
+ includeScale = false;
890
+ }
891
+ if (isFixedStrategy === void 0) {
892
+ isFixedStrategy = false;
893
+ }
894
+ const clientRect = element.getBoundingClientRect();
895
+ const domElement = unwrapElement(element);
896
+ let scale = FALLBACK_SCALE;
897
+ if (includeScale) {
898
+ if (offsetParent) {
899
+ if (isElement(offsetParent)) {
900
+ scale = getScale(offsetParent);
901
+ }
902
+ } else {
903
+ scale = getScale(element);
904
+ }
905
+ }
906
+ const win = domElement ? getWindow(domElement) : window;
907
+ const addVisualOffsets = isClientRectVisualViewportBased() && isFixedStrategy;
908
+ let x = (clientRect.left + (addVisualOffsets ? ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0 : 0)) / scale.x;
909
+ let y = (clientRect.top + (addVisualOffsets ? ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0 : 0)) / scale.y;
910
+ let width = clientRect.width / scale.x;
911
+ let height = clientRect.height / scale.y;
912
+ if (domElement) {
913
+ const win = getWindow(domElement);
914
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
915
+ let currentIFrame = win.frameElement;
916
+ while (currentIFrame && offsetParent && offsetWin !== win) {
917
+ const iframeScale = getScale(currentIFrame);
918
+ const iframeRect = currentIFrame.getBoundingClientRect();
919
+ const css = getComputedStyle(currentIFrame);
920
+ iframeRect.x += (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
921
+ iframeRect.y += (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
922
+ x *= iframeScale.x;
923
+ y *= iframeScale.y;
924
+ width *= iframeScale.x;
925
+ height *= iframeScale.y;
926
+ x += iframeRect.x;
927
+ y += iframeRect.y;
928
+ currentIFrame = getWindow(currentIFrame).frameElement;
929
+ }
930
+ }
931
+ return rectToClientRect({
932
+ width,
933
+ height,
934
+ x,
935
+ y
936
+ });
937
+ }
938
+
939
+ function getDocumentElement(node) {
940
+ return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
941
+ }
942
+
943
+ function getNodeScroll(element) {
944
+ if (isElement(element)) {
945
+ return {
946
+ scrollLeft: element.scrollLeft,
947
+ scrollTop: element.scrollTop
948
+ };
949
+ }
950
+ return {
951
+ scrollLeft: element.pageXOffset,
952
+ scrollTop: element.pageYOffset
953
+ };
954
+ }
955
+
956
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
957
+ let {
958
+ rect,
959
+ offsetParent,
960
+ strategy
961
+ } = _ref;
962
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
963
+ const documentElement = getDocumentElement(offsetParent);
964
+ if (offsetParent === documentElement) {
965
+ return rect;
966
+ }
967
+ let scroll = {
968
+ scrollLeft: 0,
969
+ scrollTop: 0
970
+ };
971
+ let scale = {
972
+ x: 1,
973
+ y: 1
974
+ };
975
+ const offsets = {
976
+ x: 0,
977
+ y: 0
978
+ };
979
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
980
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
981
+ scroll = getNodeScroll(offsetParent);
982
+ }
983
+ if (isHTMLElement(offsetParent)) {
984
+ const offsetRect = getBoundingClientRect(offsetParent);
985
+ scale = getScale(offsetParent);
986
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
987
+ offsets.y = offsetRect.y + offsetParent.clientTop;
988
+ }
989
+ }
990
+ return {
991
+ width: rect.width * scale.x,
992
+ height: rect.height * scale.y,
993
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
994
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
995
+ };
996
+ }
997
+
998
+ function getWindowScrollBarX(element) {
999
+ // If <html> has a CSS width greater than the viewport, then this will be
1000
+ // incorrect for RTL.
1001
+ return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
1002
+ }
1003
+
1004
+ // Gets the entire size of the scrollable document area, even extending outside
1005
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
1006
+ function getDocumentRect(element) {
1007
+ const html = getDocumentElement(element);
1008
+ const scroll = getNodeScroll(element);
1009
+ const body = element.ownerDocument.body;
1010
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1011
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1012
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1013
+ const y = -scroll.scrollTop;
1014
+ if (getComputedStyle$1(body).direction === 'rtl') {
1015
+ x += max(html.clientWidth, body.clientWidth) - width;
1016
+ }
1017
+ return {
1018
+ width,
1019
+ height,
1020
+ x,
1021
+ y
1022
+ };
1023
+ }
1024
+
1025
+ function getParentNode(node) {
1026
+ if (getNodeName(node) === 'html') {
1027
+ return node;
1028
+ }
1029
+ const result =
1030
+ // Step into the shadow DOM of the parent of a slotted node.
1031
+ node.assignedSlot ||
1032
+ // DOM Element detected.
1033
+ node.parentNode ||
1034
+ // ShadowRoot detected.
1035
+ isShadowRoot(node) && node.host ||
1036
+ // Fallback.
1037
+ getDocumentElement(node);
1038
+ return isShadowRoot(result) ? result.host : result;
1039
+ }
1040
+
1041
+ function getNearestOverflowAncestor(node) {
1042
+ const parentNode = getParentNode(node);
1043
+ if (isLastTraversableNode(parentNode)) {
1044
+ // `getParentNode` will never return a `Document` due to the fallback
1045
+ // check, so it's either the <html> or <body> element.
1046
+ return parentNode.ownerDocument.body;
1047
+ }
1048
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1049
+ return parentNode;
1050
+ }
1051
+ return getNearestOverflowAncestor(parentNode);
1052
+ }
1053
+
1054
+ function getOverflowAncestors(node, list) {
1055
+ var _node$ownerDocument;
1056
+ if (list === void 0) {
1057
+ list = [];
1058
+ }
1059
+ const scrollableAncestor = getNearestOverflowAncestor(node);
1060
+ const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
1061
+ const win = getWindow(scrollableAncestor);
1062
+ if (isBody) {
1063
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []);
1064
+ }
1065
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor));
1066
+ }
1067
+
1068
+ function getViewportRect(element, strategy) {
1069
+ const win = getWindow(element);
1070
+ const html = getDocumentElement(element);
1071
+ const visualViewport = win.visualViewport;
1072
+ let width = html.clientWidth;
1073
+ let height = html.clientHeight;
1074
+ let x = 0;
1075
+ let y = 0;
1076
+ if (visualViewport) {
1077
+ width = visualViewport.width;
1078
+ height = visualViewport.height;
1079
+ const visualViewportBased = isClientRectVisualViewportBased();
1080
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
1081
+ x = visualViewport.offsetLeft;
1082
+ y = visualViewport.offsetTop;
1083
+ }
1084
+ }
1085
+ return {
1086
+ width,
1087
+ height,
1088
+ x,
1089
+ y
1090
+ };
1091
+ }
1092
+
1093
+ // Returns the inner client rect, subtracting scrollbars if present.
1094
+ function getInnerBoundingClientRect(element, strategy) {
1095
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
1096
+ const top = clientRect.top + element.clientTop;
1097
+ const left = clientRect.left + element.clientLeft;
1098
+ const scale = isHTMLElement(element) ? getScale(element) : {
1099
+ x: 1,
1100
+ y: 1
1101
+ };
1102
+ const width = element.clientWidth * scale.x;
1103
+ const height = element.clientHeight * scale.y;
1104
+ const x = left * scale.x;
1105
+ const y = top * scale.y;
1106
+ return {
1107
+ width,
1108
+ height,
1109
+ x,
1110
+ y
1111
+ };
1112
+ }
1113
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1114
+ let rect;
1115
+ if (clippingAncestor === 'viewport') {
1116
+ rect = getViewportRect(element, strategy);
1117
+ } else if (clippingAncestor === 'document') {
1118
+ rect = getDocumentRect(getDocumentElement(element));
1119
+ } else if (isElement(clippingAncestor)) {
1120
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1121
+ } else {
1122
+ const mutableRect = {
1123
+ ...clippingAncestor
1124
+ };
1125
+ if (isClientRectVisualViewportBased()) {
1126
+ var _win$visualViewport, _win$visualViewport2;
1127
+ const win = getWindow(element);
1128
+ mutableRect.x -= ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0;
1129
+ mutableRect.y -= ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0;
1130
+ }
1131
+ rect = mutableRect;
1132
+ }
1133
+ return rectToClientRect(rect);
1134
+ }
1135
+ function hasFixedPositionAncestor(element, stopNode) {
1136
+ const parentNode = getParentNode(element);
1137
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1138
+ return false;
1139
+ }
1140
+ return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
1141
+ }
1142
+
1143
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
1144
+ // clipping (or hiding) child elements. This returns all clipping ancestors
1145
+ // of the given element up the tree.
1146
+ function getClippingElementAncestors(element, cache) {
1147
+ const cachedResult = cache.get(element);
1148
+ if (cachedResult) {
1149
+ return cachedResult;
1150
+ }
1151
+ let result = getOverflowAncestors(element).filter(el => isElement(el) && getNodeName(el) !== 'body');
1152
+ let currentContainingBlockComputedStyle = null;
1153
+ const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
1154
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
1155
+
1156
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1157
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1158
+ const computedStyle = getComputedStyle$1(currentNode);
1159
+ const currentNodeIsContaining = isContainingBlock(currentNode);
1160
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1161
+ currentContainingBlockComputedStyle = null;
1162
+ }
1163
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1164
+ if (shouldDropCurrentNode) {
1165
+ // Drop non-containing blocks.
1166
+ result = result.filter(ancestor => ancestor !== currentNode);
1167
+ } else {
1168
+ // Record last containing block for next iteration.
1169
+ currentContainingBlockComputedStyle = computedStyle;
1170
+ }
1171
+ currentNode = getParentNode(currentNode);
1172
+ }
1173
+ cache.set(element, result);
1174
+ return result;
1175
+ }
1176
+
1177
+ // Gets the maximum area that the element is visible in due to any number of
1178
+ // clipping ancestors.
1179
+ function getClippingRect(_ref) {
1180
+ let {
1181
+ element,
1182
+ boundary,
1183
+ rootBoundary,
1184
+ strategy
1185
+ } = _ref;
1186
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
1187
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1188
+ const firstClippingAncestor = clippingAncestors[0];
1189
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1190
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1191
+ accRect.top = max(rect.top, accRect.top);
1192
+ accRect.right = min(rect.right, accRect.right);
1193
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1194
+ accRect.left = max(rect.left, accRect.left);
1195
+ return accRect;
1196
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1197
+ return {
1198
+ width: clippingRect.right - clippingRect.left,
1199
+ height: clippingRect.bottom - clippingRect.top,
1200
+ x: clippingRect.left,
1201
+ y: clippingRect.top
1202
+ };
1203
+ }
1204
+
1205
+ function getDimensions(element) {
1206
+ return getCssDimensions(element);
1207
+ }
1208
+
1209
+ function getTrueOffsetParent(element, polyfill) {
1210
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
1211
+ return null;
1212
+ }
1213
+ if (polyfill) {
1214
+ return polyfill(element);
1215
+ }
1216
+ return element.offsetParent;
1217
+ }
1218
+ function getContainingBlock(element) {
1219
+ let currentNode = getParentNode(element);
1220
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1221
+ if (isContainingBlock(currentNode)) {
1222
+ return currentNode;
1223
+ } else {
1224
+ currentNode = getParentNode(currentNode);
1225
+ }
1226
+ }
1227
+ return null;
1228
+ }
1229
+
1230
+ // Gets the closest ancestor positioned element. Handles some edge cases,
1231
+ // such as table ancestors and cross browser bugs.
1232
+ function getOffsetParent(element, polyfill) {
1233
+ const window = getWindow(element);
1234
+ if (!isHTMLElement(element)) {
1235
+ return window;
1236
+ }
1237
+ let offsetParent = getTrueOffsetParent(element, polyfill);
1238
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
1239
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1240
+ }
1241
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
1242
+ return window;
1243
+ }
1244
+ return offsetParent || getContainingBlock(element) || window;
1245
+ }
1246
+
1247
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1248
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1249
+ const documentElement = getDocumentElement(offsetParent);
1250
+ const rect = getBoundingClientRect(element, true, strategy === 'fixed', offsetParent);
1251
+ let scroll = {
1252
+ scrollLeft: 0,
1253
+ scrollTop: 0
1254
+ };
1255
+ const offsets = {
1256
+ x: 0,
1257
+ y: 0
1258
+ };
1259
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
1260
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1261
+ scroll = getNodeScroll(offsetParent);
1262
+ }
1263
+ if (isHTMLElement(offsetParent)) {
1264
+ const offsetRect = getBoundingClientRect(offsetParent, true);
1265
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1266
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1267
+ } else if (documentElement) {
1268
+ offsets.x = getWindowScrollBarX(documentElement);
1269
+ }
1270
+ }
1271
+ return {
1272
+ x: rect.left + scroll.scrollLeft - offsets.x,
1273
+ y: rect.top + scroll.scrollTop - offsets.y,
1274
+ width: rect.width,
1275
+ height: rect.height
1276
+ };
1277
+ }
1278
+
1279
+ const platform = {
1280
+ getClippingRect,
1281
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1282
+ isElement,
1283
+ getDimensions,
1284
+ getOffsetParent,
1285
+ getDocumentElement,
1286
+ getScale,
1287
+ async getElementRects(_ref) {
1288
+ let {
1289
+ reference,
1290
+ floating,
1291
+ strategy
1292
+ } = _ref;
1293
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1294
+ const getDimensionsFn = this.getDimensions;
1295
+ return {
1296
+ reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
1297
+ floating: {
1298
+ x: 0,
1299
+ y: 0,
1300
+ ...(await getDimensionsFn(floating))
1301
+ }
1302
+ };
1303
+ },
1304
+ getClientRects: element => Array.from(element.getClientRects()),
1305
+ isRTL: element => getComputedStyle$1(element).direction === 'rtl'
1306
+ };
1307
+
1308
+ /**
1309
+ * Automatically updates the position of the floating element when necessary.
1310
+ * Should only be called when the floating element is mounted on the DOM or
1311
+ * visible on the screen.
1312
+ * @returns cleanup function that should be invoked when the floating element is
1313
+ * removed from the DOM or hidden from the screen.
1314
+ * @see https://floating-ui.com/docs/autoUpdate
1315
+ */
1316
+ function autoUpdate(reference, floating, update, options) {
1317
+ if (options === void 0) {
1318
+ options = {};
1319
+ }
1320
+ const {
1321
+ ancestorScroll = true,
1322
+ ancestorResize = true,
1323
+ elementResize = true,
1324
+ animationFrame = false
1325
+ } = options;
1326
+ const ancestors = ancestorScroll || ancestorResize ? [...(isElement(reference) ? getOverflowAncestors(reference) : reference.contextElement ? getOverflowAncestors(reference.contextElement) : []), ...getOverflowAncestors(floating)] : [];
1327
+ ancestors.forEach(ancestor => {
1328
+ // ignores Window, checks for [object VisualViewport]
1329
+ const isVisualViewport = !isElement(ancestor) && ancestor.toString().includes('V');
1330
+ if (ancestorScroll && (animationFrame ? isVisualViewport : true)) {
1331
+ ancestor.addEventListener('scroll', update, {
1332
+ passive: true
1333
+ });
1334
+ }
1335
+ ancestorResize && ancestor.addEventListener('resize', update);
1336
+ });
1337
+ let observer = null;
1338
+ if (elementResize) {
1339
+ observer = new ResizeObserver(() => {
1340
+ update();
1341
+ });
1342
+ isElement(reference) && !animationFrame && observer.observe(reference);
1343
+ if (!isElement(reference) && reference.contextElement && !animationFrame) {
1344
+ observer.observe(reference.contextElement);
1345
+ }
1346
+ observer.observe(floating);
1347
+ }
1348
+ let frameId;
1349
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1350
+ if (animationFrame) {
1351
+ frameLoop();
1352
+ }
1353
+ function frameLoop() {
1354
+ const nextRefRect = getBoundingClientRect(reference);
1355
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
1356
+ update();
1357
+ }
1358
+ prevRefRect = nextRefRect;
1359
+ frameId = requestAnimationFrame(frameLoop);
1360
+ }
1361
+ update();
1362
+ return () => {
1363
+ var _observer;
1364
+ ancestors.forEach(ancestor => {
1365
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
1366
+ ancestorResize && ancestor.removeEventListener('resize', update);
1367
+ });
1368
+ (_observer = observer) == null ? void 0 : _observer.disconnect();
1369
+ observer = null;
1370
+ if (animationFrame) {
1371
+ cancelAnimationFrame(frameId);
1372
+ }
1373
+ };
1374
+ }
1375
+
1376
+ /**
1377
+ * Computes the `x` and `y` coordinates that will place the floating element
1378
+ * next to a reference element when it is given a certain CSS positioning
1379
+ * strategy.
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
+ export { autoUpdate as a, arrow as b, computePosition as c, flip as f, limitShift as l, offset as o, shift as s };
1401
+
1402
+ //# sourceMappingURL=floating-ui.dom.esm.js.map