@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/docs/pages/card.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { setTextNode } from '../../core/dom.js';
|
|
2
2
|
import { convertElementToCode } from '../_sample-utils.js';
|
|
3
3
|
|
|
4
4
|
/** @type {HTMLElement} */
|
|
@@ -15,8 +15,10 @@ let primaryButtonElement;
|
|
|
15
15
|
/** @return {void} */
|
|
16
16
|
function updateSampleCode() {
|
|
17
17
|
const htmlCodeElement = document.getElementsByClassName('component-html')[0];
|
|
18
|
-
setTextNode(htmlCodeElement, convertElementToCode(
|
|
19
|
-
|
|
18
|
+
setTextNode(htmlCodeElement, convertElementToCode(
|
|
19
|
+
sampleComponent,
|
|
20
|
+
document.getElementById('usePug').getAttribute('aria-pressed') === 'true',
|
|
21
|
+
));
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
/** @return {void} */
|
|
@@ -54,11 +56,11 @@ function onOptionChange(event) {
|
|
|
54
56
|
case 'raise-hover':
|
|
55
57
|
raiseOptions = (sampleComponent.getAttribute('mdw-raised') || '').split(' ');
|
|
56
58
|
if (checked) {
|
|
57
|
-
if (raiseOptions.
|
|
58
|
-
raiseOptions.push(name.
|
|
59
|
+
if (!raiseOptions.includes(name.slice('raise-'.length))) {
|
|
60
|
+
raiseOptions.push(name.slice('raise-'.length));
|
|
59
61
|
}
|
|
60
62
|
} else {
|
|
61
|
-
raiseOptions = raiseOptions.filter((o) => o !== name.
|
|
63
|
+
raiseOptions = raiseOptions.filter((o) => o !== name.slice('raise-'.length));
|
|
62
64
|
}
|
|
63
65
|
raiseOptions.sort();
|
|
64
66
|
if (raiseOptions.length) {
|
|
@@ -69,7 +71,7 @@ function onOptionChange(event) {
|
|
|
69
71
|
break;
|
|
70
72
|
case 'media-placement':
|
|
71
73
|
if (mediaElement.parentElement) {
|
|
72
|
-
mediaElement.
|
|
74
|
+
mediaElement.remove();
|
|
73
75
|
}
|
|
74
76
|
switch (value) {
|
|
75
77
|
default:
|
|
@@ -112,7 +114,7 @@ function onOptionChange(event) {
|
|
|
112
114
|
sampleComponent.insertBefore(primaryButtonElement, sampleComponent.firstChild);
|
|
113
115
|
}
|
|
114
116
|
} else if (primaryButtonElement.parentElement) {
|
|
115
|
-
primaryButtonElement.
|
|
117
|
+
primaryButtonElement.remove();
|
|
116
118
|
}
|
|
117
119
|
break;
|
|
118
120
|
case 'secondary-actions':
|
|
@@ -121,7 +123,7 @@ function onOptionChange(event) {
|
|
|
121
123
|
sampleComponent.appendChild(actionsElement);
|
|
122
124
|
}
|
|
123
125
|
} else if (actionsElement.parentElement) {
|
|
124
|
-
actionsElement.
|
|
126
|
+
actionsElement.remove();
|
|
125
127
|
}
|
|
126
128
|
break;
|
|
127
129
|
case 'close-action':
|
|
@@ -130,17 +132,17 @@ function onOptionChange(event) {
|
|
|
130
132
|
sampleComponent.insertBefore(closeActionElement, sampleComponent.getElementsByClassName('mdw-card__header')[0]);
|
|
131
133
|
}
|
|
132
134
|
} else if (closeActionElement.parentElement) {
|
|
133
|
-
closeActionElement.
|
|
135
|
+
closeActionElement.remove();
|
|
134
136
|
}
|
|
135
137
|
break;
|
|
136
138
|
case 'surface':
|
|
137
139
|
sampleComponent.setAttribute('mdw-surface', value.replace(/ (light|dark)/, ''));
|
|
138
|
-
if (value.
|
|
140
|
+
if (!value.includes(' light')) {
|
|
139
141
|
sampleComponent.removeAttribute('mdw-light');
|
|
140
142
|
} else {
|
|
141
143
|
sampleComponent.setAttribute('mdw-light', '');
|
|
142
144
|
}
|
|
143
|
-
if (value.
|
|
145
|
+
if (!value.includes(' dark')) {
|
|
144
146
|
sampleComponent.removeAttribute('mdw-dark');
|
|
145
147
|
} else {
|
|
146
148
|
sampleComponent.setAttribute('mdw-dark', '');
|
|
@@ -159,17 +161,13 @@ function onOptionChange(event) {
|
|
|
159
161
|
/** @return {void} */
|
|
160
162
|
function setupComponentOptions() {
|
|
161
163
|
sampleComponent = document.querySelector('.component-sample .mdw-card');
|
|
162
|
-
/** @type {HTMLElement} */
|
|
163
|
-
|
|
164
|
-
/** @type {HTMLElement} */
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
primaryButtonElement = (sampleComponent.getElementsByClassName('mdw-card__button')[0]);
|
|
168
|
-
/** @type {HTMLElement} */
|
|
169
|
-
closeActionElement = (sampleComponent.getElementsByClassName('mdw-card__end')[0]);
|
|
170
|
-
iterateArrayLike(document.querySelectorAll('input[name]'), (el) => {
|
|
164
|
+
mediaElement = /** @type {HTMLElement} */ (sampleComponent.getElementsByClassName('mdw-card__media')[0]);
|
|
165
|
+
actionsElement = /** @type {HTMLElement} */ (sampleComponent.getElementsByClassName('mdw-card__actions')[0]);
|
|
166
|
+
primaryButtonElement = /** @type {HTMLElement} */ (sampleComponent.getElementsByClassName('mdw-card__button')[0]);
|
|
167
|
+
closeActionElement = /** @type {HTMLElement} */ (sampleComponent.getElementsByClassName('mdw-card__end')[0]);
|
|
168
|
+
for (const el of document.querySelectorAll('input[name]')) {
|
|
171
169
|
el.addEventListener('change', onOptionChange);
|
|
172
|
-
}
|
|
170
|
+
}
|
|
173
171
|
}
|
|
174
172
|
|
|
175
173
|
setupComponentOptions();
|
package/docs/pages/chip.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as Chip from '../../components/chip/index.js';
|
|
2
|
-
import { iterateArrayLike } from '../../core/dom.js';
|
|
3
2
|
import { convertElementToCode } from '../_sample-utils.js';
|
|
4
3
|
|
|
5
|
-
/** @type {
|
|
4
|
+
/** @type {Iterable<HTMLElement>} */
|
|
6
5
|
let sampleComponents;
|
|
7
6
|
|
|
8
7
|
/** @return {void} */
|
|
@@ -12,7 +11,7 @@ function updateSampleCode() {
|
|
|
12
11
|
const useJS = jsRequired || jsOptional;
|
|
13
12
|
|
|
14
13
|
// Strip JS related elements and attributes
|
|
15
|
-
|
|
14
|
+
for (const element of sampleComponents) { Chip.detach(element); }
|
|
16
15
|
|
|
17
16
|
const htmlCodeElement = document.getElementsByClassName('component-html')[0];
|
|
18
17
|
const sampleContainer = document.querySelector('.component-sample__container').firstElementChild;
|
|
@@ -20,7 +19,7 @@ function updateSampleCode() {
|
|
|
20
19
|
|
|
21
20
|
// Reattach JS if requested
|
|
22
21
|
if (useJS) {
|
|
23
|
-
|
|
22
|
+
for (const element of sampleComponents) { Chip.attach(element); }
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
const jsCodeElement = document.getElementsByClassName('component-js')[0];
|
|
@@ -29,10 +28,10 @@ function updateSampleCode() {
|
|
|
29
28
|
|
|
30
29
|
/** @return {void} */
|
|
31
30
|
function initializeSampleComponents() {
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
for (const element of document.querySelectorAll('.js .mdw-tab')) { Chip.attach(element); }
|
|
32
|
+
for (const formElement of document.getElementsByTagName('form')) {
|
|
34
33
|
formElement.reset();
|
|
35
|
-
}
|
|
34
|
+
}
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
/**
|
|
@@ -40,8 +39,7 @@ function initializeSampleComponents() {
|
|
|
40
39
|
* @return {void}
|
|
41
40
|
*/
|
|
42
41
|
function onOptionChange(event) {
|
|
43
|
-
/** @type {HTMLInputElement} */
|
|
44
|
-
const inputElement = (event.currentTarget);
|
|
42
|
+
const inputElement = /** @type {HTMLInputElement} */ (event.currentTarget);
|
|
45
43
|
const { name, value, checked } = inputElement;
|
|
46
44
|
|
|
47
45
|
switch (name) {
|
|
@@ -55,13 +53,13 @@ function onOptionChange(event) {
|
|
|
55
53
|
}
|
|
56
54
|
break;
|
|
57
55
|
case 'outlined': {
|
|
58
|
-
|
|
56
|
+
for (const el of sampleComponents) {
|
|
59
57
|
if (checked) {
|
|
60
58
|
el.setAttribute('mdw-outlined', '');
|
|
61
59
|
} else {
|
|
62
60
|
el.removeAttribute('mdw-outlined');
|
|
63
61
|
}
|
|
64
|
-
}
|
|
62
|
+
}
|
|
65
63
|
break;
|
|
66
64
|
}
|
|
67
65
|
default:
|
|
@@ -72,9 +70,9 @@ function onOptionChange(event) {
|
|
|
72
70
|
/** @return {void} */
|
|
73
71
|
function setupComponentOptions() {
|
|
74
72
|
sampleComponents = document.querySelectorAll('.component-sample .mdw-chip');
|
|
75
|
-
|
|
73
|
+
for (const el of document.querySelectorAll('.demo-options input[name]')) {
|
|
76
74
|
el.addEventListener('change', onOptionChange);
|
|
77
|
-
}
|
|
75
|
+
}
|
|
78
76
|
}
|
|
79
77
|
|
|
80
78
|
initializeSampleComponents();
|
package/docs/pages/color.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { iterateArrayLike, nextTick } from '../../core/dom.js';
|
|
2
1
|
import * as Overlay from '../../core/overlay/index.js';
|
|
3
2
|
import * as Ripple from '../../core/ripple/index.js';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
for (const el of document.getElementsByClassName('mdw-overlay')) Overlay.attach(el);
|
|
5
|
+
for (const el of document.getElementsByClassName('mdw-ripple')) Ripple.attach(el);
|
|
7
6
|
|
|
8
7
|
const sampleSurface = document.getElementById('sample-surface');
|
|
9
8
|
const sampleInk = document.getElementById('sample-ink');
|
|
@@ -39,7 +38,7 @@ function parseColor(colorString) {
|
|
|
39
38
|
return colorString
|
|
40
39
|
.match(/\(([^)]+)\)/)[1]
|
|
41
40
|
.split(',')
|
|
42
|
-
.map((value) => (value == null ? 1
|
|
41
|
+
.map((value) => (value == null ? 1 : Number.parseFloat(value)))
|
|
43
42
|
.reduce((prev, curr, index) => {
|
|
44
43
|
if (index > 3) {
|
|
45
44
|
throw new Error('Unexpected 5th value');
|
|
@@ -51,7 +50,7 @@ function parseColor(colorString) {
|
|
|
51
50
|
a: index === 3 ? curr : prev.a,
|
|
52
51
|
};
|
|
53
52
|
}, {
|
|
54
|
-
r: 255, g: 255, b: 255, a: 1
|
|
53
|
+
r: 255, g: 255, b: 255, a: 1,
|
|
55
54
|
});
|
|
56
55
|
}
|
|
57
56
|
|
|
@@ -62,29 +61,30 @@ function parseColor(colorString) {
|
|
|
62
61
|
*/
|
|
63
62
|
function overlayColor(color, overlay) {
|
|
64
63
|
return {
|
|
65
|
-
r: (1
|
|
66
|
-
g: (1
|
|
67
|
-
b: (1
|
|
68
|
-
a: 1
|
|
64
|
+
r: (1 - overlay.a) * color.r + overlay.a * overlay.r,
|
|
65
|
+
g: (1 - overlay.a) * color.g + overlay.a * overlay.g,
|
|
66
|
+
b: (1 - overlay.a) * color.b + overlay.a * overlay.b,
|
|
67
|
+
a: 1,
|
|
69
68
|
};
|
|
70
69
|
}
|
|
71
70
|
|
|
71
|
+
/**
|
|
72
|
+
* @param {number} colorValue
|
|
73
|
+
* @return {number}
|
|
74
|
+
*/
|
|
75
|
+
function sRGBMapping(colorValue) {
|
|
76
|
+
if (colorValue <= (0.039_28 * 255)) {
|
|
77
|
+
return colorValue / 255 / 12.92;
|
|
78
|
+
}
|
|
79
|
+
return ((colorValue / 255 + 0.055) / 1.055) ** 2.4;
|
|
80
|
+
}
|
|
81
|
+
|
|
72
82
|
/**
|
|
73
83
|
* https://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
|
|
74
84
|
* @param {Color} color
|
|
75
85
|
* @return {number}
|
|
76
86
|
*/
|
|
77
87
|
function getLuminance(color) {
|
|
78
|
-
/**
|
|
79
|
-
* @param {number} colorValue
|
|
80
|
-
* @return {number}
|
|
81
|
-
*/
|
|
82
|
-
function sRGBMapping(colorValue) {
|
|
83
|
-
if (colorValue <= (0.03928 * 255)) {
|
|
84
|
-
return colorValue / 255 / 12.92;
|
|
85
|
-
}
|
|
86
|
-
return ((colorValue / 255 + 0.055) / 1.055) ** 2.4;
|
|
87
|
-
}
|
|
88
88
|
const R = 0.2126 * sRGBMapping(color.r);
|
|
89
89
|
const G = 0.7152 * sRGBMapping(color.g);
|
|
90
90
|
const B = 0.0722 * sRGBMapping(color.b);
|
|
@@ -128,7 +128,7 @@ function updateInks(name) {
|
|
|
128
128
|
|
|
129
129
|
/** @return {void} */
|
|
130
130
|
function calculateContrast() {
|
|
131
|
-
|
|
131
|
+
requestAnimationFrame(() => {
|
|
132
132
|
const style = window.getComputedStyle(sampleButton);
|
|
133
133
|
const surfaceColor = parseColor(style.backgroundColor);
|
|
134
134
|
const inkColor = parseColor(style.color);
|
|
@@ -166,8 +166,7 @@ function calculateContrast() {
|
|
|
166
166
|
* @return {void}
|
|
167
167
|
*/
|
|
168
168
|
function onItemClick(event) {
|
|
169
|
-
/** @type {HTMLElement} */
|
|
170
|
-
const item = (event.currentTarget);
|
|
169
|
+
const item = /** @type {HTMLElement} */ (event.currentTarget);
|
|
171
170
|
if (item.id) {
|
|
172
171
|
return;
|
|
173
172
|
}
|
|
@@ -197,15 +196,15 @@ function refresh() {
|
|
|
197
196
|
currentInkOptions.color,
|
|
198
197
|
currentInkOptions.tone,
|
|
199
198
|
currentInkOptions.opacity,
|
|
200
|
-
].filter(
|
|
199
|
+
].filter(Boolean).join(' ');
|
|
201
200
|
const surfaceProperties = [
|
|
202
201
|
currentSurfaceOptions.color,
|
|
203
202
|
currentSurfaceOptions.tone,
|
|
204
|
-
].filter(
|
|
205
|
-
|
|
203
|
+
].filter(Boolean).join(' ');
|
|
204
|
+
for (const el of document.querySelectorAll('#color-sample-area .demo-core-item')) {
|
|
206
205
|
el.setAttribute('mdw-ink', inkProperties);
|
|
207
206
|
el.setAttribute('mdw-surface', surfaceProperties);
|
|
208
|
-
}
|
|
207
|
+
}
|
|
209
208
|
calculateContrast();
|
|
210
209
|
}
|
|
211
210
|
|
|
@@ -214,8 +213,7 @@ function refresh() {
|
|
|
214
213
|
* @return {void}
|
|
215
214
|
*/
|
|
216
215
|
function onOptionChange(event) {
|
|
217
|
-
/** @type {HTMLSelectElement} */
|
|
218
|
-
const selectElement = (event.target);
|
|
216
|
+
const selectElement = /** @type {HTMLSelectElement} */ (event.target);
|
|
219
217
|
const { name, value } = selectElement;
|
|
220
218
|
switch (name) {
|
|
221
219
|
case 'ink-color':
|
|
@@ -243,20 +241,21 @@ function onOptionChange(event) {
|
|
|
243
241
|
function setupComponentOptions() {
|
|
244
242
|
// sampleComponent = document.querySelector('.component-sample .mdw-button');
|
|
245
243
|
// Button.attach(sampleComponent);
|
|
246
|
-
|
|
244
|
+
for (const el of document.querySelectorAll('#color-page-options [name]')) {
|
|
247
245
|
el.addEventListener('change', onOptionChange);
|
|
248
|
-
}
|
|
246
|
+
}
|
|
249
247
|
}
|
|
250
248
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
);
|
|
249
|
+
for (const item of document.getElementsByClassName('demo-core-item')) {
|
|
250
|
+
item.addEventListener('click', onItemClick);
|
|
251
|
+
}
|
|
255
252
|
|
|
256
|
-
[
|
|
253
|
+
for (const button of [
|
|
257
254
|
document.getElementById('darkModeButton'),
|
|
258
255
|
document.getElementById('altThemeButton'),
|
|
259
|
-
]
|
|
256
|
+
]) {
|
|
257
|
+
button?.addEventListener('click', calculateContrast);
|
|
258
|
+
}
|
|
260
259
|
|
|
261
260
|
setupComponentOptions();
|
|
262
261
|
refresh();
|
package/docs/pages/datatable.js
CHANGED
|
@@ -4,14 +4,13 @@ import * as DataTable from '../../components/datatable/index.js';
|
|
|
4
4
|
import * as Menu from '../../components/menu/index.js';
|
|
5
5
|
import * as MenuItem from '../../components/menu/item.js';
|
|
6
6
|
import * as Selection from '../../components/selection/index.js';
|
|
7
|
-
import { iterateArrayLike } from '../../core/dom.js';
|
|
8
7
|
|
|
9
8
|
/** @return {void} */
|
|
10
9
|
function initializeMdwComponents() {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
for (const element of document.querySelectorAll('.mdw-datatable.js')) { DataTable.attach(element); }
|
|
11
|
+
for (const element of document.getElementsByClassName('mdw-button')) { Button.attach(element); }
|
|
12
|
+
for (const element of document.getElementsByClassName('mdw-selection')) { Selection.attach(element); }
|
|
13
|
+
for (const element of document.getElementsByClassName('mdw-menu')) { Menu.attach(element); }
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
/**
|
|
@@ -34,11 +33,11 @@ function buildDynamicTable() {
|
|
|
34
33
|
const addDatasourceObject = () => {
|
|
35
34
|
datasource.push({
|
|
36
35
|
selected: false,
|
|
37
|
-
text: Math.random().toString(36).
|
|
38
|
-
text2: Math.random().toString(36).
|
|
36
|
+
text: Math.random().toString(36).slice(2),
|
|
37
|
+
text2: Math.random().toString(36).slice(2),
|
|
39
38
|
check1: Math.random() > 0.5,
|
|
40
39
|
increment: count,
|
|
41
|
-
random: Math.floor(Math.random() *
|
|
40
|
+
random: Math.floor(Math.random() * 99_999),
|
|
42
41
|
});
|
|
43
42
|
count += 1;
|
|
44
43
|
};
|
|
@@ -101,15 +100,14 @@ function buildDynamicTable() {
|
|
|
101
100
|
optionsButton.addEventListener('click', (/** @type {MouseEvent} */ event) => Menu.show(optionsMenu, event));
|
|
102
101
|
|
|
103
102
|
filterMenu.addEventListener(MenuItem.CHECK_EVENT, (event) => {
|
|
104
|
-
/** @type {HTMLElement} */
|
|
105
|
-
const menuItem = (event.target);
|
|
103
|
+
const menuItem = /** @type {HTMLElement} */ (event.target);
|
|
106
104
|
switch (menuItem.dataset.filter) {
|
|
107
105
|
default:
|
|
108
106
|
case 'none':
|
|
109
107
|
dynamicTableAdapter.setFilter(null);
|
|
110
108
|
break;
|
|
111
109
|
case 'md':
|
|
112
|
-
dynamicTableAdapter.setFilter((data) => data.text.
|
|
110
|
+
dynamicTableAdapter.setFilter((data) => data.text.includes('md') || data.text2.includes('md'));
|
|
113
111
|
break;
|
|
114
112
|
case 'div9':
|
|
115
113
|
dynamicTableAdapter.setFilter((data) => data.random % 9 === 0);
|
|
@@ -128,8 +126,7 @@ function buildDynamicTable() {
|
|
|
128
126
|
filterMenu.addEventListener(MenuItem.ACTIVATE_EVENT, () => Menu.hide(filterMenu));
|
|
129
127
|
|
|
130
128
|
optionsMenu.addEventListener(MenuItem.CHECK_EVENT, (event) => {
|
|
131
|
-
/** @type {HTMLElement} */
|
|
132
|
-
const menuItem = (event.target);
|
|
129
|
+
const menuItem = /** @type {HTMLElement} */ (event.target);
|
|
133
130
|
switch (menuItem.dataset.option) {
|
|
134
131
|
default:
|
|
135
132
|
break;
|
|
@@ -143,8 +140,7 @@ function buildDynamicTable() {
|
|
|
143
140
|
dynamicTableAdapter.refresh();
|
|
144
141
|
});
|
|
145
142
|
optionsMenu.addEventListener(MenuItem.UNCHECK_EVENT, (event) => {
|
|
146
|
-
/** @type {HTMLElement} */
|
|
147
|
-
const menuItem = (event.target);
|
|
143
|
+
const menuItem = /** @type {HTMLElement} */ (event.target);
|
|
148
144
|
switch (menuItem.dataset.option) {
|
|
149
145
|
default:
|
|
150
146
|
break;
|
package/docs/pages/dialog.eta
CHANGED
|
@@ -63,18 +63,16 @@
|
|
|
63
63
|
<div class="display-flex flex-1" flex-column style="position:relative;">
|
|
64
64
|
<%~ includeFile('../_partials/_androidstatusbar.eta', { surface: 'primary 700', dark: true }) %>
|
|
65
65
|
<div class="mdw-appbar mdw-theme" mdw-surface="primary 500" mdw-dark>
|
|
66
|
-
<div class="mdw-
|
|
67
|
-
<div class="mdw-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
<div class="mdw-tooltip mdw-theme" mdw-surface="background 700" mdw-dark>Menu</div>
|
|
71
|
-
</div>
|
|
66
|
+
<div class="mdw-appbar__start">
|
|
67
|
+
<div class="mdw-tooltip__wrapper">
|
|
68
|
+
<%~ includeFile(T, {button: { icon:true, class:"mdw-tooltip__target material-icons", text:'menu' }}) %>
|
|
69
|
+
<div class="mdw-tooltip mdw-theme" mdw-surface="background 700" mdw-dark>Menu</div>
|
|
72
70
|
</div>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
</div>
|
|
71
|
+
</div>
|
|
72
|
+
<div class="mdw-appbar__end">
|
|
73
|
+
<div class="mdw-tooltip__wrapper">
|
|
74
|
+
<%~ includeFile(T, {button: { icon:true, class:"mdw-tooltip__target material-icons", text:'more_vert' }}) %>
|
|
75
|
+
<div class="mdw-tooltip mdw-theme" mdw-surface="background 700" mdw-dark>Options</div>
|
|
78
76
|
</div>
|
|
79
77
|
</div>
|
|
80
78
|
</div>
|
package/docs/pages/dialog.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as Button from '../../components/button/index.js';
|
|
2
2
|
import * as Dialog from '../../components/dialog/index.js';
|
|
3
|
-
import { iterateArrayLike } from '../../core/dom.js';
|
|
4
3
|
import { convertElementToCode } from '../_sample-utils.js';
|
|
5
4
|
|
|
6
5
|
/** @type {HTMLElement} */
|
|
@@ -28,13 +27,11 @@ function updateSampleCode() {
|
|
|
28
27
|
Button.detach(button);
|
|
29
28
|
button.removeEventListener('click', onSampleButtonClick);
|
|
30
29
|
const tabIndexElements = sampleComponent.querySelectorAll('[tabindex]');
|
|
31
|
-
|
|
30
|
+
for (const el of tabIndexElements) el.removeAttribute('tabindex');
|
|
32
31
|
|
|
33
|
-
if (closer) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
closer = null;
|
|
37
|
-
}
|
|
32
|
+
if (closer && (jsRequired || !(closer instanceof HTMLAnchorElement))) {
|
|
33
|
+
closer.remove();
|
|
34
|
+
closer = null;
|
|
38
35
|
}
|
|
39
36
|
|
|
40
37
|
if (useJS) {
|
|
@@ -122,9 +119,9 @@ function onOptionChange(event) {
|
|
|
122
119
|
/** @return {void} */
|
|
123
120
|
function setupComponentOptions() {
|
|
124
121
|
sampleComponent = document.querySelector('.component-sample .mdw-dialog');
|
|
125
|
-
|
|
122
|
+
for (const el of document.querySelectorAll('input[name]')) {
|
|
126
123
|
el.addEventListener('change', onOptionChange);
|
|
127
|
-
}
|
|
124
|
+
}
|
|
128
125
|
}
|
|
129
126
|
|
|
130
127
|
/** @return {void} */
|
package/docs/pages/dom.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import DomAdapter from '../../adapters/dom/index.js';
|
|
2
2
|
import * as ListContent from '../../components/list/content.js';
|
|
3
3
|
import * as ListItem from '../../components/list/item.js';
|
|
4
|
-
import { iterateArrayLike } from '../../core/dom.js';
|
|
5
4
|
|
|
6
5
|
class CustomDataSourceItem {
|
|
7
6
|
/** @param {number} i */
|
|
@@ -40,9 +39,9 @@ function onOptionChange(event) {
|
|
|
40
39
|
}
|
|
41
40
|
/** @return {void} */
|
|
42
41
|
function setupComponentOptions() {
|
|
43
|
-
|
|
42
|
+
for (const el of document.querySelectorAll('input[name]')) {
|
|
44
43
|
el.addEventListener('change', onOptionChange);
|
|
45
|
-
}
|
|
44
|
+
}
|
|
46
45
|
sampleComponent = document.querySelector('.component-sample .mdw-list');
|
|
47
46
|
resetDatasource();
|
|
48
47
|
domAdapter = new DomAdapter({
|
|
@@ -115,7 +114,7 @@ function setupComponentOptions() {
|
|
|
115
114
|
buttons[1].setAttribute('aria-disabled', 'true');
|
|
116
115
|
});
|
|
117
116
|
buttons[2].addEventListener('click', () => {
|
|
118
|
-
const item = datasource.
|
|
117
|
+
const item = datasource.find((d) => d.itemnumber === 50);
|
|
119
118
|
item.clickCount += 1;
|
|
120
119
|
// Element will not change size, therefore avoid possible invalidation
|
|
121
120
|
// (When element is refreshed and not in DOM, adapter may assume sized change)
|
|
@@ -123,17 +122,15 @@ function setupComponentOptions() {
|
|
|
123
122
|
domAdapter.drawViewport();
|
|
124
123
|
});
|
|
125
124
|
buttons[3].addEventListener('click', () => {
|
|
126
|
-
const item = datasource.
|
|
125
|
+
const item = datasource.find((d) => d.itemnumber === 80);
|
|
127
126
|
item.expanded = !item.expanded;
|
|
128
127
|
// Force invalidation from height change
|
|
129
128
|
domAdapter.refreshItem(item, { invalidate: true });
|
|
130
129
|
domAdapter.drawViewport();
|
|
131
130
|
});
|
|
132
131
|
sampleComponent.addEventListener(ListContent.ACTIVATE_EVENT, (event) => {
|
|
133
|
-
/** @type {HTMLElement} */
|
|
134
|
-
const
|
|
135
|
-
/** @type {HTMLLIElement} */
|
|
136
|
-
const listItem = (listContent.parentElement);
|
|
132
|
+
const listContent = /** @type {HTMLElement} */ (event.target);
|
|
133
|
+
const listItem = /** @type {HTMLLIElement} */ (listContent.parentElement);
|
|
137
134
|
const dataItem = domAdapter.elementDataMap.get(listItem);
|
|
138
135
|
dataItem.clickCount += 1;
|
|
139
136
|
domAdapter.refreshItem(dataItem);
|
package/docs/pages/elevation.eta
CHANGED
|
@@ -2,34 +2,34 @@
|
|
|
2
2
|
<% layout('../_partials/_header.eta', {page: 'elevation'}) %>
|
|
3
3
|
<div class="docs-grid mdw-grid" mdw-margin-top mdw-margin-bottom mdw-columns="4" mdw-margin-4col="40" mdw-gutter-4col="40">
|
|
4
4
|
<div class="mdw-grid__item">
|
|
5
|
-
<div class="docs-elevation__item mdw-elevation" mdw-elevation="1">1dp</div>
|
|
5
|
+
<div class="docs-elevation__item mdw-elevation mdw-overlay" mdw-overlay-off="hover" mdw-elevation="1">1dp</div>
|
|
6
6
|
</div>
|
|
7
7
|
<div class="mdw-grid__item">
|
|
8
|
-
<div class="docs-elevation__item mdw-elevation" mdw-elevation="2">2dp</div>
|
|
8
|
+
<div class="docs-elevation__item mdw-elevation mdw-overlay" mdw-overlay-off="hover" mdw-elevation="2">2dp</div>
|
|
9
9
|
</div>
|
|
10
10
|
<div class="mdw-grid__item">
|
|
11
|
-
<div class="docs-elevation__item mdw-elevation" mdw-elevation="3">3dp</div>
|
|
11
|
+
<div class="docs-elevation__item mdw-elevation mdw-overlay" mdw-overlay-off="hover" mdw-elevation="3">3dp</div>
|
|
12
12
|
</div>
|
|
13
13
|
<div class="mdw-grid__item">
|
|
14
|
-
<div class="docs-elevation__item mdw-elevation" mdw-elevation="4">4dp</div>
|
|
14
|
+
<div class="docs-elevation__item mdw-elevation mdw-overlay" mdw-overlay-off="hover" mdw-elevation="4">4dp</div>
|
|
15
15
|
</div>
|
|
16
16
|
<div class="mdw-grid__item">
|
|
17
|
-
<div class="docs-elevation__item mdw-elevation" mdw-elevation="6">6dp</div>
|
|
17
|
+
<div class="docs-elevation__item mdw-elevation mdw-overlay" mdw-overlay-off="hover" mdw-elevation="6">6dp</div>
|
|
18
18
|
</div>
|
|
19
19
|
<div class="mdw-grid__item">
|
|
20
|
-
<div class="docs-elevation__item mdw-elevation" mdw-elevation="8">8dp</div>
|
|
20
|
+
<div class="docs-elevation__item mdw-elevation mdw-overlay" mdw-overlay-off="hover" mdw-elevation="8">8dp</div>
|
|
21
21
|
</div>
|
|
22
22
|
<div class="mdw-grid__item">
|
|
23
|
-
<div class="docs-elevation__item mdw-elevation" mdw-elevation="9">9dp</div>
|
|
23
|
+
<div class="docs-elevation__item mdw-elevation mdw-overlay" mdw-overlay-off="hover" mdw-elevation="9">9dp</div>
|
|
24
24
|
</div>
|
|
25
25
|
<div class="mdw-grid__item">
|
|
26
|
-
<div class="docs-elevation__item mdw-elevation" mdw-elevation="12">12dp</div>
|
|
26
|
+
<div class="docs-elevation__item mdw-elevation mdw-overlay" mdw-overlay-off="hover" mdw-elevation="12">12dp</div>
|
|
27
27
|
</div>
|
|
28
28
|
<div class="mdw-grid__item">
|
|
29
|
-
<div class="docs-elevation__item mdw-elevation" mdw-elevation="16">16dp</div>
|
|
29
|
+
<div class="docs-elevation__item mdw-elevation mdw-overlay" mdw-overlay-off="hover" mdw-elevation="16">16dp</div>
|
|
30
30
|
</div>
|
|
31
31
|
<div class="mdw-grid__item">
|
|
32
|
-
<div class="docs-elevation__item mdw-elevation" mdw-elevation="24">24dp</div>
|
|
32
|
+
<div class="docs-elevation__item mdw-elevation mdw-overlay" mdw-overlay-off="hover" mdw-elevation="24">24dp</div>
|
|
33
33
|
</div>
|
|
34
34
|
</div>
|
|
35
35
|
<script src="elevation.min.js"></script>
|
package/docs/pages/fab.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import * as Button from '../../components/button/index.js';
|
|
2
2
|
import * as Fab from '../../components/fab/index.js';
|
|
3
|
-
import { iterateArrayLike } from '../../core/dom.js';
|
|
4
3
|
|
|
5
4
|
/** @return {void} */
|
|
6
5
|
function initializeMdwComponents() {
|
|
7
|
-
|
|
6
|
+
for (const element of document.querySelectorAll('.js .mdw-fab')) { Fab.attach(element); }
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
for (const element of document.querySelectorAll('.js .mdw-button')) { Button.attach(element); }
|
|
10
9
|
|
|
11
10
|
document.querySelector('input[name="hover"]').addEventListener('change', (event) => {
|
|
12
11
|
if (event.currentTarget.checked) {
|
package/docs/pages/grid.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { setTextNode } from '../../core/dom.js';
|
|
2
2
|
|
|
3
3
|
const sampleComponent = document.getElementById('sample-component');
|
|
4
4
|
|
|
@@ -115,14 +115,14 @@ function onOptionChange(event) {
|
|
|
115
115
|
|
|
116
116
|
/** @return {void} */
|
|
117
117
|
function setupInteractions() {
|
|
118
|
-
|
|
118
|
+
for (const item of sampleComponent.getElementsByClassName('mdw-grid__item')) {
|
|
119
119
|
item.addEventListener('click', () => {
|
|
120
120
|
onGridItemClick(item);
|
|
121
121
|
});
|
|
122
|
-
}
|
|
123
|
-
|
|
122
|
+
}
|
|
123
|
+
for (const el of document.querySelectorAll('[name]')) {
|
|
124
124
|
el.addEventListener('change', onOptionChange);
|
|
125
|
-
}
|
|
125
|
+
}
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
setupInteractions();
|
package/docs/pages/list.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as List from '../../components/list/index.js';
|
|
2
|
-
import { iterateArrayLike } from '../../core/dom.js';
|
|
3
2
|
|
|
4
3
|
/** @return {void} */
|
|
5
4
|
function initializeMdwComponents() {
|
|
6
|
-
|
|
5
|
+
for (const element of document.querySelectorAll('.js .mdw-list')) List.attach(element);
|
|
7
6
|
}
|
|
8
7
|
|
|
9
8
|
initializeMdwComponents();
|