@shortfuse/materialdesignweb 0.0.9 → 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/.browserslistrc +3 -0
- package/.eslintrc.json +146 -27
- package/.stylelintrc.json +598 -2
- package/.vscode/launch.json +20 -5
- package/.vscode/settings.json +3 -0
- package/.vscode/tasks.json +19 -10
- package/CHANGELOG.md +24 -0
- package/README.md +84 -2
- package/adapters/datatable/column.js +203 -0
- package/adapters/datatable/index.js +972 -0
- package/adapters/dom/index.js +601 -0
- package/adapters/list/index.js +69 -0
- package/adapters/search/index.js +521 -0
- package/components/appbar/_spec.scss +225 -0
- package/components/appbar/_theme.scss +0 -0
- package/components/appbar/index.scss +2 -0
- package/components/banner/_spec.scss +118 -0
- package/components/banner/_theme.scss +0 -0
- package/components/banner/index.scss +2 -0
- package/components/bottomnav/README.md +85 -0
- package/components/bottomnav/_spec.scss +157 -0
- package/components/bottomnav/_theme.scss +0 -0
- package/components/bottomnav/index.js +122 -0
- package/components/bottomnav/index.scss +2 -0
- package/components/bottomnav/item.js +89 -0
- package/components/{core/button → button}/README.md +16 -22
- package/components/button/_spec.scss +161 -0
- package/components/button/_theme.scss +65 -0
- package/components/button/index.eta +32 -0
- package/components/button/index.js +43 -0
- package/components/button/index.pug +18 -0
- package/components/button/index.scss +2 -0
- package/components/card/_spec.scss +249 -0
- package/components/card/_theme.scss +0 -0
- package/components/card/index.scss +2 -0
- package/components/chip/_spec.scss +134 -0
- package/components/chip/_theme.scss +177 -0
- package/components/chip/index.js +21 -0
- package/components/chip/index.scss +2 -0
- package/components/chip/item.js +20 -0
- package/components/datatable/_spec.scss +288 -0
- package/components/datatable/_theme.scss +154 -0
- package/components/datatable/cell.js +45 -0
- package/components/datatable/columnheader.js +47 -0
- package/components/datatable/index.js +388 -0
- package/components/datatable/index.scss +2 -0
- package/components/datatable/row.js +49 -0
- package/components/datatable/rowheader.js +18 -0
- package/components/dialog/_spec.scss +213 -0
- package/components/dialog/_theme.scss +0 -0
- package/components/dialog/index.js +627 -0
- package/components/dialog/index.scss +2 -0
- package/components/divider/_spec.scss +13 -0
- package/components/divider/_theme.scss +0 -0
- package/components/divider/index.scss +2 -0
- package/components/elevation/_spec.scss +9 -0
- package/components/elevation/_theme.scss +0 -0
- package/components/elevation/index.scss +2 -0
- package/components/fab/_spec.scss +222 -0
- package/components/fab/_theme.scss +0 -0
- package/components/fab/index.js +103 -0
- package/components/fab/index.scss +2 -0
- package/components/grid/_spec.scss +312 -0
- package/components/grid/_theme.scss +0 -0
- package/components/grid/index.scss +2 -0
- package/components/layout/_mixins.scss +33 -0
- package/components/layout/_spec.scss +1012 -0
- package/components/layout/_theme.scss +44 -0
- package/components/layout/index.js +464 -0
- package/components/layout/index.scss +2 -0
- package/components/list/_spec.scss +397 -0
- package/components/list/_theme.scss +111 -0
- package/components/list/content.js +110 -0
- package/components/list/index.js +260 -0
- package/components/list/index.scss +2 -0
- package/components/list/item.js +170 -0
- package/components/list/secondary.js +46 -0
- package/components/menu/_spec.scss +362 -0
- package/components/menu/_theme.scss +0 -0
- package/components/menu/index.js +721 -0
- package/components/menu/index.scss +2 -0
- package/components/menu/item.js +239 -0
- package/components/{core/progress/style.scss → progress/_spec.scss} +36 -25
- package/components/progress/_theme.scss +0 -0
- package/components/progress/index.js +36 -0
- package/components/progress/index.scss +2 -0
- package/components/selection/_spec.scss +386 -0
- package/components/selection/_theme.scss +166 -0
- package/components/selection/index.eta +60 -0
- package/components/selection/index.js +76 -0
- package/components/selection/index.pug +30 -0
- package/components/selection/index.scss +2 -0
- package/components/selection/input.js +56 -0
- package/components/selection/radiogroup.js +47 -0
- package/components/slider/_spec.scss +64 -0
- package/components/slider/_theme.scss +0 -0
- package/components/slider/index.scss +2 -0
- package/components/snackbar/_spec.scss +195 -0
- package/components/snackbar/_theme.scss +0 -0
- package/components/snackbar/index.js +344 -0
- package/components/snackbar/index.scss +2 -0
- package/components/tab/_spec.scss +235 -0
- package/components/tab/_theme.scss +0 -0
- package/components/tab/content.js +205 -0
- package/components/tab/index.js +260 -0
- package/components/tab/index.scss +2 -0
- package/components/tab/item.js +89 -0
- package/components/tab/list.js +210 -0
- package/components/tab/panel.js +54 -0
- package/components/template/_theme.scss +27 -0
- package/components/{core/textfield → textfield}/README.md +70 -50
- package/components/textfield/_mixins.scss +52 -0
- package/components/textfield/_spec.scss +809 -0
- package/components/textfield/_theme.scss +299 -0
- package/components/textfield/index.eta +74 -0
- package/components/textfield/index.js +168 -0
- package/components/textfield/index.pug +30 -0
- package/components/textfield/index.scss +2 -0
- package/components/tooltip/_spec.scss +188 -0
- package/components/tooltip/_theme.scss +0 -0
- package/components/tooltip/index.scss +2 -0
- package/components/type/_spec.scss +224 -0
- package/components/type/_theme.scss +0 -0
- package/components/type/index.scss +2 -0
- package/core/_breakpoint.scss +189 -0
- package/core/_elevation.scss +38 -0
- package/core/_length.scss +9 -0
- package/core/_motion.scss +31 -0
- package/core/_platform.scss +34 -0
- package/core/_type.scss +127 -0
- package/core/aria/attributes.js +141 -0
- package/core/aria/button.js +50 -0
- package/core/aria/keyboard.js +93 -0
- package/core/aria/rovingtabindex.js +178 -0
- package/core/aria/tab.js +60 -0
- package/core/color/_spec.scss +0 -0
- package/core/color/_theme.scss +390 -0
- package/core/color/index.scss +2 -0
- package/core/document/index.js +39 -0
- package/core/dom.js +271 -0
- package/core/overlay/_spec.scss +31 -0
- package/core/overlay/_theme.scss +171 -0
- package/core/overlay/index.js +108 -0
- package/core/overlay/index.scss +2 -0
- package/core/ripple/_spec.scss +197 -0
- package/core/ripple/_theme.scss +40 -0
- package/core/ripple/index.js +294 -0
- package/core/ripple/index.scss +2 -0
- package/core/theme/_config.scss +2 -0
- package/core/theme/_mixins.scss +172 -0
- package/{components/theming/palettes.scss → core/theme/_palettes.scss} +173 -150
- package/core/theme/_variables.scss +24 -0
- package/core/theme/index.js +50 -0
- package/core/throttler.js +42 -0
- package/core/transition/index.js +468 -0
- package/docs/_flex.scss +22 -0
- package/docs/_menuoptions.js +183 -0
- package/docs/_mixins.pug +155 -0
- 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/_sample-utils.js +93 -0
- package/docs/_storage.js +33 -0
- package/docs/docs.scss +295 -0
- package/docs/index.eta +16 -0
- package/docs/index.js +0 -0
- package/docs/pages/appbar.eta +114 -0
- package/docs/pages/appbar.js +0 -0
- package/docs/pages/appbar.pug +78 -0
- package/docs/pages/bottomnav.eta +188 -0
- package/docs/pages/bottomnav.js +115 -0
- package/docs/pages/bottomnav.pug +137 -0
- package/docs/pages/button.eta +124 -0
- package/docs/pages/button.js +224 -0
- package/docs/pages/button.pug +121 -0
- package/docs/pages/card.eta +90 -0
- package/docs/pages/card.js +177 -0
- package/docs/pages/card.pug +74 -0
- package/docs/pages/chip.eta +122 -0
- package/docs/pages/chip.js +82 -0
- package/docs/pages/chip.pug +91 -0
- package/docs/pages/color.eta +143 -0
- package/docs/pages/color.js +262 -0
- package/docs/pages/color.pug +121 -0
- package/docs/pages/datatable.eta +323 -0
- package/docs/pages/datatable.js +164 -0
- package/docs/pages/datatable.pug +283 -0
- package/docs/pages/dialog.eta +186 -0
- package/docs/pages/dialog.js +177 -0
- package/docs/pages/dialog.pug +132 -0
- 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/pages/elevation.js +0 -0
- package/docs/pages/elevation.pug +25 -0
- package/docs/pages/fab.eta +99 -0
- package/docs/pages/fab.js +44 -0
- package/docs/pages/fab.pug +66 -0
- package/docs/pages/grid.eta +135 -0
- package/docs/pages/grid.js +128 -0
- package/docs/pages/grid.pug +95 -0
- package/docs/pages/layout.eta +8 -0
- package/docs/pages/layout.js +0 -0
- package/docs/pages/layout.pug +7 -0
- package/docs/pages/list.eta +465 -0
- package/docs/pages/list.js +9 -0
- package/docs/pages/list.pug +326 -0
- package/docs/pages/menu.eta +276 -0
- package/docs/pages/menu.js +217 -0
- package/docs/pages/menu.pug +205 -0
- package/docs/pages/overlay.eta +69 -0
- package/docs/pages/overlay.js +4 -0
- package/docs/pages/overlay.pug +55 -0
- package/docs/pages/progress.eta +23 -0
- package/docs/pages/progress.js +12 -0
- package/docs/pages/progress.pug +16 -0
- package/docs/pages/ripple.eta +27 -0
- package/docs/pages/ripple.js +4 -0
- package/docs/pages/ripple.pug +21 -0
- package/docs/pages/search.eta +246 -0
- package/docs/pages/search.js +243 -0
- package/docs/pages/search.pug +165 -0
- 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/pages/slider.js +0 -0
- package/docs/pages/slider.pug +17 -0
- package/docs/pages/snackbar.eta +83 -0
- package/docs/pages/snackbar.js +158 -0
- package/docs/pages/snackbar.pug +60 -0
- package/docs/pages/tab.eta +421 -0
- package/docs/pages/tab.js +151 -0
- package/docs/pages/tab.pug +304 -0
- package/docs/pages/textfield.eta +486 -0
- package/docs/pages/textfield.js +254 -0
- package/docs/pages/textfield.pug +360 -0
- package/docs/pages/tooltip.eta +94 -0
- package/docs/pages/tooltip.js +0 -0
- package/docs/pages/tooltip.pug +78 -0
- package/docs/pages/transition.eta +117 -0
- package/docs/pages/transition.js +54 -0
- package/docs/pages/transition.pug +76 -0
- package/docs/pages/type.eta +31 -0
- package/docs/pages/type.js +0 -0
- package/docs/pages/type.pug +29 -0
- package/docs/postrender.js +39 -0
- package/docs/prerender.js +16 -0
- package/docs/pwa/_dialogs.eta +143 -0
- package/docs/pwa/_dialogs.pug +96 -0
- package/docs/pwa/_menus.eta +16 -0
- package/docs/pwa/_menus.pug +11 -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/pwa/pwa.pug +325 -0
- 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 +43 -28
- package/scripts/deploy-docs.sh +9 -0
- package/templates/index.eta +2 -0
- package/templates/index.pug +3 -0
- package/utils/function.js +3 -0
- package/webpack.config.cjs +257 -0
- package/components/_index.scss +0 -4
- package/components/all-components.scss +0 -14
- package/components/common/functions.scss +0 -173
- package/components/common/mixins.scss +0 -107
- package/components/common/motion.scss +0 -36
- package/components/common/ripple.scss +0 -92
- package/components/common/variables.scss +0 -48
- package/components/complex/dialog/style.scss +0 -159
- package/components/complex/dialog/theming.scss +0 -29
- package/components/complex/navdrawer/style.scss +0 -477
- package/components/complex/navdrawer/theming.scss +0 -58
- package/components/complex/search/index.js +0 -492
- package/components/core/bottomnav/README.md +0 -85
- package/components/core/bottomnav/index.js +0 -140
- package/components/core/bottomnav/style.scss +0 -173
- package/components/core/bottomnav/theming.scss +0 -42
- package/components/core/button/index.js +0 -52
- package/components/core/button/style.scss +0 -283
- package/components/core/button/theming.scss +0 -131
- package/components/core/list/index.js +0 -94
- package/components/core/list/style.scss +0 -269
- package/components/core/list/theming.scss +0 -74
- package/components/core/menu/index.js +0 -127
- package/components/core/menu/style.scss +0 -239
- package/components/core/menu/theming.scss +0 -55
- package/components/core/progress/index.js +0 -33
- package/components/core/selection/style.scss +0 -249
- package/components/core/selection/theming.scss +0 -49
- package/components/core/switch/style.scss +0 -3
- package/components/core/tab/index.js +0 -174
- package/components/core/tab/style.scss +0 -202
- package/components/core/tab/theming.scss +0 -43
- package/components/core/textfield/index.js +0 -169
- package/components/core/textfield/style.scss +0 -672
- package/components/core/textfield/theming.scss +0 -262
- package/components/core/toolbar/style.scss +0 -109
- package/components/core/toolbar/theming.scss +0 -28
- package/components/core/tooltip/style.scss +0 -127
- package/components/core/type/style.scss +0 -133
- package/components/core/type/theming.scss +0 -25
- package/components/index.js +0 -24
- package/components/template/theming.scss +0 -31
- package/components/theming/theming.scss +0 -504
- package/docs/bottomnav.html +0 -171
- package/docs/bottomnav.min.js +0 -383
- package/docs/button.html +0 -322
- package/docs/button.min.js +0 -251
- package/docs/components.min.css +0 -1
- package/docs/components.min.js +0 -83
- package/docs/dialog.html +0 -103
- package/docs/dialog.min.js +0 -160
- package/docs/docs.min.css +0 -1
- package/docs/docs.min.js +0 -83
- package/docs/index.html +0 -55
- package/docs/index.min.js +0 -83
- package/docs/list.html +0 -442
- package/docs/list.min.js +0 -312
- package/docs/menu.html +0 -185
- package/docs/menu.min.js +0 -370
- package/docs/navdrawer.html +0 -199
- package/docs/navdrawer.min.js +0 -244
- package/docs/progress.html +0 -75
- package/docs/progress.min.js +0 -162
- package/docs/search.html +0 -230
- package/docs/search.min.js +0 -1202
- package/docs/selection.html +0 -188
- package/docs/selection.min.js +0 -160
- package/docs/src/complex/dialog.js +0 -3
- package/docs/src/complex/dialog.pug +0 -44
- package/docs/src/complex/navdrawer.js +0 -82
- package/docs/src/complex/navdrawer.pug +0 -109
- package/docs/src/complex/search.js +0 -207
- package/docs/src/complex/search.pug +0 -143
- package/docs/src/components.scss +0 -1
- package/docs/src/core/bottomnav.js +0 -22
- package/docs/src/core/bottomnav.pug +0 -93
- package/docs/src/core/button.js +0 -16
- package/docs/src/core/button.pug +0 -73
- package/docs/src/core/list.js +0 -21
- package/docs/src/core/list.pug +0 -246
- package/docs/src/core/menu.js +0 -33
- package/docs/src/core/menu.pug +0 -108
- package/docs/src/core/progress.js +0 -11
- package/docs/src/core/progress.pug +0 -17
- package/docs/src/core/selection.js +0 -4
- package/docs/src/core/selection.pug +0 -92
- package/docs/src/core/tab.js +0 -21
- package/docs/src/core/tab.pug +0 -180
- package/docs/src/core/textfield.js +0 -15
- package/docs/src/core/textfield.pug +0 -274
- package/docs/src/core/toolbar.js +0 -4
- package/docs/src/core/toolbar.pug +0 -79
- package/docs/src/core/tooltip.js +0 -4
- package/docs/src/core/tooltip.pug +0 -76
- package/docs/src/core/type.js +0 -4
- package/docs/src/core/type.pug +0 -36
- package/docs/src/docs.scss +0 -200
- package/docs/src/index.pug +0 -5
- package/docs/src/mixins.pug +0 -72
- package/docs/src/targetHandler.js +0 -50
- package/docs/src/theming.ie11.scss +0 -35
- package/docs/src/theming.scss +0 -36
- package/docs/tab.html +0 -301
- package/docs/tab.min.js +0 -397
- package/docs/textfield.html +0 -476
- package/docs/textfield.min.js +0 -381
- package/docs/theming.ie11.min.css +0 -1
- package/docs/theming.ie11.min.js +0 -83
- package/docs/theming.min.css +0 -1
- package/docs/theming.min.js +0 -83
- package/docs/toolbar.html +0 -213
- package/docs/toolbar.min.js +0 -160
- package/docs/tooltip.html +0 -138
- package/docs/tooltip.min.js +0 -160
- package/docs/type.html +0 -94
- package/docs/type.min.js +0 -160
- package/webpack.config.js +0 -176
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
// https://www.w3.org/TR/wai-aria-1.1/#alert
|
|
2
|
+
// https://www.w3.org/TR/wai-aria-practices/#alert
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
dispatchDomEvent,
|
|
6
|
+
findElementParentByClassName,
|
|
7
|
+
nextTick,
|
|
8
|
+
setTextNode,
|
|
9
|
+
} from '../../core/dom.js';
|
|
10
|
+
import * as Button from '../button/index.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef SnackbarCreateOptions
|
|
14
|
+
* @prop {!string} text
|
|
15
|
+
* @prop {!string} [buttonText]
|
|
16
|
+
* @prop {string} [buttonInk='primary']
|
|
17
|
+
* @prop {boolean} [stacked=false]
|
|
18
|
+
* @prop {number|boolean} [autoHide=4] Auto hide time in seconds
|
|
19
|
+
* @prop {boolean} [autoDestroy=true] Destroy element after hide
|
|
20
|
+
* @prop {Element} [parent] Parent element to which to append
|
|
21
|
+
* @prop {boolean} [show=true] Show element after creation
|
|
22
|
+
* @prop {boolean} [skipQueue=false] Skip queue
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
class SnackbarQueueItem {
|
|
26
|
+
/**
|
|
27
|
+
* @param {Element} element
|
|
28
|
+
* @param {SnackbarCreateOptions} [options]
|
|
29
|
+
*/
|
|
30
|
+
constructor(element, options) {
|
|
31
|
+
this.element = element;
|
|
32
|
+
this.options = options;
|
|
33
|
+
this.hideTimeout = null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** @return {void} */
|
|
37
|
+
clearHideTimeout() {
|
|
38
|
+
if (this.hideTimeout) {
|
|
39
|
+
clearTimeout(this.hideTimeout);
|
|
40
|
+
this.hideTimeout = null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** @type {SnackbarQueueItem[]} */
|
|
46
|
+
const SNACKBAR_QUEUE = [];
|
|
47
|
+
|
|
48
|
+
export const HIDE_EVENT = 'mdw:snackbar-hide';
|
|
49
|
+
export const SHOW_EVENT = 'mdw:snackbar-show';
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @param {Element} snackbarElement
|
|
53
|
+
* @return {void}
|
|
54
|
+
*/
|
|
55
|
+
export function setupARIA(snackbarElement) {
|
|
56
|
+
if (snackbarElement.hasAttribute('mdw-no-aria')) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
snackbarElement.setAttribute('role', 'alert');
|
|
60
|
+
snackbarElement.setAttribute('tabindex', '-1');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @param {Element} element
|
|
65
|
+
* @return {SnackbarQueueItem}
|
|
66
|
+
*/
|
|
67
|
+
export function findNextQueueItem(element) {
|
|
68
|
+
let queue = null;
|
|
69
|
+
SNACKBAR_QUEUE.some((q) => {
|
|
70
|
+
if (q.element === element) {
|
|
71
|
+
queue = q;
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
});
|
|
76
|
+
return queue;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @param {Element} snackbarElement
|
|
81
|
+
* @return {void}
|
|
82
|
+
*/
|
|
83
|
+
export function handleAnimationChange(snackbarElement) {
|
|
84
|
+
const showing = snackbarElement.getAttribute('aria-hidden') === 'false';
|
|
85
|
+
if (showing) {
|
|
86
|
+
const currentQueueItem = findNextQueueItem(snackbarElement);
|
|
87
|
+
if (currentQueueItem && currentQueueItem.hideTimeout) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const autoHideString = snackbarElement.getAttribute('mdw-autohide');
|
|
91
|
+
if (autoHideString == null) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const timeInSeconds = parseFloat(autoHideString) || 4;
|
|
95
|
+
if (timeInSeconds < 0) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const timeout = setTimeout(() => {
|
|
99
|
+
// eslint-disable-next-line no-use-before-define
|
|
100
|
+
hide(snackbarElement);
|
|
101
|
+
}, timeInSeconds * 1000);
|
|
102
|
+
if (currentQueueItem) {
|
|
103
|
+
currentQueueItem.hideTimeout = timeout;
|
|
104
|
+
}
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const nextQueueItem = findNextQueueItem(snackbarElement);
|
|
109
|
+
if (nextQueueItem) {
|
|
110
|
+
// eslint-disable-next-line no-use-before-define
|
|
111
|
+
update(snackbarElement, nextQueueItem.options);
|
|
112
|
+
// eslint-disable-next-line no-use-before-define
|
|
113
|
+
show(snackbarElement);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (snackbarElement.hasAttribute('mdw-autodestroy')) {
|
|
117
|
+
if (snackbarElement.parentElement) {
|
|
118
|
+
snackbarElement.parentElement.removeChild(snackbarElement);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @param {AnimationEvent} event
|
|
125
|
+
* @return {void}
|
|
126
|
+
*/
|
|
127
|
+
export function onAnimationEnd(event) {
|
|
128
|
+
handleAnimationChange(/** @type {Element} */ (event.currentTarget));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @param {Element} snackbarElement
|
|
133
|
+
* @return {boolean} changed
|
|
134
|
+
*/
|
|
135
|
+
export function hide(snackbarElement) {
|
|
136
|
+
if (snackbarElement.getAttribute('aria-hidden') === 'true') {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
if (!dispatchDomEvent(snackbarElement, HIDE_EVENT)) {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
snackbarElement.setAttribute('aria-hidden', 'true');
|
|
143
|
+
const currentQueueItem = findNextQueueItem(snackbarElement);
|
|
144
|
+
if (currentQueueItem) {
|
|
145
|
+
SNACKBAR_QUEUE.splice(SNACKBAR_QUEUE.indexOf(currentQueueItem), 1);
|
|
146
|
+
}
|
|
147
|
+
if (window.getComputedStyle(snackbarElement).animationName === 'none') {
|
|
148
|
+
nextTick(() => handleAnimationChange(snackbarElement));
|
|
149
|
+
}
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @param {KeyboardEvent} event
|
|
155
|
+
* @return {void}
|
|
156
|
+
*/
|
|
157
|
+
export function onKeyDown(event) {
|
|
158
|
+
if (event.key === 'Escape' || event.key === 'Esc') {
|
|
159
|
+
// Allow users to close snackbar with escape, for accessibilty reasons
|
|
160
|
+
event.stopPropagation();
|
|
161
|
+
event.preventDefault();
|
|
162
|
+
/** @type {Element} */
|
|
163
|
+
const snackbarElement = (event.currentTarget);
|
|
164
|
+
hide(snackbarElement);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* @param {MouseEvent} event
|
|
170
|
+
* @return {void}
|
|
171
|
+
*/
|
|
172
|
+
export function onButtonClick(event) {
|
|
173
|
+
/** @type {HTMLElement} */
|
|
174
|
+
const buttonElement = (event.currentTarget);
|
|
175
|
+
if (buttonElement instanceof HTMLAnchorElement) {
|
|
176
|
+
event.preventDefault();
|
|
177
|
+
}
|
|
178
|
+
const snackbarElement = findElementParentByClassName(buttonElement, 'mdw-snackbar');
|
|
179
|
+
hide(snackbarElement);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @param {Element} element
|
|
184
|
+
* @param {SnackbarCreateOptions} options
|
|
185
|
+
* @return {void}
|
|
186
|
+
*/
|
|
187
|
+
export function update(element, options) {
|
|
188
|
+
element.classList.add('mdw-snackbar');
|
|
189
|
+
if (!element.classList.contains('mdw-theme')) {
|
|
190
|
+
// Guidelines conflict stating a background should be fully opaque
|
|
191
|
+
// But says spec says to use #000000 with 87% opacity
|
|
192
|
+
// Calculated against white, opaque value is #212121 (Gray-900)
|
|
193
|
+
element.classList.add('mdw-theme');
|
|
194
|
+
element.setAttribute('mdw-surface', 'background 900');
|
|
195
|
+
element.setAttribute('mdw-dark', '');
|
|
196
|
+
}
|
|
197
|
+
let span = element.getElementsByTagName('span')[0];
|
|
198
|
+
if (span) {
|
|
199
|
+
// To trigger screen readers, we destroy and create a new span and textnode
|
|
200
|
+
span.parentElement.removeChild(span);
|
|
201
|
+
}
|
|
202
|
+
span = document.createElement('span');
|
|
203
|
+
if (element.firstChild) {
|
|
204
|
+
element.insertBefore(span, element.firstChild);
|
|
205
|
+
} else {
|
|
206
|
+
element.appendChild(span);
|
|
207
|
+
}
|
|
208
|
+
const textNode = document.createTextNode(options.text);
|
|
209
|
+
span.appendChild(textNode);
|
|
210
|
+
let button = element.getElementsByClassName('mdw-button')[0];
|
|
211
|
+
if (options.buttonText) {
|
|
212
|
+
if (!button) {
|
|
213
|
+
button = document.createElement('a');
|
|
214
|
+
element.appendChild(button);
|
|
215
|
+
}
|
|
216
|
+
setTextNode(button, options.buttonText);
|
|
217
|
+
button.classList.add('mdw-button');
|
|
218
|
+
if (typeof options.buttonInk === 'undefined') {
|
|
219
|
+
button.classList.add('mdw-theme');
|
|
220
|
+
button.setAttribute('mdw-ink', 'secondary');
|
|
221
|
+
} else if (typeof options.buttonInk === 'string') {
|
|
222
|
+
button.classList.add('mdw-theme');
|
|
223
|
+
button.setAttribute('mdw-ink', options.buttonInk);
|
|
224
|
+
} else {
|
|
225
|
+
// Don't set attribute if null is passed
|
|
226
|
+
}
|
|
227
|
+
} else if (button && button.parentElement) {
|
|
228
|
+
button.parentElement.removeChild(button);
|
|
229
|
+
}
|
|
230
|
+
if (options.stacked) {
|
|
231
|
+
element.setAttribute('mdw-stacked', '');
|
|
232
|
+
}
|
|
233
|
+
if (options.autoHide !== false) {
|
|
234
|
+
let timeInSeconds;
|
|
235
|
+
if (options.autoHide === true) {
|
|
236
|
+
timeInSeconds = 4;
|
|
237
|
+
} else if (options.autoHide == null) {
|
|
238
|
+
timeInSeconds = 4;
|
|
239
|
+
} else {
|
|
240
|
+
timeInSeconds = options.autoHide;
|
|
241
|
+
}
|
|
242
|
+
if (timeInSeconds > 0) {
|
|
243
|
+
element.setAttribute('mdw-autohide', timeInSeconds.toString());
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if (options.autoDestroy !== false) {
|
|
247
|
+
element.setAttribute('mdw-autodestroy', '');
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* @param {Element} snackbarElement
|
|
253
|
+
* @return {void}
|
|
254
|
+
*/
|
|
255
|
+
export function attach(snackbarElement) {
|
|
256
|
+
const button = snackbarElement.getElementsByClassName('mdw-button')[0];
|
|
257
|
+
if (button) {
|
|
258
|
+
Button.attach(button);
|
|
259
|
+
button.addEventListener('click', onButtonClick);
|
|
260
|
+
}
|
|
261
|
+
snackbarElement.setAttribute('mdw-js', '');
|
|
262
|
+
snackbarElement.addEventListener('animationend', onAnimationEnd);
|
|
263
|
+
snackbarElement.addEventListener('keydown', onKeyDown);
|
|
264
|
+
setupARIA(snackbarElement);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* @param {Element} snackbarElement
|
|
269
|
+
* @return {void}
|
|
270
|
+
*/
|
|
271
|
+
export function detach(snackbarElement) {
|
|
272
|
+
const button = snackbarElement.getElementsByClassName('mdw-button')[0];
|
|
273
|
+
if (button) {
|
|
274
|
+
Button.detach(button);
|
|
275
|
+
button.removeEventListener('click', onButtonClick);
|
|
276
|
+
}
|
|
277
|
+
// Remove timeouts and stacks
|
|
278
|
+
SNACKBAR_QUEUE.slice().reverse().forEach((queue, reverseIndex, array) => {
|
|
279
|
+
if (queue.element === snackbarElement) {
|
|
280
|
+
queue.clearHideTimeout();
|
|
281
|
+
const index = array.length - reverseIndex - 1;
|
|
282
|
+
SNACKBAR_QUEUE.splice(index, 1);
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
snackbarElement.removeAttribute('mdw-js');
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* @param {?Element} snackbarElement
|
|
290
|
+
* @return {boolean} changed
|
|
291
|
+
*/
|
|
292
|
+
export function show(snackbarElement) {
|
|
293
|
+
if (snackbarElement.getAttribute('aria-hidden') === 'false') {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
if (!dispatchDomEvent(snackbarElement, SHOW_EVENT)) {
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
299
|
+
snackbarElement.setAttribute('aria-hidden', 'false');
|
|
300
|
+
attach(snackbarElement);
|
|
301
|
+
if (window.getComputedStyle(snackbarElement).animationName === 'none') {
|
|
302
|
+
nextTick(() => handleAnimationChange(snackbarElement));
|
|
303
|
+
}
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Creates a Snackbar element if required and adds to show queue
|
|
309
|
+
* @param {SnackbarCreateOptions} options
|
|
310
|
+
* @return {HTMLElement}
|
|
311
|
+
*/
|
|
312
|
+
export function create(options) {
|
|
313
|
+
let element;
|
|
314
|
+
let newlyCreated = false;
|
|
315
|
+
if (options.parent) {
|
|
316
|
+
/** @type {HTMLElement} */
|
|
317
|
+
element = (options.parent.getElementsByClassName('mdw-snackbar')[0]);
|
|
318
|
+
}
|
|
319
|
+
if (!element) {
|
|
320
|
+
element = document.createElement('div');
|
|
321
|
+
if (options.parent) {
|
|
322
|
+
options.parent.appendChild(element);
|
|
323
|
+
}
|
|
324
|
+
newlyCreated = true;
|
|
325
|
+
}
|
|
326
|
+
const queue = new SnackbarQueueItem(element, options);
|
|
327
|
+
if (options.skipQueue) {
|
|
328
|
+
SNACKBAR_QUEUE.splice(0, 0, queue);
|
|
329
|
+
} else {
|
|
330
|
+
SNACKBAR_QUEUE.push(queue);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
if (options.show !== false) {
|
|
334
|
+
if (newlyCreated) {
|
|
335
|
+
// Update after show to trigger a text change
|
|
336
|
+
update(element, options);
|
|
337
|
+
show(element);
|
|
338
|
+
update(element, options);
|
|
339
|
+
} else {
|
|
340
|
+
show(element);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return element;
|
|
344
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
// https://material.io/design/components/tabs.html#spec
|
|
2
|
+
|
|
3
|
+
@use '../../core/_elevation.scss' as elevation;
|
|
4
|
+
@use '../../core/_length.scss' as *;
|
|
5
|
+
@use '../../core/_motion.scss' as motion;
|
|
6
|
+
@use '../../core/_type.scss' as type;
|
|
7
|
+
|
|
8
|
+
$icon-size: 24 !default;
|
|
9
|
+
$icon-margin-top: 12 !default;
|
|
10
|
+
$icon-to-label-baseline: 20 !default;
|
|
11
|
+
$icon-with-label-height: 72 !default;
|
|
12
|
+
|
|
13
|
+
.mdw-tab {
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.mdw-tab__list {
|
|
19
|
+
display: flex; // IE11 doesn't support grid-auto-columns
|
|
20
|
+
display: grid;
|
|
21
|
+
position: relative;
|
|
22
|
+
flex-direction: row;
|
|
23
|
+
|
|
24
|
+
grid-auto-columns: 1fr;
|
|
25
|
+
|
|
26
|
+
justify-content: flex-start;
|
|
27
|
+
|
|
28
|
+
-ms-overflow-style: none;
|
|
29
|
+
|
|
30
|
+
overflow-x: auto;
|
|
31
|
+
overflow-y: hidden;
|
|
32
|
+
scrollbar-width: none;
|
|
33
|
+
|
|
34
|
+
flex: none;
|
|
35
|
+
overscroll-behavior-x: none;
|
|
36
|
+
|
|
37
|
+
&::-webkit-scrollbar {
|
|
38
|
+
display: none;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&[mdw-scrollable] {
|
|
42
|
+
display: flex;
|
|
43
|
+
overflow-x: auto;
|
|
44
|
+
|
|
45
|
+
box-sizing: border-box;
|
|
46
|
+
|
|
47
|
+
&::before,
|
|
48
|
+
&::after {
|
|
49
|
+
|
|
50
|
+
min-width: dp(52);
|
|
51
|
+
// Ensures 52dp blank space at end
|
|
52
|
+
content: '';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
& > .mdw-tab__item {
|
|
56
|
+
min-width: dp(90);
|
|
57
|
+
max-width: 100%;
|
|
58
|
+
flex: none;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.mdw-tab__icon,
|
|
64
|
+
.mdw-tab__label,
|
|
65
|
+
.mdw-tab__indicator {
|
|
66
|
+
transition-duration: motion.$simpleDuration;
|
|
67
|
+
transition-timing-function: motion.$standardEasing;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.mdw-tab__indicator {
|
|
71
|
+
position: absolute;
|
|
72
|
+
right: auto;
|
|
73
|
+
bottom: 0;
|
|
74
|
+
left: 0;
|
|
75
|
+
|
|
76
|
+
height: dp(2);
|
|
77
|
+
width: 0;
|
|
78
|
+
width: dp(1000);
|
|
79
|
+
|
|
80
|
+
transition-property: none;
|
|
81
|
+
|
|
82
|
+
transform: translateX(0) scaleX(0);
|
|
83
|
+
transform-origin: 0 0 0;
|
|
84
|
+
|
|
85
|
+
background-color: currentColor;
|
|
86
|
+
|
|
87
|
+
&[mdw-animate] {
|
|
88
|
+
transition-property: transform;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.mdw-tab__item {
|
|
94
|
+
display: flex;
|
|
95
|
+
position: relative;
|
|
96
|
+
align-items: center;
|
|
97
|
+
flex-direction: column;
|
|
98
|
+
|
|
99
|
+
grid-row: 1;
|
|
100
|
+
overflow: hidden;
|
|
101
|
+
|
|
102
|
+
box-sizing: content-box;
|
|
103
|
+
min-height: dp(48); // Redundant but needed for IE11
|
|
104
|
+
flex: auto;
|
|
105
|
+
|
|
106
|
+
cursor: pointer;
|
|
107
|
+
-webkit-tap-highlight-color: transparent;
|
|
108
|
+
-moz-user-select: none;
|
|
109
|
+
-ms-user-select: none;
|
|
110
|
+
-webkit-user-select: none;
|
|
111
|
+
user-select: none;
|
|
112
|
+
|
|
113
|
+
z-index: 0;
|
|
114
|
+
|
|
115
|
+
border-radius: 0;
|
|
116
|
+
|
|
117
|
+
box-shadow: none;
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.mdw-tab__icon {
|
|
123
|
+
@include type.baselineToBottom($icon-to-label-baseline);
|
|
124
|
+
margin-top: dp($icon-margin-top);
|
|
125
|
+
margin-bottom: dp(-$icon-to-label-baseline);
|
|
126
|
+
|
|
127
|
+
transition-property: color;
|
|
128
|
+
|
|
129
|
+
pointer-events: none;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.mdw-tab__label {
|
|
133
|
+
@include type.addRules('button');
|
|
134
|
+
|
|
135
|
+
box-sizing: border-box;
|
|
136
|
+
margin-top: auto;
|
|
137
|
+
margin-bottom: auto;
|
|
138
|
+
padding: 0 dp(16);
|
|
139
|
+
|
|
140
|
+
transition-property: color;
|
|
141
|
+
|
|
142
|
+
pointer-events: none;
|
|
143
|
+
|
|
144
|
+
text-align: center;
|
|
145
|
+
|
|
146
|
+
.mdw-tab__icon ~ & {
|
|
147
|
+
@include type.baselineToTop($icon-to-label-baseline);
|
|
148
|
+
@include type.baselineToBottom($icon-with-label-height
|
|
149
|
+
- $icon-margin-top
|
|
150
|
+
- $icon-size
|
|
151
|
+
- $icon-to-label-baseline);
|
|
152
|
+
|
|
153
|
+
display: block;
|
|
154
|
+
|
|
155
|
+
min-height: 0;
|
|
156
|
+
margin: 0;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.mdw-tab__content {
|
|
161
|
+
display: flex;
|
|
162
|
+
position: relative;
|
|
163
|
+
align-items: stretch;
|
|
164
|
+
flex-direction: row;
|
|
165
|
+
|
|
166
|
+
// Hide scrollbar
|
|
167
|
+
-ms-overflow-style: none;
|
|
168
|
+
overflow-x: hidden;
|
|
169
|
+
overflow-x: scroll;
|
|
170
|
+
-webkit-overflow-scrolling: touch;
|
|
171
|
+
scroll-behavior: smooth;
|
|
172
|
+
|
|
173
|
+
// W3C standard
|
|
174
|
+
scroll-snap-type: x mandatory;
|
|
175
|
+
scrollbar-width: none;
|
|
176
|
+
|
|
177
|
+
flex-grow: 1;
|
|
178
|
+
|
|
179
|
+
// Snap
|
|
180
|
+
|
|
181
|
+
// Firefox
|
|
182
|
+
-webkit-scroll-snap-type-x: mandatory;
|
|
183
|
+
scroll-snap-type-x: mandatory;
|
|
184
|
+
-webkit-scroll-snap-points-x: repeat(100%);
|
|
185
|
+
scroll-snap-points-x: repeat(100%);
|
|
186
|
+
|
|
187
|
+
// Safari 9
|
|
188
|
+
|
|
189
|
+
// IE + Edge
|
|
190
|
+
-ms-scroll-snap-x: mandatory snapInterval(0%, 100%);
|
|
191
|
+
|
|
192
|
+
overscroll-behavior-x: none;
|
|
193
|
+
|
|
194
|
+
.mdw-tab[mdw-resize-stage] & {
|
|
195
|
+
scroll-behavior: auto;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
&::-webkit-scrollbar {
|
|
199
|
+
display: none;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.mdw-tab__panel {
|
|
204
|
+
scroll-snap-align: center;
|
|
205
|
+
|
|
206
|
+
min-width: 100%;
|
|
207
|
+
max-width: 100%;
|
|
208
|
+
flex-shrink: 0;
|
|
209
|
+
flex-basis: 100%;
|
|
210
|
+
|
|
211
|
+
will-change: visibility;
|
|
212
|
+
|
|
213
|
+
visibility: visible;
|
|
214
|
+
|
|
215
|
+
&[aria-hidden="true"] {
|
|
216
|
+
visibility: hidden;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
&[aria-expanded="false"] .mdw-tabs__panel__inactive-hide,
|
|
221
|
+
&[aria-expanded="true"] .mdw-tabs__panel__active-hide {
|
|
222
|
+
visibility: hidden;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
&[aria-expanded="false"] .mdw-tabs__panel__inactive-remove,
|
|
226
|
+
&[aria-expanded="true"] .mdw-tabs__panel__active-remove {
|
|
227
|
+
display: none;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.mdw-tab__content[mdw-no-scroll] {
|
|
233
|
+
overflow-x: hidden;
|
|
234
|
+
scroll-behavior: auto;
|
|
235
|
+
}
|
|
File without changes
|