@m3e/core 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/NOTICE.md +8 -0
- package/README.md +59 -0
- package/cem.config.mjs +16 -0
- package/demo/index.html +58 -0
- package/dist/a11y.js +1431 -0
- package/dist/a11y.js.map +1 -0
- package/dist/a11y.min.js +87 -0
- package/dist/a11y.min.js.map +1 -0
- package/dist/anchoring.js +1748 -0
- package/dist/anchoring.js.map +1 -0
- package/dist/anchoring.min.js +7 -0
- package/dist/anchoring.min.js.map +1 -0
- package/dist/bidi.js +106 -0
- package/dist/bidi.js.map +1 -0
- package/dist/bidi.min.js +16 -0
- package/dist/bidi.min.js.map +1 -0
- package/dist/css-custom-data.json +257 -0
- package/dist/custom-elements.json +13504 -0
- package/dist/html-custom-data.json +199 -0
- package/dist/index.js +4342 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +520 -0
- package/dist/index.min.js.map +1 -0
- package/dist/layout.js +64 -0
- package/dist/layout.js.map +1 -0
- package/dist/layout.min.js +15 -0
- package/dist/layout.min.js.map +1 -0
- package/dist/platform.js +56 -0
- package/dist/platform.js.map +1 -0
- package/dist/platform.min.js +15 -0
- package/dist/platform.min.js.map +1 -0
- package/dist/src/a11y/AriaDescriber.d.ts +31 -0
- package/dist/src/a11y/AriaDescriber.d.ts.map +1 -0
- package/dist/src/a11y/FocusTrapElement.d.ts +25 -0
- package/dist/src/a11y/FocusTrapElement.d.ts.map +1 -0
- package/dist/src/a11y/InteractivityChecker.d.ts +22 -0
- package/dist/src/a11y/InteractivityChecker.d.ts.map +1 -0
- package/dist/src/a11y/LiveAnnouncer.d.ts +56 -0
- package/dist/src/a11y/LiveAnnouncer.d.ts.map +1 -0
- package/dist/src/a11y/aria-reference.d.ts +30 -0
- package/dist/src/a11y/aria-reference.d.ts.map +1 -0
- package/dist/src/a11y/index.d.ts +8 -0
- package/dist/src/a11y/index.d.ts.map +1 -0
- package/dist/src/a11y/keycodes/KeyCode.d.ts +118 -0
- package/dist/src/a11y/keycodes/KeyCode.d.ts.map +1 -0
- package/dist/src/a11y/keycodes/ModifierKeys.d.ts +5 -0
- package/dist/src/a11y/keycodes/ModifierKeys.d.ts.map +1 -0
- package/dist/src/a11y/keycodes/getKeyCode.d.ts +7 -0
- package/dist/src/a11y/keycodes/getKeyCode.d.ts.map +1 -0
- package/dist/src/a11y/keycodes/hasModifierKey.d.ts +9 -0
- package/dist/src/a11y/keycodes/hasModifierKey.d.ts.map +1 -0
- package/dist/src/a11y/keycodes/index.d.ts +6 -0
- package/dist/src/a11y/keycodes/index.d.ts.map +1 -0
- package/dist/src/a11y/keycodes/isModifierAllowed.d.ts +9 -0
- package/dist/src/a11y/keycodes/isModifierAllowed.d.ts.map +1 -0
- package/dist/src/a11y/list-key/FocusKeyManager.d.ts +17 -0
- package/dist/src/a11y/list-key/FocusKeyManager.d.ts.map +1 -0
- package/dist/src/a11y/list-key/ListKeyManager.d.ts +114 -0
- package/dist/src/a11y/list-key/ListKeyManager.d.ts.map +1 -0
- package/dist/src/a11y/list-key/ListManager.d.ts +37 -0
- package/dist/src/a11y/list-key/ListManager.d.ts.map +1 -0
- package/dist/src/a11y/list-key/RadioKeyManager.d.ts +20 -0
- package/dist/src/a11y/list-key/RadioKeyManager.d.ts.map +1 -0
- package/dist/src/a11y/list-key/RovingTabIndexManager.d.ts +22 -0
- package/dist/src/a11y/list-key/RovingTabIndexManager.d.ts.map +1 -0
- package/dist/src/a11y/list-key/SelectionManager.d.ts +46 -0
- package/dist/src/a11y/list-key/SelectionManager.d.ts.map +1 -0
- package/dist/src/a11y/list-key/Typeahead.d.ts +64 -0
- package/dist/src/a11y/list-key/Typeahead.d.ts.map +1 -0
- package/dist/src/a11y/list-key/index.d.ts +8 -0
- package/dist/src/a11y/list-key/index.d.ts.map +1 -0
- package/dist/src/a11y/visuallyHide.d.ts +6 -0
- package/dist/src/a11y/visuallyHide.d.ts.map +1 -0
- package/dist/src/anchoring/AnchorOptions.d.ts +15 -0
- package/dist/src/anchoring/AnchorOptions.d.ts.map +1 -0
- package/dist/src/anchoring/AnchorPosition.d.ts +3 -0
- package/dist/src/anchoring/AnchorPosition.d.ts.map +1 -0
- package/dist/src/anchoring/index.d.ts +4 -0
- package/dist/src/anchoring/index.d.ts.map +1 -0
- package/dist/src/anchoring/positionAnchor.d.ts +12 -0
- package/dist/src/anchoring/positionAnchor.d.ts.map +1 -0
- package/dist/src/bidi/Directionality.d.ts +27 -0
- package/dist/src/bidi/Directionality.d.ts.map +1 -0
- package/dist/src/bidi/index.d.ts +2 -0
- package/dist/src/bidi/index.d.ts.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/layout/Breakpoint.d.ts +26 -0
- package/dist/src/layout/Breakpoint.d.ts.map +1 -0
- package/dist/src/layout/BreakpointObserver.d.ts +18 -0
- package/dist/src/layout/BreakpointObserver.d.ts.map +1 -0
- package/dist/src/layout/index.d.ts +3 -0
- package/dist/src/layout/index.d.ts.map +1 -0
- package/dist/src/platform/Platform.d.ts +34 -0
- package/dist/src/platform/Platform.d.ts.map +1 -0
- package/dist/src/platform/index.d.ts +2 -0
- package/dist/src/platform/index.d.ts.map +1 -0
- package/dist/src/shared/controllers/FocusController.d.ts +30 -0
- package/dist/src/shared/controllers/FocusController.d.ts.map +1 -0
- package/dist/src/shared/controllers/HoverController.d.ts +40 -0
- package/dist/src/shared/controllers/HoverController.d.ts.map +1 -0
- package/dist/src/shared/controllers/IntersectionController.d.ts +40 -0
- package/dist/src/shared/controllers/IntersectionController.d.ts.map +1 -0
- package/dist/src/shared/controllers/LongPressController.d.ts +32 -0
- package/dist/src/shared/controllers/LongPressController.d.ts.map +1 -0
- package/dist/src/shared/controllers/MonitorControllerBase.d.ts +62 -0
- package/dist/src/shared/controllers/MonitorControllerBase.d.ts.map +1 -0
- package/dist/src/shared/controllers/MutationController.d.ts +37 -0
- package/dist/src/shared/controllers/MutationController.d.ts.map +1 -0
- package/dist/src/shared/controllers/PressedController.d.ts +45 -0
- package/dist/src/shared/controllers/PressedController.d.ts.map +1 -0
- package/dist/src/shared/controllers/ResizeController.d.ts +40 -0
- package/dist/src/shared/controllers/ResizeController.d.ts.map +1 -0
- package/dist/src/shared/controllers/ScrollController.d.ts +34 -0
- package/dist/src/shared/controllers/ScrollController.d.ts.map +1 -0
- package/dist/src/shared/controllers/index.d.ts +9 -0
- package/dist/src/shared/controllers/index.d.ts.map +1 -0
- package/dist/src/shared/decorators/debounce.d.ts +7 -0
- package/dist/src/shared/decorators/debounce.d.ts.map +1 -0
- package/dist/src/shared/decorators/index.d.ts +2 -0
- package/dist/src/shared/decorators/index.d.ts.map +1 -0
- package/dist/src/shared/directives/index.d.ts +2 -0
- package/dist/src/shared/directives/index.d.ts.map +1 -0
- package/dist/src/shared/directives/safeStyleMap.d.ts +44 -0
- package/dist/src/shared/directives/safeStyleMap.d.ts.map +1 -0
- package/dist/src/shared/index.d.ts +8 -0
- package/dist/src/shared/index.d.ts.map +1 -0
- package/dist/src/shared/mixins/AttachInternals.d.ts +24 -0
- package/dist/src/shared/mixins/AttachInternals.d.ts.map +1 -0
- package/dist/src/shared/mixins/Checked.d.ts +24 -0
- package/dist/src/shared/mixins/Checked.d.ts.map +1 -0
- package/dist/src/shared/mixins/CheckedIndeterminate.d.ts +25 -0
- package/dist/src/shared/mixins/CheckedIndeterminate.d.ts.map +1 -0
- package/dist/src/shared/mixins/CheckedOrSelected.d.ts +23 -0
- package/dist/src/shared/mixins/CheckedOrSelected.d.ts.map +1 -0
- package/dist/src/shared/mixins/ConstraintValidation.d.ts +48 -0
- package/dist/src/shared/mixins/ConstraintValidation.d.ts.map +1 -0
- package/dist/src/shared/mixins/Constructor.d.ts +3 -0
- package/dist/src/shared/mixins/Constructor.d.ts.map +1 -0
- package/dist/src/shared/mixins/Dirty.d.ts +27 -0
- package/dist/src/shared/mixins/Dirty.d.ts.map +1 -0
- package/dist/src/shared/mixins/Disabled.d.ts +25 -0
- package/dist/src/shared/mixins/Disabled.d.ts.map +1 -0
- package/dist/src/shared/mixins/DisabledInteractive.d.ts +25 -0
- package/dist/src/shared/mixins/DisabledInteractive.d.ts.map +1 -0
- package/dist/src/shared/mixins/EventAttribute.d.ts +11 -0
- package/dist/src/shared/mixins/EventAttribute.d.ts.map +1 -0
- package/dist/src/shared/mixins/Focusable.d.ts +11 -0
- package/dist/src/shared/mixins/Focusable.d.ts.map +1 -0
- package/dist/src/shared/mixins/FormAssociated.d.ts +34 -0
- package/dist/src/shared/mixins/FormAssociated.d.ts.map +1 -0
- package/dist/src/shared/mixins/FormSubmitter.d.ts +31 -0
- package/dist/src/shared/mixins/FormSubmitter.d.ts.map +1 -0
- package/dist/src/shared/mixins/HtmlFor.d.ts +30 -0
- package/dist/src/shared/mixins/HtmlFor.d.ts.map +1 -0
- package/dist/src/shared/mixins/KeyboardClick.d.ts +11 -0
- package/dist/src/shared/mixins/KeyboardClick.d.ts.map +1 -0
- package/dist/src/shared/mixins/Labelled.d.ts +22 -0
- package/dist/src/shared/mixins/Labelled.d.ts.map +1 -0
- package/dist/src/shared/mixins/LinkButton.d.ts +36 -0
- package/dist/src/shared/mixins/LinkButton.d.ts.map +1 -0
- package/dist/src/shared/mixins/ReadOnly.d.ts +25 -0
- package/dist/src/shared/mixins/ReadOnly.d.ts.map +1 -0
- package/dist/src/shared/mixins/Required.d.ts +26 -0
- package/dist/src/shared/mixins/Required.d.ts.map +1 -0
- package/dist/src/shared/mixins/RequiredConstraintValidation.d.ts +21 -0
- package/dist/src/shared/mixins/RequiredConstraintValidation.d.ts.map +1 -0
- package/dist/src/shared/mixins/Role.d.ts +13 -0
- package/dist/src/shared/mixins/Role.d.ts.map +1 -0
- package/dist/src/shared/mixins/Selected.d.ts +24 -0
- package/dist/src/shared/mixins/Selected.d.ts.map +1 -0
- package/dist/src/shared/mixins/Touched.d.ts +27 -0
- package/dist/src/shared/mixins/Touched.d.ts.map +1 -0
- package/dist/src/shared/mixins/Vertical.d.ts +24 -0
- package/dist/src/shared/mixins/Vertical.d.ts.map +1 -0
- package/dist/src/shared/mixins/hasKeys.d.ts +9 -0
- package/dist/src/shared/mixins/hasKeys.d.ts.map +1 -0
- package/dist/src/shared/mixins/index.d.ts +25 -0
- package/dist/src/shared/mixins/index.d.ts.map +1 -0
- package/dist/src/shared/primitives/CollapsibleElement.d.ts +58 -0
- package/dist/src/shared/primitives/CollapsibleElement.d.ts.map +1 -0
- package/dist/src/shared/primitives/ElevationElement.d.ts +88 -0
- package/dist/src/shared/primitives/ElevationElement.d.ts.map +1 -0
- package/dist/src/shared/primitives/ElevationLevel.d.ts +3 -0
- package/dist/src/shared/primitives/ElevationLevel.d.ts.map +1 -0
- package/dist/src/shared/primitives/ElevationToken.d.ts +15 -0
- package/dist/src/shared/primitives/ElevationToken.d.ts.map +1 -0
- package/dist/src/shared/primitives/FocusRingElement.d.ts +78 -0
- package/dist/src/shared/primitives/FocusRingElement.d.ts.map +1 -0
- package/dist/src/shared/primitives/FocusRingToken.d.ts +17 -0
- package/dist/src/shared/primitives/FocusRingToken.d.ts.map +1 -0
- package/dist/src/shared/primitives/PseudoCheckboxElement.d.ts +50 -0
- package/dist/src/shared/primitives/PseudoCheckboxElement.d.ts.map +1 -0
- package/dist/src/shared/primitives/PseudoRadioElement.d.ts +41 -0
- package/dist/src/shared/primitives/PseudoRadioElement.d.ts.map +1 -0
- package/dist/src/shared/primitives/RippleElement.d.ts +110 -0
- package/dist/src/shared/primitives/RippleElement.d.ts.map +1 -0
- package/dist/src/shared/primitives/RippleToken.d.ts +12 -0
- package/dist/src/shared/primitives/RippleToken.d.ts.map +1 -0
- package/dist/src/shared/primitives/ScrollContainerElement.d.ts +64 -0
- package/dist/src/shared/primitives/ScrollContainerElement.d.ts.map +1 -0
- package/dist/src/shared/primitives/ScrollDividers.d.ts +3 -0
- package/dist/src/shared/primitives/ScrollDividers.d.ts.map +1 -0
- package/dist/src/shared/primitives/SlideElement.d.ts +48 -0
- package/dist/src/shared/primitives/SlideElement.d.ts.map +1 -0
- package/dist/src/shared/primitives/StateLayerElement.d.ts +77 -0
- package/dist/src/shared/primitives/StateLayerElement.d.ts.map +1 -0
- package/dist/src/shared/primitives/StateLayerToken.d.ts +13 -0
- package/dist/src/shared/primitives/StateLayerToken.d.ts.map +1 -0
- package/dist/src/shared/primitives/TextOverflowElement.d.ts +39 -0
- package/dist/src/shared/primitives/TextOverflowElement.d.ts.map +1 -0
- package/dist/src/shared/primitives/index.d.ts +13 -0
- package/dist/src/shared/primitives/index.d.ts.map +1 -0
- package/dist/src/shared/tokens/ColorToken.d.ts +96 -0
- package/dist/src/shared/tokens/ColorToken.d.ts.map +1 -0
- package/dist/src/shared/tokens/DensityToken.d.ts +15 -0
- package/dist/src/shared/tokens/DensityToken.d.ts.map +1 -0
- package/dist/src/shared/tokens/DesignToken.d.ts +366 -0
- package/dist/src/shared/tokens/DesignToken.d.ts.map +1 -0
- package/dist/src/shared/tokens/ElevationToken.d.ts +16 -0
- package/dist/src/shared/tokens/ElevationToken.d.ts.map +1 -0
- package/dist/src/shared/tokens/MotionToken.d.ts +69 -0
- package/dist/src/shared/tokens/MotionToken.d.ts.map +1 -0
- package/dist/src/shared/tokens/ScrollbarToken.d.ts +10 -0
- package/dist/src/shared/tokens/ScrollbarToken.d.ts.map +1 -0
- package/dist/src/shared/tokens/ShapeToken.d.ts +79 -0
- package/dist/src/shared/tokens/ShapeToken.d.ts.map +1 -0
- package/dist/src/shared/tokens/StateToken.d.ts +10 -0
- package/dist/src/shared/tokens/StateToken.d.ts.map +1 -0
- package/dist/src/shared/tokens/TypescaleToken.d.ts +220 -0
- package/dist/src/shared/tokens/TypescaleToken.d.ts.map +1 -0
- package/dist/src/shared/tokens/index.d.ts +2 -0
- package/dist/src/shared/tokens/index.d.ts.map +1 -0
- package/dist/src/shared/utils/getTextContent.d.ts +8 -0
- package/dist/src/shared/utils/getTextContent.d.ts.map +1 -0
- package/dist/src/shared/utils/guid.d.ts +6 -0
- package/dist/src/shared/utils/guid.d.ts.map +1 -0
- package/dist/src/shared/utils/hasAssignedNodes.d.ts +7 -0
- package/dist/src/shared/utils/hasAssignedNodes.d.ts.map +1 -0
- package/dist/src/shared/utils/index.d.ts +6 -0
- package/dist/src/shared/utils/index.d.ts.map +1 -0
- package/dist/src/shared/utils/prefersReducedMotion.d.ts +6 -0
- package/dist/src/shared/utils/prefersReducedMotion.d.ts.map +1 -0
- package/dist/src/shared/utils/scrollIntoViewIfNeeded.d.ts +8 -0
- package/dist/src/shared/utils/scrollIntoViewIfNeeded.d.ts.map +1 -0
- package/eslint.config.mjs +21 -0
- package/package.json +87 -0
- package/rollup.config.js +132 -0
- package/src/a11y/AriaDescriber.ts +130 -0
- package/src/a11y/FocusTrapElement.ts +136 -0
- package/src/a11y/InteractivityChecker.ts +62 -0
- package/src/a11y/LiveAnnouncer.ts +143 -0
- package/src/a11y/aria-reference.ts +51 -0
- package/src/a11y/index.ts +8 -0
- package/src/a11y/keycodes/KeyCode.ts +128 -0
- package/src/a11y/keycodes/ModifierKeys.ts +5 -0
- package/src/a11y/keycodes/getKeyCode.ts +8 -0
- package/src/a11y/keycodes/hasModifierKey.ts +11 -0
- package/src/a11y/keycodes/index.ts +5 -0
- package/src/a11y/keycodes/isModifierAllowed.ts +12 -0
- package/src/a11y/list-key/FocusKeyManager.ts +25 -0
- package/src/a11y/list-key/ListKeyManager.ts +350 -0
- package/src/a11y/list-key/ListManager.ts +66 -0
- package/src/a11y/list-key/RadioKeyManager.ts +49 -0
- package/src/a11y/list-key/RovingTabIndexManager.ts +56 -0
- package/src/a11y/list-key/SelectionManager.ts +132 -0
- package/src/a11y/list-key/Typeahead.ts +131 -0
- package/src/a11y/list-key/index.ts +7 -0
- package/src/a11y/visuallyHide.ts +18 -0
- package/src/anchoring/AnchorOptions.ts +19 -0
- package/src/anchoring/AnchorPosition.ts +14 -0
- package/src/anchoring/index.ts +3 -0
- package/src/anchoring/positionAnchor.ts +53 -0
- package/src/bidi/Directionality.ts +85 -0
- package/src/bidi/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/layout/Breakpoint.ts +26 -0
- package/src/layout/BreakpointObserver.ts +44 -0
- package/src/layout/index.ts +2 -0
- package/src/platform/Platform.ts +67 -0
- package/src/platform/index.ts +1 -0
- package/src/shared/controllers/FocusController.ts +60 -0
- package/src/shared/controllers/HoverController.ts +140 -0
- package/src/shared/controllers/IntersectionController.ts +81 -0
- package/src/shared/controllers/LongPressController.ts +87 -0
- package/src/shared/controllers/MonitorControllerBase.ts +99 -0
- package/src/shared/controllers/MutationController.ts +89 -0
- package/src/shared/controllers/PressedController.ts +137 -0
- package/src/shared/controllers/ResizeController.ts +83 -0
- package/src/shared/controllers/ScrollController.ts +100 -0
- package/src/shared/controllers/index.ts +8 -0
- package/src/shared/decorators/debounce.ts +19 -0
- package/src/shared/decorators/index.ts +1 -0
- package/src/shared/directives/index.ts +1 -0
- package/src/shared/directives/safeStyleMap.ts +108 -0
- package/src/shared/index.ts +7 -0
- package/src/shared/mixins/AttachInternals.ts +48 -0
- package/src/shared/mixins/Checked.ts +50 -0
- package/src/shared/mixins/CheckedIndeterminate.ts +47 -0
- package/src/shared/mixins/CheckedOrSelected.ts +36 -0
- package/src/shared/mixins/ConstraintValidation.ts +213 -0
- package/src/shared/mixins/Constructor.ts +2 -0
- package/src/shared/mixins/Dirty.ts +71 -0
- package/src/shared/mixins/Disabled.ts +49 -0
- package/src/shared/mixins/DisabledInteractive.ts +78 -0
- package/src/shared/mixins/EventAttribute.ts +25 -0
- package/src/shared/mixins/Focusable.ts +52 -0
- package/src/shared/mixins/FormAssociated.ts +152 -0
- package/src/shared/mixins/FormSubmitter.ts +123 -0
- package/src/shared/mixins/HtmlFor.ts +89 -0
- package/src/shared/mixins/KeyboardClick.ts +46 -0
- package/src/shared/mixins/Labelled.ts +88 -0
- package/src/shared/mixins/LinkButton.ts +169 -0
- package/src/shared/mixins/ReadOnly.ts +48 -0
- package/src/shared/mixins/Required.ts +50 -0
- package/src/shared/mixins/RequiredConstraintValidation.ts +45 -0
- package/src/shared/mixins/Role.ts +134 -0
- package/src/shared/mixins/Selected.ts +50 -0
- package/src/shared/mixins/Touched.ts +71 -0
- package/src/shared/mixins/Vertical.ts +44 -0
- package/src/shared/mixins/hasKeys.ts +10 -0
- package/src/shared/mixins/index.ts +24 -0
- package/src/shared/primitives/CollapsibleElement.ts +227 -0
- package/src/shared/primitives/ElevationElement.ts +254 -0
- package/src/shared/primitives/ElevationLevel.ts +2 -0
- package/src/shared/primitives/ElevationToken.ts +18 -0
- package/src/shared/primitives/FocusRingElement.ts +199 -0
- package/src/shared/primitives/FocusRingToken.ts +24 -0
- package/src/shared/primitives/PseudoCheckboxElement.ts +116 -0
- package/src/shared/primitives/PseudoRadioElement.ts +83 -0
- package/src/shared/primitives/RippleElement.ts +289 -0
- package/src/shared/primitives/RippleToken.ts +15 -0
- package/src/shared/primitives/ScrollContainerElement.ts +151 -0
- package/src/shared/primitives/ScrollDividers.ts +2 -0
- package/src/shared/primitives/SlideElement.ts +128 -0
- package/src/shared/primitives/StateLayerElement.ts +191 -0
- package/src/shared/primitives/StateLayerToken.ts +16 -0
- package/src/shared/primitives/TextOverflowElement.ts +60 -0
- package/src/shared/primitives/index.ts +12 -0
- package/src/shared/tokens/ColorToken.ts +142 -0
- package/src/shared/tokens/DensityToken.ts +23 -0
- package/src/shared/tokens/DesignToken.ts +35 -0
- package/src/shared/tokens/ElevationToken.ts +115 -0
- package/src/shared/tokens/MotionToken.ts +107 -0
- package/src/shared/tokens/ScrollbarToken.ts +13 -0
- package/src/shared/tokens/ShapeToken.ts +138 -0
- package/src/shared/tokens/StateToken.ts +13 -0
- package/src/shared/tokens/TypescaleToken.ts +230 -0
- package/src/shared/tokens/index.ts +1 -0
- package/src/shared/utils/getTextContent.ts +31 -0
- package/src/shared/utils/guid.ts +11 -0
- package/src/shared/utils/hasAssignedNodes.ts +8 -0
- package/src/shared/utils/index.ts +5 -0
- package/src/shared/utils/prefersReducedMotion.ts +9 -0
- package/src/shared/utils/scrollIntoViewIfNeeded.ts +18 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,1748 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license MIT
|
|
3
|
+
* Copyright (c) 2025 matraic
|
|
4
|
+
* See LICENSE file in the project root for full license text.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Custom positioning reference element.
|
|
8
|
+
* @see https://floating-ui.com/docs/virtual-elements
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const min = Math.min;
|
|
12
|
+
const max = Math.max;
|
|
13
|
+
const round = Math.round;
|
|
14
|
+
const floor = Math.floor;
|
|
15
|
+
const createCoords = v => ({
|
|
16
|
+
x: v,
|
|
17
|
+
y: v
|
|
18
|
+
});
|
|
19
|
+
const oppositeSideMap = {
|
|
20
|
+
left: 'right',
|
|
21
|
+
right: 'left',
|
|
22
|
+
bottom: 'top',
|
|
23
|
+
top: 'bottom'
|
|
24
|
+
};
|
|
25
|
+
const oppositeAlignmentMap = {
|
|
26
|
+
start: 'end',
|
|
27
|
+
end: 'start'
|
|
28
|
+
};
|
|
29
|
+
function clamp(start, value, end) {
|
|
30
|
+
return max(start, min(value, end));
|
|
31
|
+
}
|
|
32
|
+
function evaluate(value, param) {
|
|
33
|
+
return typeof value === 'function' ? value(param) : value;
|
|
34
|
+
}
|
|
35
|
+
function getSide(placement) {
|
|
36
|
+
return placement.split('-')[0];
|
|
37
|
+
}
|
|
38
|
+
function getAlignment(placement) {
|
|
39
|
+
return placement.split('-')[1];
|
|
40
|
+
}
|
|
41
|
+
function getOppositeAxis(axis) {
|
|
42
|
+
return axis === 'x' ? 'y' : 'x';
|
|
43
|
+
}
|
|
44
|
+
function getAxisLength(axis) {
|
|
45
|
+
return axis === 'y' ? 'height' : 'width';
|
|
46
|
+
}
|
|
47
|
+
const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);
|
|
48
|
+
function getSideAxis(placement) {
|
|
49
|
+
return yAxisSides.has(getSide(placement)) ? 'y' : 'x';
|
|
50
|
+
}
|
|
51
|
+
function getAlignmentAxis(placement) {
|
|
52
|
+
return getOppositeAxis(getSideAxis(placement));
|
|
53
|
+
}
|
|
54
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
55
|
+
if (rtl === void 0) {
|
|
56
|
+
rtl = false;
|
|
57
|
+
}
|
|
58
|
+
const alignment = getAlignment(placement);
|
|
59
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
60
|
+
const length = getAxisLength(alignmentAxis);
|
|
61
|
+
let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
|
62
|
+
if (rects.reference[length] > rects.floating[length]) {
|
|
63
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
64
|
+
}
|
|
65
|
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
66
|
+
}
|
|
67
|
+
function getExpandedPlacements(placement) {
|
|
68
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
69
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
70
|
+
}
|
|
71
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
72
|
+
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
|
73
|
+
}
|
|
74
|
+
const lrPlacement = ['left', 'right'];
|
|
75
|
+
const rlPlacement = ['right', 'left'];
|
|
76
|
+
const tbPlacement = ['top', 'bottom'];
|
|
77
|
+
const btPlacement = ['bottom', 'top'];
|
|
78
|
+
function getSideList(side, isStart, rtl) {
|
|
79
|
+
switch (side) {
|
|
80
|
+
case 'top':
|
|
81
|
+
case 'bottom':
|
|
82
|
+
if (rtl) return isStart ? rlPlacement : lrPlacement;
|
|
83
|
+
return isStart ? lrPlacement : rlPlacement;
|
|
84
|
+
case 'left':
|
|
85
|
+
case 'right':
|
|
86
|
+
return isStart ? tbPlacement : btPlacement;
|
|
87
|
+
default:
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
92
|
+
const alignment = getAlignment(placement);
|
|
93
|
+
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
|
94
|
+
if (alignment) {
|
|
95
|
+
list = list.map(side => side + "-" + alignment);
|
|
96
|
+
if (flipAlignment) {
|
|
97
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return list;
|
|
101
|
+
}
|
|
102
|
+
function getOppositePlacement(placement) {
|
|
103
|
+
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
|
104
|
+
}
|
|
105
|
+
function expandPaddingObject(padding) {
|
|
106
|
+
return {
|
|
107
|
+
top: 0,
|
|
108
|
+
right: 0,
|
|
109
|
+
bottom: 0,
|
|
110
|
+
left: 0,
|
|
111
|
+
...padding
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function getPaddingObject(padding) {
|
|
115
|
+
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
116
|
+
top: padding,
|
|
117
|
+
right: padding,
|
|
118
|
+
bottom: padding,
|
|
119
|
+
left: padding
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function rectToClientRect(rect) {
|
|
123
|
+
const {
|
|
124
|
+
x,
|
|
125
|
+
y,
|
|
126
|
+
width,
|
|
127
|
+
height
|
|
128
|
+
} = rect;
|
|
129
|
+
return {
|
|
130
|
+
width,
|
|
131
|
+
height,
|
|
132
|
+
top: y,
|
|
133
|
+
left: x,
|
|
134
|
+
right: x + width,
|
|
135
|
+
bottom: y + height,
|
|
136
|
+
x,
|
|
137
|
+
y
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
142
|
+
let {
|
|
143
|
+
reference,
|
|
144
|
+
floating
|
|
145
|
+
} = _ref;
|
|
146
|
+
const sideAxis = getSideAxis(placement);
|
|
147
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
148
|
+
const alignLength = getAxisLength(alignmentAxis);
|
|
149
|
+
const side = getSide(placement);
|
|
150
|
+
const isVertical = sideAxis === 'y';
|
|
151
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
152
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
153
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
154
|
+
let coords;
|
|
155
|
+
switch (side) {
|
|
156
|
+
case 'top':
|
|
157
|
+
coords = {
|
|
158
|
+
x: commonX,
|
|
159
|
+
y: reference.y - floating.height
|
|
160
|
+
};
|
|
161
|
+
break;
|
|
162
|
+
case 'bottom':
|
|
163
|
+
coords = {
|
|
164
|
+
x: commonX,
|
|
165
|
+
y: reference.y + reference.height
|
|
166
|
+
};
|
|
167
|
+
break;
|
|
168
|
+
case 'right':
|
|
169
|
+
coords = {
|
|
170
|
+
x: reference.x + reference.width,
|
|
171
|
+
y: commonY
|
|
172
|
+
};
|
|
173
|
+
break;
|
|
174
|
+
case 'left':
|
|
175
|
+
coords = {
|
|
176
|
+
x: reference.x - floating.width,
|
|
177
|
+
y: commonY
|
|
178
|
+
};
|
|
179
|
+
break;
|
|
180
|
+
default:
|
|
181
|
+
coords = {
|
|
182
|
+
x: reference.x,
|
|
183
|
+
y: reference.y
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
switch (getAlignment(placement)) {
|
|
187
|
+
case 'start':
|
|
188
|
+
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
189
|
+
break;
|
|
190
|
+
case 'end':
|
|
191
|
+
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
return coords;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
199
|
+
* next to a given reference element.
|
|
200
|
+
*
|
|
201
|
+
* This export does not have any `platform` interface logic. You will need to
|
|
202
|
+
* write one for the platform you are using Floating UI with.
|
|
203
|
+
*/
|
|
204
|
+
const computePosition$1 = async (reference, floating, config) => {
|
|
205
|
+
const {
|
|
206
|
+
placement = 'bottom',
|
|
207
|
+
strategy = 'absolute',
|
|
208
|
+
middleware = [],
|
|
209
|
+
platform
|
|
210
|
+
} = config;
|
|
211
|
+
const validMiddleware = middleware.filter(Boolean);
|
|
212
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
213
|
+
let rects = await platform.getElementRects({
|
|
214
|
+
reference,
|
|
215
|
+
floating,
|
|
216
|
+
strategy
|
|
217
|
+
});
|
|
218
|
+
let {
|
|
219
|
+
x,
|
|
220
|
+
y
|
|
221
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
222
|
+
let statefulPlacement = placement;
|
|
223
|
+
let middlewareData = {};
|
|
224
|
+
let resetCount = 0;
|
|
225
|
+
for (let i = 0; i < validMiddleware.length; i++) {
|
|
226
|
+
const {
|
|
227
|
+
name,
|
|
228
|
+
fn
|
|
229
|
+
} = validMiddleware[i];
|
|
230
|
+
const {
|
|
231
|
+
x: nextX,
|
|
232
|
+
y: nextY,
|
|
233
|
+
data,
|
|
234
|
+
reset
|
|
235
|
+
} = await fn({
|
|
236
|
+
x,
|
|
237
|
+
y,
|
|
238
|
+
initialPlacement: placement,
|
|
239
|
+
placement: statefulPlacement,
|
|
240
|
+
strategy,
|
|
241
|
+
middlewareData,
|
|
242
|
+
rects,
|
|
243
|
+
platform,
|
|
244
|
+
elements: {
|
|
245
|
+
reference,
|
|
246
|
+
floating
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
x = nextX != null ? nextX : x;
|
|
250
|
+
y = nextY != null ? nextY : y;
|
|
251
|
+
middlewareData = {
|
|
252
|
+
...middlewareData,
|
|
253
|
+
[name]: {
|
|
254
|
+
...middlewareData[name],
|
|
255
|
+
...data
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
if (reset && resetCount <= 50) {
|
|
259
|
+
resetCount++;
|
|
260
|
+
if (typeof reset === 'object') {
|
|
261
|
+
if (reset.placement) {
|
|
262
|
+
statefulPlacement = reset.placement;
|
|
263
|
+
}
|
|
264
|
+
if (reset.rects) {
|
|
265
|
+
rects = reset.rects === true ? await platform.getElementRects({
|
|
266
|
+
reference,
|
|
267
|
+
floating,
|
|
268
|
+
strategy
|
|
269
|
+
}) : reset.rects;
|
|
270
|
+
}
|
|
271
|
+
({
|
|
272
|
+
x,
|
|
273
|
+
y
|
|
274
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
275
|
+
}
|
|
276
|
+
i = -1;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return {
|
|
280
|
+
x,
|
|
281
|
+
y,
|
|
282
|
+
placement: statefulPlacement,
|
|
283
|
+
strategy,
|
|
284
|
+
middlewareData
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Resolves with an object of overflow side offsets that determine how much the
|
|
290
|
+
* element is overflowing a given clipping boundary on each side.
|
|
291
|
+
* - positive = overflowing the boundary by that number of pixels
|
|
292
|
+
* - negative = how many pixels left before it will overflow
|
|
293
|
+
* - 0 = lies flush with the boundary
|
|
294
|
+
* @see https://floating-ui.com/docs/detectOverflow
|
|
295
|
+
*/
|
|
296
|
+
async function detectOverflow(state, options) {
|
|
297
|
+
var _await$platform$isEle;
|
|
298
|
+
if (options === void 0) {
|
|
299
|
+
options = {};
|
|
300
|
+
}
|
|
301
|
+
const {
|
|
302
|
+
x,
|
|
303
|
+
y,
|
|
304
|
+
platform,
|
|
305
|
+
rects,
|
|
306
|
+
elements,
|
|
307
|
+
strategy
|
|
308
|
+
} = state;
|
|
309
|
+
const {
|
|
310
|
+
boundary = 'clippingAncestors',
|
|
311
|
+
rootBoundary = 'viewport',
|
|
312
|
+
elementContext = 'floating',
|
|
313
|
+
altBoundary = false,
|
|
314
|
+
padding = 0
|
|
315
|
+
} = evaluate(options, state);
|
|
316
|
+
const paddingObject = getPaddingObject(padding);
|
|
317
|
+
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
318
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
319
|
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
320
|
+
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))),
|
|
321
|
+
boundary,
|
|
322
|
+
rootBoundary,
|
|
323
|
+
strategy
|
|
324
|
+
}));
|
|
325
|
+
const rect = elementContext === 'floating' ? {
|
|
326
|
+
x,
|
|
327
|
+
y,
|
|
328
|
+
width: rects.floating.width,
|
|
329
|
+
height: rects.floating.height
|
|
330
|
+
} : rects.reference;
|
|
331
|
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
332
|
+
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
|
333
|
+
x: 1,
|
|
334
|
+
y: 1
|
|
335
|
+
} : {
|
|
336
|
+
x: 1,
|
|
337
|
+
y: 1
|
|
338
|
+
};
|
|
339
|
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
340
|
+
elements,
|
|
341
|
+
rect,
|
|
342
|
+
offsetParent,
|
|
343
|
+
strategy
|
|
344
|
+
}) : rect);
|
|
345
|
+
return {
|
|
346
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
347
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
348
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
349
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
355
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
356
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
357
|
+
* @see https://floating-ui.com/docs/flip
|
|
358
|
+
*/
|
|
359
|
+
const flip$1 = function (options) {
|
|
360
|
+
if (options === void 0) {
|
|
361
|
+
options = {};
|
|
362
|
+
}
|
|
363
|
+
return {
|
|
364
|
+
name: 'flip',
|
|
365
|
+
options,
|
|
366
|
+
async fn(state) {
|
|
367
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
|
368
|
+
const {
|
|
369
|
+
placement,
|
|
370
|
+
middlewareData,
|
|
371
|
+
rects,
|
|
372
|
+
initialPlacement,
|
|
373
|
+
platform,
|
|
374
|
+
elements
|
|
375
|
+
} = state;
|
|
376
|
+
const {
|
|
377
|
+
mainAxis: checkMainAxis = true,
|
|
378
|
+
crossAxis: checkCrossAxis = true,
|
|
379
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
|
380
|
+
fallbackStrategy = 'bestFit',
|
|
381
|
+
fallbackAxisSideDirection = 'none',
|
|
382
|
+
flipAlignment = true,
|
|
383
|
+
...detectOverflowOptions
|
|
384
|
+
} = evaluate(options, state);
|
|
385
|
+
|
|
386
|
+
// If a reset by the arrow was caused due to an alignment offset being
|
|
387
|
+
// added, we should skip any logic now since `flip()` has already done its
|
|
388
|
+
// work.
|
|
389
|
+
// https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
|
|
390
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
391
|
+
return {};
|
|
392
|
+
}
|
|
393
|
+
const side = getSide(placement);
|
|
394
|
+
const initialSideAxis = getSideAxis(initialPlacement);
|
|
395
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
396
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
397
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
398
|
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
|
|
399
|
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
|
400
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
401
|
+
}
|
|
402
|
+
const placements = [initialPlacement, ...fallbackPlacements];
|
|
403
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
404
|
+
const overflows = [];
|
|
405
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
406
|
+
if (checkMainAxis) {
|
|
407
|
+
overflows.push(overflow[side]);
|
|
408
|
+
}
|
|
409
|
+
if (checkCrossAxis) {
|
|
410
|
+
const sides = getAlignmentSides(placement, rects, rtl);
|
|
411
|
+
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
|
412
|
+
}
|
|
413
|
+
overflowsData = [...overflowsData, {
|
|
414
|
+
placement,
|
|
415
|
+
overflows
|
|
416
|
+
}];
|
|
417
|
+
|
|
418
|
+
// One or more sides is overflowing.
|
|
419
|
+
if (!overflows.every(side => side <= 0)) {
|
|
420
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
421
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
422
|
+
const nextPlacement = placements[nextIndex];
|
|
423
|
+
if (nextPlacement) {
|
|
424
|
+
const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
|
|
425
|
+
if (!ignoreCrossAxisOverflow ||
|
|
426
|
+
// We leave the current main axis only if every placement on that axis
|
|
427
|
+
// overflows the main axis.
|
|
428
|
+
overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
|
|
429
|
+
// Try next placement and re-run the lifecycle.
|
|
430
|
+
return {
|
|
431
|
+
data: {
|
|
432
|
+
index: nextIndex,
|
|
433
|
+
overflows: overflowsData
|
|
434
|
+
},
|
|
435
|
+
reset: {
|
|
436
|
+
placement: nextPlacement
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// First, find the candidates that fit on the mainAxis side of overflow,
|
|
443
|
+
// then find the placement that fits the best on the main crossAxis side.
|
|
444
|
+
let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
|
445
|
+
|
|
446
|
+
// Otherwise fallback.
|
|
447
|
+
if (!resetPlacement) {
|
|
448
|
+
switch (fallbackStrategy) {
|
|
449
|
+
case 'bestFit':
|
|
450
|
+
{
|
|
451
|
+
var _overflowsData$filter2;
|
|
452
|
+
const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
|
|
453
|
+
if (hasFallbackAxisSideDirection) {
|
|
454
|
+
const currentSideAxis = getSideAxis(d.placement);
|
|
455
|
+
return currentSideAxis === initialSideAxis ||
|
|
456
|
+
// Create a bias to the `y` side axis due to horizontal
|
|
457
|
+
// reading directions favoring greater width.
|
|
458
|
+
currentSideAxis === 'y';
|
|
459
|
+
}
|
|
460
|
+
return true;
|
|
461
|
+
}).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
|
462
|
+
if (placement) {
|
|
463
|
+
resetPlacement = placement;
|
|
464
|
+
}
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
case 'initialPlacement':
|
|
468
|
+
resetPlacement = initialPlacement;
|
|
469
|
+
break;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
if (placement !== resetPlacement) {
|
|
473
|
+
return {
|
|
474
|
+
reset: {
|
|
475
|
+
placement: resetPlacement
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
return {};
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
function getBoundingRect(rects) {
|
|
486
|
+
const minX = min(...rects.map(rect => rect.left));
|
|
487
|
+
const minY = min(...rects.map(rect => rect.top));
|
|
488
|
+
const maxX = max(...rects.map(rect => rect.right));
|
|
489
|
+
const maxY = max(...rects.map(rect => rect.bottom));
|
|
490
|
+
return {
|
|
491
|
+
x: minX,
|
|
492
|
+
y: minY,
|
|
493
|
+
width: maxX - minX,
|
|
494
|
+
height: maxY - minY
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
function getRectsByLine(rects) {
|
|
498
|
+
const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
|
|
499
|
+
const groups = [];
|
|
500
|
+
let prevRect = null;
|
|
501
|
+
for (let i = 0; i < sortedRects.length; i++) {
|
|
502
|
+
const rect = sortedRects[i];
|
|
503
|
+
if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
|
|
504
|
+
groups.push([rect]);
|
|
505
|
+
} else {
|
|
506
|
+
groups[groups.length - 1].push(rect);
|
|
507
|
+
}
|
|
508
|
+
prevRect = rect;
|
|
509
|
+
}
|
|
510
|
+
return groups.map(rect => rectToClientRect(getBoundingRect(rect)));
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Provides improved positioning for inline reference elements that can span
|
|
514
|
+
* over multiple lines, such as hyperlinks or range selections.
|
|
515
|
+
* @see https://floating-ui.com/docs/inline
|
|
516
|
+
*/
|
|
517
|
+
const inline$1 = function (options) {
|
|
518
|
+
if (options === void 0) {
|
|
519
|
+
options = {};
|
|
520
|
+
}
|
|
521
|
+
return {
|
|
522
|
+
name: 'inline',
|
|
523
|
+
options,
|
|
524
|
+
async fn(state) {
|
|
525
|
+
const {
|
|
526
|
+
placement,
|
|
527
|
+
elements,
|
|
528
|
+
rects,
|
|
529
|
+
platform,
|
|
530
|
+
strategy
|
|
531
|
+
} = state;
|
|
532
|
+
// A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
|
|
533
|
+
// ClientRect's bounds, despite the event listener being triggered. A
|
|
534
|
+
// padding of 2 seems to handle this issue.
|
|
535
|
+
const {
|
|
536
|
+
padding = 2,
|
|
537
|
+
x,
|
|
538
|
+
y
|
|
539
|
+
} = evaluate(options, state);
|
|
540
|
+
const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
|
|
541
|
+
const clientRects = getRectsByLine(nativeClientRects);
|
|
542
|
+
const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
|
|
543
|
+
const paddingObject = getPaddingObject(padding);
|
|
544
|
+
function getBoundingClientRect() {
|
|
545
|
+
// There are two rects and they are disjoined.
|
|
546
|
+
if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
|
|
547
|
+
// Find the first rect in which the point is fully inside.
|
|
548
|
+
return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
// There are 2 or more connected rects.
|
|
552
|
+
if (clientRects.length >= 2) {
|
|
553
|
+
if (getSideAxis(placement) === 'y') {
|
|
554
|
+
const firstRect = clientRects[0];
|
|
555
|
+
const lastRect = clientRects[clientRects.length - 1];
|
|
556
|
+
const isTop = getSide(placement) === 'top';
|
|
557
|
+
const top = firstRect.top;
|
|
558
|
+
const bottom = lastRect.bottom;
|
|
559
|
+
const left = isTop ? firstRect.left : lastRect.left;
|
|
560
|
+
const right = isTop ? firstRect.right : lastRect.right;
|
|
561
|
+
const width = right - left;
|
|
562
|
+
const height = bottom - top;
|
|
563
|
+
return {
|
|
564
|
+
top,
|
|
565
|
+
bottom,
|
|
566
|
+
left,
|
|
567
|
+
right,
|
|
568
|
+
width,
|
|
569
|
+
height,
|
|
570
|
+
x: left,
|
|
571
|
+
y: top
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
const isLeftSide = getSide(placement) === 'left';
|
|
575
|
+
const maxRight = max(...clientRects.map(rect => rect.right));
|
|
576
|
+
const minLeft = min(...clientRects.map(rect => rect.left));
|
|
577
|
+
const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
|
|
578
|
+
const top = measureRects[0].top;
|
|
579
|
+
const bottom = measureRects[measureRects.length - 1].bottom;
|
|
580
|
+
const left = minLeft;
|
|
581
|
+
const right = maxRight;
|
|
582
|
+
const width = right - left;
|
|
583
|
+
const height = bottom - top;
|
|
584
|
+
return {
|
|
585
|
+
top,
|
|
586
|
+
bottom,
|
|
587
|
+
left,
|
|
588
|
+
right,
|
|
589
|
+
width,
|
|
590
|
+
height,
|
|
591
|
+
x: left,
|
|
592
|
+
y: top
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
return fallback;
|
|
596
|
+
}
|
|
597
|
+
const resetRects = await platform.getElementRects({
|
|
598
|
+
reference: {
|
|
599
|
+
getBoundingClientRect
|
|
600
|
+
},
|
|
601
|
+
floating: elements.floating,
|
|
602
|
+
strategy
|
|
603
|
+
});
|
|
604
|
+
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) {
|
|
605
|
+
return {
|
|
606
|
+
reset: {
|
|
607
|
+
rects: resetRects
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
return {};
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
const originSides = /*#__PURE__*/new Set(['left', 'top']);
|
|
617
|
+
|
|
618
|
+
// For type backwards-compatibility, the `OffsetOptions` type was also
|
|
619
|
+
// Derivable.
|
|
620
|
+
|
|
621
|
+
async function convertValueToCoords(state, options) {
|
|
622
|
+
const {
|
|
623
|
+
placement,
|
|
624
|
+
platform,
|
|
625
|
+
elements
|
|
626
|
+
} = state;
|
|
627
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
628
|
+
const side = getSide(placement);
|
|
629
|
+
const alignment = getAlignment(placement);
|
|
630
|
+
const isVertical = getSideAxis(placement) === 'y';
|
|
631
|
+
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
|
632
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
633
|
+
const rawValue = evaluate(options, state);
|
|
634
|
+
|
|
635
|
+
// eslint-disable-next-line prefer-const
|
|
636
|
+
let {
|
|
637
|
+
mainAxis,
|
|
638
|
+
crossAxis,
|
|
639
|
+
alignmentAxis
|
|
640
|
+
} = typeof rawValue === 'number' ? {
|
|
641
|
+
mainAxis: rawValue,
|
|
642
|
+
crossAxis: 0,
|
|
643
|
+
alignmentAxis: null
|
|
644
|
+
} : {
|
|
645
|
+
mainAxis: rawValue.mainAxis || 0,
|
|
646
|
+
crossAxis: rawValue.crossAxis || 0,
|
|
647
|
+
alignmentAxis: rawValue.alignmentAxis
|
|
648
|
+
};
|
|
649
|
+
if (alignment && typeof alignmentAxis === 'number') {
|
|
650
|
+
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
|
651
|
+
}
|
|
652
|
+
return isVertical ? {
|
|
653
|
+
x: crossAxis * crossAxisMulti,
|
|
654
|
+
y: mainAxis * mainAxisMulti
|
|
655
|
+
} : {
|
|
656
|
+
x: mainAxis * mainAxisMulti,
|
|
657
|
+
y: crossAxis * crossAxisMulti
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Modifies the placement by translating the floating element along the
|
|
663
|
+
* specified axes.
|
|
664
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
665
|
+
* object may be passed.
|
|
666
|
+
* @see https://floating-ui.com/docs/offset
|
|
667
|
+
*/
|
|
668
|
+
const offset$1 = function (options) {
|
|
669
|
+
if (options === void 0) {
|
|
670
|
+
options = 0;
|
|
671
|
+
}
|
|
672
|
+
return {
|
|
673
|
+
name: 'offset',
|
|
674
|
+
options,
|
|
675
|
+
async fn(state) {
|
|
676
|
+
var _middlewareData$offse, _middlewareData$arrow;
|
|
677
|
+
const {
|
|
678
|
+
x,
|
|
679
|
+
y,
|
|
680
|
+
placement,
|
|
681
|
+
middlewareData
|
|
682
|
+
} = state;
|
|
683
|
+
const diffCoords = await convertValueToCoords(state, options);
|
|
684
|
+
|
|
685
|
+
// If the placement is the same and the arrow caused an alignment offset
|
|
686
|
+
// then we don't need to change the positioning coordinates.
|
|
687
|
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
688
|
+
return {};
|
|
689
|
+
}
|
|
690
|
+
return {
|
|
691
|
+
x: x + diffCoords.x,
|
|
692
|
+
y: y + diffCoords.y,
|
|
693
|
+
data: {
|
|
694
|
+
...diffCoords,
|
|
695
|
+
placement
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
};
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
704
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
705
|
+
* @see https://floating-ui.com/docs/shift
|
|
706
|
+
*/
|
|
707
|
+
const shift$1 = function (options) {
|
|
708
|
+
if (options === void 0) {
|
|
709
|
+
options = {};
|
|
710
|
+
}
|
|
711
|
+
return {
|
|
712
|
+
name: 'shift',
|
|
713
|
+
options,
|
|
714
|
+
async fn(state) {
|
|
715
|
+
const {
|
|
716
|
+
x,
|
|
717
|
+
y,
|
|
718
|
+
placement
|
|
719
|
+
} = state;
|
|
720
|
+
const {
|
|
721
|
+
mainAxis: checkMainAxis = true,
|
|
722
|
+
crossAxis: checkCrossAxis = false,
|
|
723
|
+
limiter = {
|
|
724
|
+
fn: _ref => {
|
|
725
|
+
let {
|
|
726
|
+
x,
|
|
727
|
+
y
|
|
728
|
+
} = _ref;
|
|
729
|
+
return {
|
|
730
|
+
x,
|
|
731
|
+
y
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
},
|
|
735
|
+
...detectOverflowOptions
|
|
736
|
+
} = evaluate(options, state);
|
|
737
|
+
const coords = {
|
|
738
|
+
x,
|
|
739
|
+
y
|
|
740
|
+
};
|
|
741
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
742
|
+
const crossAxis = getSideAxis(getSide(placement));
|
|
743
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
744
|
+
let mainAxisCoord = coords[mainAxis];
|
|
745
|
+
let crossAxisCoord = coords[crossAxis];
|
|
746
|
+
if (checkMainAxis) {
|
|
747
|
+
const minSide = mainAxis === 'y' ? 'top' : 'left';
|
|
748
|
+
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
|
749
|
+
const min = mainAxisCoord + overflow[minSide];
|
|
750
|
+
const max = mainAxisCoord - overflow[maxSide];
|
|
751
|
+
mainAxisCoord = clamp(min, mainAxisCoord, max);
|
|
752
|
+
}
|
|
753
|
+
if (checkCrossAxis) {
|
|
754
|
+
const minSide = crossAxis === 'y' ? 'top' : 'left';
|
|
755
|
+
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
|
756
|
+
const min = crossAxisCoord + overflow[minSide];
|
|
757
|
+
const max = crossAxisCoord - overflow[maxSide];
|
|
758
|
+
crossAxisCoord = clamp(min, crossAxisCoord, max);
|
|
759
|
+
}
|
|
760
|
+
const limitedCoords = limiter.fn({
|
|
761
|
+
...state,
|
|
762
|
+
[mainAxis]: mainAxisCoord,
|
|
763
|
+
[crossAxis]: crossAxisCoord
|
|
764
|
+
});
|
|
765
|
+
return {
|
|
766
|
+
...limitedCoords,
|
|
767
|
+
data: {
|
|
768
|
+
x: limitedCoords.x - x,
|
|
769
|
+
y: limitedCoords.y - y,
|
|
770
|
+
enabled: {
|
|
771
|
+
[mainAxis]: checkMainAxis,
|
|
772
|
+
[crossAxis]: checkCrossAxis
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
};
|
|
779
|
+
|
|
780
|
+
function hasWindow() {
|
|
781
|
+
return typeof window !== 'undefined';
|
|
782
|
+
}
|
|
783
|
+
function getNodeName(node) {
|
|
784
|
+
if (isNode(node)) {
|
|
785
|
+
return (node.nodeName || '').toLowerCase();
|
|
786
|
+
}
|
|
787
|
+
// Mocked nodes in testing environments may not be instances of Node. By
|
|
788
|
+
// returning `#document` an infinite loop won't occur.
|
|
789
|
+
// https://github.com/floating-ui/floating-ui/issues/2317
|
|
790
|
+
return '#document';
|
|
791
|
+
}
|
|
792
|
+
function getWindow(node) {
|
|
793
|
+
var _node$ownerDocument;
|
|
794
|
+
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
795
|
+
}
|
|
796
|
+
function getDocumentElement(node) {
|
|
797
|
+
var _ref;
|
|
798
|
+
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
799
|
+
}
|
|
800
|
+
function isNode(value) {
|
|
801
|
+
if (!hasWindow()) {
|
|
802
|
+
return false;
|
|
803
|
+
}
|
|
804
|
+
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
805
|
+
}
|
|
806
|
+
function isElement(value) {
|
|
807
|
+
if (!hasWindow()) {
|
|
808
|
+
return false;
|
|
809
|
+
}
|
|
810
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
811
|
+
}
|
|
812
|
+
function isHTMLElement(value) {
|
|
813
|
+
if (!hasWindow()) {
|
|
814
|
+
return false;
|
|
815
|
+
}
|
|
816
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
817
|
+
}
|
|
818
|
+
function isShadowRoot(value) {
|
|
819
|
+
if (!hasWindow() || typeof ShadowRoot === 'undefined') {
|
|
820
|
+
return false;
|
|
821
|
+
}
|
|
822
|
+
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
823
|
+
}
|
|
824
|
+
const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
|
|
825
|
+
function isOverflowElement(element) {
|
|
826
|
+
const {
|
|
827
|
+
overflow,
|
|
828
|
+
overflowX,
|
|
829
|
+
overflowY,
|
|
830
|
+
display
|
|
831
|
+
} = getComputedStyle$1(element);
|
|
832
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
|
833
|
+
}
|
|
834
|
+
const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
|
|
835
|
+
function isTableElement(element) {
|
|
836
|
+
return tableElements.has(getNodeName(element));
|
|
837
|
+
}
|
|
838
|
+
const topLayerSelectors = [':popover-open', ':modal'];
|
|
839
|
+
function isTopLayer(element) {
|
|
840
|
+
return topLayerSelectors.some(selector => {
|
|
841
|
+
try {
|
|
842
|
+
return element.matches(selector);
|
|
843
|
+
} catch (_e) {
|
|
844
|
+
return false;
|
|
845
|
+
}
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
|
|
849
|
+
const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
|
|
850
|
+
const containValues = ['paint', 'layout', 'strict', 'content'];
|
|
851
|
+
function isContainingBlock(elementOrCss) {
|
|
852
|
+
const webkit = isWebKit();
|
|
853
|
+
const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
|
|
854
|
+
|
|
855
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
856
|
+
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
|
|
857
|
+
return transformProperties.some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || willChangeValues.some(value => (css.willChange || '').includes(value)) || containValues.some(value => (css.contain || '').includes(value));
|
|
858
|
+
}
|
|
859
|
+
function getContainingBlock(element) {
|
|
860
|
+
let currentNode = getParentNode(element);
|
|
861
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
862
|
+
if (isContainingBlock(currentNode)) {
|
|
863
|
+
return currentNode;
|
|
864
|
+
} else if (isTopLayer(currentNode)) {
|
|
865
|
+
return null;
|
|
866
|
+
}
|
|
867
|
+
currentNode = getParentNode(currentNode);
|
|
868
|
+
}
|
|
869
|
+
return null;
|
|
870
|
+
}
|
|
871
|
+
function isWebKit() {
|
|
872
|
+
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
|
873
|
+
return CSS.supports('-webkit-backdrop-filter', 'none');
|
|
874
|
+
}
|
|
875
|
+
const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
|
|
876
|
+
function isLastTraversableNode(node) {
|
|
877
|
+
return lastTraversableNodeNames.has(getNodeName(node));
|
|
878
|
+
}
|
|
879
|
+
function getComputedStyle$1(element) {
|
|
880
|
+
return getWindow(element).getComputedStyle(element);
|
|
881
|
+
}
|
|
882
|
+
function getNodeScroll(element) {
|
|
883
|
+
if (isElement(element)) {
|
|
884
|
+
return {
|
|
885
|
+
scrollLeft: element.scrollLeft,
|
|
886
|
+
scrollTop: element.scrollTop
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
return {
|
|
890
|
+
scrollLeft: element.scrollX,
|
|
891
|
+
scrollTop: element.scrollY
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
function getParentNode(node) {
|
|
895
|
+
if (getNodeName(node) === 'html') {
|
|
896
|
+
return node;
|
|
897
|
+
}
|
|
898
|
+
const result =
|
|
899
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
900
|
+
node.assignedSlot ||
|
|
901
|
+
// DOM Element detected.
|
|
902
|
+
node.parentNode ||
|
|
903
|
+
// ShadowRoot detected.
|
|
904
|
+
isShadowRoot(node) && node.host ||
|
|
905
|
+
// Fallback.
|
|
906
|
+
getDocumentElement(node);
|
|
907
|
+
return isShadowRoot(result) ? result.host : result;
|
|
908
|
+
}
|
|
909
|
+
function getNearestOverflowAncestor(node) {
|
|
910
|
+
const parentNode = getParentNode(node);
|
|
911
|
+
if (isLastTraversableNode(parentNode)) {
|
|
912
|
+
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
913
|
+
}
|
|
914
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
915
|
+
return parentNode;
|
|
916
|
+
}
|
|
917
|
+
return getNearestOverflowAncestor(parentNode);
|
|
918
|
+
}
|
|
919
|
+
function getOverflowAncestors(node, list, traverseIframes) {
|
|
920
|
+
var _node$ownerDocument2;
|
|
921
|
+
if (list === void 0) {
|
|
922
|
+
list = [];
|
|
923
|
+
}
|
|
924
|
+
if (traverseIframes === void 0) {
|
|
925
|
+
traverseIframes = true;
|
|
926
|
+
}
|
|
927
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
928
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
929
|
+
const win = getWindow(scrollableAncestor);
|
|
930
|
+
if (isBody) {
|
|
931
|
+
const frameElement = getFrameElement(win);
|
|
932
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
|
933
|
+
}
|
|
934
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
935
|
+
}
|
|
936
|
+
function getFrameElement(win) {
|
|
937
|
+
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
function getCssDimensions(element) {
|
|
941
|
+
const css = getComputedStyle$1(element);
|
|
942
|
+
// In testing environments, the `width` and `height` properties are empty
|
|
943
|
+
// strings for SVG elements, returning NaN. Fallback to `0` in this case.
|
|
944
|
+
let width = parseFloat(css.width) || 0;
|
|
945
|
+
let height = parseFloat(css.height) || 0;
|
|
946
|
+
const hasOffset = isHTMLElement(element);
|
|
947
|
+
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
948
|
+
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
949
|
+
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
950
|
+
if (shouldFallback) {
|
|
951
|
+
width = offsetWidth;
|
|
952
|
+
height = offsetHeight;
|
|
953
|
+
}
|
|
954
|
+
return {
|
|
955
|
+
width,
|
|
956
|
+
height,
|
|
957
|
+
$: shouldFallback
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
function unwrapElement(element) {
|
|
962
|
+
return !isElement(element) ? element.contextElement : element;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
function getScale(element) {
|
|
966
|
+
const domElement = unwrapElement(element);
|
|
967
|
+
if (!isHTMLElement(domElement)) {
|
|
968
|
+
return createCoords(1);
|
|
969
|
+
}
|
|
970
|
+
const rect = domElement.getBoundingClientRect();
|
|
971
|
+
const {
|
|
972
|
+
width,
|
|
973
|
+
height,
|
|
974
|
+
$
|
|
975
|
+
} = getCssDimensions(domElement);
|
|
976
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
977
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
978
|
+
|
|
979
|
+
// 0, NaN, or Infinity should always fallback to 1.
|
|
980
|
+
|
|
981
|
+
if (!x || !Number.isFinite(x)) {
|
|
982
|
+
x = 1;
|
|
983
|
+
}
|
|
984
|
+
if (!y || !Number.isFinite(y)) {
|
|
985
|
+
y = 1;
|
|
986
|
+
}
|
|
987
|
+
return {
|
|
988
|
+
x,
|
|
989
|
+
y
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
const noOffsets = /*#__PURE__*/createCoords(0);
|
|
994
|
+
function getVisualOffsets(element) {
|
|
995
|
+
const win = getWindow(element);
|
|
996
|
+
if (!isWebKit() || !win.visualViewport) {
|
|
997
|
+
return noOffsets;
|
|
998
|
+
}
|
|
999
|
+
return {
|
|
1000
|
+
x: win.visualViewport.offsetLeft,
|
|
1001
|
+
y: win.visualViewport.offsetTop
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
1005
|
+
if (isFixed === void 0) {
|
|
1006
|
+
isFixed = false;
|
|
1007
|
+
}
|
|
1008
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
1009
|
+
return false;
|
|
1010
|
+
}
|
|
1011
|
+
return isFixed;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
1015
|
+
if (includeScale === void 0) {
|
|
1016
|
+
includeScale = false;
|
|
1017
|
+
}
|
|
1018
|
+
if (isFixedStrategy === void 0) {
|
|
1019
|
+
isFixedStrategy = false;
|
|
1020
|
+
}
|
|
1021
|
+
const clientRect = element.getBoundingClientRect();
|
|
1022
|
+
const domElement = unwrapElement(element);
|
|
1023
|
+
let scale = createCoords(1);
|
|
1024
|
+
if (includeScale) {
|
|
1025
|
+
if (offsetParent) {
|
|
1026
|
+
if (isElement(offsetParent)) {
|
|
1027
|
+
scale = getScale(offsetParent);
|
|
1028
|
+
}
|
|
1029
|
+
} else {
|
|
1030
|
+
scale = getScale(element);
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
1034
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
1035
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
1036
|
+
let width = clientRect.width / scale.x;
|
|
1037
|
+
let height = clientRect.height / scale.y;
|
|
1038
|
+
if (domElement) {
|
|
1039
|
+
const win = getWindow(domElement);
|
|
1040
|
+
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
1041
|
+
let currentWin = win;
|
|
1042
|
+
let currentIFrame = getFrameElement(currentWin);
|
|
1043
|
+
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
1044
|
+
const iframeScale = getScale(currentIFrame);
|
|
1045
|
+
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
1046
|
+
const css = getComputedStyle$1(currentIFrame);
|
|
1047
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
1048
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
1049
|
+
x *= iframeScale.x;
|
|
1050
|
+
y *= iframeScale.y;
|
|
1051
|
+
width *= iframeScale.x;
|
|
1052
|
+
height *= iframeScale.y;
|
|
1053
|
+
x += left;
|
|
1054
|
+
y += top;
|
|
1055
|
+
currentWin = getWindow(currentIFrame);
|
|
1056
|
+
currentIFrame = getFrameElement(currentWin);
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
return rectToClientRect({
|
|
1060
|
+
width,
|
|
1061
|
+
height,
|
|
1062
|
+
x,
|
|
1063
|
+
y
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
// If <html> has a CSS width greater than the viewport, then this will be
|
|
1068
|
+
// incorrect for RTL.
|
|
1069
|
+
function getWindowScrollBarX(element, rect) {
|
|
1070
|
+
const leftScroll = getNodeScroll(element).scrollLeft;
|
|
1071
|
+
if (!rect) {
|
|
1072
|
+
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
|
1073
|
+
}
|
|
1074
|
+
return rect.left + leftScroll;
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
function getHTMLOffset(documentElement, scroll) {
|
|
1078
|
+
const htmlRect = documentElement.getBoundingClientRect();
|
|
1079
|
+
const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
|
|
1080
|
+
const y = htmlRect.top + scroll.scrollTop;
|
|
1081
|
+
return {
|
|
1082
|
+
x,
|
|
1083
|
+
y
|
|
1084
|
+
};
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
1088
|
+
let {
|
|
1089
|
+
elements,
|
|
1090
|
+
rect,
|
|
1091
|
+
offsetParent,
|
|
1092
|
+
strategy
|
|
1093
|
+
} = _ref;
|
|
1094
|
+
const isFixed = strategy === 'fixed';
|
|
1095
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1096
|
+
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
1097
|
+
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
1098
|
+
return rect;
|
|
1099
|
+
}
|
|
1100
|
+
let scroll = {
|
|
1101
|
+
scrollLeft: 0,
|
|
1102
|
+
scrollTop: 0
|
|
1103
|
+
};
|
|
1104
|
+
let scale = createCoords(1);
|
|
1105
|
+
const offsets = createCoords(0);
|
|
1106
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1107
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1108
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1109
|
+
scroll = getNodeScroll(offsetParent);
|
|
1110
|
+
}
|
|
1111
|
+
if (isHTMLElement(offsetParent)) {
|
|
1112
|
+
const offsetRect = getBoundingClientRect(offsetParent);
|
|
1113
|
+
scale = getScale(offsetParent);
|
|
1114
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1115
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
1119
|
+
return {
|
|
1120
|
+
width: rect.width * scale.x,
|
|
1121
|
+
height: rect.height * scale.y,
|
|
1122
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
|
1123
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
|
1124
|
+
};
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
function getClientRects(element) {
|
|
1128
|
+
return Array.from(element.getClientRects());
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
// Gets the entire size of the scrollable document area, even extending outside
|
|
1132
|
+
// of the `<html>` and `<body>` rect bounds if horizontally scrollable.
|
|
1133
|
+
function getDocumentRect(element) {
|
|
1134
|
+
const html = getDocumentElement(element);
|
|
1135
|
+
const scroll = getNodeScroll(element);
|
|
1136
|
+
const body = element.ownerDocument.body;
|
|
1137
|
+
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
1138
|
+
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
1139
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
1140
|
+
const y = -scroll.scrollTop;
|
|
1141
|
+
if (getComputedStyle$1(body).direction === 'rtl') {
|
|
1142
|
+
x += max(html.clientWidth, body.clientWidth) - width;
|
|
1143
|
+
}
|
|
1144
|
+
return {
|
|
1145
|
+
width,
|
|
1146
|
+
height,
|
|
1147
|
+
x,
|
|
1148
|
+
y
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
// Safety check: ensure the scrollbar space is reasonable in case this
|
|
1153
|
+
// calculation is affected by unusual styles.
|
|
1154
|
+
// Most scrollbars leave 15-18px of space.
|
|
1155
|
+
const SCROLLBAR_MAX = 25;
|
|
1156
|
+
function getViewportRect(element, strategy) {
|
|
1157
|
+
const win = getWindow(element);
|
|
1158
|
+
const html = getDocumentElement(element);
|
|
1159
|
+
const visualViewport = win.visualViewport;
|
|
1160
|
+
let width = html.clientWidth;
|
|
1161
|
+
let height = html.clientHeight;
|
|
1162
|
+
let x = 0;
|
|
1163
|
+
let y = 0;
|
|
1164
|
+
if (visualViewport) {
|
|
1165
|
+
width = visualViewport.width;
|
|
1166
|
+
height = visualViewport.height;
|
|
1167
|
+
const visualViewportBased = isWebKit();
|
|
1168
|
+
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
|
|
1169
|
+
x = visualViewport.offsetLeft;
|
|
1170
|
+
y = visualViewport.offsetTop;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
const windowScrollbarX = getWindowScrollBarX(html);
|
|
1174
|
+
// <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
|
|
1175
|
+
// visual width of the <html> but this is not considered in the size
|
|
1176
|
+
// of `html.clientWidth`.
|
|
1177
|
+
if (windowScrollbarX <= 0) {
|
|
1178
|
+
const doc = html.ownerDocument;
|
|
1179
|
+
const body = doc.body;
|
|
1180
|
+
const bodyStyles = getComputedStyle(body);
|
|
1181
|
+
const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
|
|
1182
|
+
const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
|
|
1183
|
+
if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
|
|
1184
|
+
width -= clippingStableScrollbarWidth;
|
|
1185
|
+
}
|
|
1186
|
+
} else if (windowScrollbarX <= SCROLLBAR_MAX) {
|
|
1187
|
+
// If the <body> scrollbar is on the left, the width needs to be extended
|
|
1188
|
+
// by the scrollbar amount so there isn't extra space on the right.
|
|
1189
|
+
width += windowScrollbarX;
|
|
1190
|
+
}
|
|
1191
|
+
return {
|
|
1192
|
+
width,
|
|
1193
|
+
height,
|
|
1194
|
+
x,
|
|
1195
|
+
y
|
|
1196
|
+
};
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
const absoluteOrFixed = /*#__PURE__*/new Set(['absolute', 'fixed']);
|
|
1200
|
+
// Returns the inner client rect, subtracting scrollbars if present.
|
|
1201
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
1202
|
+
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
|
1203
|
+
const top = clientRect.top + element.clientTop;
|
|
1204
|
+
const left = clientRect.left + element.clientLeft;
|
|
1205
|
+
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
1206
|
+
const width = element.clientWidth * scale.x;
|
|
1207
|
+
const height = element.clientHeight * scale.y;
|
|
1208
|
+
const x = left * scale.x;
|
|
1209
|
+
const y = top * scale.y;
|
|
1210
|
+
return {
|
|
1211
|
+
width,
|
|
1212
|
+
height,
|
|
1213
|
+
x,
|
|
1214
|
+
y
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1217
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
1218
|
+
let rect;
|
|
1219
|
+
if (clippingAncestor === 'viewport') {
|
|
1220
|
+
rect = getViewportRect(element, strategy);
|
|
1221
|
+
} else if (clippingAncestor === 'document') {
|
|
1222
|
+
rect = getDocumentRect(getDocumentElement(element));
|
|
1223
|
+
} else if (isElement(clippingAncestor)) {
|
|
1224
|
+
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
1225
|
+
} else {
|
|
1226
|
+
const visualOffsets = getVisualOffsets(element);
|
|
1227
|
+
rect = {
|
|
1228
|
+
x: clippingAncestor.x - visualOffsets.x,
|
|
1229
|
+
y: clippingAncestor.y - visualOffsets.y,
|
|
1230
|
+
width: clippingAncestor.width,
|
|
1231
|
+
height: clippingAncestor.height
|
|
1232
|
+
};
|
|
1233
|
+
}
|
|
1234
|
+
return rectToClientRect(rect);
|
|
1235
|
+
}
|
|
1236
|
+
function hasFixedPositionAncestor(element, stopNode) {
|
|
1237
|
+
const parentNode = getParentNode(element);
|
|
1238
|
+
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
1239
|
+
return false;
|
|
1240
|
+
}
|
|
1241
|
+
return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
|
1245
|
+
// clipping (or hiding) child elements. This returns all clipping ancestors
|
|
1246
|
+
// of the given element up the tree.
|
|
1247
|
+
function getClippingElementAncestors(element, cache) {
|
|
1248
|
+
const cachedResult = cache.get(element);
|
|
1249
|
+
if (cachedResult) {
|
|
1250
|
+
return cachedResult;
|
|
1251
|
+
}
|
|
1252
|
+
let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
|
|
1253
|
+
let currentContainingBlockComputedStyle = null;
|
|
1254
|
+
const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
|
|
1255
|
+
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
1256
|
+
|
|
1257
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
1258
|
+
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1259
|
+
const computedStyle = getComputedStyle$1(currentNode);
|
|
1260
|
+
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
1261
|
+
if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
|
|
1262
|
+
currentContainingBlockComputedStyle = null;
|
|
1263
|
+
}
|
|
1264
|
+
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
1265
|
+
if (shouldDropCurrentNode) {
|
|
1266
|
+
// Drop non-containing blocks.
|
|
1267
|
+
result = result.filter(ancestor => ancestor !== currentNode);
|
|
1268
|
+
} else {
|
|
1269
|
+
// Record last containing block for next iteration.
|
|
1270
|
+
currentContainingBlockComputedStyle = computedStyle;
|
|
1271
|
+
}
|
|
1272
|
+
currentNode = getParentNode(currentNode);
|
|
1273
|
+
}
|
|
1274
|
+
cache.set(element, result);
|
|
1275
|
+
return result;
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
// Gets the maximum area that the element is visible in due to any number of
|
|
1279
|
+
// clipping ancestors.
|
|
1280
|
+
function getClippingRect(_ref) {
|
|
1281
|
+
let {
|
|
1282
|
+
element,
|
|
1283
|
+
boundary,
|
|
1284
|
+
rootBoundary,
|
|
1285
|
+
strategy
|
|
1286
|
+
} = _ref;
|
|
1287
|
+
const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
1288
|
+
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
1289
|
+
const firstClippingAncestor = clippingAncestors[0];
|
|
1290
|
+
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
1291
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
1292
|
+
accRect.top = max(rect.top, accRect.top);
|
|
1293
|
+
accRect.right = min(rect.right, accRect.right);
|
|
1294
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
1295
|
+
accRect.left = max(rect.left, accRect.left);
|
|
1296
|
+
return accRect;
|
|
1297
|
+
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
1298
|
+
return {
|
|
1299
|
+
width: clippingRect.right - clippingRect.left,
|
|
1300
|
+
height: clippingRect.bottom - clippingRect.top,
|
|
1301
|
+
x: clippingRect.left,
|
|
1302
|
+
y: clippingRect.top
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
function getDimensions(element) {
|
|
1307
|
+
const {
|
|
1308
|
+
width,
|
|
1309
|
+
height
|
|
1310
|
+
} = getCssDimensions(element);
|
|
1311
|
+
return {
|
|
1312
|
+
width,
|
|
1313
|
+
height
|
|
1314
|
+
};
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
1318
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1319
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1320
|
+
const isFixed = strategy === 'fixed';
|
|
1321
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
1322
|
+
let scroll = {
|
|
1323
|
+
scrollLeft: 0,
|
|
1324
|
+
scrollTop: 0
|
|
1325
|
+
};
|
|
1326
|
+
const offsets = createCoords(0);
|
|
1327
|
+
|
|
1328
|
+
// If the <body> scrollbar appears on the left (e.g. RTL systems). Use
|
|
1329
|
+
// Firefox with layout.scrollbar.side = 3 in about:config to test this.
|
|
1330
|
+
function setLeftRTLScrollbarOffset() {
|
|
1331
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
1332
|
+
}
|
|
1333
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1334
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1335
|
+
scroll = getNodeScroll(offsetParent);
|
|
1336
|
+
}
|
|
1337
|
+
if (isOffsetParentAnElement) {
|
|
1338
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
1339
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1340
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1341
|
+
} else if (documentElement) {
|
|
1342
|
+
setLeftRTLScrollbarOffset();
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
if (isFixed && !isOffsetParentAnElement && documentElement) {
|
|
1346
|
+
setLeftRTLScrollbarOffset();
|
|
1347
|
+
}
|
|
1348
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
1349
|
+
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
|
1350
|
+
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
|
1351
|
+
return {
|
|
1352
|
+
x,
|
|
1353
|
+
y,
|
|
1354
|
+
width: rect.width,
|
|
1355
|
+
height: rect.height
|
|
1356
|
+
};
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
function isStaticPositioned(element) {
|
|
1360
|
+
return getComputedStyle$1(element).position === 'static';
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
function getTrueOffsetParent(element, polyfill) {
|
|
1364
|
+
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
|
|
1365
|
+
return null;
|
|
1366
|
+
}
|
|
1367
|
+
if (polyfill) {
|
|
1368
|
+
return polyfill(element);
|
|
1369
|
+
}
|
|
1370
|
+
let rawOffsetParent = element.offsetParent;
|
|
1371
|
+
|
|
1372
|
+
// Firefox returns the <html> element as the offsetParent if it's non-static,
|
|
1373
|
+
// while Chrome and Safari return the <body> element. The <body> element must
|
|
1374
|
+
// be used to perform the correct calculations even if the <html> element is
|
|
1375
|
+
// non-static.
|
|
1376
|
+
if (getDocumentElement(element) === rawOffsetParent) {
|
|
1377
|
+
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
|
1378
|
+
}
|
|
1379
|
+
return rawOffsetParent;
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
// Gets the closest ancestor positioned element. Handles some edge cases,
|
|
1383
|
+
// such as table ancestors and cross browser bugs.
|
|
1384
|
+
function getOffsetParent(element, polyfill) {
|
|
1385
|
+
const win = getWindow(element);
|
|
1386
|
+
if (isTopLayer(element)) {
|
|
1387
|
+
return win;
|
|
1388
|
+
}
|
|
1389
|
+
if (!isHTMLElement(element)) {
|
|
1390
|
+
let svgOffsetParent = getParentNode(element);
|
|
1391
|
+
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
1392
|
+
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
|
1393
|
+
return svgOffsetParent;
|
|
1394
|
+
}
|
|
1395
|
+
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
1396
|
+
}
|
|
1397
|
+
return win;
|
|
1398
|
+
}
|
|
1399
|
+
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
1400
|
+
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
|
1401
|
+
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
1402
|
+
}
|
|
1403
|
+
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
|
1404
|
+
return win;
|
|
1405
|
+
}
|
|
1406
|
+
return offsetParent || getContainingBlock(element) || win;
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
const getElementRects = async function (data) {
|
|
1410
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1411
|
+
const getDimensionsFn = this.getDimensions;
|
|
1412
|
+
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
1413
|
+
return {
|
|
1414
|
+
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
1415
|
+
floating: {
|
|
1416
|
+
x: 0,
|
|
1417
|
+
y: 0,
|
|
1418
|
+
width: floatingDimensions.width,
|
|
1419
|
+
height: floatingDimensions.height
|
|
1420
|
+
}
|
|
1421
|
+
};
|
|
1422
|
+
};
|
|
1423
|
+
|
|
1424
|
+
function isRTL(element) {
|
|
1425
|
+
return getComputedStyle$1(element).direction === 'rtl';
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
const platform = {
|
|
1429
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1430
|
+
getDocumentElement,
|
|
1431
|
+
getClippingRect,
|
|
1432
|
+
getOffsetParent,
|
|
1433
|
+
getElementRects,
|
|
1434
|
+
getClientRects,
|
|
1435
|
+
getDimensions,
|
|
1436
|
+
getScale,
|
|
1437
|
+
isElement,
|
|
1438
|
+
isRTL
|
|
1439
|
+
};
|
|
1440
|
+
|
|
1441
|
+
function rectsAreEqual(a, b) {
|
|
1442
|
+
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
// https://samthor.au/2021/observing-dom/
|
|
1446
|
+
function observeMove(element, onMove) {
|
|
1447
|
+
let io = null;
|
|
1448
|
+
let timeoutId;
|
|
1449
|
+
const root = getDocumentElement(element);
|
|
1450
|
+
function cleanup() {
|
|
1451
|
+
var _io;
|
|
1452
|
+
clearTimeout(timeoutId);
|
|
1453
|
+
(_io = io) == null || _io.disconnect();
|
|
1454
|
+
io = null;
|
|
1455
|
+
}
|
|
1456
|
+
function refresh(skip, threshold) {
|
|
1457
|
+
if (skip === void 0) {
|
|
1458
|
+
skip = false;
|
|
1459
|
+
}
|
|
1460
|
+
if (threshold === void 0) {
|
|
1461
|
+
threshold = 1;
|
|
1462
|
+
}
|
|
1463
|
+
cleanup();
|
|
1464
|
+
const elementRectForRootMargin = element.getBoundingClientRect();
|
|
1465
|
+
const {
|
|
1466
|
+
left,
|
|
1467
|
+
top,
|
|
1468
|
+
width,
|
|
1469
|
+
height
|
|
1470
|
+
} = elementRectForRootMargin;
|
|
1471
|
+
if (!skip) {
|
|
1472
|
+
onMove();
|
|
1473
|
+
}
|
|
1474
|
+
if (!width || !height) {
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
const insetTop = floor(top);
|
|
1478
|
+
const insetRight = floor(root.clientWidth - (left + width));
|
|
1479
|
+
const insetBottom = floor(root.clientHeight - (top + height));
|
|
1480
|
+
const insetLeft = floor(left);
|
|
1481
|
+
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
|
1482
|
+
const options = {
|
|
1483
|
+
rootMargin,
|
|
1484
|
+
threshold: max(0, min(1, threshold)) || 1
|
|
1485
|
+
};
|
|
1486
|
+
let isFirstUpdate = true;
|
|
1487
|
+
function handleObserve(entries) {
|
|
1488
|
+
const ratio = entries[0].intersectionRatio;
|
|
1489
|
+
if (ratio !== threshold) {
|
|
1490
|
+
if (!isFirstUpdate) {
|
|
1491
|
+
return refresh();
|
|
1492
|
+
}
|
|
1493
|
+
if (!ratio) {
|
|
1494
|
+
// If the reference is clipped, the ratio is 0. Throttle the refresh
|
|
1495
|
+
// to prevent an infinite loop of updates.
|
|
1496
|
+
timeoutId = setTimeout(() => {
|
|
1497
|
+
refresh(false, 1e-7);
|
|
1498
|
+
}, 1000);
|
|
1499
|
+
} else {
|
|
1500
|
+
refresh(false, ratio);
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
|
|
1504
|
+
// It's possible that even though the ratio is reported as 1, the
|
|
1505
|
+
// element is not actually fully within the IntersectionObserver's root
|
|
1506
|
+
// area anymore. This can happen under performance constraints. This may
|
|
1507
|
+
// be a bug in the browser's IntersectionObserver implementation. To
|
|
1508
|
+
// work around this, we compare the element's bounding rect now with
|
|
1509
|
+
// what it was at the time we created the IntersectionObserver. If they
|
|
1510
|
+
// are not equal then the element moved, so we refresh.
|
|
1511
|
+
refresh();
|
|
1512
|
+
}
|
|
1513
|
+
isFirstUpdate = false;
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
// Older browsers don't support a `document` as the root and will throw an
|
|
1517
|
+
// error.
|
|
1518
|
+
try {
|
|
1519
|
+
io = new IntersectionObserver(handleObserve, {
|
|
1520
|
+
...options,
|
|
1521
|
+
// Handle <iframe>s
|
|
1522
|
+
root: root.ownerDocument
|
|
1523
|
+
});
|
|
1524
|
+
} catch (_e) {
|
|
1525
|
+
io = new IntersectionObserver(handleObserve, options);
|
|
1526
|
+
}
|
|
1527
|
+
io.observe(element);
|
|
1528
|
+
}
|
|
1529
|
+
refresh(true);
|
|
1530
|
+
return cleanup;
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
/**
|
|
1534
|
+
* Automatically updates the position of the floating element when necessary.
|
|
1535
|
+
* Should only be called when the floating element is mounted on the DOM or
|
|
1536
|
+
* visible on the screen.
|
|
1537
|
+
* @returns cleanup function that should be invoked when the floating element is
|
|
1538
|
+
* removed from the DOM or hidden from the screen.
|
|
1539
|
+
* @see https://floating-ui.com/docs/autoUpdate
|
|
1540
|
+
*/
|
|
1541
|
+
function autoUpdate(reference, floating, update, options) {
|
|
1542
|
+
if (options === void 0) {
|
|
1543
|
+
options = {};
|
|
1544
|
+
}
|
|
1545
|
+
const {
|
|
1546
|
+
ancestorScroll = true,
|
|
1547
|
+
ancestorResize = true,
|
|
1548
|
+
elementResize = typeof ResizeObserver === 'function',
|
|
1549
|
+
layoutShift = typeof IntersectionObserver === 'function',
|
|
1550
|
+
animationFrame = false
|
|
1551
|
+
} = options;
|
|
1552
|
+
const referenceEl = unwrapElement(reference);
|
|
1553
|
+
const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
|
|
1554
|
+
ancestors.forEach(ancestor => {
|
|
1555
|
+
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
|
1556
|
+
passive: true
|
|
1557
|
+
});
|
|
1558
|
+
ancestorResize && ancestor.addEventListener('resize', update);
|
|
1559
|
+
});
|
|
1560
|
+
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
|
1561
|
+
let reobserveFrame = -1;
|
|
1562
|
+
let resizeObserver = null;
|
|
1563
|
+
if (elementResize) {
|
|
1564
|
+
resizeObserver = new ResizeObserver(_ref => {
|
|
1565
|
+
let [firstEntry] = _ref;
|
|
1566
|
+
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
|
1567
|
+
// Prevent update loops when using the `size` middleware.
|
|
1568
|
+
// https://github.com/floating-ui/floating-ui/issues/1740
|
|
1569
|
+
resizeObserver.unobserve(floating);
|
|
1570
|
+
cancelAnimationFrame(reobserveFrame);
|
|
1571
|
+
reobserveFrame = requestAnimationFrame(() => {
|
|
1572
|
+
var _resizeObserver;
|
|
1573
|
+
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
|
|
1574
|
+
});
|
|
1575
|
+
}
|
|
1576
|
+
update();
|
|
1577
|
+
});
|
|
1578
|
+
if (referenceEl && !animationFrame) {
|
|
1579
|
+
resizeObserver.observe(referenceEl);
|
|
1580
|
+
}
|
|
1581
|
+
resizeObserver.observe(floating);
|
|
1582
|
+
}
|
|
1583
|
+
let frameId;
|
|
1584
|
+
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
1585
|
+
if (animationFrame) {
|
|
1586
|
+
frameLoop();
|
|
1587
|
+
}
|
|
1588
|
+
function frameLoop() {
|
|
1589
|
+
const nextRefRect = getBoundingClientRect(reference);
|
|
1590
|
+
if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
|
|
1591
|
+
update();
|
|
1592
|
+
}
|
|
1593
|
+
prevRefRect = nextRefRect;
|
|
1594
|
+
frameId = requestAnimationFrame(frameLoop);
|
|
1595
|
+
}
|
|
1596
|
+
update();
|
|
1597
|
+
return () => {
|
|
1598
|
+
var _resizeObserver2;
|
|
1599
|
+
ancestors.forEach(ancestor => {
|
|
1600
|
+
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
|
1601
|
+
ancestorResize && ancestor.removeEventListener('resize', update);
|
|
1602
|
+
});
|
|
1603
|
+
cleanupIo == null || cleanupIo();
|
|
1604
|
+
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
|
|
1605
|
+
resizeObserver = null;
|
|
1606
|
+
if (animationFrame) {
|
|
1607
|
+
cancelAnimationFrame(frameId);
|
|
1608
|
+
}
|
|
1609
|
+
};
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
/**
|
|
1613
|
+
* Modifies the placement by translating the floating element along the
|
|
1614
|
+
* specified axes.
|
|
1615
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
1616
|
+
* object may be passed.
|
|
1617
|
+
* @see https://floating-ui.com/docs/offset
|
|
1618
|
+
*/
|
|
1619
|
+
const offset = offset$1;
|
|
1620
|
+
|
|
1621
|
+
/**
|
|
1622
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
1623
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
1624
|
+
* @see https://floating-ui.com/docs/shift
|
|
1625
|
+
*/
|
|
1626
|
+
const shift = shift$1;
|
|
1627
|
+
|
|
1628
|
+
/**
|
|
1629
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
1630
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
1631
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
1632
|
+
* @see https://floating-ui.com/docs/flip
|
|
1633
|
+
*/
|
|
1634
|
+
const flip = flip$1;
|
|
1635
|
+
|
|
1636
|
+
/**
|
|
1637
|
+
* Provides improved positioning for inline reference elements that can span
|
|
1638
|
+
* over multiple lines, such as hyperlinks or range selections.
|
|
1639
|
+
* @see https://floating-ui.com/docs/inline
|
|
1640
|
+
*/
|
|
1641
|
+
const inline = inline$1;
|
|
1642
|
+
|
|
1643
|
+
/**
|
|
1644
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
1645
|
+
* next to a given reference element.
|
|
1646
|
+
*/
|
|
1647
|
+
const computePosition = (reference, floating, options) => {
|
|
1648
|
+
// This caches the expensive `getClippingElementAncestors` function so that
|
|
1649
|
+
// multiple lifecycle resets re-use the same result. It only lives for a
|
|
1650
|
+
// single call. If other functions become expensive, we can add them as well.
|
|
1651
|
+
const cache = new Map();
|
|
1652
|
+
const mergedOptions = {
|
|
1653
|
+
platform,
|
|
1654
|
+
...options
|
|
1655
|
+
};
|
|
1656
|
+
const platformWithCache = {
|
|
1657
|
+
...mergedOptions.platform,
|
|
1658
|
+
_c: cache
|
|
1659
|
+
};
|
|
1660
|
+
return computePosition$1(reference, floating, {
|
|
1661
|
+
...mergedOptions,
|
|
1662
|
+
platform: platformWithCache
|
|
1663
|
+
});
|
|
1664
|
+
};
|
|
1665
|
+
|
|
1666
|
+
function offsetParent(element) {
|
|
1667
|
+
return offsetParentPolyfill(element);
|
|
1668
|
+
}
|
|
1669
|
+
function flatTreeParent(element) {
|
|
1670
|
+
if (element.assignedSlot) {
|
|
1671
|
+
return element.assignedSlot;
|
|
1672
|
+
}
|
|
1673
|
+
if (element.parentNode instanceof ShadowRoot) {
|
|
1674
|
+
return element.parentNode.host;
|
|
1675
|
+
}
|
|
1676
|
+
return element.parentNode;
|
|
1677
|
+
}
|
|
1678
|
+
function offsetParentPolyfill(element) {
|
|
1679
|
+
// Do an initial walk to check for display:none ancestors.
|
|
1680
|
+
for (let ancestor = element; ancestor; ancestor = flatTreeParent(ancestor)) {
|
|
1681
|
+
if (!(ancestor instanceof Element)) {
|
|
1682
|
+
continue;
|
|
1683
|
+
}
|
|
1684
|
+
if (getComputedStyle(ancestor).display === 'none') {
|
|
1685
|
+
return null;
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
for (let ancestor = flatTreeParent(element); ancestor; ancestor = flatTreeParent(ancestor)) {
|
|
1689
|
+
if (!(ancestor instanceof Element)) {
|
|
1690
|
+
continue;
|
|
1691
|
+
}
|
|
1692
|
+
const style = getComputedStyle(ancestor);
|
|
1693
|
+
// Display:contents nodes aren't in the layout tree, so they should be skipped.
|
|
1694
|
+
if (style.display === 'contents') {
|
|
1695
|
+
continue;
|
|
1696
|
+
}
|
|
1697
|
+
if (style.position !== 'static' || isContainingBlock(style)) {
|
|
1698
|
+
return ancestor;
|
|
1699
|
+
}
|
|
1700
|
+
if (ancestor.tagName === 'BODY') {
|
|
1701
|
+
return ancestor;
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
return null;
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
/**
|
|
1708
|
+
* Positions an element relative to an anchor element.
|
|
1709
|
+
* @param {HTMLElement} target The element to position.
|
|
1710
|
+
* @param {HTMLElement} anchor The element in which to anchor `target`.
|
|
1711
|
+
* @param {AnchorOptions} options Options that control positioning relative to the anchor.
|
|
1712
|
+
* @param {((x: number, y: number, position: AnchorPosition) => void) | undefined} update Callback used to position `target`.
|
|
1713
|
+
* @returns {Promise<() => void>} Promise that resolves to a function used to stop updating target when the position of the anchor element changes.
|
|
1714
|
+
*/
|
|
1715
|
+
async function positionAnchor(target, anchor, options, update) {
|
|
1716
|
+
async function computeAnchorPosition() {
|
|
1717
|
+
const middleware = new Array();
|
|
1718
|
+
if (options?.inline) {
|
|
1719
|
+
middleware.push(inline());
|
|
1720
|
+
}
|
|
1721
|
+
if (options.flip) {
|
|
1722
|
+
middleware.push(options.flip === true ? flip() : flip({ fallbackPlacements: options.flip }));
|
|
1723
|
+
}
|
|
1724
|
+
if (options.shift) {
|
|
1725
|
+
middleware.push(shift());
|
|
1726
|
+
}
|
|
1727
|
+
if (options.offset && !isNaN(options.offset)) {
|
|
1728
|
+
middleware.push(offset(options.offset));
|
|
1729
|
+
}
|
|
1730
|
+
const result = await computePosition(anchor, target, {
|
|
1731
|
+
placement: options.position,
|
|
1732
|
+
middleware: middleware,
|
|
1733
|
+
platform: { ...platform, getOffsetParent: (x) => platform.getOffsetParent(x, offsetParent) },
|
|
1734
|
+
});
|
|
1735
|
+
if (!update) {
|
|
1736
|
+
target.style.left = `${result.x}px`;
|
|
1737
|
+
target.style.top = `${result.y}px`;
|
|
1738
|
+
}
|
|
1739
|
+
else {
|
|
1740
|
+
update(result.x, result.y, result.placement);
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
await computeAnchorPosition();
|
|
1744
|
+
return autoUpdate(anchor, target, async () => await computeAnchorPosition());
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
export { positionAnchor };
|
|
1748
|
+
//# sourceMappingURL=anchoring.js.map
|