@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
package/core/dom.js CHANGED
@@ -1,40 +1,3 @@
1
- /** @type {?boolean} */
2
- let passiveEventListenerSupported = null;
3
-
4
- /** @return {void} */
5
- function testPassiveEventListenerOptionSupport() {
6
- try {
7
- passiveEventListenerSupported = false;
8
- const options = {
9
- get passive() {
10
- passiveEventListenerSupported = true;
11
- return true;
12
- },
13
- };
14
- // @ts-ignore: Custom test event
15
- window.addEventListener('test', options, options);
16
- // @ts-ignore: Custom test event
17
- window.removeEventListener('test', options, options);
18
- } catch (err) {
19
- passiveEventListenerSupported = false;
20
- }
21
- }
22
-
23
- /** @return {Object|boolean} */
24
- export function getPassiveEventListenerOption() {
25
- if (passiveEventListenerSupported == null) {
26
- testPassiveEventListenerOptionSupport();
27
- }
28
- if (passiveEventListenerSupported) {
29
- return { passive: true };
30
- }
31
- return false;
32
- }
33
-
34
- export const nextTick = window.requestAnimationFrame || ((cb) => window.setTimeout(cb, 17));
35
-
36
- export const cancelTick = window.cancelAnimationFrame || window.clearTimeout;
37
-
38
1
  /**
39
2
  * @param {Element} element
40
3
  * @param {string} className
@@ -48,26 +11,6 @@ export function getChildElementByClass(element, className) {
48
11
  return child;
49
12
  }
50
13
 
51
- /**
52
- * @param {Element} element
53
- * @param {string} className
54
- * @param {boolean} [includeSelf=true]
55
- * @return {HTMLElement}
56
- */
57
- export function findElementParentByClassName(element, className, includeSelf) {
58
- let el;
59
- if (includeSelf === false) {
60
- el = element.parentElement;
61
- } else {
62
- /** @type {HTMLElement} */
63
- el = (element);
64
- }
65
- while (el != null && !el.classList.contains(className)) {
66
- el = el.parentElement;
67
- }
68
- return el;
69
- }
70
-
71
14
  /** @return {boolean} */
