@shortfuse/materialdesignweb 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.browserslistrc +2 -1
- package/.eslintrc.json +59 -8
- package/.stylelintrc.json +94 -49
- package/CHANGELOG.md +12 -0
- package/README.md +1 -3
- package/adapters/datatable/column.js +27 -54
- package/adapters/datatable/index.js +69 -81
- package/adapters/dom/index.js +32 -47
- package/adapters/search/index.js +107 -133
- package/components/appbar/_spec.scss +77 -137
- package/components/banner/_spec.scss +28 -63
- package/components/bottomnav/_spec.scss +46 -54
- package/components/bottomnav/index.js +15 -20
- package/components/bottomnav/item.js +4 -5
- package/components/button/README.md +1 -1
- package/components/button/_spec.scss +43 -42
- package/components/button/_theme.scss +27 -50
- package/components/card/_spec.scss +61 -69
- package/components/chip/_spec.scss +21 -44
- package/components/chip/_theme.scss +79 -151
- package/components/chip/index.js +6 -4
- package/components/datatable/_spec.scss +36 -99
- package/components/datatable/_theme.scss +98 -124
- package/components/datatable/cell.js +1 -2
- package/components/datatable/columnheader.js +1 -2
- package/components/datatable/index.js +33 -47
- package/components/datatable/row.js +4 -5
- package/components/dialog/_spec.scss +53 -63
- package/components/dialog/_theme.scss +7 -0
- package/components/dialog/index.js +62 -88
- package/components/divider/_spec.scss +6 -8
- package/components/elevation/_spec.scss +1 -1
- package/components/fab/_spec.scss +30 -42
- package/components/fab/index.js +4 -8
- package/components/grid/_spec.scss +68 -211
- package/components/layout/_mixins.scss +0 -22
- package/components/layout/_spec.scss +267 -363
- package/components/layout/_theme.scss +10 -35
- package/components/layout/index.js +40 -50
- package/components/list/_spec.scss +57 -91
- package/components/list/_theme.scss +75 -84
- package/components/list/content.js +9 -13
- package/components/list/index.js +34 -38
- package/components/list/item.js +8 -11
- package/components/list/secondary.js +8 -9
- package/components/menu/_spec.scss +134 -167
- package/components/menu/index.js +45 -61
- package/components/menu/item.js +11 -19
- package/components/progress/_spec.scss +43 -34
- package/components/selection/_spec.scss +123 -133
- package/components/selection/_theme.scss +88 -120
- package/components/selection/index.js +9 -15
- package/components/selection/input.js +3 -5
- package/components/selection/radiogroup.js +8 -15
- package/components/slider/_spec.scss +23 -28
- package/components/snackbar/_spec.scss +17 -62
- package/components/snackbar/index.js +15 -21
- package/components/tab/_spec.scss +35 -50
- package/components/tab/content.js +33 -28
- package/components/tab/index.js +30 -33
- package/components/tab/item.js +4 -5
- package/components/tab/list.js +22 -36
- package/components/textfield/README.md +2 -2
- package/components/textfield/_spec.scss +241 -287
- package/components/textfield/_theme.scss +197 -232
- package/components/textfield/index.js +8 -16
- package/components/tooltip/_spec.scss +23 -26
- package/components/type/_spec.scss +19 -16
- package/core/_breakpoint.scss +33 -33
- package/core/_elevation.scss +40 -0
- package/core/_length.scss +0 -1
- package/core/_platform.scss +0 -22
- package/core/_type.scss +7 -6
- package/core/aria/button.js +4 -5
- package/core/aria/keyboard.js +1 -2
- package/core/aria/rovingtabindex.js +14 -17
- package/core/aria/tab.js +1 -2
- package/core/dom.js +18 -109
- package/core/overlay/_spec.scss +5 -8
- package/core/overlay/_theme.scss +126 -150
- package/core/overlay/index.js +19 -32
- package/core/ripple/_spec.scss +16 -17
- package/core/ripple/_theme.scss +13 -33
- package/core/ripple/index.js +36 -44
- package/core/theme/_aliases.scss +15 -0
- package/core/theme/_config.scss +8 -2
- package/core/theme/_functions.scss +22 -0
- package/core/theme/_palettes.scss +0 -1
- package/core/{color → theme}/_spec.scss +0 -0
- package/core/theme/_theme.scss +268 -0
- package/core/theme/index.scss +4 -0
- package/core/transition/index.js +73 -76
- package/docs/_flex.scss +7 -1
- package/docs/_menuoptions.js +2 -2
- package/docs/_partials/_appbar.eta +12 -14
- package/docs/_partials/_header.eta +41 -44
- package/docs/_sample-utils.js +15 -20
- package/docs/docs.scss +123 -87
- package/docs/framework.scss +26 -0
- package/docs/index.eta +2 -6
- package/docs/index.js +7 -0
- package/docs/pages/appbar.eta +22 -28
- package/docs/pages/bottomnav.js +17 -14
- package/docs/pages/button.js +10 -10
- package/docs/pages/card.js +20 -22
- package/docs/pages/chip.js +11 -13
- package/docs/pages/color.js +35 -36
- package/docs/pages/datatable.js +11 -15
- package/docs/pages/dialog.eta +9 -11
- package/docs/pages/dialog.js +6 -9
- package/docs/pages/dom.js +6 -9
- package/docs/pages/elevation.eta +10 -10
- package/docs/pages/fab.js +2 -3
- package/docs/pages/grid.js +5 -5
- package/docs/pages/list.js +1 -2
- package/docs/pages/menu.eta +17 -19
- package/docs/pages/menu.js +7 -11
- package/docs/pages/overlay.js +1 -2
- package/docs/pages/progress.eta +2 -2
- package/docs/pages/progress.js +1 -1
- package/docs/pages/ripple.js +1 -2
- package/docs/pages/search.eta +20 -24
- package/docs/pages/search.js +24 -41
- package/docs/pages/selection.eta +2 -6
- package/docs/pages/selection.js +3 -4
- package/docs/pages/snackbar.js +3 -4
- package/docs/pages/tab.eta +61 -75
- package/docs/pages/tab.js +16 -15
- package/docs/pages/textfield.eta +9 -8
- package/docs/pages/textfield.js +26 -23
- package/docs/pages/tooltip.eta +10 -12
- package/docs/pages/transition.js +5 -7
- package/docs/postrender.js +7 -5
- package/docs/pwa/pwa.eta +14 -16
- package/docs/pwa/pwa.js +19 -27
- package/docs/pwa/pwa.scss +12 -7
- package/docs/themes/theme-colored.scss +9 -11
- package/docs/themes/theme-default.scss +0 -14
- package/index.scss +27 -0
- package/jsconfig.json +7 -3
- package/package.json +26 -15
- package/tsconfig.json +16 -0
- package/{webpack.config.cjs → webpack.config.js} +105 -58
- package/components/template/_theme.scss +0 -27
- package/components/textfield/_mixins.scss +0 -52
- package/core/color/_theme.scss +0 -390
- package/core/color/index.scss +0 -2
- package/core/theme/_mixins.scss +0 -172
- package/core/theme/_variables.scss +0 -24
- package/docs/_mixins.pug +0 -155
- package/docs/pages/appbar.pug +0 -78
- package/docs/pages/bottomnav.pug +0 -137
- package/docs/pages/button.pug +0 -121
- package/docs/pages/card.pug +0 -74
- package/docs/pages/chip.pug +0 -91
- package/docs/pages/color.pug +0 -121
- package/docs/pages/datatable.pug +0 -283
- package/docs/pages/dialog.pug +0 -132
- package/docs/pages/dom.pug +0 -22
- package/docs/pages/elevation.pug +0 -25
- package/docs/pages/fab.pug +0 -66
- package/docs/pages/grid.pug +0 -95
- package/docs/pages/layout.pug +0 -7
- package/docs/pages/list.pug +0 -326
- package/docs/pages/menu.pug +0 -205
- package/docs/pages/overlay.pug +0 -55
- package/docs/pages/progress.pug +0 -16
- package/docs/pages/ripple.pug +0 -21
- package/docs/pages/search.pug +0 -165
- package/docs/pages/selection.pug +0 -74
- package/docs/pages/slider.pug +0 -17
- package/docs/pages/snackbar.pug +0 -60
- package/docs/pages/tab.pug +0 -304
- package/docs/pages/textfield.pug +0 -360
- package/docs/pages/tooltip.pug +0 -78
- package/docs/pages/transition.pug +0 -76
- package/docs/pages/type.pug +0 -29
- package/docs/pwa/_dialogs.pug +0 -96
- package/docs/pwa/_menus.pug +0 -11
- package/docs/pwa/pwa.pug +0 -325
- package/docs/spec.scss +0 -26
- package/docs/themes/_component-themes.scss +0 -26
- package/docs/themes/theme-colored-fallbacks.scss +0 -17
- package/docs/themes/theme-default-fallbacks.scss +0 -17
|
@@ -1,154 +1,128 @@
|
|
|
1
|
-
|
|
1
|
+
.mdw-theme {
|
|
2
|
+
--mdw-datatable__text-rgb: var(--mdw-ink-default);
|
|
3
|
+
--mdw-datatable__text-opacity: var(--mdw-high-opacity);
|
|
4
|
+
--mdw-datatable__secondary-text-opacity: var(--mdw-medium-opacity);
|
|
5
|
+
--mdw-datatable__divider-opacity: var(--mdw-divider-opacity);
|
|
6
|
+
--mdw-datatable__hover-opacity: var(--mdw-datatable__hover-opacity-value);
|
|
7
|
+
--mdw-datatable__focus-opacity: var(--mdw-datatable__focus-opacity-value);
|
|
8
|
+
--mdw-datatable__selected-opacity: var(--mdw-datatable__selected-opacity-value);
|
|
9
|
+
--mdw-datatable__disabled-opacity: var(--mdw-inactive-opacity);
|
|
10
|
+
}
|
|
2
11
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
divider-opacity: theme.$divider-opacity,
|
|
12
|
+
.mdw-theme[mdw-light] {
|
|
13
|
+
--mdw-datatable__hover-opacity-value: 0.04;
|
|
14
|
+
--mdw-datatable__focus-opacity-value: 0.12;
|
|
15
|
+
--mdw-datatable__selected-opacity-value: 0.08;
|
|
8
16
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
17
|
+
// Inherit color on light theme.
|
|
18
|
+
--mdw-datatable__header-fill-text: invalid;
|
|
19
|
+
}
|
|
12
20
|
|
|
13
|
-
|
|
21
|
+
.mdw-theme[mdw-dark] {
|
|
22
|
+
--mdw-datatable__hover-opacity-value: 0.08;
|
|
23
|
+
--mdw-datatable__focus-opacity-value: 0.24;
|
|
24
|
+
--mdw-datatable__selected-opacity-value: 0.16;
|
|
25
|
+
--mdw-datatable__header-fill-text: rgba(255, 255, 255, 1.00);
|
|
26
|
+
}
|
|
14
27
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
28
|
+
.mdw-datatable {
|
|
29
|
+
--mdw-datatable__cell-focus-opacity: 0;
|
|
30
|
+
--mdw-datatable__cell-hover-opacity: 0;
|
|
31
|
+
--mdw-datatable__cell-disabled-opacity: 0;
|
|
32
|
+
--mdw-datatable__row-background-color: var(--mdw-datatable__text-rgb);
|
|
33
|
+
--mdw-datatable__row-focus-opacity: var(--mdw-datatable__focus-opacity);
|
|
34
|
+
--mdw-datatable__row-hover-opacity: var(--mdw-datatable__hover-opacity);
|
|
35
|
+
--mdw-datatable__row-disabled-opacity: var(--mdw-datatable__disabled-opacity);
|
|
36
|
+
|
|
37
|
+
&[mdw-cell-focusable] {
|
|
38
|
+
--mdw-datatable__cell-focus-opacity: var(--mdw-datatable__focus-opacity);
|
|
39
|
+
--mdw-datatable__cell-hover-opacity: var(--mdw-datatable__hover-opacity);
|
|
40
|
+
--mdw-datatable__cell-disabled-opacity: var(--mdw-datatable__disabled-opacity);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
18
43
|
|
|
44
|
+
.mdw-datatable tr,
|
|
45
|
+
.mdw-datatable td,
|
|
46
|
+
.mdw-datatable th {
|
|
47
|
+
border-color: RGBA(var(--mdw-datatable__text-rgb), var(--mdw-datatable__divider-opacity));
|
|
48
|
+
}
|
|
19
49
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
) !default;
|
|
50
|
+
.mdw-datatable th:not([mdw-selector]),
|
|
51
|
+
.mdw-datatable__footer {
|
|
52
|
+
color: RGBA(var(--mdw-datatable__text-rgb), var(--mdw-datatable__secondary-text-opacity));
|
|
53
|
+
}
|
|
25
54
|
|
|
26
|
-
|
|
27
|
-
|
|
55
|
+
.mdw-datatable caption,
|
|
56
|
+
.mdw-datatable__header-text {
|
|
57
|
+
color: RGBA(var(--mdw-datatable__text-rgb), var(--mdw-datatable__text-opacity));
|
|
28
58
|
}
|
|
29
59
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
60
|
+
.mdw-datatable__header-controls,
|
|
61
|
+
.mdw-datatable__footer-controls {
|
|
62
|
+
color: RGBA(var(--mdw-datatable__text-rgb), var(--mdw-datatable__text-opacity));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.mdw-datatable td:not([mdw-checkbox]) {
|
|
66
|
+
color: RGBA(var(--mdw-datatable__text-rgb), var(--mdw-datatable__text-opacity));
|
|
67
|
+
}
|
|
36
68
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
69
|
+
.mdw-datatable th[aria-sort]:not([aria-sort="none"]) {
|
|
70
|
+
color: RGBA(var(--mdw-datatable__text-rgb), var(--mdw-datatable__text-opacity));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.mdw-datatable[mdw-has-selection] {
|
|
74
|
+
caption,
|
|
75
|
+
.mdw-datatable__header {
|
|
76
|
+
background-color: RGBA(var(--mdw-ink), var(--mdw-datatable__selected-opacity));
|
|
40
77
|
}
|
|
41
78
|
|
|
42
|
-
|
|
79
|
+
caption,
|
|
43
80
|
.mdw-datatable__header-text {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
.mdw-datatable__header-controls,
|
|
48
|
-
.mdw-datatable__footer-controls {
|
|
49
|
-
color: RGBA(getThemeValue("text-color", $type), getThemeValue("text-opacity", $type));
|
|
81
|
+
// Inherit color on light theme
|
|
82
|
+
color: var(--mdw-datatable__header-fill-text, inherit);
|
|
50
83
|
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.mdw-datatable tbody tr {
|
|
87
|
+
background-color: RGBA(var(--mdw-datatable__row-background-color), calc(var(--mdw-datatable__row-hover-opacity) + var(--mdw-datatable__row-focus-opacity) + var(--mdw-datatable__selected-opacity)));
|
|
51
88
|
|
|
52
|
-
|
|
53
|
-
color:
|
|
89
|
+
&[aria-selected="true"] {
|
|
90
|
+
--mdw-datatable__row-background-color: var(--mdw-ink);
|
|
54
91
|
}
|
|
55
92
|
|
|
56
|
-
|
|
57
|
-
|
|
93
|
+
&:not([aria-selected="true"]) {
|
|
94
|
+
--mdw-datatable__selected-opacity: 0;
|
|
58
95
|
}
|
|
59
96
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
&:hover {
|
|
63
|
-
background-color: RGBA(getThemeValue("text-color", $type), getThemeValue("hover-opacity", $type));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
&:focus,
|
|
67
|
-
> td:focus {
|
|
68
|
-
background-color: RGBA(getThemeValue("text-color", $type), getThemeValue("focus-opacity", $type));
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
&:hover:focus,
|
|
72
|
-
& > td:hover:focus {
|
|
73
|
-
background-color: RGBA(getThemeValue("text-color", $type), getThemeValue("hover-focus-opacity", $type));
|
|
74
|
-
}
|
|
75
|
-
}
|
|
97
|
+
&:not(:hover) {
|
|
98
|
+
--mdw-datatable__row-hover-opacity: 0;
|
|
76
99
|
}
|
|
77
100
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
.mdw-datatable__header-text {
|
|
81
|
-
@if ($type == 'light') {
|
|
82
|
-
color: inherit;
|
|
83
|
-
} @else {
|
|
84
|
-
color: RGBA(getThemeValue("header-fill-text", $type));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
}
|
|
101
|
+
&:not(:focus) {
|
|
102
|
+
--mdw-datatable__row-focus-opacity: 0;
|
|
88
103
|
}
|
|
89
104
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
background-color: RGBA(var(--mdw-ink), getThemeValue("selected-opacity", $type));
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
.mdw-datatable tbody tr[aria-selected="true"] {
|
|
99
|
-
background-color: RGBA(var(--mdw-ink), getThemeValue("selected-opacity", $type));
|
|
100
|
-
|
|
101
|
-
&:hover {
|
|
102
|
-
background-color: RGBA(var(--mdw-ink), getThemeValue("selected-hover-opacity", $type));
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
&:focus {
|
|
106
|
-
background-color: RGBA(var(--mdw-ink), getThemeValue("selected-focus-opacity", $type));
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
&:hover:focus {
|
|
110
|
-
background-color: RGBA(var(--mdw-ink), getThemeValue("selected-hover-focus-opacity", $type));
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
} @else {
|
|
114
|
-
@each $color in ('primary', 'secondary', 'warn') {
|
|
115
|
-
.mdw-datatable[mdw-ink^="#{$color}"] {
|
|
116
|
-
&[mdw-has-selection] {
|
|
117
|
-
.mdw-datatable__header,
|
|
118
|
-
caption {
|
|
119
|
-
background-color: RGBA(getThemeValue("selected-#{$color}-ie", $type), getThemeValue("selected-opacity", $type));
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
tbody tr[aria-selected="true"] {
|
|
124
|
-
background-color: RGBA(getThemeValue("selected-#{$color}-ie", $type), getThemeValue("selected-opacity", $type));
|
|
125
|
-
|
|
126
|
-
&:hover {
|
|
127
|
-
background-color: RGBA(getThemeValue("selected-#{$color}-ie", $type), getThemeValue("selected-hover-opacity", $type));
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
&:focus {
|
|
131
|
-
background-color: RGBA(getThemeValue("selected-#{$color}-ie", $type), getThemeValue("selected-focus-opacity", $type));
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
&:hover:focus {
|
|
135
|
-
background-color: RGBA(getThemeValue("selected-#{$color}-ie", $type), getThemeValue("selected-hover-focus-opacity", $type));
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
105
|
+
&[aria-disabled="true"] {
|
|
106
|
+
--mdw-datatable__row-hover-opacity: 0;
|
|
107
|
+
--mdw-datatable__row-focus-opacity: 0;
|
|
108
|
+
opacity: var(--mdw-datatable__row-disabled-opacity);
|
|
140
109
|
}
|
|
141
110
|
}
|
|
142
111
|
|
|
112
|
+
.mdw-datatable tbody td {
|
|
113
|
+
background-color: RGBA(var(--mdw-datatable__text-rgb), calc(var(--mdw-datatable__cell-hover-opacity) + var(--mdw-datatable__cell-focus-opacity)));
|
|
143
114
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
@include theme.addComponentFallbackRules('dark') {
|
|
148
|
-
@include addThemeRules('dark');
|
|
149
|
-
}
|
|
115
|
+
&:not(:hover) {
|
|
116
|
+
--mdw-datatable__cell-hover-opacity: 0;
|
|
117
|
+
}
|
|
150
118
|
|
|
119
|
+
&:not(:focus) {
|
|
120
|
+
--mdw-datatable__cell-focus-opacity: 0;
|
|
121
|
+
}
|
|
151
122
|
|
|
152
|
-
|
|
153
|
-
|
|
123
|
+
&[aria-disabled="true"] {
|
|
124
|
+
--mdw-datatable__cell-hover-opacity: 0;
|
|
125
|
+
--mdw-datatable__cell-focus-opacity: 0;
|
|
126
|
+
opacity: var(--mdw-datatable__cell-disabled-opacity);
|
|
127
|
+
}
|
|
154
128
|
}
|
|
@@ -11,8 +11,7 @@ export const SELECTED_CHANGE_EVENT = 'mdw:datatablecell-selectedchange';
|
|
|
11
11
|
* @return {void}
|
|
12
12
|
*/
|
|
13
13
|
export function onFocus(event) {
|
|
14
|
-
/** @type {HTMLElement} */
|
|
15
|
-
const gridCellElement = (event.currentTarget);
|
|
14
|
+
const gridCellElement = /** @type {HTMLElement} */ (event.currentTarget);
|
|
16
15
|
dispatchDomEvent(gridCellElement, FOCUS_EVENT);
|
|
17
16
|
}
|
|
18
17
|
|
|
@@ -11,8 +11,7 @@ export const SORT_EVENT = 'mdw:datatablecolumnheader-sort';
|
|
|
11
11
|
* @return {void}
|
|
12
12
|
*/
|
|
13
13
|
export function onClick(event) {
|
|
14
|
-
/** @type {HTMLElement} */
|
|
15
|
-
const columnHeaderElement = (event.currentTarget);
|
|
14
|
+
const columnHeaderElement = /** @type {HTMLElement} */ (event.currentTarget);
|
|
16
15
|
if (Attributes.isDisabled(columnHeaderElement)) {
|
|
17
16
|
return;
|
|
18
17
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import * as Keyboard from '../../core/aria/keyboard.js';
|
|
4
4
|
import * as RovingTabIndex from '../../core/aria/rovingtabindex.js';
|
|
5
|
-
import { iterateArrayLike } from '../../core/dom.js';
|
|
6
5
|
|
|
7
6
|
import * as DataTableCell from './cell.js';
|
|
8
7
|
import * as DataTableColumnHeader from './columnheader.js';
|
|
@@ -22,8 +21,7 @@ export const CELL_TABINDEX_QUERIES = [
|
|
|
22
21
|
*/
|
|
23
22
|
export function onSelectedChange(event) {
|
|
24
23
|
const selected = event.detail.value === 'true';
|
|
25
|
-
/** @type {HTMLElement} */
|
|
26
|
-
const dataTableElement = (event.currentTarget);
|
|
24
|
+
const dataTableElement = /** @type {HTMLElement} */ (event.currentTarget);
|
|
27
25
|
const hasSelection = selected || dataTableElement.querySelector('td[aria-selected="true"],tr[aria-selected="true"]');
|
|
28
26
|
if (hasSelection) {
|
|
29
27
|
dataTableElement.setAttribute('mdw-has-selection', '');
|
|
@@ -37,21 +35,20 @@ export function onSelectedChange(event) {
|
|
|
37
35
|
* @return {HTMLElement}
|
|
38
36
|
*/
|
|
39
37
|
export function getScroller(datatableElement) {
|
|
40
|
-
/** @type {HTMLElement} */
|
|
41
|
-
let scroller = (datatableElement.getElementsByClassName('mdw-datatable__scroller')[0]);
|
|
38
|
+
let scroller = /** @type {HTMLElement} */ (datatableElement.getElementsByClassName('mdw-datatable__scroller')[0]);
|
|
42
39
|
if (!scroller) {
|
|
43
40
|
scroller = document.createElement('div');
|
|
44
41
|
scroller.classList.add('mdw-datatable__scroller');
|
|
45
42
|
const footer = datatableElement.getElementsByClassName('mdw-datatable__footer')[0];
|
|
46
43
|
if (footer) {
|
|
47
|
-
|
|
44
|
+
footer.before(scroller);
|
|
48
45
|
} else {
|
|
49
46
|
datatableElement.appendChild(scroller);
|
|
50
47
|
}
|
|
51
48
|
// Move table into scroller if it exists
|
|
52
49
|
const table = datatableElement.getElementsByTagName('table')[0];
|
|
53
50
|
if (table) {
|
|
54
|
-
table.
|
|
51
|
+
table.remove();
|
|
55
52
|
scroller.appendChild(table);
|
|
56
53
|
}
|
|
57
54
|
}
|
|
@@ -99,18 +96,19 @@ export function sortColumn(datatableElement, columnIndex, ascending = true) {
|
|
|
99
96
|
if (datatableElement.hasAttribute('mdw-datatable-adapter')) {
|
|
100
97
|
return;
|
|
101
98
|
}
|
|
102
|
-
|
|
99
|
+
for (const th of datatableElement.getElementsByTagName('th')) {
|
|
103
100
|
if (th.cellIndex === columnIndex) {
|
|
104
101
|
th.setAttribute('aria-sort', ascending ? 'ascending' : 'descending');
|
|
105
102
|
} else if (th.hasAttribute('aria-sort')) {
|
|
106
103
|
th.setAttribute('aria-sort', 'none');
|
|
107
104
|
}
|
|
108
|
-
}
|
|
105
|
+
}
|
|
109
106
|
|
|
110
107
|
/** @type {HTMLTableSectionElement} */
|
|
111
108
|
const tbody = getTableBody(datatableElement);
|
|
112
109
|
const rows = [];
|
|
113
|
-
|
|
110
|
+
let i = tbody.rows.length;
|
|
111
|
+
while (i--) {
|
|
114
112
|
rows.push(tbody.rows.item(i));
|
|
115
113
|
tbody.deleteRow(i);
|
|
116
114
|
}
|
|
@@ -120,7 +118,7 @@ export function sortColumn(datatableElement, columnIndex, ascending = true) {
|
|
|
120
118
|
const aText = aCell.textContent;
|
|
121
119
|
const bText = bCell.textContent;
|
|
122
120
|
if (aCell.dataset.type === 'number') {
|
|
123
|
-
return parseFloat(bText) - parseFloat(aText);
|
|
121
|
+
return Number.parseFloat(bText) - Number.parseFloat(aText);
|
|
124
122
|
}
|
|
125
123
|
return bText.localeCompare(aText);
|
|
126
124
|
});
|
|
@@ -128,9 +126,9 @@ export function sortColumn(datatableElement, columnIndex, ascending = true) {
|
|
|
128
126
|
rows.reverse();
|
|
129
127
|
}
|
|
130
128
|
const fragment = document.createDocumentFragment();
|
|
131
|
-
|
|
129
|
+
for (const row of rows) {
|
|
132
130
|
fragment.appendChild(row);
|
|
133
|
-
}
|
|
131
|
+
}
|
|
134
132
|
tbody.appendChild(fragment);
|
|
135
133
|
}
|
|
136
134
|
|
|
@@ -139,18 +137,16 @@ export function sortColumn(datatableElement, columnIndex, ascending = true) {
|
|
|
139
137
|
* @return {void}
|
|
140
138
|
*/
|
|
141
139
|
export function onItemFocus(event) {
|
|
142
|
-
/** @type {HTMLElement} */
|
|
143
|
-
const datatableElement = (event.currentTarget);
|
|
140
|
+
const datatableElement = /** @type {HTMLElement} */ (event.currentTarget);
|
|
144
141
|
const onFocusInteraction = datatableElement.getAttribute('mdw-on-focus');
|
|
145
142
|
if (!onFocusInteraction) {
|
|
146
143
|
return;
|
|
147
144
|
}
|
|
148
|
-
/** @type {HTMLElement} */
|
|
149
|
-
const itemElement = (event.target);
|
|
145
|
+
const itemElement = /** @type {HTMLElement} */ (event.target);
|
|
150
146
|
if (itemElement.getAttribute('aria-disabled') === 'true') {
|
|
151
147
|
return;
|
|
152
148
|
}
|
|
153
|
-
onFocusInteraction.split(' ')
|
|
149
|
+
for (const interaction of onFocusInteraction.split(' ')) {
|
|
154
150
|
switch (interaction) {
|
|
155
151
|
case 'select':
|
|
156
152
|
if (itemElement instanceof HTMLTableRowElement) {
|
|
@@ -161,7 +157,7 @@ export function onItemFocus(event) {
|
|
|
161
157
|
break;
|
|
162
158
|
default:
|
|
163
159
|
}
|
|
164
|
-
}
|
|
160
|
+
}
|
|
165
161
|
}
|
|
166
162
|
|
|
167
163
|
/**
|
|
@@ -169,10 +165,8 @@ export function onItemFocus(event) {
|
|
|
169
165
|
* @return {void}
|
|
170
166
|
*/
|
|
171
167
|
export function onSort(event) {
|
|
172
|
-
/** @type {HTMLElement} */
|
|
173
|
-
const
|
|
174
|
-
/** @type {HTMLTableHeaderCellElement} */
|
|
175
|
-
const cell = (event.target);
|
|
168
|
+
const datatableElement = /** @type {HTMLElement} */ (event.currentTarget);
|
|
169
|
+
const cell = /** @type {HTMLTableHeaderCellElement} */ (event.target);
|
|
176
170
|
sortColumn(datatableElement, cell.cellIndex, event.detail.sort === 'ascending');
|
|
177
171
|
}
|
|
178
172
|
|
|
@@ -181,8 +175,7 @@ export function onSort(event) {
|
|
|
181
175
|
* @return {void}
|
|
182
176
|
*/
|
|
183
177
|
export function onRowHeaderCheckedChange(event) {
|
|
184
|
-
/** @type {HTMLTableHeaderCellElement} */
|
|
185
|
-
const cell = (event.target);
|
|
178
|
+
const cell = /** @type {HTMLTableHeaderCellElement} */ (event.target);
|
|
186
179
|
const row = cell.parentElement;
|
|
187
180
|
DataTableRow.setSelected(row, event.detail.value);
|
|
188
181
|
}
|
|
@@ -192,10 +185,8 @@ export function onRowHeaderCheckedChange(event) {
|
|
|
192
185
|
* @return {void}
|
|
193
186
|
*/
|
|
194
187
|
function onTabIndexZeroed(event) {
|
|
195
|
-
/** @type {HTMLElement} */
|
|
196
|
-
const
|
|
197
|
-
/** @type {HTMLElement} */
|
|
198
|
-
const emitter = (event.target);
|
|
188
|
+
const dataTableElement = /** @type {HTMLElement} */ (event.currentTarget);
|
|
189
|
+
const emitter = /** @type {HTMLElement} */ (event.target);
|
|
199
190
|
|
|
200
191
|
const row = (emitter instanceof HTMLTableRowElement && emitter);
|
|
201
192
|
const cell = (!row && emitter instanceof HTMLTableCellElement && emitter);
|
|
@@ -211,10 +202,8 @@ function onTabIndexZeroed(event) {
|
|
|
211
202
|
* @return {void}
|
|
212
203
|
*/
|
|
213
204
|
export function onKeyboard(event) {
|
|
214
|
-
/** @type {HTMLElement} */
|
|
215
|
-
const
|
|
216
|
-
/** @type {HTMLElement} */
|
|
217
|
-
const emitter = (event.target);
|
|
205
|
+
const dataTableElement = /** @type {HTMLElement} */ (event.currentTarget);
|
|
206
|
+
const emitter = /** @type {HTMLElement} */ (event.target);
|
|
218
207
|
let current = document.activeElement;
|
|
219
208
|
|
|
220
209
|
let row = (emitter instanceof HTMLTableRowElement && emitter);
|
|
@@ -223,8 +212,7 @@ export function onKeyboard(event) {
|
|
|
223
212
|
return;
|
|
224
213
|
}
|
|
225
214
|
if (!row) {
|
|
226
|
-
/** @type {HTMLTableRowElement} */
|
|
227
|
-
row = (cell.parentElement);
|
|
215
|
+
row = /** @type {HTMLTableRowElement} */ (cell.parentElement);
|
|
228
216
|
}
|
|
229
217
|
|
|
230
218
|
let checkNavKeys = false;
|
|
@@ -247,14 +235,14 @@ export function onKeyboard(event) {
|
|
|
247
235
|
|
|
248
236
|
if (checkNavKeys) {
|
|
249
237
|
// Keyboard Navigation
|
|
250
|
-
/** @type {
|
|
238
|
+
/** @type {Iterable<HTMLElement>} */
|
|
251
239
|
let searchElements;
|
|
252
240
|
let reverse = false;
|
|
253
241
|
let loop = false;
|
|
254
242
|
switch (event.type) {
|
|
255
243
|
case Keyboard.UP_ARROW_KEY:
|
|
256
244
|
reverse = true;
|
|
257
|
-
//
|
|
245
|
+
// Fallthrough
|
|
258
246
|
case Keyboard.DOWN_ARROW_KEY:
|
|
259
247
|
if (event.detail.ctrlKey || event.detail.altKey || event.detail.metaKey) {
|
|
260
248
|
return;
|
|
@@ -269,7 +257,7 @@ export function onKeyboard(event) {
|
|
|
269
257
|
break;
|
|
270
258
|
case Keyboard.BACK_ARROW_KEY:
|
|
271
259
|
reverse = true;
|
|
272
|
-
//
|
|
260
|
+
// Fallthrough
|
|
273
261
|
case Keyboard.FORWARD_ARROW_KEY:
|
|
274
262
|
if (event.detail.ctrlKey || event.detail.altKey || event.detail.metaKey) {
|
|
275
263
|
return;
|
|
@@ -281,7 +269,7 @@ export function onKeyboard(event) {
|
|
|
281
269
|
break;
|
|
282
270
|
case Keyboard.END_KEY:
|
|
283
271
|
reverse = true;
|
|
284
|
-
//
|
|
272
|
+
// Fallthrough
|
|
285
273
|
case Keyboard.HOME_KEY:
|
|
286
274
|
if (event.detail.altKey || event.detail.metaKey) {
|
|
287
275
|
return;
|
|
@@ -289,11 +277,9 @@ export function onKeyboard(event) {
|
|
|
289
277
|
if (!cell) {
|
|
290
278
|
return;
|
|
291
279
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
searchElements = cell.parentElement.querySelectorAll(CELL_TABINDEX_QUERIES.join(','));
|
|
296
|
-
}
|
|
280
|
+
searchElements = event.detail.ctrlKey
|
|
281
|
+
? getTableBody(dataTableElement).querySelectorAll(CELL_TABINDEX_QUERIES.join(','))
|
|
282
|
+
: cell.parentElement.querySelectorAll(CELL_TABINDEX_QUERIES.join(','));
|
|
297
283
|
cell.setAttribute('tabindex', '-1');
|
|
298
284
|
current = null;
|
|
299
285
|
loop = true;
|
|
@@ -357,11 +343,11 @@ export function attach(element) {
|
|
|
357
343
|
const headerRow = getHeaderRow(element);
|
|
358
344
|
const tbody = getTableBody(element);
|
|
359
345
|
|
|
360
|
-
|
|
361
|
-
|
|
346
|
+
for (const el of headerRow.getElementsByTagName('th')) DataTableColumnHeader.attach(el);
|
|
347
|
+
for (const el of tbody.getElementsByTagName('th')) DataTableRowHeader.attach(el);
|
|
362
348
|
|
|
363
349
|
const tableRows = tbody.getElementsByTagName('tr');
|
|
364
|
-
|
|
350
|
+
for (const el of tableRows) DataTableRow.attach(el);
|
|
365
351
|
|
|
366
352
|
const rowFocusable = element.hasAttribute('mdw-row-focusable');
|
|
367
353
|
if (rowFocusable) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Attributes from '../../core/aria/attributes.js';
|
|
2
2
|
import * as Keyboard from '../../core/aria/keyboard.js';
|
|
3
|
-
import { dispatchDomEvent
|
|
3
|
+
import { dispatchDomEvent } from '../../core/dom.js';
|
|
4
4
|
|
|
5
5
|
import * as DataTableCell from './cell.js';
|
|
6
6
|
|
|
@@ -12,8 +12,7 @@ export const SELECTED_CHANGE_EVENT = 'mdw:datatablerow-selectedchange';
|
|
|
12
12
|
* @return {void}
|
|
13
13
|
*/
|
|
14
14
|
export function onFocus(event) {
|
|
15
|
-
/** @type {HTMLTableRowElement} */
|
|
16
|
-
const rowElement = (event.currentTarget);
|
|
15
|
+
const rowElement = /** @type {HTMLTableRowElement} */ (event.currentTarget);
|
|
17
16
|
dispatchDomEvent(rowElement, FOCUS_EVENT);
|
|
18
17
|
}
|
|
19
18
|
|
|
@@ -35,7 +34,7 @@ export function attach(element) {
|
|
|
35
34
|
Keyboard.attach(element);
|
|
36
35
|
element.setAttribute('role', 'row');
|
|
37
36
|
element.addEventListener('focus', onFocus);
|
|
38
|
-
|
|
37
|
+
for (const el of element.cells) DataTableCell.attach(el);
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
/**
|
|
@@ -45,5 +44,5 @@ export function attach(element) {
|
|
|
45
44
|
export function detach(element) {
|
|
46
45
|
element.removeEventListener('focus', onFocus);
|
|
47
46
|
Keyboard.detach(element);
|
|
48
|
-
|
|
47
|
+
for (const el of element.cells) DataTableCell.detach(el);
|
|
49
48
|
}
|