@vonage/vivid 3.0.0-next.11 → 3.0.0-next.110

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 (209) hide show
  1. package/README.md +165 -4
  2. package/accordion/index.js +5 -14
  3. package/accordion-item/index.js +34 -41
  4. package/action-group/index.js +37 -0
  5. package/avatar/index.js +61 -0
  6. package/badge/index.js +23 -35
  7. package/banner/index.js +20 -115
  8. package/breadcrumb/index.js +22 -19
  9. package/breadcrumb-item/index.js +28 -25
  10. package/button/index.js +29 -690
  11. package/calendar/index.js +70 -69
  12. package/calendar-event/index.js +109 -0
  13. package/card/index.js +112 -0
  14. package/checkbox/index.js +178 -0
  15. package/custom-elements.json +3941 -0
  16. package/dialog/index.js +214 -0
  17. package/divider/index.js +27 -0
  18. package/elevation/index.js +10 -16
  19. package/fab/index.js +98 -0
  20. package/focus/index.js +18 -3
  21. package/header/index.js +63 -0
  22. package/icon/index.js +9 -12
  23. package/index.js +68 -22
  24. package/layout/index.js +6 -16
  25. package/lib/accordion-item/accordion-item.d.ts +2 -2
  26. package/lib/accordion-item/index.d.ts +0 -1
  27. package/lib/action-group/action-group.d.ts +10 -0
  28. package/lib/{sidenav-item/sidenav-item.template.d.ts → action-group/action-group.template.d.ts} +2 -2
  29. package/lib/{sidenav-item → action-group}/index.d.ts +1 -2
  30. package/lib/avatar/avatar.d.ts +15 -0
  31. package/lib/avatar/avatar.template.d.ts +4 -0
  32. package/lib/avatar/index.d.ts +2 -0
  33. package/lib/badge/badge.d.ts +3 -5
  34. package/lib/badge/index.d.ts +1 -2
  35. package/lib/banner/banner.d.ts +1 -1
  36. package/lib/banner/banner.template.d.ts +0 -2
  37. package/lib/breadcrumb/breadcrumb.template.d.ts +4 -0
  38. package/lib/breadcrumb-item/breadcrumb-item.d.ts +1 -1
  39. package/lib/breadcrumb-item/index.d.ts +0 -1
  40. package/lib/button/button.d.ts +4 -3
  41. package/lib/button/index.d.ts +1 -21
  42. package/lib/calendar/calendar.d.ts +3 -1
  43. package/lib/calendar/index.d.ts +0 -1
  44. package/lib/calendar-event/calendar-event.d.ts +14 -0
  45. package/lib/calendar-event/calendar-event.template.d.ts +4 -0
  46. package/lib/calendar-event/index.d.ts +2 -0
  47. package/lib/card/card.d.ts +10 -0
  48. package/lib/{text/text.template.d.ts → card/card.template.d.ts} +2 -2
  49. package/lib/{text → card}/index.d.ts +1 -1
  50. package/lib/checkbox/checkbox.d.ts +5 -0
  51. package/lib/checkbox/checkbox.template.d.ts +4 -0
  52. package/lib/checkbox/index.d.ts +2 -0
  53. package/lib/components.d.ts +32 -10
  54. package/lib/dialog/dialog.d.ts +20 -0
  55. package/lib/dialog/dialog.template.d.ts +4 -0
  56. package/lib/dialog/index.d.ts +2 -0
  57. package/lib/divider/divider.d.ts +3 -0
  58. package/lib/divider/divider.template.d.ts +4 -0
  59. package/lib/divider/index.d.ts +2 -0
  60. package/lib/elevation/elevation.d.ts +1 -0
  61. package/lib/elevation/index.d.ts +1 -1
  62. package/lib/enums.d.ts +19 -6
  63. package/lib/fab/fab.d.ts +13 -0
  64. package/lib/fab/fab.template.d.ts +4 -0
  65. package/lib/fab/index.d.ts +2 -0
  66. package/lib/focus/index.d.ts +1 -1
  67. package/lib/header/header.d.ts +5 -0
  68. package/lib/header/header.template.d.ts +4 -0
  69. package/lib/header/index.d.ts +2 -0
  70. package/lib/icon/icon.d.ts +5 -6
  71. package/lib/layout/index.d.ts +1 -1
  72. package/lib/layout/layout.d.ts +4 -4
  73. package/lib/listbox/index.d.ts +1 -0
  74. package/lib/listbox/listbox.d.ts +9 -0
  75. package/lib/listbox/listbox.template.d.ts +4 -0
  76. package/lib/menu/index.d.ts +10 -0
  77. package/lib/menu/menu.d.ts +10 -0
  78. package/lib/menu/menu.template.d.ts +3 -0
  79. package/lib/menu-item/index.d.ts +2 -0
  80. package/lib/menu-item/menu-item.d.ts +7 -0
  81. package/lib/menu-item/menu-item.template.d.ts +5 -0
  82. package/lib/nav/index.d.ts +2 -0
  83. package/lib/nav/nav.d.ts +3 -0
  84. package/lib/nav/nav.template.d.ts +4 -0
  85. package/lib/nav-disclosure/index.d.ts +2 -0
  86. package/lib/nav-disclosure/nav-disclosure.d.ts +10 -0
  87. package/lib/nav-disclosure/nav-disclosure.template.d.ts +4 -0
  88. package/lib/nav-item/index.d.ts +2 -0
  89. package/lib/{sidenav-item/sidenav-item.d.ts → nav-item/nav-item.d.ts} +2 -2
  90. package/lib/nav-item/nav-item.template.d.ts +4 -0
  91. package/lib/note/index.d.ts +2 -0
  92. package/lib/note/note.d.ts +10 -0
  93. package/lib/note/note.template.d.ts +4 -0
  94. package/lib/number-field/index.d.ts +2 -0
  95. package/lib/number-field/number-field.d.ts +14 -0
  96. package/lib/number-field/number-field.template.d.ts +4 -0
  97. package/lib/option/index.d.ts +2 -0
  98. package/lib/option/option.d.ts +9 -0
  99. package/lib/option/option.template.d.ts +4 -0
  100. package/lib/popup/index.d.ts +1 -3
  101. package/lib/popup/popup.d.ts +3 -2
  102. package/lib/progress/progress.d.ts +1 -1
  103. package/lib/progress-ring/progress-ring.d.ts +2 -1
  104. package/lib/radio/index.d.ts +2 -0
  105. package/lib/radio/radio.d.ts +4 -0
  106. package/lib/radio/radio.template.d.ts +4 -0
  107. package/lib/radio-group/index.d.ts +10 -0
  108. package/lib/radio-group/radio-group.d.ts +4 -0
  109. package/lib/radio-group/radio-group.template.d.ts +4 -0
  110. package/lib/side-drawer/index.d.ts +1 -1
  111. package/lib/side-drawer/side-drawer.d.ts +3 -2
  112. package/lib/slider/index.d.ts +2 -0
  113. package/lib/slider/slider.d.ts +4 -0
  114. package/lib/slider/slider.template.d.ts +4 -0
  115. package/lib/switch/index.d.ts +2 -0
  116. package/lib/switch/switch.d.ts +7 -0
  117. package/lib/switch/switch.template.d.ts +4 -0
  118. package/lib/text-anchor/text-anchor.d.ts +1 -1
  119. package/lib/text-area/index.d.ts +2 -0
  120. package/lib/text-area/text-area.d.ts +9 -0
  121. package/lib/text-area/text-area.template.d.ts +4 -0
  122. package/lib/text-field/index.d.ts +2 -0
  123. package/lib/text-field/text-field.d.ts +14 -0
  124. package/lib/text-field/text-field.template.d.ts +4 -0
  125. package/lib/tooltip/index.d.ts +0 -1
  126. package/lib/tooltip/tooltip.d.ts +7 -7
  127. package/listbox/index.js +1086 -0
  128. package/menu/index.js +357 -0
  129. package/menu-item/index.js +90 -0
  130. package/nav/index.js +17 -0
  131. package/nav-disclosure/index.js +80 -0
  132. package/nav-item/index.js +44 -0
  133. package/note/index.js +59 -0
  134. package/number-field/index.js +460 -0
  135. package/option/index.js +75 -0
  136. package/package.json +62 -10
  137. package/popup/index.js +35 -2036
  138. package/progress/index.js +33 -38
  139. package/progress-ring/index.js +13 -13
  140. package/radio/index.js +52 -0
  141. package/radio-group/index.js +435 -0
  142. package/shared/affix.js +2 -8
  143. package/shared/anchor.js +11 -3
  144. package/shared/apply-mixins.js +5 -4
  145. package/shared/aria-global.js +2 -86
  146. package/shared/aria.js +9 -0
  147. package/shared/base-progress.js +6 -1
  148. package/shared/breadcrumb-item.js +2 -2
  149. package/shared/button.js +23 -0
  150. package/shared/button2.js +200 -0
  151. package/shared/calendar-event.js +19 -0
  152. package/shared/design-system/index.d.ts +1 -1
  153. package/shared/dialog-polyfill.esm.js +858 -0
  154. package/shared/direction.js +20 -0
  155. package/shared/divider.js +55 -0
  156. package/shared/dom.js +8 -0
  157. package/shared/elevation.js +10 -0
  158. package/shared/enums.js +70 -0
  159. package/shared/es.object.assign.js +2 -59
  160. package/shared/es.promise.resolve.js +944 -0
  161. package/shared/es.regexp.to-string.js +58 -0
  162. package/shared/focus.js +11 -0
  163. package/shared/focus2.js +5 -0
  164. package/shared/form-associated.js +466 -0
  165. package/shared/form-elements.js +343 -0
  166. package/shared/icon.js +32 -1153
  167. package/shared/index.js +3780 -83
  168. package/shared/index2.js +7 -19
  169. package/shared/key-codes.js +97 -0
  170. package/shared/listbox-option.js +201 -0
  171. package/shared/menu-item.js +277 -0
  172. package/shared/numbers.js +25 -0
  173. package/shared/patterns/focus.d.ts +3 -0
  174. package/shared/patterns/form-elements/form-elements.d.ts +31 -0
  175. package/shared/patterns/form-elements/index.d.ts +1 -0
  176. package/shared/patterns/index.d.ts +2 -0
  177. package/shared/popup.js +1484 -0
  178. package/shared/radio.js +127 -0
  179. package/shared/ref.js +41 -0
  180. package/shared/slotted.js +1 -1
  181. package/shared/start-end.js +50 -0
  182. package/shared/string-trim.js +39 -0
  183. package/shared/text-anchor.js +2 -13
  184. package/shared/text-anchor.template.js +6 -5
  185. package/shared/utils/index.d.ts +1 -0
  186. package/side-drawer/index.js +38 -34
  187. package/slider/index.js +596 -0
  188. package/styles/core/all.css +86 -0
  189. package/styles/core/theme.css +11 -0
  190. package/styles/core/typography.css +80 -0
  191. package/styles/fonts/SpeziaCompleteVariableItalicWeb.woff2 +0 -0
  192. package/styles/fonts/SpeziaCompleteVariableUprightWeb.woff2 +0 -0
  193. package/styles/fonts/SpeziaMonoCompleteVariableWeb.woff2 +0 -0
  194. package/styles/fonts/spezia.css +9 -12
  195. package/styles/tokens/theme-dark.css +230 -0
  196. package/styles/tokens/theme-light.css +230 -0
  197. package/switch/index.js +153 -0
  198. package/text-anchor/index.js +8 -3
  199. package/text-area/index.js +288 -0
  200. package/text-field/index.js +129 -0
  201. package/tooltip/index.js +59 -43
  202. package/vivid.api.json +2979 -0
  203. package/lib/text/text.d.ts +0 -10
  204. package/shared/style-inject.es.js +0 -28
  205. package/shared/web.dom-collections.iterator.js +0 -1479
  206. package/sidenav-item/index.js +0 -38
  207. package/styles/themes/dark.css +0 -205
  208. package/styles/themes/light.css +0 -205
  209. package/text/index.js +0 -45
