@shortfuse/materialdesignweb 0.3.0 → 0.4.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/.eslintrc.json +136 -30
- package/.stylelintrc.json +6 -40
- package/.vscode/launch.json +20 -5
- package/CHANGELOG.md +24 -0
- package/README.md +12 -9
- package/adapters/datatable/column.js +82 -74
- package/adapters/datatable/index.js +173 -131
- package/adapters/dom/index.js +529 -75
- package/adapters/list/index.js +25 -12
- package/adapters/search/index.js +13 -13
- package/components/appbar/_spec.scss +87 -64
- package/components/appbar/index.scss +2 -2
- package/components/banner/_spec.scss +8 -8
- package/components/banner/index.scss +2 -2
- package/components/bottomnav/_spec.scss +22 -17
- package/components/bottomnav/index.js +61 -52
- package/components/bottomnav/index.scss +2 -2
- package/components/bottomnav/item.js +44 -25
- package/components/button/README.md +14 -14
- package/components/button/_spec.scss +23 -22
- package/components/button/_theme.scss +37 -21
- package/components/button/index.eta +32 -0
- package/components/button/index.js +12 -12
- package/components/button/index.scss +2 -2
- package/components/card/_spec.scss +40 -36
- package/components/card/index.scss +2 -2
- package/components/chip/_spec.scss +7 -8
- package/components/chip/_theme.scss +31 -31
- package/components/chip/index.js +3 -2
- package/components/chip/index.scss +2 -2
- package/components/chip/item.js +1 -16
- package/components/datatable/_spec.scss +71 -85
- package/components/datatable/_theme.scss +61 -156
- package/components/datatable/cell.js +45 -0
- package/components/datatable/columnheader.js +47 -0
- package/components/datatable/index.js +279 -366
- package/components/datatable/index.scss +2 -2
- package/components/datatable/row.js +49 -0
- package/components/datatable/rowheader.js +18 -0
- package/components/dialog/_spec.scss +61 -41
- package/components/dialog/index.js +325 -297
- package/components/dialog/index.scss +2 -2
- package/components/divider/_spec.scss +8 -6
- package/components/divider/index.scss +2 -2
- package/components/elevation/_spec.scss +2 -2
- package/components/elevation/index.scss +2 -2
- package/components/fab/_spec.scss +23 -24
- package/components/fab/index.js +50 -50
- package/components/fab/index.scss +2 -2
- package/components/grid/_spec.scss +33 -31
- package/components/grid/index.scss +2 -2
- package/components/layout/_mixins.scss +5 -5
- package/components/layout/_spec.scss +206 -176
- package/components/layout/_theme.scss +14 -16
- package/components/layout/index.js +181 -153
- package/components/layout/index.scss +2 -2
- package/components/list/_spec.scss +117 -104
- package/components/list/_theme.scss +31 -34
- package/components/list/content.js +68 -52
- package/components/list/index.js +194 -61
- package/components/list/index.scss +2 -2
- package/components/list/item.js +136 -12
- package/components/list/secondary.js +46 -0
- package/components/menu/_spec.scss +32 -19
- package/components/menu/index.js +242 -229
- package/components/menu/index.scss +2 -2
- package/components/menu/item.js +95 -110
- package/components/progress/_spec.scss +35 -27
- package/components/progress/index.js +21 -0
- package/components/progress/index.scss +2 -1
- package/components/selection/_spec.scss +242 -224
- package/components/selection/_theme.scss +100 -95
- package/components/selection/index.eta +60 -0
- package/components/selection/index.js +76 -0
- package/components/selection/index.pug +15 -8
- package/components/selection/index.scss +2 -2
- package/components/selection/input.js +56 -0
- package/components/selection/radiogroup.js +47 -0
- package/components/slider/_spec.scss +10 -8
- package/components/slider/index.scss +2 -2
- package/components/snackbar/_spec.scss +22 -21
- package/components/snackbar/index.js +102 -111
- package/components/snackbar/index.scss +2 -2
- package/components/tab/_spec.scss +20 -19
- package/components/tab/content.js +41 -40
- package/components/tab/index.js +192 -99
- package/components/tab/index.scss +2 -2
- package/components/tab/item.js +38 -55
- package/components/tab/list.js +96 -72
- package/components/tab/panel.js +12 -13
- package/components/template/_theme.scss +11 -11
- package/components/textfield/_mixins.scss +52 -0
- package/components/textfield/_spec.scss +215 -266
- package/components/textfield/_theme.scss +95 -72
- package/components/textfield/index.eta +74 -0
- package/components/textfield/index.js +63 -57
- package/components/textfield/index.scss +2 -2
- package/components/tooltip/_spec.scss +27 -25
- package/components/tooltip/index.scss +2 -2
- package/components/type/_spec.scss +51 -38
- package/components/type/index.scss +2 -2
- package/core/_breakpoint.scss +75 -91
- package/core/_elevation.scss +10 -10
- package/core/_length.scss +9 -0
- package/core/_motion.scss +14 -14
- package/core/_platform.scss +9 -15
- package/core/_type.scss +33 -32
- package/core/aria/attributes.js +125 -25
- package/core/aria/button.js +23 -23
- package/core/aria/keyboard.js +93 -0
- package/core/aria/rovingtabindex.js +69 -154
- package/core/aria/tab.js +31 -28
- package/core/color/_theme.scss +240 -280
- package/core/color/index.scss +2 -2
- package/core/document/index.js +39 -0
- package/core/dom.js +12 -12
- package/core/overlay/_spec.scss +0 -3
- package/core/overlay/_theme.scss +56 -74
- package/core/overlay/index.js +49 -18
- package/core/overlay/index.scss +2 -2
- package/core/ripple/_spec.scss +22 -39
- package/core/ripple/_theme.scss +13 -13
- package/core/ripple/index.js +137 -134
- package/core/ripple/index.scss +2 -2
- package/core/theme/_config.scss +2 -0
- package/core/theme/_mixins.scss +172 -0
- package/core/theme/_palettes.scss +155 -135
- package/core/theme/_variables.scss +24 -15
- package/core/theme/index.js +50 -0
- package/core/throttler.js +1 -1
- package/core/transition/index.js +36 -20
- package/{docs-src → docs}/_flex.scss +0 -0
- package/{docs-src → docs}/_menuoptions.js +21 -34
- package/{docs-src → docs}/_mixins.pug +39 -26
- package/docs/_partials/_androidnavbar.eta +5 -0
- package/docs/_partials/_androidstatusbar.eta +13 -0
- package/docs/_partials/_appbar.eta +29 -0
- package/docs/_partials/_buttontest.eta +31 -0
- package/docs/_partials/_header.eta +149 -0
- package/docs/_partials/_navlistitem.eta +16 -0
- package/docs/_partials/_target.eta +1 -0
- package/{docs-src → docs}/_sample-utils.js +8 -6
- package/{docs-src → docs}/_storage.js +0 -0
- package/{docs-src → docs}/docs.scss +5 -2
- package/docs/index.eta +16 -0
- package/{docs-src → docs}/index.js +0 -0
- package/docs/pages/appbar.eta +114 -0
- package/{docs-src/components → docs/pages}/appbar.js +0 -0
- package/{docs-src/components → docs/pages}/appbar.pug +15 -18
- package/docs/pages/bottomnav.eta +188 -0
- package/{docs-src/components → docs/pages}/bottomnav.js +23 -24
- package/{docs-src/components → docs/pages}/bottomnav.pug +4 -4
- package/docs/pages/button.eta +124 -0
- package/{docs-src/components → docs/pages}/button.js +19 -19
- package/{docs-src/components → docs/pages}/button.pug +15 -15
- package/docs/pages/card.eta +90 -0
- package/{docs-src/components → docs/pages}/card.js +3 -3
- package/{docs-src/components → docs/pages}/card.pug +7 -7
- package/docs/pages/chip.eta +122 -0
- package/{docs-src/components → docs/pages}/chip.js +3 -6
- package/{docs-src/components → docs/pages}/chip.pug +2 -2
- package/docs/pages/color.eta +143 -0
- package/{docs-src/core → docs/pages}/color.js +95 -20
- package/docs/pages/color.pug +121 -0
- package/docs/pages/datatable.eta +323 -0
- package/{docs-src/components → docs/pages}/datatable.js +26 -13
- package/docs/pages/datatable.pug +283 -0
- package/docs/pages/dialog.eta +186 -0
- package/{docs-src/components → docs/pages}/dialog.js +26 -13
- package/{docs-src/components → docs/pages}/dialog.pug +46 -28
- package/docs/pages/dom.eta +26 -0
- package/docs/pages/dom.js +143 -0
- package/docs/pages/dom.pug +22 -0
- package/docs/pages/elevation.eta +35 -0
- package/{docs-src/components → docs/pages}/elevation.js +0 -0
- package/{docs-src/components → docs/pages}/elevation.pug +0 -0
- package/docs/pages/fab.eta +99 -0
- package/{docs-src/components → docs/pages}/fab.js +3 -3
- package/{docs-src/components → docs/pages}/fab.pug +2 -2
- package/docs/pages/grid.eta +135 -0
- package/{docs-src/components → docs/pages}/grid.js +1 -1
- package/{docs-src/components → docs/pages}/grid.pug +3 -3
- package/docs/pages/layout.eta +8 -0
- package/{docs-src/components → docs/pages}/layout.js +0 -0
- package/{docs-src/components → docs/pages}/layout.pug +0 -0
- package/docs/pages/list.eta +465 -0
- package/{docs-src/components → docs/pages}/list.js +2 -2
- package/{docs-src/components → docs/pages}/list.pug +7 -14
- package/docs/pages/menu.eta +276 -0
- package/{docs-src/components → docs/pages}/menu.js +14 -10
- package/{docs-src/components → docs/pages}/menu.pug +0 -0
- package/docs/pages/overlay.eta +69 -0
- package/docs/pages/overlay.js +4 -0
- package/{docs-src/core → docs/pages}/overlay.pug +14 -11
- package/docs/pages/progress.eta +23 -0
- package/{docs-src/components → docs/pages}/progress.js +1 -1
- package/{docs-src/components → docs/pages}/progress.pug +1 -1
- package/docs/pages/ripple.eta +27 -0
- package/docs/pages/ripple.js +4 -0
- package/{docs-src/core → docs/pages}/ripple.pug +4 -4
- package/docs/pages/search.eta +246 -0
- package/{docs-src/components → docs/pages}/search.js +59 -42
- package/{docs-src/components → docs/pages}/search.pug +50 -51
- package/docs/pages/selection.eta +111 -0
- package/docs/pages/selection.js +13 -0
- package/docs/pages/selection.pug +74 -0
- package/docs/pages/slider.eta +23 -0
- package/{docs-src/components → docs/pages}/slider.js +0 -0
- package/{docs-src/components → docs/pages}/slider.pug +0 -0
- package/docs/pages/snackbar.eta +83 -0
- package/{docs-src/components → docs/pages}/snackbar.js +3 -3
- package/{docs-src/components → docs/pages}/snackbar.pug +0 -0
- package/docs/pages/tab.eta +421 -0
- package/{docs-src/components → docs/pages}/tab.js +18 -35
- package/{docs-src/components → docs/pages}/tab.pug +4 -4
- package/docs/pages/textfield.eta +486 -0
- package/{docs-src/components → docs/pages}/textfield.js +3 -4
- package/{docs-src/components → docs/pages}/textfield.pug +87 -35
- package/docs/pages/tooltip.eta +94 -0
- package/{docs-src/components → docs/pages}/tooltip.js +0 -0
- package/{docs-src/components → docs/pages}/tooltip.pug +0 -1
- package/docs/pages/transition.eta +117 -0
- package/{docs-src/core → docs/pages}/transition.js +7 -8
- package/{docs-src/core → docs/pages}/transition.pug +0 -0
- package/docs/pages/type.eta +31 -0
- package/{docs-src/components → docs/pages}/type.js +0 -0
- package/{docs-src/components → docs/pages}/type.pug +0 -1
- package/docs/postrender.js +39 -0
- package/{docs-src → docs}/prerender.js +3 -9
- package/docs/pwa/_dialogs.eta +143 -0
- package/docs/pwa/_dialogs.pug +96 -0
- package/docs/pwa/_menus.eta +16 -0
- package/{docs-src → docs}/pwa/_menus.pug +0 -0
- package/docs/pwa/pwa-prerender.js +3 -0
- package/docs/pwa/pwa.eta +480 -0
- package/docs/pwa/pwa.js +306 -0
- package/{docs-src → docs}/pwa/pwa.pug +166 -263
- package/docs/pwa/pwa.scss +26 -0
- package/docs/spec.scss +26 -0
- package/docs/themes/_component-themes.scss +26 -0
- package/docs/themes/theme-colored-fallbacks.scss +17 -0
- package/docs/themes/theme-colored.scss +17 -0
- package/docs/themes/theme-default-fallbacks.scss +17 -0
- package/docs/themes/theme-default.scss +17 -0
- package/jsconfig.json +4 -2
- package/package.json +40 -27
- package/scripts/deploy-docs.sh +9 -0
- package/templates/index.eta +2 -0
- package/utils/function.js +3 -0
- package/webpack.config.cjs +257 -0
- package/_spec.scss +0 -27
- package/_theme.scss +0 -27
- package/components/list/expander.js +0 -142
- package/components/list/itemgroup.js +0 -22
- package/core/theme/_builder.scss +0 -116
- package/core/theme/index.scss +0 -68
- package/docs/appbar.html +0 -1
- package/docs/appbar.min.js +0 -2
- package/docs/appbar.min.js.map +0 -1
- package/docs/bottomnav.html +0 -1
- package/docs/bottomnav.min.js +0 -2
- package/docs/bottomnav.min.js.map +0 -1
- package/docs/button.html +0 -1
- package/docs/button.min.js +0 -2
- package/docs/button.min.js.map +0 -1
- package/docs/card.html +0 -1
- package/docs/card.min.js +0 -2
- package/docs/card.min.js.map +0 -1
- package/docs/chip.html +0 -1
- package/docs/chip.min.js +0 -2
- package/docs/chip.min.js.map +0 -1
- package/docs/color.html +0 -1
- package/docs/color.min.js +0 -2
- package/docs/color.min.js.map +0 -1
- package/docs/datatable.html +0 -1
- package/docs/datatable.min.js +0 -2
- package/docs/datatable.min.js.map +0 -1
- package/docs/default.common.min.js +0 -2
- package/docs/default.common.min.js.map +0 -1
- package/docs/dialog.html +0 -1
- package/docs/dialog.min.js +0 -2
- package/docs/dialog.min.js.map +0 -1
- package/docs/docs.min.css +0 -1
- package/docs/docs.min.js +0 -2
- package/docs/docs.min.js.map +0 -1
- package/docs/elevation.html +0 -1
- package/docs/elevation.min.js +0 -2
- package/docs/elevation.min.js.map +0 -1
- package/docs/fab.html +0 -1
- package/docs/fab.min.js +0 -2
- package/docs/fab.min.js.map +0 -1
- package/docs/grid.html +0 -1
- package/docs/grid.min.js +0 -2
- package/docs/grid.min.js.map +0 -1
- package/docs/index.html +0 -1
- package/docs/index.min.js +0 -2
- package/docs/index.min.js.map +0 -1
- package/docs/ink.html +0 -1
- package/docs/ink.min.js +0 -2
- package/docs/ink.min.js.map +0 -1
- package/docs/layout.html +0 -1
- package/docs/layout.min.js +0 -2
- package/docs/layout.min.js.map +0 -1
- package/docs/list.html +0 -1
- package/docs/list.min.js +0 -2
- package/docs/list.min.js.map +0 -1
- package/docs/menu.html +0 -1
- package/docs/menu.min.js +0 -2
- package/docs/menu.min.js.map +0 -1
- package/docs/overlay.html +0 -1
- package/docs/overlay.min.js +0 -2
- package/docs/overlay.min.js.map +0 -1
- package/docs/prerender.common.min.js +0 -2
- package/docs/prerender.common.min.js.map +0 -1
- package/docs/prerender.min.js +0 -2
- package/docs/prerender.min.js.map +0 -1
- package/docs/progress.html +0 -1
- package/docs/progress.min.js +0 -2
- package/docs/progress.min.js.map +0 -1
- package/docs/pwa-prerender.min.js +0 -2
- package/docs/pwa-prerender.min.js.map +0 -1
- package/docs/pwa.html +0 -11
- package/docs/pwa.min.css +0 -1
- package/docs/pwa.min.js +0 -2
- package/docs/pwa.min.js.map +0 -1
- package/docs/ripple.html +0 -1
- package/docs/ripple.min.js +0 -2
- package/docs/ripple.min.js.map +0 -1
- package/docs/search.html +0 -1
- package/docs/search.min.js +0 -2
- package/docs/search.min.js.map +0 -1
- package/docs/selection.html +0 -1
- package/docs/selection.min.js +0 -2
- package/docs/selection.min.js.map +0 -1
- package/docs/slider.html +0 -1
- package/docs/slider.min.js +0 -2
- package/docs/slider.min.js.map +0 -1
- package/docs/snackbar.html +0 -1
- package/docs/snackbar.min.js +0 -2
- package/docs/snackbar.min.js.map +0 -1
- package/docs/spec.min.css +0 -1
- package/docs/spec.min.js +0 -2
- package/docs/spec.min.js.map +0 -1
- package/docs/surface.html +0 -1
- package/docs/surface.min.js +0 -2
- package/docs/surface.min.js.map +0 -1
- package/docs/tab.html +0 -1
- package/docs/tab.min.js +0 -2
- package/docs/tab.min.js.map +0 -1
- package/docs/textfield.html +0 -2
- package/docs/textfield.min.js +0 -2
- package/docs/textfield.min.js.map +0 -1
- package/docs/theme-colored-fallbacks.min.css +0 -1
- package/docs/theme-colored-fallbacks.min.js +0 -2
- package/docs/theme-colored-fallbacks.min.js.map +0 -1
- package/docs/theme-colored.min.css +0 -1
- package/docs/theme-colored.min.js +0 -2
- package/docs/theme-colored.min.js.map +0 -1
- package/docs/theme-default-fallbacks.min.css +0 -1
- package/docs/theme-default-fallbacks.min.js +0 -2
- package/docs/theme-default-fallbacks.min.js.map +0 -1
- package/docs/theme-default.min.css +0 -1
- package/docs/theme-default.min.js +0 -2
- package/docs/theme-default.min.js.map +0 -1
- package/docs/themes-fallbacks.min.css +0 -1
- package/docs/themes-fallbacks.min.js +0 -2
- package/docs/themes-fallbacks.min.js.map +0 -1
- package/docs/themes.min.css +0 -1
- package/docs/themes.min.js +0 -2
- package/docs/themes.min.js.map +0 -1
- package/docs/tooltip.html +0 -1
- package/docs/tooltip.min.js +0 -2
- package/docs/tooltip.min.js.map +0 -1
- package/docs/transition.html +0 -1
- package/docs/transition.min.js +0 -2
- package/docs/transition.min.js.map +0 -1
- package/docs/type.html +0 -1
- package/docs/type.min.js +0 -2
- package/docs/type.min.js.map +0 -1
- package/docs-src/components/datatable.pug +0 -327
- package/docs-src/components/selection.js +0 -9
- package/docs-src/components/selection.pug +0 -77
- package/docs-src/core/color.pug +0 -201
- package/docs-src/core/overlay.js +0 -4
- package/docs-src/core/ripple.js +0 -4
- package/docs-src/index.pug +0 -9
- package/docs-src/pwa/_dialogs.pug +0 -15
- package/docs-src/pwa/pwa-prerender.js +0 -3
- package/docs-src/pwa/pwa.js +0 -182
- package/docs-src/pwa/pwa.scss +0 -25
- package/docs-src/spec.scss +0 -1
- package/docs-src/themes/theme-colored-fallbacks.scss +0 -14
- package/docs-src/themes/theme-colored.scss +0 -14
- package/docs-src/themes/theme-default-fallbacks.scss +0 -14
- package/docs-src/themes/theme-default.scss +0 -14
- package/index.js +0 -51
- package/index.scss +0 -2
- package/webpack.config.js +0 -187
package/core/ripple/index.js
CHANGED
|
@@ -1,130 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* @param {Element|Document} [root=document]
|
|
5
|
-
* @return {void}
|
|
6
|
-
*/
|
|
7
|
-
export function attachAll(root = document) {
|
|
8
|
-
iterateArrayLike(root.getElementsByClassName('mdw-ripple'), attach);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @param {Element} element
|
|
13
|
-
* @return {void}
|
|
14
|
-
*/
|
|
15
|
-
export function attach(element) {
|
|
16
|
-
let rippleContainer = getChildElementByClass(element, 'mdw-ripple__container');
|
|
17
|
-
if (!rippleContainer) {
|
|
18
|
-
rippleContainer = document.createElement('div');
|
|
19
|
-
rippleContainer.classList.add('mdw-ripple__container');
|
|
20
|
-
rippleContainer.setAttribute('role', 'presentation');
|
|
21
|
-
if (element.firstChild) {
|
|
22
|
-
element.insertBefore(rippleContainer, element.firstChild);
|
|
23
|
-
} else {
|
|
24
|
-
element.appendChild(rippleContainer);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let rippleInner = getChildElementByClass(rippleContainer, 'mdw-ripple__inner');
|
|
29
|
-
if (!rippleInner) {
|
|
30
|
-
rippleInner = document.createElement('div');
|
|
31
|
-
rippleInner.classList.add('mdw-ripple__inner');
|
|
32
|
-
rippleInner.setAttribute('role', 'presentation');
|
|
33
|
-
rippleContainer.appendChild(rippleInner);
|
|
34
|
-
}
|
|
35
|
-
element.setAttribute('mdw-ripple-js', '');
|
|
36
|
-
element.addEventListener('click', onClick, getPassiveEventListenerOption());
|
|
37
|
-
element.addEventListener('mousedown', onMouseDown, getPassiveEventListenerOption());
|
|
38
|
-
element.addEventListener('touchstart', onTouchStart, getPassiveEventListenerOption());
|
|
39
|
-
element.addEventListener('keydown', onKeyDown, getPassiveEventListenerOption());
|
|
40
|
-
rippleInner.addEventListener('animationend', onAnimationEnd, getPassiveEventListenerOption());
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @param {PointerEvent|MouseEvent} event
|
|
46
|
-
* @return {void}
|
|
47
|
-
*/
|
|
48
|
-
export function onMouseDown(event) {
|
|
49
|
-
/** @type {HTMLElement} */
|
|
50
|
-
const element = (event.currentTarget);
|
|
51
|
-
/** @type {HTMLElement} */
|
|
52
|
-
const rippleContainer = (getChildElementByClass(element, 'mdw-ripple__container'));
|
|
53
|
-
if (!rippleContainer) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
/** @type {HTMLElement} */
|
|
57
|
-
const rippleInner = (getChildElementByClass(rippleContainer, 'mdw-ripple__inner'));
|
|
58
|
-
if (!rippleInner) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
// @ts-ignore
|
|
62
|
-
if (!event.pointerType && !event.detail) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const rect = rippleContainer.getBoundingClientRect();
|
|
66
|
-
const x = event.pageX - rect.left - window.pageXOffset;
|
|
67
|
-
const y = event.pageY - rect.top - window.pageYOffset;
|
|
68
|
-
updateRipplePosition(rippleInner, x, y);
|
|
69
|
-
drawRipple(rippleInner, 'mouse');
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* @param {TouchEvent} event
|
|
74
|
-
* @return {void}
|
|
75
|
-
*/
|
|
76
|
-
export function onTouchStart(event) {
|
|
77
|
-
/** @type {HTMLElement} */
|
|
78
|
-
const element = (event.currentTarget);
|
|
79
|
-
/** @type {HTMLElement} */
|
|
80
|
-
const rippleContainer = (getChildElementByClass(element, 'mdw-ripple__container'));
|
|
81
|
-
if (!rippleContainer) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
/** @type {HTMLElement} */
|
|
85
|
-
const rippleInner = (getChildElementByClass(rippleContainer, 'mdw-ripple__inner'));
|
|
86
|
-
if (!rippleInner) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const touch = event.changedTouches[0];
|
|
90
|
-
if (!touch) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const rect = rippleContainer.getBoundingClientRect();
|
|
94
|
-
const x = touch.pageX - rect.left - window.pageXOffset;
|
|
95
|
-
const y = touch.pageY - rect.top - window.pageYOffset;
|
|
96
|
-
updateRipplePosition(rippleInner, x, y);
|
|
97
|
-
drawRipple(rippleInner, 'touch');
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* @param {TouchEvent} event
|
|
102
|
-
* @return {void}
|
|
103
|
-
*/
|
|
104
|
-
export function onKeyDown(event) {
|
|
105
|
-
/** @type {HTMLElement} */
|
|
106
|
-
const element = (event.currentTarget);
|
|
107
|
-
/** @type {HTMLElement} */
|
|
108
|
-
const rippleContainer = (getChildElementByClass(element, 'mdw-ripple__container'));
|
|
109
|
-
if (!rippleContainer) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
/** @type {HTMLElement} */
|
|
113
|
-
const rippleInner = (getChildElementByClass(rippleContainer, 'mdw-ripple__inner'));
|
|
114
|
-
if (!rippleInner) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
nextTick(() => {
|
|
119
|
-
if (isActive(rippleContainer.parentElement)) {
|
|
120
|
-
if (rippleInner.getAttribute('mdw-fade-in') === 'key') {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
updateRipplePosition(rippleInner);
|
|
124
|
-
drawRipple(rippleInner, 'key');
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
getChildElementByClass, getPassiveEventListenerOption, iterateArrayLike, nextTick,
|
|
3
|
+
} from '../dom.js';
|
|
128
4
|
|
|
129
5
|
/**
|
|
130
6
|
* @param {Element} element
|
|
@@ -134,9 +10,8 @@ export function isActive(element) {
|
|
|
134
10
|
if (element.matches) {
|
|
135
11
|
return element.matches(':active');
|
|
136
12
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
// @ts-ignore
|
|
13
|
+
if ('msMatchesSelector' in element) {
|
|
14
|
+
// @ts-ignore: Compatibility
|
|
140
15
|
element.msMatchesSelector(':active');
|
|
141
16
|
}
|
|
142
17
|
return false;
|
|
@@ -144,8 +19,8 @@ export function isActive(element) {
|
|
|
144
19
|
|
|
145
20
|
/**
|
|
146
21
|
* @param {HTMLElement} rippleInner
|
|
147
|
-
* @param {number
|
|
148
|
-
* @param {number
|
|
22
|
+
* @param {number} [x]
|
|
23
|
+
* @param {number} [y]
|
|
149
24
|
* @return {void}
|
|
150
25
|
*/
|
|
151
26
|
export function updateRipplePosition(rippleInner, x, y) {
|
|
@@ -200,7 +75,6 @@ export function drawRipple(rippleInner, initiator) {
|
|
|
200
75
|
rippleInner.setAttribute('mdw-fade-in-repeat', '');
|
|
201
76
|
}
|
|
202
77
|
}
|
|
203
|
-
rippleInner.removeAttribute('mdw-fade-in-out');
|
|
204
78
|
}
|
|
205
79
|
|
|
206
80
|
/**
|
|
@@ -242,6 +116,62 @@ export function clearRipple(rippleInner) {
|
|
|
242
116
|
rippleInner.setAttribute('mdw-fade-out', '');
|
|
243
117
|
}
|
|
244
118
|
|
|
119
|
+
/**
|
|
120
|
+
* @param {PointerEvent|MouseEvent} event
|
|
121
|
+
* @return {void}
|
|
122
|
+
*/
|
|
123
|
+
export function onMouseDown(event) {
|
|
124
|
+
/** @type {HTMLElement} */
|
|
125
|
+
const element = (event.currentTarget);
|
|
126
|
+
/** @type {HTMLElement} */
|
|
127
|
+
const rippleContainer = (getChildElementByClass(element, 'mdw-ripple__container'));
|
|
128
|
+
if (!rippleContainer) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
/** @type {HTMLElement} */
|
|
132
|
+
const rippleInner = (getChildElementByClass(rippleContainer, 'mdw-ripple__inner'));
|
|
133
|
+
if (!rippleInner) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
// @ts-ignore: Optimization
|
|
137
|
+
if (!event.pointerType && !event.detail) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const rect = rippleContainer.getBoundingClientRect();
|
|
141
|
+
const x = event.pageX - rect.left - window.pageXOffset;
|
|
142
|
+
const y = event.pageY - rect.top - window.pageYOffset;
|
|
143
|
+
updateRipplePosition(rippleInner, x, y);
|
|
144
|
+
drawRipple(rippleInner, 'mouse');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @param {TouchEvent} event
|
|
149
|
+
* @return {void}
|
|
150
|
+
*/
|
|
151
|
+
export function onTouchStart(event) {
|
|
152
|
+
/** @type {HTMLElement} */
|
|
153
|
+
const element = (event.currentTarget);
|
|
154
|
+
/** @type {HTMLElement} */
|
|
155
|
+
const rippleContainer = (getChildElementByClass(element, 'mdw-ripple__container'));
|
|
156
|
+
if (!rippleContainer) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
/** @type {HTMLElement} */
|
|
160
|
+
const rippleInner = (getChildElementByClass(rippleContainer, 'mdw-ripple__inner'));
|
|
161
|
+
if (!rippleInner) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const touch = event.changedTouches[0];
|
|
165
|
+
if (!touch) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const rect = rippleContainer.getBoundingClientRect();
|
|
169
|
+
const x = touch.pageX - rect.left - window.pageXOffset;
|
|
170
|
+
const y = touch.pageY - rect.top - window.pageYOffset;
|
|
171
|
+
updateRipplePosition(rippleInner, x, y);
|
|
172
|
+
drawRipple(rippleInner, 'touch');
|
|
173
|
+
}
|
|
174
|
+
|
|
245
175
|
/**
|
|
246
176
|
* @param {PointerEvent|MouseEvent} event
|
|
247
177
|
* @return {void}
|
|
@@ -259,7 +189,7 @@ export function onClick(event) {
|
|
|
259
189
|
if (!rippleInner) {
|
|
260
190
|
return;
|
|
261
191
|
}
|
|
262
|
-
// @ts-ignore
|
|
192
|
+
// @ts-ignore: Optimization
|
|
263
193
|
if (event.pointerType || event.detail) {
|
|
264
194
|
return;
|
|
265
195
|
}
|
|
@@ -274,6 +204,79 @@ export function onClick(event) {
|
|
|
274
204
|
});
|
|
275
205
|
}
|
|
276
206
|
|
|
207
|
+
/**
|
|
208
|
+
* @param {TouchEvent} event
|
|
209
|
+
* @return {void}
|
|
210
|
+
*/
|
|
211
|
+
export function onKeyDown(event) {
|
|
212
|
+
/** @type {HTMLElement} */
|
|
213
|
+
const element = (event.currentTarget);
|
|
214
|
+
/** @type {HTMLElement} */
|
|
215
|
+
const rippleContainer = (getChildElementByClass(element, 'mdw-ripple__container'));
|
|
216
|
+
if (!rippleContainer) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
/** @type {HTMLElement} */
|
|
220
|
+
const rippleInner = (getChildElementByClass(rippleContainer, 'mdw-ripple__inner'));
|
|
221
|
+
if (!rippleInner) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
nextTick(() => {
|
|
226
|
+
if (isActive(rippleContainer.parentElement)) {
|
|
227
|
+
if (rippleInner.getAttribute('mdw-fade-in') === 'key') {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
updateRipplePosition(rippleInner);
|
|
231
|
+
drawRipple(rippleInner, 'key');
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* @param {Element} element
|
|
238
|
+
* @return {void}
|
|
239
|
+
*/
|
|
240
|
+
export function attach(element) {
|
|
241
|
+
let rippleContainer = getChildElementByClass(element, 'mdw-ripple__container');
|
|
242
|
+
if (!rippleContainer) {
|
|
243
|
+
rippleContainer = document.createElement('div');
|
|
244
|
+
rippleContainer.classList.add('mdw-ripple__container');
|
|
245
|
+
rippleContainer.setAttribute('role', 'presentation');
|
|
246
|
+
if (element.firstChild) {
|
|
247
|
+
element.insertBefore(rippleContainer, element.firstChild);
|
|
248
|
+
} else {
|
|
249
|
+
element.appendChild(rippleContainer);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
let rippleInner = getChildElementByClass(rippleContainer, 'mdw-ripple__inner');
|
|
254
|
+
if (!rippleInner) {
|
|
255
|
+
rippleInner = document.createElement('div');
|
|
256
|
+
rippleInner.classList.add('mdw-ripple__inner');
|
|
257
|
+
rippleInner.setAttribute('role', 'presentation');
|
|
258
|
+
rippleContainer.appendChild(rippleInner);
|
|
259
|
+
}
|
|
260
|
+
rippleInner.removeAttribute('mdw-fade-in');
|
|
261
|
+
rippleInner.removeAttribute('mdw-fade-in-repeat');
|
|
262
|
+
rippleInner.removeAttribute('mdw-fade-in-complete');
|
|
263
|
+
rippleInner.removeAttribute('mdw-fade-out');
|
|
264
|
+
element.setAttribute('mdw-ripple-js', '');
|
|
265
|
+
element.addEventListener('click', onClick, getPassiveEventListenerOption());
|
|
266
|
+
element.addEventListener('mousedown', onMouseDown, getPassiveEventListenerOption());
|
|
267
|
+
element.addEventListener('touchstart', onTouchStart, getPassiveEventListenerOption());
|
|
268
|
+
element.addEventListener('keydown', onKeyDown, getPassiveEventListenerOption());
|
|
269
|
+
rippleInner.addEventListener('animationend', onAnimationEnd, getPassiveEventListenerOption());
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* @param {Element|Document} [root=document]
|
|
274
|
+
* @return {void}
|
|
275
|
+
*/
|
|
276
|
+
export function attachAll(root = document) {
|
|
277
|
+
iterateArrayLike(root.getElementsByClassName('mdw-ripple'), attach);
|
|
278
|
+
}
|
|
279
|
+
|
|
277
280
|
/**
|
|
278
281
|
* @param {Element} element
|
|
279
282
|
* @return {void}
|
package/core/ripple/index.scss
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
@
|
|
2
|
-
@
|
|
1
|
+
@forward './_spec.scss';
|
|
2
|
+
@forward './_theme.scss';
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
@forward './_variables.scss';
|
|
2
|
+
@forward './_palettes.scss';
|
|
3
|
+
|
|
4
|
+
@use '../_platform.scss' as platform;
|
|
5
|
+
@use './_variables.scss' as variables;
|
|
6
|
+
@use './_palettes.scss' as palettes;
|
|
7
|
+
|
|
8
|
+
@mixin _addCSSVariables($component, $map, $lightness) {
|
|
9
|
+
@each $key in map-keys($map) {
|
|
10
|
+
$item: _getThemeMapItem($map, $key, $lightness);
|
|
11
|
+
$value: null;
|
|
12
|
+
$length: length($item);
|
|
13
|
+
@if ($length == 1) {
|
|
14
|
+
@if (type_of($item) == color) {
|
|
15
|
+
$value: red($item),green($item),blue($item);
|
|
16
|
+
} @else {
|
|
17
|
+
$value: $item;
|
|
18
|
+
}
|
|
19
|
+
} @else if ($length == 2) {
|
|
20
|
+
$color: nth($item, 1);
|
|
21
|
+
$opacity: nth($item, 2);
|
|
22
|
+
@if (type_of($color) == string) {
|
|
23
|
+
$color: _getThemeParamColor($color);
|
|
24
|
+
}
|
|
25
|
+
$value: red($color),green($color),blue($color),$opacity;
|
|
26
|
+
} @else {
|
|
27
|
+
$color: nth($item, 1);
|
|
28
|
+
$tone: nth($item, 2);
|
|
29
|
+
$opacity: nth($item, 3);
|
|
30
|
+
@if ($tone == null) {
|
|
31
|
+
@error '$tone cannot be null';
|
|
32
|
+
}
|
|
33
|
+
@if ($color == null) {
|
|
34
|
+
$value: var(--#{$tone}-color);
|
|
35
|
+
} @else {
|
|
36
|
+
@if (type_of($color) == string) {
|
|
37
|
+
$color: _getThemeParamColor($color, $tone);
|
|
38
|
+
}
|
|
39
|
+
@if ($opacity == null) {
|
|
40
|
+
$value: red($color),green($color),blue($color);
|
|
41
|
+
} @else {
|
|
42
|
+
$value: red($color),green($color),blue($color),$opacity;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
--mdw-#{$component}__#{$key}: #{$value};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@mixin _addComponentCSSVariableRules($component, $values) {
|
|
51
|
+
:root,
|
|
52
|
+
.mdw-theme[mdw-light] {
|
|
53
|
+
@include _addCSSVariables($component, $values, 'light');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.mdw-theme[mdw-dark] {
|
|
57
|
+
@include _addCSSVariables($component, $values, 'dark');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@mixin addComponentCSSVariableRules($component, $values) {
|
|
62
|
+
@if (variables.$cssvars == 'supports') {
|
|
63
|
+
@supports(--v:v) {
|
|
64
|
+
@content;
|
|
65
|
+
@include _addComponentCSSVariableRules($component, $values);
|
|
66
|
+
}
|
|
67
|
+
} @else if (variables.$cssvars != false) {
|
|
68
|
+
@content;
|
|
69
|
+
@include _addComponentCSSVariableRules($component, $values);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@mixin addComponentFallbackRules($lightness) {
|
|
74
|
+
@if (variables.$fallbacks == 'ieonly') {
|
|
75
|
+
@include platform.ifIE() {
|
|
76
|
+
@include fallbackWrapper($lightness) {
|
|
77
|
+
@content;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
} @else if (variables.$fallbacks != false) {
|
|
81
|
+
@include fallbackWrapper($lightness) {
|
|
82
|
+
@content;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@function getThemeParamValue($param) {
|
|
88
|
+
@if ($param == 'primary') {
|
|
89
|
+
@return map-get(palettes.$palettes, variables.$primary);
|
|
90
|
+
} @else if ($param == 'secondary') {
|
|
91
|
+
@return map-get(palettes.$palettes, variables.$secondary);
|
|
92
|
+
} @else if ($param == 'warn') {
|
|
93
|
+
@return map-get(palettes.$palettes, variables.$warn);
|
|
94
|
+
} @else if ($param == 'background') {
|
|
95
|
+
@return map-get(palettes.$palettes, variables.$background);
|
|
96
|
+
} @else if ($param == 'foreground-light') {
|
|
97
|
+
@return nth(variables.$foreground, 1);
|
|
98
|
+
} @else if ($param == 'foreground-dark') {
|
|
99
|
+
@return nth(variables.$foreground, length(variables.$foreground));
|
|
100
|
+
} @else {
|
|
101
|
+
@return map-get(palettes.$palettes, $param);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@function _getThemeParamColor($param, $tone: null) {
|
|
106
|
+
$paramValue: getThemeParamValue($param);
|
|
107
|
+
@if (($param == 'foreground-light') or ($param == 'foreground-dark')) {
|
|
108
|
+
@return $paramValue;
|
|
109
|
+
}
|
|
110
|
+
@return map-get($paramValue, $tone);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@function _getThemeMapItem($colorMap, $key, $lightness) {
|
|
114
|
+
$list: map-get($colorMap, $key);
|
|
115
|
+
$length: length($list);
|
|
116
|
+
|
|
117
|
+
@if ($lightness == 'dark') {
|
|
118
|
+
@if ($length > 1) {
|
|
119
|
+
@return nth($list, 2);
|
|
120
|
+
} @else {
|
|
121
|
+
@error 'Variable not found' $key;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
@return nth($list, 1);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@function getThemeValue($component, $colorMap, $key, $type) {
|
|
128
|
+
@if ($type == 'var') {
|
|
129
|
+
@return var(--mdw-#{$component}__#{$key});
|
|
130
|
+
}
|
|
131
|
+
$item: _getThemeMapItem($colorMap, $key, $type);
|
|
132
|
+
$length: length($item);
|
|
133
|
+
@if ($length == 1) {
|
|
134
|
+
@if (type_of($item) == color) {
|
|
135
|
+
@return red($item),green($item),blue($item);
|
|
136
|
+
}
|
|
137
|
+
@return $item;
|
|
138
|
+
} @else if ($length == 2) {
|
|
139
|
+
$color: nth($item, 1);
|
|
140
|
+
$opacity: nth($item, 2);
|
|
141
|
+
@if (type_of($color) == string) {
|
|
142
|
+
$color: _getThemeParamColor($color);
|
|
143
|
+
}
|
|
144
|
+
@return red($color),green($color),blue($color),$opacity;
|
|
145
|
+
} @else {
|
|
146
|
+
$color: nth($item, 1);
|
|
147
|
+
$tone: nth($item, 2);
|
|
148
|
+
$opacity: nth($item, 3);
|
|
149
|
+
$value: _getThemeParamColor($color, $tone);
|
|
150
|
+
@if ($opacity == null) {
|
|
151
|
+
@return red($value),green($value),blue($value);
|
|
152
|
+
}
|
|
153
|
+
@return red($value),green($value),blue($value),$opacity;
|
|
154
|
+
}
|
|
155
|
+
@return null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
@mixin fallbackWrapper($scope) {
|
|
159
|
+
@if ($scope == 'global') {
|
|
160
|
+
@content;
|
|
161
|
+
} @else if ($scope == 'light') {
|
|
162
|
+
.mdw-theme[mdw-light],
|
|
163
|
+
.mdw-theme[mdw-dark] .mdw-theme[mdw-light] {
|
|
164
|
+
@content;
|
|
165
|
+
}
|
|
166
|
+
} @else if ($scope == 'dark') {
|
|
167
|
+
.mdw-theme[mdw-dark],
|
|
168
|
+
.mdw-theme[mdw-light] .mdw-theme[mdw-dark] {
|
|
169
|
+
@content;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|