@siemens/ix 1.2.0 → 1.3.0-beta.0

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 (233) hide show
  1. package/dist/cjs/alignment-24ae2e63.js +1372 -0
  2. package/dist/cjs/index-17eb8998.js +4 -0
  3. package/dist/cjs/index.cjs.js +4 -1
  4. package/dist/cjs/ix-button.cjs.entry.js +4 -2
  5. package/dist/cjs/ix-category-filter.cjs.entry.js +8 -8
  6. package/dist/cjs/ix-chip.cjs.entry.js +21 -8
  7. package/dist/cjs/ix-counter-pill.cjs.entry.js +1 -1
  8. package/dist/cjs/ix-dropdown-button.cjs.entry.js +40 -0
  9. package/dist/cjs/ix-dropdown_2.cjs.entry.js +87 -41
  10. package/dist/cjs/ix-expanding-search.cjs.entry.js +2 -2
  11. package/dist/cjs/ix-icon-button.cjs.entry.js +2 -2
  12. package/dist/cjs/ix-map-navigation_2.cjs.entry.js +5 -4
  13. package/dist/cjs/ix-menu_9.cjs.entry.js +12 -93
  14. package/dist/cjs/ix-modal_2.cjs.entry.js +1 -1
  15. package/dist/cjs/ix-pill.cjs.entry.js +5 -2
  16. package/dist/cjs/ix-select_2.cjs.entry.js +35 -14
  17. package/dist/cjs/ix-split-button_2.cjs.entry.js +6 -35
  18. package/dist/cjs/ix-validation-tooltip.cjs.entry.js +71 -26
  19. package/dist/cjs/loader.cjs.js +1 -1
  20. package/dist/cjs/{modal-e4a6983d.js → modal-dda2f6be.js} +8 -2
  21. package/dist/cjs/siemens-ix.cjs.js +1 -1
  22. package/dist/cjs/theme-switcher-6b45e082.js +92 -0
  23. package/dist/collection/collection-manifest.json +1 -0
  24. package/dist/collection/components/button/button.css +1 -1
  25. package/dist/collection/components/button/button.js +5 -3
  26. package/dist/collection/components/category-filter/category-filter.css +4 -4
  27. package/dist/collection/components/category-filter/category-filter.js +7 -7
  28. package/dist/collection/components/chip/chip.css +20 -0
  29. package/dist/collection/components/chip/chip.js +22 -9
  30. package/dist/collection/components/counter-pill/counter-pill.css +10 -0
  31. package/dist/collection/components/dropdown/alignment.js +9 -0
  32. package/dist/collection/components/dropdown/dropdown.css +1 -0
  33. package/dist/collection/components/dropdown/dropdown.js +113 -50
  34. package/dist/collection/components/dropdown/placement.js +1 -0
  35. package/dist/collection/components/dropdown-button/dropdown-button.css +81 -0
  36. package/dist/collection/components/dropdown-button/dropdown-button.js +191 -0
  37. package/dist/collection/components/expanding-search/expanding-search.css +1 -0
  38. package/dist/collection/components/expanding-search/expanding-search.js +1 -1
  39. package/dist/collection/components/icon-button/icon-button.css +3 -30
  40. package/dist/collection/components/icon-button/icon-button.js +2 -2
  41. package/dist/collection/components/map-navigation/map-navigation.js +3 -2
  42. package/dist/collection/components/map-navigation-overlay/map-navigation-overlay.css +9 -4
  43. package/dist/collection/components/map-navigation-overlay/map-navigation-overlay.js +1 -1
  44. package/dist/collection/components/menu/menu.css +1 -1
  45. package/dist/collection/components/menu/menu.js +6 -21
  46. package/dist/collection/components/menu-avatar/menu-avatar.js +4 -30
  47. package/dist/collection/components/modal/modal.css +1 -0
  48. package/dist/collection/components/modal/modal.js +7 -1
  49. package/dist/collection/components/pill/pill.css +10 -0
  50. package/dist/collection/components/pill/pill.js +4 -1
  51. package/dist/collection/components/select/select.css +0 -3
  52. package/dist/collection/components/select/select.js +13 -12
  53. package/dist/collection/components/select-item/events.js +16 -0
  54. package/dist/collection/components/select-item/select-item.js +23 -4
  55. package/dist/collection/components/split-button/split-button.js +7 -36
  56. package/dist/collection/components/tree/tree.js +1 -1
  57. package/dist/collection/components/utils/theme-switcher.js +86 -0
  58. package/dist/collection/components/validation-tooltip/validation-tooltip.css +4 -24
  59. package/dist/collection/components/validation-tooltip/validation-tooltip.js +75 -28
  60. package/dist/collection/exports.js +1 -0
  61. package/dist/components/alignment.js +1363 -0
  62. package/dist/components/button.js +5 -3
  63. package/dist/components/dropdown.js +88 -41
  64. package/dist/components/icon-button.js +3 -3
  65. package/dist/components/index.d.ts +1 -0
  66. package/dist/components/index.js +2 -1
  67. package/dist/components/ix-category-filter.js +18 -12
  68. package/dist/components/ix-chip.js +21 -8
  69. package/dist/components/ix-counter-pill.js +1 -1
  70. package/dist/components/ix-dropdown-button.d.ts +11 -0
  71. package/dist/components/ix-dropdown-button.js +86 -0
  72. package/dist/components/ix-expanding-search.js +2 -2
  73. package/dist/components/ix-map-navigation.js +3 -2
  74. package/dist/components/ix-menu-avatar.js +6 -19
  75. package/dist/components/ix-menu.js +93 -46
  76. package/dist/components/ix-pill.js +5 -2
  77. package/dist/components/ix-select.js +9 -14
  78. package/dist/components/ix-split-button.js +6 -35
  79. package/dist/components/ix-validation-tooltip.js +74 -27
  80. package/dist/components/map-navigation-overlay.js +2 -2
  81. package/dist/components/modal.js +8 -2
  82. package/dist/components/select-item.js +27 -1
  83. package/dist/esm/alignment-f63c1b89.js +1363 -0
  84. package/dist/esm/index-6f4f3582.js +4 -0
  85. package/dist/esm/index.js +2 -1
  86. package/dist/esm/ix-button.entry.js +5 -3
  87. package/dist/esm/ix-category-filter.entry.js +8 -8
  88. package/dist/esm/ix-chip.entry.js +21 -8
  89. package/dist/esm/ix-counter-pill.entry.js +1 -1
  90. package/dist/esm/ix-dropdown-button.entry.js +36 -0
  91. package/dist/esm/ix-dropdown_2.entry.js +87 -41
  92. package/dist/esm/ix-expanding-search.entry.js +2 -2
  93. package/dist/esm/ix-icon-button.entry.js +3 -3
  94. package/dist/esm/ix-map-navigation_2.entry.js +5 -4
  95. package/dist/esm/ix-menu_9.entry.js +12 -93
  96. package/dist/esm/ix-modal_2.entry.js +1 -1
  97. package/dist/esm/ix-pill.entry.js +5 -2
  98. package/dist/esm/ix-select_2.entry.js +35 -14
  99. package/dist/esm/ix-split-button_2.entry.js +6 -35
  100. package/dist/esm/ix-validation-tooltip.entry.js +71 -26
  101. package/dist/esm/loader.js +1 -1
  102. package/dist/esm/{modal-e7343756.js → modal-df0a62f2.js} +8 -2
  103. package/dist/esm/siemens-ix.js +1 -1
  104. package/dist/esm/theme-switcher-dce1aaec.js +89 -0
  105. package/dist/siemens-ix/index.esm.js +1 -1
  106. package/dist/siemens-ix/p-03d38416.entry.js +1 -0
  107. package/dist/siemens-ix/p-0e357d27.entry.js +1 -0
  108. package/dist/siemens-ix/p-18d02e6f.entry.js +1 -0
  109. package/dist/siemens-ix/p-2bc72119.entry.js +1 -0
  110. package/dist/siemens-ix/p-2bd88760.entry.js +1 -0
  111. package/dist/siemens-ix/p-2c5abec1.js +1 -0
  112. package/dist/siemens-ix/p-35990ac7.js +1 -0
  113. package/dist/siemens-ix/p-43616759.entry.js +1 -0
  114. package/dist/siemens-ix/p-4fcb5f2b.entry.js +1 -0
  115. package/dist/siemens-ix/p-5631ae88.entry.js +1 -0
  116. package/dist/siemens-ix/p-5bbe9943.entry.js +1 -0
  117. package/dist/siemens-ix/p-6fe3bb9c.entry.js +1 -0
  118. package/dist/siemens-ix/{p-1cf3348f.entry.js → p-7f842cdc.entry.js} +1 -1
  119. package/dist/siemens-ix/p-ab7949ff.entry.js +1 -0
  120. package/dist/siemens-ix/p-b3d00feb.entry.js +1 -0
  121. package/dist/siemens-ix/p-d20119c1.entry.js +1 -0
  122. package/dist/siemens-ix/p-dec6114f.js +1 -0
  123. package/dist/siemens-ix/p-f35ce089.entry.js +1 -0
  124. package/dist/siemens-ix/siemens-ix.css +25 -3
  125. package/dist/siemens-ix/siemens-ix.esm.js +1 -1
  126. package/dist/types/components/button/button.d.ts +1 -1
  127. package/dist/types/components/category-filter/category-filter.d.ts +1 -0
  128. package/dist/types/components/chip/chip.d.ts +2 -1
  129. package/dist/types/components/dropdown/alignment.d.ts +2 -0
  130. package/dist/types/components/dropdown/dropdown.d.ts +19 -6
  131. package/dist/types/components/dropdown/placement.d.ts +8 -0
  132. package/dist/types/components/dropdown-button/dropdown-button.d.ts +37 -0
  133. package/dist/types/components/menu/menu.d.ts +0 -2
  134. package/dist/types/components/menu-avatar/menu-avatar.d.ts +1 -5
  135. package/dist/types/components/modal/modal.d.ts +1 -0
  136. package/dist/types/components/select/select.d.ts +2 -1
  137. package/dist/types/components/select-item/events.d.ts +9 -0
  138. package/dist/types/components/select-item/select-item.d.ts +3 -2
  139. package/dist/types/components/split-button/split-button.d.ts +4 -6
  140. package/dist/types/components/tree/tree.d.ts +1 -1
  141. package/dist/types/components/utils/theme-switcher.d.ts +19 -0
  142. package/dist/types/components/validation-tooltip/validation-tooltip.d.ts +12 -4
  143. package/dist/types/components.d.ts +88 -17
  144. package/dist/types/exports.d.ts +1 -0
  145. package/package.json +5 -6
  146. package/scss/components/_buttons.scss +23 -0
  147. package/scss/components/_dropdown.scss +2 -0
  148. package/dist/cjs/popper-d7a0f999.js +0 -1801
  149. package/dist/collection/components/utils/popover.util.js +0 -33
  150. package/dist/collection/components/utils/toggle-theme.js +0 -24
  151. package/dist/components/popover.util.js +0 -36
  152. package/dist/components/popper.js +0 -1799
  153. package/dist/esm/popper-42db9fbd.js +0 -1799
  154. package/dist/siemens-ix/p-0a8cfa42.entry.js +0 -1
  155. package/dist/siemens-ix/p-16e95211.entry.js +0 -1
  156. package/dist/siemens-ix/p-1fe97752.entry.js +0 -1
  157. package/dist/siemens-ix/p-23d5469a.entry.js +0 -1
  158. package/dist/siemens-ix/p-47d55e3d.entry.js +0 -1
  159. package/dist/siemens-ix/p-537f0678.entry.js +0 -1
  160. package/dist/siemens-ix/p-5e222be2.entry.js +0 -1
  161. package/dist/siemens-ix/p-7adc0686.entry.js +0 -1
  162. package/dist/siemens-ix/p-94604cdf.js +0 -1
  163. package/dist/siemens-ix/p-9566c834.entry.js +0 -1
  164. package/dist/siemens-ix/p-9e90827e.entry.js +0 -1
  165. package/dist/siemens-ix/p-a12f6079.entry.js +0 -1
  166. package/dist/siemens-ix/p-c0fecc2b.entry.js +0 -1
  167. package/dist/siemens-ix/p-d8688602.entry.js +0 -1
  168. package/dist/siemens-ix/p-f86fcdf4.js +0 -1
  169. package/dist/types/components/utils/popover.util.d.ts +0 -9
  170. package/dist/types/components/utils/toggle-theme.d.ts +0 -1
  171. package/src/components/animated-tab/readme.md +0 -24
  172. package/src/components/animated-tabs/readme.md +0 -31
  173. package/src/components/application-header/readme.md +0 -21
  174. package/src/components/basic-navigation/readme.md +0 -22
  175. package/src/components/blind/readme.md +0 -29
  176. package/src/components/breadcrumb/readme.md +0 -33
  177. package/src/components/breadcrumb-item/readme.md +0 -22
  178. package/src/components/button/readme.md +0 -27
  179. package/src/components/category-filter/readme.md +0 -39
  180. package/src/components/chip/readme.md +0 -36
  181. package/src/components/counter-pill/readme.md +0 -25
  182. package/src/components/date-picker/readme.md +0 -53
  183. package/src/components/date-time-card/readme.md +0 -22
  184. package/src/components/datetime-picker/readme.md +0 -45
  185. package/src/components/drawer/readme.md +0 -47
  186. package/src/components/dropdown/readme.md +0 -49
  187. package/src/components/dropdown-item/readme.md +0 -45
  188. package/src/components/event-list/readme.md +0 -24
  189. package/src/components/event-list-item/readme.md +0 -32
  190. package/src/components/expanding-search/readme.md +0 -32
  191. package/src/components/filter-chip/readme.md +0 -30
  192. package/src/components/flip-tile/readme.md +0 -22
  193. package/src/components/flip-tile-content/readme.md +0 -14
  194. package/src/components/group/readme.md +0 -14
  195. package/src/components/group-dropdown-item/readme.md +0 -22
  196. package/src/components/group-item/readme.md +0 -34
  197. package/src/components/icon/readme.md +0 -23
  198. package/src/components/icon-button/readme.md +0 -31
  199. package/src/components/input-group/readme.md +0 -14
  200. package/src/components/kpi/readme.md +0 -27
  201. package/src/components/map-navigation/readme.md +0 -54
  202. package/src/components/map-navigation-overlay/readme.md +0 -30
  203. package/src/components/menu/readme.md +0 -86
  204. package/src/components/menu-about/readme.md +0 -30
  205. package/src/components/menu-about-item/readme.md +0 -21
  206. package/src/components/menu-about-news/readme.md +0 -34
  207. package/src/components/menu-avatar/readme.md +0 -30
  208. package/src/components/menu-avatar-item/readme.md +0 -29
  209. package/src/components/menu-item/readme.md +0 -26
  210. package/src/components/menu-settings/readme.md +0 -30
  211. package/src/components/menu-settings-item/readme.md +0 -21
  212. package/src/components/message-bar/readme.md +0 -31
  213. package/src/components/modal/readme.md +0 -67
  214. package/src/components/modal-container/readme.md +0 -29
  215. package/src/components/my-component/readme.md +0 -16
  216. package/src/components/pill/readme.md +0 -26
  217. package/src/components/select/readme.md +0 -37
  218. package/src/components/select-item/readme.md +0 -44
  219. package/src/components/spinner/readme.md +0 -22
  220. package/src/components/split-button/readme.md +0 -36
  221. package/src/components/split-button-item/readme.md +0 -29
  222. package/src/components/tab-item/readme.md +0 -28
  223. package/src/components/tabs/readme.md +0 -25
  224. package/src/components/tile/readme.md +0 -21
  225. package/src/components/time-picker/readme.md +0 -51
  226. package/src/components/toast/readme.md +0 -36
  227. package/src/components/toggle/readme.md +0 -35
  228. package/src/components/tree/readme.md +0 -32
  229. package/src/components/tree-item/readme.md +0 -31
  230. package/src/components/upload/readme.md +0 -51
  231. package/src/components/validation-tooltip/readme.md +0 -31
  232. package/src/components/workflow-step/readme.md +0 -28
  233. package/src/components/workflow-steps/readme.md +0 -33
