@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.
Files changed (184) hide show
  1. package/.browserslistrc +2 -1
  2. package/.eslintrc.json +59 -8
  3. package/.stylelintrc.json +94 -49
  4. package/CHANGELOG.md +12 -0
  5. package/README.md +1 -3
  6. package/adapters/datatable/column.js +27 -54
  7. package/adapters/datatable/index.js +69 -81
  8. package/adapters/dom/index.js +32 -47
  9. package/adapters/search/index.js +107 -133
  10. package/components/appbar/_spec.scss +77 -137
  11. package/components/banner/_spec.scss +28 -63
  12. package/components/bottomnav/_spec.scss +46 -54
  13. package/components/bottomnav/index.js +15 -20
  14. package/components/bottomnav/item.js +4 -5
  15. package/components/button/README.md +1 -1
  16. package/components/button/_spec.scss +43 -42
  17. package/components/button/_theme.scss +27 -50
  18. package/components/card/_spec.scss +61 -69
  19. package/components/chip/_spec.scss +21 -44
  20. package/components/chip/_theme.scss +79 -151
  21. package/components/chip/index.js +6 -4
  22. package/components/datatable/_spec.scss +36 -99
  23. package/components/datatable/_theme.scss +98 -124
  24. package/components/datatable/cell.js +1 -2
  25. package/components/datatable/columnheader.js +1 -2
  26. package/components/datatable/index.js +33 -47
  27. package/components/datatable/row.js +4 -5
  28. package/components/dialog/_spec.scss +53 -63
  29. package/components/dialog/_theme.scss +7 -0
  30. package/components/dialog/index.js +62 -88
  31. package/components/divider/_spec.scss +6 -8
  32. package/components/elevation/_spec.scss +1 -1
  33. package/components/fab/_spec.scss +30 -42
  34. package/components/fab/index.js +4 -8
  35. package/components/grid/_spec.scss +68 -211
  36. package/components/layout/_mixins.scss +0 -22
  37. package/components/layout/_spec.scss +267 -363
  38. package/components/layout/_theme.scss +10 -35
  39. package/components/layout/index.js +40 -50
  40. package/components/list/_spec.scss +57 -91
  41. package/components/list/_theme.scss +75 -84
  42. package/components/list/content.js +9 -13
  43. package/components/list/index.js +34 -38
  44. package/components/list/item.js +8 -11
  45. package/components/list/secondary.js +8 -9
  46. package/components/menu/_spec.scss +134 -167
  47. package/components/menu/index.js +45 -61
  48. package/components/menu/item.js +11 -19
  49. package/components/progress/_spec.scss +43 -34
  50. package/components/selection/_spec.scss +123 -133
  51. package/components/selection/_theme.scss +88 -120
  52. package/components/selection/index.js +9 -15
  53. package/components/selection/input.js +3 -5
  54. package/components/selection/radiogroup.js +8 -15
  55. package/components/slider/_spec.scss +23 -28
  56. package/components/snackbar/_spec.scss +17 -62
  57. package/components/snackbar/index.js +15 -21
  58. package/components/tab/_spec.scss +35 -50
  59. package/components/tab/content.js +33 -28
  60. package/components/tab/index.js +30 -33
  61. package/components/tab/item.js +4 -5
  62. package/components/tab/list.js +22 -36
  63. package/components/textfield/README.md +2 -2
  64. package/components/textfield/_spec.scss +241 -287
  65. package/components/textfield/_theme.scss +197 -232
  66. package/components/textfield/index.js +8 -16
  67. package/components/tooltip/_spec.scss +23 -26
  68. package/components/type/_spec.scss +19 -16
  69. package/core/_breakpoint.scss +33 -33
  70. package/core/_elevation.scss +40 -0
  71. package/core/_length.scss +0 -1
  72. package/core/_platform.scss +0 -22
  73. package/core/_type.scss +7 -6
  74. package/core/aria/button.js +4 -5
  75. package/core/aria/keyboard.js +1 -2
  76. package/core/aria/rovingtabindex.js +14 -17
  77. package/core/aria/tab.js +1 -2
  78. package/core/dom.js +18 -109
  79. package/core/overlay/_spec.scss +5 -8
  80. package/core/overlay/_theme.scss +126 -150
  81. package/core/overlay/index.js +19 -32
  82. package/core/ripple/_spec.scss +16 -17
  83. package/core/ripple/_theme.scss +13 -33
  84. package/core/ripple/index.js +36 -44
  85. package/core/theme/_aliases.scss +15 -0
  86. package/core/theme/_config.scss +8 -2
  87. package/core/theme/_functions.scss +22 -0
  88. package/core/theme/_palettes.scss +0 -1
  89. package/core/{color → theme}/_spec.scss +0 -0
  90. package/core/theme/_theme.scss +268 -0
  91. package/core/theme/index.scss +4 -0
  92. package/core/transition/index.js +73 -76
  93. package/docs/_flex.scss +7 -1
  94. package/docs/_menuoptions.js +2 -2
  95. package/docs/_partials/_appbar.eta +12 -14
  96. package/docs/_partials/_header.eta +41 -44
  97. package/docs/_sample-utils.js +15 -20
  98. package/docs/docs.scss +123 -87
  99. package/docs/framework.scss +26 -0
  100. package/docs/index.eta +2 -6
  101. package/docs/index.js +7 -0
  102. package/docs/pages/appbar.eta +22 -28
  103. package/docs/pages/bottomnav.js +17 -14
  104. package/docs/pages/button.js +10 -10
  105. package/docs/pages/card.js +20 -22
  106. package/docs/pages/chip.js +11 -13
  107. package/docs/pages/color.js +35 -36
  108. package/docs/pages/datatable.js +11 -15
  109. package/docs/pages/dialog.eta +9 -11
  110. package/docs/pages/dialog.js +6 -9
  111. package/docs/pages/dom.js +6 -9
  112. package/docs/pages/elevation.eta +10 -10
  113. package/docs/pages/fab.js +2 -3
  114. package/docs/pages/grid.js +5 -5
  115. package/docs/pages/list.js +1 -2
  116. package/docs/pages/menu.eta +17 -19
  117. package/docs/pages/menu.js +7 -11
  118. package/docs/pages/overlay.js +1 -2
  119. package/docs/pages/progress.eta +2 -2
  120. package/docs/pages/progress.js +1 -1
  121. package/docs/pages/ripple.js +1 -2
  122. package/docs/pages/search.eta +20 -24
  123. package/docs/pages/search.js +24 -41
  124. package/docs/pages/selection.eta +2 -6
  125. package/docs/pages/selection.js +3 -4
  126. package/docs/pages/snackbar.js +3 -4
  127. package/docs/pages/tab.eta +61 -75
  128. package/docs/pages/tab.js +16 -15
  129. package/docs/pages/textfield.eta +9 -8
  130. package/docs/pages/textfield.js +26 -23
  131. package/docs/pages/tooltip.eta +10 -12
  132. package/docs/pages/transition.js +5 -7
  133. package/docs/postrender.js +7 -5
  134. package/docs/pwa/pwa.eta +14 -16
  135. package/docs/pwa/pwa.js +19 -27
  136. package/docs/pwa/pwa.scss +12 -7
  137. package/docs/themes/theme-colored.scss +9 -11
  138. package/docs/themes/theme-default.scss +0 -14
  139. package/index.scss +27 -0
  140. package/jsconfig.json +7 -3
  141. package/package.json +26 -15
  142. package/tsconfig.json +16 -0
  143. package/{webpack.config.cjs → webpack.config.js} +105 -58
  144. package/components/template/_theme.scss +0 -27
  145. package/components/textfield/_mixins.scss +0 -52
  146. package/core/color/_theme.scss +0 -390
  147. package/core/color/index.scss +0 -2
  148. package/core/theme/_mixins.scss +0 -172
  149. package/core/theme/_variables.scss +0 -24
  150. package/docs/_mixins.pug +0 -155
  151. package/docs/pages/appbar.pug +0 -78
  152. package/docs/pages/bottomnav.pug +0 -137
  153. package/docs/pages/button.pug +0 -121
  154. package/docs/pages/card.pug +0 -74
  155. package/docs/pages/chip.pug +0 -91
  156. package/docs/pages/color.pug +0 -121
  157. package/docs/pages/datatable.pug +0 -283
  158. package/docs/pages/dialog.pug +0 -132
  159. package/docs/pages/dom.pug +0 -22
  160. package/docs/pages/elevation.pug +0 -25
  161. package/docs/pages/fab.pug +0 -66
  162. package/docs/pages/grid.pug +0 -95
  163. package/docs/pages/layout.pug +0 -7
  164. package/docs/pages/list.pug +0 -326
  165. package/docs/pages/menu.pug +0 -205
  166. package/docs/pages/overlay.pug +0 -55
  167. package/docs/pages/progress.pug +0 -16
  168. package/docs/pages/ripple.pug +0 -21
  169. package/docs/pages/search.pug +0 -165
  170. package/docs/pages/selection.pug +0 -74
  171. package/docs/pages/slider.pug +0 -17
  172. package/docs/pages/snackbar.pug +0 -60
  173. package/docs/pages/tab.pug +0 -304
  174. package/docs/pages/textfield.pug +0 -360
  175. package/docs/pages/tooltip.pug +0 -78
  176. package/docs/pages/transition.pug +0 -76
  177. package/docs/pages/type.pug +0 -29
  178. package/docs/pwa/_dialogs.pug +0 -96
  179. package/docs/pwa/_menus.pug +0 -11
  180. package/docs/pwa/pwa.pug +0 -325
  181. package/docs/spec.scss +0 -26
  182. package/docs/themes/_component-themes.scss +0 -26
  183. package/docs/themes/theme-colored-fallbacks.scss +0 -17
  184. package/docs/themes/theme-default-fallbacks.scss +0 -17
