@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
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
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
|
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 {
|
|
118
|
+
* @return {?Text}
|
|
202
119
|
*/
|
|
203
120
|
export function setTextNode(node, value) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
|
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
|
-
|
|
177
|
+
requestAnimationFrame(() => {
|
|
269
178
|
parent.style.removeProperty('scroll-behavior');
|
|
270
179
|
});
|
|
271
180
|
}
|
package/core/overlay/_spec.scss
CHANGED
|
@@ -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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
|
26
|
-
pointer-events: none;
|
|
23
|
+
/* opacity handled by theme engine */
|
|
27
24
|
|
|
28
25
|
background-color: currentColor;
|
|
29
26
|
border-radius: inherit;
|
package/core/overlay/_theme.scss
CHANGED
|
@@ -1,171 +1,147 @@
|
|
|
1
1
|
// https://material.io/design/interaction/states.html
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
}
|
|
121
|
+
&[mdw-overlay-default="medium"] {
|
|
122
|
+
--mdw-overlay__text-opacity: var(--mdw-overlay__medium-opacity);
|
|
110
123
|
}
|
|
111
124
|
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
|
|
136
|
-
|
|
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
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
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
|
-
|
|
170
|
-
|
|
143
|
+
&:not([mdw-overlay-disabled]) {
|
|
144
|
+
opacity: var(--mdw-overlay__disabled-opacity);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
171
147
|
}
|
package/core/overlay/index.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
68
|
-
if (!element.hasAttribute('mdw-overlay-touch')) {
|
|
69
|
-
|
|
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,
|
|
83
|
-
element.addEventListener('touchstart', onTouchStart,
|
|
84
|
-
element.addEventListener('keydown', onKeyDown,
|
|
85
|
-
element.addEventListener('blur', onBlur,
|
|
86
|
-
element.addEventListener('focus', onFocus,
|
|
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
|
-
|
|
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
|
|
105
|
-
element.removeEventListener('touchstart', onTouchStart
|
|
106
|
-
element.removeEventListener('keydown', onKeyDown
|
|
107
|
-
element.removeEventListener('blur', onBlur
|
|
91
|
+
element.removeEventListener('mousedown', onMouseDown);
|
|
92
|
+
element.removeEventListener('touchstart', onTouchStart);
|
|
93
|
+
element.removeEventListener('keydown', onKeyDown);
|
|
94
|
+
element.removeEventListener('blur', onBlur);
|
|
108
95
|
}
|