@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/menu.eta
CHANGED
|
@@ -119,26 +119,24 @@
|
|
|
119
119
|
<div class="render-fill">
|
|
120
120
|
<%~ includeFile('../_partials/_androidstatusbar.eta', { surface:'primary 700', dark:true }) %>
|
|
121
121
|
<div class="mdw-appbar mdw-theme" mdw-surface="primary 500" mdw-dark>
|
|
122
|
-
<div class="mdw-
|
|
123
|
-
<div class="mdw-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
<div class="mdw-tooltip mdw-theme" mdw-surface="background 700" mdw-dark>Menu</div>
|
|
127
|
-
</div>
|
|
122
|
+
<div class="mdw-appbar__start">
|
|
123
|
+
<div class="mdw-tooltip__wrapper">
|
|
124
|
+
<%~ includeFile(T, { button: { icon:true, class:'mdw-tooltip__target material-icons', text:'menu' }}) %>
|
|
125
|
+
<div class="mdw-tooltip mdw-theme" mdw-surface="background 700" mdw-dark>Menu</div>
|
|
128
126
|
</div>
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
</div>
|
|
127
|
+
</div>
|
|
128
|
+
<div class="mdw-appbar__end">
|
|
129
|
+
<div class="mdw-tooltip__wrapper mdw-menu__wrapper">
|
|
130
|
+
<%~ includeFile(T, { button: { icon:true, class:'mdw-tooltip__target material-icons', href:"#moremenu", text:'more_vert' }}) %>
|
|
131
|
+
<div class="mdw-tooltip mdw-theme mdw-tooltip" mdw-surface="background 700" mdw-dark>Options</div>
|
|
132
|
+
<div class="mdw-menu" id="moremenu" mdw-direction="reverse" mdw-position="end" mdw-width-units="3">
|
|
133
|
+
<a class="mdw-menu__close" href="#"></a>
|
|
134
|
+
<div class="mdw-menu__popup mdw-theme" mdw-surface="card">
|
|
135
|
+
<div class="mdw-menu__text">Refresh</div>
|
|
136
|
+
<div class="mdw-menu__text">Settings</div>
|
|
137
|
+
<div class="mdw-menu__text">Send feedback</div>
|
|
138
|
+
<div class="mdw-menu__text">Help</div>
|
|
139
|
+
<div class="mdw-menu__text">Signout</div>
|
|
142
140
|
</div>
|
|
143
141
|
</div>
|
|
144
142
|
</div>
|
package/docs/pages/menu.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as Menu from '../../components/menu/index.js';
|
|
2
2
|
import * as MenuItem from '../../components/menu/item.js';
|
|
3
|
-
import { iterateArrayLike } from '../../core/dom.js';
|
|
4
3
|
import { convertElementToCode } from '../_sample-utils.js';
|
|
5
4
|
|
|
6
5
|
/** @type {HTMLElement} */
|
|
@@ -37,13 +36,11 @@ function updateSampleCode() {
|
|
|
37
36
|
const button = document.querySelector('.component-sample .mdw-button');
|
|
38
37
|
let closer = document.querySelector('.component-sample .mdw-menu__close');
|
|
39
38
|
button.removeEventListener('click', onSampleButtonClick);
|
|
40
|
-
|
|
39
|
+
for (const el of sampleComponent.querySelectorAll('[tabindex]')) el.removeAttribute('tabindex');
|
|
41
40
|
|
|
42
|
-
if (closer) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
closer = null;
|
|
46
|
-
}
|
|
41
|
+
if (closer && (jsRequired || !(closer instanceof HTMLAnchorElement))) {
|
|
42
|
+
closer.remove();
|
|
43
|
+
closer = null;
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
if (jsRequired) {
|
|
@@ -113,8 +110,7 @@ function initializeSampleComponents() {
|
|
|
113
110
|
* @return {void}
|
|
114
111
|
*/
|
|
115
112
|
function onOptionChange(event) {
|
|
116
|
-
/** @type {HTMLInputElement} */
|
|
117
|
-
const { name, value } = (event.target);
|
|
113
|
+
const { name, value } = /** @type {HTMLInputElement} */ (event.target);
|
|
118
114
|
let mdwDirection = sampleComponent.getAttribute('mdw-direction') || '';
|
|
119
115
|
let mdwPosition = sampleComponent.getAttribute('mdw-position') || '';
|
|
120
116
|
|
|
@@ -207,9 +203,9 @@ function onOptionChange(event) {
|
|
|
207
203
|
/** @return {void} */
|
|
208
204
|
function setupComponentOptions() {
|
|
209
205
|
sampleComponent = document.querySelector('.component-sample .mdw-menu');
|
|
210
|
-
|
|
206
|
+
for (const el of document.querySelectorAll('input[name]')) {
|
|
211
207
|
el.addEventListener('change', onOptionChange);
|
|
212
|
-
}
|
|
208
|
+
}
|
|
213
209
|
}
|
|
214
210
|
|
|
215
211
|
initializeSampleComponents();
|
package/docs/pages/overlay.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { iterateArrayLike } from '../../core/dom.js';
|
|
2
1
|
import * as Overlay from '../../core/overlay/index.js';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
for (const element of document.querySelectorAll('.js .mdw-overlay')) { Overlay.attach(element); }
|
package/docs/pages/progress.eta
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
<div class="render">
|
|
5
5
|
<div class="content display-flex">
|
|
6
6
|
<div class="flex-1 display-flex" flex-justify-content="center" flex-align-items="center">
|
|
7
|
-
<div class="mdw-
|
|
7
|
+
<div class="mdw-progress__circle mdw-theme" mdw-ink="primary">
|
|
8
8
|
<svg viewBox="0 0 24 24">
|
|
9
9
|
<path d="M12 3.25A8.75 8.75 0 1 1 3.25 12"></path>
|
|
10
10
|
<path d="M12 3.25A8.75 8.75 0 1 1 3.25 12 A 8.75 8.75 0 0 1 12 3.25"></path>
|
|
11
11
|
</svg>
|
|
12
12
|
</div>
|
|
13
|
-
<div class="mdw-
|
|
13
|
+
<div class="mdw-progress__circle mdw-theme" mdw-ink="secondary" mdw-determinate>
|
|
14
14
|
<svg viewBox="0 0 24 24">
|
|
15
15
|
<path d="M12 3.25A8.75 8.75 0 1 1 3.25 12"></path>
|
|
16
16
|
<path d="M12 3.25A8.75 8.75 0 1 1 3.25 12 A 8.75 8.75 0 0 1 12 3.25"></path>
|
package/docs/pages/progress.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as ProgressCircle from '../../components/progress/index.js';
|
|
|
2
2
|
|
|
3
3
|
/** @return {void} */
|
|
4
4
|
function setupProgressCircleInterval() {
|
|
5
|
-
const progressCircleElement = document.querySelector('.mdw-
|
|
5
|
+
const progressCircleElement = document.querySelector('.mdw-progress__circle[mdw-determinate]');
|
|
6
6
|
ProgressCircle.setValue(progressCircleElement, Math.random() * 100);
|
|
7
7
|
setInterval(() => {
|
|
8
8
|
ProgressCircle.setValue(progressCircleElement, Math.random() * 100);
|
package/docs/pages/ripple.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { iterateArrayLike } from '../../core/dom.js';
|
|
2
1
|
import * as Ripple from '../../core/ripple/index.js';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
for (const element of document.querySelectorAll('.js .mdw-ripple')) Ripple.attach(element);
|
package/docs/pages/search.eta
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
</div>
|
|
21
21
|
<div class="mdw-textfield__dropdown mdw-theme" mdw-surface="card" mdw-type="list" mdw-hide>
|
|
22
22
|
<div class="custom-busy-indicator display-flex" flex-align-items="center">
|
|
23
|
-
<div class="mdw-
|
|
23
|
+
<div class="mdw-progress__circle">
|
|
24
24
|
<svg viewBox="0 0 24 24">
|
|
25
25
|
<path d="M12 3.25A8.75 8.75 0 1 1 3.25 12"></path>
|
|
26
26
|
<path d="M12 3.25A8.75 8.75 0 1 1 3.25 12 A 8.75 8.75 0 0 1 12 3.25"></path>
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
</div>
|
|
51
51
|
<div class="mdw-textfield__dropdown mdw-theme" mdw-surface="card" mdw-type="list" mdw-hide>
|
|
52
52
|
<div class="custom-busy-indicator display-flex" flex-align-items="center">
|
|
53
|
-
<div class="mdw-
|
|
53
|
+
<div class="mdw-progress__circle">
|
|
54
54
|
<svg viewBox="0 0 24 24">
|
|
55
55
|
<path d="M12 3.25A8.75 8.75 0 1 1 3.25 12"></path>
|
|
56
56
|
<path d="M12 3.25A8.75 8.75 0 1 1 3.25 12 A 8.75 8.75 0 0 1 12 3.25"></path>
|
|
@@ -75,19 +75,17 @@
|
|
|
75
75
|
<i class="material-icons" style="letter-spacing:2px;padding:0 2px;"></i>
|
|
76
76
|
</div>
|
|
77
77
|
<div class="mdw-appbar mdw-theme" mdw-surface="primary 500" mdw-dark>
|
|
78
|
-
<div class="mdw-
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
<div class="mdw-
|
|
83
|
-
<
|
|
84
|
-
<input class="mdw-textfield__input" placeholder="Search" />
|
|
85
|
-
</div>
|
|
86
|
-
</div>
|
|
87
|
-
<div class="mdw-appbar__end">
|
|
88
|
-
<a class="mdw-button mdw-overlay mdw-ripple material-icons" mdw-icon tabindex="0">clear</a>
|
|
78
|
+
<div class="mdw-appbar__start">
|
|
79
|
+
<a class="mdw-button mdw-overlay mdw-ripple material-icons" mdw-icon tabindex="0">arrow_back</a>
|
|
80
|
+
</div>
|
|
81
|
+
<div class="mdw-appbar__title" mdw-custom>
|
|
82
|
+
<div class="mdw-textfield mdw-theme" id="search-textfield-simple" mdw-solo mdw-ink="secondary">
|
|
83
|
+
<input class="mdw-textfield__input" placeholder="Search" />
|
|
89
84
|
</div>
|
|
90
85
|
</div>
|
|
86
|
+
<div class="mdw-appbar__end">
|
|
87
|
+
<a class="mdw-button mdw-overlay mdw-ripple material-icons" mdw-icon tabindex="0">clear</a>
|
|
88
|
+
</div>
|
|
91
89
|
</div>
|
|
92
90
|
<div class="content">
|
|
93
91
|
<ul class="mdw-list" id="search-list-simple">
|
|
@@ -140,19 +138,17 @@
|
|
|
140
138
|
<i class="material-icons" style="letter-spacing:2px;padding:0 2px;"></i>
|
|
141
139
|
</div>
|
|
142
140
|
<div class="mdw-appbar mdw-theme" mdw-surface="primary 500" mdw-dark>
|
|
143
|
-
<div class="mdw-
|
|
144
|
-
<
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
<div class="mdw-
|
|
148
|
-
<
|
|
149
|
-
<input class="mdw-textfield__input" placeholder="Search" />
|
|
150
|
-
</div>
|
|
151
|
-
</div>
|
|
152
|
-
<div class="mdw-appbar__end">
|
|
153
|
-
<a class="mdw-button mdw-overlay mdw-ripple material-icons" mdw-icon tabindex="0">clear</a>
|
|
141
|
+
<div class="mdw-appbar__start">
|
|
142
|
+
<a class="mdw-button mdw-overlay mdw-ripple material-icons" mdw-icon tabindex="0">arrow_back</a>
|
|
143
|
+
</div>
|
|
144
|
+
<div class="mdw-appbar__title" mdw-custom>
|
|
145
|
+
<div class="mdw-textfield mdw-theme" id="search-textfield-multiline" mdw-solo mdw-ink="secondary">
|
|
146
|
+
<input class="mdw-textfield__input" placeholder="Search" />
|
|
154
147
|
</div>
|
|
155
148
|
</div>
|
|
149
|
+
<div class="mdw-appbar__end">
|
|
150
|
+
<a class="mdw-button mdw-overlay mdw-ripple material-icons" mdw-icon tabindex="0">clear</a>
|
|
151
|
+
</div>
|
|
156
152
|
</div>
|
|
157
153
|
<div class="content">
|
|
158
154
|
<ul class="mdw-list" id="search-list-multiline">
|
package/docs/pages/search.js
CHANGED
|
@@ -3,7 +3,7 @@ import SearchAdapter from '../../adapters/search/index.js';
|
|
|
3
3
|
import * as ListContent from '../../components/list/content.js';
|
|
4
4
|
import * as ListItem from '../../components/list/item.js';
|
|
5
5
|
import * as TextField from '../../components/textfield/index.js';
|
|
6
|
-
import {
|
|
6
|
+
import { setTextNode } from '../../core/dom.js';
|
|
7
7
|
|
|
8
8
|
/** @typedef {{line1:string, line2:string}} CustomSearchResult */
|
|
9
9
|
|
|
@@ -18,12 +18,11 @@ let searchDocsMultiline;
|
|
|
18
18
|
*/
|
|
19
19
|
function performFakeSearch(filter) {
|
|
20
20
|
const results = [];
|
|
21
|
-
// eslint-disable-next-line guard-for-in
|
|
21
|
+
// eslint-disable-next-line guard-for-in
|
|
22
22
|
for (const key in navigator) {
|
|
23
|
-
/** @type {keyof Navigator} */
|
|
24
|
-
const navKey = (key);
|
|
23
|
+
const navKey = /** @type {keyof Navigator} */ (key);
|
|
25
24
|
const value = navigator[navKey] && navigator[navKey].toString();
|
|
26
|
-
if (!filter || key.
|
|
25
|
+
if (!filter || key.includes(filter) || (value && value.includes(filter))) {
|
|
27
26
|
results.push({ line1: key, line2: value });
|
|
28
27
|
}
|
|
29
28
|
}
|
|
@@ -51,7 +50,7 @@ function showElement(element) {
|
|
|
51
50
|
* @return {void}
|
|
52
51
|
*/
|
|
53
52
|
function searchResultRenderer(listItemElement, result) {
|
|
54
|
-
if (!listItemElement.
|
|
53
|
+
if (!listItemElement.hasChildNodes()) {
|
|
55
54
|
const markup = `
|
|
56
55
|
<div class="mdw-list__content mdw-theme" mdw-ink="secondary" aria-selected="false">
|
|
57
56
|
<div class="mdw-list__text">
|
|
@@ -59,7 +58,6 @@ function searchResultRenderer(listItemElement, result) {
|
|
|
59
58
|
<div class="mdw-list__text-line"></div>
|
|
60
59
|
</div>
|
|
61
60
|
</div>`;
|
|
62
|
-
// eslint-disable-next-line no-param-reassign
|
|
63
61
|
listItemElement.innerHTML = markup;
|
|
64
62
|
ListItem.attach(listItemElement);
|
|
65
63
|
}
|
|
@@ -72,8 +70,7 @@ function searchResultRenderer(listItemElement, result) {
|
|
|
72
70
|
function buildCustomSearch1() {
|
|
73
71
|
const textfield = document.getElementById('search-textfield-custom1');
|
|
74
72
|
const list = document.getElementById('search-list-custom1');
|
|
75
|
-
/** @type {HTMLElement} */
|
|
76
|
-
const busyIndicator = (textfield.getElementsByClassName('custom-busy-indicator')[0]);
|
|
73
|
+
const busyIndicator = /** @type {HTMLElement} */ (textfield.getElementsByClassName('custom-busy-indicator')[0]);
|
|
77
74
|
|
|
78
75
|
// For purpose of this demo results are cached.
|
|
79
76
|
// Actual filter is performed by SearchAdapter
|
|
@@ -96,11 +93,10 @@ function buildCustomSearch1() {
|
|
|
96
93
|
dropdown: true,
|
|
97
94
|
textFilter: 'startsWith',
|
|
98
95
|
suggestionMethod: 'append',
|
|
99
|
-
performSearch(input
|
|
96
|
+
performSearch: async (input) => {
|
|
100
97
|
// Use precached results
|
|
101
98
|
if (myCachedResults != null) {
|
|
102
|
-
|
|
103
|
-
return;
|
|
99
|
+
return myCachedResults;
|
|
104
100
|
}
|
|
105
101
|
|
|
106
102
|
// Display a busy indicator
|
|
@@ -110,18 +106,15 @@ function buildCustomSearch1() {
|
|
|
110
106
|
myCachedResults = performFakeSearch();
|
|
111
107
|
|
|
112
108
|
// Let busy indicator spin to illustrate loading
|
|
113
|
-
setTimeout(() => {
|
|
114
|
-
|
|
115
|
-
resolve(myCachedResults);
|
|
116
|
-
}, 2000);
|
|
109
|
+
await setTimeout(() => { /* noop */ }, 2000);
|
|
110
|
+
return myCachedResults;
|
|
117
111
|
},
|
|
118
|
-
updateList(searchResults
|
|
112
|
+
updateList: (searchResults) => {
|
|
119
113
|
// SearchAdapter signaling the UI is ready to update with search results
|
|
120
114
|
|
|
121
115
|
if (customListAdapter.datasource === searchResults) {
|
|
122
116
|
// Search results have already been mapped. Nothing to do.
|
|
123
117
|
// SearchAdapter handles item filtering.
|
|
124
|
-
resolve();
|
|
125
118
|
return;
|
|
126
119
|
}
|
|
127
120
|
|
|
@@ -133,16 +126,14 @@ function buildCustomSearch1() {
|
|
|
133
126
|
|
|
134
127
|
// Tell ListAdapter to perform a full refresh
|
|
135
128
|
customListAdapter.refresh();
|
|
136
|
-
resolve();
|
|
137
129
|
},
|
|
138
130
|
});
|
|
139
131
|
|
|
140
132
|
searchDocsCustom.list.addEventListener(ListContent.ACTIVATE_EVENT, (event) => {
|
|
141
|
-
/** @type {HTMLElement} */
|
|
142
|
-
const
|
|
143
|
-
/** @type {HTMLLIElement} */
|
|
144
|
-
const listItemElement = (listContentElement.parentElement);
|
|
133
|
+
const listContentElement = /** @type {HTMLElement} */ (event.target);
|
|
134
|
+
const listItemElement = /** @type {HTMLLIElement} */ (listContentElement.parentElement);
|
|
145
135
|
const selectedItem = customListAdapter.elementDataMap.get(listItemElement);
|
|
136
|
+
if (!selectedItem) throw new Error('Missing item!');
|
|
146
137
|
const text = `${selectedItem.line1}:${selectedItem.line2}`;
|
|
147
138
|
document.getElementById('search-result-custom1').textContent = text;
|
|
148
139
|
});
|
|
@@ -152,10 +143,8 @@ function buildCustomSearch1() {
|
|
|
152
143
|
function buildCustomSearch2() {
|
|
153
144
|
const textfield = document.getElementById('search-textfield-custom2');
|
|
154
145
|
const list = document.getElementById('search-list-custom2');
|
|
155
|
-
/** @type {HTMLElement} */
|
|
156
|
-
const
|
|
157
|
-
/** @type {HTMLElement} */
|
|
158
|
-
const noResultsIndicator = (textfield.getElementsByClassName('custom-no-results-indicator')[0]);
|
|
146
|
+
const busyIndicator = /** @type {HTMLElement} */ (textfield.getElementsByClassName('custom-busy-indicator')[0]);
|
|
147
|
+
const noResultsIndicator = /** @type {HTMLElement} */ (textfield.getElementsByClassName('custom-no-results-indicator')[0]);
|
|
159
148
|
|
|
160
149
|
/** @type {ListAdapter<CustomSearchResult>} */
|
|
161
150
|
const customListAdapter = new ListAdapter({
|
|
@@ -174,7 +163,7 @@ function buildCustomSearch2() {
|
|
|
174
163
|
debounce: 300,
|
|
175
164
|
dropdown: true,
|
|
176
165
|
filterItems: false,
|
|
177
|
-
performSearch(searchTerm
|
|
166
|
+
performSearch: async (searchTerm) => {
|
|
178
167
|
// Clear ListAdapter
|
|
179
168
|
customListAdapter.clear();
|
|
180
169
|
|
|
@@ -182,32 +171,26 @@ function buildCustomSearch2() {
|
|
|
182
171
|
hideElement(noResultsIndicator);
|
|
183
172
|
|
|
184
173
|
const myData = performFakeSearch(searchTerm);
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}, 1000);
|
|
174
|
+
// Spin for 1000ms
|
|
175
|
+
await setTimeout(() => { /* noop */ }, 1000);
|
|
176
|
+
return myData;
|
|
189
177
|
},
|
|
190
|
-
updateList(items
|
|
178
|
+
updateList: (items) => {
|
|
191
179
|
hideElement(busyIndicator);
|
|
192
180
|
|
|
193
181
|
if (!items.length) {
|
|
194
182
|
showElement(noResultsIndicator);
|
|
195
|
-
resolve();
|
|
196
183
|
return;
|
|
197
184
|
}
|
|
198
185
|
|
|
199
186
|
// Assign results to ListAdapter
|
|
200
187
|
customListAdapter.datasource = items;
|
|
201
188
|
customListAdapter.refresh();
|
|
202
|
-
|
|
203
|
-
resolve();
|
|
204
189
|
},
|
|
205
190
|
});
|
|
206
191
|
searchDocsCustom.list.addEventListener(ListContent.ACTIVATE_EVENT, (event) => {
|
|
207
|
-
/** @type {HTMLElement} */
|
|
208
|
-
const
|
|
209
|
-
/** @type {HTMLLIElement} */
|
|
210
|
-
const listItemElement = (listContentElement.parentElement);
|
|
192
|
+
const listContentElement = /** @type {HTMLElement} */ (event.target);
|
|
193
|
+
const listItemElement = /** @type {HTMLLIElement} */ (listContentElement.parentElement);
|
|
211
194
|
const selectedItem = customListAdapter.elementDataMap.get(listItemElement);
|
|
212
195
|
const text = `${selectedItem.line1}:${selectedItem.line2}`;
|
|
213
196
|
document.getElementById('search-result-custom2').textContent = text;
|
|
@@ -236,7 +219,7 @@ function setupSearches() {
|
|
|
236
219
|
|
|
237
220
|
/** @return {void} */
|
|
238
221
|
function initializeMdwComponents() {
|
|
239
|
-
|
|
222
|
+
for (const element of document.querySelectorAll('.js .mdw-textfield')) { TextField.attach(element); }
|
|
240
223
|
}
|
|
241
224
|
|
|
242
225
|
initializeMdwComponents();
|
package/docs/pages/selection.eta
CHANGED
|
@@ -6,9 +6,7 @@
|
|
|
6
6
|
<div class="render-fill">
|
|
7
7
|
<%~ includeFile('../_partials/_androidstatusbar.eta', { surface:'teal 700', dark:true }) %>
|
|
8
8
|
<div class="mdw-appbar mdw-theme" mdw-surface="teal 500" mdw-dark>
|
|
9
|
-
<div class="mdw-
|
|
10
|
-
<div class="mdw-appbar__title">Styled HTMLInputElement</div>
|
|
11
|
-
</div>
|
|
9
|
+
<div class="mdw-appbar__title">Styled HTMLInputElement</div>
|
|
12
10
|
</div>
|
|
13
11
|
<div class="content">
|
|
14
12
|
<div class="display-flex" style="padding:16px;">
|
|
@@ -41,9 +39,7 @@
|
|
|
41
39
|
<div class="render-fill">
|
|
42
40
|
<%~ includeFile('../_partials/_androidstatusbar.eta', { surface:'teal 700', dark:true }) %>
|
|
43
41
|
<div class="mdw-appbar mdw-theme" mdw-surface="teal 500" mdw-dark>
|
|
44
|
-
<div class="mdw-
|
|
45
|
-
<div class="mdw-appbar__title">aria-checked (JS)</div>
|
|
46
|
-
</div>
|
|
42
|
+
<div class="mdw-appbar__title">aria-checked (JS)</div>
|
|
47
43
|
</div>
|
|
48
44
|
<div class="content">
|
|
49
45
|
<div class="mdw-list__subheader mdw-theme" id="docs-selection-subheader1" mdw-ink="medium">Switch</div>
|
package/docs/pages/selection.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import * as List from '../../components/list/index.js';
|
|
2
2
|
import * as Selection from '../../components/selection/index.js';
|
|
3
3
|
import * as SelectionRadioGroup from '../../components/selection/radiogroup.js';
|
|
4
|
-
import { iterateArrayLike } from '../../core/dom.js';
|
|
5
4
|
|
|
6
5
|
/** @return {void} */
|
|
7
6
|
function initializeMdwComponents() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
for (const element of document.getElementsByClassName('mdw-selection')) Selection.attach(element);
|
|
8
|
+
for (const element of document.getElementsByClassName('mdw-selection__radio-group')) SelectionRadioGroup.attach(element);
|
|
9
|
+
for (const element of document.getElementsByClassName('mdw-list')) List.attach(element);
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
initializeMdwComponents();
|
package/docs/pages/snackbar.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as Snackbar from '../../components/snackbar/index.js';
|
|
2
|
-
import { iterateArrayLike } from '../../core/dom.js';
|
|
3
2
|
import { convertElementToCode } from '../_sample-utils.js';
|
|
4
3
|
|
|
5
4
|
/** @type {HTMLElement} */
|
|
@@ -112,7 +111,7 @@ function onOptionChange(event) {
|
|
|
112
111
|
case 'button':
|
|
113
112
|
if (value === 'none') {
|
|
114
113
|
if (buttonElement) {
|
|
115
|
-
buttonElement.
|
|
114
|
+
buttonElement.remove();
|
|
116
115
|
}
|
|
117
116
|
break;
|
|
118
117
|
}
|
|
@@ -149,9 +148,9 @@ function setupComponentOptions() {
|
|
|
149
148
|
parent: jsSnackbarContainer,
|
|
150
149
|
});
|
|
151
150
|
});
|
|
152
|
-
|
|
151
|
+
for (const el of document.querySelectorAll('input[name]')) {
|
|
153
152
|
el.addEventListener('change', onOptionChange);
|
|
154
|
-
}
|
|
153
|
+
}
|
|
155
154
|
}
|
|
156
155
|
|
|
157
156
|
setupComponentOptions();
|