@shortfuse/materialdesignweb 0.5.0 → 0.7.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 +155 -77
- package/bin/generate-css.js +12 -0
- package/components/Badge.css +30 -0
- package/components/Badge.js +15 -0
- package/components/Body.css +14 -0
- package/components/Body.js +7 -0
- package/components/BottomAppBar.css +23 -0
- package/components/BottomAppBar.js +25 -0
- package/components/Box.css +31 -0
- package/components/Box.js +24 -0
- package/components/Button.css +146 -0
- package/components/Button.js +95 -0
- package/components/Button.md +61 -0
- package/components/Card.css +109 -0
- package/components/Card.js +82 -0
- package/components/Checkbox.css +77 -0
- package/components/Checkbox.js +59 -0
- package/components/CheckboxIcon.css +89 -0
- package/components/CheckboxIcon.js +41 -0
- package/components/Chip.css +35 -0
- package/components/Chip.js +22 -0
- package/components/Dialog.css +235 -0
- package/components/Dialog.js +327 -0
- package/components/DialogActions.js +13 -0
- package/components/Divider.css +41 -0
- package/components/Divider.js +13 -0
- package/components/ExtendedFab.css +24 -0
- package/components/ExtendedFab.js +11 -0
- package/components/Fab.css +23 -0
- package/components/Fab.js +26 -0
- package/components/FilterChip.css +80 -0
- package/components/FilterChip.js +51 -0
- package/components/Headline.css +14 -0
- package/components/Headline.js +33 -0
- package/components/Icon.css +76 -0
- package/components/Icon.js +174 -0
- package/components/IconButton.css +151 -0
- package/components/IconButton.js +65 -0
- package/components/Input.js +16 -0
- package/components/Label.css +14 -0
- package/components/Label.js +7 -0
- package/components/Layout.css +19 -0
- package/components/Layout.js +12 -0
- package/components/List.css +12 -0
- package/components/List.js +17 -0
- package/components/ListItem.css +224 -0
- package/components/ListItem.js +112 -0
- package/components/ListOption.css +34 -0
- package/components/ListOption.js +122 -0
- package/components/ListSelect.css +9 -0
- package/components/ListSelect.js +206 -0
- package/components/Menu.css +171 -0
- package/components/Menu.js +470 -0
- package/components/MenuItem.css +53 -0
- package/components/MenuItem.js +215 -0
- package/components/Nav.css +17 -0
- package/components/Nav.js +23 -0
- package/components/NavBar.css +34 -0
- package/components/NavBar.js +88 -0
- package/components/NavBarItem.css +41 -0
- package/components/NavBarItem.js +7 -0
- package/components/NavDrawer.css +31 -0
- package/components/NavDrawer.js +13 -0
- package/components/NavDrawerItem.css +42 -0
- package/components/NavDrawerItem.js +12 -0
- package/components/NavItem.css +181 -0
- package/components/NavItem.js +83 -0
- package/components/NavRail.css +47 -0
- package/components/NavRail.js +17 -0
- package/components/NavRailItem.css +25 -0
- package/components/NavRailItem.js +7 -0
- package/components/Option.js +91 -0
- package/components/Outline.css +138 -0
- package/components/Pane.css +261 -0
- package/components/Pane.js +21 -0
- package/components/Progress.css +74 -0
- package/components/Progress.js +67 -0
- package/components/ProgressCircle.css +226 -0
- package/components/ProgressLine.css +155 -0
- package/components/Radio.css +83 -0
- package/components/Radio.js +42 -0
- package/components/RadioIcon.css +73 -0
- package/components/RadioIcon.js +37 -0
- package/components/Ripple.css +74 -0
- package/components/Ripple.js +114 -0
- package/components/SegmentedButton.css +94 -0
- package/components/SegmentedButton.js +49 -0
- package/components/SegmentedButtonGroup.css +12 -0
- package/components/SegmentedButtonGroup.js +44 -0
- package/components/Select.css +52 -0
- package/components/Select.js +71 -0
- package/components/Shape.css +132 -0
- package/components/Shape.js +25 -0
- package/components/Slider.css +306 -0
- package/components/Slider.js +206 -0
- package/components/Snackbar.css +80 -0
- package/components/Snackbar.js +75 -0
- package/components/Surface.css +10 -0
- package/components/Surface.js +23 -0
- package/components/Switch.css +63 -0
- package/components/Switch.js +127 -0
- package/components/SwitchIcon.css +177 -0
- package/components/SwitchIcon.js +89 -0
- package/components/SwitchIconAnimations.css +89 -0
- package/components/Tab.css +85 -0
- package/components/Tab.js +103 -0
- package/components/TabContent.js +151 -0
- package/components/TabList.css +129 -0
- package/components/TabList.js +309 -0
- package/components/TabPanel.js +37 -0
- package/components/TextArea.css +93 -0
- package/components/TextArea.js +229 -0
- package/components/Title.css +14 -0
- package/components/Title.js +15 -0
- package/components/Tooltip.css +40 -0
- package/components/Tooltip.js +22 -0
- package/components/TopAppBar.css +209 -0
- package/components/TopAppBar.js +201 -0
- package/core/Composition.js +988 -0
- package/core/CustomElement.js +844 -0
- package/core/ICustomElement.d.ts +288 -0
- package/core/ICustomElement.js +1 -0
- package/core/css.js +51 -0
- package/core/customTypes.js +125 -0
- package/core/dom.js +56 -154
- package/core/identify.js +40 -0
- package/core/observe.js +410 -0
- package/core/template.js +121 -0
- package/core/typings.d.ts +135 -0
- package/core/typings.js +1 -0
- package/mixins/AriaReflectorMixin.js +42 -0
- package/mixins/AriaToolbarMixin.js +13 -0
- package/mixins/ControlMixin.css +57 -0
- package/mixins/ControlMixin.js +212 -0
- package/mixins/DensityMixin.css +40 -0
- package/mixins/DensityMixin.js +11 -0
- package/mixins/FlexableMixin.css +79 -0
- package/mixins/FlexableMixin.js +32 -0
- package/mixins/FormAssociatedMixin.js +170 -0
- package/mixins/InputMixin.js +335 -0
- package/mixins/KeyboardNavMixin.js +244 -0
- package/mixins/RTLObserverMixin.js +35 -0
- package/mixins/ResizeObserverMixin.js +38 -0
- package/mixins/RippleMixin.css +12 -0
- package/mixins/RippleMixin.js +115 -0
- package/mixins/ScrollListenerMixin.js +100 -0
- package/mixins/ShapeMixin.css +135 -0
- package/mixins/ShapeMixin.js +31 -0
- package/mixins/StateMixin.css +82 -0
- package/mixins/StateMixin.js +114 -0
- package/mixins/SurfaceMixin.css +150 -0
- package/mixins/SurfaceMixin.js +32 -0
- package/mixins/TextFieldMixin.css +657 -0
- package/mixins/TextFieldMixin.js +121 -0
- package/mixins/ThemableMixin.css +204 -0
- package/mixins/ThemableMixin.js +16 -0
- package/mixins/TooltipTriggerMixin.css +27 -0
- package/mixins/TooltipTriggerMixin.js +366 -0
- package/mixins/TouchTargetMixin.css +26 -0
- package/mixins/TouchTargetMixin.js +9 -0
- package/package.json +54 -49
- package/theming/index.js +594 -0
- package/theming/loader.js +24 -0
- package/utils/cli.js +11 -0
- package/utils/color_keywords.js +151 -0
- package/utils/hct/Cam16.js +298 -0
- package/utils/hct/CorePalette.js +84 -0
- package/utils/hct/Hct.js +172 -0
- package/utils/hct/Scheme.js +587 -0
- package/utils/hct/TonalPalette.js +68 -0
- package/utils/hct/ViewingConditions.js +136 -0
- package/utils/hct/blend.js +93 -0
- package/utils/hct/colorUtils.js +302 -0
- package/utils/hct/hctSolver.js +559 -0
- package/utils/hct/helper.js +182 -0
- package/utils/hct/mathUtils.js +153 -0
- package/utils/jsonMergePatch.js +100 -0
- package/utils/jsx-runtime.js +101 -0
- package/utils/popup.js +117 -0
- package/utils/svg.js +129 -0
- package/.browserslistrc +0 -4
- package/.eslintrc.json +0 -204
- package/.stylelintrc.json +0 -645
- package/.vscode/launch.json +0 -31
- package/.vscode/settings.json +0 -3
- package/.vscode/tasks.json +0 -32
- package/CHANGELOG.md +0 -36
- package/CODE_OF_CONDUCT.md +0 -46
- package/adapters/datatable/column.js +0 -176
- package/adapters/datatable/index.js +0 -960
- package/adapters/dom/index.js +0 -586
- package/adapters/list/index.js +0 -69
- package/adapters/search/index.js +0 -495
- package/components/appbar/_spec.scss +0 -165
- package/components/appbar/_theme.scss +0 -0
- package/components/appbar/index.scss +0 -2
- package/components/banner/_spec.scss +0 -83
- package/components/banner/_theme.scss +0 -0
- package/components/banner/index.scss +0 -2
- package/components/bottomnav/README.md +0 -85
- package/components/bottomnav/_spec.scss +0 -149
- package/components/bottomnav/_theme.scss +0 -0
- package/components/bottomnav/index.js +0 -117
- package/components/bottomnav/index.scss +0 -2
- package/components/bottomnav/item.js +0 -88
- package/components/button/README.md +0 -61
- package/components/button/_spec.scss +0 -162
- package/components/button/_theme.scss +0 -42
- package/components/button/index.eta +0 -32
- package/components/button/index.js +0 -43
- package/components/button/index.pug +0 -18
- package/components/button/index.scss +0 -2
- package/components/card/_spec.scss +0 -241
- package/components/card/_theme.scss +0 -0
- package/components/card/index.scss +0 -2
- package/components/chip/_spec.scss +0 -111
- package/components/chip/_theme.scss +0 -105
- package/components/chip/index.js +0 -23
- package/components/chip/index.scss +0 -2
- package/components/chip/item.js +0 -20
- package/components/datatable/_spec.scss +0 -225
- package/components/datatable/_theme.scss +0 -128
- package/components/datatable/cell.js +0 -44
- package/components/datatable/columnheader.js +0 -46
- package/components/datatable/index.js +0 -374
- package/components/datatable/index.scss +0 -2
- package/components/datatable/row.js +0 -48
- package/components/datatable/rowheader.js +0 -18
- package/components/dialog/_spec.scss +0 -203
- package/components/dialog/_theme.scss +0 -7
- package/components/dialog/index.js +0 -601
- package/components/dialog/index.scss +0 -2
- package/components/divider/_spec.scss +0 -11
- package/components/divider/_theme.scss +0 -0
- package/components/divider/index.scss +0 -2
- package/components/elevation/_spec.scss +0 -9
- package/components/elevation/_theme.scss +0 -0
- package/components/elevation/index.scss +0 -2
- package/components/fab/_spec.scss +0 -210
- package/components/fab/_theme.scss +0 -0
- package/components/fab/index.js +0 -99
- package/components/fab/index.scss +0 -2
- package/components/grid/_spec.scss +0 -169
- package/components/grid/_theme.scss +0 -0
- package/components/grid/index.scss +0 -2
- package/components/layout/_mixins.scss +0 -11
- package/components/layout/_spec.scss +0 -916
- package/components/layout/_theme.scss +0 -19
- package/components/layout/index.js +0 -454
- package/components/layout/index.scss +0 -2
- package/components/list/_spec.scss +0 -363
- package/components/list/_theme.scss +0 -102
- package/components/list/content.js +0 -106
- package/components/list/index.js +0 -256
- package/components/list/index.scss +0 -2
- package/components/list/item.js +0 -167
- package/components/list/secondary.js +0 -45
- package/components/menu/_spec.scss +0 -329
- package/components/menu/_theme.scss +0 -0
- package/components/menu/index.js +0 -705
- package/components/menu/index.scss +0 -2
- package/components/menu/item.js +0 -231
- package/components/progress/_spec.scss +0 -156
- package/components/progress/_theme.scss +0 -0
- package/components/progress/index.js +0 -36
- package/components/progress/index.scss +0 -2
- package/components/selection/_spec.scss +0 -376
- package/components/selection/_theme.scss +0 -134
- package/components/selection/index.eta +0 -60
- package/components/selection/index.js +0 -70
- package/components/selection/index.pug +0 -30
- package/components/selection/index.scss +0 -2
- package/components/selection/input.js +0 -54
- package/components/selection/radiogroup.js +0 -40
- package/components/slider/_spec.scss +0 -59
- package/components/slider/_theme.scss +0 -0
- package/components/slider/index.scss +0 -2
- package/components/snackbar/_spec.scss +0 -150
- package/components/snackbar/_theme.scss +0 -0
- package/components/snackbar/index.js +0 -338
- package/components/snackbar/index.scss +0 -2
- package/components/tab/_spec.scss +0 -220
- package/components/tab/_theme.scss +0 -0
- package/components/tab/content.js +0 -210
- package/components/tab/index.js +0 -257
- package/components/tab/index.scss +0 -2
- package/components/tab/item.js +0 -88
- package/components/tab/list.js +0 -196
- package/components/tab/panel.js +0 -54
- package/components/textfield/README.md +0 -179
- package/components/textfield/_spec.scss +0 -763
- package/components/textfield/_theme.scss +0 -264
- package/components/textfield/index.eta +0 -74
- package/components/textfield/index.js +0 -160
- package/components/textfield/index.pug +0 -30
- package/components/textfield/index.scss +0 -2
- package/components/tooltip/_spec.scss +0 -185
- package/components/tooltip/_theme.scss +0 -0
- package/components/tooltip/index.scss +0 -2
- package/components/type/_spec.scss +0 -227
- package/components/type/_theme.scss +0 -0
- package/components/type/index.scss +0 -2
- package/core/_breakpoint.scss +0 -189
- package/core/_elevation.scss +0 -78
- package/core/_length.scss +0 -8
- package/core/_motion.scss +0 -31
- package/core/_platform.scss +0 -12
- package/core/_type.scss +0 -128
- package/core/aria/attributes.js +0 -141
- package/core/aria/button.js +0 -49
- package/core/aria/keyboard.js +0 -92
- package/core/aria/rovingtabindex.js +0 -175
- package/core/aria/tab.js +0 -59
- package/core/document/index.js +0 -39
- package/core/overlay/_spec.scss +0 -28
- package/core/overlay/_theme.scss +0 -147
- package/core/overlay/index.js +0 -95
- package/core/overlay/index.scss +0 -2
- package/core/ripple/_spec.scss +0 -196
- package/core/ripple/_theme.scss +0 -20
- package/core/ripple/index.js +0 -286
- package/core/ripple/index.scss +0 -2
- package/core/theme/_aliases.scss +0 -15
- package/core/theme/_config.scss +0 -8
- package/core/theme/_functions.scss +0 -22
- package/core/theme/_palettes.scss +0 -405
- package/core/theme/_spec.scss +0 -0
- package/core/theme/_theme.scss +0 -268
- package/core/theme/index.js +0 -50
- package/core/theme/index.scss +0 -4
- package/core/throttler.js +0 -42
- package/core/transition/index.js +0 -465
- package/docs/_flex.scss +0 -28
- package/docs/_menuoptions.js +0 -183
- package/docs/_partials/_androidnavbar.eta +0 -5
- package/docs/_partials/_androidstatusbar.eta +0 -13
- package/docs/_partials/_appbar.eta +0 -27
- package/docs/_partials/_buttontest.eta +0 -31
- package/docs/_partials/_header.eta +0 -146
- package/docs/_partials/_navlistitem.eta +0 -16
- package/docs/_partials/_target.eta +0 -1
- package/docs/_sample-utils.js +0 -88
- package/docs/_storage.js +0 -33
- package/docs/docs.scss +0 -331
- package/docs/framework.scss +0 -26
- package/docs/index.eta +0 -12
- package/docs/index.js +0 -7
- package/docs/pages/appbar.eta +0 -108
- package/docs/pages/appbar.js +0 -0
- package/docs/pages/bottomnav.eta +0 -188
- package/docs/pages/bottomnav.js +0 -118
- package/docs/pages/button.eta +0 -124
- package/docs/pages/button.js +0 -224
- package/docs/pages/card.eta +0 -90
- package/docs/pages/card.js +0 -175
- package/docs/pages/chip.eta +0 -122
- package/docs/pages/chip.js +0 -80
- package/docs/pages/color.eta +0 -143
- package/docs/pages/color.js +0 -261
- package/docs/pages/datatable.eta +0 -323
- package/docs/pages/datatable.js +0 -160
- package/docs/pages/dialog.eta +0 -184
- package/docs/pages/dialog.js +0 -174
- package/docs/pages/dom.eta +0 -26
- package/docs/pages/dom.js +0 -140
- package/docs/pages/elevation.eta +0 -35
- package/docs/pages/elevation.js +0 -0
- package/docs/pages/fab.eta +0 -99
- package/docs/pages/fab.js +0 -43
- package/docs/pages/grid.eta +0 -135
- package/docs/pages/grid.js +0 -128
- package/docs/pages/layout.eta +0 -8
- package/docs/pages/layout.js +0 -0
- package/docs/pages/list.eta +0 -465
- package/docs/pages/list.js +0 -8
- package/docs/pages/menu.eta +0 -274
- package/docs/pages/menu.js +0 -213
- package/docs/pages/overlay.eta +0 -69
- package/docs/pages/overlay.js +0 -3
- package/docs/pages/progress.eta +0 -23
- package/docs/pages/progress.js +0 -12
- package/docs/pages/ripple.eta +0 -27
- package/docs/pages/ripple.js +0 -3
- package/docs/pages/search.eta +0 -242
- package/docs/pages/search.js +0 -226
- package/docs/pages/selection.eta +0 -107
- package/docs/pages/selection.js +0 -12
- package/docs/pages/slider.eta +0 -23
- package/docs/pages/slider.js +0 -0
- package/docs/pages/snackbar.eta +0 -83
- package/docs/pages/snackbar.js +0 -157
- package/docs/pages/tab.eta +0 -407
- package/docs/pages/tab.js +0 -152
- package/docs/pages/textfield.eta +0 -487
- package/docs/pages/textfield.js +0 -257
- package/docs/pages/tooltip.eta +0 -92
- package/docs/pages/tooltip.js +0 -0
- package/docs/pages/transition.eta +0 -117
- package/docs/pages/transition.js +0 -52
- package/docs/pages/type.eta +0 -31
- package/docs/pages/type.js +0 -0
- package/docs/postrender.js +0 -41
- package/docs/prerender.js +0 -16
- package/docs/pwa/_dialogs.eta +0 -143
- package/docs/pwa/_menus.eta +0 -16
- package/docs/pwa/pwa-prerender.js +0 -3
- package/docs/pwa/pwa.eta +0 -478
- package/docs/pwa/pwa.js +0 -298
- package/docs/pwa/pwa.scss +0 -31
- package/docs/themes/theme-colored.scss +0 -15
- package/docs/themes/theme-default.scss +0 -3
- package/index.scss +0 -27
- package/jsconfig.json +0 -16
- package/scripts/deploy-docs.sh +0 -9
- package/templates/index.eta +0 -2
- package/templates/index.pug +0 -3
- package/tsconfig.json +0 -16
- package/webpack.config.js +0 -304
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import Tooltip from '../components/Tooltip.js';
|
|
2
|
+
import { canAnchorPopup } from '../utils/popup.js';
|
|
3
|
+
|
|
4
|
+
import styles from './TooltipTriggerMixin.css' assert { type: 'css' };
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @param {ReturnType<import('./StateMixin.js').default>} Base
|
|
8
|
+
*/
|
|
9
|
+
export default function TooltipTriggerMixin(Base) {
|
|
10
|
+
class TooltipTrigger extends Base {
|
|
11
|
+
static {
|
|
12
|
+
this.css(styles);
|
|
13
|
+
|
|
14
|
+
this.on({
|
|
15
|
+
composed({ template, html }) {
|
|
16
|
+
template.append(html`
|
|
17
|
+
<${Tooltip.elementName} role=tooltip id=tooltip
|
|
18
|
+
><slot id=tooltip-slot
|
|
19
|
+
on-slotchange={onTooltipTriggerSlotChange} name=tooltip
|
|
20
|
+
>{tooltip}</slot></${Tooltip.elementName}>
|
|
21
|
+
`);
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static TOOLTIP_MOUSE_IDLE_MS = 500;
|
|
27
|
+
|
|
28
|
+
static TOOLTIP_TOUCH_IDLE_MS = 1500;
|
|
29
|
+
|
|
30
|
+
/** @type {InstanceType<Tooltip>} */
|
|
31
|
+
#tooltip;
|
|
32
|
+
|
|
33
|
+
/** @type {any} */
|
|
34
|
+
#idleDebounce;
|
|
35
|
+
|
|
36
|
+
#pendingHide = false;
|
|
37
|
+
|
|
38
|
+
/** @type {HTMLElement[]} */
|
|
39
|
+
#watchedParents = [];
|
|
40
|
+
|
|
41
|
+
#resizeObserver;
|
|
42
|
+
|
|
43
|
+
#intersectObserver;
|
|
44
|
+
|
|
45
|
+
onParentScroll = (event) => {
|
|
46
|
+
this.updateTooltipPosition();
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/** @param {any[]} args */
|
|
50
|
+
constructor(...args) {
|
|
51
|
+
super(...args);
|
|
52
|
+
this.#tooltip = /** @type {InstanceType<Tooltip>} */ (this.refs.tooltip.cloneNode(true));
|
|
53
|
+
this.#tooltip.removeAttribute('id');
|
|
54
|
+
this.#tooltip.style.setProperty('position', 'fixed');
|
|
55
|
+
this.#tooltip.setAttribute('aria-hidden', 'true');
|
|
56
|
+
this.#resizeObserver = new ResizeObserver((entries) => {
|
|
57
|
+
// console.log('RO', entries);
|
|
58
|
+
if (!this.#tooltip.open) return;
|
|
59
|
+
this.updateTooltipPosition();
|
|
60
|
+
});
|
|
61
|
+
const threshold = [0, 0.49, 0.5, 0.51, 1];
|
|
62
|
+
this.#intersectObserver = new IntersectionObserver((entries) => {
|
|
63
|
+
// console.log('IO', entries);
|
|
64
|
+
if (!this.#tooltip.open) return;
|
|
65
|
+
for (const entry of entries) {
|
|
66
|
+
if (entry.intersectionRatio <= 0) {
|
|
67
|
+
console.debug('Hide tooltip due to tooltip occlusion');
|
|
68
|
+
this.hideTooltip();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (entry.target === this.#tooltip) {
|
|
72
|
+
console.debug('Reposition tooltip due to possible tooltip occlusion');
|
|
73
|
+
this.updateTooltipPosition();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (entry.target === this) {
|
|
77
|
+
if (entry.intersectionRatio <= 0.5) {
|
|
78
|
+
console.debug('Hiding tooltip because target is occluded');
|
|
79
|
+
this.hideTooltip();
|
|
80
|
+
} else {
|
|
81
|
+
console.debug('Using InsectionObserver rect to update tooltip');
|
|
82
|
+
this.updateTooltipPosition(entry.boundingClientRect);
|
|
83
|
+
}
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
console.debug('Updating tooltip position because offsetParent change.');
|
|
88
|
+
this.updateTooltipPosition();
|
|
89
|
+
}, { threshold });
|
|
90
|
+
// this.#tooltip.remove();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @param {Event & {currentTarget: HTMLSlotElement}} event
|
|
95
|
+
* @return {void}
|
|
96
|
+
*/
|
|
97
|
+
onTooltipTriggerSlotChange(event) {
|
|
98
|
+
const tooltip = this.tooltipClone;
|
|
99
|
+
tooltip.replaceChildren(
|
|
100
|
+
...event.currentTarget.assignedNodes()
|
|
101
|
+
.map((child) => child.cloneNode(true)),
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @this {TooltipTrigger} this
|
|
107
|
+
* @param {FocusEvent} event
|
|
108
|
+
* @return {void}
|
|
109
|
+
*/
|
|
110
|
+
onTooltipTriggerFocus(event) {
|
|
111
|
+
// console.log('getting focus', event);
|
|
112
|
+
if (this.disabledState) return;
|
|
113
|
+
if (this.matches(':active')) {
|
|
114
|
+
// console.log('abort from active');
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
this.showTooltip();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @this {TooltipTrigger} this
|
|
122
|
+
* @param {KeyboardEvent} event
|
|
123
|
+
* @return {void}
|
|
124
|
+
*/
|
|
125
|
+
onTooltipTriggerKeydown(event) {
|
|
126
|
+
if (event.ctrlKey) this.hideTooltip();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @this {TooltipTrigger} this
|
|
131
|
+
* @return {void}
|
|
132
|
+
*/
|
|
133
|
+
onTooltipTriggerBlur() {
|
|
134
|
+
this.hideTooltip();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @param {MouseEvent|TouchEvent} event
|
|
139
|
+
* @this {TooltipTrigger} this
|
|
140
|
+
* @return {void}
|
|
141
|
+
*/
|
|
142
|
+
onTooltipTriggerPointer(event) {
|
|
143
|
+
if (this.disabledState) return;
|
|
144
|
+
// console.log('tooltip event', event.type);
|
|
145
|
+
switch (event.type) {
|
|
146
|
+
case 'touchstart':
|
|
147
|
+
this.scheduleShowTooltip('touch');
|
|
148
|
+
break;
|
|
149
|
+
case 'touchend':
|
|
150
|
+
case 'touchcancel':
|
|
151
|
+
this.scheduleHideTooltip('touch');
|
|
152
|
+
break;
|
|
153
|
+
case 'click':
|
|
154
|
+
case 'mouseout':
|
|
155
|
+
this.cancelShowTooltip();
|
|
156
|
+
this.hideTooltip();
|
|
157
|
+
break;
|
|
158
|
+
case 'mousemove':
|
|
159
|
+
case 'mouseover':
|
|
160
|
+
this.scheduleShowTooltip('mouse');
|
|
161
|
+
break;
|
|
162
|
+
default:
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
get tooltipClone() {
|
|
167
|
+
return this.#tooltip;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
get clonedTooltip() {
|
|
171
|
+
return this.#tooltip;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
cancelShowTooltip() {
|
|
175
|
+
// console.log('cancel tooltiptimer');
|
|
176
|
+
clearTimeout(this.#idleDebounce);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** @param {'mouse'|'touch'|'keyboard'} type */
|
|
180
|
+
scheduleHideTooltip(type) {
|
|
181
|
+
clearTimeout(this.#idleDebounce);
|
|
182
|
+
if (!this.#tooltip.open) {
|
|
183
|
+
// console.log('abort schedule (shown)');
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
let timeout = 0;
|
|
187
|
+
switch (type) {
|
|
188
|
+
case 'mouse':
|
|
189
|
+
timeout = 0;
|
|
190
|
+
break;
|
|
191
|
+
case 'touch':
|
|
192
|
+
timeout = 1500;
|
|
193
|
+
break;
|
|
194
|
+
default:
|
|
195
|
+
}
|
|
196
|
+
// console.log('schedule tooltiptimer');
|
|
197
|
+
this.#idleDebounce = setTimeout(() => {
|
|
198
|
+
// console.log('hide timeout');
|
|
199
|
+
this.hideTooltip();
|
|
200
|
+
}, timeout);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** @param {'mouse'|'touch'|'keyboard'} type */
|
|
204
|
+
scheduleShowTooltip(type) {
|
|
205
|
+
if (this.#tooltip.open) {
|
|
206
|
+
// console.log('abort schedule (shown)');
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
let timeout = 0;
|
|
210
|
+
switch (type) {
|
|
211
|
+
case 'mouse':
|
|
212
|
+
timeout = this.constructor.TOOLTIP_MOUSE_IDLE_MS;
|
|
213
|
+
break;
|
|
214
|
+
case 'touch':
|
|
215
|
+
timeout = this.constructor.TOOLTIP_TOUCH_IDLE_MS;
|
|
216
|
+
break;
|
|
217
|
+
default:
|
|
218
|
+
}
|
|
219
|
+
// console.log('schedule tooltiptimer');
|
|
220
|
+
clearTimeout(this.#idleDebounce);
|
|
221
|
+
this.#idleDebounce = setTimeout(() => {
|
|
222
|
+
// console.log('idle');
|
|
223
|
+
this.showTooltip(type === 'touch');
|
|
224
|
+
}, timeout);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
showTooltip(touch = false) {
|
|
228
|
+
if (this.#tooltip.open) return;
|
|
229
|
+
this.refs.tooltip.open = true;
|
|
230
|
+
this.refs.tooltip.touch = touch;
|
|
231
|
+
this.#tooltip.touch = touch;
|
|
232
|
+
document.body.append(this.#tooltip);
|
|
233
|
+
this.updateTooltipPosition();
|
|
234
|
+
this.#resizeObserver.observe(this, { box: 'border-box' });
|
|
235
|
+
this.#intersectObserver.observe(this);
|
|
236
|
+
this.#intersectObserver.observe(this.#tooltip);
|
|
237
|
+
/** @type {HTMLElement} */
|
|
238
|
+
let offsetParent = this;
|
|
239
|
+
while ((offsetParent = offsetParent.offsetParent)) {
|
|
240
|
+
this.#resizeObserver.observe(offsetParent, { box: 'border-box' });
|
|
241
|
+
// console.log('observing', offsetParent);
|
|
242
|
+
this.#watchedParents.push(offsetParent);
|
|
243
|
+
this.#intersectObserver.observe(offsetParent);
|
|
244
|
+
offsetParent.addEventListener('scroll', this.onParentScroll);
|
|
245
|
+
}
|
|
246
|
+
window.addEventListener('scroll', this.onParentScroll);
|
|
247
|
+
|
|
248
|
+
// console.log('offsetparent', this.offsetParent);
|
|
249
|
+
|
|
250
|
+
this.#tooltip.open = true;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
hideTooltip() {
|
|
254
|
+
this.#resizeObserver.disconnect();
|
|
255
|
+
this.#intersectObserver.disconnect();
|
|
256
|
+
let parent;
|
|
257
|
+
while ((parent = this.#watchedParents.pop())) {
|
|
258
|
+
parent.removeEventListener('scroll', this.onParentScroll);
|
|
259
|
+
}
|
|
260
|
+
window.removeEventListener('scroll', this.onParentScroll);
|
|
261
|
+
this.#tooltip.open = false;
|
|
262
|
+
this.#tooltip.remove();
|
|
263
|
+
this.refs.tooltip.open = false;
|
|
264
|
+
const hoverStyle = this.refs.tooltip.style;
|
|
265
|
+
hoverStyle.removeProperty('width');
|
|
266
|
+
hoverStyle.removeProperty('height');
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* @param {DOMRect} [domRect]
|
|
271
|
+
* @return {void}
|
|
272
|
+
*/
|
|
273
|
+
updateTooltipPosition(domRect) {
|
|
274
|
+
const offset = 8;
|
|
275
|
+
// const margin = 8;
|
|
276
|
+
/** @type {import('../utils/popup.js').CanAnchorPopUpOptions} */
|
|
277
|
+
const anchorOptions = {
|
|
278
|
+
anchor: domRect ?? this.getBoundingClientRect(),
|
|
279
|
+
width: this.#tooltip.clientWidth,
|
|
280
|
+
height: this.#tooltip.clientHeight,
|
|
281
|
+
// margin,
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
const isPageRTL = (getComputedStyle(this).direction === 'rtl');
|
|
285
|
+
const xStart = isPageRTL ? 'right' : 'left';
|
|
286
|
+
const xEnd = isPageRTL ? 'left' : 'right';
|
|
287
|
+
/** @type {import('../utils/popup.js').CanAnchorPopUpOptions[]} */
|
|
288
|
+
const preferences = [
|
|
289
|
+
{ clientY: 'bottom', clientX: 'center', offsetY: offset },
|
|
290
|
+
{ clientY: 'bottom', clientX: xStart, offsetY: offset },
|
|
291
|
+
{ clientY: 'bottom', clientX: xEnd, offsetY: offset },
|
|
292
|
+
{ clientY: 'top', clientX: 'center', offsetY: -offset },
|
|
293
|
+
{ clientY: 'top', clientX: xStart, offsetY: -offset },
|
|
294
|
+
{ clientY: 'top', clientX: xEnd, offsetY: -offset },
|
|
295
|
+
];
|
|
296
|
+
|
|
297
|
+
let anchorResult;
|
|
298
|
+
for (const preference of preferences) {
|
|
299
|
+
anchorResult = canAnchorPopup({
|
|
300
|
+
...anchorOptions,
|
|
301
|
+
...preference,
|
|
302
|
+
});
|
|
303
|
+
if (anchorResult) break;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// console.log({ anchorResult });
|
|
307
|
+
if (!anchorResult) {
|
|
308
|
+
anchorResult = canAnchorPopup({
|
|
309
|
+
...anchorOptions,
|
|
310
|
+
...preferences[0],
|
|
311
|
+
force: true,
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
this.#tooltip.style.setProperty('top', `${anchorResult.pageY}px`);
|
|
316
|
+
this.#tooltip.style.setProperty('left', `${anchorResult.pageX}px`);
|
|
317
|
+
this.#tooltip.style.setProperty('margin', '0');
|
|
318
|
+
this.#tooltip.style.setProperty('transform-origin', `${anchorResult.transformOriginY} ${anchorResult.transformOriginX}`);
|
|
319
|
+
|
|
320
|
+
const hoverStyle = this.refs.tooltip.style;
|
|
321
|
+
hoverStyle.setProperty('width', `${anchorResult.width + (anchorResult.offsetX * 2)}px`);
|
|
322
|
+
hoverStyle.setProperty('height', `${anchorResult.height + (anchorResult.offsetY)}px`);
|
|
323
|
+
if (anchorResult.clientY === 'bottom') {
|
|
324
|
+
hoverStyle.setProperty('top', '100%');
|
|
325
|
+
hoverStyle.removeProperty('bottom');
|
|
326
|
+
} else {
|
|
327
|
+
hoverStyle.removeProperty('top');
|
|
328
|
+
hoverStyle.setProperty('height', `${anchorResult.height + (anchorResult.offsetY)}px`);
|
|
329
|
+
hoverStyle.setProperty('bottom', '100%');
|
|
330
|
+
}
|
|
331
|
+
switch (anchorResult.clientX) {
|
|
332
|
+
case 'left':
|
|
333
|
+
hoverStyle.setProperty('left', '0');
|
|
334
|
+
hoverStyle.removeProperty('right');
|
|
335
|
+
break;
|
|
336
|
+
default:
|
|
337
|
+
case 'center':
|
|
338
|
+
hoverStyle.removeProperty('left');
|
|
339
|
+
hoverStyle.removeProperty('right');
|
|
340
|
+
break;
|
|
341
|
+
case 'right':
|
|
342
|
+
hoverStyle.removeProperty('left');
|
|
343
|
+
hoverStyle.setProperty('right', '0');
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
connectedCallback() {
|
|
348
|
+
super.connectedCallback();
|
|
349
|
+
for (const type of ['click', 'mousedown', 'mousemove', 'mouseout',
|
|
350
|
+
'touchmove', 'touchstart', 'touchend', 'touchleave', 'touchcancel']) {
|
|
351
|
+
this.addEventListener(type, this.onTooltipTriggerPointer, { passive: true });
|
|
352
|
+
}
|
|
353
|
+
this.addEventListener('focus', this.onTooltipTriggerFocus);
|
|
354
|
+
this.addEventListener('blur', this.onTooltipTriggerBlur);
|
|
355
|
+
this.addEventListener('keydown', this.onTooltipTriggerKeydown, { passive: true });
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
disconnectedCallback() {
|
|
359
|
+
// console.log('disconnected');
|
|
360
|
+
this.hideTooltip();
|
|
361
|
+
super.disconnectedCallback();
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
TooltipTrigger.prototype.tooltip = TooltipTrigger.prop('tooltip');
|
|
365
|
+
return TooltipTrigger;
|
|
366
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.touch-target {
|
|
2
|
+
position: absolute;
|
|
3
|
+
inset: 50%;
|
|
4
|
+
/* --mdw-device-pixel-ratio: 1; */
|
|
5
|
+
|
|
6
|
+
block-size: 100%;
|
|
7
|
+
min-block-size: 48px;
|
|
8
|
+
/* min-block-size: 10mm; */
|
|
9
|
+
/* min-block-size: calc(0.393701in / var(--mdw-device-pixel-ratio, 1)); */
|
|
10
|
+
inline-size:100%;
|
|
11
|
+
min-inline-size: 48px;
|
|
12
|
+
/* min-inline-size: 10mm; */
|
|
13
|
+
/* min-inline-size: calc(0.393701in / var(--mdw-device-pixel-ratio, 1)); */
|
|
14
|
+
|
|
15
|
+
cursor: inherit;
|
|
16
|
+
|
|
17
|
+
/* box-sizing: border-box; */
|
|
18
|
+
/* border: solid 1px magenta; */
|
|
19
|
+
pointer-events: auto;
|
|
20
|
+
|
|
21
|
+
transform: translateX(-50%) translateY(-50%);
|
|
22
|
+
visibility: visible;
|
|
23
|
+
z-index: 1;
|
|
24
|
+
|
|
25
|
+
border-radius: inherit;
|
|
26
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import styles from './TouchTargetMixin.css' assert { type: 'css' };
|
|
2
|
+
|
|
3
|
+
/** @param {typeof import('../core/CustomElement.js').default} Base */
|
|
4
|
+
export default function TouchTargetMixin(Base) {
|
|
5
|
+
return Base
|
|
6
|
+
.extend()
|
|
7
|
+
.css(styles)
|
|
8
|
+
.html/* html */`<div id=touch-target class=touch-target></div>`;
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shortfuse/materialdesignweb",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Material Design for Web",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
+
"prebuild": "node bin/generate-css.js --custom=yellow,orange:orange,green:0f0,alias:aqua | npx esbuild --minify --loader=css > docs/theme.css",
|
|
8
|
+
"prebuild-alt": "node bin/generate-css.js --color=a46750 --custom=yellow,orange:orange,green:0f0,alias:aqua | npx esbuild --minify --loader=css > docs/alt-theme.css",
|
|
9
|
+
"build": "node build/esbuild.js --minify --metafile",
|
|
10
|
+
"watch": "node build/esbuild.js --watch --metafile",
|
|
11
|
+
"serve": "node build/esbuild.js --watch --metafile --serve --live",
|
|
12
|
+
"pretest": "eslint --ignore-path .gitignore",
|
|
13
|
+
"test": "c8 tap --no-coverage"
|
|
15
14
|
},
|
|
16
15
|
"repository": {
|
|
17
16
|
"type": "git",
|
|
@@ -20,58 +19,64 @@
|
|
|
20
19
|
"keywords": [
|
|
21
20
|
"material",
|
|
22
21
|
"design",
|
|
23
|
-
"web"
|
|
22
|
+
"web",
|
|
23
|
+
"materialyou",
|
|
24
|
+
"md3",
|
|
25
|
+
"web-components"
|
|
26
|
+
],
|
|
27
|
+
"files": [
|
|
28
|
+
"/bin",
|
|
29
|
+
"/components",
|
|
30
|
+
"/core",
|
|
31
|
+
"/theming",
|
|
32
|
+
"/mixins",
|
|
33
|
+
"/utils"
|
|
24
34
|
],
|
|
25
35
|
"exports": {
|
|
26
|
-
"
|
|
36
|
+
"/components": "./components",
|
|
37
|
+
"/core": "./core",
|
|
38
|
+
"/theming": "./theming",
|
|
39
|
+
"/mixins": "./mixins",
|
|
40
|
+
"/utils": "./utils"
|
|
27
41
|
},
|
|
28
42
|
"author": "Carlos Lopez Jr. <clshortfuse@gmail.com> (https://shortfuse.org/)",
|
|
29
43
|
"license": "ISC",
|
|
30
|
-
"sideEffects":
|
|
44
|
+
"sideEffects": [
|
|
45
|
+
"./polyfills.js",
|
|
46
|
+
"./components/*.js",
|
|
47
|
+
"./utils/metadata.js",
|
|
48
|
+
"./theming/loader.js",
|
|
49
|
+
"./docs/demo/*.js"
|
|
50
|
+
],
|
|
31
51
|
"bugs": {
|
|
32
52
|
"url": "https://github.com/clshortfuse/materialdesignweb/issues"
|
|
33
53
|
},
|
|
34
54
|
"homepage": "https://github.com/clshortfuse/materialdesignweb#readme",
|
|
35
55
|
"devDependencies": {
|
|
36
|
-
"@
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"clean-css": "^5.2.2",
|
|
45
|
-
"css-loader": "^6.5.1",
|
|
46
|
-
"cssnano": "^5.0.14",
|
|
47
|
-
"eslint": "^8.8.0",
|
|
56
|
+
"@types/tap": "^15.0.7",
|
|
57
|
+
"@typescript-eslint/eslint-plugin": "^5.30.7",
|
|
58
|
+
"@typescript-eslint/parser": "^5.30.7",
|
|
59
|
+
"browserslist-to-esbuild": "^1.1.1",
|
|
60
|
+
"c8": "^7.12.0",
|
|
61
|
+
"element-internals-polyfill": "^1.1.11",
|
|
62
|
+
"esbuild": "^0.17.12",
|
|
63
|
+
"eslint": "^8.24.0",
|
|
48
64
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
49
65
|
"eslint-plugin-compat": "^4.0.2",
|
|
50
|
-
"eslint-plugin-eta": "github:clshortfuse/eslint-plugin-eta",
|
|
51
66
|
"eslint-plugin-github": "^4.3.5",
|
|
52
|
-
"eslint-plugin-import": "^2.
|
|
53
|
-
"eslint-plugin-jsdoc": "^
|
|
54
|
-
"eslint-plugin-
|
|
55
|
-
"eslint-plugin-unicorn": "^
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"stylelint-config-sass-guidelines": "^9.0.1",
|
|
67
|
-
"stylelint-no-unsupported-browser-features": "github:clshortfuse/stylelint-no-unsupported-browser-features",
|
|
68
|
-
"stylelint-scss": "^4.2.0",
|
|
69
|
-
"stylelint-use-logical-spec": "^3.2.2",
|
|
70
|
-
"terser-webpack-plugin": "^5.3.1",
|
|
71
|
-
"typescript": "^4.5.4",
|
|
72
|
-
"webpack": "^5.72.1",
|
|
73
|
-
"webpack-bundle-analyzer": "^4.1.0",
|
|
74
|
-
"webpack-cli": "^4.2.0",
|
|
75
|
-
"webpack-dev-server": "^4.7.0"
|
|
67
|
+
"eslint-plugin-import": "^2.27.5",
|
|
68
|
+
"eslint-plugin-jsdoc": "^40.0.3",
|
|
69
|
+
"eslint-plugin-sort-class-members": "^1.15.2",
|
|
70
|
+
"eslint-plugin-unicorn": "^46.0.0",
|
|
71
|
+
"http-server": "^14.1.1",
|
|
72
|
+
"postcss-styled": "^0.34.0",
|
|
73
|
+
"postcss-styled-syntax": "^0.4.0",
|
|
74
|
+
"stylelint": "^15.2.0",
|
|
75
|
+
"stylelint-no-unsupported-browser-features": "github:clshortfuse/stylelint-no-unsupported-browser-features#0a51157",
|
|
76
|
+
"stylelint-order": "^6.0.2",
|
|
77
|
+
"stylelint-use-logical-spec": "^5.0.0",
|
|
78
|
+
"tap": "^16.3.0",
|
|
79
|
+
"typescript": "^5.0.2",
|
|
80
|
+
"webdriverio": "^7.23.0"
|
|
76
81
|
}
|
|
77
82
|
}
|