@vonage/vivid 3.27.0 → 3.29.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.
- package/README.md +2 -1
- package/accordion/index.js +0 -2
- package/accordion-item/index.js +0 -2
- package/alert/index.js +0 -2
- package/avatar/index.js +0 -2
- package/badge/index.js +0 -2
- package/banner/index.js +0 -2
- package/breadcrumb-item/index.js +0 -2
- package/button/index.js +0 -2
- package/calendar/index.js +0 -1
- package/calendar-event/index.js +0 -2
- package/card/index.js +0 -2
- package/checkbox/index.js +0 -2
- package/combobox/index.js +0 -3
- package/custom-elements.json +173 -52
- package/data-grid/index.js +1 -5
- package/dialog/index.js +0 -2
- package/empty-state/index.js +0 -2
- package/fab/index.js +0 -2
- package/file-picker/index.js +0 -2
- package/icon/index.js +0 -2
- package/index.d.ts +3 -3
- package/index.js +1 -6
- package/lib/accordion/accordion.d.ts +5 -5
- package/lib/accordion/accordion.template.d.ts +3 -3
- package/lib/accordion/definition.d.ts +2 -2
- package/lib/accordion/index.d.ts +1 -1
- package/lib/accordion-item/accordion-item.d.ts +12 -12
- package/lib/accordion-item/accordion-item.template.d.ts +4 -4
- package/lib/accordion-item/definition.d.ts +1 -1
- package/lib/accordion-item/index.d.ts +1 -1
- package/lib/action-group/action-group.d.ts +11 -11
- package/lib/action-group/action-group.template.d.ts +4 -4
- package/lib/action-group/definition.d.ts +2 -2
- package/lib/action-group/index.d.ts +1 -1
- package/lib/alert/alert.d.ts +22 -22
- package/lib/alert/alert.template.d.ts +4 -4
- package/lib/alert/definition.d.ts +2 -2
- package/lib/alert/index.d.ts +1 -1
- package/lib/avatar/avatar.d.ts +14 -14
- package/lib/avatar/avatar.template.d.ts +4 -4
- package/lib/avatar/definition.d.ts +2 -2
- package/lib/avatar/index.d.ts +1 -1
- package/lib/badge/badge.d.ts +14 -14
- package/lib/badge/badge.template.d.ts +4 -4
- package/lib/badge/definition.d.ts +4 -4
- package/lib/badge/index.d.ts +1 -1
- package/lib/banner/banner.d.ts +20 -20
- package/lib/banner/banner.template.d.ts +4 -4
- package/lib/banner/definition.d.ts +2 -2
- package/lib/banner/index.d.ts +1 -1
- package/lib/breadcrumb/breadcrumb.d.ts +3 -3
- package/lib/breadcrumb/breadcrumb.template.d.ts +4 -4
- package/lib/breadcrumb/definition.d.ts +1 -1
- package/lib/breadcrumb/index.d.ts +1 -1
- package/lib/breadcrumb-item/breadcrumb-item.d.ts +5 -5
- package/lib/breadcrumb-item/breadcrumb-item.template.d.ts +4 -4
- package/lib/breadcrumb-item/definition.d.ts +1 -1
- package/lib/breadcrumb-item/index.d.ts +1 -1
- package/lib/button/button.d.ts +18 -18
- package/lib/button/button.template.d.ts +4 -4
- package/lib/button/definition.d.ts +2 -2
- package/lib/button/index.d.ts +1 -1
- package/lib/calendar/calendar.d.ts +13 -13
- package/lib/calendar/calendar.template.d.ts +4 -4
- package/lib/calendar/definition.d.ts +1 -1
- package/lib/calendar/helpers/calendar.date-functions.d.ts +2 -2
- package/lib/calendar/helpers/calendar.event-context.d.ts +6 -6
- package/lib/calendar/helpers/calendar.keyboard-interactions.d.ts +9 -9
- package/lib/calendar/index.d.ts +1 -1
- package/lib/calendar-event/calendar-event.d.ts +13 -13
- package/lib/calendar-event/calendar-event.template.d.ts +4 -4
- package/lib/calendar-event/definition.d.ts +2 -2
- package/lib/calendar-event/index.d.ts +1 -1
- package/lib/card/card.d.ts +10 -10
- package/lib/card/card.template.d.ts +4 -4
- package/lib/card/definition.d.ts +1 -1
- package/lib/card/index.d.ts +1 -1
- package/lib/checkbox/checkbox.d.ts +10 -11
- package/lib/checkbox/checkbox.template.d.ts +4 -4
- package/lib/checkbox/definition.d.ts +1 -1
- package/lib/checkbox/index.d.ts +1 -1
- package/lib/combobox/combobox.d.ts +12 -13
- package/lib/combobox/combobox.template.d.ts +4 -4
- package/lib/combobox/definition.d.ts +3 -4
- package/lib/combobox/index.d.ts +1 -1
- package/lib/components.d.ts +52 -52
- package/lib/data-grid/data-grid-cell.d.ts +22 -22
- package/lib/data-grid/data-grid-cell.template.d.ts +4 -4
- package/lib/data-grid/data-grid-row.d.ts +4 -4
- package/lib/data-grid/data-grid-row.template.d.ts +3 -3
- package/lib/data-grid/data-grid.d.ts +20 -20
- package/lib/data-grid/data-grid.options.d.ts +38 -38
- package/lib/data-grid/data-grid.template.d.ts +3 -3
- package/lib/data-grid/definition.d.ts +6 -6
- package/lib/data-grid/index.d.ts +1 -1
- package/lib/dialog/definition.d.ts +2 -2
- package/lib/dialog/dialog.d.ts +26 -26
- package/lib/dialog/dialog.template.d.ts +4 -4
- package/lib/dialog/index.d.ts +1 -1
- package/lib/divider/definition.d.ts +1 -1
- package/lib/divider/divider.d.ts +3 -3
- package/lib/divider/divider.template.d.ts +4 -4
- package/lib/divider/index.d.ts +1 -1
- package/lib/elevation/definition.d.ts +1 -1
- package/lib/elevation/elevation.d.ts +5 -5
- package/lib/elevation/elevation.template.d.ts +4 -4
- package/lib/elevation/index.d.ts +1 -1
- package/lib/empty-state/definition.d.ts +3 -3
- package/lib/empty-state/empty-state.d.ts +5 -5
- package/lib/empty-state/empty-state.template.d.ts +4 -4
- package/lib/empty-state/index.d.ts +1 -1
- package/lib/enums.d.ts +60 -60
- package/lib/fab/definition.d.ts +4 -4
- package/lib/fab/fab.d.ts +12 -12
- package/lib/fab/fab.template.d.ts +4 -4
- package/lib/fab/index.d.ts +1 -1
- package/lib/file-picker/definition.d.ts +3 -3
- package/lib/file-picker/file-picker.d.ts +22 -22
- package/lib/file-picker/file-picker.template.d.ts +4 -4
- package/lib/file-picker/index.d.ts +1 -1
- package/lib/focus/definition.d.ts +3 -3
- package/lib/focus/focus.d.ts +3 -3
- package/lib/focus/focus.template.d.ts +4 -4
- package/lib/focus/index.d.ts +1 -1
- package/lib/header/definition.d.ts +3 -3
- package/lib/header/header.d.ts +5 -5
- package/lib/header/header.template.d.ts +4 -4
- package/lib/header/index.d.ts +1 -1
- package/lib/icon/definition.d.ts +4 -4
- package/lib/icon/icon.d.ts +12 -12
- package/lib/icon/icon.placeholder.d.ts +1 -1
- package/lib/icon/icon.template.d.ts +4 -4
- package/lib/icon/index.d.ts +1 -1
- package/lib/layout/definition.d.ts +4 -4
- package/lib/layout/index.d.ts +1 -1
- package/lib/layout/layout.d.ts +17 -17
- package/lib/layout/layout.template.d.ts +4 -4
- package/lib/listbox/definition.d.ts +4 -4
- package/lib/listbox/index.d.ts +1 -1
- package/lib/listbox/listbox.d.ts +6 -6
- package/lib/listbox/listbox.template.d.ts +4 -4
- package/lib/menu/definition.d.ts +12 -12
- package/lib/menu/index.d.ts +1 -1
- package/lib/menu/menu.d.ts +16 -15
- package/lib/menu/menu.template.d.ts +3 -3
- package/lib/menu-item/definition.d.ts +3 -3
- package/lib/menu-item/index.d.ts +1 -1
- package/lib/menu-item/menu-item.d.ts +14 -14
- package/lib/menu-item/menu-item.template.d.ts +4 -4
- package/lib/nav/definition.d.ts +3 -3
- package/lib/nav/index.d.ts +1 -1
- package/lib/nav/nav.d.ts +3 -3
- package/lib/nav/nav.template.d.ts +4 -4
- package/lib/nav-disclosure/definition.d.ts +3 -3
- package/lib/nav-disclosure/index.d.ts +1 -1
- package/lib/nav-disclosure/nav-disclosure.d.ts +10 -10
- package/lib/nav-disclosure/nav-disclosure.template.d.ts +4 -4
- package/lib/nav-item/definition.d.ts +3 -3
- package/lib/nav-item/index.d.ts +1 -1
- package/lib/nav-item/nav-item.d.ts +7 -7
- package/lib/nav-item/nav-item.template.d.ts +4 -4
- package/lib/note/definition.d.ts +4 -4
- package/lib/note/index.d.ts +1 -1
- package/lib/note/note.d.ts +10 -10
- package/lib/note/note.template.d.ts +4 -4
- package/lib/number-field/definition.d.ts +5 -5
- package/lib/number-field/index.d.ts +1 -1
- package/lib/number-field/number-field.d.ts +13 -13
- package/lib/number-field/number-field.template.d.ts +4 -4
- package/lib/option/definition.d.ts +3 -3
- package/lib/option/index.d.ts +1 -1
- package/lib/option/option.d.ts +12 -12
- package/lib/option/option.template.d.ts +4 -4
- package/lib/pagination/definition.d.ts +3 -3
- package/lib/pagination/index.d.ts +1 -1
- package/lib/pagination/pagination.d.ts +18 -18
- package/lib/pagination/pagination.template.d.ts +4 -4
- package/lib/popup/definition.d.ts +5 -5
- package/lib/popup/index.d.ts +1 -1
- package/lib/popup/popup.d.ts +21 -21
- package/lib/popup/popup.template.d.ts +4 -4
- package/lib/progress/definition.d.ts +4 -4
- package/lib/progress/index.d.ts +1 -1
- package/lib/progress/progress.d.ts +9 -9
- package/lib/progress/progress.template.d.ts +5 -5
- package/lib/progress-ring/definition.d.ts +4 -4
- package/lib/progress-ring/index.d.ts +1 -1
- package/lib/progress-ring/progress-ring.d.ts +7 -7
- package/lib/progress-ring/progress-ring.template.d.ts +4 -4
- package/lib/radio/definition.d.ts +3 -3
- package/lib/radio/index.d.ts +1 -1
- package/lib/radio/radio.d.ts +7 -7
- package/lib/radio/radio.template.d.ts +4 -4
- package/lib/radio-group/definition.d.ts +11 -11
- package/lib/radio-group/index.d.ts +1 -1
- package/lib/radio-group/radio-group.d.ts +4 -4
- package/lib/radio-group/radio-group.template.d.ts +4 -4
- package/lib/select/definition.d.ts +4 -4
- package/lib/select/index.d.ts +1 -1
- package/lib/select/select.d.ts +17 -18
- package/lib/select/select.template.d.ts +4 -4
- package/lib/side-drawer/definition.d.ts +3 -3
- package/lib/side-drawer/index.d.ts +1 -1
- package/lib/side-drawer/side-drawer.d.ts +9 -9
- package/lib/side-drawer/side-drawer.template.d.ts +4 -4
- package/lib/slider/definition.d.ts +3 -3
- package/lib/slider/index.d.ts +1 -1
- package/lib/slider/slider.d.ts +4 -4
- package/lib/slider/slider.template.d.ts +4 -4
- package/lib/switch/definition.d.ts +4 -4
- package/lib/switch/index.d.ts +1 -1
- package/lib/switch/switch.d.ts +7 -7
- package/lib/switch/switch.template.d.ts +4 -4
- package/lib/tab/definition.d.ts +4 -4
- package/lib/tab/index.d.ts +1 -1
- package/lib/tab/tab.d.ts +14 -14
- package/lib/tab/tab.template.d.ts +3 -3
- package/lib/tab-panel/definition.d.ts +3 -3
- package/lib/tab-panel/index.d.ts +1 -1
- package/lib/tab-panel/tab-panel.d.ts +3 -3
- package/lib/tab-panel/tab-panel.template.d.ts +2 -2
- package/lib/tabs/definition.d.ts +3 -3
- package/lib/tabs/index.d.ts +1 -1
- package/lib/tabs/tabs.d.ts +15 -15
- package/lib/tabs/tabs.template.d.ts +2 -2
- package/lib/tag/definition.d.ts +4 -4
- package/lib/tag/index.d.ts +1 -1
- package/lib/tag/tag.d.ts +22 -22
- package/lib/tag/tag.template.d.ts +4 -4
- package/lib/tag-group/definition.d.ts +3 -3
- package/lib/tag-group/index.d.ts +1 -1
- package/lib/tag-group/tag-group.d.ts +3 -3
- package/lib/tag-group/tag-group.template.d.ts +4 -4
- package/lib/text-anchor/definition.d.ts +3 -3
- package/lib/text-anchor/index.d.ts +1 -1
- package/lib/text-anchor/text-anchor.d.ts +7 -7
- package/lib/text-anchor/text-anchor.template.d.ts +4 -4
- package/lib/text-area/definition.d.ts +4 -4
- package/lib/text-area/index.d.ts +1 -1
- package/lib/text-area/text-area.d.ts +8 -9
- package/lib/text-area/text-area.template.d.ts +4 -4
- package/lib/text-field/definition.d.ts +4 -4
- package/lib/text-field/index.d.ts +1 -1
- package/lib/text-field/text-field.d.ts +13 -14
- package/lib/text-field/text-field.template.d.ts +4 -4
- package/lib/toggletip/definition.d.ts +3 -3
- package/lib/toggletip/index.d.ts +1 -1
- package/lib/toggletip/toggletip.d.ts +15 -15
- package/lib/toggletip/toggletip.template.d.ts +4 -4
- package/lib/tooltip/definition.d.ts +3 -3
- package/lib/tooltip/index.d.ts +1 -1
- package/lib/tooltip/tooltip.d.ts +14 -14
- package/lib/tooltip/tooltip.template.d.ts +4 -4
- package/lib/tree-item/definition.d.ts +3 -3
- package/lib/tree-item/index.d.ts +1 -1
- package/lib/tree-item/tree-item.d.ts +7 -7
- package/lib/tree-item/tree-item.template.d.ts +4 -4
- package/lib/tree-view/definition.d.ts +3 -3
- package/lib/tree-view/index.d.ts +1 -1
- package/lib/tree-view/tree-view.d.ts +3 -3
- package/lib/tree-view/tree-view.template.d.ts +2 -2
- package/listbox/index.js +17 -21
- package/menu/index.js +0 -3
- package/menu-item/index.js +0 -3
- package/nav-disclosure/index.js +0 -2
- package/nav-item/index.js +0 -2
- package/note/index.js +0 -2
- package/number-field/index.js +0 -3
- package/option/index.js +0 -2
- package/package.json +9 -8
- package/pagination/index.js +1 -5
- package/popup/index.js +0 -3
- package/radio-group/index.js +2 -2
- package/select/index.js +0 -3
- package/shared/affix.js +2 -5
- package/shared/anchor.js +2 -1
- package/shared/apply-mixins.js +1 -1
- package/shared/definition.js +7 -9
- package/shared/definition10.js +13 -17
- package/shared/definition11.js +6 -9
- package/shared/definition12.js +16 -18
- package/shared/definition13.js +6 -8
- package/shared/definition14.js +7 -12
- package/shared/definition15.js +43 -52
- package/shared/definition16.js +8 -71
- package/shared/definition17.js +36 -45
- package/shared/definition18.js +19 -24
- package/shared/definition19.js +45 -49
- package/shared/definition2.js +24 -28
- package/shared/definition20.js +389 -280
- package/shared/definition21.js +12 -16
- package/shared/definition22.js +82 -168
- package/shared/definition23.js +35 -41
- package/shared/definition24.js +6 -8
- package/shared/definition25.js +10 -14
- package/shared/definition26.js +40 -42
- package/shared/definition27.js +24 -27
- package/shared/definition28.js +6 -8
- package/shared/definition29.js +3 -5
- package/shared/definition3.js +5 -9
- package/shared/definition30.js +88 -45
- package/shared/definition31.js +33 -43
- package/shared/definition32.js +2 -4
- package/shared/definition33.js +11 -15
- package/shared/definition34.js +5 -9
- package/shared/definition35.js +7 -11
- package/shared/definition36.js +66 -71
- package/shared/definition37.js +60 -101
- package/shared/definition38.js +14 -46
- package/shared/definition39.js +11 -14
- package/shared/definition4.js +3 -5
- package/shared/definition40.js +17 -20
- package/shared/definition41.js +56 -62
- package/shared/definition42.js +8 -11
- package/shared/definition43.js +20 -58
- package/shared/definition44.js +14 -17
- package/shared/definition45.js +8 -10
- package/shared/definition46.js +2 -4
- package/shared/definition47.js +12 -15
- package/shared/definition48.js +19 -24
- package/shared/definition49.js +3 -5
- package/shared/definition5.js +7 -8
- package/shared/definition50.js +51 -55
- package/shared/definition51.js +56 -60
- package/shared/definition52.js +12 -520
- package/shared/definition53.js +9 -11
- package/shared/definition54.js +27 -31
- package/shared/definition55.js +12 -14
- package/shared/definition6.js +17 -23
- package/shared/definition7.js +43 -47
- package/shared/definition8.js +3 -5
- package/shared/definition9.js +13 -17
- package/shared/design-system/index.d.ts +3 -3
- package/shared/focus2.js +1 -3
- package/shared/form-associated.js +1 -1
- package/shared/form-elements.js +16 -20
- package/shared/icon.js +2 -1171
- package/shared/index.js +41 -1549
- package/shared/listbox.js +1 -1
- package/shared/patterns/affix.d.ts +9 -9
- package/shared/patterns/focus.d.ts +3 -3
- package/shared/patterns/form-elements/form-elements.d.ts +57 -57
- package/shared/patterns/form-elements/index.d.ts +1 -1
- package/shared/patterns/index.d.ts +3 -3
- package/shared/repeat.js +1 -1
- package/shared/text-anchor.template.js +38 -40
- package/shared/text-field.js +1 -1
- package/shared/text-field2.js +1 -1
- package/shared/when.js +19 -5
- package/slider/index.js +0 -3
- package/styles/core/all.css +1 -1
- package/styles/core/theme.css +1 -1
- package/styles/core/typography.css +1 -1
- package/styles/tokens/theme-dark.css +17 -17
- package/styles/tokens/theme-light.css +17 -17
- package/switch/index.js +0 -2
- package/tab/index.js +0 -2
- package/tabs/index.js +0 -2
- package/tag/index.js +0 -2
- package/text-anchor/index.js +0 -2
- package/text-area/index.js +0 -2
- package/text-field/index.js +0 -2
- package/toggletip/index.js +0 -4
- package/tooltip/index.js +0 -3
- package/tree-item/index.js +1 -3
- package/vivid.api.json +48 -84
- package/shared/es.object.assign.js +0 -68
- package/shared/es.regexp.to-string.js +0 -61
- package/shared/es.string.includes.js +0 -83
- package/shared/string-trim.js +0 -40
- package/shared/to-string.js +0 -51
package/shared/definition20.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { F as FoundationElement,
|
|
1
|
+
import { F as FoundationElement, d as __classPrivateFieldGet, f as __classPrivateFieldSet, _ as __decorate, a as attr, b as __metadata, h as html, r as registerFactory } from './index.js';
|
|
2
2
|
import { B as Button, b as buttonRegistries } from './definition7.js';
|
|
3
3
|
import { E as Elevation, e as elevationRegistries } from './definition8.js';
|
|
4
|
-
import './icon.js';
|
|
5
|
-
import './es.object.assign.js';
|
|
6
|
-
import { w as when } from './when.js';
|
|
7
4
|
import { r as ref } from './ref.js';
|
|
5
|
+
import { w as when } from './when.js';
|
|
8
6
|
import { c as classNames } from './class-names.js';
|
|
9
7
|
|
|
10
8
|
function getAlignment(placement) {
|
|
@@ -170,6 +168,10 @@ const computePosition$1 = async (reference, floating, config) => {
|
|
|
170
168
|
};
|
|
171
169
|
};
|
|
172
170
|
|
|
171
|
+
function evaluate(value, param) {
|
|
172
|
+
return typeof value === 'function' ? value(param) : value;
|
|
173
|
+
}
|
|
174
|
+
|
|
173
175
|
function expandPaddingObject(padding) {
|
|
174
176
|
return {
|
|
175
177
|
top: 0,
|
|
@@ -201,13 +203,13 @@ function rectToClientRect(rect) {
|
|
|
201
203
|
|
|
202
204
|
/**
|
|
203
205
|
* Resolves with an object of overflow side offsets that determine how much the
|
|
204
|
-
* element is overflowing a given clipping boundary.
|
|
206
|
+
* element is overflowing a given clipping boundary on each side.
|
|
205
207
|
* - positive = overflowing the boundary by that number of pixels
|
|
206
208
|
* - negative = how many pixels left before it will overflow
|
|
207
209
|
* - 0 = lies flush with the boundary
|
|
208
210
|
* @see https://floating-ui.com/docs/detectOverflow
|
|
209
211
|
*/
|
|
210
|
-
async function detectOverflow(
|
|
212
|
+
async function detectOverflow(state, options) {
|
|
211
213
|
var _await$platform$isEle;
|
|
212
214
|
if (options === void 0) {
|
|
213
215
|
options = {};
|
|
@@ -219,14 +221,14 @@ async function detectOverflow(middlewareArguments, options) {
|
|
|
219
221
|
rects,
|
|
220
222
|
elements,
|
|
221
223
|
strategy
|
|
222
|
-
} =
|
|
224
|
+
} = state;
|
|
223
225
|
const {
|
|
224
226
|
boundary = 'clippingAncestors',
|
|
225
227
|
rootBoundary = 'viewport',
|
|
226
228
|
elementContext = 'floating',
|
|
227
229
|
altBoundary = false,
|
|
228
230
|
padding = 0
|
|
229
|
-
} = options;
|
|
231
|
+
} = evaluate(options, state);
|
|
230
232
|
const paddingObject = getSideObjectFromPadding(padding);
|
|
231
233
|
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
232
234
|
const element = elements[altBoundary ? altContext : elementContext];
|
|
@@ -270,27 +272,27 @@ function within(min$1$1, value, max$1$1) {
|
|
|
270
272
|
}
|
|
271
273
|
|
|
272
274
|
/**
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
* reference element.
|
|
275
|
+
* Provides data to position an inner element of the floating element so that it
|
|
276
|
+
* appears centered to the reference element.
|
|
276
277
|
* @see https://floating-ui.com/docs/arrow
|
|
277
278
|
*/
|
|
278
279
|
const arrow = options => ({
|
|
279
280
|
name: 'arrow',
|
|
280
281
|
options,
|
|
281
|
-
async fn(
|
|
282
|
-
// Since `element` is required, we don't Partial<> the type.
|
|
283
|
-
const {
|
|
284
|
-
element,
|
|
285
|
-
padding = 0
|
|
286
|
-
} = options || {};
|
|
282
|
+
async fn(state) {
|
|
287
283
|
const {
|
|
288
284
|
x,
|
|
289
285
|
y,
|
|
290
286
|
placement,
|
|
291
287
|
rects,
|
|
292
|
-
platform
|
|
293
|
-
|
|
288
|
+
platform,
|
|
289
|
+
elements
|
|
290
|
+
} = state;
|
|
291
|
+
// Since `element` is required, we don't Partial<> the type.
|
|
292
|
+
const {
|
|
293
|
+
element,
|
|
294
|
+
padding = 0
|
|
295
|
+
} = evaluate(options, state) || {};
|
|
294
296
|
if (element == null) {
|
|
295
297
|
return {};
|
|
296
298
|
}
|
|
@@ -302,35 +304,45 @@ const arrow = options => ({
|
|
|
302
304
|
const axis = getMainAxisFromPlacement(placement);
|
|
303
305
|
const length = getLengthFromAxis(axis);
|
|
304
306
|
const arrowDimensions = await platform.getDimensions(element);
|
|
305
|
-
const
|
|
306
|
-
const
|
|
307
|
+
const isYAxis = axis === 'y';
|
|
308
|
+
const minProp = isYAxis ? 'top' : 'left';
|
|
309
|
+
const maxProp = isYAxis ? 'bottom' : 'right';
|
|
310
|
+
const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
|
|
307
311
|
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
308
312
|
const startDiff = coords[axis] - rects.reference[axis];
|
|
309
313
|
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
|
310
|
-
let clientSize = arrowOffsetParent ?
|
|
311
|
-
|
|
312
|
-
|
|
314
|
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
315
|
+
|
|
316
|
+
// DOM platform can return `window` as the `offsetParent`.
|
|
317
|
+
if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
|
|
318
|
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
313
319
|
}
|
|
314
320
|
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
315
321
|
|
|
322
|
+
// If the padding is large enough that it causes the arrow to no longer be
|
|
323
|
+
// centered, modify the padding so that it is centered.
|
|
324
|
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
325
|
+
const minPadding = min$1(paddingObject[minProp], largestPossiblePadding);
|
|
326
|
+
const maxPadding = min$1(paddingObject[maxProp], largestPossiblePadding);
|
|
327
|
+
|
|
316
328
|
// Make sure the arrow doesn't overflow the floating element if the center
|
|
317
329
|
// point is outside the floating element's bounds.
|
|
318
|
-
const min =
|
|
319
|
-
const max = clientSize - arrowDimensions[length] -
|
|
330
|
+
const min$1$1 = minPadding;
|
|
331
|
+
const max = clientSize - arrowDimensions[length] - maxPadding;
|
|
320
332
|
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
321
|
-
const offset = within(min, center, max);
|
|
333
|
+
const offset = within(min$1$1, center, max);
|
|
322
334
|
|
|
323
335
|
// If the reference is small enough that the arrow's padding causes it to
|
|
324
336
|
// to point to nothing for an aligned placement, adjust the offset of the
|
|
325
337
|
// floating element itself. This stops `shift()` from taking action, but can
|
|
326
338
|
// be worked around by calling it again after the `arrow()` if desired.
|
|
327
|
-
const shouldAddOffset = getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min ?
|
|
328
|
-
const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;
|
|
339
|
+
const shouldAddOffset = getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min$1$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
340
|
+
const alignmentOffset = shouldAddOffset ? center < min$1$1 ? min$1$1 - center : max - center : 0;
|
|
329
341
|
return {
|
|
330
342
|
[axis]: coords[axis] - alignmentOffset,
|
|
331
343
|
data: {
|
|
332
344
|
[axis]: offset,
|
|
333
|
-
centerOffset: center - offset
|
|
345
|
+
centerOffset: center - offset + alignmentOffset
|
|
334
346
|
}
|
|
335
347
|
};
|
|
336
348
|
}
|
|
@@ -408,12 +420,9 @@ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
|
408
420
|
}
|
|
409
421
|
|
|
410
422
|
/**
|
|
411
|
-
*
|
|
412
|
-
* order to keep it in view
|
|
413
|
-
*
|
|
414
|
-
* It has the ability to flip to any placement, not just the opposite one. You
|
|
415
|
-
* can use a series of “fallback” placements, where each placement is
|
|
416
|
-
* progressively tried until the one that fits can be used.
|
|
423
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
424
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
425
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
417
426
|
* @see https://floating-ui.com/docs/flip
|
|
418
427
|
*/
|
|
419
428
|
const flip = function (options) {
|
|
@@ -423,7 +432,7 @@ const flip = function (options) {
|
|
|
423
432
|
return {
|
|
424
433
|
name: 'flip',
|
|
425
434
|
options,
|
|
426
|
-
async fn(
|
|
435
|
+
async fn(state) {
|
|
427
436
|
var _middlewareData$flip;
|
|
428
437
|
const {
|
|
429
438
|
placement,
|
|
@@ -432,7 +441,7 @@ const flip = function (options) {
|
|
|
432
441
|
initialPlacement,
|
|
433
442
|
platform,
|
|
434
443
|
elements
|
|
435
|
-
} =
|
|
444
|
+
} = state;
|
|
436
445
|
const {
|
|
437
446
|
mainAxis: checkMainAxis = true,
|
|
438
447
|
crossAxis: checkCrossAxis = true,
|
|
@@ -441,7 +450,7 @@ const flip = function (options) {
|
|
|
441
450
|
fallbackAxisSideDirection = 'none',
|
|
442
451
|
flipAlignment = true,
|
|
443
452
|
...detectOverflowOptions
|
|
444
|
-
} = options;
|
|
453
|
+
} = evaluate(options, state);
|
|
445
454
|
const side = getSide(placement);
|
|
446
455
|
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
447
456
|
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
@@ -450,7 +459,7 @@ const flip = function (options) {
|
|
|
450
459
|
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
451
460
|
}
|
|
452
461
|
const placements = [initialPlacement, ...fallbackPlacements];
|
|
453
|
-
const overflow = await detectOverflow(
|
|
462
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
454
463
|
const overflows = [];
|
|
455
464
|
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
456
465
|
if (checkMainAxis) {
|
|
@@ -532,9 +541,8 @@ function isAnySideFullyClipped(overflow) {
|
|
|
532
541
|
return sides.some(side => overflow[side] >= 0);
|
|
533
542
|
}
|
|
534
543
|
/**
|
|
535
|
-
*
|
|
536
|
-
*
|
|
537
|
-
* reference element.
|
|
544
|
+
* Provides data to hide the floating element in applicable situations, such as
|
|
545
|
+
* when it is not in the same clipping context as the reference element.
|
|
538
546
|
* @see https://floating-ui.com/docs/hide
|
|
539
547
|
*/
|
|
540
548
|
const hide = function (options) {
|
|
@@ -544,18 +552,18 @@ const hide = function (options) {
|
|
|
544
552
|
return {
|
|
545
553
|
name: 'hide',
|
|
546
554
|
options,
|
|
547
|
-
async fn(
|
|
555
|
+
async fn(state) {
|
|
556
|
+
const {
|
|
557
|
+
rects
|
|
558
|
+
} = state;
|
|
548
559
|
const {
|
|
549
560
|
strategy = 'referenceHidden',
|
|
550
561
|
...detectOverflowOptions
|
|
551
|
-
} = options;
|
|
552
|
-
const {
|
|
553
|
-
rects
|
|
554
|
-
} = middlewareArguments;
|
|
562
|
+
} = evaluate(options, state);
|
|
555
563
|
switch (strategy) {
|
|
556
564
|
case 'referenceHidden':
|
|
557
565
|
{
|
|
558
|
-
const overflow = await detectOverflow(
|
|
566
|
+
const overflow = await detectOverflow(state, {
|
|
559
567
|
...detectOverflowOptions,
|
|
560
568
|
elementContext: 'reference'
|
|
561
569
|
});
|
|
@@ -569,7 +577,7 @@ const hide = function (options) {
|
|
|
569
577
|
}
|
|
570
578
|
case 'escaped':
|
|
571
579
|
{
|
|
572
|
-
const overflow = await detectOverflow(
|
|
580
|
+
const overflow = await detectOverflow(state, {
|
|
573
581
|
...detectOverflowOptions,
|
|
574
582
|
altBoundary: true
|
|
575
583
|
});
|
|
@@ -590,6 +598,33 @@ const hide = function (options) {
|
|
|
590
598
|
};
|
|
591
599
|
};
|
|
592
600
|
|
|
601
|
+
function getBoundingRect(rects) {
|
|
602
|
+
const minX = min$1(...rects.map(rect => rect.left));
|
|
603
|
+
const minY = min$1(...rects.map(rect => rect.top));
|
|
604
|
+
const maxX = max$1(...rects.map(rect => rect.right));
|
|
605
|
+
const maxY = max$1(...rects.map(rect => rect.bottom));
|
|
606
|
+
return {
|
|
607
|
+
x: minX,
|
|
608
|
+
y: minY,
|
|
609
|
+
width: maxX - minX,
|
|
610
|
+
height: maxY - minY
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
function getRectsByLine(rects) {
|
|
614
|
+
const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
|
|
615
|
+
const groups = [];
|
|
616
|
+
let prevRect = null;
|
|
617
|
+
for (let i = 0; i < sortedRects.length; i++) {
|
|
618
|
+
const rect = sortedRects[i];
|
|
619
|
+
if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
|
|
620
|
+
groups.push([rect]);
|
|
621
|
+
} else {
|
|
622
|
+
groups[groups.length - 1].push(rect);
|
|
623
|
+
}
|
|
624
|
+
prevRect = rect;
|
|
625
|
+
}
|
|
626
|
+
return groups.map(rect => rectToClientRect(getBoundingRect(rect)));
|
|
627
|
+
}
|
|
593
628
|
/**
|
|
594
629
|
* Provides improved positioning for inline reference elements that can span
|
|
595
630
|
* over multiple lines, such as hyperlinks or range selections.
|
|
@@ -602,14 +637,14 @@ const inline = function (options) {
|
|
|
602
637
|
return {
|
|
603
638
|
name: 'inline',
|
|
604
639
|
options,
|
|
605
|
-
async fn(
|
|
640
|
+
async fn(state) {
|
|
606
641
|
const {
|
|
607
642
|
placement,
|
|
608
643
|
elements,
|
|
609
644
|
rects,
|
|
610
645
|
platform,
|
|
611
646
|
strategy
|
|
612
|
-
} =
|
|
647
|
+
} = state;
|
|
613
648
|
// A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
|
|
614
649
|
// ClientRect's bounds, despite the event listener being triggered. A
|
|
615
650
|
// padding of 2 seems to handle this issue.
|
|
@@ -617,13 +652,10 @@ const inline = function (options) {
|
|
|
617
652
|
padding = 2,
|
|
618
653
|
x,
|
|
619
654
|
y
|
|
620
|
-
} = options;
|
|
621
|
-
const
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
strategy
|
|
625
|
-
}) : rects.reference);
|
|
626
|
-
const clientRects = (await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || [];
|
|
655
|
+
} = evaluate(options, state);
|
|
656
|
+
const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
|
|
657
|
+
const clientRects = getRectsByLine(nativeClientRects);
|
|
658
|
+
const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
|
|
627
659
|
const paddingObject = getSideObjectFromPadding(padding);
|
|
628
660
|
function getBoundingClientRect() {
|
|
629
661
|
// There are two rects and they are disjoined.
|
|
@@ -697,19 +729,19 @@ const inline = function (options) {
|
|
|
697
729
|
};
|
|
698
730
|
};
|
|
699
731
|
|
|
700
|
-
async function convertValueToCoords(
|
|
732
|
+
async function convertValueToCoords(state, options) {
|
|
701
733
|
const {
|
|
702
734
|
placement,
|
|
703
735
|
platform,
|
|
704
736
|
elements
|
|
705
|
-
} =
|
|
737
|
+
} = state;
|
|
706
738
|
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
707
739
|
const side = getSide(placement);
|
|
708
740
|
const alignment = getAlignment(placement);
|
|
709
741
|
const isVertical = getMainAxisFromPlacement(placement) === 'x';
|
|
710
742
|
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
|
|
711
743
|
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
712
|
-
const rawValue =
|
|
744
|
+
const rawValue = evaluate(options, state);
|
|
713
745
|
|
|
714
746
|
// eslint-disable-next-line prefer-const
|
|
715
747
|
let {
|
|
@@ -739,25 +771,25 @@ async function convertValueToCoords(middlewareArguments, value) {
|
|
|
739
771
|
}
|
|
740
772
|
|
|
741
773
|
/**
|
|
742
|
-
*
|
|
743
|
-
* axes.
|
|
774
|
+
* Modifies the placement by translating the floating element along the
|
|
775
|
+
* specified axes.
|
|
744
776
|
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
745
777
|
* object may be passed.
|
|
746
778
|
* @see https://floating-ui.com/docs/offset
|
|
747
779
|
*/
|
|
748
|
-
const offset = function (
|
|
749
|
-
if (
|
|
750
|
-
|
|
780
|
+
const offset = function (options) {
|
|
781
|
+
if (options === void 0) {
|
|
782
|
+
options = 0;
|
|
751
783
|
}
|
|
752
784
|
return {
|
|
753
785
|
name: 'offset',
|
|
754
|
-
options
|
|
755
|
-
async fn(
|
|
786
|
+
options,
|
|
787
|
+
async fn(state) {
|
|
756
788
|
const {
|
|
757
789
|
x,
|
|
758
790
|
y
|
|
759
|
-
} =
|
|
760
|
-
const diffCoords = await convertValueToCoords(
|
|
791
|
+
} = state;
|
|
792
|
+
const diffCoords = await convertValueToCoords(state, options);
|
|
761
793
|
return {
|
|
762
794
|
x: x + diffCoords.x,
|
|
763
795
|
y: y + diffCoords.y,
|
|
@@ -769,68 +801,35 @@ const offset = function (value) {
|
|
|
769
801
|
|
|
770
802
|
function getWindow(node) {
|
|
771
803
|
var _node$ownerDocument;
|
|
772
|
-
return ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
804
|
+
return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
773
805
|
}
|
|
774
806
|
|
|
775
807
|
function getComputedStyle$1(element) {
|
|
776
808
|
return getWindow(element).getComputedStyle(element);
|
|
777
809
|
}
|
|
778
810
|
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
const round = Math.round;
|
|
782
|
-
|
|
783
|
-
function getCssDimensions(element) {
|
|
784
|
-
const css = getComputedStyle$1(element);
|
|
785
|
-
let width = parseFloat(css.width);
|
|
786
|
-
let height = parseFloat(css.height);
|
|
787
|
-
const offsetWidth = element.offsetWidth;
|
|
788
|
-
const offsetHeight = element.offsetHeight;
|
|
789
|
-
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
790
|
-
if (shouldFallback) {
|
|
791
|
-
width = offsetWidth;
|
|
792
|
-
height = offsetHeight;
|
|
793
|
-
}
|
|
794
|
-
return {
|
|
795
|
-
width,
|
|
796
|
-
height,
|
|
797
|
-
fallback: shouldFallback
|
|
798
|
-
};
|
|
811
|
+
function isNode(value) {
|
|
812
|
+
return value instanceof getWindow(value).Node;
|
|
799
813
|
}
|
|
800
|
-
|
|
801
814
|
function getNodeName(node) {
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
let uaString;
|
|
806
|
-
function getUAString() {
|
|
807
|
-
if (uaString) {
|
|
808
|
-
return uaString;
|
|
815
|
+
if (isNode(node)) {
|
|
816
|
+
return (node.nodeName || '').toLowerCase();
|
|
809
817
|
}
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
}
|
|
815
|
-
return navigator.userAgent;
|
|
818
|
+
// Mocked nodes in testing environments may not be instances of Node. By
|
|
819
|
+
// returning `#document` an infinite loop won't occur.
|
|
820
|
+
// https://github.com/floating-ui/floating-ui/issues/2317
|
|
821
|
+
return '#document';
|
|
816
822
|
}
|
|
817
823
|
|
|
818
824
|
function isHTMLElement(value) {
|
|
819
|
-
return value instanceof getWindow(value).HTMLElement;
|
|
820
|
-
}
|
|
821
|
-
function isElement(value) {
|
|
822
|
-
return value instanceof getWindow(value).Element;
|
|
823
|
-
}
|
|
824
|
-
function isNode(value) {
|
|
825
|
-
return value instanceof getWindow(value).Node;
|
|
825
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
826
826
|
}
|
|
827
827
|
function isShadowRoot(node) {
|
|
828
828
|
// Browsers without `ShadowRoot` support.
|
|
829
829
|
if (typeof ShadowRoot === 'undefined') {
|
|
830
830
|
return false;
|
|
831
831
|
}
|
|
832
|
-
|
|
833
|
-
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
832
|
+
return node instanceof getWindow(node).ShadowRoot || node instanceof ShadowRoot;
|
|
834
833
|
}
|
|
835
834
|
function isOverflowElement(element) {
|
|
836
835
|
const {
|
|
@@ -845,62 +844,71 @@ function isTableElement(element) {
|
|
|
845
844
|
return ['table', 'td', 'th'].includes(getNodeName(element));
|
|
846
845
|
}
|
|
847
846
|
function isContainingBlock(element) {
|
|
848
|
-
|
|
849
|
-
const isFirefox = /firefox/i.test(getUAString());
|
|
847
|
+
const safari = isSafari();
|
|
850
848
|
const css = getComputedStyle$1(element);
|
|
851
|
-
const backdropFilter = css.backdropFilter || css.WebkitBackdropFilter;
|
|
852
849
|
|
|
853
|
-
// This is non-exhaustive but covers the most common CSS properties that
|
|
854
|
-
// create a containing block.
|
|
855
850
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
856
|
-
return css.transform !== 'none' || css.perspective !== 'none' || (
|
|
857
|
-
// Add type check for old browsers.
|
|
858
|
-
const contain = css.contain;
|
|
859
|
-
return contain != null ? contain.includes(value) : false;
|
|
860
|
-
});
|
|
851
|
+
return css.transform !== 'none' || css.perspective !== 'none' || (css.containerType ? css.containerType !== 'normal' : false) || !safari && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !safari && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
|
|
861
852
|
}
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
* viewport offsets. In Safari, the `x`/`y` offsets are values relative to the
|
|
866
|
-
* visual viewport, while in other engines, they are values relative to the
|
|
867
|
-
* layout viewport.
|
|
868
|
-
*/
|
|
869
|
-
function isClientRectVisualViewportBased() {
|
|
870
|
-
// TODO: Try to use feature detection here instead. Feature detection for
|
|
871
|
-
// this can fail in various ways, making the userAgent check the most
|
|
872
|
-
// reliable:
|
|
873
|
-
// • Always-visible scrollbar or not
|
|
874
|
-
// • Width of <html>
|
|
875
|
-
|
|
876
|
-
// Is Safari.
|
|
877
|
-
return /^((?!chrome|android).)*safari/i.test(getUAString());
|
|
853
|
+
function isSafari() {
|
|
854
|
+
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
|
855
|
+
return CSS.supports('-webkit-backdrop-filter', 'none');
|
|
878
856
|
}
|
|
879
857
|
function isLastTraversableNode(node) {
|
|
880
858
|
return ['html', 'body', '#document'].includes(getNodeName(node));
|
|
881
859
|
}
|
|
882
860
|
|
|
861
|
+
const min = Math.min;
|
|
862
|
+
const max = Math.max;
|
|
863
|
+
const round = Math.round;
|
|
864
|
+
const floor = Math.floor;
|
|
865
|
+
const createCoords = v => ({
|
|
866
|
+
x: v,
|
|
867
|
+
y: v
|
|
868
|
+
});
|
|
869
|
+
|
|
870
|
+
function getCssDimensions(element) {
|
|
871
|
+
const css = getComputedStyle$1(element);
|
|
872
|
+
// In testing environments, the `width` and `height` properties are empty
|
|
873
|
+
// strings for SVG elements, returning NaN. Fallback to `0` in this case.
|
|
874
|
+
let width = parseFloat(css.width) || 0;
|
|
875
|
+
let height = parseFloat(css.height) || 0;
|
|
876
|
+
const hasOffset = isHTMLElement(element);
|
|
877
|
+
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
878
|
+
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
879
|
+
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
880
|
+
if (shouldFallback) {
|
|
881
|
+
width = offsetWidth;
|
|
882
|
+
height = offsetHeight;
|
|
883
|
+
}
|
|
884
|
+
return {
|
|
885
|
+
width,
|
|
886
|
+
height,
|
|
887
|
+
$: shouldFallback
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
function isElement(value) {
|
|
892
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
893
|
+
}
|
|
894
|
+
|
|
883
895
|
function unwrapElement(element) {
|
|
884
896
|
return !isElement(element) ? element.contextElement : element;
|
|
885
897
|
}
|
|
886
898
|
|
|
887
|
-
const FALLBACK_SCALE = {
|
|
888
|
-
x: 1,
|
|
889
|
-
y: 1
|
|
890
|
-
};
|
|
891
899
|
function getScale(element) {
|
|
892
900
|
const domElement = unwrapElement(element);
|
|
893
901
|
if (!isHTMLElement(domElement)) {
|
|
894
|
-
return
|
|
902
|
+
return createCoords(1);
|
|
895
903
|
}
|
|
896
904
|
const rect = domElement.getBoundingClientRect();
|
|
897
905
|
const {
|
|
898
906
|
width,
|
|
899
907
|
height,
|
|
900
|
-
|
|
908
|
+
$
|
|
901
909
|
} = getCssDimensions(domElement);
|
|
902
|
-
let x = (
|
|
903
|
-
let y = (
|
|
910
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
911
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
904
912
|
|
|
905
913
|
// 0, NaN, or Infinity should always fallback to 1.
|
|
906
914
|
|
|
@@ -916,8 +924,28 @@ function getScale(element) {
|
|
|
916
924
|
};
|
|
917
925
|
}
|
|
918
926
|
|
|
927
|
+
const noOffsets = /*#__PURE__*/createCoords(0);
|
|
928
|
+
function getVisualOffsets(element) {
|
|
929
|
+
const win = getWindow(element);
|
|
930
|
+
if (!isSafari() || !win.visualViewport) {
|
|
931
|
+
return noOffsets;
|
|
932
|
+
}
|
|
933
|
+
return {
|
|
934
|
+
x: win.visualViewport.offsetLeft,
|
|
935
|
+
y: win.visualViewport.offsetTop
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
939
|
+
if (isFixed === void 0) {
|
|
940
|
+
isFixed = false;
|
|
941
|
+
}
|
|
942
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
943
|
+
return false;
|
|
944
|
+
}
|
|
945
|
+
return isFixed;
|
|
946
|
+
}
|
|
947
|
+
|
|
919
948
|
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
920
|
-
var _win$visualViewport, _win$visualViewport2;
|
|
921
949
|
if (includeScale === void 0) {
|
|
922
950
|
includeScale = false;
|
|
923
951
|
}
|
|
@@ -926,7 +954,7 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
926
954
|
}
|
|
927
955
|
const clientRect = element.getBoundingClientRect();
|
|
928
956
|
const domElement = unwrapElement(element);
|
|
929
|
-
let scale =
|
|
957
|
+
let scale = createCoords(1);
|
|
930
958
|
if (includeScale) {
|
|
931
959
|
if (offsetParent) {
|
|
932
960
|
if (isElement(offsetParent)) {
|
|
@@ -936,10 +964,9 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
936
964
|
scale = getScale(element);
|
|
937
965
|
}
|
|
938
966
|
}
|
|
939
|
-
const
|
|
940
|
-
|
|
941
|
-
let
|
|
942
|
-
let y = (clientRect.top + (addVisualOffsets ? ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0 : 0)) / scale.y;
|
|
967
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
968
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
969
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
943
970
|
let width = clientRect.width / scale.x;
|
|
944
971
|
let height = clientRect.height / scale.y;
|
|
945
972
|
if (domElement) {
|
|
@@ -950,31 +977,23 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
950
977
|
const iframeScale = getScale(currentIFrame);
|
|
951
978
|
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
952
979
|
const css = getComputedStyle(currentIFrame);
|
|
953
|
-
iframeRect.
|
|
954
|
-
iframeRect.
|
|
980
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
981
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
955
982
|
x *= iframeScale.x;
|
|
956
983
|
y *= iframeScale.y;
|
|
957
984
|
width *= iframeScale.x;
|
|
958
985
|
height *= iframeScale.y;
|
|
959
|
-
x +=
|
|
960
|
-
y +=
|
|
986
|
+
x += left;
|
|
987
|
+
y += top;
|
|
961
988
|
currentIFrame = getWindow(currentIFrame).frameElement;
|
|
962
989
|
}
|
|
963
990
|
}
|
|
964
|
-
return {
|
|
991
|
+
return rectToClientRect({
|
|
965
992
|
width,
|
|
966
993
|
height,
|
|
967
|
-
top: y,
|
|
968
|
-
right: x + width,
|
|
969
|
-
bottom: y + height,
|
|
970
|
-
left: x,
|
|
971
994
|
x,
|
|
972
995
|
y
|
|
973
|
-
};
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
function getDocumentElement(node) {
|
|
977
|
-
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
|
|
996
|
+
});
|
|
978
997
|
}
|
|
979
998
|
|
|
980
999
|
function getNodeScroll(element) {
|
|
@@ -990,6 +1009,11 @@ function getNodeScroll(element) {
|
|
|
990
1009
|
};
|
|
991
1010
|
}
|
|
992
1011
|
|
|
1012
|
+
function getDocumentElement(node) {
|
|
1013
|
+
var _ref;
|
|
1014
|
+
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
993
1017
|
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
994
1018
|
let {
|
|
995
1019
|
rect,
|
|
@@ -1005,14 +1029,8 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
|
1005
1029
|
scrollLeft: 0,
|
|
1006
1030
|
scrollTop: 0
|
|
1007
1031
|
};
|
|
1008
|
-
let scale =
|
|
1009
|
-
|
|
1010
|
-
y: 1
|
|
1011
|
-
};
|
|
1012
|
-
const offsets = {
|
|
1013
|
-
x: 0,
|
|
1014
|
-
y: 0
|
|
1015
|
-
};
|
|
1032
|
+
let scale = createCoords(1);
|
|
1033
|
+
const offsets = createCoords(0);
|
|
1016
1034
|
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
1017
1035
|
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1018
1036
|
scroll = getNodeScroll(offsetParent);
|
|
@@ -1032,6 +1050,10 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
|
1032
1050
|
};
|
|
1033
1051
|
}
|
|
1034
1052
|
|
|
1053
|
+
function getClientRects(element) {
|
|
1054
|
+
return Array.from(element.getClientRects());
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1035
1057
|
function getWindowScrollBarX(element) {
|
|
1036
1058
|
// If <html> has a CSS width greater than the viewport, then this will be
|
|
1037
1059
|
// incorrect for RTL.
|
|
@@ -1078,9 +1100,7 @@ function getParentNode(node) {
|
|
|
1078
1100
|
function getNearestOverflowAncestor(node) {
|
|
1079
1101
|
const parentNode = getParentNode(node);
|
|
1080
1102
|
if (isLastTraversableNode(parentNode)) {
|
|
1081
|
-
|
|
1082
|
-
// check, so it's either the <html> or <body> element.
|
|
1083
|
-
return parentNode.ownerDocument.body;
|
|
1103
|
+
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
1084
1104
|
}
|
|
1085
1105
|
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
1086
1106
|
return parentNode;
|
|
@@ -1113,7 +1133,7 @@ function getViewportRect(element, strategy) {
|
|
|
1113
1133
|
if (visualViewport) {
|
|
1114
1134
|
width = visualViewport.width;
|
|
1115
1135
|
height = visualViewport.height;
|
|
1116
|
-
const visualViewportBased =
|
|
1136
|
+
const visualViewportBased = isSafari();
|
|
1117
1137
|
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
|
|
1118
1138
|
x = visualViewport.offsetLeft;
|
|
1119
1139
|
y = visualViewport.offsetTop;
|
|
@@ -1132,10 +1152,7 @@ function getInnerBoundingClientRect(element, strategy) {
|
|
|
1132
1152
|
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
|
1133
1153
|
const top = clientRect.top + element.clientTop;
|
|
1134
1154
|
const left = clientRect.left + element.clientLeft;
|
|
1135
|
-
const scale = isHTMLElement(element) ? getScale(element) :
|
|
1136
|
-
x: 1,
|
|
1137
|
-
y: 1
|
|
1138
|
-
};
|
|
1155
|
+
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
1139
1156
|
const width = element.clientWidth * scale.x;
|
|
1140
1157
|
const height = element.clientHeight * scale.y;
|
|
1141
1158
|
const x = left * scale.x;
|
|
@@ -1156,19 +1173,22 @@ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy)
|
|
|
1156
1173
|
} else if (isElement(clippingAncestor)) {
|
|
1157
1174
|
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
1158
1175
|
} else {
|
|
1159
|
-
const
|
|
1160
|
-
|
|
1176
|
+
const visualOffsets = getVisualOffsets(element);
|
|
1177
|
+
rect = {
|
|
1178
|
+
...clippingAncestor,
|
|
1179
|
+
x: clippingAncestor.x - visualOffsets.x,
|
|
1180
|
+
y: clippingAncestor.y - visualOffsets.y
|
|
1161
1181
|
};
|
|
1162
|
-
if (isClientRectVisualViewportBased()) {
|
|
1163
|
-
var _win$visualViewport, _win$visualViewport2;
|
|
1164
|
-
const win = getWindow(element);
|
|
1165
|
-
mutableRect.x -= ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0;
|
|
1166
|
-
mutableRect.y -= ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0;
|
|
1167
|
-
}
|
|
1168
|
-
rect = mutableRect;
|
|
1169
1182
|
}
|
|
1170
1183
|
return rectToClientRect(rect);
|
|
1171
1184
|
}
|
|
1185
|
+
function hasFixedPositionAncestor(element, stopNode) {
|
|
1186
|
+
const parentNode = getParentNode(element);
|
|
1187
|
+
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
1188
|
+
return false;
|
|
1189
|
+
}
|
|
1190
|
+
return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
|
|
1191
|
+
}
|
|
1172
1192
|
|
|
1173
1193
|
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
|
1174
1194
|
// clipping (or hiding) child elements. This returns all clipping ancestors
|
|
@@ -1186,8 +1206,11 @@ function getClippingElementAncestors(element, cache) {
|
|
|
1186
1206
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
1187
1207
|
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1188
1208
|
const computedStyle = getComputedStyle$1(currentNode);
|
|
1189
|
-
const
|
|
1190
|
-
|
|
1209
|
+
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
1210
|
+
if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
|
|
1211
|
+
currentContainingBlockComputedStyle = null;
|
|
1212
|
+
}
|
|
1213
|
+
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
1191
1214
|
if (shouldDropCurrentNode) {
|
|
1192
1215
|
// Drop non-containing blocks.
|
|
1193
1216
|
result = result.filter(ancestor => ancestor !== currentNode);
|
|
@@ -1230,10 +1253,37 @@ function getClippingRect(_ref) {
|
|
|
1230
1253
|
}
|
|
1231
1254
|
|
|
1232
1255
|
function getDimensions(element) {
|
|
1233
|
-
|
|
1234
|
-
|
|
1256
|
+
return getCssDimensions(element);
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
1260
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1261
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1262
|
+
const isFixed = strategy === 'fixed';
|
|
1263
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
1264
|
+
let scroll = {
|
|
1265
|
+
scrollLeft: 0,
|
|
1266
|
+
scrollTop: 0
|
|
1267
|
+
};
|
|
1268
|
+
const offsets = createCoords(0);
|
|
1269
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1270
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1271
|
+
scroll = getNodeScroll(offsetParent);
|
|
1272
|
+
}
|
|
1273
|
+
if (isHTMLElement(offsetParent)) {
|
|
1274
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
1275
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1276
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1277
|
+
} else if (documentElement) {
|
|
1278
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
1279
|
+
}
|
|
1235
1280
|
}
|
|
1236
|
-
return
|
|
1281
|
+
return {
|
|
1282
|
+
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
1283
|
+
y: rect.top + scroll.scrollTop - offsets.y,
|
|
1284
|
+
width: rect.width,
|
|
1285
|
+
height: rect.height
|
|
1286
|
+
};
|
|
1237
1287
|
}
|
|
1238
1288
|
|
|
1239
1289
|
function getTrueOffsetParent(element, polyfill) {
|
|
@@ -1261,6 +1311,9 @@ function getContainingBlock(element) {
|
|
|
1261
1311
|
// such as table ancestors and cross browser bugs.
|
|
1262
1312
|
function getOffsetParent(element, polyfill) {
|
|
1263
1313
|
const window = getWindow(element);
|
|
1314
|
+
if (!isHTMLElement(element)) {
|
|
1315
|
+
return window;
|
|
1316
|
+
}
|
|
1264
1317
|
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
1265
1318
|
while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
|
|
1266
1319
|
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
@@ -1271,69 +1324,121 @@ function getOffsetParent(element, polyfill) {
|
|
|
1271
1324
|
return offsetParent || getContainingBlock(element) || window;
|
|
1272
1325
|
}
|
|
1273
1326
|
|
|
1274
|
-
function
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
const offsets = {
|
|
1283
|
-
x: 0,
|
|
1284
|
-
y: 0
|
|
1285
|
-
};
|
|
1286
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
1287
|
-
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1288
|
-
scroll = getNodeScroll(offsetParent);
|
|
1289
|
-
}
|
|
1290
|
-
if (isHTMLElement(offsetParent)) {
|
|
1291
|
-
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
1292
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1293
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1294
|
-
} else if (documentElement) {
|
|
1295
|
-
offsets.x = getWindowScrollBarX(documentElement);
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1327
|
+
const getElementRects = async function (_ref) {
|
|
1328
|
+
let {
|
|
1329
|
+
reference,
|
|
1330
|
+
floating,
|
|
1331
|
+
strategy
|
|
1332
|
+
} = _ref;
|
|
1333
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1334
|
+
const getDimensionsFn = this.getDimensions;
|
|
1298
1335
|
return {
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1336
|
+
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
|
|
1337
|
+
floating: {
|
|
1338
|
+
x: 0,
|
|
1339
|
+
y: 0,
|
|
1340
|
+
...(await getDimensionsFn(floating))
|
|
1341
|
+
}
|
|
1303
1342
|
};
|
|
1343
|
+
};
|
|
1344
|
+
|
|
1345
|
+
function isRTL(element) {
|
|
1346
|
+
return getComputedStyle(element).direction === 'rtl';
|
|
1304
1347
|
}
|
|
1305
1348
|
|
|
1306
1349
|
const platform = {
|
|
1307
|
-
getClippingRect,
|
|
1308
1350
|
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1309
|
-
isElement,
|
|
1310
|
-
getDimensions,
|
|
1311
|
-
getOffsetParent,
|
|
1312
1351
|
getDocumentElement,
|
|
1352
|
+
getClippingRect,
|
|
1353
|
+
getOffsetParent,
|
|
1354
|
+
getElementRects,
|
|
1355
|
+
getClientRects,
|
|
1356
|
+
getDimensions,
|
|
1313
1357
|
getScale,
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
reference,
|
|
1317
|
-
floating,
|
|
1318
|
-
strategy
|
|
1319
|
-
} = _ref;
|
|
1320
|
-
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1321
|
-
const getDimensionsFn = this.getDimensions;
|
|
1322
|
-
return {
|
|
1323
|
-
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
|
|
1324
|
-
floating: {
|
|
1325
|
-
x: 0,
|
|
1326
|
-
y: 0,
|
|
1327
|
-
...(await getDimensionsFn(floating))
|
|
1328
|
-
}
|
|
1329
|
-
};
|
|
1330
|
-
},
|
|
1331
|
-
getClientRects: element => Array.from(element.getClientRects()),
|
|
1332
|
-
isRTL: element => getComputedStyle$1(element).direction === 'rtl'
|
|
1358
|
+
isElement,
|
|
1359
|
+
isRTL
|
|
1333
1360
|
};
|
|
1334
1361
|
|
|
1362
|
+
// https://samthor.au/2021/observing-dom/
|
|
1363
|
+
function observeMove(element, onMove) {
|
|
1364
|
+
let io = null;
|
|
1365
|
+
let timeoutId;
|
|
1366
|
+
const root = getDocumentElement(element);
|
|
1367
|
+
function cleanup() {
|
|
1368
|
+
clearTimeout(timeoutId);
|
|
1369
|
+
io && io.disconnect();
|
|
1370
|
+
io = null;
|
|
1371
|
+
}
|
|
1372
|
+
function refresh(skip, threshold) {
|
|
1373
|
+
if (skip === void 0) {
|
|
1374
|
+
skip = false;
|
|
1375
|
+
}
|
|
1376
|
+
if (threshold === void 0) {
|
|
1377
|
+
threshold = 1;
|
|
1378
|
+
}
|
|
1379
|
+
cleanup();
|
|
1380
|
+
const {
|
|
1381
|
+
left,
|
|
1382
|
+
top,
|
|
1383
|
+
width,
|
|
1384
|
+
height
|
|
1385
|
+
} = element.getBoundingClientRect();
|
|
1386
|
+
if (!skip) {
|
|
1387
|
+
onMove();
|
|
1388
|
+
}
|
|
1389
|
+
if (!width || !height) {
|
|
1390
|
+
return;
|
|
1391
|
+
}
|
|
1392
|
+
const insetTop = floor(top);
|
|
1393
|
+
const insetRight = floor(root.clientWidth - (left + width));
|
|
1394
|
+
const insetBottom = floor(root.clientHeight - (top + height));
|
|
1395
|
+
const insetLeft = floor(left);
|
|
1396
|
+
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
|
1397
|
+
const options = {
|
|
1398
|
+
rootMargin,
|
|
1399
|
+
threshold: max(0, min(1, threshold)) || 1
|
|
1400
|
+
};
|
|
1401
|
+
let isFirstUpdate = true;
|
|
1402
|
+
function handleObserve(entries) {
|
|
1403
|
+
const ratio = entries[0].intersectionRatio;
|
|
1404
|
+
if (ratio !== threshold) {
|
|
1405
|
+
if (!isFirstUpdate) {
|
|
1406
|
+
return refresh();
|
|
1407
|
+
}
|
|
1408
|
+
if (!ratio) {
|
|
1409
|
+
timeoutId = setTimeout(() => {
|
|
1410
|
+
refresh(false, 1e-7);
|
|
1411
|
+
}, 100);
|
|
1412
|
+
} else {
|
|
1413
|
+
refresh(false, ratio);
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
isFirstUpdate = false;
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
// Older browsers don't support a `document` as the root and will throw an
|
|
1420
|
+
// error.
|
|
1421
|
+
try {
|
|
1422
|
+
io = new IntersectionObserver(handleObserve, {
|
|
1423
|
+
...options,
|
|
1424
|
+
// Handle <iframe>s
|
|
1425
|
+
root: root.ownerDocument
|
|
1426
|
+
});
|
|
1427
|
+
} catch (e) {
|
|
1428
|
+
io = new IntersectionObserver(handleObserve, options);
|
|
1429
|
+
}
|
|
1430
|
+
io.observe(element);
|
|
1431
|
+
}
|
|
1432
|
+
refresh(true);
|
|
1433
|
+
return cleanup;
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1335
1436
|
/**
|
|
1336
1437
|
* Automatically updates the position of the floating element when necessary.
|
|
1438
|
+
* Should only be called when the floating element is mounted on the DOM or
|
|
1439
|
+
* visible on the screen.
|
|
1440
|
+
* @returns cleanup function that should be invoked when the floating element is
|
|
1441
|
+
* removed from the DOM or hidden from the screen.
|
|
1337
1442
|
* @see https://floating-ui.com/docs/autoUpdate
|
|
1338
1443
|
*/
|
|
1339
1444
|
function autoUpdate(reference, floating, update, options) {
|
|
@@ -1341,33 +1446,41 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
1341
1446
|
options = {};
|
|
1342
1447
|
}
|
|
1343
1448
|
const {
|
|
1344
|
-
ancestorScroll
|
|
1449
|
+
ancestorScroll = true,
|
|
1345
1450
|
ancestorResize = true,
|
|
1346
|
-
elementResize =
|
|
1451
|
+
elementResize = typeof ResizeObserver === 'function',
|
|
1452
|
+
layoutShift = typeof IntersectionObserver === 'function',
|
|
1347
1453
|
animationFrame = false
|
|
1348
1454
|
} = options;
|
|
1349
|
-
const
|
|
1350
|
-
const ancestors = ancestorScroll || ancestorResize ? [...(
|
|
1455
|
+
const referenceEl = unwrapElement(reference);
|
|
1456
|
+
const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
|
|
1351
1457
|
ancestors.forEach(ancestor => {
|
|
1352
1458
|
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
|
1353
1459
|
passive: true
|
|
1354
1460
|
});
|
|
1355
1461
|
ancestorResize && ancestor.addEventListener('resize', update);
|
|
1356
1462
|
});
|
|
1357
|
-
|
|
1463
|
+
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
|
1464
|
+
let reobserveFrame = -1;
|
|
1465
|
+
let resizeObserver = null;
|
|
1358
1466
|
if (elementResize) {
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
if (
|
|
1362
|
-
update
|
|
1467
|
+
resizeObserver = new ResizeObserver(_ref => {
|
|
1468
|
+
let [firstEntry] = _ref;
|
|
1469
|
+
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
|
1470
|
+
// Prevent update loops when using the `size` middleware.
|
|
1471
|
+
// https://github.com/floating-ui/floating-ui/issues/1740
|
|
1472
|
+
resizeObserver.unobserve(floating);
|
|
1473
|
+
cancelAnimationFrame(reobserveFrame);
|
|
1474
|
+
reobserveFrame = requestAnimationFrame(() => {
|
|
1475
|
+
resizeObserver && resizeObserver.observe(floating);
|
|
1476
|
+
});
|
|
1363
1477
|
}
|
|
1364
|
-
|
|
1478
|
+
update();
|
|
1365
1479
|
});
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
observer.observe(reference.contextElement);
|
|
1480
|
+
if (referenceEl && !animationFrame) {
|
|
1481
|
+
resizeObserver.observe(referenceEl);
|
|
1369
1482
|
}
|
|
1370
|
-
|
|
1483
|
+
resizeObserver.observe(floating);
|
|
1371
1484
|
}
|
|
1372
1485
|
let frameId;
|
|
1373
1486
|
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
@@ -1384,13 +1497,13 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
1384
1497
|
}
|
|
1385
1498
|
update();
|
|
1386
1499
|
return () => {
|
|
1387
|
-
var _observer;
|
|
1388
1500
|
ancestors.forEach(ancestor => {
|
|
1389
1501
|
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
|
1390
1502
|
ancestorResize && ancestor.removeEventListener('resize', update);
|
|
1391
1503
|
});
|
|
1392
|
-
|
|
1393
|
-
|
|
1504
|
+
cleanupIo && cleanupIo();
|
|
1505
|
+
resizeObserver && resizeObserver.disconnect();
|
|
1506
|
+
resizeObserver = null;
|
|
1394
1507
|
if (animationFrame) {
|
|
1395
1508
|
cancelAnimationFrame(frameId);
|
|
1396
1509
|
}
|
|
@@ -1534,10 +1647,6 @@ __decorate([attr, __metadata("design:type", Object)], Popup.prototype, "anchor",
|
|
|
1534
1647
|
|
|
1535
1648
|
var css_248z = ".control {\n background: var(--vvd-color-surface-4dp);\n border-radius: inherit;\n contain: layout;\n}\n.control:not(.open) {\n display: none;\n}\n\n.popup-wrapper {\n z-index: 10;\n border-radius: 6px;\n inline-size: fit-content;\n}\n.popup-wrapper:not(.absolute) {\n position: fixed;\n}\n.popup-wrapper.absolute {\n position: absolute;\n}\n\n.popup-content {\n display: grid;\n color: var(--vvd-color-canvas-text); /* neutral-100 */\n}\n.dismissible .popup-content {\n align-content: start;\n grid-template-columns: 1fr auto;\n}\n\n.arrow {\n position: absolute;\n z-index: -1;\n width: 8px;\n height: 8px;\n background: var(--vvd-color-surface-4dp);\n transform: rotate(45deg);\n}\n\n.dismissible-button {\n align-self: flex-start;\n margin-block-start: 4px;\n margin-inline-end: 4px;\n}";
|
|
1536
1649
|
|
|
1537
|
-
let _ = t => t,
|
|
1538
|
-
_t,
|
|
1539
|
-
_t2,
|
|
1540
|
-
_t3;
|
|
1541
1650
|
const getClasses = ({
|
|
1542
1651
|
open,
|
|
1543
1652
|
dismissible,
|
|
@@ -1546,20 +1655,20 @@ const getClasses = ({
|
|
|
1546
1655
|
const popupTemplate = context => {
|
|
1547
1656
|
const elevationTag = context.tagFor(Elevation);
|
|
1548
1657
|
const buttonTag = context.tagFor(Button);
|
|
1549
|
-
return html
|
|
1550
|
-
<${
|
|
1551
|
-
<div class="popup-wrapper ${
|
|
1552
|
-
<div class="${
|
|
1553
|
-
part="${
|
|
1658
|
+
return html`
|
|
1659
|
+
<${elevationTag}>
|
|
1660
|
+
<div class="popup-wrapper ${x => x.strategy}" ${ref('popupEl')} part="popup-base">
|
|
1661
|
+
<div class="${getClasses}" aria-hidden="${x => x.open ? 'false' : 'true'}"
|
|
1662
|
+
part="${x => x.alternate ? 'vvd-theme-alternate' : ''}">
|
|
1554
1663
|
<div class="popup-content">
|
|
1555
1664
|
<slot></slot>
|
|
1556
|
-
${
|
|
1665
|
+
${when(x => x.dismissible, html`<${buttonTag} size="condensed" @click="${x => x.open = false}"
|
|
1666
|
+
class="dismissible-button" icon="close-small-solid" shape="pill"></${buttonTag}>`)}
|
|
1557
1667
|
</div>
|
|
1558
|
-
${
|
|
1668
|
+
${when(x => x.arrow, html`<div class="arrow" ${ref('arrowEl')}></div>`)}
|
|
1559
1669
|
</div>
|
|
1560
1670
|
</div>
|
|
1561
|
-
</${
|
|
1562
|
-
class="dismissible-button" icon="close-small-solid" shape="pill"></${0}>`), buttonTag, x => x.open = false, buttonTag)), when(x => x.arrow, html(_t3 || (_t3 = _`<div class="arrow" ${0}></div>`), ref('arrowEl'))), elevationTag);
|
|
1671
|
+
</${elevationTag}>`;
|
|
1563
1672
|
};
|
|
1564
1673
|
|
|
1565
1674
|
const popupDefinition = Popup.compose({
|