@shortfuse/materialdesignweb 0.2.0 → 0.5.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 +2 -1
- package/.eslintrc.json +188 -30
- package/.stylelintrc.json +643 -2
- package/.vscode/launch.json +20 -5
- package/.vscode/settings.json +3 -0
- package/CHANGELOG.md +36 -0
- package/README.md +82 -2
- package/adapters/datatable/column.js +176 -0
- package/adapters/datatable/index.js +253 -437
- package/adapters/dom/index.js +586 -0
- package/adapters/list/index.js +36 -113
- package/adapters/search/index.js +153 -180
- package/components/appbar/_spec.scss +165 -0
- package/components/appbar/_theme.scss +0 -0
- package/components/appbar/index.scss +2 -0
- package/components/banner/_spec.scss +83 -0
- package/components/banner/_theme.scss +0 -0
- package/components/banner/index.scss +2 -0
- package/components/bottomnav/README.md +4 -4
- package/components/bottomnav/_spec.scss +149 -0
- package/components/bottomnav/_theme.scss +0 -0
- package/components/bottomnav/index.js +100 -120
- package/components/bottomnav/index.scss +2 -0
- package/components/bottomnav/item.js +88 -0
- package/components/button/README.md +16 -22
- package/components/button/_spec.scss +162 -0
- package/components/button/_theme.scss +42 -0
- package/components/button/index.eta +32 -0
- package/components/button/index.js +37 -48
- package/components/button/index.pug +18 -0
- package/components/button/index.scss +2 -0
- package/components/card/_spec.scss +241 -0
- package/components/card/_theme.scss +0 -0
- package/components/card/index.scss +2 -0
- package/components/chip/_spec.scss +111 -0
- package/components/chip/_theme.scss +105 -0
- package/components/chip/index.js +23 -0
- package/components/chip/index.scss +2 -0
- package/components/chip/item.js +20 -0
- package/components/datatable/_spec.scss +225 -0
- package/components/datatable/_theme.scss +128 -0
- package/components/datatable/cell.js +44 -0
- package/components/datatable/columnheader.js +46 -0
- package/components/datatable/index.js +339 -443
- package/components/datatable/index.scss +2 -0
- package/components/datatable/row.js +48 -0
- package/components/datatable/rowheader.js +18 -0
- package/components/dialog/_spec.scss +203 -0
- package/components/dialog/_theme.scss +7 -0
- package/components/dialog/index.js +512 -437
- package/components/dialog/index.scss +2 -0
- package/components/divider/_spec.scss +11 -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/{style.scss → _spec.scss} +104 -79
- package/components/fab/_theme.scss +0 -0
- package/components/fab/index.js +85 -79
- package/components/fab/index.scss +2 -0
- package/components/grid/_spec.scss +169 -0
- package/components/grid/_theme.scss +0 -0
- package/components/grid/index.scss +2 -0
- package/components/layout/_mixins.scss +11 -0
- package/components/layout/_spec.scss +916 -0
- package/components/layout/_theme.scss +19 -0
- package/components/layout/index.js +454 -0
- package/components/layout/index.scss +2 -0
- package/components/list/_spec.scss +363 -0
- package/components/list/_theme.scss +102 -0
- package/components/list/content.js +106 -0
- package/components/list/index.js +234 -79
- package/components/list/index.scss +2 -0
- package/components/list/item.js +167 -0
- package/components/list/secondary.js +45 -0
- package/components/menu/_spec.scss +329 -0
- package/components/menu/_theme.scss +0 -0
- package/components/menu/index.js +636 -651
- package/components/menu/index.scss +2 -0
- package/components/menu/item.js +231 -0
- package/components/progress/_spec.scss +156 -0
- package/components/progress/_theme.scss +0 -0
- package/components/progress/index.js +29 -13
- package/components/progress/index.scss +2 -0
- package/components/selection/_spec.scss +376 -0
- package/components/selection/_theme.scss +134 -0
- package/components/selection/index.eta +60 -0
- package/components/selection/index.js +70 -0
- package/components/selection/index.pug +30 -0
- package/components/selection/index.scss +2 -0
- package/components/selection/input.js +54 -0
- package/components/selection/radiogroup.js +40 -0
- package/components/slider/{style.scss → _spec.scss} +31 -34
- package/components/slider/_theme.scss +0 -0
- package/components/slider/index.scss +2 -0
- package/components/snackbar/_spec.scss +150 -0
- package/components/snackbar/_theme.scss +0 -0
- package/components/snackbar/index.js +293 -206
- package/components/snackbar/index.scss +2 -0
- package/components/tab/_spec.scss +220 -0
- package/components/tab/_theme.scss +0 -0
- package/components/tab/content.js +210 -0
- package/components/tab/index.js +229 -213
- package/components/tab/index.scss +2 -0
- package/components/tab/item.js +88 -0
- package/components/tab/list.js +196 -0
- package/components/tab/panel.js +54 -0
- package/components/textfield/README.md +4 -4
- package/components/textfield/_spec.scss +763 -0
- package/components/textfield/_theme.scss +264 -0
- package/components/textfield/index.eta +74 -0
- package/components/textfield/index.js +132 -138
- package/components/textfield/index.pug +30 -0
- package/components/textfield/index.scss +2 -0
- package/components/tooltip/_spec.scss +185 -0
- package/components/tooltip/_theme.scss +0 -0
- package/components/tooltip/index.scss +2 -0
- package/components/type/_spec.scss +227 -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 +78 -0
- package/core/_length.scss +8 -0
- package/core/_motion.scss +31 -0
- package/core/_platform.scss +12 -0
- package/core/_type.scss +128 -0
- package/core/aria/attributes.js +141 -0
- package/core/aria/button.js +49 -0
- package/core/aria/keyboard.js +92 -0
- package/core/aria/rovingtabindex.js +175 -0
- package/core/aria/tab.js +59 -0
- package/core/document/index.js +39 -0
- package/core/dom.js +180 -0
- package/core/overlay/_spec.scss +28 -0
- package/core/overlay/_theme.scss +147 -0
- package/core/overlay/index.js +95 -0
- package/core/overlay/index.scss +2 -0
- package/core/ripple/_spec.scss +196 -0
- package/core/ripple/_theme.scss +20 -0
- package/core/ripple/index.js +286 -0
- package/core/ripple/index.scss +2 -0
- package/core/theme/_aliases.scss +15 -0
- package/core/theme/_config.scss +8 -0
- package/core/theme/_functions.scss +22 -0
- package/{components/theming/palettes.scss → core/theme/_palettes.scss} +173 -151
- package/core/theme/_spec.scss +0 -0
- package/core/theme/_theme.scss +268 -0
- package/core/theme/index.js +50 -0
- package/core/theme/index.scss +4 -0
- package/core/throttler.js +42 -0
- package/core/transition/index.js +465 -0
- package/docs/_flex.scss +28 -0
- package/docs/_menuoptions.js +183 -0
- package/docs/_partials/_androidnavbar.eta +5 -0
- package/docs/_partials/_androidstatusbar.eta +13 -0
- package/docs/_partials/_appbar.eta +27 -0
- package/docs/_partials/_buttontest.eta +31 -0
- package/docs/_partials/_header.eta +146 -0
- package/docs/_partials/_navlistitem.eta +16 -0
- package/docs/_partials/_target.eta +1 -0
- package/docs/_sample-utils.js +88 -0
- package/docs/{src/storage.js → _storage.js} +0 -0
- package/docs/docs.scss +331 -0
- package/docs/framework.scss +26 -0
- package/docs/index.eta +12 -0
- package/docs/index.js +7 -0
- package/docs/pages/appbar.eta +108 -0
- package/docs/pages/appbar.js +0 -0
- package/docs/pages/bottomnav.eta +188 -0
- package/docs/pages/bottomnav.js +118 -0
- package/docs/pages/button.eta +124 -0
- package/docs/pages/button.js +224 -0
- package/docs/pages/card.eta +90 -0
- package/docs/pages/card.js +175 -0
- package/docs/pages/chip.eta +122 -0
- package/docs/pages/chip.js +80 -0
- package/docs/pages/color.eta +143 -0
- package/docs/pages/color.js +261 -0
- package/docs/pages/datatable.eta +323 -0
- package/docs/pages/datatable.js +160 -0
- package/docs/pages/dialog.eta +184 -0
- package/docs/{src/components → pages}/dialog.js +35 -48
- package/docs/pages/dom.eta +26 -0
- package/docs/pages/dom.js +140 -0
- package/docs/pages/elevation.eta +35 -0
- package/docs/pages/elevation.js +0 -0
- package/docs/pages/fab.eta +99 -0
- package/docs/{src/components → pages}/fab.js +6 -13
- package/docs/pages/grid.eta +135 -0
- package/docs/pages/grid.js +128 -0
- package/docs/pages/layout.eta +8 -0
- package/docs/pages/layout.js +0 -0
- package/docs/pages/list.eta +465 -0
- package/docs/pages/list.js +8 -0
- package/docs/pages/menu.eta +274 -0
- package/docs/{src/components → pages}/menu.js +26 -42
- package/docs/pages/overlay.eta +69 -0
- package/docs/pages/overlay.js +3 -0
- package/docs/pages/progress.eta +23 -0
- package/docs/{src/components → pages}/progress.js +2 -4
- package/docs/pages/ripple.eta +27 -0
- package/docs/pages/ripple.js +3 -0
- package/docs/pages/search.eta +242 -0
- package/docs/pages/search.js +226 -0
- package/docs/pages/selection.eta +107 -0
- package/docs/pages/selection.js +12 -0
- package/docs/pages/slider.eta +23 -0
- package/docs/pages/slider.js +0 -0
- package/docs/pages/snackbar.eta +83 -0
- package/docs/{src/components → pages}/snackbar.js +31 -36
- package/docs/pages/tab.eta +407 -0
- package/docs/pages/tab.js +152 -0
- package/docs/pages/textfield.eta +487 -0
- package/docs/{src/components → pages}/textfield.js +41 -45
- package/docs/pages/tooltip.eta +92 -0
- package/docs/pages/tooltip.js +0 -0
- package/docs/pages/transition.eta +117 -0
- package/docs/pages/transition.js +52 -0
- package/docs/pages/type.eta +31 -0
- package/docs/pages/type.js +0 -0
- package/docs/postrender.js +41 -0
- package/docs/prerender.js +16 -0
- package/docs/pwa/_dialogs.eta +143 -0
- package/docs/pwa/_menus.eta +16 -0
- package/docs/pwa/pwa-prerender.js +3 -0
- package/docs/pwa/pwa.eta +478 -0
- package/docs/pwa/pwa.js +298 -0
- package/docs/pwa/pwa.scss +31 -0
- package/docs/themes/theme-colored.scss +15 -0
- package/docs/themes/theme-default.scss +3 -0
- package/index.scss +27 -0
- package/jsconfig.json +8 -2
- package/package.json +54 -27
- package/scripts/deploy-docs.sh +9 -0
- package/templates/index.eta +2 -0
- package/templates/index.pug +3 -0
- package/tsconfig.json +16 -0
- package/utils/function.js +3 -0
- package/webpack.config.js +224 -68
- package/_index.scss +0 -4
- package/components/all-components.scss +0 -21
- package/components/bottomnav/style.scss +0 -190
- package/components/bottomnav/theming.scss +0 -76
- package/components/button/style.scss +0 -315
- package/components/button/theming.scss +0 -134
- package/components/card/style.scss +0 -175
- package/components/card/theming.scss +0 -43
- package/components/common/dom.js +0 -51
- package/components/common/functions.scss +0 -174
- package/components/common/mixins.scss +0 -122
- package/components/common/motion.scss +0 -36
- package/components/common/type.scss +0 -104
- package/components/common/variables.scss +0 -46
- package/components/datatable/style.scss +0 -257
- package/components/datatable/theming.scss +0 -119
- package/components/dialog/style.scss +0 -159
- package/components/dialog/theming.scss +0 -29
- package/components/divider/style.scss +0 -7
- package/components/divider/theming.scss +0 -20
- package/components/elevation/style.scss +0 -32
- package/components/layout/style.scss +0 -223
- package/components/list/style.scss +0 -358
- package/components/list/theming.scss +0 -83
- package/components/menu/style.scss +0 -280
- package/components/menu/theming.scss +0 -80
- package/components/navdrawer/index.js +0 -200
- package/components/navdrawer/style.scss +0 -595
- package/components/navdrawer/theming.scss +0 -62
- package/components/progress/style.scss +0 -136
- package/components/ripple/index.js +0 -63
- package/components/ripple/ripple.scss +0 -122
- package/components/selection/style.scss +0 -320
- package/components/selection/theming.scss +0 -98
- package/components/snackbar/style.scss +0 -212
- package/components/switch/style.scss +0 -3
- package/components/tab/style.scss +0 -275
- package/components/tab/theming.scss +0 -34
- package/components/template/theming.scss +0 -31
- package/components/textfield/style.scss +0 -795
- package/components/textfield/theming.scss +0 -256
- package/components/theming/globals.scss +0 -25
- package/components/theming/theming.scss +0 -559
- package/components/toolbar/style.scss +0 -190
- package/components/toolbar/theming.scss +0 -32
- package/components/tooltip/style.scss +0 -135
- package/components/type/style.scss +0 -167
- package/components/type/theming.scss +0 -25
- 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/components.min.css +0 -1
- package/docs/components.min.js +0 -2
- package/docs/components.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/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/index.html +0 -1
- package/docs/index.min.js +0 -2
- package/docs/index.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/navdrawer.html +0 -1
- package/docs/navdrawer.min.js +0 -2
- package/docs/navdrawer.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/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/src/components/bottomnav.js +0 -16
- package/docs/src/components/bottomnav.pug +0 -112
- package/docs/src/components/button.js +0 -156
- package/docs/src/components/button.pug +0 -194
- package/docs/src/components/card.js +0 -136
- package/docs/src/components/card.pug +0 -133
- package/docs/src/components/datatable.js +0 -183
- package/docs/src/components/datatable.pug +0 -324
- package/docs/src/components/dialog.pug +0 -138
- package/docs/src/components/elevation.js +0 -3
- package/docs/src/components/elevation.pug +0 -17
- package/docs/src/components/fab.pug +0 -84
- package/docs/src/components/layout.js +0 -116
- package/docs/src/components/layout.pug +0 -104
- package/docs/src/components/list.js +0 -15
- package/docs/src/components/list.pug +0 -293
- package/docs/src/components/menu.pug +0 -292
- package/docs/src/components/navdrawer.js +0 -112
- package/docs/src/components/navdrawer.pug +0 -113
- package/docs/src/components/progress.pug +0 -17
- package/docs/src/components/search.js +0 -206
- package/docs/src/components/search.pug +0 -149
- package/docs/src/components/selection.js +0 -6
- package/docs/src/components/selection.pug +0 -116
- package/docs/src/components/slider.js +0 -3
- package/docs/src/components/slider.pug +0 -19
- package/docs/src/components/snackbar.pug +0 -145
- package/docs/src/components/tab.js +0 -137
- package/docs/src/components/tab.pug +0 -329
- package/docs/src/components/textfield.pug +0 -416
- package/docs/src/components/toolbar.js +0 -6
- package/docs/src/components/toolbar.pug +0 -86
- package/docs/src/components/tooltip.js +0 -6
- package/docs/src/components/tooltip.pug +0 -76
- package/docs/src/components/type.js +0 -6
- package/docs/src/components/type.pug +0 -34
- package/docs/src/components.scss +0 -1
- package/docs/src/docs.scss +0 -284
- package/docs/src/index.js +0 -3
- package/docs/src/index.pug +0 -6
- package/docs/src/menuoptions.js +0 -136
- package/docs/src/mixins.pug +0 -139
- package/docs/src/prerender.js +0 -26
- package/docs/src/sample-utils.js +0 -108
- package/docs/src/targetHandler.js +0 -50
- package/docs/src/theming.ie11.scss +0 -18
- package/docs/src/theming.scss +0 -18
- 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/theming.ie11.min.css +0 -1
- package/docs/theming.ie11.min.js +0 -2
- package/docs/theming.ie11.min.js.map +0 -1
- package/docs/theming.min.css +0 -1
- package/docs/theming.min.js +0 -2
- package/docs/theming.min.js.map +0 -1
- package/docs/toolbar.html +0 -1
- package/docs/toolbar.min.js +0 -2
- package/docs/toolbar.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/type.html +0 -1
- package/docs/type.min.js +0 -2
- package/docs/type.min.js.map +0 -1
- package/index.js +0 -16
package/components/tab/index.js
CHANGED
|
@@ -1,241 +1,257 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
dispatchDomEvent,
|
|
3
|
+
} from '../../core/dom.js';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
static attach(tabItemElement) {
|
|
10
|
-
Ripple.attach(tabItemElement);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @param {Element} tabItemElement
|
|
15
|
-
* @return {void}
|
|
16
|
-
*/
|
|
17
|
-
static detach(tabItemElement) {
|
|
18
|
-
Ripple.detach(tabItemElement);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
class Tab {
|
|
23
|
-
/**
|
|
24
|
-
* @param {Element} tabElement
|
|
25
|
-
* @return {void}
|
|
26
|
-
*/
|
|
27
|
-
static attach(tabElement) {
|
|
28
|
-
const tabItemsElement = tabElement.getElementsByClassName('mdw-tab__items')[0];
|
|
29
|
-
let indicatorElement = tabItemsElement.getElementsByClassName('mdw-tab__indicator')[0];
|
|
30
|
-
if (!indicatorElement) {
|
|
31
|
-
indicatorElement = document.createElement('div');
|
|
32
|
-
indicatorElement.classList.add('mdw-tab__indicator');
|
|
33
|
-
tabItemsElement.appendChild(indicatorElement);
|
|
34
|
-
}
|
|
5
|
+
import * as TabContent from './content.js';
|
|
6
|
+
import * as TabItem from './item.js';
|
|
7
|
+
import * as TabList from './list.js';
|
|
8
|
+
import * as TabPanel from './panel.js';
|
|
35
9
|
|
|
36
|
-
|
|
37
|
-
if (tabContentElement) {
|
|
38
|
-
tabContentElement.addEventListener('scroll', Tab.onTabContentScroll);
|
|
39
|
-
}
|
|
10
|
+
const RESIZE_WAIT_FRAMES = 5;
|
|
40
11
|
|
|
41
|
-
|
|
42
|
-
const items = tabElement.getElementsByClassName('mdw-tab__item');
|
|
12
|
+
export const SELECTED_INDEX_CHANGE_EVENT = 'mdw:tab-selectedindexchange';
|
|
43
13
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
14
|
+
/**
|
|
15
|
+
* @param {Element} tabElement
|
|
16
|
+
* @return {void}
|
|
17
|
+
*/
|
|
18
|
+
export function onResize(tabElement) {
|
|
19
|
+
let stage = 0;
|
|
20
|
+
tabElement.setAttribute('mdw-resize-stage', stage.toString());
|
|
21
|
+
/** @return {void} */
|
|
22
|
+
function performResize() {
|
|
23
|
+
if (!tabElement.hasAttribute('mdw-resize-stage')) {
|
|
24
|
+
// Skip resize
|
|
25
|
+
return;
|
|
52
26
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
27
|
+
const attrStage = tabElement.getAttribute('mdw-resize-stage');
|
|
28
|
+
if (attrStage !== stage.toString()) {
|
|
29
|
+
// Off-sync due to another resize event
|
|
30
|
+
return;
|
|
56
31
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
32
|
+
stage += 1;
|
|
33
|
+
tabElement.setAttribute('mdw-resize-stage', stage.toString());
|
|
34
|
+
if (stage === RESIZE_WAIT_FRAMES) {
|
|
35
|
+
const tabContentElement = /** @type {HTMLElement} */ (tabElement.getElementsByClassName('mdw-tab__content')[0]);
|
|
36
|
+
if (tabContentElement) {
|
|
37
|
+
/** @type {HTMLElement} */
|
|
38
|
+
const relatedPanel = (tabContentElement.querySelector('.mdw-tab__panel[aria-expanded="true"]'));
|
|
39
|
+
if (relatedPanel) {
|
|
40
|
+
TabContent.selectPanel(tabContentElement, relatedPanel, true);
|
|
41
|
+
}
|
|
65
42
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
static detach(tabElement) {
|
|
78
|
-
const inputs = tabElement.getElementsByClassName('mdw-tab__input');
|
|
79
|
-
const items = tabElement.getElementsByClassName('mdw-tab__item');
|
|
80
|
-
const tabContentElement = tabElement.getElementsByClassName('mdw-tab__content')[0];
|
|
81
|
-
const tabContentItems = tabElement.getElementsByClassName('mdw-tab__content-item');
|
|
82
|
-
|
|
83
|
-
for (let i = 0; i < inputs.length; i += 1) {
|
|
84
|
-
const inputElement = inputs[i];
|
|
85
|
-
inputElement.removeEventListener('change', Tab.onInputChanged);
|
|
43
|
+
} else if (stage === RESIZE_WAIT_FRAMES * 2) {
|
|
44
|
+
const tabListElement = /** @type {HTMLElement} */ (tabElement.getElementsByClassName('mdw-tab__list')[0]);
|
|
45
|
+
if (tabListElement) {
|
|
46
|
+
/** @type {HTMLElement} */
|
|
47
|
+
const relatedItem = (tabListElement.querySelector('.mdw-tab__item[aria-selected="true"]'));
|
|
48
|
+
if (relatedItem) {
|
|
49
|
+
TabList.setIndicatorPosition(tabListElement, relatedItem, 0);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
tabElement.removeAttribute('mdw-resize-stage');
|
|
53
|
+
return;
|
|
86
54
|
}
|
|
87
55
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
itemElement.removeAttribute('mdw-selected');
|
|
93
|
-
}
|
|
56
|
+
requestAnimationFrame(performResize);
|
|
57
|
+
}
|
|
58
|
+
requestAnimationFrame(performResize);
|
|
59
|
+
}
|
|
94
60
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
61
|
+
/**
|
|
62
|
+
* @param {HTMLElement} tabElement
|
|
63
|
+
* @param {number} index
|
|
64
|
+
* @return {void}
|
|
65
|
+
*/
|
|
66
|
+
function updateSelectedIndex(tabElement, index) {
|
|
67
|
+
const currentIndex = tabElement.getAttribute('mdw-selected-index');
|
|
68
|
+
if (currentIndex == null || currentIndex === index.toString()) {
|
|
69
|
+
return;
|
|
103
70
|
}
|
|
71
|
+
tabElement.setAttribute('mdw-selected-index', index.toString());
|
|
72
|
+
dispatchDomEvent(tabElement, SELECTED_INDEX_CHANGE_EVENT, { value: index });
|
|
73
|
+
}
|
|
104
74
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
75
|
+
/**
|
|
76
|
+
* @param {CustomEvent} event
|
|
77
|
+
* @return {void}
|
|
78
|
+
*/
|
|
79
|
+
export function onTabItemSelectedChange(event) {
|
|
80
|
+
if (event.detail.value !== 'true') {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const tabElement = /** @type {HTMLElement} */ (event.currentTarget);
|
|
84
|
+
const tabItemElement = /** @type {HTMLElement} */ (event.target);
|
|
85
|
+
const tabListElement = /** @type {HTMLElement} */ (tabElement.getElementsByClassName('mdw-tab__list')[0]);
|
|
86
|
+
if (!tabListElement) {
|
|
87
|
+
return;
|
|
118
88
|
}
|
|
119
89
|
|
|
120
|
-
/**
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
if (!
|
|
90
|
+
const tabContentElement = /** @type {HTMLElement} */ (tabElement.getElementsByClassName('mdw-tab__content')[0]);
|
|
91
|
+
const tabItemIndex = TabList.getTabItemIndex(tabListElement, tabItemElement);
|
|
92
|
+
if (tabItemIndex === -1) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (tabContentElement) {
|
|
96
|
+
const hasNoScroll = tabContentElement.hasAttribute('mdw-no-scroll');
|
|
97
|
+
if (!hasNoScroll) {
|
|
98
|
+
TabContent.selectPanel(tabContentElement, tabItemIndex, 'smooth');
|
|
128
99
|
return;
|
|
129
100
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
101
|
+
TabContent.selectPanel(tabContentElement, tabItemIndex, true);
|
|
102
|
+
}
|
|
103
|
+
TabList.setIndicatorPosition(tabListElement, tabItemElement, 0, true);
|
|
104
|
+
if (!tabContentElement) {
|
|
105
|
+
updateSelectedIndex(tabElement, tabItemIndex);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
137
108
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
109
|
+
/**
|
|
110
|
+
* @param {CustomEvent} event
|
|
111
|
+
* @return {void}
|
|
112
|
+
*/
|
|
113
|
+
export function onTabContentScroll(event) {
|
|
114
|
+
const tabElement = /** @type {HTMLElement} */ (event.currentTarget);
|
|
115
|
+
const { detail } = event;
|
|
116
|
+
if (!detail.forceSelection && tabElement.hasAttribute('mdw-resize-stage')) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const tabListElement = tabElement.getElementsByClassName('mdw-tab__list')[0];
|
|
120
|
+
if (tabListElement) {
|
|
121
|
+
TabList.setIndicatorPosition(
|
|
122
|
+
tabListElement,
|
|
123
|
+
detail.leftPanelIndex,
|
|
124
|
+
detail.visibilityPercentage,
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
if (detail.updateSelected) {
|
|
128
|
+
updateSelectedIndex(tabElement, detail.leftPanelIndex);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @param {CustomEvent} event
|
|
134
|
+
* @return {void}
|
|
135
|
+
*/
|
|
136
|
+
export function onTabPanelExpandedChange(event) {
|
|
137
|
+
if (event.detail.value !== 'true') {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const tabElement = /** @type {HTMLElement} */ (event.currentTarget);
|
|
141
|
+
if (tabElement.hasAttribute('mdw-resize-stage')) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
let index = 0;
|
|
145
|
+
const tabPanelElement = /** @type {HTMLElement} */ (event.target);
|
|
146
|
+
let sibling = tabPanelElement.previousElementSibling;
|
|
147
|
+
while (sibling) {
|
|
148
|
+
index += 1;
|
|
149
|
+
sibling = sibling.previousElementSibling;
|
|
150
|
+
}
|
|
151
|
+
const tabListElement = tabElement.getElementsByClassName('mdw-tab__list')[0];
|
|
152
|
+
if (tabListElement) {
|
|
153
|
+
TabList.selectItemAtIndex(tabListElement, index, false);
|
|
143
154
|
}
|
|
155
|
+
}
|
|
144
156
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
157
|
+
/**
|
|
158
|
+
* @param {Element} tabElement
|
|
159
|
+
* @return {void}
|
|
160
|
+
*/
|
|
161
|
+
export function attach(tabElement) {
|
|
162
|
+
const tabListElement = tabElement.getElementsByClassName('mdw-tab__list')[0];
|
|
163
|
+
if (tabListElement) {
|
|
164
|
+
TabList.attach(tabListElement);
|
|
154
165
|
}
|
|
155
166
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
static selectItem(itemElement) {
|
|
161
|
-
const tabElement = findElementParentByClassName(itemElement, 'mdw-tab');
|
|
162
|
-
if (!tabElement) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
const tabItemsElement = findElementParentByClassName(itemElement, 'mdw-tab__items');
|
|
166
|
-
if (!tabItemsElement) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
const tabItems = tabItemsElement.getElementsByClassName('mdw-tab__item');
|
|
170
|
-
const tabContentElement = tabElement.getElementsByClassName('mdw-tab__content')[0];
|
|
171
|
-
let foundPreviousSelection = false;
|
|
172
|
-
let foundTarget = false;
|
|
173
|
-
let left = 0;
|
|
174
|
-
let contentItems = null;
|
|
175
|
-
if (tabContentElement) {
|
|
176
|
-
contentItems = tabContentElement.getElementsByClassName('mdw-tab__content-item');
|
|
177
|
-
}
|
|
178
|
-
const isRtlValue = isRtl();
|
|
179
|
-
for (let i = 0; i < tabItems.length; i += 1) {
|
|
180
|
-
const index = isRtlValue ? tabItems.length - 1 - i : i;
|
|
181
|
-
const tabItem = tabItems.item(index);
|
|
182
|
-
const contentItem = contentItems && contentItems.item(index);
|
|
183
|
-
if (tabItem === itemElement) {
|
|
184
|
-
foundTarget = true;
|
|
185
|
-
itemElement.setAttribute('mdw-selected', '');
|
|
186
|
-
if (tabContentElement) {
|
|
187
|
-
tabContentElement.setAttribute('mdw-selected-index', index.toString());
|
|
188
|
-
}
|
|
189
|
-
if (contentItem) {
|
|
190
|
-
contentItem.setAttribute('mdw-selected', '');
|
|
191
|
-
}
|
|
192
|
-
} else {
|
|
193
|
-
if (tabItem.hasAttribute('mdw-selected')) {
|
|
194
|
-
foundPreviousSelection = true;
|
|
195
|
-
tabItem.removeAttribute('mdw-selected');
|
|
196
|
-
}
|
|
197
|
-
if (contentItem && contentItem.hasAttribute('mdw-selected')) {
|
|
198
|
-
contentItem.removeAttribute('mdw-selected');
|
|
199
|
-
}
|
|
200
|
-
}
|
|
167
|
+
const tabContentElement = tabElement.getElementsByClassName('mdw-tab__content')[0];
|
|
168
|
+
if (tabContentElement) {
|
|
169
|
+
TabContent.attach(tabContentElement);
|
|
170
|
+
}
|
|
201
171
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
172
|
+
tabElement.addEventListener(
|
|
173
|
+
TabContent.SCROLL_EVENT,
|
|
174
|
+
onTabContentScroll,
|
|
175
|
+
{ passive: true },
|
|
176
|
+
);
|
|
177
|
+
tabElement.addEventListener(
|
|
178
|
+
TabItem.SELECTED_CHANGE_EVENT,
|
|
179
|
+
onTabItemSelectedChange,
|
|
180
|
+
{ passive: true },
|
|
181
|
+
);
|
|
182
|
+
tabElement.addEventListener(
|
|
183
|
+
TabPanel.EXPANDED_CHANGE_EVENT,
|
|
184
|
+
onTabPanelExpandedChange,
|
|
185
|
+
{ passive: true },
|
|
186
|
+
);
|
|
209
187
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
});
|
|
215
|
-
}
|
|
188
|
+
/** @type {HTMLCollectionOf<Element>|Element[]} */
|
|
189
|
+
const items = (tabListElement && tabListElement.getElementsByClassName('mdw-tab__item')) || [];
|
|
190
|
+
/** @type {HTMLCollectionOf<Element>|Element[]} */
|
|
191
|
+
const panels = (tabContentElement && tabContentElement.getElementsByClassName('mdw-tab__panel')) || [];
|
|
216
192
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
indicatorElement.removeAttribute('mdw-js-indicator');
|
|
227
|
-
// this.onItemSelected(itemElement);
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
const width = itemElement.clientWidth;
|
|
231
|
-
if (!indicatorElement.hasAttribute('mdw-js-indicator')) {
|
|
232
|
-
indicatorElement.setAttribute('mdw-js-indicator', '');
|
|
193
|
+
let selectedItem;
|
|
194
|
+
let selectedPanel;
|
|
195
|
+
let selectedIndex;
|
|
196
|
+
[...items].some((itemElement, index) => {
|
|
197
|
+
if (itemElement.getAttribute('aria-selected') === 'true') {
|
|
198
|
+
selectedItem = itemElement;
|
|
199
|
+
selectedPanel = panels[index];
|
|
200
|
+
selectedIndex = index;
|
|
201
|
+
return true;
|
|
233
202
|
}
|
|
234
|
-
|
|
203
|
+
return false;
|
|
204
|
+
});
|
|
205
|
+
if (selectedIndex == null) {
|
|
206
|
+
[...panels].some((panelElement, index) => {
|
|
207
|
+
if (panelElement.getAttribute('aria-expanded') === 'true') {
|
|
208
|
+
selectedPanel = panelElement;
|
|
209
|
+
selectedItem = items[index];
|
|
210
|
+
selectedIndex = index;
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
return false;
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
if (!selectedItem && items.length) {
|
|
217
|
+
selectedItem = items[0];
|
|
218
|
+
selectedIndex = 0;
|
|
235
219
|
}
|
|
220
|
+
if (!selectedPanel && panels.length) {
|
|
221
|
+
selectedPanel = panels[0];
|
|
222
|
+
selectedIndex = 0;
|
|
223
|
+
}
|
|
224
|
+
if (selectedItem) {
|
|
225
|
+
TabItem.setSelected(selectedItem, true);
|
|
226
|
+
}
|
|
227
|
+
if (selectedPanel) {
|
|
228
|
+
TabPanel.setHidden(selectedPanel, false);
|
|
229
|
+
TabPanel.setExpanded(selectedPanel, true);
|
|
230
|
+
}
|
|
231
|
+
if (selectedIndex != null) {
|
|
232
|
+
tabElement.setAttribute('mdw-selected-index', selectedIndex.toString());
|
|
233
|
+
}
|
|
234
|
+
onResize(tabElement);
|
|
236
235
|
}
|
|
237
236
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
237
|
+
/**
|
|
238
|
+
* @param {Element} tabElement
|
|
239
|
+
* @return {void}
|
|
240
|
+
*/
|
|
241
|
+
export function detach(tabElement) {
|
|
242
|
+
const tabListElement = tabElement.getElementsByClassName('mdw-tab__list')[0];
|
|
243
|
+
if (tabListElement) {
|
|
244
|
+
TabList.detach(tabListElement);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const tabContentElement = tabElement.getElementsByClassName('mdw-tab__content')[0];
|
|
248
|
+
if (tabContentElement) {
|
|
249
|
+
TabContent.detach(tabContentElement);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
tabElement.removeEventListener(TabPanel.EXPANDED_CHANGE_EVENT, onTabPanelExpandedChange);
|
|
253
|
+
tabElement.removeEventListener(TabContent.SCROLL_EVENT, onTabContentScroll);
|
|
254
|
+
tabElement.removeEventListener(TabItem.SELECTED_CHANGE_EVENT, onTabItemSelectedChange);
|
|
255
|
+
tabElement.removeAttribute('mdw-resize-stage');
|
|
256
|
+
tabElement.removeAttribute('mdw-selected-index');
|
|
257
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// https://www.w3.org/TR/wai-aria-1.1/#tab
|
|
2
|
+
|
|
3
|
+
import * as AriaTab from '../../core/aria/tab.js';
|
|
4
|
+
import * as Overlay from '../../core/overlay/index.js';
|
|
5
|
+
import * as Ripple from '../../core/ripple/index.js';
|
|
6
|
+
|
|
7
|
+
export const SELECTED_CHANGE_EVENT = 'mdw:tabitem-selectedchange';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @param {Element} element
|
|
11
|
+
* @param {string|boolean} value
|
|
12
|
+
* @param {boolean} [dispatchEvent=true]
|
|
13
|
+
* @return {boolean} successful
|
|
14
|
+
*/
|
|
15
|
+
export function setSelected(element, value, dispatchEvent = true) {
|
|
16
|
+
return AriaTab.setSelected(element, value, dispatchEvent ? SELECTED_CHANGE_EVENT : null);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {MouseEvent} event
|
|
21
|
+
* @return {void}
|
|
22
|
+
*/
|
|
23
|
+
function onClick(event) {
|
|
24
|
+
const element = /** @type {HTMLElement} */ (event.currentTarget);
|
|
25
|
+
if (element.getAttribute('aria-disabled') === 'true') {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
setSelected(element, true);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @param {Element} element
|
|
33
|
+
* @return {void}
|
|
34
|
+
*/
|
|
35
|
+
export function attachAria(element) {
|
|
36
|
+
AriaTab.attach(element);
|
|
37
|
+
for (const el of element.getElementsByClassName('mdw-tab__icon')) {
|
|
38
|
+
el.setAttribute('aria-hidden', 'true');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @param {Element} element
|
|
44
|
+
* @return {void}
|
|
45
|
+
*/
|
|
46
|
+
export function attachCore(element) {
|
|
47
|
+
attachAria(element);
|
|
48
|
+
element.addEventListener('click', onClick);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @param {Element} element
|
|
53
|
+
* @return {void}
|
|
54
|
+
*/
|
|
55
|
+
export function attach(element) {
|
|
56
|
+
element.classList.add('mdw-overlay');
|
|
57
|
+
if (!element.hasAttribute('mdw-overlay-off')) {
|
|
58
|
+
element.setAttribute('mdw-overlay-off', 'selected activated');
|
|
59
|
+
}
|
|
60
|
+
if (!element.hasAttribute('mdw-overlay-default')) {
|
|
61
|
+
element.setAttribute('mdw-overlay-default', 'medium');
|
|
62
|
+
}
|
|
63
|
+
Overlay.attach(element);
|
|
64
|
+
|
|
65
|
+
element.classList.add('mdw-ripple');
|
|
66
|
+
Ripple.attach(element);
|
|
67
|
+
|
|
68
|
+
attachCore(element);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @param {Element} element
|
|
73
|
+
* @return {void}
|
|
74
|
+
*/
|
|
75
|
+
export function detachCore(element) {
|
|
76
|
+
AriaTab.detach(element);
|
|
77
|
+
element.removeEventListener('click', onClick);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @param {Element} element
|
|
82
|
+
* @return {void}
|
|
83
|
+
*/
|
|
84
|
+
export function detach(element) {
|
|
85
|
+
detachCore(element);
|
|
86
|
+
Ripple.detach(element);
|
|
87
|
+
Overlay.detach(element);
|
|
88
|
+
}
|