@shortfuse/materialdesignweb 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +136 -30
- package/.stylelintrc.json +6 -40
- package/.vscode/launch.json +20 -5
- package/CHANGELOG.md +24 -0
- package/README.md +12 -9
- package/adapters/datatable/column.js +82 -74
- package/adapters/datatable/index.js +173 -131
- package/adapters/dom/index.js +529 -75
- package/adapters/list/index.js +25 -12
- package/adapters/search/index.js +13 -13
- package/components/appbar/_spec.scss +87 -64
- package/components/appbar/index.scss +2 -2
- package/components/banner/_spec.scss +8 -8
- package/components/banner/index.scss +2 -2
- package/components/bottomnav/_spec.scss +22 -17
- package/components/bottomnav/index.js +61 -52
- package/components/bottomnav/index.scss +2 -2
- package/components/bottomnav/item.js +44 -25
- package/components/button/README.md +14 -14
- package/components/button/_spec.scss +23 -22
- package/components/button/_theme.scss +37 -21
- package/components/button/index.eta +32 -0
- package/components/button/index.js +12 -12
- package/components/button/index.scss +2 -2
- package/components/card/_spec.scss +40 -36
- package/components/card/index.scss +2 -2
- package/components/chip/_spec.scss +7 -8
- package/components/chip/_theme.scss +31 -31
- package/components/chip/index.js +3 -2
- package/components/chip/index.scss +2 -2
- package/components/chip/item.js +1 -16
- package/components/datatable/_spec.scss +71 -85
- package/components/datatable/_theme.scss +61 -156
- package/components/datatable/cell.js +45 -0
- package/components/datatable/columnheader.js +47 -0
- package/components/datatable/index.js +279 -366
- package/components/datatable/index.scss +2 -2
- package/components/datatable/row.js +49 -0
- package/components/datatable/rowheader.js +18 -0
- package/components/dialog/_spec.scss +61 -41
- package/components/dialog/index.js +325 -297
- package/components/dialog/index.scss +2 -2
- package/components/divider/_spec.scss +8 -6
- package/components/divider/index.scss +2 -2
- package/components/elevation/_spec.scss +2 -2
- package/components/elevation/index.scss +2 -2
- package/components/fab/_spec.scss +23 -24
- package/components/fab/index.js +50 -50
- package/components/fab/index.scss +2 -2
- package/components/grid/_spec.scss +33 -31
- package/components/grid/index.scss +2 -2
- package/components/layout/_mixins.scss +5 -5
- package/components/layout/_spec.scss +206 -176
- package/components/layout/_theme.scss +14 -16
- package/components/layout/index.js +181 -153
- package/components/layout/index.scss +2 -2
- package/components/list/_spec.scss +117 -104
- package/components/list/_theme.scss +31 -34
- package/components/list/content.js +68 -52
- package/components/list/index.js +194 -61
- package/components/list/index.scss +2 -2
- package/components/list/item.js +136 -12
- package/components/list/secondary.js +46 -0
- package/components/menu/_spec.scss +32 -19
- package/components/menu/index.js +242 -229
- package/components/menu/index.scss +2 -2
- package/components/menu/item.js +95 -110
- package/components/progress/_spec.scss +35 -27
- package/components/progress/index.js +21 -0
- package/components/progress/index.scss +2 -1
- package/components/selection/_spec.scss +242 -224
- package/components/selection/_theme.scss +100 -95
- package/components/selection/index.eta +60 -0
- package/components/selection/index.js +76 -0
- package/components/selection/index.pug +15 -8
- package/components/selection/index.scss +2 -2
- package/components/selection/input.js +56 -0
- package/components/selection/radiogroup.js +47 -0
- package/components/slider/_spec.scss +10 -8
- package/components/slider/index.scss +2 -2
- package/components/snackbar/_spec.scss +22 -21
- package/components/snackbar/index.js +102 -111
- package/components/snackbar/index.scss +2 -2
- package/components/tab/_spec.scss +20 -19
- package/components/tab/content.js +41 -40
- package/components/tab/index.js +192 -99
- package/components/tab/index.scss +2 -2
- package/components/tab/item.js +38 -55
- package/components/tab/list.js +96 -72
- package/components/tab/panel.js +12 -13
- package/components/template/_theme.scss +11 -11
- package/components/textfield/_mixins.scss +52 -0
- package/components/textfield/_spec.scss +215 -266
- package/components/textfield/_theme.scss +95 -72
- package/components/textfield/index.eta +74 -0
- package/components/textfield/index.js +63 -57
- package/components/textfield/index.scss +2 -2
- package/components/tooltip/_spec.scss +27 -25
- package/components/tooltip/index.scss +2 -2
- package/components/type/_spec.scss +51 -38
- package/components/type/index.scss +2 -2
- package/core/_breakpoint.scss +75 -91
- package/core/_elevation.scss +10 -10
- package/core/_length.scss +9 -0
- package/core/_motion.scss +14 -14
- package/core/_platform.scss +9 -15
- package/core/_type.scss +33 -32
- package/core/aria/attributes.js +125 -25
- package/core/aria/button.js +23 -23
- package/core/aria/keyboard.js +93 -0
- package/core/aria/rovingtabindex.js +69 -154
- package/core/aria/tab.js +31 -28
- package/core/color/_theme.scss +240 -280
- package/core/color/index.scss +2 -2
- package/core/document/index.js +39 -0
- package/core/dom.js +12 -12
- package/core/overlay/_spec.scss +0 -3
- package/core/overlay/_theme.scss +56 -74
- package/core/overlay/index.js +49 -18
- package/core/overlay/index.scss +2 -2
- package/core/ripple/_spec.scss +22 -39
- package/core/ripple/_theme.scss +13 -13
- package/core/ripple/index.js +137 -134
- package/core/ripple/index.scss +2 -2
- package/core/theme/_config.scss +2 -0
- package/core/theme/_mixins.scss +172 -0
- package/core/theme/_palettes.scss +155 -135
- package/core/theme/_variables.scss +24 -15
- package/core/theme/index.js +50 -0
- package/core/throttler.js +1 -1
- package/core/transition/index.js +36 -20
- package/{docs-src → docs}/_flex.scss +0 -0
- package/{docs-src → docs}/_menuoptions.js +21 -34
- package/{docs-src → docs}/_mixins.pug +39 -26
- package/docs/_partials/_androidnavbar.eta +5 -0
- package/docs/_partials/_androidstatusbar.eta +13 -0
- package/docs/_partials/_appbar.eta +29 -0
- package/docs/_partials/_buttontest.eta +31 -0
- package/docs/_partials/_header.eta +149 -0
- package/docs/_partials/_navlistitem.eta +16 -0
- package/docs/_partials/_target.eta +1 -0
- package/{docs-src → docs}/_sample-utils.js +8 -6
- package/{docs-src → docs}/_storage.js +0 -0
- package/{docs-src → docs}/docs.scss +5 -2
- package/docs/index.eta +16 -0
- package/{docs-src → docs}/index.js +0 -0
- package/docs/pages/appbar.eta +114 -0
- package/{docs-src/components → docs/pages}/appbar.js +0 -0
- package/{docs-src/components → docs/pages}/appbar.pug +15 -18
- package/docs/pages/bottomnav.eta +188 -0
- package/{docs-src/components → docs/pages}/bottomnav.js +23 -24
- package/{docs-src/components → docs/pages}/bottomnav.pug +4 -4
- package/docs/pages/button.eta +124 -0
- package/{docs-src/components → docs/pages}/button.js +19 -19
- package/{docs-src/components → docs/pages}/button.pug +15 -15
- package/docs/pages/card.eta +90 -0
- package/{docs-src/components → docs/pages}/card.js +3 -3
- package/{docs-src/components → docs/pages}/card.pug +7 -7
- package/docs/pages/chip.eta +122 -0
- package/{docs-src/components → docs/pages}/chip.js +3 -6
- package/{docs-src/components → docs/pages}/chip.pug +2 -2
- package/docs/pages/color.eta +143 -0
- package/{docs-src/core → docs/pages}/color.js +95 -20
- package/docs/pages/color.pug +121 -0
- package/docs/pages/datatable.eta +323 -0
- package/{docs-src/components → docs/pages}/datatable.js +26 -13
- package/docs/pages/datatable.pug +283 -0
- package/docs/pages/dialog.eta +186 -0
- package/{docs-src/components → docs/pages}/dialog.js +26 -13
- package/{docs-src/components → docs/pages}/dialog.pug +46 -28
- package/docs/pages/dom.eta +26 -0
- package/docs/pages/dom.js +143 -0
- package/docs/pages/dom.pug +22 -0
- package/docs/pages/elevation.eta +35 -0
- package/{docs-src/components → docs/pages}/elevation.js +0 -0
- package/{docs-src/components → docs/pages}/elevation.pug +0 -0
- package/docs/pages/fab.eta +99 -0
- package/{docs-src/components → docs/pages}/fab.js +3 -3
- package/{docs-src/components → docs/pages}/fab.pug +2 -2
- package/docs/pages/grid.eta +135 -0
- package/{docs-src/components → docs/pages}/grid.js +1 -1
- package/{docs-src/components → docs/pages}/grid.pug +3 -3
- package/docs/pages/layout.eta +8 -0
- package/{docs-src/components → docs/pages}/layout.js +0 -0
- package/{docs-src/components → docs/pages}/layout.pug +0 -0
- package/docs/pages/list.eta +465 -0
- package/{docs-src/components → docs/pages}/list.js +2 -2
- package/{docs-src/components → docs/pages}/list.pug +7 -14
- package/docs/pages/menu.eta +276 -0
- package/{docs-src/components → docs/pages}/menu.js +14 -10
- package/{docs-src/components → docs/pages}/menu.pug +0 -0
- package/docs/pages/overlay.eta +69 -0
- package/docs/pages/overlay.js +4 -0
- package/{docs-src/core → docs/pages}/overlay.pug +14 -11
- package/docs/pages/progress.eta +23 -0
- package/{docs-src/components → docs/pages}/progress.js +1 -1
- package/{docs-src/components → docs/pages}/progress.pug +1 -1
- package/docs/pages/ripple.eta +27 -0
- package/docs/pages/ripple.js +4 -0
- package/{docs-src/core → docs/pages}/ripple.pug +4 -4
- package/docs/pages/search.eta +246 -0
- package/{docs-src/components → docs/pages}/search.js +59 -42
- package/{docs-src/components → docs/pages}/search.pug +50 -51
- package/docs/pages/selection.eta +111 -0
- package/docs/pages/selection.js +13 -0
- package/docs/pages/selection.pug +74 -0
- package/docs/pages/slider.eta +23 -0
- package/{docs-src/components → docs/pages}/slider.js +0 -0
- package/{docs-src/components → docs/pages}/slider.pug +0 -0
- package/docs/pages/snackbar.eta +83 -0
- package/{docs-src/components → docs/pages}/snackbar.js +3 -3
- package/{docs-src/components → docs/pages}/snackbar.pug +0 -0
- package/docs/pages/tab.eta +421 -0
- package/{docs-src/components → docs/pages}/tab.js +18 -35
- package/{docs-src/components → docs/pages}/tab.pug +4 -4
- package/docs/pages/textfield.eta +486 -0
- package/{docs-src/components → docs/pages}/textfield.js +3 -4
- package/{docs-src/components → docs/pages}/textfield.pug +87 -35
- package/docs/pages/tooltip.eta +94 -0
- package/{docs-src/components → docs/pages}/tooltip.js +0 -0
- package/{docs-src/components → docs/pages}/tooltip.pug +0 -1
- package/docs/pages/transition.eta +117 -0
- package/{docs-src/core → docs/pages}/transition.js +7 -8
- package/{docs-src/core → docs/pages}/transition.pug +0 -0
- package/docs/pages/type.eta +31 -0
- package/{docs-src/components → docs/pages}/type.js +0 -0
- package/{docs-src/components → docs/pages}/type.pug +0 -1
- package/docs/postrender.js +39 -0
- package/{docs-src → docs}/prerender.js +3 -9
- package/docs/pwa/_dialogs.eta +143 -0
- package/docs/pwa/_dialogs.pug +96 -0
- package/docs/pwa/_menus.eta +16 -0
- package/{docs-src → docs}/pwa/_menus.pug +0 -0
- package/docs/pwa/pwa-prerender.js +3 -0
- package/docs/pwa/pwa.eta +480 -0
- package/docs/pwa/pwa.js +306 -0
- package/{docs-src → docs}/pwa/pwa.pug +166 -263
- package/docs/pwa/pwa.scss +26 -0
- package/docs/spec.scss +26 -0
- package/docs/themes/_component-themes.scss +26 -0
- package/docs/themes/theme-colored-fallbacks.scss +17 -0
- package/docs/themes/theme-colored.scss +17 -0
- package/docs/themes/theme-default-fallbacks.scss +17 -0
- package/docs/themes/theme-default.scss +17 -0
- package/jsconfig.json +4 -2
- package/package.json +40 -27
- package/scripts/deploy-docs.sh +9 -0
- package/templates/index.eta +2 -0
- package/utils/function.js +3 -0
- package/webpack.config.cjs +257 -0
- package/_spec.scss +0 -27
- package/_theme.scss +0 -27
- package/components/list/expander.js +0 -142
- package/components/list/itemgroup.js +0 -22
- package/core/theme/_builder.scss +0 -116
- package/core/theme/index.scss +0 -68
- package/docs/appbar.html +0 -1
- package/docs/appbar.min.js +0 -2
- package/docs/appbar.min.js.map +0 -1
- package/docs/bottomnav.html +0 -1
- package/docs/bottomnav.min.js +0 -2
- package/docs/bottomnav.min.js.map +0 -1
- package/docs/button.html +0 -1
- package/docs/button.min.js +0 -2
- package/docs/button.min.js.map +0 -1
- package/docs/card.html +0 -1
- package/docs/card.min.js +0 -2
- package/docs/card.min.js.map +0 -1
- package/docs/chip.html +0 -1
- package/docs/chip.min.js +0 -2
- package/docs/chip.min.js.map +0 -1
- package/docs/color.html +0 -1
- package/docs/color.min.js +0 -2
- package/docs/color.min.js.map +0 -1
- package/docs/datatable.html +0 -1
- package/docs/datatable.min.js +0 -2
- package/docs/datatable.min.js.map +0 -1
- package/docs/default.common.min.js +0 -2
- package/docs/default.common.min.js.map +0 -1
- package/docs/dialog.html +0 -1
- package/docs/dialog.min.js +0 -2
- package/docs/dialog.min.js.map +0 -1
- package/docs/docs.min.css +0 -1
- package/docs/docs.min.js +0 -2
- package/docs/docs.min.js.map +0 -1
- package/docs/elevation.html +0 -1
- package/docs/elevation.min.js +0 -2
- package/docs/elevation.min.js.map +0 -1
- package/docs/fab.html +0 -1
- package/docs/fab.min.js +0 -2
- package/docs/fab.min.js.map +0 -1
- package/docs/grid.html +0 -1
- package/docs/grid.min.js +0 -2
- package/docs/grid.min.js.map +0 -1
- package/docs/index.html +0 -1
- package/docs/index.min.js +0 -2
- package/docs/index.min.js.map +0 -1
- package/docs/ink.html +0 -1
- package/docs/ink.min.js +0 -2
- package/docs/ink.min.js.map +0 -1
- package/docs/layout.html +0 -1
- package/docs/layout.min.js +0 -2
- package/docs/layout.min.js.map +0 -1
- package/docs/list.html +0 -1
- package/docs/list.min.js +0 -2
- package/docs/list.min.js.map +0 -1
- package/docs/menu.html +0 -1
- package/docs/menu.min.js +0 -2
- package/docs/menu.min.js.map +0 -1
- package/docs/overlay.html +0 -1
- package/docs/overlay.min.js +0 -2
- package/docs/overlay.min.js.map +0 -1
- package/docs/prerender.common.min.js +0 -2
- package/docs/prerender.common.min.js.map +0 -1
- package/docs/prerender.min.js +0 -2
- package/docs/prerender.min.js.map +0 -1
- package/docs/progress.html +0 -1
- package/docs/progress.min.js +0 -2
- package/docs/progress.min.js.map +0 -1
- package/docs/pwa-prerender.min.js +0 -2
- package/docs/pwa-prerender.min.js.map +0 -1
- package/docs/pwa.html +0 -11
- package/docs/pwa.min.css +0 -1
- package/docs/pwa.min.js +0 -2
- package/docs/pwa.min.js.map +0 -1
- package/docs/ripple.html +0 -1
- package/docs/ripple.min.js +0 -2
- package/docs/ripple.min.js.map +0 -1
- package/docs/search.html +0 -1
- package/docs/search.min.js +0 -2
- package/docs/search.min.js.map +0 -1
- package/docs/selection.html +0 -1
- package/docs/selection.min.js +0 -2
- package/docs/selection.min.js.map +0 -1
- package/docs/slider.html +0 -1
- package/docs/slider.min.js +0 -2
- package/docs/slider.min.js.map +0 -1
- package/docs/snackbar.html +0 -1
- package/docs/snackbar.min.js +0 -2
- package/docs/snackbar.min.js.map +0 -1
- package/docs/spec.min.css +0 -1
- package/docs/spec.min.js +0 -2
- package/docs/spec.min.js.map +0 -1
- package/docs/surface.html +0 -1
- package/docs/surface.min.js +0 -2
- package/docs/surface.min.js.map +0 -1
- package/docs/tab.html +0 -1
- package/docs/tab.min.js +0 -2
- package/docs/tab.min.js.map +0 -1
- package/docs/textfield.html +0 -2
- package/docs/textfield.min.js +0 -2
- package/docs/textfield.min.js.map +0 -1
- package/docs/theme-colored-fallbacks.min.css +0 -1
- package/docs/theme-colored-fallbacks.min.js +0 -2
- package/docs/theme-colored-fallbacks.min.js.map +0 -1
- package/docs/theme-colored.min.css +0 -1
- package/docs/theme-colored.min.js +0 -2
- package/docs/theme-colored.min.js.map +0 -1
- package/docs/theme-default-fallbacks.min.css +0 -1
- package/docs/theme-default-fallbacks.min.js +0 -2
- package/docs/theme-default-fallbacks.min.js.map +0 -1
- package/docs/theme-default.min.css +0 -1
- package/docs/theme-default.min.js +0 -2
- package/docs/theme-default.min.js.map +0 -1
- package/docs/themes-fallbacks.min.css +0 -1
- package/docs/themes-fallbacks.min.js +0 -2
- package/docs/themes-fallbacks.min.js.map +0 -1
- package/docs/themes.min.css +0 -1
- package/docs/themes.min.js +0 -2
- package/docs/themes.min.js.map +0 -1
- package/docs/tooltip.html +0 -1
- package/docs/tooltip.min.js +0 -2
- package/docs/tooltip.min.js.map +0 -1
- package/docs/transition.html +0 -1
- package/docs/transition.min.js +0 -2
- package/docs/transition.min.js.map +0 -1
- package/docs/type.html +0 -1
- package/docs/type.min.js +0 -2
- package/docs/type.min.js.map +0 -1
- package/docs-src/components/datatable.pug +0 -327
- package/docs-src/components/selection.js +0 -9
- package/docs-src/components/selection.pug +0 -77
- package/docs-src/core/color.pug +0 -201
- package/docs-src/core/overlay.js +0 -4
- package/docs-src/core/ripple.js +0 -4
- package/docs-src/index.pug +0 -9
- package/docs-src/pwa/_dialogs.pug +0 -15
- package/docs-src/pwa/pwa-prerender.js +0 -3
- package/docs-src/pwa/pwa.js +0 -182
- package/docs-src/pwa/pwa.scss +0 -25
- package/docs-src/spec.scss +0 -1
- package/docs-src/themes/theme-colored-fallbacks.scss +0 -14
- package/docs-src/themes/theme-colored.scss +0 -14
- package/docs-src/themes/theme-default-fallbacks.scss +0 -14
- package/docs-src/themes/theme-default.scss +0 -14
- package/index.js +0 -51
- package/index.scss +0 -2
- package/webpack.config.js +0 -187
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// https://material.io/design/components/snackbars.html#spec
|
|
2
2
|
|
|
3
|
-
@
|
|
4
|
-
@
|
|
5
|
-
@
|
|
6
|
-
@
|
|
7
|
-
@
|
|
3
|
+
@use '../../core/_breakpoint.scss' as breakpoint;
|
|
4
|
+
@use '../../core/_elevation.scss' as elevation;
|
|
5
|
+
@use '../../core/_length.scss' as *;
|
|
6
|
+
@use '../../core/_motion.scss' as motion;
|
|
7
|
+
@use '../../core/_platform.scss' as platform;
|
|
8
|
+
@use '../../core/_type.scss' as type;
|
|
8
9
|
|
|
9
|
-
$
|
|
10
|
+
$scale-initial: 0.85 !default;
|
|
10
11
|
|
|
11
12
|
.mdw-snackbar__wrapper {
|
|
12
13
|
position: relative;
|
|
@@ -35,7 +36,7 @@ $mdw-snackbar__scale-initial: 0.85 !default;
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
.mdw-snackbar {
|
|
38
|
-
@include type
|
|
39
|
+
@include type.addRules('body-2');
|
|
39
40
|
|
|
40
41
|
display: flex;
|
|
41
42
|
position: absolute;
|
|
@@ -49,8 +50,8 @@ $mdw-snackbar__scale-initial: 0.85 !default;
|
|
|
49
50
|
padding-left: dp(8);
|
|
50
51
|
|
|
51
52
|
animation-name: none;
|
|
52
|
-
animation-duration:
|
|
53
|
-
animation-timing-function:
|
|
53
|
+
animation-duration: motion.$fadeInDuration;
|
|
54
|
+
animation-timing-function: motion.$decelerateEasing;
|
|
54
55
|
animation-direction: normal;
|
|
55
56
|
animation-fill-mode: forwards;
|
|
56
57
|
will-change: opacity, transform, visibility;
|
|
@@ -59,12 +60,12 @@ $mdw-snackbar__scale-initial: 0.85 !default;
|
|
|
59
60
|
|
|
60
61
|
// Default state is hidden
|
|
61
62
|
pointer-events: auto;
|
|
62
|
-
transform: scale($
|
|
63
|
+
transform: scale($scale-initial);
|
|
63
64
|
visibility: hidden;
|
|
64
65
|
|
|
65
66
|
border-radius: dp(4);
|
|
66
67
|
|
|
67
|
-
box-shadow:
|
|
68
|
+
box-shadow: elevation.boxShadow(6);
|
|
68
69
|
|
|
69
70
|
&[aria-hidden="false"] {
|
|
70
71
|
animation-name: showSnackbar;
|
|
@@ -77,8 +78,8 @@ $mdw-snackbar__scale-initial: 0.85 !default;
|
|
|
77
78
|
|
|
78
79
|
&[aria-hidden="true"] {
|
|
79
80
|
animation-name: hideSnackbar;
|
|
80
|
-
animation-duration:
|
|
81
|
-
animation-timing-function:
|
|
81
|
+
animation-duration: motion.$fadeOutDuration;
|
|
82
|
+
animation-timing-function: motion.$accelerateEasing;
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
&:focus {
|
|
@@ -95,7 +96,7 @@ $mdw-snackbar__scale-initial: 0.85 !default;
|
|
|
95
96
|
|
|
96
97
|
to {
|
|
97
98
|
opacity: 0;
|
|
98
|
-
transform: scale($
|
|
99
|
+
transform: scale($scale-initial);
|
|
99
100
|
visibility: hidden;
|
|
100
101
|
}
|
|
101
102
|
}
|
|
@@ -103,7 +104,7 @@ $mdw-snackbar__scale-initial: 0.85 !default;
|
|
|
103
104
|
@keyframes showSnackbar {
|
|
104
105
|
from {
|
|
105
106
|
opacity: 0;
|
|
106
|
-
transform: scale($
|
|
107
|
+
transform: scale($scale-initial);
|
|
107
108
|
visibility: hidden;
|
|
108
109
|
}
|
|
109
110
|
|
|
@@ -122,15 +123,15 @@ $mdw-snackbar__scale-initial: 0.85 !default;
|
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
.mdw-snackbar > span {
|
|
125
|
-
@include
|
|
126
|
-
@include
|
|
126
|
+
@include type.textTopToTop(16);
|
|
127
|
+
@include type.baselineToBottom(48 - 30);
|
|
127
128
|
box-sizing: border-box;
|
|
128
129
|
padding: 0 dp(8);
|
|
129
130
|
|
|
130
131
|
white-space: pre-line;
|
|
131
132
|
}
|
|
132
133
|
|
|
133
|
-
@include
|
|
134
|
+
@include breakpoint.isXSmallWindow() {
|
|
134
135
|
.mdw-snackbar {
|
|
135
136
|
right: 0;
|
|
136
137
|
left: 0;
|
|
@@ -152,7 +153,7 @@ $mdw-snackbar__scale-initial: 0.85 !default;
|
|
|
152
153
|
}
|
|
153
154
|
}
|
|
154
155
|
|
|
155
|
-
@include
|
|
156
|
+
@include platform.ifIE() {
|
|
156
157
|
// Fix IE flexbug
|
|
157
158
|
.mdw-snackbar {
|
|
158
159
|
&::after {
|
|
@@ -170,12 +171,12 @@ $mdw-snackbar__scale-initial: 0.85 !default;
|
|
|
170
171
|
transform: translateX(50%);
|
|
171
172
|
|
|
172
173
|
&[mdw-hide] {
|
|
173
|
-
transform: translateX(50%) scale($
|
|
174
|
+
transform: translateX(50%) scale($scale-initial);
|
|
174
175
|
}
|
|
175
176
|
}
|
|
176
177
|
|
|
177
178
|
&[mdw-hide] {
|
|
178
|
-
transform: translateX(-50%) scale($
|
|
179
|
+
transform: translateX(-50%) scale($scale-initial);
|
|
179
180
|
}
|
|
180
181
|
}
|
|
181
182
|
}
|
|
@@ -6,27 +6,26 @@ import {
|
|
|
6
6
|
findElementParentByClassName,
|
|
7
7
|
nextTick,
|
|
8
8
|
setTextNode,
|
|
9
|
-
} from '../../core/dom';
|
|
10
|
-
|
|
11
|
-
import * as Button from '../button/index';
|
|
9
|
+
} from '../../core/dom.js';
|
|
10
|
+
import * as Button from '../button/index.js';
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* @typedef SnackbarCreateOptions
|
|
15
|
-
* @
|
|
16
|
-
* @
|
|
17
|
-
* @
|
|
18
|
-
* @
|
|
19
|
-
* @
|
|
20
|
-
* @
|
|
21
|
-
* @
|
|
22
|
-
* @
|
|
23
|
-
* @
|
|
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
|
|
24
23
|
*/
|
|
25
24
|
|
|
26
25
|
class SnackbarQueueItem {
|
|
27
26
|
/**
|
|
28
27
|
* @param {Element} element
|
|
29
|
-
* @param {SnackbarCreateOptions
|
|
28
|
+
* @param {SnackbarCreateOptions} [options]
|
|
30
29
|
*/
|
|
31
30
|
constructor(element, options) {
|
|
32
31
|
this.element = element;
|
|
@@ -49,22 +48,6 @@ const SNACKBAR_QUEUE = [];
|
|
|
49
48
|
export const HIDE_EVENT = 'mdw:snackbar-hide';
|
|
50
49
|
export const SHOW_EVENT = 'mdw:snackbar-show';
|
|
51
50
|
|
|
52
|
-
/**
|
|
53
|
-
* @param {Element} snackbarElement
|
|
54
|
-
* @return {void}
|
|
55
|
-
*/
|
|
56
|
-
export function attach(snackbarElement) {
|
|
57
|
-
const button = snackbarElement.getElementsByClassName('mdw-button')[0];
|
|
58
|
-
if (button) {
|
|
59
|
-
Button.attach(button);
|
|
60
|
-
button.addEventListener('click', onButtonClick);
|
|
61
|
-
}
|
|
62
|
-
snackbarElement.setAttribute('mdw-js', '');
|
|
63
|
-
snackbarElement.addEventListener('animationend', onAnimationEnd);
|
|
64
|
-
snackbarElement.addEventListener('keydown', onKeyDown);
|
|
65
|
-
setupARIA(snackbarElement);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
51
|
/**
|
|
69
52
|
* @param {Element} snackbarElement
|
|
70
53
|
* @return {void}
|
|
@@ -77,67 +60,6 @@ export function setupARIA(snackbarElement) {
|
|
|
77
60
|
snackbarElement.setAttribute('tabindex', '-1');
|
|
78
61
|
}
|
|
79
62
|
|
|
80
|
-
/**
|
|
81
|
-
* @param {KeyboardEvent} event
|
|
82
|
-
* @return {void}
|
|
83
|
-
*/
|
|
84
|
-
export function onKeyDown(event) {
|
|
85
|
-
if (event.key === 'Escape' || event.key === 'Esc') {
|
|
86
|
-
// Allow users to close snackbar with escape, for accessibilty reasons
|
|
87
|
-
event.stopPropagation();
|
|
88
|
-
event.preventDefault();
|
|
89
|
-
/** @type {Element} */
|
|
90
|
-
const snackbarElement = (event.currentTarget);
|
|
91
|
-
hide(snackbarElement);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* @param {Element} snackbarElement
|
|
97
|
-
* @return {void}
|
|
98
|
-
*/
|
|
99
|
-
export function detach(snackbarElement) {
|
|
100
|
-
const button = snackbarElement.getElementsByClassName('mdw-button')[0];
|
|
101
|
-
if (button) {
|
|
102
|
-
Button.detach(button);
|
|
103
|
-
button.removeEventListener('click', onButtonClick);
|
|
104
|
-
}
|
|
105
|
-
// Remove timeouts and stacks
|
|
106
|
-
SNACKBAR_QUEUE.slice().reverse().forEach((queue, reverseIndex, array) => {
|
|
107
|
-
if (queue.element === snackbarElement) {
|
|
108
|
-
queue.clearHideTimeout();
|
|
109
|
-
const index = array.length - reverseIndex - 1;
|
|
110
|
-
SNACKBAR_QUEUE.splice(index, 1);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
snackbarElement.removeAttribute('mdw-js');
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* @param {MouseEvent} event
|
|
118
|
-
* @return {void}
|
|
119
|
-
*/
|
|
120
|
-
export function onButtonClick(event) {
|
|
121
|
-
/** @type {HTMLElement} */
|
|
122
|
-
const buttonElement = (event.currentTarget);
|
|
123
|
-
if (buttonElement instanceof HTMLAnchorElement) {
|
|
124
|
-
event.preventDefault();
|
|
125
|
-
}
|
|
126
|
-
const snackbarElement = findElementParentByClassName(buttonElement, 'mdw-snackbar');
|
|
127
|
-
hide(snackbarElement);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/** @return {SnackbarQueueItem} */
|
|
131
|
-
export function getNextSnackbarQueueItem() {
|
|
132
|
-
const nextSnackbar = SnackbarQueueItem[0];
|
|
133
|
-
if (nextSnackbar && (!nextSnackbar.element || !nextSnackbar.element.parentElement)) {
|
|
134
|
-
// Item was removed from DOM externally
|
|
135
|
-
SNACKBAR_QUEUE.splice(0, 1);
|
|
136
|
-
return getNextSnackbarQueueItem();
|
|
137
|
-
}
|
|
138
|
-
return nextSnackbar;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
63
|
/**
|
|
142
64
|
* @param {Element} element
|
|
143
65
|
* @return {SnackbarQueueItem}
|
|
@@ -154,14 +76,6 @@ export function findNextQueueItem(element) {
|
|
|
154
76
|
return queue;
|
|
155
77
|
}
|
|
156
78
|
|
|
157
|
-
/**
|
|
158
|
-
* @param {AnimationEvent} event
|
|
159
|
-
* @return {void}
|
|
160
|
-
*/
|
|
161
|
-
export function onAnimationEnd(event) {
|
|
162
|
-
handleAnimationChange(/** @type {Element} */ (event.currentTarget));
|
|
163
|
-
}
|
|
164
|
-
|
|
165
79
|
/**
|
|
166
80
|
* @param {Element} snackbarElement
|
|
167
81
|
* @return {void}
|
|
@@ -182,6 +96,7 @@ export function handleAnimationChange(snackbarElement) {
|
|
|
182
96
|
return;
|
|
183
97
|
}
|
|
184
98
|
const timeout = setTimeout(() => {
|
|
99
|
+
// eslint-disable-next-line no-use-before-define
|
|
185
100
|
hide(snackbarElement);
|
|
186
101
|
}, timeInSeconds * 1000);
|
|
187
102
|
if (currentQueueItem) {
|
|
@@ -192,7 +107,9 @@ export function handleAnimationChange(snackbarElement) {
|
|
|
192
107
|
|
|
193
108
|
const nextQueueItem = findNextQueueItem(snackbarElement);
|
|
194
109
|
if (nextQueueItem) {
|
|
110
|
+
// eslint-disable-next-line no-use-before-define
|
|
195
111
|
update(snackbarElement, nextQueueItem.options);
|
|
112
|
+
// eslint-disable-next-line no-use-before-define
|
|
196
113
|
show(snackbarElement);
|
|
197
114
|
return;
|
|
198
115
|
}
|
|
@@ -203,6 +120,14 @@ export function handleAnimationChange(snackbarElement) {
|
|
|
203
120
|
}
|
|
204
121
|
}
|
|
205
122
|
|
|
123
|
+
/**
|
|
124
|
+
* @param {AnimationEvent} event
|
|
125
|
+
* @return {void}
|
|
126
|
+
*/
|
|
127
|
+
export function onAnimationEnd(event) {
|
|
128
|
+
handleAnimationChange(/** @type {Element} */ (event.currentTarget));
|
|
129
|
+
}
|
|
130
|
+
|
|
206
131
|
/**
|
|
207
132
|
* @param {Element} snackbarElement
|
|
208
133
|
* @return {boolean} changed
|
|
@@ -226,22 +151,32 @@ export function hide(snackbarElement) {
|
|
|
226
151
|
}
|
|
227
152
|
|
|
228
153
|
/**
|
|
229
|
-
* @param {
|
|
230
|
-
* @return {
|
|
154
|
+
* @param {KeyboardEvent} event
|
|
155
|
+
* @return {void}
|
|
231
156
|
*/
|
|
232
|
-
export function
|
|
233
|
-
if (
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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);
|
|
238
165
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
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();
|
|
243
177
|
}
|
|
244
|
-
|
|
178
|
+
const snackbarElement = findElementParentByClassName(buttonElement, 'mdw-snackbar');
|
|
179
|
+
hide(snackbarElement);
|
|
245
180
|
}
|
|
246
181
|
|
|
247
182
|
/**
|
|
@@ -313,6 +248,62 @@ export function update(element, options) {
|
|
|
313
248
|
}
|
|
314
249
|
}
|
|
315
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
|
+
|
|
316
307
|
/**
|
|
317
308
|
* Creates a Snackbar element if required and adds to show queue
|
|
318
309
|
* @param {SnackbarCreateOptions} options
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
@
|
|
2
|
-
@
|
|
1
|
+
@forward './_spec.scss';
|
|
2
|
+
@forward './_theme.scss';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// https://material.io/design/components/tabs.html#spec
|
|
2
2
|
|
|
3
|
-
@
|
|
4
|
-
@
|
|
5
|
-
@
|
|
6
|
-
@
|
|
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
7
|
|
|
8
|
-
$
|
|
9
|
-
$
|
|
10
|
-
$
|
|
11
|
-
$
|
|
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
12
|
|
|
13
13
|
.mdw-tab {
|
|
14
14
|
display: flex;
|
|
@@ -63,8 +63,8 @@ $mdw-tab__icon-with-label-height: 72 !default;
|
|
|
63
63
|
.mdw-tab__icon,
|
|
64
64
|
.mdw-tab__label,
|
|
65
65
|
.mdw-tab__indicator {
|
|
66
|
-
transition-duration:
|
|
67
|
-
transition-timing-function:
|
|
66
|
+
transition-duration: motion.$simpleDuration;
|
|
67
|
+
transition-timing-function: motion.$standardEasing;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
.mdw-tab__indicator {
|
|
@@ -120,9 +120,9 @@ $mdw-tab__icon-with-label-height: 72 !default;
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
.mdw-tab__icon {
|
|
123
|
-
@include
|
|
124
|
-
margin-top: dp($
|
|
125
|
-
margin-bottom: dp(-$
|
|
123
|
+
@include type.baselineToBottom($icon-to-label-baseline);
|
|
124
|
+
margin-top: dp($icon-margin-top);
|
|
125
|
+
margin-bottom: dp(-$icon-to-label-baseline);
|
|
126
126
|
|
|
127
127
|
transition-property: color;
|
|
128
128
|
|
|
@@ -130,7 +130,7 @@ $mdw-tab__icon-with-label-height: 72 !default;
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
.mdw-tab__label {
|
|
133
|
-
@include type
|
|
133
|
+
@include type.addRules('button');
|
|
134
134
|
|
|
135
135
|
box-sizing: border-box;
|
|
136
136
|
margin-top: auto;
|
|
@@ -144,11 +144,11 @@ $mdw-tab__icon-with-label-height: 72 !default;
|
|
|
144
144
|
text-align: center;
|
|
145
145
|
|
|
146
146
|
.mdw-tab__icon ~ & {
|
|
147
|
-
@include
|
|
148
|
-
@include
|
|
149
|
-
- $
|
|
150
|
-
- $
|
|
151
|
-
- $
|
|
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
152
|
|
|
153
153
|
display: block;
|
|
154
154
|
|
|
@@ -167,6 +167,7 @@ $mdw-tab__icon-with-label-height: 72 !default;
|
|
|
167
167
|
-ms-overflow-style: none;
|
|
168
168
|
overflow-x: hidden;
|
|
169
169
|
overflow-x: scroll;
|
|
170
|
+
-webkit-overflow-scrolling: touch;
|
|
170
171
|
scroll-behavior: smooth;
|
|
171
172
|
|
|
172
173
|
// W3C standard
|
|
@@ -1,36 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
-
iterateArrayLike,
|
|
3
|
-
nextTick,
|
|
4
|
-
scrollToElement,
|
|
5
2
|
dispatchDomEvent,
|
|
6
3
|
getPassiveEventListenerOption,
|
|
7
4
|
isRtl,
|
|
5
|
+
iterateArrayLike,
|
|
8
6
|
iterateSomeOfArrayLike,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export const SCROLL_EVENT = 'mdw:tabcontent-scroll';
|
|
7
|
+
scrollToElement,
|
|
8
|
+
} from '../../core/dom.js';
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
* @param {Element} tabContentElement
|
|
16
|
-
* @return {void}
|
|
17
|
-
*/
|
|
18
|
-
export function attach(tabContentElement) {
|
|
19
|
-
tabContentElement.addEventListener('scroll', onTabContentScroll, getPassiveEventListenerOption());
|
|
20
|
-
iterateArrayLike(tabContentElement.getElementsByClassName('mdw-tab__panel'), TabPanel.attach);
|
|
21
|
-
tabContentElement.addEventListener('keydown', onKeyDown);
|
|
22
|
-
}
|
|
10
|
+
import * as TabPanel from './panel.js';
|
|
23
11
|
|
|
24
|
-
|
|
25
|
-
* @param {Element} tabContentElement
|
|
26
|
-
* @return {void}
|
|
27
|
-
*/
|
|
28
|
-
export function detach(tabContentElement) {
|
|
29
|
-
tabContentElement.removeEventListener('keydown', onKeyDown);
|
|
30
|
-
tabContentElement.removeAttribute('mdw-selected-index');
|
|
31
|
-
tabContentElement.removeEventListener('scroll', onTabContentScroll);
|
|
32
|
-
iterateArrayLike(tabContentElement.getElementsByClassName('mdw-tab__panel'), TabPanel.detach);
|
|
33
|
-
}
|
|
12
|
+
export const SCROLL_EVENT = 'mdw:tabcontent-scroll';
|
|
34
13
|
|
|
35
14
|
/**
|
|
36
15
|
* Prevent scrolling with keyboard
|
|
@@ -52,7 +31,6 @@ function onKeyDown(event) {
|
|
|
52
31
|
}
|
|
53
32
|
}
|
|
54
33
|
|
|
55
|
-
|
|
56
34
|
/**
|
|
57
35
|
* @param {Event} event
|
|
58
36
|
* @return {void}
|
|
@@ -60,18 +38,15 @@ function onKeyDown(event) {
|
|
|
60
38
|
export function onTabContentScroll(event) {
|
|
61
39
|
/** @type {HTMLElement} */
|
|
62
40
|
const tabContentElement = (event.currentTarget);
|
|
63
|
-
if (tabContentElement.hasAttribute('mdw-no-scroll')) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
41
|
const isPageRtl = isRtl();
|
|
67
42
|
const scrollPoint = tabContentElement.scrollLeft / tabContentElement.clientWidth;
|
|
68
43
|
let visibleIndex = Math.floor(scrollPoint);
|
|
69
44
|
let visibilityPercentage = scrollPoint - visibleIndex;
|
|
70
45
|
|
|
71
46
|
// Percentage may be incorrect due to floating point rounding errors
|
|
72
|
-
// Compare
|
|
73
|
-
iterateSomeOfArrayLike(tabContentElement.children, ((panel, index) => {
|
|
74
|
-
if (tabContentElement.scrollLeft
|
|
47
|
+
// Compare integer values provided by browser to check if within 1px
|
|
48
|
+
iterateSomeOfArrayLike(tabContentElement.children, ((/** @type {HTMLElement} */ panel, index) => {
|
|
49
|
+
if (Math.abs(tabContentElement.scrollLeft - panel.offsetLeft) <= 1) {
|
|
75
50
|
visibleIndex = index;
|
|
76
51
|
visibilityPercentage = 0;
|
|
77
52
|
return true;
|
|
@@ -120,18 +95,22 @@ export function onTabContentScroll(event) {
|
|
|
120
95
|
const currentTargetIndex = currentTargetIndexString == null
|
|
121
96
|
? null : parseInt(currentTargetIndexString, 10);
|
|
122
97
|
|
|
123
|
-
let
|
|
98
|
+
let updateSelected = false;
|
|
99
|
+
let forceSelection = false;
|
|
124
100
|
if (currentTargetIndex == null) {
|
|
125
101
|
TabPanel.setExpanded(leftPanel, leftSelected);
|
|
126
102
|
if (rightPanel) {
|
|
127
103
|
TabPanel.setExpanded(rightPanel, rightSelected);
|
|
128
104
|
}
|
|
129
|
-
|
|
105
|
+
updateSelected = visibilityPercentage === 0;
|
|
130
106
|
} else if (currentTargetIndex === selectedIndex) {
|
|
131
|
-
|
|
107
|
+
if (visibilityPercentage === 0) {
|
|
108
|
+
updateSelected = true;
|
|
109
|
+
forceSelection = true;
|
|
110
|
+
tabContentElement.removeAttribute('mdw-target-index');
|
|
111
|
+
}
|
|
132
112
|
}
|
|
133
113
|
|
|
134
|
-
|
|
135
114
|
TabPanel.setHidden(leftPanel, false);
|
|
136
115
|
if (leftPeekPanel) {
|
|
137
116
|
TabPanel.setHidden(leftPeekPanel, isResting || !leftSelected);
|
|
@@ -144,9 +123,10 @@ export function onTabContentScroll(event) {
|
|
|
144
123
|
}
|
|
145
124
|
|
|
146
125
|
dispatchDomEvent(tabContentElement, SCROLL_EVENT, {
|
|
147
|
-
newSelectedIndex,
|
|
148
126
|
leftPanelIndex,
|
|
149
127
|
visibilityPercentage,
|
|
128
|
+
updateSelected,
|
|
129
|
+
forceSelection,
|
|
150
130
|
});
|
|
151
131
|
}
|
|
152
132
|
|
|
@@ -163,6 +143,7 @@ export function selectPanel(tabContentElement, panel, scrollToPanel = 'smooth')
|
|
|
163
143
|
let currentSelectedIndex = null;
|
|
164
144
|
/** @type {number} */
|
|
165
145
|
let panelIndex = null;
|
|
146
|
+
/** @type {Element[]} */
|
|
166
147
|
const otherPanels = [];
|
|
167
148
|
iterateArrayLike(tabContentElement.getElementsByClassName('mdw-tab__panel'), (el, index) => {
|
|
168
149
|
if (currentSelectedIndex == null && TabPanel.isExpanded(el)) {
|
|
@@ -182,7 +163,7 @@ export function selectPanel(tabContentElement, panel, scrollToPanel = 'smooth')
|
|
|
182
163
|
// Invalid index or panel not in tabcontent
|
|
183
164
|
return;
|
|
184
165
|
}
|
|
185
|
-
otherPanels.forEach(sibling => TabPanel.setExpanded(sibling, false));
|
|
166
|
+
otherPanels.forEach((sibling) => TabPanel.setExpanded(sibling, false));
|
|
186
167
|
|
|
187
168
|
const isPageRtl = isRtl();
|
|
188
169
|
const targetScrollLeft = isPageRtl
|
|
@@ -190,7 +171,7 @@ export function selectPanel(tabContentElement, panel, scrollToPanel = 'smooth')
|
|
|
190
171
|
: panelElement.offsetLeft;
|
|
191
172
|
if (!scrollToPanel || panelElement.parentElement.scrollLeft === targetScrollLeft) {
|
|
192
173
|
// No scrolling, hide others
|
|
193
|
-
otherPanels.forEach(sibling => TabPanel.setHidden(sibling, true));
|
|
174
|
+
otherPanels.forEach((sibling) => TabPanel.setHidden(sibling, true));
|
|
194
175
|
return;
|
|
195
176
|
}
|
|
196
177
|
if (scrollToPanel && panelElement) {
|
|
@@ -202,3 +183,23 @@ export function selectPanel(tabContentElement, panel, scrollToPanel = 'smooth')
|
|
|
202
183
|
scrollToElement(panelElement, scrollToPanel === 'smooth', isPageRtl);
|
|
203
184
|
}
|
|
204
185
|
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @param {Element} tabContentElement
|
|
189
|
+
* @return {void}
|
|
190
|
+
*/
|
|
191
|
+
export function attach(tabContentElement) {
|
|
192
|
+
tabContentElement.addEventListener('scroll', onTabContentScroll, getPassiveEventListenerOption());
|
|
193
|
+
iterateArrayLike(tabContentElement.getElementsByClassName('mdw-tab__panel'), TabPanel.attach);
|
|
194
|
+
tabContentElement.addEventListener('keydown', onKeyDown);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @param {Element} tabContentElement
|
|
199
|
+
* @return {void}
|
|
200
|
+
*/
|
|
201
|
+
export function detach(tabContentElement) {
|
|
202
|
+
tabContentElement.removeEventListener('keydown', onKeyDown);
|
|
203
|
+
tabContentElement.removeEventListener('scroll', onTabContentScroll);
|
|
204
|
+
iterateArrayLike(tabContentElement.getElementsByClassName('mdw-tab__panel'), TabPanel.detach);
|
|
205
|
+
}
|