@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/components/menu/index.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
// https://www.w3.org/TR/wai-aria-practices/#menu
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
cancelTick,
|
|
5
4
|
dispatchDomEvent,
|
|
6
5
|
isRtl,
|
|
7
|
-
iterateArrayLike,
|
|
8
|
-
iterateSomeOfArrayLike,
|
|
9
|
-
nextTick,
|
|
10
6
|
} from '../../core/dom.js';
|
|
11
7
|
|
|
12
8
|
import * as MenuItem from './item.js';
|
|
@@ -57,11 +53,9 @@ export function hide(menuElement) {
|
|
|
57
53
|
menuStack.previousFocus.focus();
|
|
58
54
|
}
|
|
59
55
|
OPEN_MENUS.splice(stackIndex, 1);
|
|
60
|
-
if (menuStack.state && window.history && window.history.state
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
window.history.back();
|
|
64
|
-
}
|
|
56
|
+
if (menuStack.state && window.history && window.history.state // IE11 returns a cloned state object, not the original
|
|
57
|
+
&& menuStack.state.hash === window.history.state.hash) {
|
|
58
|
+
window.history.back();
|
|
65
59
|
}
|
|
66
60
|
}
|
|
67
61
|
if (!OPEN_MENUS.length) {
|
|
@@ -85,8 +79,9 @@ export function setupARIA(menuElement) {
|
|
|
85
79
|
if (!menuElement.hasAttribute('aria-hidden')) {
|
|
86
80
|
menuElement.setAttribute('aria-hidden', 'true');
|
|
87
81
|
}
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
for (const el of menuElement.getElementsByClassName('mdw-divider')) {
|
|
83
|
+
el.setAttribute('role', 'separator');
|
|
84
|
+
}
|
|
90
85
|
menuElement.setAttribute('role', 'menu');
|
|
91
86
|
const popupElement = menuElement.getElementsByClassName('mdw-menu__popup')[0];
|
|
92
87
|
if (popupElement) {
|
|
@@ -107,8 +102,7 @@ export function onMenuScroll(event) {
|
|
|
107
102
|
if (event.type !== 'scroll') {
|
|
108
103
|
return;
|
|
109
104
|
}
|
|
110
|
-
/** @type {HTMLElement} */
|
|
111
|
-
const element = (event.currentTarget);
|
|
105
|
+
const element = /** @type {HTMLElement} */ (event.currentTarget);
|
|
112
106
|
if (element.scrollTop !== 0) {
|
|
113
107
|
element.scrollTop = 0;
|
|
114
108
|
}
|
|
@@ -143,27 +137,26 @@ export function updateMenuPosition(menuElement, popupElement, event, alignTarget
|
|
|
143
137
|
const margin = useAlignTarget ? '0' : '';
|
|
144
138
|
const mdwPosition = menuElement.getAttribute('mdw-position') || '';
|
|
145
139
|
const mdwDirection = menuElement.getAttribute('mdw-direction') || '';
|
|
146
|
-
let alignTop = mdwPosition.
|
|
147
|
-
let alignBottom = mdwPosition.
|
|
148
|
-
let alignVCenter = mdwPosition.
|
|
140
|
+
let alignTop = mdwPosition.includes('top');
|
|
141
|
+
let alignBottom = mdwPosition.includes('bottom');
|
|
142
|
+
let alignVCenter = mdwPosition.includes('vcenter');
|
|
149
143
|
|
|
150
|
-
const alignStart = mdwPosition.
|
|
151
|
-
const alignEnd = mdwPosition.
|
|
152
|
-
let alignLeft = mdwPosition.
|
|
153
|
-
let alignRight = mdwPosition.
|
|
154
|
-
let alignHCenter = mdwPosition.
|
|
144
|
+
const alignStart = mdwPosition.includes('start');
|
|
145
|
+
const alignEnd = mdwPosition.includes('end');
|
|
146
|
+
let alignLeft = mdwPosition.includes('left');
|
|
147
|
+
let alignRight = mdwPosition.includes('right');
|
|
148
|
+
let alignHCenter = mdwPosition.includes('hcenter');
|
|
155
149
|
|
|
156
|
-
let openUp = mdwDirection.
|
|
157
|
-
let openDown = mdwDirection.
|
|
158
|
-
const openNormal = mdwDirection.
|
|
159
|
-
const openReverse = mdwDirection.
|
|
160
|
-
let openVCenter = mdwDirection.
|
|
161
|
-
let openHCenter = mdwDirection.
|
|
162
|
-
let openLtr = mdwDirection.
|
|
163
|
-
let openRtl = mdwDirection.
|
|
150
|
+
let openUp = mdwDirection.includes('up');
|
|
151
|
+
let openDown = mdwDirection.includes('down');
|
|
152
|
+
const openNormal = mdwDirection.includes('normal');
|
|
153
|
+
const openReverse = mdwDirection.includes('reverse');
|
|
154
|
+
let openVCenter = mdwDirection.includes('vcenter');
|
|
155
|
+
let openHCenter = mdwDirection.includes('hcenter');
|
|
156
|
+
let openLtr = mdwDirection.includes('ltr');
|
|
157
|
+
let openRtl = mdwDirection.includes('rtl');
|
|
164
158
|
|
|
165
|
-
/** @type {HTMLElement} */
|
|
166
|
-
const target = (event.currentTarget || event.target);
|
|
159
|
+
const target = /** @type {HTMLElement} */ (event.currentTarget || event.target);
|
|
167
160
|
|
|
168
161
|
let isPageRTL = null;
|
|
169
162
|
if (alignStart || alignEnd || openNormal || openReverse) {
|
|
@@ -320,10 +313,10 @@ export function updateMenuPosition(menuElement, popupElement, event, alignTarget
|
|
|
320
313
|
}
|
|
321
314
|
if (isPageRTL) {
|
|
322
315
|
candidateNumber = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 15]
|
|
323
|
-
.
|
|
316
|
+
.find((number) => candidates.includes(number));
|
|
324
317
|
} else {
|
|
325
318
|
candidateNumber = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
|
|
326
|
-
.
|
|
319
|
+
.find((number) => candidates.includes(number));
|
|
327
320
|
}
|
|
328
321
|
if (candidateNumber == null) {
|
|
329
322
|
candidateNumber = isPageRTL ? 2 : 1;
|
|
@@ -470,9 +463,9 @@ export function onWindowResize() {
|
|
|
470
463
|
return;
|
|
471
464
|
}
|
|
472
465
|
if (lastOpenMenu.pendingResizeOperation) {
|
|
473
|
-
|
|
466
|
+
cancelAnimationFrame(lastOpenMenu.pendingResizeOperation);
|
|
474
467
|
}
|
|
475
|
-
lastOpenMenu.pendingResizeOperation =
|
|
468
|
+
lastOpenMenu.pendingResizeOperation = requestAnimationFrame(() => {
|
|
476
469
|
updateMenuPosition(
|
|
477
470
|
lastOpenMenu.element,
|
|
478
471
|
/** @type {HTMLElement} */ (lastOpenMenu.element.getElementsByClassName('mdw-menu__popup')[0]),
|
|
@@ -506,8 +499,7 @@ export function onPopState(event) {
|
|
|
506
499
|
* @return {void}
|
|
507
500
|
*/
|
|
508
501
|
export function selectNextMenuItem(menu, backwards) {
|
|
509
|
-
/** @type {HTMLCollectionOf<HTMLElement>} */
|
|
510
|
-
const menuItems = (menu.getElementsByClassName('mdw-menu__item'));
|
|
502
|
+
const menuItems = /** @type {HTMLCollectionOf<HTMLElement>} */ (menu.getElementsByClassName('mdw-menu__item'));
|
|
511
503
|
let foundTarget = false;
|
|
512
504
|
/** @type {HTMLElement} */
|
|
513
505
|
let candidate = null;
|
|
@@ -519,7 +511,7 @@ export function selectNextMenuItem(menu, backwards) {
|
|
|
519
511
|
// Hidden elements cannot be focused
|
|
520
512
|
// Disabled elements cannot be focused on IE11
|
|
521
513
|
// Skip elements that fail to receive focus
|
|
522
|
-
|
|
514
|
+
for (const el of menuItems) {
|
|
523
515
|
el.focus();
|
|
524
516
|
const focusable = (document.activeElement === el);
|
|
525
517
|
if (focusable) {
|
|
@@ -531,31 +523,26 @@ export function selectNextMenuItem(menu, backwards) {
|
|
|
531
523
|
if (el === target) {
|
|
532
524
|
foundTarget = true;
|
|
533
525
|
if (backwards && candidate) {
|
|
534
|
-
|
|
526
|
+
break;
|
|
535
527
|
}
|
|
536
|
-
|
|
528
|
+
continue;
|
|
537
529
|
}
|
|
538
530
|
if (backwards) {
|
|
539
531
|
if (focusable) {
|
|
540
532
|
candidate = el;
|
|
541
533
|
}
|
|
542
|
-
|
|
534
|
+
continue;
|
|
543
535
|
}
|
|
544
536
|
if (foundTarget) {
|
|
545
537
|
if (focusable) {
|
|
546
538
|
candidate = el;
|
|
547
|
-
|
|
539
|
+
break;
|
|
548
540
|
}
|
|
549
|
-
|
|
541
|
+
continue;
|
|
550
542
|
}
|
|
551
|
-
|
|
552
|
-
});
|
|
543
|
+
}
|
|
553
544
|
if (!candidate) {
|
|
554
|
-
|
|
555
|
-
candidate = lastFocusableElement;
|
|
556
|
-
} else {
|
|
557
|
-
candidate = firstFocusableItem;
|
|
558
|
-
}
|
|
545
|
+
candidate = backwards ? lastFocusableElement : firstFocusableItem;
|
|
559
546
|
}
|
|
560
547
|
if (candidate && document.activeElement !== candidate) {
|
|
561
548
|
candidate.focus();
|
|
@@ -567,8 +554,7 @@ export function selectNextMenuItem(menu, backwards) {
|
|
|
567
554
|
* @return {void}
|
|
568
555
|
*/
|
|
569
556
|
export function onKeyDown(event) {
|
|
570
|
-
/** @type {HTMLElement} */
|
|
571
|
-
const menuElement = (event.currentTarget);
|
|
557
|
+
const menuElement = /** @type {HTMLElement} */ (event.currentTarget);
|
|
572
558
|
if (!menuElement || menuElement.getAttribute('aria-hidden') === 'true') {
|
|
573
559
|
return;
|
|
574
560
|
}
|
|
@@ -607,10 +593,10 @@ export function onKeyDown(event) {
|
|
|
607
593
|
* @return {void}
|
|
608
594
|
*/
|
|
609
595
|
export function refreshMenuItems(menuElement) {
|
|
610
|
-
|
|
596
|
+
for (const menuItem of menuElement.getElementsByClassName('mdw-menu__item')) {
|
|
611
597
|
menuItem.setAttribute('tabindex', '-1');
|
|
612
598
|
MenuItem.attach(menuItem);
|
|
613
|
-
}
|
|
599
|
+
}
|
|
614
600
|
const popupElement = menuElement.getElementsByClassName('mdw-menu__popup')[0];
|
|
615
601
|
popupElement.setAttribute('tabindex', '-1');
|
|
616
602
|
}
|
|
@@ -640,8 +626,7 @@ export function show(menuElement, event, alignTarget) {
|
|
|
640
626
|
// Prevent anchor link
|
|
641
627
|
event.preventDefault();
|
|
642
628
|
}
|
|
643
|
-
/** @type {HTMLElement} */
|
|
644
|
-
const popupElement = (menuElement.getElementsByClassName('mdw-menu__popup')[0]);
|
|
629
|
+
const popupElement = /** @type {HTMLElement} */ (menuElement.getElementsByClassName('mdw-menu__popup')[0]);
|
|
645
630
|
let changed = false;
|
|
646
631
|
if (event) {
|
|
647
632
|
updateMenuPosition(menuElement, popupElement, event, alignTarget);
|
|
@@ -664,13 +649,13 @@ export function show(menuElement, event, alignTarget) {
|
|
|
664
649
|
if (changed) {
|
|
665
650
|
attach(menuElement);
|
|
666
651
|
const previousFocus = document.activeElement;
|
|
667
|
-
const newState = { hash: Math.random().toString(36).
|
|
652
|
+
const newState = { hash: Math.random().toString(36).slice(2, 18) };
|
|
668
653
|
let previousState = null;
|
|
669
654
|
if (window.history && window.history.pushState) {
|
|
670
655
|
if (!window.history.state) {
|
|
671
656
|
// Create new previous state
|
|
672
657
|
window.history.replaceState({
|
|
673
|
-
hash: Math.random().toString(36).
|
|
658
|
+
hash: Math.random().toString(36).slice(2, 18),
|
|
674
659
|
}, document.title);
|
|
675
660
|
}
|
|
676
661
|
previousState = window.history.state;
|
|
@@ -703,8 +688,7 @@ export function detach(menuElement) {
|
|
|
703
688
|
menuElement.removeEventListener('wheel', onMenuScroll);
|
|
704
689
|
menuElement.addEventListener('keydown', onKeyDown);
|
|
705
690
|
menuElement.removeAttribute('mdw-menu-js');
|
|
706
|
-
/** @type {HTMLElement} */
|
|
707
|
-
const popupElement = (menuElement.getElementsByClassName('mdw-menu__popup')[0]);
|
|
691
|
+
const popupElement = /** @type {HTMLElement} */ (menuElement.getElementsByClassName('mdw-menu__popup')[0]);
|
|
708
692
|
if (popupElement) {
|
|
709
693
|
popupElement.style.removeProperty('top');
|
|
710
694
|
popupElement.style.removeProperty('left');
|
|
@@ -717,5 +701,5 @@ export function detach(menuElement) {
|
|
|
717
701
|
popupElement.removeAttribute('style');
|
|
718
702
|
}
|
|
719
703
|
}
|
|
720
|
-
|
|
704
|
+
for (const element of menuElement.getElementsByClassName('mdw-menu__item')) { MenuItem.detach(element); }
|
|
721
705
|
}
|
package/components/menu/item.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import * as Attributes from '../../core/aria/attributes.js';
|
|
4
4
|
import {
|
|
5
5
|
dispatchDomEvent,
|
|
6
|
-
iterateArrayLike,
|
|
7
6
|
iterateElementSiblings,
|
|
8
7
|
} from '../../core/dom.js';
|
|
9
8
|
import * as Overlay from '../../core/overlay/index.js';
|
|
@@ -39,14 +38,10 @@ export function setupARIA(element) {
|
|
|
39
38
|
if (useAriaChecked && !element.hasAttribute('aria-checked')) {
|
|
40
39
|
element.setAttribute('aria-checked', 'false');
|
|
41
40
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
iterateArrayLike(element.getElementsByClassName('mdw-menu__check'),
|
|
47
|
-
(el) => el.setAttribute('aria-hidden', 'true'));
|
|
48
|
-
iterateArrayLike(element.getElementsByClassName('mdw-menu__info'),
|
|
49
|
-
(el) => el.setAttribute('role', 'note'));
|
|
41
|
+
for (const el of element.getElementsByClassName('mdw-menu__icon')) el.setAttribute('aria-hidden', 'true');
|
|
42
|
+
for (const el of element.getElementsByClassName('mdw-menu__text')) el.setAttribute('role', 'text');
|
|
43
|
+
for (const el of element.getElementsByClassName('mdw-menu__check')) el.setAttribute('aria-hidden', 'true');
|
|
44
|
+
for (const el of element.getElementsByClassName('mdw-menu__info')) el.setAttribute('role', 'note');
|
|
50
45
|
}
|
|
51
46
|
|
|
52
47
|
/**
|
|
@@ -54,8 +49,7 @@ export function setupARIA(element) {
|
|
|
54
49
|
* @return {void}
|
|
55
50
|
*/
|
|
56
51
|
export function onMouseMove(event) {
|
|
57
|
-
/** @type {HTMLElement} */
|
|
58
|
-
const el = (event.currentTarget);
|
|
52
|
+
const el = /** @type {HTMLElement} */ (event.currentTarget);
|
|
59
53
|
if (!el) {
|
|
60
54
|
return;
|
|
61
55
|
}
|
|
@@ -68,10 +62,10 @@ export function onMouseMove(event) {
|
|
|
68
62
|
return;
|
|
69
63
|
}
|
|
70
64
|
el.focus();
|
|
71
|
-
if (document.activeElement !== el
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
65
|
+
if (document.activeElement !== el
|
|
66
|
+
&& document.activeElement !== previousFocus
|
|
67
|
+
&& previousFocus instanceof HTMLElement) {
|
|
68
|
+
previousFocus.focus();
|
|
75
69
|
}
|
|
76
70
|
}
|
|
77
71
|
|
|
@@ -139,8 +133,7 @@ export function openSubMenu(element) {
|
|
|
139
133
|
export function onClick(event) {
|
|
140
134
|
event.stopPropagation();
|
|
141
135
|
|
|
142
|
-
/** @type {HTMLElement} */
|
|
143
|
-
const menuItemElement = (event.currentTarget);
|
|
136
|
+
const menuItemElement = /** @type {HTMLElement} */ (event.currentTarget);
|
|
144
137
|
if (Attributes.isDisabled(menuItemElement)) {
|
|
145
138
|
return;
|
|
146
139
|
}
|
|
@@ -158,8 +151,7 @@ export function onClick(event) {
|
|
|
158
151
|
* @return {void}
|
|
159
152
|
*/
|
|
160
153
|
export function onKeyDown(event) {
|
|
161
|
-
/** @type {HTMLElement} */
|
|
162
|
-
const menuItemElement = (event.currentTarget);
|
|
154
|
+
const menuItemElement = /** @type {HTMLElement} */ (event.currentTarget);
|
|
163
155
|
|
|
164
156
|
if (event.key === 'Enter') {
|
|
165
157
|
event.stopPropagation();
|
|
@@ -8,11 +8,13 @@
|
|
|
8
8
|
|
|
9
9
|
@use '../../core/_motion.scss' as motion;
|
|
10
10
|
@use '../../core/_platform.scss' as platform;
|
|
11
|
+
@use '../../core/_length.scss' as *;
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
:root {
|
|
14
|
+
--mdw-progress__circle-duration: 1333ms;
|
|
15
|
+
}
|
|
14
16
|
|
|
15
|
-
/*
|
|
17
|
+
/*
|
|
16
18
|
* SVG Animated Material Spin Animation
|
|
17
19
|
* radius = 8.75
|
|
18
20
|
* pi = 3.14159
|
|
@@ -20,9 +22,9 @@ $duration: 1333ms;
|
|
|
20
22
|
* dash-length = circumference * (100-x)/100
|
|
21
23
|
*
|
|
22
24
|
* Every cycle rotates entire shape an additional -90deg (CCW)
|
|
23
|
-
*
|
|
25
|
+
*
|
|
24
26
|
* Entire animation rotates 4x speed (CW)
|
|
25
|
-
*
|
|
27
|
+
*
|
|
26
28
|
* 1. Start head at: 0.5%
|
|
27
29
|
* 2. Ease in head: to 75%
|
|
28
30
|
* 3. Ease out tail: to 74.5%
|
|
@@ -42,6 +44,7 @@ $duration: 1333ms;
|
|
|
42
44
|
from {
|
|
43
45
|
transform: rotate(0deg);
|
|
44
46
|
}
|
|
47
|
+
|
|
45
48
|
to {
|
|
46
49
|
transform: rotate(360deg);
|
|
47
50
|
}
|
|
@@ -51,8 +54,9 @@ $duration: 1333ms;
|
|
|
51
54
|
0% {
|
|
52
55
|
transform: rotate(0deg);
|
|
53
56
|
}
|
|
57
|
+
|
|
54
58
|
100% {
|
|
55
|
-
transform: rotate(-360deg)
|
|
59
|
+
transform: rotate(-360deg);
|
|
56
60
|
}
|
|
57
61
|
}
|
|
58
62
|
|
|
@@ -61,36 +65,44 @@ $duration: 1333ms;
|
|
|
61
65
|
stroke-dashoffset: circlePercentage(0.5, 75);
|
|
62
66
|
}
|
|
63
67
|
#{motion.$standardPeakVelocity * 100%} {
|
|
64
|
-
stroke-dashoffset: circlePercentage(75,75);
|
|
68
|
+
stroke-dashoffset: circlePercentage(75, 75);
|
|
65
69
|
}
|
|
70
|
+
|
|
66
71
|
100% {
|
|
67
|
-
stroke-dashoffset: circlePercentage(149.5,75);
|
|
72
|
+
stroke-dashoffset: circlePercentage(149.5, 75);
|
|
68
73
|
}
|
|
69
74
|
}
|
|
70
75
|
|
|
71
|
-
.mdw-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
stroke-width: 2.5;
|
|
76
|
+
.mdw-progress__circle {
|
|
77
|
+
block-size: 48px;
|
|
78
|
+
inline-size: 48px;
|
|
75
79
|
margin: 8px;
|
|
80
|
+
|
|
81
|
+
stroke-width: 2.5;
|
|
82
|
+
|
|
76
83
|
svg {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
will-change: transform;
|
|
84
|
+
block-size: 100%;
|
|
85
|
+
inline-size: 100%;
|
|
86
|
+
|
|
81
87
|
animation-name: rotate-clockwise;
|
|
82
|
-
animation-duration:
|
|
88
|
+
animation-duration: var(--mdw-progress__circle-duration);
|
|
83
89
|
animation-timing-function: linear;
|
|
84
90
|
animation-iteration-count: infinite;
|
|
91
|
+
will-change: transform;
|
|
92
|
+
|
|
93
|
+
transform: rotate(0deg);
|
|
94
|
+
|
|
85
95
|
& > path {
|
|
96
|
+
transform-origin: center center;
|
|
97
|
+
|
|
86
98
|
fill: none;
|
|
87
|
-
stroke-width: inherit;
|
|
88
99
|
stroke: currentColor;
|
|
89
|
-
|
|
100
|
+
stroke-width: inherit;
|
|
101
|
+
|
|
90
102
|
&:nth-child(1) {
|
|
91
103
|
animation-name: mdw-progress-dash, rotate-counterclockwise;
|
|
92
|
-
animation-duration:
|
|
93
|
-
animation-timing-function: motion.$standardEasing, steps(4,end);
|
|
104
|
+
animation-duration: var(--mdw-progress__circle-duration), calc(var(--mdw-progress__circle-duration) * 4);
|
|
105
|
+
animation-timing-function: motion.$standardEasing, steps(4, end);
|
|
94
106
|
animation-iteration-count: infinite;
|
|
95
107
|
|
|
96
108
|
stroke-dasharray: circlePercentage(25, 100);
|
|
@@ -98,39 +110,36 @@ $duration: 1333ms;
|
|
|
98
110
|
stroke-linecap: round;
|
|
99
111
|
|
|
100
112
|
}
|
|
113
|
+
|
|
101
114
|
&:nth-child(2) {
|
|
102
115
|
display: none;
|
|
103
116
|
|
|
104
|
-
transition-property: stroke-dashoffset;
|
|
105
117
|
transition-duration: motion.$shapeChangeDuration;
|
|
118
|
+
|
|
119
|
+
transition-property: stroke-dashoffset;
|
|
106
120
|
transition-timing-function: motion.$standardEasing;
|
|
107
121
|
|
|
108
122
|
stroke-dasharray: circlePercentage(0, 100);
|
|
109
123
|
stroke-dashoffset: circlePercentage(0, 100);
|
|
110
124
|
stroke-linecap: square;
|
|
111
125
|
}
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// IE does not support animated SVG
|
|
117
|
-
// Double rotation speed
|
|
118
|
-
@include platform.ifIE() {
|
|
119
|
-
&:not([mdw-determinate]) svg {
|
|
120
|
-
animation-duration: $duration * 0.5;
|
|
126
|
+
|
|
121
127
|
}
|
|
122
128
|
}
|
|
123
129
|
}
|
|
124
130
|
|
|
125
|
-
.mdw-
|
|
131
|
+
.mdw-progress__circle[mdw-determinate] {
|
|
126
132
|
svg {
|
|
127
133
|
animation: none;
|
|
128
134
|
will-change: none;
|
|
135
|
+
|
|
129
136
|
& > path {
|
|
130
137
|
&:nth-child(1) {
|
|
131
138
|
display: none;
|
|
139
|
+
|
|
132
140
|
animation: none;
|
|
133
141
|
}
|
|
142
|
+
|
|
134
143
|
&:nth-child(2) {
|
|
135
144
|
display: inline;
|
|
136
145
|
}
|
|
@@ -138,10 +147,10 @@ $duration: 1333ms;
|
|
|
138
147
|
}
|
|
139
148
|
}
|
|
140
149
|
|
|
141
|
-
.mdw-
|
|
150
|
+
.mdw-progress__circle[value='100'] {
|
|
142
151
|
svg {
|
|
143
152
|
& > path:nth-child(2) {
|
|
144
153
|
stroke-dashoffset: circlePercentage(100);
|
|
145
154
|
}
|
|
146
155
|
}
|
|
147
|
-
}
|
|
156
|
+
}
|