@shortfuse/materialdesignweb 0.7.6 → 0.8.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/README.md +57 -68
- package/components/Badge.js +2 -2
- package/components/BottomAppBar.js +3 -5
- package/components/Box.js +33 -3
- package/components/Button.js +48 -21
- package/components/Button.md +9 -9
- package/components/Card.js +9 -16
- package/components/Checkbox.js +45 -36
- package/components/CheckboxIcon.js +2 -2
- package/components/Chip.js +1 -1
- package/components/Dialog.js +228 -359
- package/components/DialogActions.js +2 -2
- package/components/Divider.js +3 -3
- package/components/ExtendedFab.js +4 -8
- package/components/Fab.js +1 -2
- package/components/FilterChip.js +4 -4
- package/components/Headline.js +1 -1
- package/components/Icon.js +8 -8
- package/components/IconButton.js +9 -14
- package/components/Input.js +273 -1
- package/components/Layout.js +485 -16
- package/components/List.js +6 -4
- package/components/ListItem.js +12 -12
- package/components/ListOption.js +21 -5
- package/components/Listbox.js +239 -0
- package/components/Menu.js +77 -526
- package/components/MenuItem.js +12 -14
- package/components/Nav.js +0 -2
- package/components/NavBar.js +8 -79
- package/components/NavDrawer.js +12 -11
- package/components/NavDrawerItem.js +2 -1
- package/components/NavItem.js +18 -8
- package/components/NavRail.js +15 -7
- package/components/NavRailItem.js +3 -1
- package/components/Popup.js +20 -0
- package/components/Progress.js +24 -23
- package/components/Radio.js +42 -35
- package/components/RadioIcon.js +3 -3
- package/components/Ripple.js +2 -3
- package/components/Search.js +85 -0
- package/components/SegmentedButton.js +1 -10
- package/components/SegmentedButtonGroup.js +16 -10
- package/components/Select.js +4 -4
- package/components/Shape.js +1 -1
- package/components/Slider.js +43 -50
- package/components/Snackbar.js +4 -5
- package/components/Surface.js +3 -3
- package/components/Switch.js +55 -21
- package/components/SwitchIcon.js +10 -8
- package/components/Tab.js +11 -9
- package/components/TabContent.js +4 -3
- package/components/TabList.js +2 -2
- package/components/TabPanel.js +11 -8
- package/components/TextArea.js +38 -35
- package/components/Tooltip.js +2 -2
- package/components/TopAppBar.js +65 -147
- package/core/Composition.js +985 -628
- package/core/CompositionAdapter.js +315 -0
- package/core/CustomElement.js +153 -90
- package/core/DomAdapter.js +586 -0
- package/core/ICustomElement.d.ts +2 -2
- package/core/css.js +8 -7
- package/core/customTypes.js +53 -31
- package/{utils → core}/jsonMergePatch.js +36 -14
- package/core/observe.js +111 -57
- package/core/optimizations.js +23 -0
- package/core/template.js +17 -11
- package/core/test.js +126 -0
- package/core/typings.d.ts +11 -5
- package/core/uid.js +13 -0
- package/dist/index.min.js +83 -152
- package/dist/index.min.js.map +4 -4
- package/dist/meta.json +1 -1
- package/mixins/AriaReflectorMixin.js +1 -2
- package/mixins/AriaToolbarMixin.js +2 -3
- package/mixins/ControlMixin.js +25 -17
- package/mixins/DensityMixin.js +0 -1
- package/mixins/FlexableMixin.js +1 -2
- package/mixins/FormAssociatedMixin.js +13 -10
- package/mixins/InputMixin.js +2 -9
- package/mixins/KeyboardNavMixin.js +14 -1
- package/mixins/PopupMixin.js +757 -0
- package/mixins/RTLObserverMixin.js +0 -1
- package/mixins/ResizeObserverMixin.js +0 -1
- package/mixins/RippleMixin.js +3 -4
- package/mixins/ScrollListenerMixin.js +41 -32
- package/mixins/SemiStickyMixin.js +151 -0
- package/mixins/ShapeMixin.js +29 -24
- package/mixins/StateMixin.js +11 -6
- package/mixins/SurfaceMixin.js +3 -57
- package/mixins/TextFieldMixin.js +57 -65
- package/mixins/ThemableMixin.js +78 -156
- package/mixins/TooltipTriggerMixin.js +7 -13
- package/mixins/TouchTargetMixin.js +4 -3
- package/package.json +9 -5
- package/theming/index.js +1 -1
- package/theming/themableMixinLoader.js +12 -0
- package/utils/{hct → material-color}/blend.js +8 -10
- package/utils/{hct → material-color/hct}/Cam16.js +196 -69
- package/utils/{hct → material-color/hct}/Hct.js +61 -19
- package/utils/{hct → material-color/hct}/ViewingConditions.js +3 -3
- package/utils/{hct → material-color/hct}/hctSolver.js +9 -16
- package/utils/{hct → material-color}/helper.js +11 -18
- package/utils/{hct → material-color/palettes}/CorePalette.js +79 -19
- package/utils/{hct → material-color/palettes}/TonalPalette.js +12 -4
- package/utils/material-color/scheme/Scheme.js +376 -0
- package/utils/{hct/colorUtils.js → material-color/utils/color.js} +61 -1
- package/utils/popup.js +46 -25
- package/components/ListSelect.js +0 -220
- package/components/Option.js +0 -91
- package/components/Pane.js +0 -281
- package/core/identify.js +0 -40
- package/utils/hct/Scheme.js +0 -587
- /package/utils/{hct/mathUtils.js → material-color/utils/math.js} +0 -0
package/mixins/TextFieldMixin.js
CHANGED
|
@@ -11,7 +11,6 @@ export default function TextFieldMixin(Base) {
|
|
|
11
11
|
return Base
|
|
12
12
|
.mixin(DensityMixin)
|
|
13
13
|
.mixin(ShapeMixin)
|
|
14
|
-
.extend()
|
|
15
14
|
.set({
|
|
16
15
|
stateLayer: true,
|
|
17
16
|
})
|
|
@@ -30,7 +29,7 @@ export default function TextFieldMixin(Base) {
|
|
|
30
29
|
placeholder: { nullParser: String }, // DOMString
|
|
31
30
|
})
|
|
32
31
|
.observe({
|
|
33
|
-
erroredState({ error, _invalid }) { return Boolean(error || _invalid); },
|
|
32
|
+
erroredState({ error, _invalid, _userInteracted }) { return _userInteracted && Boolean(error || _invalid); },
|
|
34
33
|
})
|
|
35
34
|
.expressions({
|
|
36
35
|
computePlaceholder({ filled, outlined, label, placeholder }) {
|
|
@@ -38,12 +37,12 @@ export default function TextFieldMixin(Base) {
|
|
|
38
37
|
return placeholder ?? label;
|
|
39
38
|
},
|
|
40
39
|
|
|
41
|
-
shouldShowSupporting({
|
|
42
|
-
return
|
|
40
|
+
shouldShowSupporting({ erroredState, supporting }) {
|
|
41
|
+
return erroredState || (supporting != null);
|
|
43
42
|
},
|
|
44
43
|
|
|
45
|
-
computeSupportingText({ error, _validationMessage, supporting }) {
|
|
46
|
-
return (error || _validationMessage || supporting) ?? '';
|
|
44
|
+
computeSupportingText({ error, erroredState, _validationMessage, supporting }) {
|
|
45
|
+
return (error || (erroredState && _validationMessage) || supporting) ?? '';
|
|
47
46
|
},
|
|
48
47
|
|
|
49
48
|
populatedState({ value, _badInput }) {
|
|
@@ -53,44 +52,57 @@ export default function TextFieldMixin(Base) {
|
|
|
53
52
|
return label && (filled || outlined);
|
|
54
53
|
},
|
|
55
54
|
})
|
|
55
|
+
.html`
|
|
56
|
+
<div id=label-text mdw-if={_showLabelText} aria-hidden=true
|
|
57
|
+
outlined={outlined}
|
|
58
|
+
populated={populatedState}
|
|
59
|
+
focused={focusedState}
|
|
60
|
+
icon={icon}
|
|
61
|
+
trailing-icon={trailingIcon}
|
|
62
|
+
disabled={disabledState}
|
|
63
|
+
errored={erroredState}>{label}</div>
|
|
64
|
+
<div mdw-if={shouldShowSupporting} id=supporting disabled={disabledState} errored={erroredState}>
|
|
65
|
+
{computeSupportingText}
|
|
66
|
+
<slot id=supporting-slot name=supporting></slot>
|
|
67
|
+
</div>
|
|
68
|
+
`
|
|
56
69
|
.on({
|
|
57
|
-
composed({
|
|
58
|
-
const { control,
|
|
70
|
+
composed({ html, inline }) {
|
|
71
|
+
const { control, outline, shape, outlineLeft, outlineRight, state } = this.refs;
|
|
59
72
|
control.setAttribute('placeholder', '{computePlaceholder}');
|
|
60
73
|
control.setAttribute('aria-label', '{label}');
|
|
61
74
|
control.setAttribute('input-suffix', '{inputSuffix}');
|
|
62
75
|
control.setAttribute('errored', '{erroredState}');
|
|
76
|
+
control.setAttribute('aria-describedby', 'supporting');
|
|
63
77
|
control.removeAttribute('aria-labelledby');
|
|
64
78
|
control.classList.add('inline');
|
|
65
79
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
labelElement.setAttribute('shape-top', inline(({ shapeTop, filled }) => shapeTop || filled));
|
|
77
|
-
labelElement.append(
|
|
80
|
+
state.setAttribute('mdw-if', '{!outlined}');
|
|
81
|
+
shape.setAttribute('role', 'none');
|
|
82
|
+
shape.setAttribute('filled', '{filled}');
|
|
83
|
+
shape.setAttribute('icon', '{icon}');
|
|
84
|
+
shape.setAttribute('trailingIcon', '{trailingIcon}');
|
|
85
|
+
shape.setAttribute('populated', '{populatedState}');
|
|
86
|
+
shape.setAttribute('focused', '{focusedState}');
|
|
87
|
+
shape.setAttribute('label', '{label}');
|
|
88
|
+
shape.setAttribute('shape-top', inline(({ shapeTop, filled }) => shapeTop || filled));
|
|
89
|
+
shape.append(
|
|
78
90
|
state,
|
|
79
91
|
outline,
|
|
92
|
+
control,
|
|
80
93
|
html`
|
|
81
|
-
<mdw-icon
|
|
82
|
-
<span
|
|
83
|
-
<span
|
|
84
|
-
<mdw-icon
|
|
85
|
-
<div id=indicator
|
|
94
|
+
<mdw-icon mdw-if={icon} id=icon aria-hidden=true disabled={disabledState}>{icon}</mdw-icon>
|
|
95
|
+
<span mdw-if={inputPrefix} class=inline id=prefix aria-hidden=true focused={focusedState} populated={populatedState}>{inputPrefix}</span>
|
|
96
|
+
<span mdw-if={inputSuffix} class=inline id=suffix aria-hidden=true focused={focusedState} populated={populatedState}>{inputSuffix}</span>
|
|
97
|
+
<mdw-icon mdw-if={trailingIcon} id=trailing-icon ink={trailingIconInk} aria-hidden=true disabled={disabledState}>{trailingIcon}</mdw-icon>
|
|
98
|
+
<div mdw-if={filled} id=indicator aria-hidden=true focused={focusedState} hovered={hoveredState} errored={erroredState} disabled={disabledState}></div>
|
|
86
99
|
`,
|
|
87
100
|
);
|
|
88
101
|
|
|
89
102
|
outline.setAttribute('label', '{label}');
|
|
90
|
-
outline.setAttribute('invalid', '{invalid}');
|
|
91
103
|
outline.setAttribute('errored', '{erroredState}');
|
|
92
104
|
outlineLeft.after(html`
|
|
93
|
-
<div id=gap
|
|
105
|
+
<div id=gap mdw-if={label} label={label} populated={populatedState} focused={focusedState}>
|
|
94
106
|
<div id=gap-slot focused={focusedState}></div>
|
|
95
107
|
<span id=gap-label>{label}</span>
|
|
96
108
|
</div>
|
|
@@ -98,24 +110,6 @@ export default function TextFieldMixin(Base) {
|
|
|
98
110
|
|
|
99
111
|
outlineLeft.setAttribute('focused', '{focusedState}');
|
|
100
112
|
outlineRight.setAttribute('focused', '{focusedState}');
|
|
101
|
-
|
|
102
|
-
shape.remove();
|
|
103
|
-
state.setAttribute('_if', '{!outlined}');
|
|
104
|
-
|
|
105
|
-
template.append(html`
|
|
106
|
-
<div id=label-text _if={_showLabelText} aria-hidden=true
|
|
107
|
-
outlined={outlined}
|
|
108
|
-
populated={populatedState}
|
|
109
|
-
focused={focusedState}
|
|
110
|
-
icon={icon}
|
|
111
|
-
trailing-icon={trailingIcon}
|
|
112
|
-
disabled={disabledState}
|
|
113
|
-
errored={erroredState}>{label}</div>
|
|
114
|
-
<div _if={shouldShowSupporting} id=supporting disabled={disabledState} errored={erroredState}>
|
|
115
|
-
{computeSupportingText}
|
|
116
|
-
<slot id=supporting-slot name=supporting></slot>
|
|
117
|
-
</div>
|
|
118
|
-
`);
|
|
119
113
|
},
|
|
120
114
|
sizeChanged(oldValue, newValue) {
|
|
121
115
|
this.refs.control.style.setProperty('--size', `${newValue}ch`);
|
|
@@ -162,7 +156,7 @@ export default function TextFieldMixin(Base) {
|
|
|
162
156
|
|
|
163
157
|
--descriptor-opacity: 0.5;
|
|
164
158
|
--mdw-ink: var(--mdw-color__primary);
|
|
165
|
-
--mdw-bg: var(--mdw-color__surface-
|
|
159
|
+
--mdw-bg: var(--mdw-color__surface-container-highest);
|
|
166
160
|
|
|
167
161
|
--mdw-type__font: var(--mdw-typescale__body-large__font);
|
|
168
162
|
--mdw-type__letter-spacing: var(--mdw-typescale__body-large__letter-spacing);
|
|
@@ -190,18 +184,15 @@ export default function TextFieldMixin(Base) {
|
|
|
190
184
|
}
|
|
191
185
|
|
|
192
186
|
/** Guard against bleed */
|
|
193
|
-
|
|
187
|
+
#shape[label][outlined] {
|
|
194
188
|
--mdw-shape__size__top-start-size: min(var(--mdw-shape__size), 12px);
|
|
195
189
|
--mdw-shape__size__bottom-start-size: min(var(--mdw-shape__size), 12px);
|
|
196
190
|
--mdw-shape__size__top-end-size: min(var(--mdw-shape__size), 12px);
|
|
197
191
|
--mdw-shape__size__bottom-end-size: min(var(--mdw-shape__size), 12px);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
#label[label][outlined] {
|
|
201
192
|
-webkit-mask-box-image-width: min(var(--mdw-shape__size), 12px);
|
|
202
193
|
}
|
|
203
194
|
|
|
204
|
-
#
|
|
195
|
+
#shape {
|
|
205
196
|
position: relative;
|
|
206
197
|
|
|
207
198
|
display: flex;
|
|
@@ -209,9 +200,6 @@ export default function TextFieldMixin(Base) {
|
|
|
209
200
|
align-items: center;
|
|
210
201
|
overflow: visible;
|
|
211
202
|
|
|
212
|
-
padding-inline-start: 16px;
|
|
213
|
-
padding-inline-end: 16px;
|
|
214
|
-
|
|
215
203
|
cursor: inherit;
|
|
216
204
|
|
|
217
205
|
z-index: 0;
|
|
@@ -227,12 +215,16 @@ export default function TextFieldMixin(Base) {
|
|
|
227
215
|
transition: none 200ms cubic-bezier(0.0, 0.0, 0.2, 1);
|
|
228
216
|
}
|
|
229
217
|
|
|
230
|
-
#
|
|
218
|
+
#shape:where([filled],[outlined]) {
|
|
219
|
+
padding-inline: 16px;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
#shape:where([filled],[color]) {
|
|
231
223
|
background-color: rgb(var(--mdw-bg));
|
|
232
224
|
color: rgb(var(--mdw-color__on-surface));
|
|
233
225
|
}
|
|
234
226
|
|
|
235
|
-
#
|
|
227
|
+
#shape[outlined] {
|
|
236
228
|
background-color: transparent;
|
|
237
229
|
}
|
|
238
230
|
|
|
@@ -245,19 +237,19 @@ export default function TextFieldMixin(Base) {
|
|
|
245
237
|
color: rgb(var(--mdw-ink))
|
|
246
238
|
}
|
|
247
239
|
|
|
248
|
-
#
|
|
240
|
+
#shape:where([filled],[outlined])[icon] {
|
|
249
241
|
padding-inline-start: 12px;
|
|
250
242
|
}
|
|
251
243
|
|
|
252
|
-
#
|
|
244
|
+
#shape[trailing-icon] {
|
|
253
245
|
padding-inline-end: 12px;
|
|
254
246
|
}
|
|
255
247
|
|
|
256
|
-
#
|
|
248
|
+
#shape[focused] {
|
|
257
249
|
transition: none 100ms cubic-bezier(0.4, 0.0, 1, 1);
|
|
258
250
|
}
|
|
259
251
|
|
|
260
|
-
#
|
|
252
|
+
#shape[shape-top] {
|
|
261
253
|
--mdw-shape__size__bottom-start-size: 0px;
|
|
262
254
|
--mdw-shape__size__bottom-end-size: 0px;
|
|
263
255
|
--mdw-shape__mask: linear-gradient(transparent 50%, black 50%);
|
|
@@ -701,7 +693,7 @@ export default function TextFieldMixin(Base) {
|
|
|
701
693
|
padding: 0;
|
|
702
694
|
}
|
|
703
695
|
|
|
704
|
-
#
|
|
696
|
+
#shape[label][filled] {
|
|
705
697
|
align-items: flex-start;
|
|
706
698
|
}
|
|
707
699
|
|
|
@@ -753,8 +745,8 @@ export default function TextFieldMixin(Base) {
|
|
|
753
745
|
}
|
|
754
746
|
|
|
755
747
|
/* stylelint-disable-next-line selector-max-compound-selectors */
|
|
756
|
-
#
|
|
757
|
-
#
|
|
748
|
+
#shape[disabled],
|
|
749
|
+
#shape[disabled] #control {
|
|
758
750
|
cursor: not-allowed;
|
|
759
751
|
}
|
|
760
752
|
|
|
@@ -778,7 +770,7 @@ export default function TextFieldMixin(Base) {
|
|
|
778
770
|
color: rgba(var(--mdw-color__on-surface), 0.38);
|
|
779
771
|
}
|
|
780
772
|
|
|
781
|
-
#
|
|
773
|
+
#shape[disabled] {
|
|
782
774
|
background-color: rgba(var(--mdw-color__on-surface), calc(0.04));
|
|
783
775
|
color: rgba(var(--mdw-color__on-surface), 0.38);
|
|
784
776
|
}
|
|
@@ -787,7 +779,7 @@ export default function TextFieldMixin(Base) {
|
|
|
787
779
|
color: rgba(var(--mdw-color__on-surface), 0.38);
|
|
788
780
|
}
|
|
789
781
|
|
|
790
|
-
#
|
|
782
|
+
#shape[disabled][outlined] {
|
|
791
783
|
background-color: transparent;
|
|
792
784
|
}
|
|
793
785
|
|
package/mixins/ThemableMixin.js
CHANGED
|
@@ -3,62 +3,50 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export default function ThemableMixin(Base) {
|
|
5
5
|
return Base
|
|
6
|
-
.extend()
|
|
7
6
|
.observe({
|
|
8
7
|
color: 'string',
|
|
9
8
|
ink: 'string',
|
|
10
|
-
block: 'boolean',
|
|
11
9
|
typeStyle: 'string',
|
|
12
10
|
})
|
|
11
|
+
.css`${
|
|
12
|
+
ThemableMixin.PALETTES.map((palette) => [
|
|
13
|
+
`:host([color="${palette}"]){`,
|
|
14
|
+
`--mdw-bg: var(--mdw-color__${palette});`,
|
|
15
|
+
`--mdw-ink: var(--mdw-color__on-${palette});`,
|
|
16
|
+
'}',
|
|
17
|
+
`:host([color="${palette}-container"]){`,
|
|
18
|
+
`--mdw-bg: var(--mdw-color__${palette}-container);`,
|
|
19
|
+
`--mdw-ink: var(--mdw-color__on-${palette}-container);`,
|
|
20
|
+
'}',
|
|
21
|
+
].join('')).join('')}`
|
|
13
22
|
.css`
|
|
14
|
-
:host([color="
|
|
15
|
-
--mdw-bg: var(--mdw-
|
|
16
|
-
--mdw-ink: var(--mdw-color__on-
|
|
23
|
+
:host([color="background"]) {
|
|
24
|
+
--mdw-bg: var(--mdw-color__background);
|
|
25
|
+
--mdw-ink: var(--mdw-color__on-background);
|
|
17
26
|
}
|
|
18
|
-
|
|
19
|
-
:host([color="
|
|
20
|
-
--mdw-bg: var(--mdw-
|
|
21
|
-
--mdw-ink: var(--mdw-color__on-primary-container);
|
|
27
|
+
|
|
28
|
+
:host([color="surface-dim"]) {
|
|
29
|
+
--mdw-bg: var(--mdw-color__surface-dim);
|
|
22
30
|
}
|
|
23
|
-
|
|
24
|
-
:host([color="
|
|
25
|
-
--mdw-bg: var(--mdw-
|
|
26
|
-
--mdw-ink: var(--mdw-color__on-secondary);
|
|
31
|
+
|
|
32
|
+
:host([color="surface-bright"]) {
|
|
33
|
+
--mdw-bg: var(--mdw-color__surface-bright);
|
|
27
34
|
}
|
|
28
|
-
|
|
29
|
-
:host([color="
|
|
30
|
-
--mdw-bg: var(--mdw-
|
|
31
|
-
--mdw-ink: var(--mdw-color__on-secondary-container);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
:host([color="tertiary"]) {
|
|
35
|
-
--mdw-bg: var(--mdw-color__tertiary);
|
|
36
|
-
--mdw-ink: var(--mdw-color__on-tertiary);
|
|
35
|
+
|
|
36
|
+
:host([color="surface-container-lowest"]) {
|
|
37
|
+
--mdw-bg: var(--mdw-color__surface-container-lowest);
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
-
:host([color="
|
|
40
|
-
--mdw-bg: var(--mdw-
|
|
41
|
-
--mdw-ink: var(--mdw-color__on-tertiary-container);
|
|
39
|
+
|
|
40
|
+
:host([color="surface-container-low"]) {
|
|
41
|
+
--mdw-bg: var(--mdw-color__surface-container-low);
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
:host([color="
|
|
45
|
-
--mdw-bg: var(--mdw-
|
|
46
|
-
--mdw-ink: var(--mdw-color__on-error);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
:host([color="error-container"]) {
|
|
50
|
-
--mdw-bg: var(--mdw-color__error-container);
|
|
51
|
-
--mdw-ink: var(--mdw-color__on-error-container);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
:host([color="background"]) {
|
|
55
|
-
--mdw-bg: var(--mdw-color__background);
|
|
56
|
-
--mdw-ink: var(--mdw-color__on-background);
|
|
43
|
+
|
|
44
|
+
:host([color="surface-container-high"]) {
|
|
45
|
+
--mdw-bg: var(--mdw-color__surface-container-high);
|
|
57
46
|
}
|
|
58
47
|
|
|
59
|
-
:host([color
|
|
60
|
-
--mdw-bg: var(--mdw-color__surface);
|
|
61
|
-
--mdw-ink: var(--mdw-color__on-surface);
|
|
48
|
+
:host([color="surface-container-highest"]) {
|
|
49
|
+
--mdw-bg: var(--mdw-color__surface-container-highest);
|
|
62
50
|
}
|
|
63
51
|
|
|
64
52
|
/* Quality-of-life */
|
|
@@ -67,7 +55,7 @@ export default function ThemableMixin(Base) {
|
|
|
67
55
|
}
|
|
68
56
|
|
|
69
57
|
:host([color$="variant"]) {
|
|
70
|
-
--mdw-bg: var(--mdw-color__surface-
|
|
58
|
+
--mdw-bg: var(--mdw-color__surface-container-highest);
|
|
71
59
|
--mdw-ink: var(--mdw-color__on-surface-variant);
|
|
72
60
|
}
|
|
73
61
|
|
|
@@ -84,49 +72,27 @@ export default function ThemableMixin(Base) {
|
|
|
84
72
|
/* background-color: rgba(var(--mdw-color__on-surface), 0.12); */
|
|
85
73
|
/* color: rgba(var(--mdw-color__on-surface), 0.38); */
|
|
86
74
|
}
|
|
87
|
-
|
|
75
|
+
`
|
|
76
|
+
.css`${
|
|
77
|
+
ThemableMixin.PALETTES.map((palette) => [
|
|
78
|
+
`:host([ink="${palette}"]){`,
|
|
79
|
+
`--mdw-ink: var(--mdw-color__${palette});`,
|
|
80
|
+
'}',
|
|
81
|
+
`:host([ink="on-${palette}-container"]){`,
|
|
82
|
+
`--mdw-ink: var(--mdw-color__on-${palette}-container);`,
|
|
83
|
+
'}',
|
|
84
|
+
].join('')).join('')}`
|
|
85
|
+
.css`
|
|
88
86
|
:host([ink="inverse-primary"]) {
|
|
89
87
|
--mdw-ink: var(--mdw-color__inverse-primary);
|
|
90
88
|
}
|
|
91
|
-
|
|
92
|
-
:host([ink="primary"]) {
|
|
93
|
-
--mdw-ink: var(--mdw-color__primary);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
:host([ink="on-primary-container"]) {
|
|
97
|
-
--mdw-ink: var(--mdw-color__on-primary-container);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
:host([ink="secondary"]) {
|
|
101
|
-
--mdw-ink: var(--mdw-color__secondary);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
:host([ink="on-secondary-container"]) {
|
|
105
|
-
--mdw-ink: var(--mdw-color__on-secondary-container);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
:host([ink="tertiary"]) {
|
|
109
|
-
--mdw-ink: var(--mdw-color__tertiary);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
:host([ink="on-tertiary-container"]) {
|
|
113
|
-
--mdw-ink: var(--mdw-color__on-tertiary-container);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
:host([ink="error"]) {
|
|
117
|
-
--mdw-ink: var(--mdw-color__error);
|
|
118
|
-
}
|
|
119
|
-
|
|
89
|
+
|
|
120
90
|
:host([ink="outline"]) {
|
|
121
91
|
--mdw-ink: var(--mdw-color__outline);
|
|
122
92
|
}
|
|
123
93
|
|
|
124
|
-
:host([ink="
|
|
125
|
-
--mdw-ink: var(--mdw-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
:host([ink="surface-variant"]) {
|
|
129
|
-
--mdw-ink: var(--mdw-color__surface-variant);
|
|
94
|
+
:host([ink="surface-container-highest"]) {
|
|
95
|
+
--mdw-ink: var(--mdw-color__surface-container-highest);
|
|
130
96
|
}
|
|
131
97
|
|
|
132
98
|
:host([ink="on-surface-variant"]) {
|
|
@@ -140,80 +106,36 @@ export default function ThemableMixin(Base) {
|
|
|
140
106
|
:host([ink="inherit"]) {
|
|
141
107
|
--mdw-ink: inherit;
|
|
142
108
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
:host([type-style|="headline"]) {
|
|
160
|
-
--mdw-type__font: var(--mdw-typescale__headline-large__font);
|
|
161
|
-
--mdw-type__letter-spacing: var(--mdw-typescale__headline-large__letter-spacing);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
:host([type-style="headline-medium"]) {
|
|
165
|
-
--mdw-type__font: var(--mdw-typescale__headline-medium__font);
|
|
166
|
-
--mdw-type__letter-spacing: var(--mdw-typescale__headline-medium__letter-spacing);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
:host([type-style="headline-small"]) {
|
|
170
|
-
--mdw-type__font: var(--mdw-typescale__headline-small__font);
|
|
171
|
-
--mdw-type__letter-spacing: var(--mdw-typescale__headline-small__letter-spacing);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
:host([type-style|="title"]) {
|
|
175
|
-
--mdw-type__font: var(--mdw-typescale__title-large__font);
|
|
176
|
-
--mdw-type__letter-spacing: var(--mdw-typescale__title-large__letter-spacing);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
:host([type-style="title-medium"]) {
|
|
180
|
-
--mdw-type__font: var(--mdw-typescale__title-medium__font);
|
|
181
|
-
--mdw-type__letter-spacing: var(--mdw-typescale__title-medium__letter-spacing);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
:host([type-style="title-small"]) {
|
|
185
|
-
--mdw-type__font: var(--mdw-typescale__title-small__font);
|
|
186
|
-
--mdw-type__letter-spacing: var(--mdw-typescale__title-small__letter-spacing);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
:host([type-style|="label"]) {
|
|
190
|
-
--mdw-type__font: var(--mdw-typescale__label-large__font);
|
|
191
|
-
--mdw-type__letter-spacing: var(--mdw-typescale__label-large__letter-spacing);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
:host([type-style="label-medium"]) {
|
|
195
|
-
--mdw-type__font: var(--mdw-typescale__label-medium__font);
|
|
196
|
-
--mdw-type__letter-spacing: var(--mdw-typescale__label-medium__letter-spacing);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
:host([type-style="label-small"]) {
|
|
200
|
-
--mdw-type__font: var(--mdw-typescale__label-small__font);
|
|
201
|
-
--mdw-type__letter-spacing: var(--mdw-typescale__label-small__letter-spacing);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
:host([type-style|="body"]) {
|
|
205
|
-
--mdw-type__font: var(--mdw-typescale__body-large__font);
|
|
206
|
-
--mdw-type__letter-spacing: var(--mdw-typescale__body-large__letter-spacing);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
:host([type-style="body-medium"]) {
|
|
210
|
-
--mdw-type__font: var(--mdw-typescale__body-medium__font);
|
|
211
|
-
--mdw-type__letter-spacing: var(--mdw-typescale__body-medium__letter-spacing);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
:host([type-style="body-small"]) {
|
|
215
|
-
--mdw-type__font: var(--mdw-typescale__body-small__font);
|
|
216
|
-
--mdw-type__letter-spacing: var(--mdw-typescale__body-small__letter-spacing);
|
|
217
|
-
}
|
|
218
|
-
`;
|
|
109
|
+
`
|
|
110
|
+
.css`${
|
|
111
|
+
ThemableMixin.TYPE_STYLES.map((typeStyle) => [
|
|
112
|
+
`:host([type-style|="${typeStyle}"]) {`,
|
|
113
|
+
`--mdw-type__font: var(--mdw-typescale__${typeStyle}-large__font);`,
|
|
114
|
+
`--mdw-type__letter-spacing: var(--mdw-typescale__${typeStyle}-large__letter-spacing);`,
|
|
115
|
+
'}',
|
|
116
|
+
`:host([type-style="${typeStyle}-medium"]) {`,
|
|
117
|
+
`--mdw-type__font: var(--mdw-typescale__${typeStyle}-medium__font);`,
|
|
118
|
+
`--mdw-type__letter-spacing: var(--mdw-typescale__${typeStyle}-medium__letter-spacing);`,
|
|
119
|
+
'}',
|
|
120
|
+
`:host([type-style="${typeStyle}-small"]) {`,
|
|
121
|
+
`--mdw-type__font: var(--mdw-typescale__${typeStyle}-small__font);`,
|
|
122
|
+
`--mdw-type__letter-spacing: var(--mdw-typescale__${typeStyle}-small__letter-spacing);`,
|
|
123
|
+
'}',
|
|
124
|
+
].join(''))}`;
|
|
219
125
|
}
|
|
126
|
+
|
|
127
|
+
ThemableMixin.PALETTES = [
|
|
128
|
+
'primary',
|
|
129
|
+
'secondary',
|
|
130
|
+
'tertiary',
|
|
131
|
+
'error',
|
|
132
|
+
'surface',
|
|
133
|
+
];
|
|
134
|
+
|
|
135
|
+
ThemableMixin.TYPE_STYLES = [
|
|
136
|
+
'display',
|
|
137
|
+
'headline',
|
|
138
|
+
'title',
|
|
139
|
+
'label',
|
|
140
|
+
'body',
|
|
141
|
+
];
|
|
@@ -321,24 +321,18 @@ export default function TooltipTriggerMixin(Base) {
|
|
|
321
321
|
|
|
322
322
|
let anchorResult;
|
|
323
323
|
for (const preference of preferences) {
|
|
324
|
-
|
|
324
|
+
const result = canAnchorPopup({
|
|
325
325
|
...anchorOptions,
|
|
326
326
|
...preference,
|
|
327
327
|
});
|
|
328
|
-
if (anchorResult)
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
if (!anchorResult) {
|
|
333
|
-
anchorResult = canAnchorPopup({
|
|
334
|
-
...anchorOptions,
|
|
335
|
-
...preferences[0],
|
|
336
|
-
force: true,
|
|
337
|
-
});
|
|
328
|
+
if (!anchorResult || anchorResult.visibility < result.visibility) {
|
|
329
|
+
anchorResult = result;
|
|
330
|
+
}
|
|
331
|
+
if (result.visibility === 1) break;
|
|
338
332
|
}
|
|
339
333
|
|
|
340
|
-
this.#tooltip.style.setProperty('top', `${anchorResult.
|
|
341
|
-
this.#tooltip.style.setProperty('left', `${anchorResult.
|
|
334
|
+
this.#tooltip.style.setProperty('top', `${anchorResult.top}px`);
|
|
335
|
+
this.#tooltip.style.setProperty('left', `${anchorResult.left}px`);
|
|
342
336
|
this.#tooltip.style.setProperty('margin', '0');
|
|
343
337
|
this.#tooltip.style.setProperty('transform-origin', `${anchorResult.transformOriginY} ${anchorResult.transformOriginX}`);
|
|
344
338
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/** @param {typeof import('../core/CustomElement.js').default} Base */
|
|
2
2
|
export default function TouchTargetMixin(Base) {
|
|
3
3
|
return Base
|
|
4
|
-
.
|
|
5
|
-
.html/* html */`<div id=touch-target class=touch-target></div>`
|
|
4
|
+
.html`<div id=touch-target class=touch-target></div>`
|
|
6
5
|
.css`
|
|
6
|
+
/* stylelint-disable liberty/use-logical-spec */
|
|
7
7
|
.touch-target {
|
|
8
8
|
position: absolute;
|
|
9
|
-
|
|
9
|
+
top: 50%;
|
|
10
|
+
left: 50%;
|
|
10
11
|
/* --mdw-device-pixel-ratio: 1; */
|
|
11
12
|
|
|
12
13
|
block-size: 100%;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shortfuse/materialdesignweb",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Material Design for Web",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"docs": "node build/esbuild.js docs/demo.js --outdir=docs --minify --metafile",
|
|
14
14
|
"watch": "node build/esbuild.js docs/demo.js --outdir=docs --watch --metafile",
|
|
15
15
|
"serve": "node build/esbuild.js docs/demo.js --outdir=docs --watch --metafile --serve --live",
|
|
16
|
+
"sample": "node build/esbuild.js index.js --outdir=docs --watch --metafile --serve --live",
|
|
16
17
|
"pretest": "eslint --ignore-path .gitignore",
|
|
17
18
|
"test": "web-test-runner \"test/**/*.test.js\" --node-resolve",
|
|
18
19
|
"test:watch": "web-test-runner \"test/**/*.test.js\" --node-resolve --watch"
|
|
@@ -53,6 +54,7 @@
|
|
|
53
54
|
"./components/*.js",
|
|
54
55
|
"./utils/metadata.js",
|
|
55
56
|
"./theming/loader.js",
|
|
57
|
+
"./docs/custom.js",
|
|
56
58
|
"./docs/demo/*.js"
|
|
57
59
|
],
|
|
58
60
|
"bugs": {
|
|
@@ -61,13 +63,14 @@
|
|
|
61
63
|
"homepage": "https://github.com/clshortfuse/materialdesignweb#readme",
|
|
62
64
|
"devDependencies": {
|
|
63
65
|
"@esm-bundle/chai": "^4.3.4-fix.0",
|
|
66
|
+
"@playwright/test": "^1.32.3",
|
|
64
67
|
"@types/html-minifier-terser": "^7.0.0",
|
|
65
68
|
"@types/mocha": "^10.0.1",
|
|
66
69
|
"@types/tap": "^15.0.7",
|
|
67
70
|
"@typescript-eslint/eslint-plugin": "^5.30.7",
|
|
68
71
|
"@typescript-eslint/parser": "^5.30.7",
|
|
69
|
-
"@web/test-runner": "^0.
|
|
70
|
-
"@web/test-runner-playwright": "^0.
|
|
72
|
+
"@web/test-runner": "^0.16.1",
|
|
73
|
+
"@web/test-runner-playwright": "^0.10.0",
|
|
71
74
|
"acorn": "^8.8.2",
|
|
72
75
|
"acorn-walk": "^8.2.0",
|
|
73
76
|
"browserslist-to-esbuild": "^1.1.1",
|
|
@@ -79,18 +82,19 @@
|
|
|
79
82
|
"eslint-plugin-compat": "^4.0.2",
|
|
80
83
|
"eslint-plugin-github": "^4.3.5",
|
|
81
84
|
"eslint-plugin-import": "^2.27.5",
|
|
82
|
-
"eslint-plugin-jsdoc": "^
|
|
85
|
+
"eslint-plugin-jsdoc": "^43.1.1",
|
|
83
86
|
"eslint-plugin-sort-class-members": "^1.15.2",
|
|
84
87
|
"eslint-plugin-unicorn": "^46.0.0",
|
|
85
88
|
"html-minifier-terser": "^7.1.0",
|
|
86
89
|
"http-server": "^14.1.1",
|
|
87
90
|
"magic-string": "^0.30.0",
|
|
91
|
+
"playwright": "^1.32.2",
|
|
88
92
|
"postcss-styled": "^0.34.0",
|
|
89
93
|
"postcss-styled-syntax": "^0.4.0",
|
|
90
94
|
"stylelint": "^15.2.0",
|
|
91
95
|
"stylelint-no-unsupported-browser-features": "github:clshortfuse/stylelint-no-unsupported-browser-features#0a51157",
|
|
92
96
|
"stylelint-order": "^6.0.2",
|
|
93
97
|
"stylelint-use-logical-spec": "^5.0.0",
|
|
94
|
-
"typescript": "
|
|
98
|
+
"typescript": "5.1"
|
|
95
99
|
}
|
|
96
100
|
}
|
package/theming/index.js
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Import this first to ensure ThemableMixin includes custom palettes */
|
|
2
|
+
|
|
3
|
+
import ThemableMixin from '../mixins/ThemableMixin.js';
|
|
4
|
+
|
|
5
|
+
ThemableMixin.PALETTES.push(
|
|
6
|
+
...(
|
|
7
|
+
(new URL(import.meta.url).searchParams)
|
|
8
|
+
.getAll('custom')
|
|
9
|
+
.flatMap((c) => c.split(','))
|
|
10
|
+
.map((c) => c.split(':')[0])
|
|
11
|
+
),
|
|
12
|
+
);
|