@shortfuse/materialdesignweb 0.4.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 +59 -8
- package/.stylelintrc.json +94 -49
- package/CHANGELOG.md +12 -0
- package/README.md +1 -3
- package/adapters/datatable/column.js +27 -54
- package/adapters/datatable/index.js +69 -81
- package/adapters/dom/index.js +32 -47
- package/adapters/search/index.js +107 -133
- package/components/appbar/_spec.scss +77 -137
- package/components/banner/_spec.scss +28 -63
- package/components/bottomnav/_spec.scss +46 -54
- package/components/bottomnav/index.js +15 -20
- package/components/bottomnav/item.js +4 -5
- package/components/button/README.md +1 -1
- package/components/button/_spec.scss +43 -42
- package/components/button/_theme.scss +27 -50
- package/components/card/_spec.scss +61 -69
- package/components/chip/_spec.scss +21 -44
- package/components/chip/_theme.scss +79 -151
- package/components/chip/index.js +6 -4
- package/components/datatable/_spec.scss +36 -99
- package/components/datatable/_theme.scss +98 -124
- package/components/datatable/cell.js +1 -2
- package/components/datatable/columnheader.js +1 -2
- package/components/datatable/index.js +33 -47
- package/components/datatable/row.js +4 -5
- package/components/dialog/_spec.scss +53 -63
- package/components/dialog/_theme.scss +7 -0
- package/components/dialog/index.js +62 -88
- package/components/divider/_spec.scss +6 -8
- package/components/elevation/_spec.scss +1 -1
- package/components/fab/_spec.scss +30 -42
- package/components/fab/index.js +4 -8
- package/components/grid/_spec.scss +68 -211
- package/components/layout/_mixins.scss +0 -22
- package/components/layout/_spec.scss +267 -363
- package/components/layout/_theme.scss +10 -35
- package/components/layout/index.js +40 -50
- package/components/list/_spec.scss +57 -91
- package/components/list/_theme.scss +75 -84
- package/components/list/content.js +9 -13
- package/components/list/index.js +34 -38
- package/components/list/item.js +8 -11
- package/components/list/secondary.js +8 -9
- package/components/menu/_spec.scss +134 -167
- package/components/menu/index.js +45 -61
- package/components/menu/item.js +11 -19
- package/components/progress/_spec.scss +43 -34
- package/components/selection/_spec.scss +123 -133
- package/components/selection/_theme.scss +88 -120
- package/components/selection/index.js +9 -15
- package/components/selection/input.js +3 -5
- package/components/selection/radiogroup.js +8 -15
- package/components/slider/_spec.scss +23 -28
- package/components/snackbar/_spec.scss +17 -62
- package/components/snackbar/index.js +15 -21
- package/components/tab/_spec.scss +35 -50
- package/components/tab/content.js +33 -28
- package/components/tab/index.js +30 -33
- package/components/tab/item.js +4 -5
- package/components/tab/list.js +22 -36
- package/components/textfield/README.md +2 -2
- package/components/textfield/_spec.scss +241 -287
- package/components/textfield/_theme.scss +197 -232
- package/components/textfield/index.js +8 -16
- package/components/tooltip/_spec.scss +23 -26
- package/components/type/_spec.scss +19 -16
- package/core/_breakpoint.scss +33 -33
- package/core/_elevation.scss +40 -0
- package/core/_length.scss +0 -1
- package/core/_platform.scss +0 -22
- package/core/_type.scss +7 -6
- package/core/aria/button.js +4 -5
- package/core/aria/keyboard.js +1 -2
- package/core/aria/rovingtabindex.js +14 -17
- package/core/aria/tab.js +1 -2
- package/core/dom.js +18 -109
- package/core/overlay/_spec.scss +5 -8
- package/core/overlay/_theme.scss +126 -150
- package/core/overlay/index.js +19 -32
- package/core/ripple/_spec.scss +16 -17
- package/core/ripple/_theme.scss +13 -33
- package/core/ripple/index.js +36 -44
- package/core/theme/_aliases.scss +15 -0
- package/core/theme/_config.scss +8 -2
- package/core/theme/_functions.scss +22 -0
- package/core/theme/_palettes.scss +0 -1
- package/core/{color → theme}/_spec.scss +0 -0
- package/core/theme/_theme.scss +268 -0
- package/core/theme/index.scss +4 -0
- package/core/transition/index.js +73 -76
- package/docs/_flex.scss +7 -1
- package/docs/_menuoptions.js +2 -2
- package/docs/_partials/_appbar.eta +12 -14
- package/docs/_partials/_header.eta +41 -44
- package/docs/_sample-utils.js +15 -20
- package/docs/docs.scss +123 -87
- package/docs/framework.scss +26 -0
- package/docs/index.eta +2 -6
- package/docs/index.js +7 -0
- package/docs/pages/appbar.eta +22 -28
- package/docs/pages/bottomnav.js +17 -14
- package/docs/pages/button.js +10 -10
- package/docs/pages/card.js +20 -22
- package/docs/pages/chip.js +11 -13
- package/docs/pages/color.js +35 -36
- package/docs/pages/datatable.js +11 -15
- package/docs/pages/dialog.eta +9 -11
- package/docs/pages/dialog.js +6 -9
- package/docs/pages/dom.js +6 -9
- package/docs/pages/elevation.eta +10 -10
- package/docs/pages/fab.js +2 -3
- package/docs/pages/grid.js +5 -5
- package/docs/pages/list.js +1 -2
- package/docs/pages/menu.eta +17 -19
- package/docs/pages/menu.js +7 -11
- package/docs/pages/overlay.js +1 -2
- package/docs/pages/progress.eta +2 -2
- package/docs/pages/progress.js +1 -1
- package/docs/pages/ripple.js +1 -2
- package/docs/pages/search.eta +20 -24
- package/docs/pages/search.js +24 -41
- package/docs/pages/selection.eta +2 -6
- package/docs/pages/selection.js +3 -4
- package/docs/pages/snackbar.js +3 -4
- package/docs/pages/tab.eta +61 -75
- package/docs/pages/tab.js +16 -15
- package/docs/pages/textfield.eta +9 -8
- package/docs/pages/textfield.js +26 -23
- package/docs/pages/tooltip.eta +10 -12
- package/docs/pages/transition.js +5 -7
- package/docs/postrender.js +7 -5
- package/docs/pwa/pwa.eta +14 -16
- package/docs/pwa/pwa.js +19 -27
- package/docs/pwa/pwa.scss +12 -7
- package/docs/themes/theme-colored.scss +9 -11
- package/docs/themes/theme-default.scss +0 -14
- package/index.scss +27 -0
- package/jsconfig.json +7 -3
- package/package.json +26 -15
- package/tsconfig.json +16 -0
- package/{webpack.config.cjs → webpack.config.js} +105 -58
- package/components/template/_theme.scss +0 -27
- package/components/textfield/_mixins.scss +0 -52
- package/core/color/_theme.scss +0 -390
- package/core/color/index.scss +0 -2
- package/core/theme/_mixins.scss +0 -172
- package/core/theme/_variables.scss +0 -24
- package/docs/_mixins.pug +0 -155
- package/docs/pages/appbar.pug +0 -78
- package/docs/pages/bottomnav.pug +0 -137
- package/docs/pages/button.pug +0 -121
- package/docs/pages/card.pug +0 -74
- package/docs/pages/chip.pug +0 -91
- package/docs/pages/color.pug +0 -121
- package/docs/pages/datatable.pug +0 -283
- package/docs/pages/dialog.pug +0 -132
- package/docs/pages/dom.pug +0 -22
- package/docs/pages/elevation.pug +0 -25
- package/docs/pages/fab.pug +0 -66
- package/docs/pages/grid.pug +0 -95
- package/docs/pages/layout.pug +0 -7
- package/docs/pages/list.pug +0 -326
- package/docs/pages/menu.pug +0 -205
- package/docs/pages/overlay.pug +0 -55
- package/docs/pages/progress.pug +0 -16
- package/docs/pages/ripple.pug +0 -21
- package/docs/pages/search.pug +0 -165
- package/docs/pages/selection.pug +0 -74
- package/docs/pages/slider.pug +0 -17
- package/docs/pages/snackbar.pug +0 -60
- package/docs/pages/tab.pug +0 -304
- package/docs/pages/textfield.pug +0 -360
- package/docs/pages/tooltip.pug +0 -78
- package/docs/pages/transition.pug +0 -76
- package/docs/pages/type.pug +0 -29
- package/docs/pwa/_dialogs.pug +0 -96
- package/docs/pwa/_menus.pug +0 -11
- package/docs/pwa/pwa.pug +0 -325
- package/docs/spec.scss +0 -26
- package/docs/themes/_component-themes.scss +0 -26
- package/docs/themes/theme-colored-fallbacks.scss +0 -17
- package/docs/themes/theme-default-fallbacks.scss +0 -17
|
@@ -1,111 +1,102 @@
|
|
|
1
|
-
|
|
1
|
+
.mdw-theme {
|
|
2
|
+
--mdw-list__divider-color: var(--mdw-divider-color);
|
|
3
|
+
--mdw-list__focus-opacity: var(--mdw-list__focus-opacity-value);
|
|
4
|
+
--mdw-list__focus-selected-opacity: calc(var(--mdw-list__focus-opacity-value) + var(--mdw-list__selected-opacity-value));
|
|
5
|
+
--mdw-list__focus-activated-opacity: calc(var(--mdw-list__focus-opacity-value) + var(--mdw-list__activated-opacity-value));
|
|
6
|
+
--mdw-list__focus-hover-opacity: calc(var(--mdw-list__focus-opacity-value) + var(--mdw-list__hover-opacity-value));
|
|
7
|
+
--mdw-list__focus-hover-selected-opacity: calc(var(--mdw-list__focus-opacity-value) + var(--mdw-list__hover-opacity-value) + var(--mdw-list__selected-opacity-value));
|
|
8
|
+
--mdw-list__focus-hover-activated-opacity: calc(var(--mdw-list__focus-opacity-value) + var(--mdw-list__hover-opacity-value) + var(--mdw-list__activated-opacity-value));
|
|
9
|
+
}
|
|
2
10
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
11
|
+
.mdw-theme[mdw-light] {
|
|
12
|
+
--mdw-list__focus-opacity-value: 0.12;
|
|
13
|
+
--mdw-list__hover-opacity-value: 0.04;
|
|
14
|
+
--mdw-list__selected-opacity-value: 0.08;
|
|
15
|
+
--mdw-list__activated-opacity-value: 0.12;
|
|
16
|
+
}
|
|
6
17
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
18
|
+
.mdw-theme[mdw-dark] {
|
|
19
|
+
--mdw-list__focus-opacity-value: 0.24;
|
|
20
|
+
--mdw-list__hover-opacity-value: 0.08;
|
|
21
|
+
--mdw-list__selected-opacity-value: 0.16;
|
|
22
|
+
--mdw-list__activated-opacity-value: 0.24;
|
|
23
|
+
}
|
|
11
24
|
|
|
12
|
-
activated-focus-opacity: (0.12 + 0.12, 0.24 + 0.24),
|
|
13
|
-
activated-hover-focus-opacity: (0.12 + 0.04 + 0.12, 0.24 + 0.08 + 0.24),
|
|
14
25
|
|
|
15
|
-
) !default;
|
|
16
26
|
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
.mdw-list__content {
|
|
28
|
+
&[mdw-ink][aria-current] {
|
|
29
|
+
.mdw-list__icon,
|
|
30
|
+
.mdw-list__text {
|
|
31
|
+
color: inherit;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
19
34
|
}
|
|
20
35
|
|
|
21
|
-
|
|
22
|
-
.mdw-
|
|
23
|
-
|
|
24
|
-
.mdw-list__icon,
|
|
25
|
-
.mdw-list__text {
|
|
26
|
-
color: inherit;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
36
|
+
.mdw-list[mdw-divider] {
|
|
37
|
+
& > .mdw-list__item:not(:last-child) .mdw-list__text::after {
|
|
38
|
+
background-color: var(--mdw-list__divider-color);
|
|
29
39
|
}
|
|
40
|
+
}
|
|
30
41
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
42
|
+
.mdw-list__item[aria-expanded]:focus {
|
|
43
|
+
& > .mdw-list__content {
|
|
44
|
+
&:not([mdw-overlay-touch="true"]) {
|
|
45
|
+
&:not([mdw-overlay-off~="focus"]):not([mdw-overlay-touch="true"])::before {
|
|
46
|
+
opacity: var(--mdw-list__focus-opacity);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&:not([aria-disabled="true"]):not([mdw-overlay-touch="true"]) {
|
|
50
|
+
&:hover:not([mdw-overlay-off~="hover"]):not([mdw-overlay-off~="focus"])::before {
|
|
51
|
+
opacity: var(--mdw-list__focus-hover-opacity);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
34
54
|
}
|
|
35
|
-
}
|
|
36
55
|
|
|
37
|
-
|
|
38
|
-
&
|
|
56
|
+
// Selected
|
|
57
|
+
&[aria-selected="true"]:not([mdw-overlay-off~="selected"]) {
|
|
39
58
|
&:not([mdw-overlay-touch="true"]) {
|
|
40
|
-
&:not([mdw-overlay-off~="focus"])
|
|
41
|
-
opacity:
|
|
59
|
+
&:focus:not([mdw-overlay-off~="focus"])::before {
|
|
60
|
+
opacity: var(--mdw-list__focus-selected-opacity);
|
|
42
61
|
}
|
|
43
|
-
|
|
44
|
-
&:not([aria-disabled="true"])
|
|
62
|
+
|
|
63
|
+
&:not([aria-disabled="true"]) {
|
|
45
64
|
&:hover:not([mdw-overlay-off~="hover"]):not([mdw-overlay-off~="focus"])::before {
|
|
46
|
-
opacity:
|
|
65
|
+
opacity: var(--mdw-list__focus-hover-selected-opacity);
|
|
47
66
|
}
|
|
48
67
|
}
|
|
49
68
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
&:not([aria-disabled="true"]) {
|
|
59
|
-
&:hover:not([mdw-overlay-off~="hover"]):not([mdw-overlay-off~="focus"])::before {
|
|
60
|
-
opacity: getThemeValue("selected-hover-focus-opacity", $type);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Activated
|
|
72
|
+
&[aria-current]:not([mdw-overlay-off~="current"]),
|
|
73
|
+
&[aria-pressed="true"]:not([mdw-overlay-off~="activated"]) {
|
|
74
|
+
&:not([mdw-overlay-touch="true"]) {
|
|
75
|
+
&:not([mdw-overlay-off~="focus"])::before {
|
|
76
|
+
opacity: var(--mdw-list__focus-activated-opacity);
|
|
63
77
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
&[aria-pressed="true"]:not([mdw-overlay-off~="activated"]) {
|
|
69
|
-
&:not([mdw-overlay-touch="true"]) {
|
|
70
|
-
&:not([mdw-overlay-off~="focus"])::before {
|
|
71
|
-
opacity: getThemeValue("activated-focus-opacity", $type);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
&:not([aria-disabled="true"]) {
|
|
75
|
-
&:hover:not([mdw-overlay-off~="hover"]):not([mdw-overlay-off~="focus"])::before {
|
|
76
|
-
opacity: getThemeValue("activated-hover-focus-opacity", $type);
|
|
77
|
-
}
|
|
78
|
+
|
|
79
|
+
&:not([aria-disabled="true"]) {
|
|
80
|
+
&:hover:not([mdw-overlay-off~="hover"]):not([mdw-overlay-off~="focus"])::before {
|
|
81
|
+
opacity: var(--mdw-list__focus-hover-activated-opacity);
|
|
78
82
|
}
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
85
|
}
|
|
82
86
|
}
|
|
87
|
+
}
|
|
83
88
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
.mdw-list__item[aria-expanded="true"] {
|
|
90
|
+
&::before,
|
|
91
|
+
&::after {
|
|
92
|
+
background-color: var(--mdw-list__divider-color);
|
|
93
|
+
}
|
|
89
94
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
95
|
+
&[mdw-ink][aria-expanded="true"] {
|
|
96
|
+
& > .mdw-list__content,
|
|
97
|
+
& > .mdw-list__content::before,
|
|
98
|
+
& > .mdw-list__content > .mdw-list__text {
|
|
99
|
+
color: inherit;
|
|
96
100
|
}
|
|
97
101
|
}
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
@include theme.addComponentFallbackRules('light') {
|
|
103
|
-
@include addThemeRules('light');
|
|
104
|
-
}
|
|
105
|
-
@include theme.addComponentFallbackRules('dark') {
|
|
106
|
-
@include addThemeRules('dark');
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
@include theme.addComponentCSSVariableRules('list', $themeValues) {
|
|
110
|
-
@include addThemeRules();
|
|
111
|
-
}
|
|
102
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Attributes from '../../core/aria/attributes.js';
|
|
2
2
|
import * as Keyboard from '../../core/aria/keyboard.js';
|
|
3
|
-
import { dispatchDomEvent
|
|
3
|
+
import { dispatchDomEvent } from '../../core/dom.js';
|
|
4
4
|
import * as Overlay from '../../core/overlay/index.js';
|
|
5
5
|
import * as Ripple from '../../core/ripple/index.js';
|
|
6
6
|
|
|
@@ -19,8 +19,7 @@ function onEnterKey(event) {
|
|
|
19
19
|
|| event.detail.altKey || event.detail.metaKey) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
/** @type {HTMLElement} */
|
|
23
|
-
const listContentElement = (event.currentTarget);
|
|
22
|
+
const listContentElement = /** @type {HTMLElement} */ (event.currentTarget);
|
|
24
23
|
if (!listContentElement) {
|
|
25
24
|
return;
|
|
26
25
|
}
|
|
@@ -39,8 +38,7 @@ function onEnterKey(event) {
|
|
|
39
38
|
*/
|
|
40
39
|
export function onClick(event) {
|
|
41
40
|
event.preventDefault();
|
|
42
|
-
/** @type {HTMLElement} */
|
|
43
|
-
const listContentElement = (event.currentTarget);
|
|
41
|
+
const listContentElement = /** @type {HTMLElement} */ (event.currentTarget);
|
|
44
42
|
if (Attributes.isDisabled(listContentElement)) {
|
|
45
43
|
return;
|
|
46
44
|
}
|
|
@@ -52,17 +50,15 @@ export function onClick(event) {
|
|
|
52
50
|
* @return {void}
|
|
53
51
|
*/
|
|
54
52
|
export function attach(listContentElement) {
|
|
55
|
-
if (!listContentElement.hasAttribute('role')) {
|
|
56
|
-
|
|
57
|
-
listContentElement.setAttribute('role', 'option');
|
|
58
|
-
}
|
|
53
|
+
if (!listContentElement.hasAttribute('role') && listContentElement.parentElement.getAttribute('role') === 'none') {
|
|
54
|
+
listContentElement.setAttribute('role', 'option');
|
|
59
55
|
}
|
|
60
|
-
|
|
56
|
+
for (const el of listContentElement.getElementsByClassName('mdw-list__icon')) {
|
|
61
57
|
el.setAttribute('aria-hidden', 'true');
|
|
62
|
-
}
|
|
63
|
-
|
|
58
|
+
}
|
|
59
|
+
for (const el of listContentElement.getElementsByClassName('mdw-list__avatar')) {
|
|
64
60
|
el.setAttribute('aria-hidden', 'true');
|
|
65
|
-
}
|
|
61
|
+
}
|
|
66
62
|
listContentElement.addEventListener('click', onClick);
|
|
67
63
|
|
|
68
64
|
if (!listContentElement.hasAttribute('mdw-no-overlay')) {
|
package/components/list/index.js
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
import * as Attributes from '../../core/aria/attributes.js';
|
|
6
6
|
import * as Keyboard from '../../core/aria/keyboard.js';
|
|
7
7
|
import * as RovingTabIndex from '../../core/aria/rovingtabindex.js';
|
|
8
|
-
import { iterateArrayLike, iterateSomeOfArrayLike } from '../../core/dom.js';
|
|
9
8
|
|
|
10
9
|
import * as ListContent from './content.js';
|
|
11
10
|
import * as ListItem from './item.js';
|
|
@@ -15,25 +14,23 @@ import * as ListItem from './item.js';
|
|
|
15
14
|
* @return {void}
|
|
16
15
|
*/
|
|
17
16
|
function onContentFocusEvent(event) {
|
|
18
|
-
/** @type {HTMLElement} */
|
|
19
|
-
const listElement = (event.currentTarget);
|
|
17
|
+
const listElement = /** @type {HTMLElement} */ (event.currentTarget);
|
|
20
18
|
const onFocusInteraction = listElement.getAttribute('mdw-on-focus');
|
|
21
19
|
if (!onFocusInteraction) {
|
|
22
20
|
return;
|
|
23
21
|
}
|
|
24
|
-
/** @type {HTMLElement} */
|
|
25
|
-
const listContentElement = (event.target);
|
|
22
|
+
const listContentElement = /** @type {HTMLElement} */ (event.target);
|
|
26
23
|
if (Attributes.isDisabled(listContentElement)) {
|
|
27
24
|
return;
|
|
28
25
|
}
|
|
29
|
-
onFocusInteraction.split(' ')
|
|
26
|
+
for (const interaction of onFocusInteraction.split(' ')) {
|
|
30
27
|
switch (interaction) {
|
|
31
28
|
case 'select':
|
|
32
29
|
ListContent.setSelected(listContentElement, true);
|
|
33
30
|
break;
|
|
34
31
|
default:
|
|
35
32
|
}
|
|
36
|
-
}
|
|
33
|
+
}
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
/**
|
|
@@ -41,8 +38,7 @@ function onContentFocusEvent(event) {
|
|
|
41
38
|
* @return {void}
|
|
42
39
|
*/
|
|
43
40
|
function onSelectedChangeEvent(event) {
|
|
44
|
-
/** @type {HTMLElement} */
|
|
45
|
-
const listElement = (event.currentTarget);
|
|
41
|
+
const listElement = /** @type {HTMLElement} */ (event.currentTarget);
|
|
46
42
|
// List is readonly
|
|
47
43
|
if (listElement.getAttribute('aria-readonly') === 'true') {
|
|
48
44
|
event.stopPropagation();
|
|
@@ -54,8 +50,7 @@ function onSelectedChangeEvent(event) {
|
|
|
54
50
|
// Bubble up
|
|
55
51
|
return;
|
|
56
52
|
}
|
|
57
|
-
|
|
58
|
-
if (detail.value === 'false') {
|
|
53
|
+
if (event.detail.value === 'false') {
|
|
59
54
|
// Item is radio-like and cannot be unselected
|
|
60
55
|
if (listElement.getAttribute('aria-required') === 'true'
|
|
61
56
|
&& listElement.getAttribute('aria-multiselectable') !== 'true') {
|
|
@@ -64,8 +59,7 @@ function onSelectedChangeEvent(event) {
|
|
|
64
59
|
}
|
|
65
60
|
return;
|
|
66
61
|
}
|
|
67
|
-
/** @type {HTMLElement} */
|
|
68
|
-
const itemElement = (event.target);
|
|
62
|
+
const itemElement = /** @type {HTMLElement} */ (event.target);
|
|
69
63
|
if (listElement.getAttribute('aria-multiselectable') !== 'true') {
|
|
70
64
|
// Item is radio-like and must uncheck others
|
|
71
65
|
setTimeout(() => {
|
|
@@ -74,13 +68,11 @@ function onSelectedChangeEvent(event) {
|
|
|
74
68
|
return;
|
|
75
69
|
}
|
|
76
70
|
const role = itemElement.getAttribute('role');
|
|
77
|
-
|
|
78
|
-
(item)
|
|
79
|
-
if (item === itemElement) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
71
|
+
for (const item of listElement.querySelectorAll(`[role="${role}"][aria-selected="true"]`)) {
|
|
72
|
+
if (item !== itemElement) {
|
|
82
73
|
item.setAttribute('aria-selected', 'false');
|
|
83
|
-
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
84
76
|
});
|
|
85
77
|
}
|
|
86
78
|
}
|
|
@@ -91,10 +83,8 @@ function onSelectedChangeEvent(event) {
|
|
|
91
83
|
*/
|
|
92
84
|
function onTabIndexZeroed(event) {
|
|
93
85
|
event.stopPropagation();
|
|
94
|
-
/** @type {HTMLElement} */
|
|
95
|
-
const
|
|
96
|
-
/** @type {HTMLElement} */
|
|
97
|
-
const currentItem = (event.target);
|
|
86
|
+
const listElement = /** @type {HTMLElement} */ (event.currentTarget);
|
|
87
|
+
const currentItem = /** @type {HTMLElement} */ (event.target);
|
|
98
88
|
switch (listElement.getAttribute('role')) {
|
|
99
89
|
case 'tree':
|
|
100
90
|
RovingTabIndex.removeTabIndex(listElement.querySelectorAll('[role="treeitem"]'), [currentItem]);
|
|
@@ -119,8 +109,7 @@ function onDownArrowKey(event) {
|
|
|
119
109
|
}
|
|
120
110
|
event.preventDefault();
|
|
121
111
|
event.stopPropagation();
|
|
122
|
-
/** @type {HTMLElement} */
|
|
123
|
-
const listElement = (event.currentTarget);
|
|
112
|
+
const listElement = /** @type {HTMLElement} */ (event.currentTarget);
|
|
124
113
|
switch (listElement.getAttribute('role')) {
|
|
125
114
|
case 'tree':
|
|
126
115
|
RovingTabIndex.selectNext(listElement.querySelectorAll('[role="treeitem"]'));
|
|
@@ -146,8 +135,7 @@ function onUpArrowKey(event) {
|
|
|
146
135
|
}
|
|
147
136
|
event.preventDefault();
|
|
148
137
|
event.stopPropagation();
|
|
149
|
-
/** @type {HTMLElement} */
|
|
150
|
-
const listElement = (event.currentTarget);
|
|
138
|
+
const listElement = /** @type {HTMLElement} */ (event.currentTarget);
|
|
151
139
|
switch (listElement.getAttribute('role')) {
|
|
152
140
|
case 'tree':
|
|
153
141
|
RovingTabIndex.selectPrevious(listElement.querySelectorAll('[role="treeitem"]'));
|
|
@@ -188,21 +176,27 @@ export function attach(listElement) {
|
|
|
188
176
|
const parentRole = listElement.parentElement && listElement.parentElement.getAttribute('role');
|
|
189
177
|
if (parentRole === 'treeitem') {
|
|
190
178
|
newRole = 'group';
|
|
191
|
-
} else
|
|
192
|
-
(
|
|
193
|
-
|
|
179
|
+
} else {
|
|
180
|
+
for (const child of listElement.children) {
|
|
181
|
+
if (child.hasAttribute('aria-expanded') && child.classList.contains('mdw-list__item')) {
|
|
182
|
+
newRole = 'tree';
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
194
186
|
}
|
|
195
187
|
listElement.setAttribute('role', newRole);
|
|
196
188
|
role = newRole;
|
|
197
189
|
}
|
|
198
190
|
|
|
199
191
|
setupAria(listElement, role);
|
|
200
|
-
|
|
192
|
+
for (const child of listElement.children) {
|
|
201
193
|
if (child.classList.contains('mdw-list__item')) {
|
|
202
194
|
ListItem.attach(child);
|
|
203
195
|
}
|
|
204
|
-
}
|
|
205
|
-
|
|
196
|
+
}
|
|
197
|
+
for (const el of listElement.getElementsByClassName('mdw-list')) {
|
|
198
|
+
attach(el);
|
|
199
|
+
}
|
|
206
200
|
if (listElement.hasAttribute('mdw-list-js')) {
|
|
207
201
|
return;
|
|
208
202
|
}
|
|
@@ -237,7 +231,7 @@ export function attach(listElement) {
|
|
|
237
231
|
* @return {void}
|
|
238
232
|
*/
|
|
239
233
|
export function attachAll(root = document) {
|
|
240
|
-
|
|
234
|
+
for (const el of root.getElementsByClassName('mdw-list')) attach(el);
|
|
241
235
|
}
|
|
242
236
|
|
|
243
237
|
/**
|
|
@@ -245,13 +239,15 @@ export function attachAll(root = document) {
|
|
|
245
239
|
* @return {void}
|
|
246
240
|
*/
|
|
247
241
|
export function detach(listElement) {
|
|
248
|
-
|
|
242
|
+
for (const child of listElement.children) {
|
|
249
243
|
if (child.classList.contains('mdw-list__item')) {
|
|
250
244
|
ListItem.detach(child);
|
|
251
245
|
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
|
|
246
|
+
}
|
|
247
|
+
const elements = listElement.querySelectorAll(`[role="${listElement.getAttribute('role') === 'tree' ? 'treeitem' : 'option'}"]`);
|
|
248
|
+
for (const element of elements) {
|
|
249
|
+
RovingTabIndex.detach(element);
|
|
250
|
+
}
|
|
255
251
|
listElement.removeEventListener(ListContent.SELECTED_CHANGE_EVENT, onSelectedChangeEvent);
|
|
256
252
|
listElement.removeEventListener(Keyboard.DOWN_ARROW_KEY, onDownArrowKey);
|
|
257
253
|
listElement.removeEventListener(Keyboard.UP_ARROW_KEY, onUpArrowKey);
|
package/components/list/item.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Keyboard from '../../core/aria/keyboard.js';
|
|
2
|
-
import { getChildElementByClass
|
|
2
|
+
import { getChildElementByClass } from '../../core/dom.js';
|
|
3
3
|
|
|
4
4
|
import * as ListContent from './content.js';
|
|
5
5
|
|
|
@@ -18,9 +18,9 @@ export function isExpanded(listItemElement) {
|
|
|
18
18
|
*/
|
|
19
19
|
export function setExpanded(listItemElement, value) {
|
|
20
20
|
listItemElement.setAttribute('aria-expanded', value ? 'true' : 'false');
|
|
21
|
-
|
|
21
|
+
for (const treeitem of listItemElement.querySelectorAll('[role="treeitem"]')) {
|
|
22
22
|
treeitem.setAttribute('mdw-skip-tab', value ? 'false' : 'true');
|
|
23
|
-
}
|
|
23
|
+
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -28,10 +28,8 @@ export function setExpanded(listItemElement, value) {
|
|
|
28
28
|
* @return {void}
|
|
29
29
|
*/
|
|
30
30
|
export function onChildContentActivate(event) {
|
|
31
|
-
/** @type {HTMLElement} */
|
|
32
|
-
const
|
|
33
|
-
/** @type {HTMLElement} */
|
|
34
|
-
const element = (event.currentTarget);
|
|
31
|
+
const activatedElement = /** @type {HTMLElement} */ (event.target);
|
|
32
|
+
const element = /** @type {HTMLElement} */ (event.currentTarget);
|
|
35
33
|
if (!activatedElement || activatedElement.parentElement !== element) {
|
|
36
34
|
return;
|
|
37
35
|
}
|
|
@@ -110,8 +108,7 @@ function onKeyDown(event) {
|
|
|
110
108
|
if (document.activeElement !== event.currentTarget) {
|
|
111
109
|
return;
|
|
112
110
|
}
|
|
113
|
-
/** @type {HTMLElement} */
|
|
114
|
-
const element = (event.currentTarget);
|
|
111
|
+
const element = /** @type {HTMLElement} */ (event.currentTarget);
|
|
115
112
|
if (!element) {
|
|
116
113
|
return;
|
|
117
114
|
}
|
|
@@ -142,7 +139,7 @@ export function attachCore(listItemElement) {
|
|
|
142
139
|
*/
|
|
143
140
|
export function attach(listItemElement) {
|
|
144
141
|
attachCore(listItemElement);
|
|
145
|
-
|
|
142
|
+
for (const element of listItemElement.getElementsByClassName('mdw-list__content')) { ListContent.attach(element); }
|
|
146
143
|
if (listItemElement.hasAttribute('aria-expanded')) {
|
|
147
144
|
if (!listItemElement.hasAttribute('mdw-expander-js')) {
|
|
148
145
|
listItemElement.setAttribute('mdw-pre-expander-js', '');
|
|
@@ -166,5 +163,5 @@ export function attach(listItemElement) {
|
|
|
166
163
|
*/
|
|
167
164
|
export function detach(listItemElement) {
|
|
168
165
|
Keyboard.detach(listItemElement);
|
|
169
|
-
|
|
166
|
+
for (const element of listItemElement.getElementsByClassName('mdw-list__content')) { ListContent.detach(element); }
|
|
170
167
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { dispatchDomEvent
|
|
1
|
+
import { dispatchDomEvent } from '../../core/dom.js';
|
|
2
2
|
|
|
3
3
|
export const SECONDARY_ACTION_EVENT = 'mdw:listsecondary-action';
|
|
4
4
|
|
|
@@ -16,8 +16,7 @@ export function onInteraction(event) {
|
|
|
16
16
|
*/
|
|
17
17
|
export function onClick(event) {
|
|
18
18
|
event.stopPropagation();
|
|
19
|
-
/** @type {HTMLElement} */
|
|
20
|
-
const listSecondaryElement = (event.currentTarget);
|
|
19
|
+
const listSecondaryElement = /** @type {HTMLElement} */ (event.currentTarget);
|
|
21
20
|
dispatchDomEvent(listSecondaryElement, SECONDARY_ACTION_EVENT);
|
|
22
21
|
}
|
|
23
22
|
|
|
@@ -30,9 +29,9 @@ export function attach(listSecondaryElement) {
|
|
|
30
29
|
return;
|
|
31
30
|
}
|
|
32
31
|
listSecondaryElement.addEventListener('click', onClick);
|
|
33
|
-
listSecondaryElement.addEventListener('mousedown', onInteraction,
|
|
34
|
-
listSecondaryElement.addEventListener('touchstart', onInteraction,
|
|
35
|
-
listSecondaryElement.addEventListener('keydown', onInteraction,
|
|
32
|
+
listSecondaryElement.addEventListener('mousedown', onInteraction, { passive: true });
|
|
33
|
+
listSecondaryElement.addEventListener('touchstart', onInteraction, { passive: true });
|
|
34
|
+
listSecondaryElement.addEventListener('keydown', onInteraction, { passive: true });
|
|
36
35
|
}
|
|
37
36
|
/**
|
|
38
37
|
* @param {Element} listSecondaryElement
|
|
@@ -40,7 +39,7 @@ export function attach(listSecondaryElement) {
|
|
|
40
39
|
*/
|
|
41
40
|
export function detach(listSecondaryElement) {
|
|
42
41
|
listSecondaryElement.removeEventListener('click', onClick);
|
|
43
|
-
listSecondaryElement.removeEventListener('mousedown', onInteraction
|
|
44
|
-
listSecondaryElement.removeEventListener('touchstart', onInteraction
|
|
45
|
-
listSecondaryElement.removeEventListener('keydown', onInteraction
|
|
42
|
+
listSecondaryElement.removeEventListener('mousedown', onInteraction);
|
|
43
|
+
listSecondaryElement.removeEventListener('touchstart', onInteraction);
|
|
44
|
+
listSecondaryElement.removeEventListener('keydown', onInteraction);
|
|
46
45
|
}
|