@@ -0,0 +1,1484 @@
1
+ import { F as FoundationElement, Y as __classPrivateFieldGet, a9 as __classPrivateFieldSet, _ as __decorate, a as attr, b as __metadata } from './index.js';
2
+ import './es.promise.resolve.js';
3
+ import './es.object.assign.js';
4
+ import { b as keyEscape } from './key-codes.js';
5
+
6
+ function getSide(placement) {
7
+ return placement.split('-')[0];
8
+ }
9
+
10
+ function getAlignment(placement) {
11
+ return placement.split('-')[1];
12
+ }
13
+
14
+ function getMainAxisFromPlacement(placement) {
15
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
16
+ }
17
+
18
+ function getLengthFromAxis(axis) {
19
+ return axis === 'y' ? 'height' : 'width';
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
+
36
+ switch (side) {
37
+ case 'top':
38
+ coords = {
39
+ x: commonX,
40
+ y: reference.y - floating.height
41
+ };
42
+ break;
43
+
44
+ case 'bottom':
45
+ coords = {
46
+ x: commonX,
47
+ y: reference.y + reference.height
48
+ };
49
+ break;
50
+
51
+ case 'right':
52
+ coords = {
53
+ x: reference.x + reference.width,
54
+ y: commonY
55
+ };
56
+ break;
57
+
58
+ case 'left':
59
+ coords = {
60
+ x: reference.x - floating.width,
61
+ y: commonY
62
+ };
63
+ break;
64
+
65
+ default:
66
+ coords = {
67
+ x: reference.x,
68
+ y: reference.y
69
+ };
70
+ }
71
+
72
+ switch (getAlignment(placement)) {
73
+ case 'start':
74
+ coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
75
+ break;
76
+
77
+ case 'end':
78
+ coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
79
+ break;
80
+ }
81
+
82
+ return coords;
83
+ }
84
+
85
+ /**
86
+ * Computes the `x` and `y` coordinates that will place the floating element
87
+ * next to a reference element when it is given a certain positioning strategy.
88
+ *
89
+ * This export does not have any `platform` interface logic. You will need to
90
+ * write one for the platform you are using Floating UI with.
91
+ */
92
+
93
+ const computePosition$1 = async (reference, floating, config) => {
94
+ const {
95
+ placement = 'bottom',
96
+ strategy = 'absolute',
97
+ middleware = [],
98
+ platform
99
+ } = config;
100
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
101
+
102
+ let rects = await platform.getElementRects({
103
+ reference,
104
+ floating,
105
+ strategy
106
+ });
107
+ let {
108
+ x,
109
+ y
110
+ } = computeCoordsFromPlacement(rects, placement, rtl);
111
+ let statefulPlacement = placement;
112
+ let middlewareData = {};
113
+ let resetCount = 0;
114
+
115
+ for (let i = 0; i < middleware.length; i++) {
116
+ const {
117
+ name,
118
+ fn
119
+ } = middleware[i];
120
+ const {
121
+ x: nextX,
122
+ y: nextY,
123
+ data,
124
+ reset
125
+ } = await fn({
126
+ x,
127
+ y,
128
+ initialPlacement: placement,
129
+ placement: statefulPlacement,
130
+ strategy,
131
+ middlewareData,
132
+ rects,
133
+ platform,
134
+ elements: {
135
+ reference,
136
+ floating
137
+ }
138
+ });
139
+ x = nextX != null ? nextX : x;
140
+ y = nextY != null ? nextY : y;
141
+ middlewareData = { ...middlewareData,
142
+ [name]: { ...middlewareData[name],
143
+ ...data
144
+ }
145
+ };
146
+
147
+ if (reset && resetCount <= 50) {
148
+ resetCount++;
149
+
150
+ if (typeof reset === 'object') {
151
+ if (reset.placement) {
152
+ statefulPlacement = reset.placement;
153
+ }
154
+
155
+ if (reset.rects) {
156
+ rects = reset.rects === true ? await platform.getElementRects({
157
+ reference,
158
+ floating,
159
+ strategy
160
+ }) : reset.rects;
161
+ }
162
+
163
+ ({
164
+ x,
165
+ y
166
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
167
+ }
168
+
169
+ i = -1;
170
+ continue;
171
+ }
172
+ }
173
+
174
+ return {
175
+ x,
176
+ y,
177
+ placement: statefulPlacement,
178
+ strategy,
179
+ middlewareData
180
+ };
181
+ };
182
+
183
+ function expandPaddingObject(padding) {
184
+ return {
185
+ top: 0,
186
+ right: 0,
187
+ bottom: 0,
188
+ left: 0,
189
+ ...padding
190
+ };
191
+ }
192
+
193
+ function getSideObjectFromPadding(padding) {
194
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
195
+ top: padding,
196
+ right: padding,
197
+ bottom: padding,
198
+ left: padding
199
+ };
200
+ }
201
+
202
+ function rectToClientRect(rect) {
203
+ return { ...rect,
204
+ top: rect.y,
205
+ left: rect.x,
206
+ right: rect.x + rect.width,
207
+ bottom: rect.y + rect.height
208
+ };
209
+ }
210
+
211
+ /**
212
+ * Resolves with an object of overflow side offsets that determine how much the
213
+ * element is overflowing a given clipping boundary.
214
+ * - positive = overflowing the boundary by that number of pixels
215
+ * - negative = how many pixels left before it will overflow
216
+ * - 0 = lies flush with the boundary
217
+ * @see https://floating-ui.com/docs/detectOverflow
218
+ */
219
+ async function detectOverflow(middlewareArguments, options) {
220
+ var _await$platform$isEle;
221
+
222
+ if (options === void 0) {
223
+ options = {};
224
+ }
225
+
226
+ const {
227
+ x,
228
+ y,
229
+ platform,
230
+ rects,
231
+ elements,
232
+ strategy
233
+ } = middlewareArguments;
234
+ const {
235
+ boundary = 'clippingAncestors',
236
+ rootBoundary = 'viewport',
237
+ elementContext = 'floating',
238
+ altBoundary = false,
239
+ padding = 0
240
+ } = options;
241
+ const paddingObject = getSideObjectFromPadding(padding);
242
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
243
+ const element = elements[altBoundary ? altContext : elementContext];
244
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
245
+ 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))),
246
+ boundary,
247
+ rootBoundary,
248
+ strategy
249
+ }));
250
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
251
+ rect: elementContext === 'floating' ? { ...rects.floating,
252
+ x,
253
+ y
254
+ } : rects.reference,
255
+ offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
256
+ strategy
257
+ }) : rects[elementContext]);
258
+ return {
259
+ top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
260
+ bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
261
+ left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
262
+ right: elementClientRect.right - clippingClientRect.right + paddingObject.right
263
+ };
264
+ }
265
+
266
+ const min$1 = Math.min;
267
+ const max$1 = Math.max;
268
+
269
+ function within(min$1$1, value, max$1$1) {
270
+ return max$1(min$1$1, min$1(value, max$1$1));
271
+ }
272
+
273
+ /**
274
+ * Positions an inner element of the floating element such that it is centered
275
+ * to the reference element.
276
+ * @see https://floating-ui.com/docs/arrow
277
+ */
278
+ const arrow = options => ({
279
+ name: 'arrow',
280
+ options,
281
+
282
+ async fn(middlewareArguments) {
283
+ // Since `element` is required, we don't Partial<> the type
284
+ const {
285
+ element,
286
+ padding = 0
287
+ } = options != null ? options : {};
288
+ const {
289
+ x,
290
+ y,
291
+ placement,
292
+ rects,
293
+ platform
294
+ } = middlewareArguments;
295
+
296
+ if (element == null) {
297
+
298
+ return {};
299
+ }
300
+
301
+ const paddingObject = getSideObjectFromPadding(padding);
302
+ const coords = {
303
+ x,
304
+ y
305
+ };
306
+ const axis = getMainAxisFromPlacement(placement);
307
+ const alignment = getAlignment(placement);
308
+ const length = getLengthFromAxis(axis);
309
+ const arrowDimensions = await platform.getDimensions(element);
310
+ const minProp = axis === 'y' ? 'top' : 'left';
311
+ const maxProp = axis === 'y' ? 'bottom' : 'right';
312
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
313
+ const startDiff = coords[axis] - rects.reference[axis];
314
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
315
+ let clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
316
+
317
+ if (clientSize === 0) {
318
+ clientSize = rects.floating[length];
319
+ }
320
+
321
+ const centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the floating element if the center
322
+ // point is outside the floating element's bounds
323
+
324
+ const min = paddingObject[minProp];
325
+ const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
326
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
327
+ const offset = within(min, center, max); // Make sure that arrow points at the reference
328
+
329
+ const alignmentPadding = alignment === 'start' ? paddingObject[minProp] : paddingObject[maxProp];
330
+ const shouldAddOffset = alignmentPadding > 0 && center !== offset && rects.reference[length] <= rects.floating[length];
331
+ const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;
332
+ return {
333
+ [axis]: coords[axis] - alignmentOffset,
334
+ data: {
335
+ [axis]: offset,
336
+ centerOffset: center - offset
337
+ }
338
+ };
339
+ }
340
+
341
+ });
342
+
343
+ const hash$1 = {
344
+ left: 'right',
345
+ right: 'left',
346
+ bottom: 'top',
347
+ top: 'bottom'
348
+ };
349
+ function getOppositePlacement(placement) {
350
+ return placement.replace(/left|right|bottom|top/g, matched => hash$1[matched]);
351
+ }
352
+
353
+ function getAlignmentSides(placement, rects, rtl) {
354
+ if (rtl === void 0) {
355
+ rtl = false;
356
+ }
357
+
358
+ const alignment = getAlignment(placement);
359
+ const mainAxis = getMainAxisFromPlacement(placement);
360
+ const length = getLengthFromAxis(mainAxis);
361
+ let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
362
+
363
+ if (rects.reference[length] > rects.floating[length]) {
364
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
365
+ }
366
+
367
+ return {
368
+ main: mainAlignmentSide,
369
+ cross: getOppositePlacement(mainAlignmentSide)
370
+ };
371
+ }
372
+
373
+ const hash = {
374
+ start: 'end',
375
+ end: 'start'
376
+ };
377
+ function getOppositeAlignmentPlacement(placement) {
378
+ return placement.replace(/start|end/g, matched => hash[matched]);
379
+ }
380
+
381
+ const sides = ['top', 'right', 'bottom', 'left'];
382
+
383
+ function getExpandedPlacements(placement) {
384
+ const oppositePlacement = getOppositePlacement(placement);
385
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
386
+ }
387
+
388
+ /**
389
+ * Changes the placement of the floating element to one that will fit if the
390
+ * initially specified `placement` does not.
391
+ * @see https://floating-ui.com/docs/flip
392
+ */
393
+ const flip = function (options) {
394
+ if (options === void 0) {
395
+ options = {};
396
+ }
397
+
398
+ return {
399
+ name: 'flip',
400
+ options,
401
+
402
+ async fn(middlewareArguments) {
403
+ var _middlewareData$flip;
404
+
405
+ const {
406
+ placement,
407
+ middlewareData,
408
+ rects,
409
+ initialPlacement,
410
+ platform,
411
+ elements
412
+ } = middlewareArguments;
413
+ const {
414
+ mainAxis: checkMainAxis = true,
415
+ crossAxis: checkCrossAxis = true,
416
+ fallbackPlacements: specifiedFallbackPlacements,
417
+ fallbackStrategy = 'bestFit',
418
+ flipAlignment = true,
419
+ ...detectOverflowOptions
420
+ } = options;
421
+ const side = getSide(placement);
422
+ const isBasePlacement = side === initialPlacement;
423
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
424
+ const placements = [initialPlacement, ...fallbackPlacements];
425
+ const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
426
+ const overflows = [];
427
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
428
+
429
+ if (checkMainAxis) {
430
+ overflows.push(overflow[side]);
431
+ }
432
+
433
+ if (checkCrossAxis) {
434
+ const {
435
+ main,
436
+ cross
437
+ } = getAlignmentSides(placement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
438
+ overflows.push(overflow[main], overflow[cross]);
439
+ }
440
+
441
+ overflowsData = [...overflowsData, {
442
+ placement,
443
+ overflows
444
+ }]; // One or more sides is overflowing
445
+
446
+ if (!overflows.every(side => side <= 0)) {
447
+ var _middlewareData$flip$, _middlewareData$flip2;
448
+
449
+ const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
450
+ const nextPlacement = placements[nextIndex];
451
+
452
+ if (nextPlacement) {
453
+ // Try next placement and re-run the lifecycle
454
+ return {
455
+ data: {
456
+ index: nextIndex,
457
+ overflows: overflowsData
458
+ },
459
+ reset: {
460
+ placement: nextPlacement
461
+ }
462
+ };
463
+ }
464
+
465
+ let resetPlacement = 'bottom';
466
+
467
+ switch (fallbackStrategy) {
468
+ case 'bestFit':
469
+ {
470
+ var _overflowsData$map$so;
471
+
472
+ const placement = (_overflowsData$map$so = overflowsData.map(d => [d, 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].placement;
473
+
474
+ if (placement) {
475
+ resetPlacement = placement;
476
+ }
477
+
478
+ break;
479
+ }
480
+
481
+ case 'initialPlacement':
482
+ resetPlacement = initialPlacement;
483
+ break;
484
+ }
485
+
486
+ if (placement !== resetPlacement) {
487
+ return {
488
+ reset: {
489
+ placement: resetPlacement
490
+ }
491
+ };
492
+ }
493
+ }
494
+
495
+ return {};
496
+ }
497
+
498
+ };
499
+ };
500
+
501
+ function getSideOffsets(overflow, rect) {
502
+ return {
503
+ top: overflow.top - rect.height,
504
+ right: overflow.right - rect.width,
505
+ bottom: overflow.bottom - rect.height,
506
+ left: overflow.left - rect.width
507
+ };
508
+ }
509
+
510
+ function isAnySideFullyClipped(overflow) {
511
+ return sides.some(side => overflow[side] >= 0);
512
+ }
513
+
514
+ /**
515
+ * Provides data to hide the floating element in applicable situations, such as
516
+ * when it is not in the same clipping context as the reference element.
517
+ * @see https://floating-ui.com/docs/hide
518
+ */
519
+ const hide = function (_temp) {
520
+ let {
521
+ strategy = 'referenceHidden',
522
+ ...detectOverflowOptions
523
+ } = _temp === void 0 ? {} : _temp;
524
+ return {
525
+ name: 'hide',
526
+
527
+ async fn(middlewareArguments) {
528
+ const {
529
+ rects
530
+ } = middlewareArguments;
531
+
532
+ switch (strategy) {
533
+ case 'referenceHidden':
534
+ {
535
+ const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
536
+ elementContext: 'reference'
537
+ });
538
+ const offsets = getSideOffsets(overflow, rects.reference);
539
+ return {
540
+ data: {
541
+ referenceHiddenOffsets: offsets,
542
+ referenceHidden: isAnySideFullyClipped(offsets)
543
+ }
544
+ };
545
+ }
546
+
547
+ case 'escaped':
548
+ {
549
+ const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
550
+ altBoundary: true
551
+ });
552
+ const offsets = getSideOffsets(overflow, rects.floating);
553
+ return {
554
+ data: {
555
+ escapedOffsets: offsets,
556
+ escaped: isAnySideFullyClipped(offsets)
557
+ }
558
+ };
559
+ }
560
+
561
+ default:
562
+ {
563
+ return {};
564
+ }
565
+ }
566
+ }
567
+
568
+ };
569
+ };
570
+
571
+ async function convertValueToCoords(middlewareArguments, value) {
572
+ const {
573
+ placement,
574
+ platform,
575
+ elements
576
+ } = middlewareArguments;
577
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
578
+ const side = getSide(placement);
579
+ const alignment = getAlignment(placement);
580
+ const isVertical = getMainAxisFromPlacement(placement) === 'x';
581
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
582
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
583
+ const rawValue = typeof value === 'function' ? value(middlewareArguments) : value; // eslint-disable-next-line prefer-const
584
+
585
+ let {
586
+ mainAxis,
587
+ crossAxis,
588
+ alignmentAxis
589
+ } = typeof rawValue === 'number' ? {
590
+ mainAxis: rawValue,
591
+ crossAxis: 0,
592
+ alignmentAxis: null
593
+ } : {
594
+ mainAxis: 0,
595
+ crossAxis: 0,
596
+ alignmentAxis: null,
597
+ ...rawValue
598
+ };
599
+
600
+ if (alignment && typeof alignmentAxis === 'number') {
601
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
602
+ }
603
+
604
+ return isVertical ? {
605
+ x: crossAxis * crossAxisMulti,
606
+ y: mainAxis * mainAxisMulti
607
+ } : {
608
+ x: mainAxis * mainAxisMulti,
609
+ y: crossAxis * crossAxisMulti
610
+ };
611
+ }
612
+ /**
613
+ * Displaces the floating element from its reference element.
614
+ * @see https://floating-ui.com/docs/offset
615
+ */
616
+
617
+ const offset = function (value) {
618
+ if (value === void 0) {
619
+ value = 0;
620
+ }
621
+
622
+ return {
623
+ name: 'offset',
624
+ options: value,
625
+
626
+ async fn(middlewareArguments) {
627
+ const {
628
+ x,
629
+ y
630
+ } = middlewareArguments;
631
+ const diffCoords = await convertValueToCoords(middlewareArguments, value);
632
+ return {
633
+ x: x + diffCoords.x,
634
+ y: y + diffCoords.y,
635
+ data: diffCoords
636
+ };
637
+ }
638
+
639
+ };
640
+ };
641
+
642
+ /**
643
+ * Provides improved positioning for inline reference elements that can span
644
+ * over multiple lines, such as hyperlinks or range selections.
645
+ * @see https://floating-ui.com/docs/inline
646
+ */
647
+ const inline = function (options) {
648
+ if (options === void 0) {
649
+ options = {};
650
+ }
651
+
652
+ return {
653
+ name: 'inline',
654
+ options,
655
+
656
+ async fn(middlewareArguments) {
657
+ var _await$platform$getCl;
658
+
659
+ const {
660
+ placement,
661
+ elements,
662
+ rects,
663
+ platform,
664
+ strategy
665
+ } = middlewareArguments; // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
666
+ // ClientRect's bounds, despite the event listener being triggered. A
667
+ // padding of 2 seems to handle this issue.
668
+
669
+ const {
670
+ padding = 2,
671
+ x,
672
+ y
673
+ } = options;
674
+ const fallback = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
675
+ rect: rects.reference,
676
+ offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
677
+ strategy
678
+ }) : rects.reference);
679
+ const clientRects = (_await$platform$getCl = await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) != null ? _await$platform$getCl : [];
680
+ const paddingObject = getSideObjectFromPadding(padding);
681
+
682
+ function getBoundingClientRect() {
683
+ // There are two rects and they are disjoined
684
+ if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
685
+ var _clientRects$find;
686
+
687
+ // Find the first rect in which the point is fully inside
688
+ return (_clientRects$find = clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom)) != null ? _clientRects$find : fallback;
689
+ } // There are 2 or more connected rects
690
+
691
+
692
+ if (clientRects.length >= 2) {
693
+ if (getMainAxisFromPlacement(placement) === 'x') {
694
+ const firstRect = clientRects[0];
695
+ const lastRect = clientRects[clientRects.length - 1];
696
+ const isTop = getSide(placement) === 'top';
697
+ const top = firstRect.top;
698
+ const bottom = lastRect.bottom;
699
+ const left = isTop ? firstRect.left : lastRect.left;
700
+ const right = isTop ? firstRect.right : lastRect.right;
701
+ const width = right - left;
702
+ const height = bottom - top;
703
+ return {
704
+ top,
705
+ bottom,
706
+ left,
707
+ right,
708
+ width,
709
+ height,
710
+ x: left,
711
+ y: top
712
+ };
713
+ }
714
+
715
+ const isLeftSide = getSide(placement) === 'left';
716
+ const maxRight = max$1(...clientRects.map(rect => rect.right));
717
+ const minLeft = min$1(...clientRects.map(rect => rect.left));
718
+ const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
719
+ const top = measureRects[0].top;
720
+ const bottom = measureRects[measureRects.length - 1].bottom;
721
+ const left = minLeft;
722
+ const right = maxRight;
723
+ const width = right - left;
724
+ const height = bottom - top;
725
+ return {
726
+ top,
727
+ bottom,
728
+ left,
729
+ right,
730
+ width,
731
+ height,
732
+ x: left,
733
+ y: top
734
+ };
735
+ }
736
+
737
+ return fallback;
738
+ }
739
+
740
+ const resetRects = await platform.getElementRects({
741
+ reference: {
742
+ getBoundingClientRect
743
+ },
744
+ floating: elements.floating,
745
+ strategy
746
+ });
747
+
748
+ if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
749
+ return {
750
+ reset: {
751
+ rects: resetRects
752
+ }
753
+ };
754
+ }
755
+
756
+ return {};
757
+ }
758
+
759
+ };
760
+ };
761
+
762
+ function isWindow(value) {
763
+ return value && value.document && value.location && value.alert && value.setInterval;
764
+ }
765
+ function getWindow(node) {
766
+ if (node == null) {
767
+ return window;
768
+ }
769
+
770
+ if (!isWindow(node)) {
771
+ const ownerDocument = node.ownerDocument;
772
+ return ownerDocument ? ownerDocument.defaultView || window : window;
773
+ }
774
+
775
+ return node;
776
+ }
777
+
778
+ function getComputedStyle$1(element) {
779
+ return getWindow(element).getComputedStyle(element);
780
+ }
781
+
782
+ function getNodeName(node) {
783
+ return isWindow(node) ? '' : node ? (node.nodeName || '').toLowerCase() : '';
784
+ }
785
+
786
+ function getUAString() {
787
+ const uaData = navigator.userAgentData;
788
+
789
+ if (uaData != null && uaData.brands) {
790
+ return uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
791
+ }
792
+
793
+ return navigator.userAgent;
794
+ }
795
+
796
+ function isHTMLElement(value) {
797
+ return value instanceof getWindow(value).HTMLElement;
798
+ }
799
+ function isElement(value) {
800
+ return value instanceof getWindow(value).Element;
801
+ }
802
+ function isNode(value) {
803
+ return value instanceof getWindow(value).Node;
804
+ }
805
+ function isShadowRoot(node) {
806
+ // Browsers without `ShadowRoot` support
807
+ if (typeof ShadowRoot === 'undefined') {
808
+ return false;
809
+ }
810
+
811
+ const OwnElement = getWindow(node).ShadowRoot;
812
+ return node instanceof OwnElement || node instanceof ShadowRoot;
813
+ }
814
+ function isOverflowElement(element) {
815
+ // Firefox wants us to check `-x` and `-y` variations as well
816
+ const {
817
+ overflow,
818
+ overflowX,
819
+ overflowY
820
+ } = getComputedStyle$1(element);
821
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
822
+ }
823
+ function isTableElement(element) {
824
+ return ['table', 'td', 'th'].includes(getNodeName(element));
825
+ }
826
+ function isContainingBlock(element) {
827
+ // TODO: Try and use feature detection here instead
828
+ const isFirefox = /firefox/i.test(getUAString());
829
+ const css = getComputedStyle$1(element); // This is non-exhaustive but covers the most common CSS properties that
830
+ // create a containing block.
831
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
832
+
833
+ return css.transform !== 'none' || css.perspective !== 'none' || // @ts-ignore (TS 4.1 compat)
834
+ css.contain === 'paint' || ['transform', 'perspective'].includes(css.willChange) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false);
835
+ }
836
+ function isLayoutViewport() {
837
+ // Not Safari
838
+ return !/^((?!chrome|android).)*safari/i.test(getUAString()); // Feature detection for this fails in various ways
839
+ // • Always-visible scrollbar or not
840
+ // • Width of <html>, etc.
841
+ // const vV = win.visualViewport;
842
+ // return vV ? Math.abs(win.innerWidth / vV.scale - vV.width) < 0.5 : true;
843
+ }
844
+
845
+ const min = Math.min;
846
+ const max = Math.max;
847
+ const round = Math.round;
848
+
849
+ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
850
+ var _win$visualViewport$o, _win$visualViewport, _win$visualViewport$o2, _win$visualViewport2;
851
+
852
+ if (includeScale === void 0) {
853
+ includeScale = false;
854
+ }
855
+
856
+ if (isFixedStrategy === void 0) {
857
+ isFixedStrategy = false;
858
+ }
859
+
860
+ const clientRect = element.getBoundingClientRect();
861
+ let scaleX = 1;
862
+ let scaleY = 1;
863
+
864
+ if (includeScale && isHTMLElement(element)) {
865
+ scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
866
+ scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
867
+ }
868
+
869
+ const win = isElement(element) ? getWindow(element) : window;
870
+ const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
871
+ const x = (clientRect.left + (addVisualOffsets ? (_win$visualViewport$o = (_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) != null ? _win$visualViewport$o : 0 : 0)) / scaleX;
872
+ const y = (clientRect.top + (addVisualOffsets ? (_win$visualViewport$o2 = (_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) != null ? _win$visualViewport$o2 : 0 : 0)) / scaleY;
873
+ const width = clientRect.width / scaleX;
874
+ const height = clientRect.height / scaleY;
875
+ return {
876
+ width,
877
+ height,
878
+ top: y,
879
+ right: x + width,
880
+ bottom: y + height,
881
+ left: x,
882
+ x,
883
+ y
884
+ };
885
+ }
886
+
887
+ function getDocumentElement(node) {
888
+ return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
889
+ }
890
+
891
+ function getNodeScroll(element) {
892
+ if (isElement(element)) {
893
+ return {
894
+ scrollLeft: element.scrollLeft,
895
+ scrollTop: element.scrollTop
896
+ };
897
+ }
898
+
899
+ return {
900
+ scrollLeft: element.pageXOffset,
901
+ scrollTop: element.pageYOffset
902
+ };
903
+ }
904
+
905
+ function getWindowScrollBarX(element) {
906
+ // If <html> has a CSS width greater than the viewport, then this will be
907
+ // incorrect for RTL.
908
+ return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
909
+ }
910
+
911
+ function isScaled(element) {
912
+ const rect = getBoundingClientRect(element);
913
+ return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
914
+ }
915
+
916
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
917
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
918
+ const documentElement = getDocumentElement(offsetParent);
919
+ const rect = getBoundingClientRect(element, // @ts-ignore - checked above (TS 4.1 compat)
920
+ isOffsetParentAnElement && isScaled(offsetParent), strategy === 'fixed');
921
+ let scroll = {
922
+ scrollLeft: 0,
923
+ scrollTop: 0
924
+ };
925
+ const offsets = {
926
+ x: 0,
927
+ y: 0
928
+ };
929
+
930
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
931
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
932
+ scroll = getNodeScroll(offsetParent);
933
+ }
934
+
935
+ if (isHTMLElement(offsetParent)) {
936
+ const offsetRect = getBoundingClientRect(offsetParent, true);
937
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
938
+ offsets.y = offsetRect.y + offsetParent.clientTop;
939
+ } else if (documentElement) {
940
+ offsets.x = getWindowScrollBarX(documentElement);
941
+ }
942
+ }
943
+
944
+ return {
945
+ x: rect.left + scroll.scrollLeft - offsets.x,
946
+ y: rect.top + scroll.scrollTop - offsets.y,
947
+ width: rect.width,
948
+ height: rect.height
949
+ };
950
+ }
951
+
952
+ function getParentNode(node) {
953
+ if (getNodeName(node) === 'html') {
954
+ return node;
955
+ }
956
+
957
+ return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
958
+ // @ts-ignore
959
+ node.assignedSlot || // step into the shadow DOM of the parent of a slotted node
960
+ node.parentNode || ( // DOM Element detected
961
+ isShadowRoot(node) ? node.host : null) || // ShadowRoot detected
962
+ getDocumentElement(node) // fallback
963
+
964
+ );
965
+ }
966
+
967
+ function getTrueOffsetParent(element) {
968
+ if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
969
+ return null;
970
+ }
971
+
972
+ return element.offsetParent;
973
+ }
974
+
975
+ function getContainingBlock(element) {
976
+ let currentNode = getParentNode(element);
977
+
978
+ if (isShadowRoot(currentNode)) {
979
+ currentNode = currentNode.host;
980
+ }
981
+
982
+ while (isHTMLElement(currentNode) && !['html', 'body'].includes(getNodeName(currentNode))) {
983
+ if (isContainingBlock(currentNode)) {
984
+ return currentNode;
985
+ } else {
986
+ currentNode = currentNode.parentNode;
987
+ }
988
+ }
989
+
990
+ return null;
991
+ } // Gets the closest ancestor positioned element. Handles some edge cases,
992
+ // such as table ancestors and cross browser bugs.
993
+
994
+
995
+ function getOffsetParent(element) {
996
+ const window = getWindow(element);
997
+ let offsetParent = getTrueOffsetParent(element);
998
+
999
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
1000
+ offsetParent = getTrueOffsetParent(offsetParent);
1001
+ }
1002
+
1003
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
1004
+ return window;
1005
+ }
1006
+
1007
+ return offsetParent || getContainingBlock(element) || window;
1008
+ }
1009
+
1010
+ function getDimensions(element) {
1011
+ if (isHTMLElement(element)) {
1012
+ return {
1013
+ width: element.offsetWidth,
1014
+ height: element.offsetHeight
1015
+ };
1016
+ }
1017
+
1018
+ const rect = getBoundingClientRect(element);
1019
+ return {
1020
+ width: rect.width,
1021
+ height: rect.height
1022
+ };
1023
+ }
1024
+
1025
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1026
+ let {
1027
+ rect,
1028
+ offsetParent,
1029
+ strategy
1030
+ } = _ref;
1031
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1032
+ const documentElement = getDocumentElement(offsetParent);
1033
+
1034
+ if (offsetParent === documentElement) {
1035
+ return rect;
1036
+ }
1037
+
1038
+ let scroll = {
1039
+ scrollLeft: 0,
1040
+ scrollTop: 0
1041
+ };
1042
+ const offsets = {
1043
+ x: 0,
1044
+ y: 0
1045
+ };
1046
+
1047
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
1048
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1049
+ scroll = getNodeScroll(offsetParent);
1050
+ }
1051
+
1052
+ if (isHTMLElement(offsetParent)) {
1053
+ const offsetRect = getBoundingClientRect(offsetParent, true);
1054
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1055
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1056
+ } // This doesn't appear to be need to be negated.
1057
+ // else if (documentElement) {
1058
+ // offsets.x = getWindowScrollBarX(documentElement);
1059
+ // }
1060
+
1061
+ }
1062
+
1063
+ return { ...rect,
1064
+ x: rect.x - scroll.scrollLeft + offsets.x,
1065
+ y: rect.y - scroll.scrollTop + offsets.y
1066
+ };
1067
+ }
1068
+
1069
+ function getViewportRect(element, strategy) {
1070
+ const win = getWindow(element);
1071
+ const html = getDocumentElement(element);
1072
+ const visualViewport = win.visualViewport;
1073
+ let width = html.clientWidth;
1074
+ let height = html.clientHeight;
1075
+ let x = 0;
1076
+ let y = 0;
1077
+
1078
+ if (visualViewport) {
1079
+ width = visualViewport.width;
1080
+ height = visualViewport.height;
1081
+ const layoutViewport = isLayoutViewport();
1082
+
1083
+ if (layoutViewport || !layoutViewport && strategy === 'fixed') {
1084
+ x = visualViewport.offsetLeft;
1085
+ y = visualViewport.offsetTop;
1086
+ }
1087
+ }
1088
+
1089
+ return {
1090
+ width,
1091
+ height,
1092
+ x,
1093
+ y
1094
+ };
1095
+ }
1096
+
1097
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable
1098
+
1099
+ function getDocumentRect(element) {
1100
+ var _element$ownerDocumen;
1101
+
1102
+ const html = getDocumentElement(element);
1103
+ const scroll = getNodeScroll(element);
1104
+ const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
1105
+ const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
1106
+ const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
1107
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1108
+ const y = -scroll.scrollTop;
1109
+
1110
+ if (getComputedStyle$1(body || html).direction === 'rtl') {
1111
+ x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
1112
+ }
1113
+
1114
+ return {
1115
+ width,
1116
+ height,
1117
+ x,
1118
+ y
1119
+ };
1120
+ }
1121
+
1122
+ function getNearestOverflowAncestor(node) {
1123
+ const parentNode = getParentNode(node);
1124
+
1125
+ if (['html', 'body', '#document'].includes(getNodeName(parentNode))) {
1126
+ // @ts-ignore assume body is always available
1127
+ return node.ownerDocument.body;
1128
+ }
1129
+
1130
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1131
+ return parentNode;
1132
+ }
1133
+
1134
+ return getNearestOverflowAncestor(parentNode);
1135
+ }
1136
+
1137
+ function getOverflowAncestors(node, list) {
1138
+ var _node$ownerDocument;
1139
+
1140
+ if (list === void 0) {
1141
+ list = [];
1142
+ }
1143
+
1144
+ const scrollableAncestor = getNearestOverflowAncestor(node);
1145
+ const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
1146
+ const win = getWindow(scrollableAncestor);
1147
+ const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
1148
+ const updatedList = list.concat(target);
1149
+ return isBody ? updatedList : // @ts-ignore: isBody tells us target will be an HTMLElement here
1150
+ updatedList.concat(getOverflowAncestors(target));
1151
+ }
1152
+
1153
+ function contains(parent, child) {
1154
+ const rootNode = child.getRootNode == null ? void 0 : child.getRootNode(); // First, attempt with faster native method
1155
+
1156
+ if (parent.contains(child)) {
1157
+ return true;
1158
+ } // then fallback to custom implementation with Shadow DOM support
1159
+ else if (rootNode && isShadowRoot(rootNode)) {
1160
+ let next = child;
1161
+
1162
+ do {
1163
+ // use `===` replace node.isSameNode()
1164
+ if (next && parent === next) {
1165
+ return true;
1166
+ } // @ts-ignore: need a better way to handle this...
1167
+
1168
+
1169
+ next = next.parentNode || next.host;
1170
+ } while (next);
1171
+ }
1172
+
1173
+ return false;
1174
+ }
1175
+
1176
+ function getInnerBoundingClientRect(element, strategy) {
1177
+ const clientRect = getBoundingClientRect(element, false, strategy === 'fixed');
1178
+ const top = clientRect.top + element.clientTop;
1179
+ const left = clientRect.left + element.clientLeft;
1180
+ return {
1181
+ top,
1182
+ left,
1183
+ x: left,
1184
+ y: top,
1185
+ right: left + element.clientWidth,
1186
+ bottom: top + element.clientHeight,
1187
+ width: element.clientWidth,
1188
+ height: element.clientHeight
1189
+ };
1190
+ }
1191
+
1192
+ function getClientRectFromClippingAncestor(element, clippingParent, strategy) {
1193
+ if (clippingParent === 'viewport') {
1194
+ return rectToClientRect(getViewportRect(element, strategy));
1195
+ }
1196
+
1197
+ if (isElement(clippingParent)) {
1198
+ return getInnerBoundingClientRect(clippingParent, strategy);
1199
+ }
1200
+
1201
+ return rectToClientRect(getDocumentRect(getDocumentElement(element)));
1202
+ } // A "clipping ancestor" is an overflowable container with the characteristic of
1203
+ // clipping (or hiding) overflowing elements with a position different from
1204
+ // `initial`
1205
+
1206
+
1207
+ function getClippingAncestors(element) {
1208
+ const clippingAncestors = getOverflowAncestors(element);
1209
+ const canEscapeClipping = ['absolute', 'fixed'].includes(getComputedStyle$1(element).position);
1210
+ const clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
1211
+
1212
+ if (!isElement(clipperElement)) {
1213
+ return [];
1214
+ } // @ts-ignore isElement check ensures we return Array<Element>
1215
+
1216
+
1217
+ return clippingAncestors.filter(clippingAncestors => isElement(clippingAncestors) && contains(clippingAncestors, clipperElement) && getNodeName(clippingAncestors) !== 'body');
1218
+ } // Gets the maximum area that the element is visible in due to any number of
1219
+ // clipping ancestors
1220
+
1221
+
1222
+ function getClippingRect(_ref) {
1223
+ let {
1224
+ element,
1225
+ boundary,
1226
+ rootBoundary,
1227
+ strategy
1228
+ } = _ref;
1229
+ const mainClippingAncestors = boundary === 'clippingAncestors' ? getClippingAncestors(element) : [].concat(boundary);
1230
+ const clippingAncestors = [...mainClippingAncestors, rootBoundary];
1231
+ const firstClippingAncestor = clippingAncestors[0];
1232
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1233
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1234
+ accRect.top = max(rect.top, accRect.top);
1235
+ accRect.right = min(rect.right, accRect.right);
1236
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1237
+ accRect.left = max(rect.left, accRect.left);
1238
+ return accRect;
1239
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1240
+ return {
1241
+ width: clippingRect.right - clippingRect.left,
1242
+ height: clippingRect.bottom - clippingRect.top,
1243
+ x: clippingRect.left,
1244
+ y: clippingRect.top
1245
+ };
1246
+ }
1247
+
1248
+ const platform = {
1249
+ getClippingRect,
1250
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1251
+ isElement,
1252
+ getDimensions,
1253
+ getOffsetParent,
1254
+ getDocumentElement,
1255
+ getElementRects: _ref => {
1256
+ let {
1257
+ reference,
1258
+ floating,
1259
+ strategy
1260
+ } = _ref;
1261
+ return {
1262
+ reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
1263
+ floating: { ...getDimensions(floating),
1264
+ x: 0,
1265
+ y: 0
1266
+ }
1267
+ };
1268
+ },
1269
+ getClientRects: element => Array.from(element.getClientRects()),
1270
+ isRTL: element => getComputedStyle$1(element).direction === 'rtl'
1271
+ };
1272
+
1273
+ /**
1274
+ * Automatically updates the position of the floating element when necessary.
1275
+ * @see https://floating-ui.com/docs/autoUpdate
1276
+ */
1277
+ function autoUpdate(reference, floating, update, options) {
1278
+ if (options === void 0) {
1279
+ options = {};
1280
+ }
1281
+
1282
+ const {
1283
+ ancestorScroll: _ancestorScroll = true,
1284
+ ancestorResize: _ancestorResize = true,
1285
+ elementResize = true,
1286
+ animationFrame = false
1287
+ } = options;
1288
+ const ancestorScroll = _ancestorScroll && !animationFrame;
1289
+ const ancestorResize = _ancestorResize && !animationFrame;
1290
+ const ancestors = ancestorScroll || ancestorResize ? [...(isElement(reference) ? getOverflowAncestors(reference) : []), ...getOverflowAncestors(floating)] : [];
1291
+ ancestors.forEach(ancestor => {
1292
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
1293
+ passive: true
1294
+ });
1295
+ ancestorResize && ancestor.addEventListener('resize', update);
1296
+ });
1297
+ let observer = null;
1298
+
1299
+ if (elementResize) {
1300
+ let initialUpdate = true;
1301
+ observer = new ResizeObserver(() => {
1302
+ if (!initialUpdate) {
1303
+ update();
1304
+ }
1305
+
1306
+ initialUpdate = false;
1307
+ });
1308
+ isElement(reference) && !animationFrame && observer.observe(reference);
1309
+ observer.observe(floating);
1310
+ }
1311
+
1312
+ let frameId;
1313
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1314
+
1315
+ if (animationFrame) {
1316
+ frameLoop();
1317
+ }
1318
+
1319
+ function frameLoop() {
1320
+ const nextRefRect = getBoundingClientRect(reference);
1321
+
1322
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
1323
+ update();
1324
+ }
1325
+
1326
+ prevRefRect = nextRefRect;
1327
+ frameId = requestAnimationFrame(frameLoop);
1328
+ }
1329
+
1330
+ update();
1331
+ return () => {
1332
+ var _observer;
1333
+
1334
+ ancestors.forEach(ancestor => {
1335
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
1336
+ ancestorResize && ancestor.removeEventListener('resize', update);
1337
+ });
1338
+ (_observer = observer) == null ? void 0 : _observer.disconnect();
1339
+ observer = null;
1340
+
1341
+ if (animationFrame) {
1342
+ cancelAnimationFrame(frameId);
1343
+ }
1344
+ };
1345
+ }
1346
+
1347
+ /**
1348
+ * Computes the `x` and `y` coordinates that will place the floating element
1349
+ * next to a reference element when it is given a certain CSS positioning
1350
+ * strategy.
1351
+ */
1352
+
1353
+ const computePosition = (reference, floating, options) => computePosition$1(reference, floating, {
1354
+ platform,
1355
+ ...options
1356
+ });
1357
+
1358
+ var _Popup_instances, _Popup_arrowPosition_get, _Popup_padding_get, _Popup_distance_get, _Popup_strategy_get, _Popup_middleware_get, _Popup_cleanup, _Popup_assignPopupPosition, _Popup_assignArrowPosition, _Popup_getAnchorById, _Popup_handleKeydown;
1359
+ class Popup extends FoundationElement {
1360
+ constructor() {
1361
+ super(...arguments);
1362
+ _Popup_instances.add(this);
1363
+ _Popup_cleanup.set(this, void 0);
1364
+ this.open = false;
1365
+ this.dismissible = false;
1366
+ this.arrow = false;
1367
+ this.alternate = false;
1368
+ _Popup_handleKeydown.set(this, event => {
1369
+ if (event.key === keyEscape) {
1370
+ this.open = false;
1371
+ }
1372
+ });
1373
+ }
1374
+ openChanged(_, newValue) {
1375
+ newValue ? this.$emit('open') : this.$emit('close');
1376
+ }
1377
+ disconnectedCallback() {
1378
+ var _a, _b;
1379
+ super.disconnectedCallback();
1380
+ (_a = this.anchorEl) === null || _a === void 0 ? void 0 : _a.removeEventListener('keydown', __classPrivateFieldGet(this, _Popup_handleKeydown, "f"));
1381
+ (_b = __classPrivateFieldGet(this, _Popup_cleanup, "f")) === null || _b === void 0 ? void 0 : _b.call(this);
1382
+ }
1383
+ attributeChangedCallback(name, oldValue, newValue) {
1384
+ var _a, _b, _c;
1385
+ super.attributeChangedCallback(name, oldValue, newValue);
1386
+ switch (name) {
1387
+ case 'anchor':
1388
+ {
1389
+ (_a = this.anchorEl) === null || _a === void 0 ? void 0 : _a.removeEventListener('keydown', __classPrivateFieldGet(this, _Popup_handleKeydown, "f"));
1390
+ this.anchorEl = __classPrivateFieldGet(this, _Popup_instances, "m", _Popup_getAnchorById).call(this);
1391
+ (_b = this.anchorEl) === null || _b === void 0 ? void 0 : _b.addEventListener('keydown', __classPrivateFieldGet(this, _Popup_handleKeydown, "f"));
1392
+ break;
1393
+ }
1394
+ }
1395
+ if (this.anchorEl && this.popupEl) {
1396
+ __classPrivateFieldSet(this, _Popup_cleanup, autoUpdate(this.anchorEl, this.popupEl, () => this.updatePosition()), "f");
1397
+ } else {
1398
+ (_c = __classPrivateFieldGet(this, _Popup_cleanup, "f")) === null || _c === void 0 ? void 0 : _c.call(this);
1399
+ }
1400
+ }
1401
+ async updatePosition() {
1402
+ if (!this.open || !this.anchorEl) {
1403
+ return;
1404
+ }
1405
+ const positionData = await computePosition(this.anchorEl, this.popupEl, {
1406
+ placement: this.placement,
1407
+ strategy: __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_strategy_get),
1408
+ middleware: __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_middleware_get)
1409
+ });
1410
+ __classPrivateFieldGet(this, _Popup_instances, "m", _Popup_assignPopupPosition).call(this, positionData);
1411
+ if (this.arrow) {
1412
+ __classPrivateFieldGet(this, _Popup_instances, "m", _Popup_assignArrowPosition).call(this, positionData);
1413
+ }
1414
+ }
1415
+ }
1416
+ _Popup_cleanup = new WeakMap(), _Popup_handleKeydown = new WeakMap(), _Popup_instances = new WeakSet(), _Popup_arrowPosition_get = function _Popup_arrowPosition_get() {
1417
+ return {
1418
+ top: 'bottom',
1419
+ right: 'left',
1420
+ bottom: 'top',
1421
+ left: 'right'
1422
+ };
1423
+ }, _Popup_padding_get = function _Popup_padding_get() {
1424
+ return 0;
1425
+ }, _Popup_distance_get = function _Popup_distance_get() {
1426
+ return 12;
1427
+ }, _Popup_strategy_get = function _Popup_strategy_get() {
1428
+ return 'fixed';
1429
+ }, _Popup_middleware_get = function _Popup_middleware_get() {
1430
+ const middleware = [flip(), hide(), inline()];
1431
+ if (this.arrow) {
1432
+ middleware.push(arrow({
1433
+ element: this.arrowEl,
1434
+ padding: __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_padding_get)
1435
+ }), offset(__classPrivateFieldGet(this, _Popup_instances, "a", _Popup_distance_get)));
1436
+ }
1437
+ return middleware;
1438
+ }, _Popup_assignPopupPosition = function _Popup_assignPopupPosition(data) {
1439
+ const {
1440
+ x: popupX,
1441
+ y: popupY
1442
+ } = data;
1443
+ const {
1444
+ referenceHidden
1445
+ } = data.middlewareData.hide;
1446
+ Object.assign(this.popupEl.style, {
1447
+ left: `${popupX}px`,
1448
+ top: `${popupY}px`,
1449
+ visibility: referenceHidden ? 'hidden' : 'visible'
1450
+ });
1451
+ }, _Popup_assignArrowPosition = function _Popup_assignArrowPosition(data) {
1452
+ const {
1453
+ x: arrowX,
1454
+ y: arrowY
1455
+ } = data.middlewareData.arrow;
1456
+ const side = __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_arrowPosition_get)[data.placement.split('-')[0]];
1457
+ Object.assign(this.arrowEl.style, {
1458
+ left: `${arrowX}px`,
1459
+ top: `${arrowY}px`,
1460
+ right: '',
1461
+ bottom: '',
1462
+ [side]: '-4px'
1463
+ });
1464
+ }, _Popup_getAnchorById = function _Popup_getAnchorById() {
1465
+ return document.getElementById(this.anchor);
1466
+ };
1467
+ __decorate([attr({
1468
+ mode: 'boolean'
1469
+ }), __metadata("design:type", Object)], Popup.prototype, "open", void 0);
1470
+ __decorate([attr({
1471
+ mode: 'boolean'
1472
+ }), __metadata("design:type", Object)], Popup.prototype, "dismissible", void 0);
1473
+ __decorate([attr({
1474
+ mode: 'boolean'
1475
+ }), __metadata("design:type", Object)], Popup.prototype, "arrow", void 0);
1476
+ __decorate([attr({
1477
+ mode: 'boolean'
1478
+ }), __metadata("design:type", Object)], Popup.prototype, "alternate", void 0);
1479
+ __decorate([attr({
1480
+ mode: 'fromView'
1481
+ }), __metadata("design:type", String)], Popup.prototype, "placement", void 0);
1482
+ __decorate([attr, __metadata("design:type", String)], Popup.prototype, "anchor", void 0);
1483
+
1484
+ export { Popup as P };