@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
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {HTMLElement} element
|
|
3
|
-
* @param {MouseEvent|PointerEvent} event
|
|
4
|
-
* @return {void}
|
|
5
|
-
*/
|
|
6
|
-
function updateRipplePosition(element, event) {
|
|
7
|
-
if (!event.pointerType && !event.detail) {
|
|
8
|
-
// Ripple from center
|
|
9
|
-
element.style.setProperty('left', '0');
|
|
10
|
-
element.style.setProperty('top', '0');
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
const x = event.offsetX - (element.clientWidth / 2.0);
|
|
14
|
-
const y = event.offsetY - (element.clientHeight / 2.0);
|
|
15
|
-
element.style.setProperty('left', `${x}px`);
|
|
16
|
-
element.style.setProperty('top', `${y}px`);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
class TabItem {
|
|
20
|
-
/**
|
|
21
|
-
* @param {Element} element
|
|
22
|
-
*/
|
|
23
|
-
constructor(element) {
|
|
24
|
-
this.element = element;
|
|
25
|
-
const rippleElements = element.getElementsByClassName('mdw-ripple');
|
|
26
|
-
this.ripple = rippleElements && rippleElements[0];
|
|
27
|
-
if (!this.ripple) {
|
|
28
|
-
const ripple = document.createElement('div');
|
|
29
|
-
ripple.classList.add('mdw-ripple');
|
|
30
|
-
this.element.insertBefore(ripple, this.element.firstChild);
|
|
31
|
-
this.ripple = ripple;
|
|
32
|
-
}
|
|
33
|
-
this.element.setAttribute('mdw-js-ripple', '');
|
|
34
|
-
this.element.addEventListener('click', (event) => {
|
|
35
|
-
updateRipplePosition(this.ripple, event);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
class Tab {
|
|
41
|
-
/**
|
|
42
|
-
* @param {Element} element
|
|
43
|
-
*/
|
|
44
|
-
constructor(element) {
|
|
45
|
-
this.element = element;
|
|
46
|
-
this.inputs = element.getElementsByTagName('input');
|
|
47
|
-
this.items = element.getElementsByClassName('mdw-tab__item');
|
|
48
|
-
|
|
49
|
-
const indicatorElements = element.getElementsByClassName('mdw-tab__indicator');
|
|
50
|
-
this.indicator = indicatorElements && indicatorElements[0];
|
|
51
|
-
if (!this.indicator) {
|
|
52
|
-
const indicator = document.createElement('div');
|
|
53
|
-
indicator.classList.add('mdw-tab__indicator');
|
|
54
|
-
this.element.appendChild(indicator);
|
|
55
|
-
this.indicator = indicator;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
for (let i = 0; i < this.inputs.length; i += 1) {
|
|
59
|
-
const inputElement = this.inputs[i];
|
|
60
|
-
if (inputElement.checked) {
|
|
61
|
-
this.onInputChanged(inputElement);
|
|
62
|
-
}
|
|
63
|
-
inputElement.addEventListener('change', () => {
|
|
64
|
-
this.onInputChanged(inputElement);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
for (let i = 0; i < this.items.length; i += 1) {
|
|
69
|
-
const itemElement = this.items[i];
|
|
70
|
-
if (itemElement.hasAttribute('selected')) {
|
|
71
|
-
this.selectItem(itemElement);
|
|
72
|
-
}
|
|
73
|
-
itemElement.addEventListener('click', () => {
|
|
74
|
-
this.selectItem(itemElement);
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* @param {HTMLInputElement} inputElement
|
|
81
|
-
* @return {HTMLElement}
|
|
82
|
-
*/
|
|
83
|
-
static getItemForInput(inputElement) {
|
|
84
|
-
let itemElement;
|
|
85
|
-
if (inputElement.parentElement.classList.contains('mdw-tab__item')) {
|
|
86
|
-
itemElement = inputElement.parentElement;
|
|
87
|
-
}
|
|
88
|
-
if (inputElement.id) {
|
|
89
|
-
itemElement = document.querySelector(`label.mdw-tab__item[for="${inputElement.id}"]`);
|
|
90
|
-
}
|
|
91
|
-
return itemElement;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
static isRtl() {
|
|
95
|
-
const htmlElement = document.getElementsByTagName('html')[0];
|
|
96
|
-
if (htmlElement.hasAttribute('dir') && htmlElement.getAttribute('dir').toLowerCase() === 'rtl') {
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
if (!document.body.hasAttribute('dir')) {
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
return document.body.getAttribute('dir').toLowerCase() === 'rtl';
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* @param {HTMLElement} itemElement
|
|
107
|
-
* @return {boolean} changed
|
|
108
|
-
*/
|
|
109
|
-
selectItem(itemElement) {
|
|
110
|
-
let foundPreviousSelection = false;
|
|
111
|
-
let foundTarget = false;
|
|
112
|
-
let indicatorUpdated = false;
|
|
113
|
-
let left = 0;
|
|
114
|
-
const isRtl = Tab.isRtl();
|
|
115
|
-
for (let i = 0; i < this.items.length; i += 1) {
|
|
116
|
-
const index = isRtl ? this.items.length - 1 -i : i;
|
|
117
|
-
const item = this.items.item(index);
|
|
118
|
-
if (item.hasAttribute('selected')) {
|
|
119
|
-
foundPreviousSelection = true;
|
|
120
|
-
item.removeAttribute('selected');
|
|
121
|
-
if (!indicatorUpdated) {
|
|
122
|
-
this.indicator.setAttribute('mdw-direction', 'forwards');
|
|
123
|
-
indicatorUpdated = true;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (item === itemElement) {
|
|
127
|
-
foundTarget = true;
|
|
128
|
-
itemElement.setAttribute('selected', '');
|
|
129
|
-
if (!indicatorUpdated) {
|
|
130
|
-
this.indicator.setAttribute('mdw-direction', 'backwards');
|
|
131
|
-
indicatorUpdated = true;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
if (!foundTarget) {
|
|
135
|
-
left += item.clientWidth;
|
|
136
|
-
}
|
|
137
|
-
if (foundTarget && foundPreviousSelection) {
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (!this.element.clientWidth) {
|
|
143
|
-
this.indicator.style.setProperty('left', '');
|
|
144
|
-
this.indicator.style.setProperty('right', '');
|
|
145
|
-
this.indicator.removeAttribute('mdw-js-indicator');
|
|
146
|
-
// use CSS styling fallback
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
const right = this.element.clientWidth - left - itemElement.clientWidth;
|
|
150
|
-
if (!this.indicator.hasAttribute('mdw-js-indicator')) {
|
|
151
|
-
this.indicator.setAttribute('mdw-js-indicator', '');
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
this.indicator.style.setProperty('left', `${left}px`);
|
|
155
|
-
this.indicator.style.setProperty('right', `${right}px`);
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* @param {HTMLInputElement} inputElement
|
|
161
|
-
* @return {void}
|
|
162
|
-
*/
|
|
163
|
-
onInputChanged(inputElement) {
|
|
164
|
-
const itemElement = Tab.getItemForInput(inputElement);
|
|
165
|
-
if (itemElement) {
|
|
166
|
-
this.selectItem(itemElement);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export {
|
|
172
|
-
Tab,
|
|
173
|
-
TabItem,
|
|
174
|
-
};
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
// https://material.io/guidelines/components/tabs.html#
|
|
2
|
-
|
|
3
|
-
@import '../../common/functions.scss';
|
|
4
|
-
@import '../../common/motion.scss';
|
|
5
|
-
|
|
6
|
-
.mdw-tab {
|
|
7
|
-
min-height: dp(48);
|
|
8
|
-
overflow-y: hidden;
|
|
9
|
-
position: relative;
|
|
10
|
-
display:flex;
|
|
11
|
-
width: 100%;
|
|
12
|
-
justify-content: center;
|
|
13
|
-
flex-direction:row;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.mdw-tab__indicator {
|
|
17
|
-
position: absolute;
|
|
18
|
-
bottom: 0;
|
|
19
|
-
height: 2px;
|
|
20
|
-
width: 0;
|
|
21
|
-
left: 0;
|
|
22
|
-
right: auto;
|
|
23
|
-
[dir=rtl] & {
|
|
24
|
-
right: 0;
|
|
25
|
-
left: auto;
|
|
26
|
-
}
|
|
27
|
-
background-color: currentColor;
|
|
28
|
-
transition-property: transform;
|
|
29
|
-
transition-timing-function: $motion-easing-standard;
|
|
30
|
-
transition-duration: $motion-duration-desktop-default;
|
|
31
|
-
@include allHandsets {
|
|
32
|
-
transition-duration: $motion-duration-mobile-default;
|
|
33
|
-
}
|
|
34
|
-
@include allTablets {
|
|
35
|
-
transition-duration: $motion-duration-tablet-default;
|
|
36
|
-
}
|
|
37
|
-
// Indicator width
|
|
38
|
-
// Element position = 2 * number of input elements + 1 (itself)
|
|
39
|
-
// Width = 100% / number of input elements
|
|
40
|
-
@for $j from 1 through 8 {
|
|
41
|
-
// Fallback for 0 width element with JS indicator
|
|
42
|
-
&:nth-child(#{$j + 1}):not([mdw-js-indicator]) {
|
|
43
|
-
width: #{100% / $j};
|
|
44
|
-
}
|
|
45
|
-
input ~ &:nth-child(#{($j * 2) + 1}):not([mdw-js-indicator]) {
|
|
46
|
-
width: #{100% / $j};
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
// Indicator offset
|
|
50
|
-
@for $i from 1 through 8 {
|
|
51
|
-
input:nth-of-type(#{$i}):checked ~ &:not([mdw-js-indicator]) {
|
|
52
|
-
transform: translateX(#{100% * ($i - 1)});
|
|
53
|
-
}
|
|
54
|
-
[dir=rtl] input:nth-of-type(#{$i}):checked ~ &:not([mdw-js-indicator]) {
|
|
55
|
-
transform: translateX(#{-100% * ($i - 1)});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
&[mdw-js-indicator] {
|
|
60
|
-
width: auto;
|
|
61
|
-
// Stretch animation
|
|
62
|
-
transition-property: left, right;
|
|
63
|
-
&[mdw-direction="backwards"] {
|
|
64
|
-
transition-property: right, left;
|
|
65
|
-
}
|
|
66
|
-
transition-delay: $motion-duration-desktop-default / 2, 0ms;
|
|
67
|
-
transition-duration: $motion-duration-desktop-default / 2;
|
|
68
|
-
@include allHandsets {
|
|
69
|
-
transition-delay: $motion-duration-mobile-default / 2, 0ms;
|
|
70
|
-
transition-duration: $motion-duration-mobile-default / 2;
|
|
71
|
-
}
|
|
72
|
-
@include allTablets {
|
|
73
|
-
transition-delay: $motion-duration-tablet-default / 2, 0ms;
|
|
74
|
-
transition-duration: $motion-duration-tablet-default / 2;
|
|
75
|
-
}
|
|
76
|
-
transform: none;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.mdw-tab__item {
|
|
81
|
-
min-height: dp(48); // Redundant but needed for IE11
|
|
82
|
-
position: relative;
|
|
83
|
-
display: flex;
|
|
84
|
-
flex-grow: 1;
|
|
85
|
-
flex-basis: 0;
|
|
86
|
-
flex-direction: column;
|
|
87
|
-
align-items: center;
|
|
88
|
-
justify-content: flex-end;
|
|
89
|
-
box-shadow: none;
|
|
90
|
-
box-sizing: content-box;
|
|
91
|
-
border-radius: 0;
|
|
92
|
-
z-index: 0;
|
|
93
|
-
overflow: hidden;
|
|
94
|
-
cursor: pointer;
|
|
95
|
-
color: black;
|
|
96
|
-
user-select: none;
|
|
97
|
-
-webkit-tap-highlight-color: transparent;
|
|
98
|
-
input:checked + & {
|
|
99
|
-
cursor: default;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
> .mdw-ripple {
|
|
103
|
-
@include mdw-ripple__container;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
& > .mdw-ripple > .mdw-ripple__inner,
|
|
107
|
-
&::after {
|
|
108
|
-
@include mdw-ripple__inner;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
& > .mdw-ripple:active > .mdw-ripple__inner,
|
|
112
|
-
&:active::after {
|
|
113
|
-
@include mdw-ripple__active;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
&[mdw-ripple] {
|
|
117
|
-
overflow: visible;
|
|
118
|
-
&::after {
|
|
119
|
-
// If using custom ripple, destroy ::after object
|
|
120
|
-
content: none;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.mdw-tab__icon {
|
|
126
|
-
pointer-events: none;
|
|
127
|
-
transition-property: color;
|
|
128
|
-
transition-duration: 200ms;
|
|
129
|
-
transition-timing-function: $motion-easing-standard;
|
|
130
|
-
margin-top: 12px;
|
|
131
|
-
&:last-child {
|
|
132
|
-
margin-bottom: 12px;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
.mdw-tab__label {
|
|
137
|
-
display: block;
|
|
138
|
-
text-align: center;
|
|
139
|
-
|
|
140
|
-
pointer-events: none;
|
|
141
|
-
min-width: dp(80);
|
|
142
|
-
max-width: dp(168);
|
|
143
|
-
padding-left: dp(12);
|
|
144
|
-
padding-right: dp(12);
|
|
145
|
-
transition-property: color;
|
|
146
|
-
transition-duration: 200ms;
|
|
147
|
-
transition-timing-function: $motion-easing-standard;
|
|
148
|
-
text-overflow: ellipsis;
|
|
149
|
-
white-space: nowrap;
|
|
150
|
-
min-height: 1em; // Prevents stretching when using larger fonts
|
|
151
|
-
height: auto;
|
|
152
|
-
font-size: sp(14);
|
|
153
|
-
text-transform: uppercase;
|
|
154
|
-
font-weight: $font-weight-medium;
|
|
155
|
-
|
|
156
|
-
// 10dp top padding
|
|
157
|
-
&::before {
|
|
158
|
-
content: "\200D"; // ‍
|
|
159
|
-
display: inline-block;
|
|
160
|
-
margin-top: dp(10);
|
|
161
|
-
line-height: 1;
|
|
162
|
-
vertical-align: text-bottom;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// 20dp bottom padding from baseline
|
|
166
|
-
&::after {
|
|
167
|
-
content: "\200D"; // ‍
|
|
168
|
-
display: inline-block;
|
|
169
|
-
line-height: 1;
|
|
170
|
-
margin-bottom: dp(20);
|
|
171
|
-
vertical-align: text-top;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
.mdw-tab__icon ~ & {
|
|
175
|
-
&::after {
|
|
176
|
-
content: "\200D"; // ‍
|
|
177
|
-
display: inline-block;
|
|
178
|
-
line-height: 1;
|
|
179
|
-
margin-bottom: dp(16);
|
|
180
|
-
vertical-align: text-top;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
.mdw-tab input {
|
|
186
|
-
// Using `display: none` breaks keyboard navigation
|
|
187
|
-
opacity: 0;
|
|
188
|
-
height: 0;
|
|
189
|
-
width: 0;
|
|
190
|
-
margin: 0;
|
|
191
|
-
padding: 0;
|
|
192
|
-
pointer-events: none;
|
|
193
|
-
position: absolute;
|
|
194
|
-
display: inline;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.mdw-tab[mdw-theme-color] {
|
|
198
|
-
.mdw-tab__item,
|
|
199
|
-
.mdw-tab__indicator {
|
|
200
|
-
color: inherit;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
@import '../../common/functions.scss';
|
|
2
|
-
@import '../../common/mixins.scss';
|
|
3
|
-
|
|
4
|
-
$tabColors: (
|
|
5
|
-
active-color: (inherit, (#fff, 1.00)),
|
|
6
|
-
inactive-color: ((#000, 0.54), (#fff, 0.50)),
|
|
7
|
-
indicator-color: ((#000, 1.00), (#fff, 1.00)),
|
|
8
|
-
ripple-opacity: ( 0.26 , 0.30,)
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
@function tabThemeValue($key, $type, $theme) {
|
|
12
|
-
@return themeValue('tab', $tabColors, $key, $type, $theme);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
@mixin tabThemeVariables($color, $lightness) {
|
|
16
|
-
@include themeVariables('tab', $tabColors, $color, $lightness);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Vary by contrast
|
|
20
|
-
@mixin tabContrastRules($type: 'var', $theme: null) {
|
|
21
|
-
.mdw-tab__icon,
|
|
22
|
-
.mdw-tab__label {
|
|
23
|
-
color: tabThemeValue("inactive-color", $type, $theme);
|
|
24
|
-
}
|
|
25
|
-
.mdw-tab__indicator {
|
|
26
|
-
color: tabThemeValue("indicator-color", $type, $theme);
|
|
27
|
-
}
|
|
28
|
-
input:checked ~ .mdw-tab__icon,
|
|
29
|
-
input:checked ~ .mdw-tab__label,
|
|
30
|
-
.mdw-tab__item[selected] > .mdw-tab__icon,
|
|
31
|
-
.mdw-tab__item[selected] > .mdw-tab__label,
|
|
32
|
-
input:checked + .mdw-tab__item > .mdw-tab__icon,
|
|
33
|
-
input:checked + .mdw-tab__item > .mdw-tab__label {
|
|
34
|
-
color: tabThemeValue("active-color", $type, $theme);
|
|
35
|
-
}
|
|
36
|
-
.mdw-tab__item {
|
|
37
|
-
& > .mdw-ripple > .mdw-ripple__inner,
|
|
38
|
-
&:after {
|
|
39
|
-
color: tabThemeValue("active-color", $type, $theme);
|
|
40
|
-
opacity: tabThemeValue("ripple-opacity", $type, $theme);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
class TextField {
|
|
2
|
-
/**
|
|
3
|
-
* @param {HTMLElement} element
|
|
4
|
-
*/
|
|
5
|
-
constructor(element) {
|
|
6
|
-
this.element = element;
|
|
7
|
-
/** @type {HTMLInputElement|HTMLTextAreaElement|HTMLSelectElement} */
|
|
8
|
-
this.input = element.querySelector('.mdw-textfield__input');
|
|
9
|
-
if (this.input) {
|
|
10
|
-
if (this.input instanceof HTMLTextAreaElement && this.element.hasAttribute('mdw-multiline')) {
|
|
11
|
-
this.input.addEventListener('input', () => {
|
|
12
|
-
this.updateTextAreaSize();
|
|
13
|
-
});
|
|
14
|
-
this.updateTextAreaSize();
|
|
15
|
-
}
|
|
16
|
-
this.input.addEventListener('input', () => {
|
|
17
|
-
this.updateInputEmptyState();
|
|
18
|
-
});
|
|
19
|
-
this.updateInputEmptyState();
|
|
20
|
-
}
|
|
21
|
-
this.border = element.querySelector('.mdw-textfield__border-line');
|
|
22
|
-
if (!this.border) {
|
|
23
|
-
const border = document.createElement('div');
|
|
24
|
-
border.classList.add('.mdw-textfield__border-line');
|
|
25
|
-
element.appendChild(border);
|
|
26
|
-
this.border = border;
|
|
27
|
-
}
|
|
28
|
-
const rippleElements = this.border.getElementsByClassName('mdw-ripple');
|
|
29
|
-
this.ripple = rippleElements && rippleElements[0];
|
|
30
|
-
if (!this.ripple) {
|
|
31
|
-
const ripple = document.createElement('div');
|
|
32
|
-
ripple.classList.add('mdw-ripple');
|
|
33
|
-
this.border.appendChild(ripple);
|
|
34
|
-
this.ripple = ripple;
|
|
35
|
-
}
|
|
36
|
-
const innerRippleElements = this.ripple.getElementsByClassName('mdw-ripple__inner');
|
|
37
|
-
this.rippleInner = innerRippleElements && innerRippleElements[0];
|
|
38
|
-
if (!this.rippleInner) {
|
|
39
|
-
const rippleInner = document.createElement('div');
|
|
40
|
-
rippleInner.classList.add('mdw-ripple__inner');
|
|
41
|
-
this.ripple.appendChild(rippleInner);
|
|
42
|
-
this.rippleInner = rippleInner;
|
|
43
|
-
}
|
|
44
|
-
this.element.setAttribute('mdw-ripple', '');
|
|
45
|
-
this.border.addEventListener('click', (event) => {
|
|
46
|
-
this.updateRipplePosition(event);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** @return {void} */
|
|
51
|
-
updateInputEmptyState() {
|
|
52
|
-
const attributeName = 'mdw-value-empty';
|
|
53
|
-
if (this.input.value) {
|
|
54
|
-
if (this.element.hasAttribute(attributeName)) {
|
|
55
|
-
this.element.removeAttribute(attributeName);
|
|
56
|
-
}
|
|
57
|
-
} else if (!this.element.hasAttribute(attributeName)) {
|
|
58
|
-
this.element.setAttribute('mdw-value-empty', '');
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/** @return {number} Single row height */
|
|
63
|
-
updateTextAreaSize() {
|
|
64
|
-
const previousRowsValue = this.input.getAttribute('rows');
|
|
65
|
-
this.input.setAttribute('rows', '1');
|
|
66
|
-
const { height, paddingTop } = window.getComputedStyle(this.input);
|
|
67
|
-
if (height === 'auto') {
|
|
68
|
-
this.input.setAttribute('rows', previousRowsValue);
|
|
69
|
-
return -1;
|
|
70
|
-
}
|
|
71
|
-
const heightPx = parseInt(height.replace('px', ''), 10);
|
|
72
|
-
const paddingTopPx = parseInt(paddingTop.replace('px', ''), 10);
|
|
73
|
-
this.input.setAttribute('rows', Math.floor((this.input.scrollHeight - paddingTopPx) / heightPx).toString());
|
|
74
|
-
return heightPx;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* @param {MouseEvent|PointerEvent} event
|
|
79
|
-
* @return {void}
|
|
80
|
-
*/
|
|
81
|
-
updateRipplePosition(event) {
|
|
82
|
-
if (event.target !== this.border && event.target !== this.ripple) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
if ((!event.pointerType && !event.detail)) {
|
|
86
|
-
// Ripple from center
|
|
87
|
-
this.rippleInner.style.removeProperty('left');
|
|
88
|
-
this.rippleInner.style.removeProperty('top');
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const x = event.offsetX;
|
|
92
|
-
const y = event.offsetY;
|
|
93
|
-
this.rippleInner.style.setProperty('left', `${x}px`);
|
|
94
|
-
this.rippleInner.style.setProperty('top', `${y}px`);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* @return {string|Date|number}
|
|
99
|
-
*/
|
|
100
|
-
get value() {
|
|
101
|
-
if ((this.input instanceof HTMLTextAreaElement) || (this.input instanceof HTMLSelectElement)) {
|
|
102
|
-
return this.value;
|
|
103
|
-
}
|
|
104
|
-
const type = this.input.hasAttribute('type') && this.input.getAttribute('type').toLowerCase();
|
|
105
|
-
switch (type) {
|
|
106
|
-
case 'date':
|
|
107
|
-
case 'time':
|
|
108
|
-
return this.input.valueAsDate;
|
|
109
|
-
case 'datetime-local':
|
|
110
|
-
case 'number':
|
|
111
|
-
case 'range':
|
|
112
|
-
return this.input.valueAsNumber;
|
|
113
|
-
default:
|
|
114
|
-
return this.input.value;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/** @param {(string|Date|number)=} value */
|
|
119
|
-
set value(value) {
|
|
120
|
-
if (value == null) {
|
|
121
|
-
this.input.value = null;
|
|
122
|
-
} else if (this.input instanceof HTMLTextAreaElement
|
|
123
|
-
|| this.input instanceof HTMLSelectElement) {
|
|
124
|
-
if (value instanceof Date) {
|
|
125
|
-
this.input.value = value.toString();
|
|
126
|
-
} else if (typeof value === 'string') {
|
|
127
|
-
this.input.value = value;
|
|
128
|
-
} else {
|
|
129
|
-
this.input.value = value.toString(10);
|
|
130
|
-
}
|
|
131
|
-
} else if (value instanceof Date) {
|
|
132
|
-
const type = this.input.hasAttribute('type') && this.input.getAttribute('type').toLowerCase();
|
|
133
|
-
switch (type) {
|
|
134
|
-
case 'date':
|
|
135
|
-
case 'time':
|
|
136
|
-
case 'datetime-local':
|
|
137
|
-
this.input.valueAsDate = value;
|
|
138
|
-
break;
|
|
139
|
-
case 'number':
|
|
140
|
-
case 'range':
|
|
141
|
-
this.input.valueAsNumber = value.getTime();
|
|
142
|
-
break;
|
|
143
|
-
default:
|
|
144
|
-
this.input.value = value.toString();
|
|
145
|
-
}
|
|
146
|
-
} else if (typeof value === 'string') {
|
|
147
|
-
this.input.value = value;
|
|
148
|
-
} else {
|
|
149
|
-
const type = this.input.hasAttribute('type') && this.input.getAttribute('type').toLowerCase();
|
|
150
|
-
switch (type) {
|
|
151
|
-
case 'date':
|
|
152
|
-
case 'time':
|
|
153
|
-
case 'datetime-local':
|
|
154
|
-
case 'number':
|
|
155
|
-
case 'range':
|
|
156
|
-
this.input.valueAsNumber = value;
|
|
157
|
-
break;
|
|
158
|
-
default:
|
|
159
|
-
this.input.value = value.toString();
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
this.updateInputEmptyState();
|
|
163
|
-
this.updateTextAreaSize();
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export {
|
|
168
|
-
TextField,
|
|
169
|
-
};
|