@shortfuse/materialdesignweb 0.7.1-0 → 0.7.1-2
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/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 -3
- package/mixins/ThemableMixin.js +206 -3
- package/mixins/TooltipTriggerMixin.js +30 -4
- package/mixins/TouchTargetMixin.js +29 -4
- package/package.json +2 -1
- package/theming/loader.js +0 -2
- package/components/Badge.css +0 -38
- package/components/Body.css +0 -14
- package/components/BottomAppBar.css +0 -23
- package/components/Box.css +0 -31
- package/components/Button.css +0 -147
- package/components/Card.css +0 -109
- package/components/Checkbox.css +0 -89
- package/components/CheckboxIcon.css +0 -90
- 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 -150
- 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 -75
- package/components/ProgressCircle.css +0 -226
- package/components/ProgressLine.css +0 -155
- package/components/Radio.css +0 -95
- 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 -307
- package/components/Snackbar.css +0 -80
- package/components/Surface.css +0 -10
- package/components/Switch.css +0 -64
- package/components/SwitchIcon.css +0 -178
- 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/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
|
}
|
package/mixins/RippleMixin.js
CHANGED
|
@@ -2,15 +2,12 @@ import Ripple from '../components/Ripple.js';
|
|
|
2
2
|
|
|
3
3
|
/** @typedef {import('../components/Ripple.js').default} Ripple */
|
|
4
4
|
|
|
5
|
-
import styles from './RippleMixin.css' assert { type: 'css' };
|
|
6
|
-
|
|
7
5
|
/**
|
|
8
6
|
* @param {ReturnType<import('./StateMixin.js').default>} Base
|
|
9
7
|
*/
|
|
10
8
|
export default function RippleMixin(Base) {
|
|
11
9
|
return Base
|
|
12
10
|
.extend()
|
|
13
|
-
.css(styles)
|
|
14
11
|
.set({
|
|
15
12
|
/** @type {WeakRef<InstanceType<Ripple>>} */
|
|
16
13
|
_lastRippleWeakRef: null,
|
|
@@ -111,5 +108,19 @@ export default function RippleMixin(Base) {
|
|
|
111
108
|
if (ripple.hadRippleHeld) return;
|
|
112
109
|
ripple.holdRipple = true;
|
|
113
110
|
},
|
|
114
|
-
})
|
|
111
|
+
})
|
|
112
|
+
.css`
|
|
113
|
+
:host {
|
|
114
|
+
--mdw-state__pressed-opacity: 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
#ripple-container {
|
|
118
|
+
position: absolute;
|
|
119
|
+
inset: 0;
|
|
120
|
+
|
|
121
|
+
overflow: hidden;
|
|
122
|
+
|
|
123
|
+
pointer-events: none;
|
|
124
|
+
}
|
|
125
|
+
`;
|
|
115
126
|
}
|