@shortfuse/materialdesignweb 0.7.6 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -90
- package/bin/mdw-css.js +1 -1
- package/components/Badge.js +14 -7
- package/components/Body.js +3 -0
- package/components/BottomAppBar.js +4 -13
- package/components/BottomSheet.js +424 -0
- package/components/Box.js +20 -28
- package/components/Button.js +85 -79
- package/components/Button.md +9 -9
- package/components/Card.js +60 -72
- package/components/Checkbox.js +33 -42
- package/components/CheckboxIcon.js +11 -29
- package/components/Chip.js +13 -11
- package/components/Dialog.js +214 -394
- package/components/DialogActions.js +2 -2
- package/components/Display.js +55 -0
- package/components/Divider.js +3 -3
- package/components/Fab.js +83 -18
- package/components/FabContainer.js +48 -0
- package/components/FilterChip.js +35 -33
- package/components/Grid.js +176 -0
- package/components/Headline.js +5 -28
- package/components/Icon.js +61 -76
- package/components/IconButton.js +72 -126
- package/components/Input.js +859 -1
- package/components/InputChip.js +161 -0
- package/components/Label.js +3 -0
- package/components/List.js +4 -6
- package/components/ListItem.js +46 -30
- package/components/ListOption.js +86 -53
- package/components/Listbox.js +248 -0
- package/components/Menu.js +69 -528
- package/components/MenuItem.js +33 -36
- package/components/NavBar.js +49 -86
- package/components/NavDrawer.js +16 -15
- package/components/NavDrawerItem.js +4 -5
- package/components/NavItem.js +58 -41
- package/components/NavRail.js +30 -20
- package/components/NavRailItem.js +8 -3
- package/components/Page.js +105 -0
- package/components/Pane.js +11 -274
- package/components/Popup.js +29 -0
- package/components/Progress.js +24 -23
- package/components/Radio.js +40 -36
- package/components/RadioIcon.js +12 -16
- package/components/Ripple.js +13 -10
- package/components/Root.js +209 -0
- package/components/Scrim.js +87 -0
- package/components/Search.js +77 -0
- package/components/SegmentedButton.js +33 -45
- package/components/SegmentedButtonGroup.js +25 -13
- package/components/Select.js +10 -11
- package/components/Shape.js +5 -65
- package/components/SideSheet.js +308 -0
- package/components/Slider.js +108 -78
- package/components/Snackbar.js +26 -21
- package/components/SnackbarContainer.js +42 -0
- package/components/Surface.js +17 -12
- package/components/Switch.js +45 -24
- package/components/SwitchIcon.js +49 -39
- package/components/Tab.js +64 -43
- package/components/TabContent.js +5 -3
- package/components/TabList.js +62 -34
- package/components/TabPanel.js +11 -8
- package/components/Table.js +116 -0
- package/components/TextArea.js +54 -50
- package/components/Title.js +4 -9
- package/components/Tooltip.js +44 -22
- package/components/TopAppBar.js +68 -172
- package/constants/shapes.js +36 -0
- package/constants/typography.js +127 -0
- package/core/Composition.js +1164 -645
- package/core/CompositionAdapter.js +314 -0
- package/core/CustomElement.js +701 -286
- package/core/css.js +121 -15
- package/core/customTypes.js +157 -40
- package/core/dom.js +17 -11
- package/{utils → core}/jsonMergePatch.js +42 -18
- package/core/observe.js +343 -244
- package/core/optimizations.js +23 -0
- package/core/template.js +19 -56
- package/core/uid.js +13 -0
- package/dist/index.min.js +85 -184
- package/dist/index.min.js.map +4 -4
- package/dist/meta.json +1 -1
- package/dom/HTMLOptionsCollectionProxy.js +106 -0
- package/loaders/palette.js +13 -0
- package/loaders/theme.js +12 -0
- package/mixins/AriaReflectorMixin.js +53 -14
- package/mixins/AriaToolbarMixin.js +5 -3
- package/mixins/ControlMixin.js +92 -41
- package/mixins/DelegatesFocusMixin.js +54 -0
- package/mixins/DensityMixin.js +2 -3
- package/mixins/ElevationMixin.js +62 -0
- package/mixins/FlexableMixin.js +67 -39
- package/mixins/FormAssociatedMixin.js +71 -16
- package/mixins/HyperlinkMixin.js +66 -0
- package/mixins/InputMixin.js +205 -39
- package/mixins/KeyboardNavMixin.js +22 -7
- package/mixins/NavigationListenerMixin.js +33 -0
- package/mixins/PopupMixin.js +725 -0
- package/mixins/RTLObserverMixin.js +0 -1
- package/mixins/ResizeObserverMixin.js +16 -5
- package/mixins/RippleMixin.js +11 -10
- package/mixins/ScrollListenerMixin.js +42 -33
- package/mixins/SemiStickyMixin.js +97 -0
- package/mixins/ShapeMaskedMixin.js +117 -0
- package/mixins/ShapeMixin.js +17 -194
- package/mixins/StateMixin.js +80 -39
- package/mixins/TextFieldMixin.js +139 -183
- package/mixins/ThemableMixin.js +71 -161
- package/mixins/TooltipTriggerMixin.js +292 -366
- package/mixins/TouchTargetMixin.js +5 -4
- package/mixins/TypographyMixin.js +121 -0
- package/package.json +111 -71
- package/services/rtl.js +10 -0
- package/services/svgAlias.js +17 -0
- package/{theming/index.js → services/theme.js} +25 -175
- package/types/bin/mdw-css.d.ts +3 -0
- package/types/bin/mdw-css.d.ts.map +1 -0
- package/types/components/Badge.d.ts +39 -0
- package/types/components/Badge.d.ts.map +1 -0
- package/types/components/Body.d.ts +29 -0
- package/types/components/Body.d.ts.map +1 -0
- package/types/components/BottomAppBar.d.ts +73 -0
- package/types/components/BottomAppBar.d.ts.map +1 -0
- package/types/components/BottomSheet.d.ts +109 -0
- package/types/components/BottomSheet.d.ts.map +1 -0
- package/types/components/Box.d.ts +16 -0
- package/types/components/Box.d.ts.map +1 -0
- package/types/components/Button.d.ts +714 -0
- package/types/components/Button.d.ts.map +1 -0
- package/types/components/Card.d.ts +412 -0
- package/types/components/Card.d.ts.map +1 -0
- package/types/components/Checkbox.d.ts +205 -0
- package/types/components/Checkbox.d.ts.map +1 -0
- package/types/components/CheckboxIcon.d.ts +44 -0
- package/types/components/CheckboxIcon.d.ts.map +1 -0
- package/types/components/Chip.d.ts +1425 -0
- package/types/components/Chip.d.ts.map +1 -0
- package/types/components/Dialog.d.ts +286 -0
- package/types/components/Dialog.d.ts.map +1 -0
- package/types/components/DialogActions.d.ts +4 -0
- package/types/components/DialogActions.d.ts.map +1 -0
- package/types/components/Display.d.ts +45 -0
- package/types/components/Display.d.ts.map +1 -0
- package/types/components/Divider.d.ts +10 -0
- package/types/components/Divider.d.ts.map +1 -0
- package/types/components/Fab.d.ts +741 -0
- package/types/components/Fab.d.ts.map +1 -0
- package/types/components/FabContainer.d.ts +10 -0
- package/types/components/FabContainer.d.ts.map +1 -0
- package/types/components/FilterChip.d.ts +4283 -0
- package/types/components/FilterChip.d.ts.map +1 -0
- package/types/components/Grid.d.ts +37 -0
- package/types/components/Grid.d.ts.map +1 -0
- package/types/components/Headline.d.ts +47 -0
- package/types/components/Headline.d.ts.map +1 -0
- package/types/components/Icon.d.ts +103 -0
- package/types/components/Icon.d.ts.map +1 -0
- package/types/components/IconButton.d.ts +1486 -0
- package/types/components/IconButton.d.ts.map +1 -0
- package/types/components/Input.d.ts +51288 -0
- package/types/components/Input.d.ts.map +1 -0
- package/types/components/InputChip.d.ts +243 -0
- package/types/components/InputChip.d.ts.map +1 -0
- package/types/components/Label.d.ts +29 -0
- package/types/components/Label.d.ts.map +1 -0
- package/types/components/List.d.ts +31 -0
- package/types/components/List.d.ts.map +1 -0
- package/types/components/ListItem.d.ts +349 -0
- package/types/components/ListItem.d.ts.map +1 -0
- package/types/components/ListOption.d.ts +1493 -0
- package/types/components/ListOption.d.ts.map +1 -0
- package/types/components/Listbox.d.ts +12012 -0
- package/types/components/Listbox.d.ts.map +1 -0
- package/types/components/Menu.d.ts +119 -0
- package/types/components/Menu.d.ts.map +1 -0
- package/types/components/MenuItem.d.ts +3109 -0
- package/types/components/MenuItem.d.ts.map +1 -0
- package/types/components/NavBar.d.ts +18 -0
- package/types/components/NavBar.d.ts.map +1 -0
- package/types/components/NavBarItem.d.ts +186 -0
- package/types/components/NavBarItem.d.ts.map +1 -0
- package/types/components/NavDrawer.d.ts +108 -0
- package/types/components/NavDrawer.d.ts.map +1 -0
- package/types/components/NavDrawerItem.d.ts +186 -0
- package/types/components/NavDrawerItem.d.ts.map +1 -0
- package/types/components/NavItem.d.ts +190 -0
- package/types/components/NavItem.d.ts.map +1 -0
- package/types/components/NavRail.d.ts +109 -0
- package/types/components/NavRail.d.ts.map +1 -0
- package/types/components/NavRailItem.d.ts +186 -0
- package/types/components/NavRailItem.d.ts.map +1 -0
- package/types/components/Page.d.ts +24 -0
- package/types/components/Page.d.ts.map +1 -0
- package/types/components/Pane.d.ts +44 -0
- package/types/components/Pane.d.ts.map +1 -0
- package/types/components/Popup.d.ts +76 -0
- package/types/components/Popup.d.ts.map +1 -0
- package/types/components/Progress.d.ts +19 -0
- package/types/components/Progress.d.ts.map +1 -0
- package/types/components/Radio.d.ts +199 -0
- package/types/components/Radio.d.ts.map +1 -0
- package/types/components/RadioIcon.d.ts +46 -0
- package/types/components/RadioIcon.d.ts.map +1 -0
- package/types/components/Ripple.d.ts +34 -0
- package/types/components/Ripple.d.ts.map +1 -0
- package/types/components/Root.d.ts +68 -0
- package/types/components/Root.d.ts.map +1 -0
- package/types/components/Scrim.d.ts +6 -0
- package/types/components/Scrim.d.ts.map +1 -0
- package/types/components/Search.d.ts +16 -0
- package/types/components/Search.d.ts.map +1 -0
- package/types/components/SegmentedButton.d.ts +718 -0
- package/types/components/SegmentedButton.d.ts.map +1 -0
- package/types/components/SegmentedButtonGroup.d.ts +44 -0
- package/types/components/SegmentedButtonGroup.d.ts.map +1 -0
- package/types/components/Select.d.ts +1361 -0
- package/types/components/Select.d.ts.map +1 -0
- package/types/components/Shape.d.ts +10 -0
- package/types/components/Shape.d.ts.map +1 -0
- package/types/components/SideSheet.d.ts +106 -0
- package/types/components/SideSheet.d.ts.map +1 -0
- package/types/components/Slider.d.ts +382 -0
- package/types/components/Slider.d.ts.map +1 -0
- package/types/components/Snackbar.d.ts +65 -0
- package/types/components/Snackbar.d.ts.map +1 -0
- package/types/components/SnackbarContainer.d.ts +6 -0
- package/types/components/SnackbarContainer.d.ts.map +1 -0
- package/types/components/Surface.d.ts +45 -0
- package/types/components/Surface.d.ts.map +1 -0
- package/types/components/Switch.d.ts +183 -0
- package/types/components/Switch.d.ts.map +1 -0
- package/types/components/SwitchIcon.d.ts +169 -0
- package/types/components/SwitchIcon.d.ts.map +1 -0
- package/types/components/Tab.d.ts +879 -0
- package/types/components/Tab.d.ts.map +1 -0
- package/types/components/TabContent.d.ts +122 -0
- package/types/components/TabContent.d.ts.map +1 -0
- package/types/components/TabList.d.ts +6266 -0
- package/types/components/TabList.d.ts.map +1 -0
- package/types/components/TabPanel.d.ts +28 -0
- package/types/components/TabPanel.d.ts.map +1 -0
- package/types/components/Table.d.ts +2 -0
- package/types/components/Table.d.ts.map +1 -0
- package/types/components/TextArea.d.ts +1394 -0
- package/types/components/TextArea.d.ts.map +1 -0
- package/types/components/Title.d.ts +47 -0
- package/types/components/Title.d.ts.map +1 -0
- package/types/components/Tooltip.d.ts +49 -0
- package/types/components/Tooltip.d.ts.map +1 -0
- package/types/components/TopAppBar.d.ts +130 -0
- package/types/components/TopAppBar.d.ts.map +1 -0
- package/types/constants/colorKeywords.d.ts +2 -0
- package/types/constants/colorKeywords.d.ts.map +1 -0
- package/types/constants/shapes.d.ts +38 -0
- package/types/constants/shapes.d.ts.map +1 -0
- package/types/constants/typography.d.ts +212 -0
- package/types/constants/typography.d.ts.map +1 -0
- package/types/core/Composition.d.ts +252 -0
- package/types/core/Composition.d.ts.map +1 -0
- package/types/core/CompositionAdapter.d.ts +92 -0
- package/types/core/CompositionAdapter.d.ts.map +1 -0
- package/types/core/CustomElement.d.ts +302 -0
- package/types/core/CustomElement.d.ts.map +1 -0
- package/types/core/css.d.ts +44 -0
- package/types/core/css.d.ts.map +1 -0
- package/types/core/customTypes.d.ts +26 -0
- package/types/core/customTypes.d.ts.map +1 -0
- package/types/core/dom.d.ts +32 -0
- package/types/core/dom.d.ts.map +1 -0
- package/types/core/jsonMergePatch.d.ts +31 -0
- package/types/core/jsonMergePatch.d.ts.map +1 -0
- package/types/core/observe.d.ts +113 -0
- package/types/core/observe.d.ts.map +1 -0
- package/types/core/optimizations.d.ts +7 -0
- package/types/core/optimizations.d.ts.map +1 -0
- package/types/core/template.d.ts +47 -0
- package/types/core/template.d.ts.map +1 -0
- package/types/core/uid.d.ts +6 -0
- package/types/core/uid.d.ts.map +1 -0
- package/types/dom/HTMLOptionsCollectionProxy.d.ts +18 -0
- package/types/dom/HTMLOptionsCollectionProxy.d.ts.map +1 -0
- package/types/index.d.ts +88 -0
- package/types/index.d.ts.map +1 -0
- package/types/loaders/palette.d.ts +2 -0
- package/types/loaders/palette.d.ts.map +1 -0
- package/types/loaders/theme.d.ts +2 -0
- package/types/loaders/theme.d.ts.map +1 -0
- package/types/mixins/AriaReflectorMixin.d.ts +23 -0
- package/types/mixins/AriaReflectorMixin.d.ts.map +1 -0
- package/types/mixins/AriaToolbarMixin.d.ts +32 -0
- package/types/mixins/AriaToolbarMixin.d.ts.map +1 -0
- package/types/mixins/ControlMixin.d.ts +124 -0
- package/types/mixins/ControlMixin.d.ts.map +1 -0
- package/types/mixins/DelegatesFocusMixin.d.ts +5 -0
- package/types/mixins/DelegatesFocusMixin.d.ts.map +1 -0
- package/types/mixins/DensityMixin.d.ts +5 -0
- package/types/mixins/DensityMixin.d.ts.map +1 -0
- package/types/mixins/ElevationMixin.d.ts +33 -0
- package/types/mixins/ElevationMixin.d.ts.map +1 -0
- package/types/mixins/FlexableMixin.d.ts +13 -0
- package/types/mixins/FlexableMixin.d.ts.map +1 -0
- package/types/mixins/FormAssociatedMixin.d.ts +122 -0
- package/types/mixins/FormAssociatedMixin.d.ts.map +1 -0
- package/types/mixins/HyperlinkMixin.d.ts +22 -0
- package/types/mixins/HyperlinkMixin.d.ts.map +1 -0
- package/types/mixins/InputMixin.d.ts +179 -0
- package/types/mixins/InputMixin.d.ts.map +1 -0
- package/types/mixins/KeyboardNavMixin.d.ts +47 -0
- package/types/mixins/KeyboardNavMixin.d.ts.map +1 -0
- package/types/mixins/NavigationListenerMixin.d.ts +8 -0
- package/types/mixins/NavigationListenerMixin.d.ts.map +1 -0
- package/types/mixins/PopupMixin.d.ts +82 -0
- package/types/mixins/PopupMixin.d.ts.map +1 -0
- package/types/mixins/RTLObserverMixin.d.ts +7 -0
- package/types/mixins/RTLObserverMixin.d.ts.map +1 -0
- package/types/mixins/ResizeObserverMixin.d.ts +12 -0
- package/types/mixins/ResizeObserverMixin.d.ts.map +1 -0
- package/types/mixins/RippleMixin.d.ts +92 -0
- package/types/mixins/RippleMixin.d.ts.map +1 -0
- package/types/mixins/ScrollListenerMixin.d.ts +41 -0
- package/types/mixins/ScrollListenerMixin.d.ts.map +1 -0
- package/types/mixins/SemiStickyMixin.d.ts +50 -0
- package/types/mixins/SemiStickyMixin.d.ts.map +1 -0
- package/types/mixins/ShapeMaskedMixin.d.ts +9 -0
- package/types/mixins/ShapeMaskedMixin.d.ts.map +1 -0
- package/types/mixins/ShapeMixin.d.ts +38 -0
- package/types/mixins/ShapeMixin.d.ts.map +1 -0
- package/types/mixins/StateMixin.d.ts +27 -0
- package/types/mixins/StateMixin.d.ts.map +1 -0
- package/types/mixins/TextFieldMixin.d.ts +1354 -0
- package/types/mixins/TextFieldMixin.d.ts.map +1 -0
- package/types/mixins/ThemableMixin.d.ts +9 -0
- package/types/mixins/ThemableMixin.d.ts.map +1 -0
- package/types/mixins/TooltipTriggerMixin.d.ts +106 -0
- package/types/mixins/TooltipTriggerMixin.d.ts.map +1 -0
- package/types/mixins/TouchTargetMixin.d.ts +3 -0
- package/types/mixins/TouchTargetMixin.d.ts.map +1 -0
- package/types/mixins/TypographyMixin.d.ts +17 -0
- package/types/mixins/TypographyMixin.d.ts.map +1 -0
- package/types/services/rtl.d.ts +3 -0
- package/types/services/rtl.d.ts.map +1 -0
- package/types/services/svgAlias.d.ts +13 -0
- package/types/services/svgAlias.d.ts.map +1 -0
- package/types/services/theme.d.ts +45 -0
- package/types/services/theme.d.ts.map +1 -0
- package/types/utils/cli.d.ts +3 -0
- package/types/utils/cli.d.ts.map +1 -0
- package/types/utils/function.d.ts +3 -0
- package/types/utils/function.d.ts.map +1 -0
- package/types/utils/jsx-runtime.d.ts +20 -0
- package/types/utils/jsx-runtime.d.ts.map +1 -0
- package/types/utils/material-color/blend.d.ts +34 -0
- package/types/utils/material-color/blend.d.ts.map +1 -0
- package/types/utils/material-color/hct/Cam16.d.ts +142 -0
- package/types/utils/material-color/hct/Cam16.d.ts.map +1 -0
- package/types/utils/material-color/hct/Hct.d.ts +93 -0
- package/types/utils/material-color/hct/Hct.d.ts.map +1 -0
- package/types/utils/material-color/hct/ViewingConditions.d.ts +69 -0
- package/types/utils/material-color/hct/ViewingConditions.d.ts.map +1 -0
- package/types/utils/material-color/hct/hctSolver.d.ts +30 -0
- package/types/utils/material-color/hct/hctSolver.d.ts.map +1 -0
- package/types/utils/material-color/helper.d.ts +8 -0
- package/types/utils/material-color/helper.d.ts.map +1 -0
- package/types/utils/material-color/palettes/CorePalette.d.ts +75 -0
- package/types/utils/material-color/palettes/CorePalette.d.ts.map +1 -0
- package/types/utils/material-color/palettes/TonalPalette.d.ts +38 -0
- package/types/utils/material-color/palettes/TonalPalette.d.ts.map +1 -0
- package/types/utils/material-color/scheme/Scheme.d.ts +264 -0
- package/types/utils/material-color/scheme/Scheme.d.ts.map +1 -0
- package/types/utils/material-color/utils/color.d.ts +172 -0
- package/types/utils/material-color/utils/color.d.ts.map +1 -0
- package/types/utils/material-color/utils/math.d.ts +94 -0
- package/types/utils/material-color/utils/math.d.ts.map +1 -0
- package/types/utils/pixelmatch.d.ts +22 -0
- package/types/utils/pixelmatch.d.ts.map +1 -0
- package/types/utils/popup.d.ts +106 -0
- package/types/utils/popup.d.ts.map +1 -0
- package/types/utils/searchParams.d.ts +3 -0
- package/types/utils/searchParams.d.ts.map +1 -0
- package/types/utils/svg.d.ts +7 -0
- package/types/utils/svg.d.ts.map +1 -0
- package/utils/{hct → material-color}/blend.js +8 -10
- package/utils/{hct → material-color/hct}/Cam16.js +196 -69
- package/utils/{hct → material-color/hct}/Hct.js +61 -19
- package/utils/{hct → material-color/hct}/ViewingConditions.js +3 -3
- package/utils/{hct → material-color/hct}/hctSolver.js +9 -16
- package/utils/{hct → material-color}/helper.js +11 -18
- package/utils/{hct → material-color/palettes}/CorePalette.js +79 -19
- package/utils/{hct → material-color/palettes}/TonalPalette.js +12 -4
- package/utils/material-color/scheme/Scheme.js +376 -0
- package/utils/{hct/colorUtils.js → material-color/utils/color.js} +61 -1
- package/utils/pixelmatch.js +360 -0
- package/utils/popup.js +127 -30
- package/utils/searchParams.js +19 -0
- package/components/ExtendedFab.js +0 -36
- package/components/Layout.js +0 -35
- package/components/ListSelect.js +0 -220
- package/components/Nav.js +0 -40
- package/components/Option.js +0 -91
- package/core/ICustomElement.d.ts +0 -291
- package/core/ICustomElement.js +0 -1
- package/core/identify.js +0 -40
- package/core/typings.d.ts +0 -136
- package/core/typings.js +0 -1
- package/mixins/SurfaceMixin.js +0 -181
- package/theming/loader.js +0 -22
- package/utils/hct/Scheme.js +0 -587
- /package/{utils/color_keywords.js → constants/colorKeywords.js} +0 -0
- /package/utils/{hct/mathUtils.js → material-color/utils/math.js} +0 -0
|
@@ -1,391 +1,317 @@
|
|
|
1
1
|
import '../components/Tooltip.js';
|
|
2
|
+
import { FIREFOX_VERSION } from '../core/dom.js';
|
|
2
3
|
import { canAnchorPopup } from '../utils/popup.js';
|
|
3
4
|
|
|
5
|
+
/** @typedef {import('../components/Tooltip.js').default} Tooltip */
|
|
6
|
+
|
|
4
7
|
/**
|
|
5
8
|
* @param {ReturnType<import('./StateMixin.js').default>} Base
|
|
6
9
|
*/
|
|
7
10
|
export default function TooltipTriggerMixin(Base) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
11
|
+
return Base
|
|
12
|
+
.set({
|
|
13
|
+
TOOLTIP_MOUSE_IDLE_MS: 500,
|
|
14
|
+
TOOLTIP_TOUCH_IDLE_MS: 1500,
|
|
15
|
+
/** @type {any} */
|
|
16
|
+
_idleDebounce: null,
|
|
17
|
+
/** @type {HTMLElement[]} */
|
|
18
|
+
_watchedParents: null,
|
|
19
|
+
/** @type {ResizeObserver} */
|
|
20
|
+
_resizeObserver: null,
|
|
21
|
+
/** @type {IntersectionObserver} */
|
|
22
|
+
_intersectObserver: null,
|
|
23
|
+
_parentScrollListener: null,
|
|
24
|
+
tooltipSlotId: 'slot',
|
|
25
|
+
})
|
|
26
|
+
.observe({
|
|
27
|
+
tooltip: 'string',
|
|
28
|
+
autoTooltip: 'boolean',
|
|
29
|
+
})
|
|
30
|
+
.html`<mdw-tooltip id=tooltip></mdw-tooltip>`
|
|
31
|
+
.css`
|
|
32
|
+
#tooltip {
|
|
33
|
+
display:none;
|
|
34
|
+
}
|
|
35
|
+
`
|
|
36
|
+
.methods({
|
|
37
|
+
cancelShowTooltip() {
|
|
38
|
+
// console.log('cancel tooltiptimer');
|
|
39
|
+
clearTimeout(this._idleDebounce);
|
|
40
|
+
},
|
|
41
|
+
/** @param {'mouse'|'touch'|'keyboard'} type */
|
|
42
|
+
scheduleHideTooltip(type) {
|
|
43
|
+
this.cancelShowTooltip();
|
|
44
|
+
if (!this.refs.tooltip.open) {
|
|
45
|
+
// console.log('abort schedule (shown)');
|
|
46
|
+
return;
|
|
34
47
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
let timeout = 0;
|
|
49
|
+
switch (type) {
|
|
50
|
+
case 'mouse':
|
|
51
|
+
timeout = 0;
|
|
52
|
+
break;
|
|
53
|
+
case 'touch':
|
|
54
|
+
timeout = 1500;
|
|
55
|
+
break;
|
|
56
|
+
default:
|
|
57
|
+
}
|
|
58
|
+
// console.log('schedule tooltiptimer');
|
|
59
|
+
this._idleDebounce = setTimeout(() => {
|
|
60
|
+
// console.log('hide timeout');
|
|
61
|
+
this.hideTooltip();
|
|
62
|
+
}, timeout);
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
/** @param {'mouse'|'touch'|'keyboard'} type */
|
|
66
|
+
scheduleShowTooltip(type) {
|
|
67
|
+
if (this.refs.tooltip.open) return;
|
|
68
|
+
let timeout = 0;
|
|
69
|
+
switch (type) {
|
|
70
|
+
case 'mouse':
|
|
71
|
+
timeout = this.TOOLTIP_MOUSE_IDLE_MS;
|
|
72
|
+
break;
|
|
73
|
+
case 'touch':
|
|
74
|
+
timeout = this.TOOLTIP_TOUCH_IDLE_MS;
|
|
75
|
+
break;
|
|
76
|
+
default:
|
|
47
77
|
}
|
|
48
|
-
`;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
static TOOLTIP_MOUSE_IDLE_MS = 500;
|
|
52
|
-
|
|
53
|
-
static TOOLTIP_TOUCH_IDLE_MS = 1500;
|
|
54
78
|
|
|
55
|
-
|
|
56
|
-
|
|
79
|
+
clearTimeout(this._idleDebounce);
|
|
80
|
+
if (timeout) {
|
|
81
|
+
this._idleDebounce = setTimeout(this.showTooltip.bind(this), timeout);
|
|
82
|
+
} else {
|
|
83
|
+
this.showTooltip();
|
|
84
|
+
}
|
|
85
|
+
},
|
|
57
86
|
|
|
58
|
-
|
|
59
|
-
|
|
87
|
+
showTooltip() {
|
|
88
|
+
const tooltip = /** @type {InstanceType<Tooltip>} */ (this.refs.tooltip);
|
|
89
|
+
if (tooltip.open) return;
|
|
90
|
+
document.body.append(this.refs.tooltip);
|
|
91
|
+
this.recloneTooltip();
|
|
92
|
+
this.updateTooltipPosition();
|
|
93
|
+
this._resizeObserver.observe(this, { box: 'border-box' });
|
|
94
|
+
this._resizeObserver.observe(tooltip, { box: 'border-box' });
|
|
95
|
+
this._intersectObserver.observe(this);
|
|
96
|
+
this._intersectObserver.observe(tooltip);
|
|
97
|
+
/** @type {HTMLElement} */
|
|
98
|
+
let offsetParent = this;
|
|
99
|
+
while ((offsetParent = offsetParent.offsetParent)) {
|
|
100
|
+
this._resizeObserver.observe(offsetParent, { box: 'border-box' });
|
|
101
|
+
// console.log('observing', offsetParent);
|
|
102
|
+
this._watchedParents.push(offsetParent);
|
|
103
|
+
this._intersectObserver.observe(offsetParent);
|
|
104
|
+
offsetParent.addEventListener('scroll', this._parentScrollListener);
|
|
105
|
+
}
|
|
106
|
+
window.addEventListener('scroll', this._parentScrollListener);
|
|
60
107
|
|
|
61
|
-
|
|
108
|
+
// console.log('offsetparent', this.offsetParent);
|
|
62
109
|
|
|
63
|
-
|
|
64
|
-
|
|
110
|
+
tooltip.open = true;
|
|
111
|
+
},
|
|
65
112
|
|
|
66
|
-
|
|
113
|
+
hideTooltip(cancelSchedule = false) {
|
|
114
|
+
if (cancelSchedule) {
|
|
115
|
+
this.cancelShowTooltip();
|
|
116
|
+
}
|
|
117
|
+
this._resizeObserver.disconnect();
|
|
118
|
+
this._intersectObserver.disconnect();
|
|
119
|
+
let parent;
|
|
120
|
+
while ((parent = this._watchedParents.pop())) {
|
|
121
|
+
parent.removeEventListener('scroll', this._parentScrollListener);
|
|
122
|
+
}
|
|
123
|
+
window.removeEventListener('scroll', this._parentScrollListener);
|
|
124
|
+
const tooltip = /** @type {InstanceType<Tooltip>} */ (this.refs.tooltip);
|
|
125
|
+
tooltip.open = false;
|
|
126
|
+
// TODO: Self-remove on close (hide animation)
|
|
127
|
+
tooltip.remove();
|
|
128
|
+
},
|
|
129
|
+
/**
|
|
130
|
+
* TODO: Throttle multiple calls
|
|
131
|
+
* @param {DOMRect} [domRect]
|
|
132
|
+
* @return {void}
|
|
133
|
+
*/
|
|
134
|
+
updateTooltipPosition(domRect) {
|
|
135
|
+
const offset = 8;
|
|
136
|
+
const tooltip = /** @type {InstanceType<Tooltip>} */ (this.refs.tooltip);
|
|
137
|
+
// const margin = 8;
|
|
138
|
+
/** @type {import('../utils/popup.js').CanAnchorPopUpOptions} */
|
|
139
|
+
|
|
140
|
+
Object.assign(tooltip.style, {
|
|
141
|
+
top: '0',
|
|
142
|
+
left: '0',
|
|
143
|
+
right: 'auto',
|
|
144
|
+
bottom: 'auto',
|
|
145
|
+
position: 'fixed',
|
|
146
|
+
maxWidth: null,
|
|
147
|
+
maxHeight: null,
|
|
148
|
+
});
|
|
67
149
|
|
|
68
|
-
|
|
150
|
+
const anchorOptions = {
|
|
151
|
+
anchor: domRect ?? this.getBoundingClientRect(),
|
|
152
|
+
width: tooltip.clientWidth,
|
|
153
|
+
height: tooltip.clientHeight,
|
|
154
|
+
// margin,
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const isPageRTL = (getComputedStyle(this).direction === 'rtl');
|
|
158
|
+
const xStart = isPageRTL ? 'right' : 'left';
|
|
159
|
+
const xEnd = isPageRTL ? 'left' : 'right';
|
|
160
|
+
/** @type {import('../utils/popup.js').CanAnchorPopUpOptions[]} */
|
|
161
|
+
const preferences = [
|
|
162
|
+
{ clientY: 'bottom', clientX: 'center', offsetY: offset },
|
|
163
|
+
{ clientY: 'bottom', clientX: xStart, offsetY: offset },
|
|
164
|
+
{ clientY: 'bottom', clientX: xEnd, offsetY: offset },
|
|
165
|
+
{ clientY: 'top', clientX: 'center', offsetY: -offset },
|
|
166
|
+
{ clientY: 'top', clientX: xStart, offsetY: -offset },
|
|
167
|
+
{ clientY: 'top', clientX: xEnd, offsetY: -offset },
|
|
168
|
+
];
|
|
169
|
+
|
|
170
|
+
let anchorResult;
|
|
171
|
+
for (const preference of preferences) {
|
|
172
|
+
const result = canAnchorPopup({
|
|
173
|
+
...anchorOptions,
|
|
174
|
+
...preference,
|
|
175
|
+
});
|
|
176
|
+
if (!anchorResult || anchorResult.visibility < result.visibility) {
|
|
177
|
+
anchorResult = result;
|
|
178
|
+
}
|
|
179
|
+
if (result.visibility === 1) break;
|
|
180
|
+
}
|
|
69
181
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
182
|
+
Object.assign(tooltip.style, {
|
|
183
|
+
position: 'fixed',
|
|
184
|
+
...anchorResult.styles,
|
|
185
|
+
});
|
|
186
|
+
},
|
|
187
|
+
recloneTooltip() {
|
|
188
|
+
let args;
|
|
189
|
+
const tooltip = this.tooltip;
|
|
190
|
+
if (tooltip) {
|
|
191
|
+
args = [tooltip];
|
|
192
|
+
} else {
|
|
193
|
+
args = /** @type {HTMLSlotElement} */ (this.refs[this.tooltipSlotId])
|
|
194
|
+
.assignedNodes()
|
|
195
|
+
.map((child) => child.cloneNode(true));
|
|
196
|
+
}
|
|
73
197
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
198
|
+
this.refs.tooltip.replaceChildren(...args);
|
|
199
|
+
},
|
|
200
|
+
closeIfNotHovered() {
|
|
201
|
+
// eslint-disable-next-line unicorn/consistent-function-scoping
|
|
202
|
+
const check = () => {
|
|
203
|
+
if (this.hoveredState) return;
|
|
204
|
+
if (this.refs.tooltip.matches(':hover')) return;
|
|
205
|
+
this.hideTooltip(true);
|
|
206
|
+
};
|
|
207
|
+
if (FIREFOX_VERSION) {
|
|
208
|
+
// Firefox stalls one tick
|
|
209
|
+
requestAnimationFrame(check);
|
|
210
|
+
} else {
|
|
211
|
+
check();
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
})
|
|
215
|
+
.childEvents({
|
|
216
|
+
slot: {
|
|
217
|
+
slotchange: 'recloneTooltip',
|
|
218
|
+
},
|
|
219
|
+
tooltip: {
|
|
220
|
+
pointerleave: 'closeIfNotHovered',
|
|
221
|
+
},
|
|
222
|
+
})
|
|
223
|
+
.events({
|
|
224
|
+
'~pointermove'(event) {
|
|
225
|
+
if (event.pointerType === 'touch') return;
|
|
226
|
+
if (this.autoTooltip && !this.disabledState) {
|
|
227
|
+
this.scheduleShowTooltip('mouse');
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
'~keydown'({ ctrlKey }) {
|
|
231
|
+
if (ctrlKey) {
|
|
232
|
+
this.hideTooltip(true);
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
'~click'() {
|
|
236
|
+
this.hideTooltip(true);
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
})
|
|
240
|
+
.on({
|
|
241
|
+
constructed() {
|
|
242
|
+
this._watchedParents = [];
|
|
243
|
+
this._parentScrollListener = this.updateTooltipPosition.bind(this, null);
|
|
244
|
+
this._resizeObserver = new ResizeObserver(() => {
|
|
245
|
+
const tooltip = /** @type {InstanceType<Tooltip>} */ (this.refs.tooltip);
|
|
246
|
+
if (tooltip.open) {
|
|
98
247
|
this.updateTooltipPosition();
|
|
99
|
-
return;
|
|
100
248
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
249
|
+
});
|
|
250
|
+
const threshold = [0, 0.49, 0.5, 0.51, 1];
|
|
251
|
+
this._intersectObserver = new IntersectionObserver((entries) => {
|
|
252
|
+
const tooltip = /** @type {InstanceType<Tooltip>} */ (this.refs.tooltip);
|
|
253
|
+
// console.log('IO', entries);
|
|
254
|
+
if (!tooltip.open) return;
|
|
255
|
+
for (const entry of entries) {
|
|
256
|
+
if (entry.intersectionRatio <= 0) {
|
|
257
|
+
// console.debug('Hide tooltip due to tooltip occlusion');
|
|
104
258
|
this.hideTooltip();
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
if (entry.target === tooltip) {
|
|
262
|
+
// console.debug('Reposition tooltip due to possible tooltip occlusion');
|
|
263
|
+
this.updateTooltipPosition();
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if (entry.target === this) {
|
|
267
|
+
if (entry.intersectionRatio <= 0.5) {
|
|
268
|
+
// console.debug('Hiding tooltip because target is occluded');
|
|
269
|
+
this.hideTooltip();
|
|
270
|
+
} else {
|
|
271
|
+
// console.debug('Using InsectionObserver rect to update tooltip');
|
|
272
|
+
this.updateTooltipPosition(entry.boundingClientRect);
|
|
273
|
+
}
|
|
274
|
+
return;
|
|
108
275
|
}
|
|
109
|
-
return;
|
|
110
276
|
}
|
|
277
|
+
// console.debug('Updating tooltip position because offsetParent change.');
|
|
278
|
+
this.updateTooltipPosition();
|
|
279
|
+
}, { threshold });
|
|
280
|
+
// this.#tooltip.remove();
|
|
281
|
+
},
|
|
282
|
+
_focusedChanged(previous, current) {
|
|
283
|
+
if (current) {
|
|
284
|
+
if (!this._pointerPressed && !this._focusedSynthetic && this.autoTooltip) {
|
|
285
|
+
this.showTooltip();
|
|
286
|
+
}
|
|
287
|
+
} else {
|
|
288
|
+
this.closeIfNotHovered();
|
|
111
289
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* @this {TooltipTrigger} this
|
|
132
|
-
* @param {FocusEvent} event
|
|
133
|
-
* @return {void}
|
|
134
|
-
*/
|
|
135
|
-
onTooltipTriggerFocus(event) {
|
|
136
|
-
// console.log('getting focus', event);
|
|
137
|
-
if (this.disabledState) return;
|
|
138
|
-
if (this.matches(':active')) {
|
|
139
|
-
// console.log('abort from active');
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
this.showTooltip();
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* @this {TooltipTrigger} this
|
|
147
|
-
* @param {KeyboardEvent} event
|
|
148
|
-
* @return {void}
|
|
149
|
-
*/
|
|
150
|
-
onTooltipTriggerKeydown(event) {
|
|
151
|
-
if (event.ctrlKey) this.hideTooltip();
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* @this {TooltipTrigger} this
|
|
156
|
-
* @return {void}
|
|
157
|
-
*/
|
|
158
|
-
onTooltipTriggerBlur() {
|
|
159
|
-
this.hideTooltip();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* @param {MouseEvent|TouchEvent} event
|
|
164
|
-
* @this {TooltipTrigger} this
|
|
165
|
-
* @return {void}
|
|
166
|
-
*/
|
|
167
|
-
onTooltipTriggerPointer(event) {
|
|
168
|
-
if (this.disabledState) return;
|
|
169
|
-
// console.log('tooltip event', event.type);
|
|
170
|
-
switch (event.type) {
|
|
171
|
-
case 'touchstart':
|
|
172
|
-
this.scheduleShowTooltip('touch');
|
|
173
|
-
break;
|
|
174
|
-
case 'touchend':
|
|
175
|
-
case 'touchcancel':
|
|
290
|
+
},
|
|
291
|
+
_hoveredChanged(previous, current) {
|
|
292
|
+
if (current) {
|
|
293
|
+
if (this.autoTooltip && !this.disabledState) {
|
|
294
|
+
this.scheduleShowTooltip('mouse');
|
|
295
|
+
}
|
|
296
|
+
} else {
|
|
297
|
+
this.closeIfNotHovered();
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
_pointerPressedChanged(previous, current) {
|
|
301
|
+
if (this._lastInteraction !== 'touch') return;
|
|
302
|
+
if (current) {
|
|
303
|
+
if (this.autoTooltip && !this.disabledState) {
|
|
304
|
+
this.scheduleShowTooltip('touch');
|
|
305
|
+
}
|
|
306
|
+
} else {
|
|
176
307
|
this.scheduleHideTooltip('touch');
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
break;
|
|
187
|
-
default:
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
get tooltipClone() {
|
|
192
|
-
return this.#tooltip;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
get clonedTooltip() {
|
|
196
|
-
return this.#tooltip;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
cancelShowTooltip() {
|
|
200
|
-
// console.log('cancel tooltiptimer');
|
|
201
|
-
clearTimeout(this.#idleDebounce);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/** @param {'mouse'|'touch'|'keyboard'} type */
|
|
205
|
-
scheduleHideTooltip(type) {
|
|
206
|
-
clearTimeout(this.#idleDebounce);
|
|
207
|
-
if (!this.#tooltip.open) {
|
|
208
|
-
// console.log('abort schedule (shown)');
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
let timeout = 0;
|
|
212
|
-
switch (type) {
|
|
213
|
-
case 'mouse':
|
|
214
|
-
timeout = 0;
|
|
215
|
-
break;
|
|
216
|
-
case 'touch':
|
|
217
|
-
timeout = 1500;
|
|
218
|
-
break;
|
|
219
|
-
default:
|
|
220
|
-
}
|
|
221
|
-
// console.log('schedule tooltiptimer');
|
|
222
|
-
this.#idleDebounce = setTimeout(() => {
|
|
223
|
-
// console.log('hide timeout');
|
|
224
|
-
this.hideTooltip();
|
|
225
|
-
}, timeout);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/** @param {'mouse'|'touch'|'keyboard'} type */
|
|
229
|
-
scheduleShowTooltip(type) {
|
|
230
|
-
if (this.#tooltip.open) {
|
|
231
|
-
// console.log('abort schedule (shown)');
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
let timeout = 0;
|
|
235
|
-
switch (type) {
|
|
236
|
-
case 'mouse':
|
|
237
|
-
timeout = this.constructor.TOOLTIP_MOUSE_IDLE_MS;
|
|
238
|
-
break;
|
|
239
|
-
case 'touch':
|
|
240
|
-
timeout = this.constructor.TOOLTIP_TOUCH_IDLE_MS;
|
|
241
|
-
break;
|
|
242
|
-
default:
|
|
243
|
-
}
|
|
244
|
-
// console.log('schedule tooltiptimer');
|
|
245
|
-
clearTimeout(this.#idleDebounce);
|
|
246
|
-
this.#idleDebounce = setTimeout(() => {
|
|
247
|
-
// console.log('idle');
|
|
248
|
-
this.showTooltip(type === 'touch');
|
|
249
|
-
}, timeout);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
showTooltip(touch = false) {
|
|
253
|
-
if (this.#tooltip.open) return;
|
|
254
|
-
this.refs.tooltip.open = true;
|
|
255
|
-
this.refs.tooltip.touch = touch;
|
|
256
|
-
this.#tooltip.touch = touch;
|
|
257
|
-
document.body.append(this.#tooltip);
|
|
258
|
-
this.updateTooltipPosition();
|
|
259
|
-
this.#resizeObserver.observe(this, { box: 'border-box' });
|
|
260
|
-
this.#intersectObserver.observe(this);
|
|
261
|
-
this.#intersectObserver.observe(this.#tooltip);
|
|
262
|
-
/** @type {HTMLElement} */
|
|
263
|
-
let offsetParent = this;
|
|
264
|
-
while ((offsetParent = offsetParent.offsetParent)) {
|
|
265
|
-
this.#resizeObserver.observe(offsetParent, { box: 'border-box' });
|
|
266
|
-
// console.log('observing', offsetParent);
|
|
267
|
-
this.#watchedParents.push(offsetParent);
|
|
268
|
-
this.#intersectObserver.observe(offsetParent);
|
|
269
|
-
offsetParent.addEventListener('scroll', this.onParentScroll);
|
|
270
|
-
}
|
|
271
|
-
window.addEventListener('scroll', this.onParentScroll);
|
|
272
|
-
|
|
273
|
-
// console.log('offsetparent', this.offsetParent);
|
|
274
|
-
|
|
275
|
-
this.#tooltip.open = true;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
hideTooltip() {
|
|
279
|
-
this.#resizeObserver.disconnect();
|
|
280
|
-
this.#intersectObserver.disconnect();
|
|
281
|
-
let parent;
|
|
282
|
-
while ((parent = this.#watchedParents.pop())) {
|
|
283
|
-
parent.removeEventListener('scroll', this.onParentScroll);
|
|
284
|
-
}
|
|
285
|
-
window.removeEventListener('scroll', this.onParentScroll);
|
|
286
|
-
this.#tooltip.open = false;
|
|
287
|
-
this.#tooltip.remove();
|
|
288
|
-
this.refs.tooltip.open = false;
|
|
289
|
-
const hoverStyle = this.refs.tooltip.style;
|
|
290
|
-
hoverStyle.removeProperty('width');
|
|
291
|
-
hoverStyle.removeProperty('height');
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* @param {DOMRect} [domRect]
|
|
296
|
-
* @return {void}
|
|
297
|
-
*/
|
|
298
|
-
updateTooltipPosition(domRect) {
|
|
299
|
-
const offset = 8;
|
|
300
|
-
// const margin = 8;
|
|
301
|
-
/** @type {import('../utils/popup.js').CanAnchorPopUpOptions} */
|
|
302
|
-
const anchorOptions = {
|
|
303
|
-
anchor: domRect ?? this.getBoundingClientRect(),
|
|
304
|
-
width: this.#tooltip.clientWidth,
|
|
305
|
-
height: this.#tooltip.clientHeight,
|
|
306
|
-
// margin,
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
const isPageRTL = (getComputedStyle(this).direction === 'rtl');
|
|
310
|
-
const xStart = isPageRTL ? 'right' : 'left';
|
|
311
|
-
const xEnd = isPageRTL ? 'left' : 'right';
|
|
312
|
-
/** @type {import('../utils/popup.js').CanAnchorPopUpOptions[]} */
|
|
313
|
-
const preferences = [
|
|
314
|
-
{ clientY: 'bottom', clientX: 'center', offsetY: offset },
|
|
315
|
-
{ clientY: 'bottom', clientX: xStart, offsetY: offset },
|
|
316
|
-
{ clientY: 'bottom', clientX: xEnd, offsetY: offset },
|
|
317
|
-
{ clientY: 'top', clientX: 'center', offsetY: -offset },
|
|
318
|
-
{ clientY: 'top', clientX: xStart, offsetY: -offset },
|
|
319
|
-
{ clientY: 'top', clientX: xEnd, offsetY: -offset },
|
|
320
|
-
];
|
|
321
|
-
|
|
322
|
-
let anchorResult;
|
|
323
|
-
for (const preference of preferences) {
|
|
324
|
-
anchorResult = canAnchorPopup({
|
|
325
|
-
...anchorOptions,
|
|
326
|
-
...preference,
|
|
327
|
-
});
|
|
328
|
-
if (anchorResult) break;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// console.log({ anchorResult });
|
|
332
|
-
if (!anchorResult) {
|
|
333
|
-
anchorResult = canAnchorPopup({
|
|
334
|
-
...anchorOptions,
|
|
335
|
-
...preferences[0],
|
|
336
|
-
force: true,
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
this.#tooltip.style.setProperty('top', `${anchorResult.pageY}px`);
|
|
341
|
-
this.#tooltip.style.setProperty('left', `${anchorResult.pageX}px`);
|
|
342
|
-
this.#tooltip.style.setProperty('margin', '0');
|
|
343
|
-
this.#tooltip.style.setProperty('transform-origin', `${anchorResult.transformOriginY} ${anchorResult.transformOriginX}`);
|
|
344
|
-
|
|
345
|
-
const hoverStyle = this.refs.tooltip.style;
|
|
346
|
-
hoverStyle.setProperty('width', `${anchorResult.width + (anchorResult.offsetX * 2)}px`);
|
|
347
|
-
hoverStyle.setProperty('height', `${anchorResult.height + (anchorResult.offsetY)}px`);
|
|
348
|
-
if (anchorResult.clientY === 'bottom') {
|
|
349
|
-
hoverStyle.setProperty('top', '100%');
|
|
350
|
-
hoverStyle.removeProperty('bottom');
|
|
351
|
-
} else {
|
|
352
|
-
hoverStyle.removeProperty('top');
|
|
353
|
-
hoverStyle.setProperty('height', `${anchorResult.height + (anchorResult.offsetY)}px`);
|
|
354
|
-
hoverStyle.setProperty('bottom', '100%');
|
|
355
|
-
}
|
|
356
|
-
switch (anchorResult.clientX) {
|
|
357
|
-
case 'left':
|
|
358
|
-
hoverStyle.setProperty('left', '0');
|
|
359
|
-
hoverStyle.removeProperty('right');
|
|
360
|
-
break;
|
|
361
|
-
default:
|
|
362
|
-
case 'center':
|
|
363
|
-
hoverStyle.removeProperty('left');
|
|
364
|
-
hoverStyle.removeProperty('right');
|
|
365
|
-
break;
|
|
366
|
-
case 'right':
|
|
367
|
-
hoverStyle.removeProperty('left');
|
|
368
|
-
hoverStyle.setProperty('right', '0');
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
connectedCallback() {
|
|
373
|
-
super.connectedCallback();
|
|
374
|
-
for (const type of ['click', 'mousedown', 'mousemove', 'mouseout',
|
|
375
|
-
'touchmove', 'touchstart', 'touchend', 'touchleave', 'touchcancel']) {
|
|
376
|
-
this.addEventListener(type, this.onTooltipTriggerPointer, { passive: true });
|
|
377
|
-
}
|
|
378
|
-
this.addEventListener('focus', this.onTooltipTriggerFocus);
|
|
379
|
-
this.addEventListener('blur', this.onTooltipTriggerBlur);
|
|
380
|
-
this.addEventListener('keydown', this.onTooltipTriggerKeydown, { passive: true });
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
disconnectedCallback() {
|
|
384
|
-
// console.log('disconnected');
|
|
385
|
-
this.hideTooltip();
|
|
386
|
-
super.disconnectedCallback();
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
TooltipTrigger.prototype.tooltip = TooltipTrigger.prop('tooltip');
|
|
390
|
-
return TooltipTrigger;
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
disconnected() {
|
|
311
|
+
this.hideTooltip(true);
|
|
312
|
+
},
|
|
313
|
+
tooltipChanged() {
|
|
314
|
+
this.recloneTooltip();
|
|
315
|
+
},
|
|
316
|
+
});
|
|
391
317
|
}
|