@@ -0,0 +1,1363 @@
1
+ function getSide(placement) {
2
+ return placement.split('-')[0];
3
+ }
4
+
5
+ function getAlignment$1(placement) {
6
+ return placement.split('-')[1];
7
+ }
8
+
9
+ function getMainAxisFromPlacement(placement) {
10
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
11
+ }
12
+
13
+ function getLengthFromAxis(axis) {
14
+ return axis === 'y' ? 'height' : 'width';
15
+ }
16
+
17
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
18
+ let {
19
+ reference,
20
+ floating
21
+ } = _ref;
22
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
23
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
24
+ const mainAxis = getMainAxisFromPlacement(placement);
25
+ const length = getLengthFromAxis(mainAxis);
26
+ const commonAlign = reference[length] / 2 - floating[length] / 2;
27
+ const side = getSide(placement);
28
+ const isVertical = mainAxis === 'x';
29
+ let coords;
30
+
31
+ switch (side) {
32
+ case 'top':
33
+ coords = {
34
+ x: commonX,
35
+ y: reference.y - floating.height
36
+ };
37
+ break;
38
+
39
+ case 'bottom':
40
+ coords = {
41
+ x: commonX,
42
+ y: reference.y + reference.height
43
+ };
44
+ break;
45
+
46
+ case 'right':
47
+ coords = {
48
+ x: reference.x + reference.width,
49
+ y: commonY
50
+ };
51
+ break;
52
+
53
+ case 'left':
54
+ coords = {
55
+ x: reference.x - floating.width,
56
+ y: commonY
57
+ };
58
+ break;
59
+
60
+ default:
61
+ coords = {
62
+ x: reference.x,
63
+ y: reference.y
64
+ };
65
+ }
66
+
67
+ switch (getAlignment$1(placement)) {
68
+ case 'start':
69
+ coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
70
+ break;
71
+
72
+ case 'end':
73
+ coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
74
+ break;
75
+ }
76
+
77
+ return coords;
78
+ }
79
+
80
+ /**
81
+ * Computes the `x` and `y` coordinates that will place the floating element
82
+ * next to a reference element when it is given a certain positioning strategy.
83
+ *
84
+ * This export does not have any `platform` interface logic. You will need to
85
+ * write one for the platform you are using Floating UI with.
86
+ */
87
+
88
+ const computePosition$1 = async (reference, floating, config) => {
89
+ const {
90
+ placement = 'bottom',
91
+ strategy = 'absolute',
92
+ middleware = [],
93
+ platform
94
+ } = config;
95
+ const validMiddleware = middleware.filter(Boolean);
96
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
97
+
98
+ let rects = await platform.getElementRects({
99
+ reference,
100
+ floating,
101
+ strategy
102
+ });
103
+ let {
104
+ x,
105
+ y
106
+ } = computeCoordsFromPlacement(rects, placement, rtl);
107
+ let statefulPlacement = placement;
108
+ let middlewareData = {};
109
+ let resetCount = 0;
110
+
111
+ for (let i = 0; i < validMiddleware.length; i++) {
112
+ const {
113
+ name,
114
+ fn
115
+ } = validMiddleware[i];
116
+ const {
117
+ x: nextX,
118
+ y: nextY,
119
+ data,
120
+ reset
121
+ } = await fn({
122
+ x,
123
+ y,
124
+ initialPlacement: placement,
125
+ placement: statefulPlacement,
126
+ strategy,
127
+ middlewareData,
128
+ rects,
129
+ platform,
130
+ elements: {
131
+ reference,
132
+ floating
133
+ }
134
+ });
135
+ x = nextX != null ? nextX : x;
136
+ y = nextY != null ? nextY : y;
137
+ middlewareData = { ...middlewareData,
138
+ [name]: { ...middlewareData[name],
139
+ ...data
140
+ }
141
+ };
142
+
143
+ if (reset && resetCount <= 50) {
144
+ resetCount++;
145
+
146
+ if (typeof reset === 'object') {
147
+ if (reset.placement) {
148
+ statefulPlacement = reset.placement;
149
+ }
150
+
151
+ if (reset.rects) {
152
+ rects = reset.rects === true ? await platform.getElementRects({
153
+ reference,
154
+ floating,
155
+ strategy
156
+ }) : reset.rects;
157
+ }
158
+
159
+ ({
160
+ x,
161
+ y
162
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
163
+ }
164
+
165
+ i = -1;
166
+ continue;
167
+ }
168
+ }
169
+
170
+ return {
171
+ x,
172
+ y,
173
+ placement: statefulPlacement,
174
+ strategy,
175
+ middlewareData
176
+ };
177
+ };
178
+
179
+ function expandPaddingObject(padding) {
180
+ return {
181
+ top: 0,
182
+ right: 0,
183
+ bottom: 0,
184
+ left: 0,
185
+ ...padding
186
+ };
187
+ }
188
+
189
+ function getSideObjectFromPadding(padding) {
190
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
191
+ top: padding,
192
+ right: padding,
193
+ bottom: padding,
194
+ left: padding
195
+ };
196
+ }
197
+
198
+ function rectToClientRect(rect) {
199
+ return { ...rect,
200
+ top: rect.y,
201
+ left: rect.x,
202
+ right: rect.x + rect.width,
203
+ bottom: rect.y + rect.height
204
+ };
205
+ }
206
+
207
+ /**
208
+ * Resolves with an object of overflow side offsets that determine how much the
209
+ * element is overflowing a given clipping boundary.
210
+ * - positive = overflowing the boundary by that number of pixels
211
+ * - negative = how many pixels left before it will overflow
212
+ * - 0 = lies flush with the boundary
213
+ * @see https://floating-ui.com/docs/detectOverflow
214
+ */
215
+ async function detectOverflow(middlewareArguments, options) {
216
+ var _await$platform$isEle;
217
+
218
+ if (options === void 0) {
219
+ options = {};
220
+ }
221
+
222
+ const {
223
+ x,
224
+ y,
225
+ platform,
226
+ rects,
227
+ elements,
228
+ strategy
229
+ } = middlewareArguments;
230
+ const {
231
+ boundary = 'clippingAncestors',
232
+ rootBoundary = 'viewport',
233
+ elementContext = 'floating',
234
+ altBoundary = false,
235
+ padding = 0
236
+ } = options;
237
+ const paddingObject = getSideObjectFromPadding(padding);
238
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
239
+ const element = elements[altBoundary ? altContext : elementContext];
240
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
241
+ 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))),
242
+ boundary,
243
+ rootBoundary,
244
+ strategy
245
+ }));
246
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
247
+ rect: elementContext === 'floating' ? { ...rects.floating,
248
+ x,
249
+ y
250
+ } : rects.reference,
251
+ offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
252
+ strategy
253
+ }) : rects[elementContext]);
254
+ return {
255
+ top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
256
+ bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
257
+ left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
258
+ right: elementClientRect.right - clippingClientRect.right + paddingObject.right
259
+ };
260
+ }
261
+
262
+ const min$1 = Math.min;
263
+ const max$1 = Math.max;
264
+
265
+ function within(min$1$1, value, max$1$1) {
266
+ return max$1(min$1$1, min$1(value, max$1$1));
267
+ }
268
+
269
+ /**
270
+ * Positions an inner element of the floating element such that it is centered
271
+ * to the reference element.
272
+ * @see https://floating-ui.com/docs/arrow
273
+ */
274
+ const arrow = options => ({
275
+ name: 'arrow',
276
+ options,
277
+
278
+ async fn(middlewareArguments) {
279
+ // Since `element` is required, we don't Partial<> the type
280
+ const {
281
+ element,
282
+ padding = 0
283
+ } = options != null ? options : {};
284
+ const {
285
+ x,
286
+ y,
287
+ placement,
288
+ rects,
289
+ platform
290
+ } = middlewareArguments;
291
+
292
+ if (element == null) {
293
+
294
+ return {};
295
+ }
296
+
297
+ const paddingObject = getSideObjectFromPadding(padding);
298
+ const coords = {
299
+ x,
300
+ y
301
+ };
302
+ const axis = getMainAxisFromPlacement(placement);
303
+ const alignment = getAlignment$1(placement);
304
+ const length = getLengthFromAxis(axis);
305
+ const arrowDimensions = await platform.getDimensions(element);
306
+ const minProp = axis === 'y' ? 'top' : 'left';
307
+ const maxProp = axis === 'y' ? 'bottom' : 'right';
308
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
309
+ const startDiff = coords[axis] - rects.reference[axis];
310
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
311
+ let clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
312
+
313
+ if (clientSize === 0) {
314
+ clientSize = rects.floating[length];
315
+ }
316
+
317
+ const centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the floating element if the center
318
+ // point is outside the floating element's bounds
319
+
320
+ const min = paddingObject[minProp];
321
+ const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
322
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
323
+ const offset = within(min, center, max); // Make sure that arrow points at the reference
324
+
325
+ const alignmentPadding = alignment === 'start' ? paddingObject[minProp] : paddingObject[maxProp];
326
+ const shouldAddOffset = alignmentPadding > 0 && center !== offset && rects.reference[length] <= rects.floating[length];
327
+ const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;
328
+ return {
329
+ [axis]: coords[axis] - alignmentOffset,
330
+ data: {
331
+ [axis]: offset,
332
+ centerOffset: center - offset
333
+ }
334
+ };
335
+ }
336
+
337
+ });
338
+
339
+ const hash$1 = {
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, matched => hash$1[matched]);
347
+ }
348
+
349
+ function getAlignmentSides(placement, rects, rtl) {
350
+ if (rtl === void 0) {
351
+ rtl = false;
352
+ }
353
+
354
+ const alignment = getAlignment$1(placement);
355
+ const mainAxis = getMainAxisFromPlacement(placement);
356
+ const length = getLengthFromAxis(mainAxis);
357
+ let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
358
+
359
+ if (rects.reference[length] > rects.floating[length]) {
360
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
361
+ }
362
+
363
+ return {
364
+ main: mainAlignmentSide,
365
+ cross: getOppositePlacement(mainAlignmentSide)
366
+ };
367
+ }
368
+
369
+ const hash = {
370
+ start: 'end',
371
+ end: 'start'
372
+ };
373
+ function getOppositeAlignmentPlacement(placement) {
374
+ return placement.replace(/start|end/g, matched => hash[matched]);
375
+ }
376
+
377
+ const sides = ['top', 'right', 'bottom', 'left'];
378
+ const allPlacements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-start", side + "-end"), []);
379
+
380
+ function getPlacementList(alignment, autoAlignment, allowedPlacements) {
381
+ const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment$1(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment$1(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
382
+ return allowedPlacementsSortedByAlignment.filter(placement => {
383
+ if (alignment) {
384
+ return getAlignment$1(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
385
+ }
386
+
387
+ return true;
388
+ });
389
+ }
390
+
391
+ /**
392
+ * Automatically chooses the `placement` which has the most space available.
393
+ * @see https://floating-ui.com/docs/autoPlacement
394
+ */
395
+ const autoPlacement = function (options) {
396
+ if (options === void 0) {
397
+ options = {};
398
+ }
399
+
400
+ return {
401
+ name: 'autoPlacement',
402
+ options,
403
+
404
+ async fn(middlewareArguments) {
405
+ var _middlewareData$autoP, _middlewareData$autoP2, _middlewareData$autoP3, _middlewareData$autoP4, _placementsSortedByLe;
406
+
407
+ const {
408
+ x,
409
+ y,
410
+ rects,
411
+ middlewareData,
412
+ placement,
413
+ platform,
414
+ elements
415
+ } = middlewareArguments;
416
+ const {
417
+ alignment = null,
418
+ allowedPlacements = allPlacements,
419
+ autoAlignment = true,
420
+ ...detectOverflowOptions
421
+ } = options;
422
+ const placements = getPlacementList(alignment, autoAlignment, allowedPlacements);
423
+ const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
424
+ const currentIndex = (_middlewareData$autoP = (_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.index) != null ? _middlewareData$autoP : 0;
425
+ const currentPlacement = placements[currentIndex];
426
+
427
+ if (currentPlacement == null) {
428
+ return {};
429
+ }
430
+
431
+ const {
432
+ main,
433
+ cross
434
+ } = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))); // Make `computeCoords` start from the right place
435
+
436
+ if (placement !== currentPlacement) {
437
+ return {
438
+ x,
439
+ y,
440
+ reset: {
441
+ placement: placements[0]
442
+ }
443
+ };
444
+ }
445
+
446
+ const currentOverflows = [overflow[getSide(currentPlacement)], overflow[main], overflow[cross]];
447
+ const allOverflows = [...((_middlewareData$autoP3 = (_middlewareData$autoP4 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP4.overflows) != null ? _middlewareData$autoP3 : []), {
448
+ placement: currentPlacement,
449
+ overflows: currentOverflows
450
+ }];
451
+ const nextPlacement = placements[currentIndex + 1]; // There are more placements to check
452
+
453
+ if (nextPlacement) {
454
+ return {
455
+ data: {
456
+ index: currentIndex + 1,
457
+ overflows: allOverflows
458
+ },
459
+ reset: {
460
+ placement: nextPlacement
461
+ }
462
+ };
463
+ }
464
+
465
+ const placementsSortedByLeastOverflow = allOverflows.slice().sort((a, b) => a.overflows[0] - b.overflows[0]);
466
+ const placementThatFitsOnAllSides = (_placementsSortedByLe = placementsSortedByLeastOverflow.find(_ref => {
467
+ let {
468
+ overflows
469
+ } = _ref;
470
+ return overflows.every(overflow => overflow <= 0);
471
+ })) == null ? void 0 : _placementsSortedByLe.placement;
472
+ const resetPlacement = placementThatFitsOnAllSides != null ? placementThatFitsOnAllSides : placementsSortedByLeastOverflow[0].placement;
473
+
474
+ if (resetPlacement !== placement) {
475
+ return {
476
+ data: {
477
+ index: currentIndex + 1,
478
+ overflows: allOverflows
479
+ },
480
+ reset: {
481
+ placement: resetPlacement
482
+ }
483
+ };
484
+ }
485
+
486
+ return {};
487
+ }
488
+
489
+ };
490
+ };
491
+
492
+ async function convertValueToCoords(middlewareArguments, value) {
493
+ const {
494
+ placement,
495
+ platform,
496
+ elements
497
+ } = middlewareArguments;
498
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
499
+ const side = getSide(placement);
500
+ const alignment = getAlignment$1(placement);
501
+ const isVertical = getMainAxisFromPlacement(placement) === 'x';
502
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
503
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
504
+ const rawValue = typeof value === 'function' ? value(middlewareArguments) : value; // eslint-disable-next-line prefer-const
505
+
506
+ let {
507
+ mainAxis,
508
+ crossAxis,
509
+ alignmentAxis
510
+ } = typeof rawValue === 'number' ? {
511
+ mainAxis: rawValue,
512
+ crossAxis: 0,
513
+ alignmentAxis: null
514
+ } : {
515
+ mainAxis: 0,
516
+ crossAxis: 0,
517
+ alignmentAxis: null,
518
+ ...rawValue
519
+ };
520
+
521
+ if (alignment && typeof alignmentAxis === 'number') {
522
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
523
+ }
524
+
525
+ return isVertical ? {
526
+ x: crossAxis * crossAxisMulti,
527
+ y: mainAxis * mainAxisMulti
528
+ } : {
529
+ x: mainAxis * mainAxisMulti,
530
+ y: crossAxis * crossAxisMulti
531
+ };
532
+ }
533
+ /**
534
+ * Displaces the floating element from its reference element.
535
+ * @see https://floating-ui.com/docs/offset
536
+ */
537
+
538
+ const offset = function (value) {
539
+ if (value === void 0) {
540
+ value = 0;
541
+ }
542
+
543
+ return {
544
+ name: 'offset',
545
+ options: value,
546
+
547
+ async fn(middlewareArguments) {
548
+ const {
549
+ x,
550
+ y
551
+ } = middlewareArguments;
552
+ const diffCoords = await convertValueToCoords(middlewareArguments, value);
553
+ return {
554
+ x: x + diffCoords.x,
555
+ y: y + diffCoords.y,
556
+ data: diffCoords
557
+ };
558
+ }
559
+
560
+ };
561
+ };
562
+
563
+ function getCrossAxis(axis) {
564
+ return axis === 'x' ? 'y' : 'x';
565
+ }
566
+
567
+ /**
568
+ * Shifts the floating element in order to keep it in view when it will overflow
569
+ * a clipping boundary.
570
+ * @see https://floating-ui.com/docs/shift
571
+ */
572
+ const shift = function (options) {
573
+ if (options === void 0) {
574
+ options = {};
575
+ }
576
+
577
+ return {
578
+ name: 'shift',
579
+ options,
580
+
581
+ async fn(middlewareArguments) {
582
+ const {
583
+ x,
584
+ y,
585
+ placement
586
+ } = middlewareArguments;
587
+ const {
588
+ mainAxis: checkMainAxis = true,
589
+ crossAxis: checkCrossAxis = false,
590
+ limiter = {
591
+ fn: _ref => {
592
+ let {
593
+ x,
594
+ y
595
+ } = _ref;
596
+ return {
597
+ x,
598
+ y
599
+ };
600
+ }
601
+ },
602
+ ...detectOverflowOptions
603
+ } = options;
604
+ const coords = {
605
+ x,
606
+ y
607
+ };
608
+ const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
609
+ const mainAxis = getMainAxisFromPlacement(getSide(placement));
610
+ const crossAxis = getCrossAxis(mainAxis);
611
+ let mainAxisCoord = coords[mainAxis];
612
+ let crossAxisCoord = coords[crossAxis];
613
+
614
+ if (checkMainAxis) {
615
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
616
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
617
+ const min = mainAxisCoord + overflow[minSide];
618
+ const max = mainAxisCoord - overflow[maxSide];
619
+ mainAxisCoord = within(min, mainAxisCoord, max);
620
+ }
621
+
622
+ if (checkCrossAxis) {
623
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
624
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
625
+ const min = crossAxisCoord + overflow[minSide];
626
+ const max = crossAxisCoord - overflow[maxSide];
627
+ crossAxisCoord = within(min, crossAxisCoord, max);
628
+ }
629
+
630
+ const limitedCoords = limiter.fn({ ...middlewareArguments,
631
+ [mainAxis]: mainAxisCoord,
632
+ [crossAxis]: crossAxisCoord
633
+ });
634
+ return { ...limitedCoords,
635
+ data: {
636
+ x: limitedCoords.x - x,
637
+ y: limitedCoords.y - y
638
+ }
639
+ };
640
+ }
641
+
642
+ };
643
+ };
644
+
645
+ /**
646
+ * Provides improved positioning for inline reference elements that can span
647
+ * over multiple lines, such as hyperlinks or range selections.
648
+ * @see https://floating-ui.com/docs/inline
649
+ */
650
+ const inline = function (options) {
651
+ if (options === void 0) {
652
+ options = {};
653
+ }
654
+
655
+ return {
656
+ name: 'inline',
657
+ options,
658
+
659
+ async fn(middlewareArguments) {
660
+ var _await$platform$getCl;
661
+
662
+ const {
663
+ placement,
664
+ elements,
665
+ rects,
666
+ platform,
667
+ strategy
668
+ } = middlewareArguments; // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
669
+ // ClientRect's bounds, despite the event listener being triggered. A
670
+ // padding of 2 seems to handle this issue.
671
+
672
+ const {
673
+ padding = 2,
674
+ x,
675
+ y
676
+ } = options;
677
+ const fallback = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
678
+ rect: rects.reference,
679
+ offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
680
+ strategy
681
+ }) : rects.reference);
682
+ const clientRects = (_await$platform$getCl = await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) != null ? _await$platform$getCl : [];
683
+ const paddingObject = getSideObjectFromPadding(padding);
684
+
685
+ function getBoundingClientRect() {
686
+ // There are two rects and they are disjoined
687
+ if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
688
+ var _clientRects$find;
689
+
690
+ // Find the first rect in which the point is fully inside
691
+ 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;
692
+ } // There are 2 or more connected rects
693
+
694
+
695
+ if (clientRects.length >= 2) {
696
+ if (getMainAxisFromPlacement(placement) === 'x') {
697
+ const firstRect = clientRects[0];
698
+ const lastRect = clientRects[clientRects.length - 1];
699
+ const isTop = getSide(placement) === 'top';
700
+ const top = firstRect.top;
701
+ const bottom = lastRect.bottom;
702
+ const left = isTop ? firstRect.left : lastRect.left;
703
+ const right = isTop ? firstRect.right : lastRect.right;
704
+ const width = right - left;
705
+ const height = bottom - top;
706
+ return {
707
+ top,
708
+ bottom,
709
+ left,
710
+ right,
711
+ width,
712
+ height,
713
+ x: left,
714
+ y: top
715
+ };
716
+ }
717
+
718
+ const isLeftSide = getSide(placement) === 'left';
719
+ const maxRight = max$1(...clientRects.map(rect => rect.right));
720
+ const minLeft = min$1(...clientRects.map(rect => rect.left));
721
+ const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
722
+ const top = measureRects[0].top;
723
+ const bottom = measureRects[measureRects.length - 1].bottom;
724
+ const left = minLeft;
725
+ const right = maxRight;
726
+ const width = right - left;
727
+ const height = bottom - top;
728
+ return {
729
+ top,
730
+ bottom,
731
+ left,
732
+ right,
733
+ width,
734
+ height,
735
+ x: left,
736
+ y: top
737
+ };
738
+ }
739
+
740
+ return fallback;
741
+ }
742
+
743
+ const resetRects = await platform.getElementRects({
744
+ reference: {
745
+ getBoundingClientRect
746
+ },
747
+ floating: elements.floating,
748
+ strategy
749
+ });
750
+
751
+ 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) {
752
+ return {
753
+ reset: {
754
+ rects: resetRects
755
+ }
756
+ };
757
+ }
758
+
759
+ return {};
760
+ }
761
+
762
+ };
763
+ };
764
+
765
+ function isWindow(value) {
766
+ return value && value.document && value.location && value.alert && value.setInterval;
767
+ }
768
+ function getWindow(node) {
769
+ if (node == null) {
770
+ return window;
771
+ }
772
+
773
+ if (!isWindow(node)) {
774
+ const ownerDocument = node.ownerDocument;
775
+ return ownerDocument ? ownerDocument.defaultView || window : window;
776
+ }
777
+
778
+ return node;
779
+ }
780
+
781
+ function getComputedStyle(element) {
782
+ return getWindow(element).getComputedStyle(element);
783
+ }
784
+
785
+ function getNodeName(node) {
786
+ return isWindow(node) ? '' : node ? (node.nodeName || '').toLowerCase() : '';
787
+ }
788
+
789
+ function getUAString() {
790
+ const uaData = navigator.userAgentData;
791
+
792
+ if (uaData != null && uaData.brands) {
793
+ return uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
794
+ }
795
+
796
+ return navigator.userAgent;
797
+ }
798
+
799
+ function isHTMLElement(value) {
800
+ return value instanceof getWindow(value).HTMLElement;
801
+ }
802
+ function isElement(value) {
803
+ return value instanceof getWindow(value).Element;
804
+ }
805
+ function isNode(value) {
806
+ return value instanceof getWindow(value).Node;
807
+ }
808
+ function isShadowRoot(node) {
809
+ // Browsers without `ShadowRoot` support
810
+ if (typeof ShadowRoot === 'undefined') {
811
+ return false;
812
+ }
813
+
814
+ const OwnElement = getWindow(node).ShadowRoot;
815
+ return node instanceof OwnElement || node instanceof ShadowRoot;
816
+ }
817
+ function isOverflowElement(element) {
818
+ // Firefox wants us to check `-x` and `-y` variations as well
819
+ const {
820
+ overflow,
821
+ overflowX,
822
+ overflowY,
823
+ display
824
+ } = getComputedStyle(element);
825
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
826
+ }
827
+ function isTableElement(element) {
828
+ return ['table', 'td', 'th'].includes(getNodeName(element));
829
+ }
830
+ function isContainingBlock(element) {
831
+ // TODO: Try and use feature detection here instead
832
+ const isFirefox = /firefox/i.test(getUAString());
833
+ const css = getComputedStyle(element);
834
+ const backdropFilter = css.backdropFilter || css.WebkitBackdropFilter; // This is non-exhaustive but covers the most common CSS properties that
835
+ // create a containing block.
836
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
837
+
838
+ 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( // TS 4.1 compat
839
+ value => {
840
+ const contain = css.contain;
841
+ return contain != null ? contain.includes(value) : false;
842
+ });
843
+ }
844
+ function isLayoutViewport() {
845
+ // Not Safari
846
+ return !/^((?!chrome|android).)*safari/i.test(getUAString()); // Feature detection for this fails in various ways
847
+ // • Always-visible scrollbar or not
848
+ // • Width of <html>, etc.
849
+ // const vV = win.visualViewport;
850
+ // return vV ? Math.abs(win.innerWidth / vV.scale - vV.width) < 0.5 : true;
851
+ }
852
+ function isLastTraversableNode(node) {
853
+ return ['html', 'body', '#document'].includes(getNodeName(node));
854
+ }
855
+
856
+ const min = Math.min;
857
+ const max = Math.max;
858
+ const round = Math.round;
859
+
860
+ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
861
+ var _win$visualViewport$o, _win$visualViewport, _win$visualViewport$o2, _win$visualViewport2;
862
+
863
+ if (includeScale === void 0) {
864
+ includeScale = false;
865
+ }
866
+
867
+ if (isFixedStrategy === void 0) {
868
+ isFixedStrategy = false;
869
+ }
870
+
871
+ const clientRect = element.getBoundingClientRect();
872
+ let scaleX = 1;
873
+ let scaleY = 1;
874
+
875
+ if (includeScale && isHTMLElement(element)) {
876
+ scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
877
+ scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
878
+ }
879
+
880
+ const win = isElement(element) ? getWindow(element) : window;
881
+ const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
882
+ 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;
883
+ 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;
884
+ const width = clientRect.width / scaleX;
885
+ const height = clientRect.height / scaleY;
886
+ return {
887
+ width,
888
+ height,
889
+ top: y,
890
+ right: x + width,
891
+ bottom: y + height,
892
+ left: x,
893
+ x,
894
+ y
895
+ };
896
+ }
897
+
898
+ function getDocumentElement(node) {
899
+ return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
900
+ }
901
+
902
+ function getNodeScroll(element) {
903
+ if (isElement(element)) {
904
+ return {
905
+ scrollLeft: element.scrollLeft,
906
+ scrollTop: element.scrollTop
907
+ };
908
+ }
909
+
910
+ return {
911
+ scrollLeft: element.pageXOffset,
912
+ scrollTop: element.pageYOffset
913
+ };
914
+ }
915
+
916
+ function getWindowScrollBarX(element) {
917
+ // If <html> has a CSS width greater than the viewport, then this will be
918
+ // incorrect for RTL.
919
+ return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
920
+ }
921
+
922
+ function isScaled(element) {
923
+ const rect = getBoundingClientRect(element);
924
+ return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
925
+ }
926
+
927
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
928
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
929
+ const documentElement = getDocumentElement(offsetParent);
930
+ const rect = getBoundingClientRect(element, // @ts-ignore - checked above (TS 4.1 compat)
931
+ isOffsetParentAnElement && isScaled(offsetParent), strategy === 'fixed');
932
+ let scroll = {
933
+ scrollLeft: 0,
934
+ scrollTop: 0
935
+ };
936
+ const offsets = {
937
+ x: 0,
938
+ y: 0
939
+ };
940
+
941
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
942
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
943
+ scroll = getNodeScroll(offsetParent);
944
+ }
945
+
946
+ if (isHTMLElement(offsetParent)) {
947
+ const offsetRect = getBoundingClientRect(offsetParent, true);
948
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
949
+ offsets.y = offsetRect.y + offsetParent.clientTop;
950
+ } else if (documentElement) {
951
+ offsets.x = getWindowScrollBarX(documentElement);
952
+ }
953
+ }
954
+
955
+ return {
956
+ x: rect.left + scroll.scrollLeft - offsets.x,
957
+ y: rect.top + scroll.scrollTop - offsets.y,
958
+ width: rect.width,
959
+ height: rect.height
960
+ };
961
+ }
962
+
963
+ function getParentNode(node) {
964
+ if (getNodeName(node) === 'html') {
965
+ return node;
966
+ }
967
+
968
+ const result = // Step into the shadow DOM of the parent of a slotted node
969
+ node.assignedSlot || // DOM Element detected
970
+ node.parentNode || ( // ShadowRoot detected
971
+ isShadowRoot(node) ? node.host : null) || // Fallback
972
+ getDocumentElement(node);
973
+ return isShadowRoot(result) ? result.host : result;
974
+ }
975
+
976
+ function getTrueOffsetParent(element) {
977
+ if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
978
+ return null;
979
+ }
980
+
981
+ return element.offsetParent;
982
+ }
983
+
984
+ function getContainingBlock(element) {
985
+ let currentNode = getParentNode(element);
986
+
987
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
988
+ if (isContainingBlock(currentNode)) {
989
+ return currentNode;
990
+ } else {
991
+ currentNode = getParentNode(currentNode);
992
+ }
993
+ }
994
+
995
+ return null;
996
+ } // Gets the closest ancestor positioned element. Handles some edge cases,
997
+ // such as table ancestors and cross browser bugs.
998
+
999
+
1000
+ function getOffsetParent(element) {
1001
+ const window = getWindow(element);
1002
+ let offsetParent = getTrueOffsetParent(element);
1003
+
1004
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
1005
+ offsetParent = getTrueOffsetParent(offsetParent);
1006
+ }
1007
+
1008
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
1009
+ return window;
1010
+ }
1011
+
1012
+ return offsetParent || getContainingBlock(element) || window;
1013
+ }
1014
+
1015
+ function getDimensions(element) {
1016
+ if (isHTMLElement(element)) {
1017
+ return {
1018
+ width: element.offsetWidth,
1019
+ height: element.offsetHeight
1020
+ };
1021
+ }
1022
+
1023
+ const rect = getBoundingClientRect(element);
1024
+ return {
1025
+ width: rect.width,
1026
+ height: rect.height
1027
+ };
1028
+ }
1029
+
1030
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1031
+ let {
1032
+ rect,
1033
+ offsetParent,
1034
+ strategy
1035
+ } = _ref;
1036
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1037
+ const documentElement = getDocumentElement(offsetParent);
1038
+
1039
+ if (offsetParent === documentElement) {
1040
+ return rect;
1041
+ }
1042
+
1043
+ let scroll = {
1044
+ scrollLeft: 0,
1045
+ scrollTop: 0
1046
+ };
1047
+ const offsets = {
1048
+ x: 0,
1049
+ y: 0
1050
+ };
1051
+
1052
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
1053
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1054
+ scroll = getNodeScroll(offsetParent);
1055
+ }
1056
+
1057
+ if (isHTMLElement(offsetParent)) {
1058
+ const offsetRect = getBoundingClientRect(offsetParent, true);
1059
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1060
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1061
+ } // This doesn't appear to be need to be negated.
1062
+ // else if (documentElement) {
1063
+ // offsets.x = getWindowScrollBarX(documentElement);
1064
+ // }
1065
+
1066
+ }
1067
+
1068
+ return { ...rect,
1069
+ x: rect.x - scroll.scrollLeft + offsets.x,
1070
+ y: rect.y - scroll.scrollTop + offsets.y
1071
+ };
1072
+ }
1073
+
1074
+ function getViewportRect(element, strategy) {
1075
+ const win = getWindow(element);
1076
+ const html = getDocumentElement(element);
1077
+ const visualViewport = win.visualViewport;
1078
+ let width = html.clientWidth;
1079
+ let height = html.clientHeight;
1080
+ let x = 0;
1081
+ let y = 0;
1082
+
1083
+ if (visualViewport) {
1084
+ width = visualViewport.width;
1085
+ height = visualViewport.height;
1086
+ const layoutViewport = isLayoutViewport();
1087
+
1088
+ if (layoutViewport || !layoutViewport && strategy === 'fixed') {
1089
+ x = visualViewport.offsetLeft;
1090
+ y = visualViewport.offsetTop;
1091
+ }
1092
+ }
1093
+
1094
+ return {
1095
+ width,
1096
+ height,
1097
+ x,
1098
+ y
1099
+ };
1100
+ }
1101
+
1102
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable
1103
+
1104
+ function getDocumentRect(element) {
1105
+ var _element$ownerDocumen;
1106
+
1107
+ const html = getDocumentElement(element);
1108
+ const scroll = getNodeScroll(element);
1109
+ const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
1110
+ const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
1111
+ const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
1112
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1113
+ const y = -scroll.scrollTop;
1114
+
1115
+ if (getComputedStyle(body || html).direction === 'rtl') {
1116
+ x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
1117
+ }
1118
+
1119
+ return {
1120
+ width,
1121
+ height,
1122
+ x,
1123
+ y
1124
+ };
1125
+ }
1126
+
1127
+ function getNearestOverflowAncestor(node) {
1128
+ const parentNode = getParentNode(node);
1129
+
1130
+ if (isLastTraversableNode(parentNode)) {
1131
+ // @ts-ignore assume body is always available
1132
+ return node.ownerDocument.body;
1133
+ }
1134
+
1135
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1136
+ return parentNode;
1137
+ }
1138
+
1139
+ return getNearestOverflowAncestor(parentNode);
1140
+ }
1141
+
1142
+ function getOverflowAncestors(node, list) {
1143
+ var _node$ownerDocument;
1144
+
1145
+ if (list === void 0) {
1146
+ list = [];
1147
+ }
1148
+
1149
+ const scrollableAncestor = getNearestOverflowAncestor(node);
1150
+ const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
1151
+ const win = getWindow(scrollableAncestor);
1152
+ const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
1153
+ const updatedList = list.concat(target);
1154
+ return isBody ? updatedList : // @ts-ignore: isBody tells us target will be an HTMLElement here
1155
+ updatedList.concat(getOverflowAncestors(target));
1156
+ }
1157
+
1158
+ function getInnerBoundingClientRect(element, strategy) {
1159
+ const clientRect = getBoundingClientRect(element, false, strategy === 'fixed');
1160
+ const top = clientRect.top + element.clientTop;
1161
+ const left = clientRect.left + element.clientLeft;
1162
+ return {
1163
+ top,
1164
+ left,
1165
+ x: left,
1166
+ y: top,
1167
+ right: left + element.clientWidth,
1168
+ bottom: top + element.clientHeight,
1169
+ width: element.clientWidth,
1170
+ height: element.clientHeight
1171
+ };
1172
+ }
1173
+
1174
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1175
+ if (clippingAncestor === 'viewport') {
1176
+ return rectToClientRect(getViewportRect(element, strategy));
1177
+ }
1178
+
1179
+ if (isElement(clippingAncestor)) {
1180
+ return getInnerBoundingClientRect(clippingAncestor, strategy);
1181
+ }
1182
+
1183
+ return rectToClientRect(getDocumentRect(getDocumentElement(element)));
1184
+ } // A "clipping ancestor" is an overflowable container with the characteristic of
1185
+ // clipping (or hiding) overflowing elements with a position different from
1186
+ // `initial`
1187
+
1188
+
1189
+ function getClippingElementAncestors(element) {
1190
+ let result = getOverflowAncestors(element).filter(el => isElement(el) && getNodeName(el) !== 'body');
1191
+ let currentNode = element;
1192
+ let currentContainingBlockComputedStyle = null; // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1193
+
1194
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1195
+ const computedStyle = getComputedStyle(currentNode);
1196
+
1197
+ if (computedStyle.position === 'static' && currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) && !isContainingBlock(currentNode)) {
1198
+ // Drop non-containing blocks
1199
+ result = result.filter(ancestor => ancestor !== currentNode);
1200
+ } else {
1201
+ // Record last containing block for next iteration
1202
+ currentContainingBlockComputedStyle = computedStyle;
1203
+ }
1204
+
1205
+ currentNode = getParentNode(currentNode);
1206
+ }
1207
+
1208
+ return result;
1209
+ } // Gets the maximum area that the element is visible in due to any number of
1210
+ // clipping ancestors
1211
+
1212
+
1213
+ function getClippingRect(_ref) {
1214
+ let {
1215
+ element,
1216
+ boundary,
1217
+ rootBoundary,
1218
+ strategy
1219
+ } = _ref;
1220
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element) : [].concat(boundary);
1221
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1222
+ const firstClippingAncestor = clippingAncestors[0];
1223
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1224
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1225
+ accRect.top = max(rect.top, accRect.top);
1226
+ accRect.right = min(rect.right, accRect.right);
1227
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1228
+ accRect.left = max(rect.left, accRect.left);
1229
+ return accRect;
1230
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1231
+ return {
1232
+ width: clippingRect.right - clippingRect.left,
1233
+ height: clippingRect.bottom - clippingRect.top,
1234
+ x: clippingRect.left,
1235
+ y: clippingRect.top
1236
+ };
1237
+ }
1238
+
1239
+ const platform = {
1240
+ getClippingRect,
1241
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1242
+ isElement,
1243
+ getDimensions,
1244
+ getOffsetParent,
1245
+ getDocumentElement,
1246
+ getElementRects: _ref => {
1247
+ let {
1248
+ reference,
1249
+ floating,
1250
+ strategy
1251
+ } = _ref;
1252
+ return {
1253
+ reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
1254
+ floating: { ...getDimensions(floating),
1255
+ x: 0,
1256
+ y: 0
1257
+ }
1258
+ };
1259
+ },
1260
+ getClientRects: element => Array.from(element.getClientRects()),
1261
+ isRTL: element => getComputedStyle(element).direction === 'rtl'
1262
+ };
1263
+
1264
+ /**
1265
+ * Automatically updates the position of the floating element when necessary.
1266
+ * @see https://floating-ui.com/docs/autoUpdate
1267
+ */
1268
+ function autoUpdate(reference, floating, update, options) {
1269
+ if (options === void 0) {
1270
+ options = {};
1271
+ }
1272
+
1273
+ const {
1274
+ ancestorScroll: _ancestorScroll = true,
1275
+ ancestorResize = true,
1276
+ elementResize = true,
1277
+ animationFrame = false
1278
+ } = options;
1279
+ const ancestorScroll = _ancestorScroll && !animationFrame;
1280
+ const ancestors = ancestorScroll || ancestorResize ? [...(isElement(reference) ? getOverflowAncestors(reference) : reference.contextElement ? getOverflowAncestors(reference.contextElement) : []), ...getOverflowAncestors(floating)] : [];
1281
+ ancestors.forEach(ancestor => {
1282
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
1283
+ passive: true
1284
+ });
1285
+ ancestorResize && ancestor.addEventListener('resize', update);
1286
+ });
1287
+ let observer = null;
1288
+
1289
+ if (elementResize) {
1290
+ let initialUpdate = true;
1291
+ observer = new ResizeObserver(() => {
1292
+ if (!initialUpdate) {
1293
+ update();
1294
+ }
1295
+
1296
+ initialUpdate = false;
1297
+ });
1298
+ isElement(reference) && !animationFrame && observer.observe(reference);
1299
+
1300
+ if (!isElement(reference) && reference.contextElement && !animationFrame) {
1301
+ observer.observe(reference.contextElement);
1302
+ }
1303
+
1304
+ observer.observe(floating);
1305
+ }
1306
+
1307
+ let frameId;
1308
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1309
+
1310
+ if (animationFrame) {
1311
+ frameLoop();
1312
+ }
1313
+
1314
+ function frameLoop() {
1315
+ const nextRefRect = getBoundingClientRect(reference);
1316
+
1317
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
1318
+ update();
1319
+ }
1320
+
1321
+ prevRefRect = nextRefRect;
1322
+ frameId = requestAnimationFrame(frameLoop);
1323
+ }
1324
+
1325
+ update();
1326
+ return () => {
1327
+ var _observer;
1328
+
1329
+ ancestors.forEach(ancestor => {
1330
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
1331
+ ancestorResize && ancestor.removeEventListener('resize', update);
1332
+ });
1333
+ (_observer = observer) == null ? void 0 : _observer.disconnect();
1334
+ observer = null;
1335
+
1336
+ if (animationFrame) {
1337
+ cancelAnimationFrame(frameId);
1338
+ }
1339
+ };
1340
+ }
1341
+
1342
+ /**
1343
+ * Computes the `x` and `y` coordinates that will place the floating element
1344
+ * next to a reference element when it is given a certain CSS positioning
1345
+ * strategy.
1346
+ */
1347
+
1348
+ const computePosition = (reference, floating, options) => computePosition$1(reference, floating, {
1349
+ platform,
1350
+ ...options
1351
+ });
1352
+
1353
+ function getAlignment(placement) {
1354
+ if (placement.includes('-end')) {
1355
+ return 'end';
1356
+ }
1357
+ else if (placement.includes('-start')) {
1358
+ return 'start';
1359
+ }
1360
+ return undefined;
1361
+ }
1362
+
1363
+ export { autoPlacement as a, autoUpdate as b, arrow as c, computePosition as d, getAlignment as g, inline as i, offset as o, shift as s };