72
15
  export function isRtl() {
73
16
  return document.documentElement.dir === 'rtl';
@@ -104,26 +47,6 @@ export function dispatchDomEvent(eventTarget, type, detail) {
104
47
  return eventTarget.dispatchEvent(event);
105
48
  }
106
49
 
107
- /**
108
- * @param {ArrayLike<T>} arrayLike
109
- * @param {function(T, number, ArrayLike<T>):any} fn
110
- * @return {void}
111
- * @template {any} T
112
- */
113
- export function iterateArrayLike(arrayLike, fn) {
114
- Array.prototype.forEach.call(arrayLike, fn);
115
- }
116
-
117
- /**
118
- * @param {ArrayLike<T>} arrayLike
119
- * @param {function(T, number, ArrayLike<T>):boolean|void} fn
120
- * @return {boolean}
121
- * @template {any} T
122
- */
123
- export function iterateSomeOfArrayLike(arrayLike, fn) {
124
- return Array.prototype.some.call(arrayLike, fn);
125
- }
126
-
127
50
  /**
128
51
  * @param {Element} element
129
52
  * @param {function(Element, number):boolean|void} fn
@@ -177,50 +100,36 @@ export function iterateSomeOfElementSiblings(element, fn) {
177
100
  /**
178
101
  * @param {Node} node
179
102
  * @param {boolean} [create]
180
- * @return {Text}
103
+ * @return {?Text}
181
104
  */
182
105
  export function getTextNode(node, create) {
183
- let textNode;
184
- iterateSomeOfArrayLike(node.childNodes, (childNode) => {
185
- if (childNode.nodeType !== Node.TEXT_NODE) {
186
- return false;
106
+ for (const childNode of node.childNodes) {
107
+ if (childNode.nodeType === Node.TEXT_NODE) {
108
+ return /** @type {Text} */ (childNode);
187
109
  }
188
- textNode = childNode;
189
- return true;
190
- });
191
- if (create && !textNode) {
192
- textNode = document.createTextNode('');
193
- node.appendChild(textNode);
194
110
  }
195
- return textNode;
111
+ if (!create) return null;
112
+ return node.appendChild(document.createTextNode(''));
196
113
  }
197
114
 
198
115
  /**
199
116
  * @param {Node} node
200
117
  * @param {string} value
201
- * @return {Node}
118
+ * @return {?Text}
202
119
  */
203
120
  export function setTextNode(node, value) {
204
- /** @type {ChildNode} */
205
- let textNode;
206
- iterateSomeOfArrayLike(node.childNodes, (childNode) => {
207
- if (childNode.nodeType !== Node.TEXT_NODE) {
208
- return false;
209
- }
210
- textNode = childNode;
211
- return true;
212
- });
213
- if (value) {
214
- if (!textNode) {
215
- textNode = document.createTextNode(value);
216
- node.appendChild(textNode);
217
- } else {
218
- textNode.nodeValue = value;
121
+ for (const childNode of node.childNodes) {
122
+ if (childNode.nodeType === Node.TEXT_NODE) {
123
+ if (value) {
124
+ childNode.nodeValue = value;
125
+ } else {
126
+ node.removeChild(childNode);
127
+ }
128
+ return /** @type {Text} */ (childNode);
219
129
  }
220
- } else if (textNode) {
221
- node.removeChild(textNode);
222
130
  }
223
- return textNode;
131
+ if (!value) return null;
132
+ return node.appendChild(document.createTextNode(value));
224
133
  }
225
134
 
226
135
  /**
@@ -265,7 +174,7 @@ export function scrollToElement(element, smooth, rtl) {
265
174
  }
266
175
  parent.style.setProperty('scroll-behavior', 'auto');
267
176
  parent.scrollLeft = targetScrollLeft;
268
- nextTick(() => {
177
+ requestAnimationFrame(() => {
269
178
  parent.style.removeProperty('scroll-behavior');
270
179
  });
271
180
  }
@@ -8,22 +8,19 @@
8
8
  border: 0;
9
9
  }
10
10
 
11
-
12
11
  &::before {
13
12
  content: '';
14
13
 
15
14
  position: absolute;
16
- top: 0;
17
- right: 0;
18
- bottom: 0;
19
- left: 0;
20
-
15
+ inset: 0;
16
+
17
+ pointer-events: none;
18
+
21
19
  transition-delay: 1ms;
22
20
  transition-duration: 0ms;
23
21
  transition-property: opacity, color, background-color;
24
22
 
25
- opacity: 0;
26
- pointer-events: none;
23
+ /* opacity handled by theme engine */
27
24
 
28
25
  background-color: currentColor;
29
26
  border-radius: inherit;
@@ -1,171 +1,147 @@
1
1
  // https://material.io/design/interaction/states.html
2
2
 
3
- @use '../theme/_mixins.scss' as theme;
4
-
5
- $themeValues: (
6
- overlay-color: theme.$foreground,
7
-
8
- high-opacity: theme.$high-opacity,
9
- medium-opacity: theme.$medium-opacity,
10
- inactive-opacity: theme.$inactive-opacity,
11
- divider-opacity: theme.$divider-opacity,
12
-
13
- disabled-opacity: (0.38, 0.50),
14
-
15
- // states
16
-
17
- hover-opacity: (0.04, 0.08),
18
- focus-opacity: (0.12, 0.24),
19
- selected-opacity: (0.08, 0.16),
20
- activated-opacity: (0.12, 0.24),
21
-
22
- hover-focus-opacity: (0.04 + 0.12, 0.08 + 0.24),
23
-
24
- selected-hover-opacity: (0.08 + 0.04, 0.16 + 0.08),
25
- selected-focus-opacity: (0.08 + 0.12, 0.16 + 0.24),
26
- selected-hover-focus-opacity: (0.08 + 0.04 + 0.12, 0.16 + 0.08 + 0.24),
27
-
28
- activated-hover-opacity: (0.12 + 0.04, 0.24 + 0.08),
29
- activated-focus-opacity: (0.12 + 0.12, 0.24 + 0.24),
30
- activated-hover-focus-opacity: (0.12 + 0.04 + 0.12, 0.24 + 0.08 + 0.24),
31
- ) !default;
32
-
33
- @function getThemeValue($key, $type) {
34
- @return theme.getThemeValue('overlay', $themeValues, $key, $type);
3
+ .mdw-theme {
4
+ --mdw-overlay__overlay-rgb: var(--mdw-ink-default);
5
+ --mdw-overlay__high-opacity: var(--mdw-high-opacity);
6
+ --mdw-overlay__medium-opacity: var(--mdw-medium-opacity);
7
+ --mdw-overlay__inactive-opacity: var(--mdw-inactive-opacity);
8
+ --mdw-overlay__divider-opacity: var(--mdw-divider-opacity);
9
+ --mdw-overlay__base-opacity: var(--mdw-overlay__base-opacity-value);
10
+ --mdw-overlay__disabled-opacity: var(--mdw-overlay__disabled-opacity-value);
11
+ --mdw-overlay__hover-opacity: var(--mdw-overlay__hover-opacity-value);
12
+ --mdw-overlay__focus-opacity: var(--mdw-overlay__focus-opacity-value);
13
+ --mdw-overlay__selected-opacity: var(--mdw-overlay__selected-opacity-value);
14
+ --mdw-overlay__activated-opacity: var(--mdw-overlay__activated-opacity-value);
15
+
35
16
  }
36
17
 
37
- @mixin addThemeRules($type: 'var') {
38
- .mdw-overlay {
39
- &,
40
- &[aria-pressed="false"]:active,
41
- &[aria-selected="true"],
42
- &[aria-pressed="true"],
43
- &[aria-current] {
44
- &::before {
45
- @if ($type == 'var') {
46
- color: RGB(var(--mdw-ink));
47
- } @else {
48
- // Handled by mdw-color
49
- }
50
- }
51
- }
18
+ .mdw-theme[mdw-light] {
19
+ --mdw-overlay__base-opacity-value: 0;
20
+ --mdw-overlay__base-opacity-elevation_1: 0;
21
+ --mdw-overlay__base-opacity-elevation_2: 0;
22
+ --mdw-overlay__base-opacity-elevation_3: 0;
23
+ --mdw-overlay__base-opacity-elevation_4: 0;
24
+ --mdw-overlay__base-opacity-elevation_6: 0;
25
+ --mdw-overlay__base-opacity-elevation_8: 0;
26
+ --mdw-overlay__base-opacity-elevation_9: 0;
27
+ --mdw-overlay__base-opacity-elevation_12: 0;
28
+ --mdw-overlay__base-opacity-elevation_16: 0;
29
+ --mdw-overlay__base-opacity-elevation_24: 0;
30
+ --mdw-overlay__disabled-opacity-value: 0.38;
31
+ --mdw-overlay__hover-opacity-value: 0.04;
32
+ --mdw-overlay__focus-opacity-value: 0.12;
33
+ --mdw-overlay__selected-opacity-value: 0.08;
34
+ --mdw-overlay__activated-opacity-value: 0.12;
35
+ }
52
36
 
53
- &[aria-selected="false"],
54
- &[aria-pressed="false"],
55
- &[aria-disabled="true"],
56
- &[aria-disabled="true"]:active {
57
- &::before {
58
- @if ($type == 'var') {
59
- color: RGB(getThemeValue("overlay-color", $type));
60
- } @else {
61
- background-color: RGB(getThemeValue("overlay-color", $type));
62
- }
63
- }
64
- }
37
+ .mdw-theme[mdw-dark] {
38
+ --mdw-overlay__base-opacity-value: 0;
39
+ --mdw-overlay__base-opacity-elevation_1: 0.05;
40
+ --mdw-overlay__base-opacity-elevation_2: 0.07;
41
+ --mdw-overlay__base-opacity-elevation_3: 0.08;
42
+ --mdw-overlay__base-opacity-elevation_4: 0.09;
43
+ --mdw-overlay__base-opacity-elevation_6: 0.11;
44
+ --mdw-overlay__base-opacity-elevation_8: 0.12;
45
+ --mdw-overlay__base-opacity-elevation_9: 0.13;
46
+ --mdw-overlay__base-opacity-elevation_12: 0.14;
47
+ --mdw-overlay__base-opacity-elevation_16: 0.15;
48
+ --mdw-overlay__base-opacity-elevation_24: 0.16;
49
+ --mdw-overlay__disabled-opacity-value: 0.50;
50
+ --mdw-overlay__hover-opacity-value: 0.08;
51
+ --mdw-overlay__focus-opacity-value: 0.24;
52
+ --mdw-overlay__selected-opacity-value: 0.16;
53
+ --mdw-overlay__activated-opacity-value: 0.24;
54
+ }
55
+
56
+ .mdw-overlay {
57
+ // Disable Hover State
58
+ &[aria-disabled="true"],
59
+ &[mdw-overlay-touch="true"],
60
+ &[mdw-overlay-off~="hover"],
61
+ &:not(:hover) {
62
+ --mdw-overlay__hover-opacity: 0;
63
+ }
64
+
65
+ // Disable Focus State
66
+ &[aria-disabled="true"],
67
+ &[mdw-overlay-touch="true"],
68
+ &[mdw-overlay-off~="focus"],
69
+ &:not(:focus) {
70
+ --mdw-overlay__focus-opacity: 0;
71
+ }
72
+
73
+ // Disable Selected State
74
+ // Activated overrides Selected
75
+ &[mdw-overlay-off~="selected"],
76
+ &:not([aria-selected="true"]),
77
+ &[aria-current],
78
+ &[aria-pressed="true"] {
79
+ --mdw-overlay__selected-opacity: 0;
80
+ }
81
+
82
+ &[mdw-overlay-off~="activated"],
83
+ &:not([aria-current]):not([aria-pressed="true"]) {
84
+ --mdw-overlay__activated-opacity: 0;
85
+ }
86
+
87
+ &::before {
88
+ opacity: calc(var(--mdw-overlay__base-opacity) + var(--mdw-overlay__hover-opacity) + var(--mdw-overlay__focus-opacity) + var(--mdw-overlay__selected-opacity) + var(--mdw-overlay__activated-opacity));
65
89
 
66
- // Off color
67
- &[aria-selected="false"],
68
- &[aria-pressed="false"],
69
- &[aria-selected="true"]:not([aria-current]) {
70
- #{if($type == 'var', '&', '&,&.mdw-theme')} {
71
- color: RGBA(getThemeValue("overlay-color", $type), getThemeValue("high-opacity", $type));
72
- &[mdw-border-ink] {
73
- border-color: RGBA(getThemeValue("overlay-color", $type), getThemeValue("divider-opacity", $type));
74
- }
75
- &[mdw-overlay-default="medium"] {
76
- color: RGBA(getThemeValue("overlay-color", $type), getThemeValue("medium-opacity", $type));
77
- }
78
- &[mdw-overlay-default="inactive"] {
79
- color: RGBA(getThemeValue("overlay-color", $type), getThemeValue("inactive-opacity", $type));
80
- }
81
- &[mdw-overlay-default="divider"] {
82
- color: RGBA(getThemeValue("overlay-color", $type), getThemeValue("divider-opacity", $type));
83
- }
84
- }
90
+ color: RGB(var(--mdw-overlay__overlay-rgb));
91
+ }
92
+
93
+ &:hover,
94
+ &:focus,
95
+ &[aria-pressed="false"]:active,
96
+ &[aria-selected="true"],
97
+ &[aria-pressed="true"],
98
+ &[aria-current] {
99
+ &::before {
100
+ color: RGB(var(--mdw-ink));
85
101
  }
102
+ }
86
103
 
87
- &[aria-disabled="true"] {
88
- &[mdw-overlay-disabled="ink"] {
89
- color: RGBA(getThemeValue("overlay-color", $type), getThemeValue("inactive-opacity", $type));
90
- }
91
- &:not([mdw-overlay-disabled]) {
92
- opacity: getThemeValue("disabled-opacity", $type);
93
- }
104
+ &[aria-selected="false"],
105
+ &[aria-pressed="false"],
106
+ &[aria-disabled="true"],
107
+ &[aria-disabled="true"]:active {
108
+ &::before {
109
+ color: RGB(var(--mdw-overlay__overlay-rgb));
94
110
  }
111
+ }
95
112
 
96
- &:not([mdw-overlay-touch="true"]) {
97
- &:focus:not([mdw-overlay-off~="focus"]):not([mdw-overlay-touch="true"])::before {
98
- opacity: getThemeValue("focus-opacity", $type);
99
- }
113
+ // Off color
114
+ &[aria-selected="false"],
115
+ &[aria-pressed="false"],
116
+ &[aria-selected="true"]:not([aria-current]) {
117
+ --mdw-overlay__text-opacity: var(--mdw-overlay__high-opacity);
100
118
 
101
- &:not([aria-disabled="true"]):not([mdw-overlay-touch="true"]) {
102
- &:hover:not([mdw-overlay-off~="hover"])::before {
103
- opacity: getThemeValue("hover-opacity", $type);
104
- }
119
+ color: RGBA(var(--mdw-overlay__overlay-rgb), var(--mdw-overlay__text-opacity));
105
120
 
106
- &:hover:focus:not([mdw-overlay-off~="hover"]):not([mdw-overlay-off~="focus"])::before {
107
- opacity: getThemeValue("hover-focus-opacity", $type);
108
- }
109
- }
121
+ &[mdw-overlay-default="medium"] {
122
+ --mdw-overlay__text-opacity: var(--mdw-overlay__medium-opacity);
110
123
  }
111
124
 
112
- // Selected
113
- &[aria-selected="true"]:not([mdw-overlay-off~="selected"]) {
114
- &::before {
115
- opacity: getThemeValue("selected-opacity", $type);
116
- }
117
-
118
- &:not([mdw-overlay-touch="true"]) {
119
- &:focus:not([mdw-overlay-off~="focus"])::before {
120
- opacity: getThemeValue("selected-focus-opacity", $type);
121
- }
122
-
123
- &:not([aria-disabled="true"]) {
124
- &:hover:not([mdw-overlay-off~="hover"])::before {
125
- opacity: getThemeValue("selected-hover-opacity", $type);
126
- }
127
-
128
- &:hover:focus:not([mdw-overlay-off~="hover"]):not([mdw-overlay-off~="focus"])::before {
129
- opacity: getThemeValue("selected-hover-focus-opacity", $type);
130
- }
131
- }
132
- }
125
+ &[mdw-overlay-default="inactive"] {
126
+ --mdw-overlay__text-opacity: var(--mdw-overlay__inactive-opacity);
133
127
  }
134
128
 
135
- // Activated
136
- &[aria-current]:not([mdw-overlay-off~="activated"]),
137
- &[aria-pressed="true"]:not([mdw-overlay-off~="activated"]) {
138
- &::before {
139
- opacity: getThemeValue("activated-opacity", $type);
140
- }
141
-
142
- &:not([mdw-overlay-touch="true"]) {
143
- &:focus:not([mdw-overlay-off~="focus"])::before {
144
- opacity: getThemeValue("activated-focus-opacity", $type);
145
- }
146
-
147
- &:not([aria-disabled="true"]) {
148
- &:hover:not([mdw-overlay-off~="hover"])::before {
149
- opacity: getThemeValue("activated-hover-opacity", $type);
150
- }
151
-
152
- &:hover:focus:not([mdw-overlay-off~="hover"]):not([mdw-overlay-off~="focus"])::before {
153
- opacity: getThemeValue("activated-hover-focus-opacity", $type);
154
- }
155
- }
156
- }
129
+ &[mdw-overlay-default="divider"] {
130
+ --mdw-overlay__text-opacity: var(--mdw-overlay__divider-opacity);
157
131
  }
158
- }
159
- }
160
132
 
161
- @include theme.addComponentFallbackRules('light') {
162
- @include addThemeRules('light');
163
- }
164
- @include theme.addComponentFallbackRules('dark') {
165
- @include addThemeRules('dark');
166
- }
133
+ &[mdw-border-ink] {
134
+ border-color: RGBA(var(--mdw-overlay__overlay-rgb), var(--mdw-overlay__divider-opacity));
135
+ }
136
+ }
167
137
 
138
+ &[aria-disabled="true"] {
139
+ &[mdw-overlay-disabled="ink"] {
140
+ color: RGBA(var(--mdw-overlay__overlay-rgb), var(--mdw-overlay__inactive-opacity));
141
+ }
168
142
 
169
- @include theme.addComponentCSSVariableRules('overlay', $themeValues) {
170
- @include addThemeRules();
143
+ &:not([mdw-overlay-disabled]) {
144
+ opacity: var(--mdw-overlay__disabled-opacity);
145
+ }
146
+ }
171
147
  }
@@ -1,5 +1,3 @@
1
- import { getPassiveEventListenerOption, iterateArrayLike } from '../dom.js';
2
-
3
1
  let lastInteractionWasTouch = false;
4
2
 
5
3
  if (window && window.matchMedia) {
@@ -11,8 +9,7 @@ if (window && window.matchMedia) {
11
9
  * @return {void}
12
10
  */
13
11
  export function onMouseDown(event) {
14
- /** @type {HTMLElement} */
15
- const element = (event.currentTarget);
12
+ const element = /** @type {HTMLElement} */ (event.currentTarget);
16
13
  if (element.hasAttribute('mdw-overlay-touch')) {
17
14
  return;
18
15
  }
@@ -24,8 +21,7 @@ export function onMouseDown(event) {
24
21
  * @return {void}
25
22
  */
26
23
  export function onTouchStart(event) {
27
- /** @type {HTMLElement} */
28
- const element = (event.currentTarget);
24
+ const element = /** @type {HTMLElement} */ (event.currentTarget);
29
25
  element.setAttribute('mdw-overlay-touch', 'true');
30
26
  }
31
27
 
@@ -34,8 +30,7 @@ export function onTouchStart(event) {
34
30
  * @return {void}
35
31
  */
36
32
  export function onKeyDown(event) {
37
- /** @type {HTMLElement} */
38
- const element = (event.currentTarget);
33
+ const element = /** @type {HTMLElement} */ (event.currentTarget);
39
34
  element.setAttribute('mdw-overlay-touch', 'false');
40
35
  }
41
36
 
@@ -44,17 +39,12 @@ export function onKeyDown(event) {
44
39
  * @return {void}
45
40
  */
46
41
  export function onBlur(event) {
47
- /** @type {HTMLElement} */
48
- const element = (event.currentTarget);
42
+ const element = /** @type {HTMLElement} */ (event.currentTarget);
49
43
  const value = element.getAttribute('mdw-overlay-touch');
50
44
  if (value == null) {
51
45
  return;
52
46
  }
53
- if (value === 'true') {
54
- lastInteractionWasTouch = true;
55
- } else {
56
- lastInteractionWasTouch = false;
57
- }
47
+ lastInteractionWasTouch = value === 'true';
58
48
  element.removeAttribute('mdw-overlay-touch');
59
49
  }
60
50
 
@@ -63,13 +53,10 @@ export function onBlur(event) {
63
53
  * @return {void}
64
54
  */
65
55
  export function onFocus(event) {
66
- /** @type {HTMLElement} */
67
- const element = (event.currentTarget);
68
- if (!element.hasAttribute('mdw-overlay-touch')) {
69
- // Element was focused without a mouse or touch event (keyboard or programmatic)
70
- if (lastInteractionWasTouch) {
71
- element.setAttribute('mdw-overlay-touch', 'true');
72
- }
56
+ const element = /** @type {HTMLElement} */ (event.currentTarget);
57
+ // Element was focused without a mouse or touch event (keyboard or programmatic)
58
+ if (!element.hasAttribute('mdw-overlay-touch') && lastInteractionWasTouch) {
59
+ element.setAttribute('mdw-overlay-touch', 'true');
73
60
  }
74
61
  }
75
62
 
@@ -79,11 +66,11 @@ export function onFocus(event) {
79
66
  */
80
67
  export function attach(element) {
81
68
  element.setAttribute('mdw-overlay-js', '');
82
- element.addEventListener('mousedown', onMouseDown, getPassiveEventListenerOption());
83
- element.addEventListener('touchstart', onTouchStart, getPassiveEventListenerOption());
84
- element.addEventListener('keydown', onKeyDown, getPassiveEventListenerOption());
85
- element.addEventListener('blur', onBlur, getPassiveEventListenerOption());
86
- element.addEventListener('focus', onFocus, getPassiveEventListenerOption());
69
+ element.addEventListener('mousedown', onMouseDown, { passive: true });
70
+ element.addEventListener('touchstart', onTouchStart, { passive: true });
71
+ element.addEventListener('keydown', onKeyDown, { passive: true });
72
+ element.addEventListener('blur', onBlur, { passive: true });
73
+ element.addEventListener('focus', onFocus, { passive: true });
87
74
  }
88
75
 
89
76
  /**
@@ -91,7 +78,7 @@ export function attach(element) {
91
78
  * @return {void}
92
79
  */
93
80
  export function attachAll(root = document) {
94
- iterateArrayLike(root.getElementsByClassName('mdw-overlay'), attach);
81
+ for (const el of root.getElementsByClassName('mdw-overlay')) attach(el);
95
82
  }
96
83
 
97
84
  /**
@@ -101,8 +88,8 @@ export function attachAll(root = document) {
101
88
  export function detach(element) {
102
89
  element.removeAttribute('mdw-overlay-js');
103
90
  element.removeAttribute('mdw-overlay-touch');
104
- element.removeEventListener('mousedown', onMouseDown, getPassiveEventListenerOption());
105
- element.removeEventListener('touchstart', onTouchStart, getPassiveEventListenerOption());
106
- element.removeEventListener('keydown', onKeyDown, getPassiveEventListenerOption());
107
- element.removeEventListener('blur', onBlur, getPassiveEventListenerOption());
91
+ element.removeEventListener('mousedown', onMouseDown);
92
+ element.removeEventListener('touchstart', onTouchStart);
93
+ element.removeEventListener('keydown', onKeyDown);
94
+ element.removeEventListener('blur', onBlur);
108
95
  }