@shortfuse/materialdesignweb 0.7.0 → 0.7.1-1
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/bin/generate-css.js +1 -2
- package/components/Badge.js +40 -3
- package/components/Body.js +16 -2
- package/components/BottomAppBar.js +25 -2
- package/components/Box.js +33 -3
- package/components/Button.js +146 -9
- package/components/Card.js +111 -3
- package/components/Checkbox.js +91 -3
- package/components/CheckboxIcon.js +92 -4
- package/components/Chip.js +38 -2
- package/components/Dialog.js +237 -3
- package/components/DialogActions.js +3 -2
- package/components/Divider.js +44 -3
- package/components/ExtendedFab.js +27 -2
- package/components/Fab.js +26 -2
- package/components/FilterChip.js +83 -2
- package/components/Headline.js +16 -2
- package/components/Icon.js +80 -4
- package/components/IconButton.js +153 -2
- package/components/Label.js +16 -2
- package/components/Layout.js +21 -3
- package/components/List.js +15 -2
- package/components/ListItem.js +229 -3
- package/components/ListOption.js +37 -3
- package/components/ListSelect.js +12 -2
- package/components/Menu.js +173 -3
- package/components/MenuItem.js +55 -2
- package/components/Nav.js +19 -2
- package/components/NavBar.js +37 -2
- package/components/NavBarItem.js +44 -2
- package/components/NavDrawer.js +34 -2
- package/components/NavDrawerItem.js +44 -2
- package/components/NavItem.js +183 -3
- package/components/NavRail.js +50 -2
- package/components/NavRailItem.js +25 -2
- package/components/Pane.js +263 -3
- package/components/Progress.js +469 -10
- package/components/Radio.js +97 -3
- package/components/RadioIcon.js +77 -5
- package/components/Ripple.js +76 -3
- package/components/SegmentedButton.js +97 -2
- package/components/SegmentedButtonGroup.js +15 -2
- package/components/Select.js +54 -2
- package/components/Shape.js +55 -18
- package/components/Slider.js +309 -3
- package/components/Snackbar.js +82 -2
- package/components/Surface.js +13 -4
- package/components/Switch.js +67 -4
- package/components/SwitchIcon.js +272 -5
- package/components/Tab.js +87 -3
- package/components/TabContent.js +21 -21
- package/components/TabList.js +131 -2
- package/components/TextArea.js +97 -3
- package/components/Title.js +16 -2
- package/components/Tooltip.js +42 -2
- package/components/TopAppBar.js +212 -3
- package/core/template.js +36 -9
- package/index.js +77 -0
- package/mixins/ControlMixin.js +65 -2
- package/mixins/DensityMixin.js +17 -3
- package/mixins/FlexableMixin.js +81 -3
- package/mixins/RippleMixin.js +15 -4
- package/mixins/ShapeMixin.js +279 -8
- package/mixins/StateMixin.js +87 -5
- package/mixins/SurfaceMixin.js +152 -3
- package/mixins/TextFieldMixin.js +661 -2
- package/mixins/ThemableMixin.js +206 -3
- package/mixins/TooltipTriggerMixin.js +30 -4
- package/mixins/TouchTargetMixin.js +29 -4
- package/package.json +3 -1
- package/theming/index.js +0 -121
- package/theming/loader.js +0 -2
- package/utils/svg.js +0 -117
- package/components/Badge.css +0 -30
- package/components/Body.css +0 -14
- package/components/BottomAppBar.css +0 -23
- package/components/Box.css +0 -31
- package/components/Button.css +0 -146
- package/components/Card.css +0 -109
- package/components/Checkbox.css +0 -77
- package/components/CheckboxIcon.css +0 -89
- package/components/Chip.css +0 -35
- package/components/Dialog.css +0 -235
- package/components/Divider.css +0 -41
- package/components/ExtendedFab.css +0 -24
- package/components/Fab.css +0 -23
- package/components/FilterChip.css +0 -80
- package/components/Headline.css +0 -14
- package/components/Icon.css +0 -76
- package/components/IconButton.css +0 -151
- package/components/Label.css +0 -14
- package/components/Layout.css +0 -19
- package/components/List.css +0 -12
- package/components/ListItem.css +0 -224
- package/components/ListOption.css +0 -34
- package/components/ListSelect.css +0 -9
- package/components/Menu.css +0 -171
- package/components/MenuItem.css +0 -53
- package/components/Nav.css +0 -17
- package/components/NavBar.css +0 -34
- package/components/NavBarItem.css +0 -41
- package/components/NavDrawer.css +0 -31
- package/components/NavDrawerItem.css +0 -42
- package/components/NavItem.css +0 -181
- package/components/NavRail.css +0 -47
- package/components/NavRailItem.css +0 -25
- package/components/Outline.css +0 -138
- package/components/Pane.css +0 -261
- package/components/Progress.css +0 -74
- package/components/ProgressCircle.css +0 -226
- package/components/ProgressLine.css +0 -155
- package/components/Radio.css +0 -83
- package/components/RadioIcon.css +0 -73
- package/components/Ripple.css +0 -74
- package/components/SegmentedButton.css +0 -94
- package/components/SegmentedButtonGroup.css +0 -12
- package/components/Select.css +0 -52
- package/components/Shape.css +0 -132
- package/components/Slider.css +0 -306
- package/components/Snackbar.css +0 -80
- package/components/Surface.css +0 -10
- package/components/Switch.css +0 -63
- package/components/SwitchIcon.css +0 -177
- package/components/SwitchIconAnimations.css +0 -89
- package/components/Tab.css +0 -85
- package/components/TabList.css +0 -129
- package/components/TextArea.css +0 -93
- package/components/Title.css +0 -14
- package/components/Tooltip.css +0 -40
- package/components/TopAppBar.css +0 -209
- package/mixins/ControlMixin.css +0 -57
- package/mixins/DensityMixin.css +0 -40
- package/mixins/FlexableMixin.css +0 -79
- package/mixins/RippleMixin.css +0 -12
- package/mixins/ShapeMixin.css +0 -135
- package/mixins/StateMixin.css +0 -82
- package/mixins/SurfaceMixin.css +0 -150
- package/mixins/TextFieldMixin.css +0 -657
- package/mixins/ThemableMixin.css +0 -204
- package/mixins/TooltipTriggerMixin.css +0 -27
- package/mixins/TouchTargetMixin.css +0 -26
package/components/Title.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import Headline from './Headline.js';
|
|
2
|
-
import styles from './Title.css' assert { type: 'css' };
|
|
3
2
|
|
|
4
3
|
export default Headline
|
|
5
4
|
.extend()
|
|
6
|
-
.css(styles)
|
|
7
5
|
.expressions({
|
|
8
6
|
computeAriaLevel({ ariaLevel, size }) {
|
|
9
7
|
if (ariaLevel) return ariaLevel;
|
|
@@ -12,4 +10,20 @@ export default Headline
|
|
|
12
10
|
return '4';
|
|
13
11
|
},
|
|
14
12
|
})
|
|
13
|
+
.css`
|
|
14
|
+
:host {
|
|
15
|
+
font: var(--mdw-typescale__title-large__font);
|
|
16
|
+
letter-spacing: var(--mdw-typescale__title-large__letter-spacing);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
:host([size="medium"]) {
|
|
20
|
+
font: var(--mdw-typescale__title-medium__font);
|
|
21
|
+
letter-spacing: var(--mdw-typescale__title-medium__letter-spacing);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
:host([size="small"]) {
|
|
25
|
+
font: var(--mdw-typescale__title-small__font);
|
|
26
|
+
letter-spacing: var(--mdw-typescale__title-small__letter-spacing);
|
|
27
|
+
}
|
|
28
|
+
`
|
|
15
29
|
.autoRegister('mdw-title');
|
package/components/Tooltip.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import AriaReflectorMixin from '../mixins/AriaReflectorMixin.js';
|
|
2
2
|
|
|
3
3
|
import Surface from './Surface.js';
|
|
4
|
-
import styles from './Tooltip.css' assert { type: 'css' };
|
|
5
4
|
|
|
6
5
|
export default Surface
|
|
7
6
|
.mixin(AriaReflectorMixin)
|
|
@@ -9,7 +8,6 @@ export default Surface
|
|
|
9
8
|
.set({
|
|
10
9
|
_ariaRole: 'tooltip',
|
|
11
10
|
})
|
|
12
|
-
.css(styles)
|
|
13
11
|
.observe({
|
|
14
12
|
open: {
|
|
15
13
|
type: 'boolean',
|
|
@@ -19,4 +17,46 @@ export default Surface
|
|
|
19
17
|
},
|
|
20
18
|
touch: 'boolean',
|
|
21
19
|
})
|
|
20
|
+
.css`
|
|
21
|
+
/* https://m2.material.io/components/tooltips */
|
|
22
|
+
|
|
23
|
+
:host {
|
|
24
|
+
--mdw-shape__size: var(--mdw-shape__extra-small);
|
|
25
|
+
--mdw-ink: var(--mdw-color__on-surface-variant);
|
|
26
|
+
--mdw-shape__bg: rgb(var(--mdw-color__surface-variant));
|
|
27
|
+
display: block;
|
|
28
|
+
vertical-align: middle;
|
|
29
|
+
|
|
30
|
+
box-sizing: border-box;
|
|
31
|
+
/* stylelint-disable-next-line declaration-property-value-disallowed-list */
|
|
32
|
+
margin-inline: auto;
|
|
33
|
+
padding-block: 4px;
|
|
34
|
+
padding-inline: 8px;
|
|
35
|
+
|
|
36
|
+
pointer-events: none;
|
|
37
|
+
|
|
38
|
+
opacity: 0;
|
|
39
|
+
transform: scale(0);
|
|
40
|
+
z-index: 24;
|
|
41
|
+
|
|
42
|
+
font: var(--mdw-typescale__label-medium__font);
|
|
43
|
+
letter-spacing: var(--mdw-typescale__label-medium__letter-spacing);
|
|
44
|
+
|
|
45
|
+
transition: transform 200ms, opacity 200ms;
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
:host([touch]) {
|
|
50
|
+
padding-block: 6px;
|
|
51
|
+
padding-inline: 16px;
|
|
52
|
+
|
|
53
|
+
font: var(--mdw-typescale__label-large__font);
|
|
54
|
+
letter-spacing: var(--mdw-typescale__label-large__letter-spacing);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
:host([open]) {
|
|
58
|
+
opacity: 1;
|
|
59
|
+
transform: scale(1);
|
|
60
|
+
}
|
|
61
|
+
`
|
|
22
62
|
.autoRegister('mdw-tooltip');
|
package/components/TopAppBar.js
CHANGED
|
@@ -6,8 +6,6 @@ import ScrollListenerMixin from '../mixins/ScrollListenerMixin.js';
|
|
|
6
6
|
import SurfaceMixin from '../mixins/SurfaceMixin.js';
|
|
7
7
|
import ThemableMixin from '../mixins/ThemableMixin.js';
|
|
8
8
|
|
|
9
|
-
import styles from './TopAppBar.css' assert { type: 'css' };
|
|
10
|
-
|
|
11
9
|
export default CustomElement
|
|
12
10
|
.mixin(ThemableMixin)
|
|
13
11
|
.mixin(SurfaceMixin) // TopAppBars are non-shaped surfaces
|
|
@@ -90,7 +88,6 @@ export default CustomElement
|
|
|
90
88
|
},
|
|
91
89
|
},
|
|
92
90
|
})
|
|
93
|
-
.css(styles)
|
|
94
91
|
.html/* html */`
|
|
95
92
|
<slot id=leading name=leading on-slotchange={refreshTabIndexes}></slot>
|
|
96
93
|
<div id=headline ink={ink} color={color} type-style={typeStyle} on-slotchange={refreshTabIndexes}>
|
|
@@ -198,4 +195,216 @@ export default CustomElement
|
|
|
198
195
|
this.clearScrollListener();
|
|
199
196
|
},
|
|
200
197
|
})
|
|
198
|
+
.css`
|
|
199
|
+
/* https://m3.material.io/components/bottom-app-bar/specs */
|
|
200
|
+
|
|
201
|
+
:host {
|
|
202
|
+
--mdw-bg: var(--mdw-color__surface);
|
|
203
|
+
--mdw-ink: var(--mdw-color__on-surface);
|
|
204
|
+
--mdw-surface__tint: var(--mdw-surface__tint__0);
|
|
205
|
+
--mdw-surface__tint__raised: var(--mdw-surface__tint__2);
|
|
206
|
+
display: contents;
|
|
207
|
+
|
|
208
|
+
z-index:2;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
#surface {
|
|
212
|
+
position: sticky;
|
|
213
|
+
inset-block-start: 0;
|
|
214
|
+
|
|
215
|
+
display: grid;
|
|
216
|
+
|
|
217
|
+
align-items: center;
|
|
218
|
+
gap: 12px;
|
|
219
|
+
grid-auto-flow: row;
|
|
220
|
+
grid-template-rows: minmax(64px,min-content);
|
|
221
|
+
grid-template-columns: minmax(auto,1fr) minmax(0,auto) minmax(auto,1fr);
|
|
222
|
+
overflow-x: clip; /* Clip oversized touch targets to avoid scroll-bars */
|
|
223
|
+
overflow-y: visible;
|
|
224
|
+
|
|
225
|
+
box-sizing: border-box;
|
|
226
|
+
inline-size: 100%;
|
|
227
|
+
max-inline-size: 100%;
|
|
228
|
+
|
|
229
|
+
/* 16px from icon */
|
|
230
|
+
/* inset = (button.width / 2) - (icon.width / 2) */
|
|
231
|
+
/* paddingInline = 16px - inset */
|
|
232
|
+
/* paddingInlineStart = 16px - ((48px / 2) - (24px / 2)) */
|
|
233
|
+
/* paddingInlineEnd = 16px - ((48px / 2) - (30px / 2)) */
|
|
234
|
+
|
|
235
|
+
padding-inline: 4px;
|
|
236
|
+
|
|
237
|
+
pointer-events: auto;
|
|
238
|
+
|
|
239
|
+
filter: none; /* Never receive shadow */
|
|
240
|
+
|
|
241
|
+
z-index: 5;
|
|
242
|
+
/* inset-inline: 0; */
|
|
243
|
+
|
|
244
|
+
background-color: rgb(var(--mdw-bg));
|
|
245
|
+
color: rgb(var(--mdw-ink));
|
|
246
|
+
|
|
247
|
+
transition: grid-template-columns 100ms;
|
|
248
|
+
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
#surface-tint {
|
|
252
|
+
position: 0;
|
|
253
|
+
|
|
254
|
+
z-index: 1;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
#leading {
|
|
258
|
+
justify-self: flex-start;
|
|
259
|
+
|
|
260
|
+
display: flex;
|
|
261
|
+
align-items: center;
|
|
262
|
+
|
|
263
|
+
grid-column: 1;
|
|
264
|
+
grid-row: 1;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
#headline {
|
|
268
|
+
display: inline-block;
|
|
269
|
+
|
|
270
|
+
overflow: clip hidden;
|
|
271
|
+
|
|
272
|
+
max-inline-size: 100%;
|
|
273
|
+
|
|
274
|
+
grid-column: 2;
|
|
275
|
+
grid-row: 1;
|
|
276
|
+
|
|
277
|
+
font: var(--mdw-typescale__title-large__font);
|
|
278
|
+
letter-spacing: var(--mdw-typescale__title-large__letter-spacing);
|
|
279
|
+
|
|
280
|
+
text-overflow: ellipsis;
|
|
281
|
+
text-transform: none;
|
|
282
|
+
white-space: nowrap;
|
|
283
|
+
word-break: break-word;
|
|
284
|
+
|
|
285
|
+
transition-duration: 200ms;
|
|
286
|
+
transition-property: transform, opacity, color, background-color;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
#trailing {
|
|
290
|
+
justify-self: flex-end;
|
|
291
|
+
|
|
292
|
+
display: flex;
|
|
293
|
+
align-items: center;
|
|
294
|
+
gap: 8px;
|
|
295
|
+
justify-content: flex-end;
|
|
296
|
+
|
|
297
|
+
grid-column: 3;
|
|
298
|
+
grid-row: 1;
|
|
299
|
+
|
|
300
|
+
color: var(--mdw-color__on-surface-variant);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/* Medium */
|
|
304
|
+
#companion {
|
|
305
|
+
position: relative;
|
|
306
|
+
|
|
307
|
+
display: flex;
|
|
308
|
+
align-items: flex-end;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Total Height = 112px
|
|
312
|
+
* Bar = 12 + 40 + 12 (64)
|
|
313
|
+
* Companion = 112px - 64
|
|
314
|
+
* Companion Bottom = 20px
|
|
315
|
+
* Companion = 28px
|
|
316
|
+
* Shift up = 1lh - 28px
|
|
317
|
+
*/
|
|
318
|
+
/* stylelint-disable-next-line declaration-property-value-disallowed-list */
|
|
319
|
+
margin-block-start: calc(28px - var(--mdw-typescale__headline-small__line-height));
|
|
320
|
+
padding-block-end: 20px;
|
|
321
|
+
|
|
322
|
+
padding-inline: 16px;
|
|
323
|
+
|
|
324
|
+
background-color: rgb(var(--mdw-bg));
|
|
325
|
+
box-shadow: none;
|
|
326
|
+
|
|
327
|
+
font: var(--mdw-typescale__headline-small__font);
|
|
328
|
+
letter-spacing: var(--mdw-typescale__headline-small__letter-spacing);
|
|
329
|
+
white-space: nowrap;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
#companion[size="large"] {
|
|
333
|
+
/**
|
|
334
|
+
* Total Height = 152px
|
|
335
|
+
* Bar = 12 + 40 + 12 (64)
|
|
336
|
+
* Companion = 152px - 64
|
|
337
|
+
* Companion Bottom = 20px
|
|
338
|
+
* Companion = 68px
|
|
339
|
+
* Shift up = 2lh - 68px
|
|
340
|
+
*/
|
|
341
|
+
|
|
342
|
+
min-block-size: calc(2 * var(--mdw-typescale__headline-medium__line-height));
|
|
343
|
+
/* stylelint-disable-next-line declaration-property-value-disallowed-list */
|
|
344
|
+
margin-block-start: calc(68px - (2 * var(--mdw-typescale__headline-medium__line-height)));
|
|
345
|
+
|
|
346
|
+
font: var(--mdw-typescale__headline-medium__font);
|
|
347
|
+
letter-spacing: var(--mdw-typescale__headline-medium__letter-spacing);
|
|
348
|
+
white-space: normal;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
@supports(width: 1lh) {
|
|
352
|
+
#companion {
|
|
353
|
+
/* stylelint-disable-next-line declaration-property-value-disallowed-list */
|
|
354
|
+
margin-block-start: calc(28px - 1lh);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
#companion[size="large"] {
|
|
358
|
+
min-block-size: 2lh;
|
|
359
|
+
/* stylelint-disable-next-line declaration-property-value-disallowed-list */
|
|
360
|
+
margin-block-start: calc(68px - 2lh);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
#companion-slot {
|
|
365
|
+
display: block;
|
|
366
|
+
overflow-x: clip;
|
|
367
|
+
overflow-y: hidden;
|
|
368
|
+
|
|
369
|
+
text-overflow: ellipsis;
|
|
370
|
+
text-transform: none;
|
|
371
|
+
word-break: break-word;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
#companion-slot[size="large"] {
|
|
375
|
+
max-block-size: calc(2 * var(--mdw-typescale__headline-medium__line-height));
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
@supports(-webkit-line-clamp: 2) {
|
|
379
|
+
#companion-slot[size="large"] {
|
|
380
|
+
display: -webkit-box;
|
|
381
|
+
-webkit-box-orient: vertical;
|
|
382
|
+
-webkit-line-clamp: 2;
|
|
383
|
+
|
|
384
|
+
max-block-size: none;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
#surface[hide-on-scroll] {
|
|
389
|
+
position: relative;
|
|
390
|
+
|
|
391
|
+
inset-block-start: 0;
|
|
392
|
+
|
|
393
|
+
transform: translateY(0);
|
|
394
|
+
|
|
395
|
+
will-change: transform, position;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
#surface[size="small"] {
|
|
399
|
+
gap: 4px;
|
|
400
|
+
grid-template-columns: auto 1fr auto;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
#headline:is([size="medium"],[size="large"]) {
|
|
404
|
+
opacity: 0;
|
|
405
|
+
|
|
406
|
+
will-change: opacity;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
`
|
|
201
410
|
.autoRegister('mdw-top-app-bar');
|
package/core/template.js
CHANGED
|
@@ -49,6 +49,12 @@ export function addInlineFunction(fn) {
|
|
|
49
49
|
return `{${internalName}}`;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
/** @type {Map<string, CSSStyleSheet>} */
|
|
53
|
+
const cssStyleSheetsCache = new Map();
|
|
54
|
+
|
|
55
|
+
/** @type {Map<string, HTMLStyleElement>} */
|
|
56
|
+
const styleElementCache = new Map();
|
|
57
|
+
|
|
52
58
|
/**
|
|
53
59
|
* @param {TemplateStringsArray} array
|
|
54
60
|
* @param {...(string)} substitutions
|
|
@@ -56,29 +62,42 @@ export function addInlineFunction(fn) {
|
|
|
56
62
|
*/
|
|
57
63
|
export function css(array, ...substitutions) {
|
|
58
64
|
const content = String.raw({ raw: array }, ...substitutions);
|
|
65
|
+
|
|
59
66
|
if (_cssStyleSheetConstructable == null) {
|
|
60
67
|
try {
|
|
61
68
|
const sheet = new CSSStyleSheet();
|
|
62
69
|
_cssStyleSheetConstructable = true;
|
|
63
70
|
sheet.replaceSync(content);
|
|
71
|
+
cssStyleSheetsCache.set(content, sheet);
|
|
64
72
|
return sheet;
|
|
65
73
|
} catch {
|
|
66
74
|
_cssStyleSheetConstructable = false;
|
|
67
75
|
}
|
|
68
76
|
}
|
|
77
|
+
|
|
69
78
|
if (_cssStyleSheetConstructable) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
79
|
+
let sheet = cssStyleSheetsCache.get(content);
|
|
80
|
+
if (!sheet) {
|
|
81
|
+
sheet = new CSSStyleSheet();
|
|
82
|
+
_cssStyleSheetConstructable = true;
|
|
83
|
+
sheet.replaceSync(content);
|
|
84
|
+
cssStyleSheetsCache.set(content, sheet);
|
|
85
|
+
}
|
|
73
86
|
return sheet;
|
|
74
87
|
}
|
|
75
88
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
89
|
+
let style = styleElementCache.get(content);
|
|
90
|
+
if (!style) {
|
|
91
|
+
_inactiveDocument ??= document.implementation.createHTMLDocument();
|
|
92
|
+
style = _inactiveDocument.createElement('style');
|
|
93
|
+
style.textContent = content;
|
|
94
|
+
styleElementCache.set(content, style);
|
|
95
|
+
}
|
|
96
|
+
return /** @type {HTMLStyleElement} */ (style.cloneNode(true));
|
|
80
97
|
}
|
|
81
98
|
|
|
99
|
+
/** @type {Map<string, DocumentFragment>} */
|
|
100
|
+
const fragmentCache = new Map();
|
|
82
101
|
/**
|
|
83
102
|
* @template T1
|
|
84
103
|
* @template T2
|
|
@@ -109,13 +128,21 @@ export function html(strings, ...substitutions) {
|
|
|
109
128
|
}
|
|
110
129
|
});
|
|
111
130
|
const compiledString = String.raw({ raw: strings }, ...replacements);
|
|
112
|
-
|
|
131
|
+
|
|
113
132
|
if (tempSlots) {
|
|
133
|
+
const fragment = generateFragment(compiledString);
|
|
114
134
|
for (const [id, element] of tempSlots) {
|
|
115
135
|
const slot = fragment.getElementById(id);
|
|
116
136
|
slot.replaceWith(element);
|
|
117
137
|
}
|
|
138
|
+
return fragment;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
let fragment = fragmentCache.get(compiledString);
|
|
142
|
+
if (!fragment) {
|
|
143
|
+
fragment = generateFragment(compiledString);
|
|
144
|
+
fragmentCache.set(compiledString, fragment);
|
|
118
145
|
}
|
|
119
146
|
|
|
120
|
-
return fragment;
|
|
147
|
+
return /** @type {DocumentFragment} */ (fragment.cloneNode(true));
|
|
121
148
|
}
|
package/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export { default as Badge } from './components/Badge.js';
|
|
2
|
+
export { default as Body } from './components/Body.js';
|
|
3
|
+
export { default as BottomAppBar } from './components/BottomAppBar.js';
|
|
4
|
+
export { default as Box } from './components/Box.js';
|
|
5
|
+
export { default as Button } from './components/Button.js';
|
|
6
|
+
export { default as Card } from './components/Card.js';
|
|
7
|
+
export { default as Checkbox } from './components/Checkbox.js';
|
|
8
|
+
export { default as Chip } from './components/Chip.js';
|
|
9
|
+
export { default as Dialog } from './components/Dialog.js';
|
|
10
|
+
export { default as Divider } from './components/Divider.js';
|
|
11
|
+
export { default as ExtendedFab } from './components/ExtendedFab.js';
|
|
12
|
+
export { default as Fab } from './components/Fab.js';
|
|
13
|
+
export { default as FilterChip } from './components/FilterChip.js';
|
|
14
|
+
export { default as Headline } from './components/Headline.js';
|
|
15
|
+
export { default as Icon } from './components/Icon.js';
|
|
16
|
+
export { default as IconButton } from './components/IconButton.js';
|
|
17
|
+
export { default as Input } from './components/Input.js';
|
|
18
|
+
export { default as Label } from './components/Label.js';
|
|
19
|
+
export { default as Layout } from './components/Layout.js';
|
|
20
|
+
export { default as List } from './components/List.js';
|
|
21
|
+
export { default as ListItem } from './components/ListItem.js';
|
|
22
|
+
export { default as ListOption } from './components/ListOption.js';
|
|
23
|
+
export { default as ListSelect } from './components/ListSelect.js';
|
|
24
|
+
export { default as Menu } from './components/Menu.js';
|
|
25
|
+
export { default as MenuItem } from './components/MenuItem.js';
|
|
26
|
+
export { default as NavBar } from './components/NavBar.js';
|
|
27
|
+
export { default as NavBarItem } from './components/NavBarItem.js';
|
|
28
|
+
export { default as NavDrawer } from './components/NavDrawer.js';
|
|
29
|
+
export { default as NavDrawerItem } from './components/NavDrawerItem.js';
|
|
30
|
+
export { default as NavItem } from './components/NavItem.js';
|
|
31
|
+
export { default as NavRail } from './components/NavRail.js';
|
|
32
|
+
export { default as NavRailItem } from './components/NavRailItem.js';
|
|
33
|
+
export { default as Pane } from './components/Pane.js';
|
|
34
|
+
export { default as Progress } from './components/Progress.js';
|
|
35
|
+
export { default as Radio } from './components/Radio.js';
|
|
36
|
+
export { default as SegmentedButton } from './components/SegmentedButton.js';
|
|
37
|
+
export { default as SegmentedButtonGroup } from './components/SegmentedButtonGroup.js';
|
|
38
|
+
export { default as Select } from './components/Select.js';
|
|
39
|
+
export { default as Slider } from './components/Slider.js';
|
|
40
|
+
export { default as Snackbar } from './components/Snackbar.js';
|
|
41
|
+
export { default as Surface } from './components/Surface.js';
|
|
42
|
+
export { default as Switch } from './components/Switch.js';
|
|
43
|
+
export { default as Tab } from './components/Tab.js';
|
|
44
|
+
export { default as TabContent } from './components/TabContent.js';
|
|
45
|
+
export { default as TabList } from './components/TabList.js';
|
|
46
|
+
export { default as TabPanel } from './components/TabPanel.js';
|
|
47
|
+
export { default as TextArea } from './components/TextArea.js';
|
|
48
|
+
export { default as Title } from './components/Title.js';
|
|
49
|
+
export { default as Tooltip } from './components/Tooltip.js';
|
|
50
|
+
export { default as TopAppBar } from './components/TopAppBar.js';
|
|
51
|
+
|
|
52
|
+
export { default as CustomElement } from './core/CustomElement.js';
|
|
53
|
+
export { default as Composition } from './core/Composition.js';
|
|
54
|
+
|
|
55
|
+
export { default as InputMixin } from './mixins/InputMixin.js';
|
|
56
|
+
export { default as AriaReflectorMixin } from './mixins/AriaReflectorMixin.js';
|
|
57
|
+
export { default as ControlMixin } from './mixins/ControlMixin.js';
|
|
58
|
+
export { default as RTLObserverMixin } from './mixins/RTLObserverMixin.js';
|
|
59
|
+
export { default as TouchTargetMixin } from './mixins/TouchTargetMixin.js';
|
|
60
|
+
export { default as ShapeMixin } from './mixins/ShapeMixin.js';
|
|
61
|
+
export { default as RippleMixin } from './mixins/RippleMixin.js';
|
|
62
|
+
export { default as FormAssociatedMixin } from './mixins/FormAssociatedMixin.js';
|
|
63
|
+
export { default as KeyboardNavMixin } from './mixins/KeyboardNavMixin.js';
|
|
64
|
+
export { default as ResizeObserverMixin } from './mixins/ResizeObserverMixin.js';
|
|
65
|
+
export { default as DensityMixin } from './mixins/DensityMixin.js';
|
|
66
|
+
export { default as TooltipTriggerMixin } from './mixins/TooltipTriggerMixin.js';
|
|
67
|
+
export { default as ScrollListenerMixin } from './mixins/ScrollListenerMixin.js';
|
|
68
|
+
export { default as FlexableMixin } from './mixins/FlexableMixin.js';
|
|
69
|
+
export { default as ThemableMixin } from './mixins/ThemableMixin.js';
|
|
70
|
+
export { default as AriaToolbarMixin } from './mixins/AriaToolbarMixin.js';
|
|
71
|
+
export { default as TextFieldMixin } from './mixins/TextFieldMixin.js';
|
|
72
|
+
export { default as SurfaceMixin } from './mixins/SurfaceMixin.js';
|
|
73
|
+
export { default as StateMixin } from './mixins/StateMixin.js';
|
|
74
|
+
|
|
75
|
+
export * as themeLoader from './theming/loader.js';
|
|
76
|
+
|
|
77
|
+
export * as theming from './theming/index.js';
|
package/mixins/ControlMixin.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* https://html.spec.whatwg.org/multipage/form-control-infrastructure.html */
|
|
2
2
|
|
|
3
|
-
import styles from './ControlMixin.css' assert { type: 'css' };
|
|
4
3
|
import FormAssociatedMixin from './FormAssociatedMixin.js';
|
|
5
4
|
|
|
6
5
|
/** @typedef {import('../core/CustomElement.js').default} CustomElement */
|
|
@@ -36,6 +35,71 @@ export default function ControlMixin(Base) {
|
|
|
36
35
|
/** @type {string[]} */
|
|
37
36
|
static valueChangingContentAttributes = [];
|
|
38
37
|
|
|
38
|
+
static {
|
|
39
|
+
// eslint-disable-next-line no-unused-expressions
|
|
40
|
+
this.css`
|
|
41
|
+
|
|
42
|
+
:host {
|
|
43
|
+
display: inline-flex;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Remove Firefox inner */
|
|
47
|
+
:host(::-moz-focus-inner) {
|
|
48
|
+
border: 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
#label {
|
|
52
|
+
display: contents;
|
|
53
|
+
|
|
54
|
+
pointer-events: none;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#control {
|
|
58
|
+
/* Control is the touch target */
|
|
59
|
+
/* Firefox requires at least 1px "visible" for screen reading */
|
|
60
|
+
/* Safari will not allow interaction with 0 opacity */
|
|
61
|
+
/* Chrome will not focus with visibility:hidden */
|
|
62
|
+
|
|
63
|
+
position: absolute;
|
|
64
|
+
inset: 50%;
|
|
65
|
+
/* --mdw-device-pixel-ratio: 1; */
|
|
66
|
+
|
|
67
|
+
block-size: 100%;
|
|
68
|
+
min-block-size: 48px;
|
|
69
|
+
inline-size:100%;
|
|
70
|
+
min-inline-size: 48px;
|
|
71
|
+
margin: 0;
|
|
72
|
+
border: 0;
|
|
73
|
+
padding: 0;
|
|
74
|
+
|
|
75
|
+
-webkit-appearance: none;
|
|
76
|
+
-moz-appearance: none;
|
|
77
|
+
appearance: none;
|
|
78
|
+
|
|
79
|
+
cursor: auto;
|
|
80
|
+
outline: none;
|
|
81
|
+
|
|
82
|
+
pointer-events: auto;
|
|
83
|
+
|
|
84
|
+
transform: translateX(-50%) translateY(-50%);
|
|
85
|
+
|
|
86
|
+
/* Safari and Chrome will emit two click events if not at top of stack */
|
|
87
|
+
/* Allows up to 3 other layers (eg: ripple, outline) */
|
|
88
|
+
z-index: 4;
|
|
89
|
+
|
|
90
|
+
background-color: transparent;
|
|
91
|
+
|
|
92
|
+
border-radius: 0;
|
|
93
|
+
color: transparent;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
#control::-moz-focus-inner {
|
|
97
|
+
border: 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
`;
|
|
101
|
+
}
|
|
102
|
+
|
|
39
103
|
/** @param {any[]} args */
|
|
40
104
|
constructor(...args) {
|
|
41
105
|
super(...args);
|
|
@@ -89,7 +153,6 @@ export default function ControlMixin(Base) {
|
|
|
89
153
|
}
|
|
90
154
|
|
|
91
155
|
static {
|
|
92
|
-
this.css(styles);
|
|
93
156
|
this.on({
|
|
94
157
|
// Wait until controlTagName is settled before templating
|
|
95
158
|
composed({ template, html }) {
|
package/mixins/DensityMixin.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import styles from './DensityMixin.css' assert {type: 'css'};
|
|
2
|
-
|
|
3
1
|
/** @param {typeof import('../core/CustomElement.js').default} Base */
|
|
4
2
|
export default function DensityMixin(Base) {
|
|
5
3
|
return Base
|
|
@@ -7,5 +5,21 @@ export default function DensityMixin(Base) {
|
|
|
7
5
|
.observe({
|
|
8
6
|
density: 'integer',
|
|
9
7
|
})
|
|
10
|
-
.css
|
|
8
|
+
.css`
|
|
9
|
+
:host {
|
|
10
|
+
--mdw-density: var(--mdw-density__default, 0);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* Reset */
|
|
14
|
+
:host([density]) { --mdw-density: 0; }
|
|
15
|
+
|
|
16
|
+
:host([density="-1"]) { --mdw-density: -1; }
|
|
17
|
+
:host([density="-2"]) { --mdw-density: -2; }
|
|
18
|
+
:host([density="-3"]) { --mdw-density: -2; }
|
|
19
|
+
:host([density="-4"]) { --mdw-density: -4; }
|
|
20
|
+
:host([density="1"]) { --mdw-density: 1; }
|
|
21
|
+
:host([density="2"]) { --mdw-density: 2; }
|
|
22
|
+
:host([density="3"]) { --mdw-density: 3; }
|
|
23
|
+
:host([density="4"]) { --mdw-density: 3; }
|
|
24
|
+
`;
|
|
11
25
|
}
|
package/mixins/FlexableMixin.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import styles from './FlexableMixin.css' assert {type: 'css'};
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* @param {typeof import('../core/CustomElement.js').default} Base
|
|
5
3
|
*/
|
|
@@ -28,5 +26,85 @@ export default function FlexableMixin(Base) {
|
|
|
28
26
|
gap: 'float',
|
|
29
27
|
padding: 'float',
|
|
30
28
|
})
|
|
31
|
-
.css
|
|
29
|
+
.css`
|
|
30
|
+
/* https://css-tricks.com/snippets/css/a-guide-to-flexbox/ */
|
|
31
|
+
|
|
32
|
+
:host{
|
|
33
|
+
box-sizing: border-box;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
:host([flex]) {
|
|
37
|
+
display:flex;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
:host([flex="column"]) {
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
:host(:where([flex][y="start"], [flex="column"][x="start"])) {
|
|
45
|
+
align-items: flex-start;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
:host(:where([flex][y="end"], [flex="column"][x="end"])) {
|
|
49
|
+
align-items: flex-end;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
:host(:where([flex][y="center"], [flex="column"][x="center"])) {
|
|
53
|
+
align-items: center;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
:host(:where([flex][y="between"], [flex="column"][x="between"])) {
|
|
57
|
+
align-items: space-between;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
:host(:where([flex][y="around"], [flex="column"][x="around"])) {
|
|
61
|
+
align-items: space-around;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
:host(:where([flex][y="stretch"], [flex="column"][x="stretch"])) {
|
|
65
|
+
align-items: stretch;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
:host(:where([flex][x="start"], [flex="column"][y="start"])) {
|
|
69
|
+
justify-content: flex-start;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
:host(:where([flex][x="end"], [flex="column"][y="end"])) {
|
|
73
|
+
justify-content: flex-end;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
:host(:where([flex][x="center"], [flex="column"][y="center"])) {
|
|
77
|
+
justify-content: center;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
:host(:where([flex][x="between"], [flex="column"][y="between"])) {
|
|
81
|
+
justify-content: space-between;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
:host(:where([flex][x="stretch"], [flex="column"][y="stretch"])) {
|
|
85
|
+
justify-content: space-around;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
:host([wrap]) {
|
|
89
|
+
flex-wrap: wrap;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
:host([wrap="reverse"]) {
|
|
93
|
+
flex-wrap: wrap-reverse;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
:host([gap="4"]) {gap: 4px;}
|
|
97
|
+
:host([gap="8"]) {gap: 8px;}
|
|
98
|
+
:host([gap="12"]) {gap: 12px;}
|
|
99
|
+
:host([gap="16"]) {gap: 16px;}
|
|
100
|
+
:host([gap="20"]) {gap: 20px;}
|
|
101
|
+
:host([gap="24"]) {gap: 24px;}
|
|
102
|
+
|
|
103
|
+
:host([padding="4"]) {padding: 4px;}
|
|
104
|
+
:host([padding="8"]) {padding: 8px;}
|
|
105
|
+
:host([padding="12"]) {padding: 12px;}
|
|
106
|
+
:host([padding="16"]) {padding: 16px;}
|
|
107
|
+
:host([padding="20"]) {padding: 20px;}
|
|
108
|
+
:host([padding="24"]) {padding: 24px;}
|
|
109
|
+
`;
|
|
32
110
|
}
|