@@ -1,111 +1,102 @@
1
- @use '../../core/theme/_mixins.scss' as theme;
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
- $themeValues: (
4
- divider-color: theme.$foreground,
5
- divider-opacity: theme.$divider-opacity,
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
- focus-opacity: (0.12, 0.24),
8
- hover-focus-opacity: (0.04 + 0.12, 0.08 + 0.24),
9
- selected-focus-opacity: (0.08 + 0.12, 0.16 + 0.24),
10
- selected-hover-focus-opacity: (0.08 + 0.04 + 0.12, 0.16 + 0.08 + 0.24),
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
- @function getThemeValue($key, $type) {
18
- @return theme.getThemeValue('list', $themeValues, $key, $type);
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
- @mixin addThemeRules($type: 'var') {
22
- .mdw-list__content {
23
- &[mdw-ink][aria-current] {
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
- .mdw-list[mdw-divider] {
32
- & > .mdw-list__item:not(:last-child) .mdw-list__text::after {
33
- background-color: RGBA(getThemeValue("divider-color", $type), getThemeValue("divider-opacity", $type));
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
- .mdw-list__item[aria-expanded]:focus {
38
- & > .mdw-list__content {
56
+ // Selected
57
+ &[aria-selected="true"]:not([mdw-overlay-off~="selected"]) {
39
58
  &:not([mdw-overlay-touch="true"]) {
40
- &:not([mdw-overlay-off~="focus"]):not([mdw-overlay-touch="true"])::before {
41
- opacity: getThemeValue("focus-opacity", $type);
59
+ &:focus:not([mdw-overlay-off~="focus"])::before {
60
+ opacity: var(--mdw-list__focus-selected-opacity);
42
61
  }
43
-
44
- &:not([aria-disabled="true"]):not([mdw-overlay-touch="true"]) {
62
+
63
+ &:not([aria-disabled="true"]) {
45
64
  &:hover:not([mdw-overlay-off~="hover"]):not([mdw-overlay-off~="focus"])::before {
46
- opacity: getThemeValue("hover-focus-opacity", $type);
65
+ opacity: var(--mdw-list__focus-hover-selected-opacity);
47
66
  }
48
67
  }
49
68
  }
50
-
51
- // Selected
52
- &[aria-selected="true"]:not([mdw-overlay-off~="selected"]) {
53
- &:not([mdw-overlay-touch="true"]) {
54
- &:focus:not([mdw-overlay-off~="focus"])::before {
55
- opacity: getThemeValue("selected-focus-opacity", $type);
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
- // Activated
67
- &[aria-current]:not([mdw-overlay-off~="current"]),
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
- .mdw-list__item[aria-expanded="true"] {
85
- &::before,
86
- &::after {
87
- background-color: RGBA(getThemeValue("divider-color", $type), getThemeValue("divider-opacity", $type));
88
- }
89
+ .mdw-list__item[aria-expanded="true"] {
90
+ &::before,
91
+ &::after {
92
+ background-color: var(--mdw-list__divider-color);
93
+ }
89
94
 
90
- &[mdw-ink][aria-expanded="true"] {
91
- & > .mdw-list__content,
92
- & > .mdw-list__content::before,
93
- & > .mdw-list__content > .mdw-list__text {
94
- color: inherit;
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, iterateArrayLike } from '../../core/dom.js';
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
- if (listContentElement.parentElement.getAttribute('role') === 'none') {
57
- listContentElement.setAttribute('role', 'option');
58
- }
53
+ if (!listContentElement.hasAttribute('role') && listContentElement.parentElement.getAttribute('role') === 'none') {
54
+ listContentElement.setAttribute('role', 'option');
59
55
  }
60
- iterateArrayLike(listContentElement.getElementsByClassName('mdw-list__icon'), (el) => {
56
+ for (const el of listContentElement.getElementsByClassName('mdw-list__icon')) {
61
57
  el.setAttribute('aria-hidden', 'true');
62
- });
63
- iterateArrayLike(listContentElement.getElementsByClassName('mdw-list__avatar'), (el) => {
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')) {
@@ -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(' ').forEach((interaction) => {
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
- const { detail } = event;
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
- iterateArrayLike(listElement.querySelectorAll(`[role="${role}"][aria-selected="true"]`),
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 listElement = (event.currentTarget);
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 if (iterateSomeOfArrayLike(listElement.children,
192
- (child) => child.hasAttribute('aria-expanded') && child.classList.contains('mdw-list__item'))) {
193
- newRole = 'tree';
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
- iterateArrayLike(listElement.children, (child) => {
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
- iterateArrayLike(listElement.getElementsByClassName('mdw-list'), attach);
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
- iterateArrayLike(root.getElementsByClassName('mdw-list'), attach);
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
- iterateArrayLike(listElement.children, (child) => {
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
- iterateArrayLike(listElement.querySelectorAll(`[role="${listElement.getAttribute('role') === 'tree' ? 'treeitem' : 'option'}"]`),
254
- RovingTabIndex.detach);
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);
@@ -1,5 +1,5 @@
1
1
  import * as Keyboard from '../../core/aria/keyboard.js';
2
- import { getChildElementByClass, iterateArrayLike } from '../../core/dom.js';
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
- iterateArrayLike(listItemElement.querySelectorAll('[role="treeitem"]'), (treeitem) => {
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 activatedElement = (event.target);
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
- iterateArrayLike(listItemElement.getElementsByClassName('mdw-list__content'), ListContent.attach);
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
- iterateArrayLike(listItemElement.getElementsByClassName('mdw-list__content'), ListContent.detach);
166
+ for (const element of listItemElement.getElementsByClassName('mdw-list__content')) { ListContent.detach(element); }
170
167
  }
@@ -1,4 +1,4 @@
1
- import { dispatchDomEvent, getPassiveEventListenerOption } from '../../core/dom.js';
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, getPassiveEventListenerOption());
34
- listSecondaryElement.addEventListener('touchstart', onInteraction, getPassiveEventListenerOption());
35
- listSecondaryElement.addEventListener('keydown', onInteraction, getPassiveEventListenerOption());
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, getPassiveEventListenerOption());
44
- listSecondaryElement.removeEventListener('touchstart', onInteraction, getPassiveEventListenerOption());
45
- listSecondaryElement.removeEventListener('keydown', onInteraction, getPassiveEventListenerOption());
42
+ listSecondaryElement.removeEventListener('mousedown', onInteraction);
43
+ listSecondaryElement.removeEventListener('touchstart', onInteraction);
44
+ listSecondaryElement.removeEventListener('keydown', onInteraction);
46
45
  }