@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/components/TopAppBar.js
CHANGED
|
@@ -1,77 +1,34 @@
|
|
|
1
1
|
import CustomElement from '../core/CustomElement.js';
|
|
2
2
|
import { ELEMENT_STYLER_TYPE } from '../core/customTypes.js';
|
|
3
3
|
import AriaToolbarMixin from '../mixins/AriaToolbarMixin.js';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import SemiStickyMixin from '../mixins/SemiStickyMixin.js';
|
|
5
|
+
import ShapeMixin from '../mixins/ShapeMixin.js';
|
|
6
6
|
import SurfaceMixin from '../mixins/SurfaceMixin.js';
|
|
7
7
|
import ThemableMixin from '../mixins/ThemableMixin.js';
|
|
8
8
|
|
|
9
9
|
export default CustomElement
|
|
10
|
+
.extend()
|
|
10
11
|
.mixin(ThemableMixin)
|
|
11
|
-
.mixin(SurfaceMixin)
|
|
12
|
+
.mixin(SurfaceMixin)
|
|
13
|
+
.mixin(ShapeMixin)
|
|
12
14
|
.mixin(AriaToolbarMixin)
|
|
13
|
-
.mixin(
|
|
14
|
-
.mixin(ResizeObserverMixin)
|
|
15
|
-
.extend()
|
|
15
|
+
.mixin(SemiStickyMixin)
|
|
16
16
|
.set({
|
|
17
17
|
elevated: true,
|
|
18
18
|
})
|
|
19
19
|
.observe({
|
|
20
|
+
_raised: 'boolean',
|
|
21
|
+
_headlineOpacity: { type: 'float', default: 0 },
|
|
20
22
|
headline: 'string',
|
|
21
|
-
_raised: 'boolean', // Change to raw value instead of computed
|
|
22
|
-
hideOnScroll: 'boolean',
|
|
23
23
|
size: { value: /** @type {'small'|'medium'|'large'|null} */ (null) },
|
|
24
|
-
|
|
25
|
-
/** @type {'sticky'|'relative'} */
|
|
26
|
-
empty: 'relative',
|
|
27
|
-
},
|
|
28
|
-
_visibleStart: { type: 'float', default: 0 },
|
|
29
|
-
_translateY: { type: 'float', empty: 0 },
|
|
30
|
-
_duration: { type: 'float', empty: 0 },
|
|
31
|
-
_easing: { empty: 'ease-in' },
|
|
32
|
-
_headlineOpacity: { type: 'float', default: 0 },
|
|
33
|
-
/** Convert to observable */
|
|
24
|
+
/** Convert native to observable */
|
|
34
25
|
ariaLabel: 'string',
|
|
35
26
|
color: { empty: 'surface' },
|
|
36
27
|
})
|
|
28
|
+
.overrides({
|
|
29
|
+
_getSemiStickyElement() { return this.refs.surface; },
|
|
30
|
+
})
|
|
37
31
|
.observe({
|
|
38
|
-
_scrollDirection: {
|
|
39
|
-
/**
|
|
40
|
-
* @param {'up'|'down'} oldValue
|
|
41
|
-
* @param {'up'|'down'} newValue
|
|
42
|
-
*/
|
|
43
|
-
changedCallback(oldValue, newValue) {
|
|
44
|
-
if (newValue === 'down') {
|
|
45
|
-
if (this._cssPosition !== 'sticky') return;
|
|
46
|
-
// Was sticky, switch to relative and let appbar scroll away
|
|
47
|
-
this._cssPosition = 'relative';
|
|
48
|
-
this._translateY = this.scrollListenerPositionY;
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
if (this._visibleStart < 1) return;
|
|
52
|
-
// Align appbar.bottom with scroll position (top of screen)
|
|
53
|
-
this._translateY = this.scrollListenerPositionY - this.refs.surface.scrollHeight;
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
_surfaceStyle: {
|
|
57
|
-
...ELEMENT_STYLER_TYPE,
|
|
58
|
-
get({ hideOnScroll, _cssPosition, _translateY, _duration, _easing }) {
|
|
59
|
-
if (!hideOnScroll) {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
target: 'surface',
|
|
64
|
-
styles: {
|
|
65
|
-
position: _cssPosition,
|
|
66
|
-
transform: `translateY(${_translateY}px)`,
|
|
67
|
-
},
|
|
68
|
-
timing: {
|
|
69
|
-
duration: _duration,
|
|
70
|
-
easing: _easing,
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
32
|
_headlineStyle: {
|
|
76
33
|
...ELEMENT_STYLER_TYPE,
|
|
77
34
|
get({ size, _headlineOpacity }) {
|
|
@@ -88,81 +45,49 @@ export default CustomElement
|
|
|
88
45
|
},
|
|
89
46
|
},
|
|
90
47
|
})
|
|
91
|
-
.html
|
|
48
|
+
.html`
|
|
92
49
|
<slot id=leading name=leading on-slotchange={refreshTabIndexes}></slot>
|
|
93
50
|
<div id=headline ink={ink} color={color} type-style={typeStyle} on-slotchange={refreshTabIndexes}>
|
|
94
51
|
{headline}
|
|
95
52
|
<slot id=headline-slot></slot>
|
|
96
53
|
</div>
|
|
97
54
|
<slot id=trailing name=trailing on-slotchange={refreshTabIndexes}></slot>
|
|
98
|
-
<div
|
|
99
|
-
<div _if={showSurfaceTint} id=companion-tint raised={_raised} class=surface-tint color={color}></div>
|
|
55
|
+
<div mdw-if=${({ size }) => size === 'medium' || size === 'large'} id=companion aria-hidden=true size={size} color={color} raised={_raised}>
|
|
100
56
|
<slot id=companion-slot name=companion size={size}>{headline}</span>
|
|
101
57
|
</div>
|
|
102
58
|
`
|
|
103
59
|
.on({
|
|
104
60
|
composed({ inline }) {
|
|
105
|
-
const { surface, leading, headline, trailing } = this.refs;
|
|
106
|
-
|
|
61
|
+
const { surface, shape, leading, headline, trailing } = this.refs;
|
|
62
|
+
shape.append(leading, headline, trailing);
|
|
63
|
+
surface.append(shape);
|
|
107
64
|
surface.setAttribute('size', '{size}');
|
|
108
|
-
surface.setAttribute('hide-on-scroll', '{hideOnScroll}');
|
|
109
65
|
surface.setAttribute('role', 'toolbar');
|
|
110
66
|
surface.setAttribute('aria-label', '{ariaLabel}');
|
|
111
67
|
surface.setAttribute(
|
|
112
68
|
'aria-labelledby',
|
|
113
69
|
inline(({ ariaLabel }) => (ariaLabel ? null : 'headline')),
|
|
114
70
|
);
|
|
71
|
+
surface.setAttribute('raised', '{_raised}');
|
|
72
|
+
shape.setAttribute('raised', '{_raised}');
|
|
115
73
|
},
|
|
116
|
-
|
|
117
|
-
this._raised = (newValue >
|
|
74
|
+
_scrollListenerPositionYChanged(oldValue, newValue) {
|
|
75
|
+
this._raised = (newValue > this._semiStickyOffsetY);
|
|
118
76
|
if (this.size === 'medium' || this.size === 'large') {
|
|
119
77
|
const max = this.refs.companion.scrollHeight;
|
|
120
78
|
const min = (0.5 * max);
|
|
121
79
|
this._headlineOpacity = Math.max(0, Math.min(1, (newValue - min) / (max - min)));
|
|
122
80
|
}
|
|
123
|
-
|
|
124
|
-
if (!this.hideOnScroll) return;
|
|
125
|
-
|
|
126
|
-
this._duration = 0;
|
|
127
|
-
if (newValue <= 0) {
|
|
128
|
-
// Set at rest (top of parent, but allow overscroll)
|
|
129
|
-
this._cssPosition = 'relative';
|
|
130
|
-
this._translateY = 0;
|
|
131
|
-
this._visibleStart = 0;
|
|
132
|
-
} else if (newValue < this._translateY) {
|
|
133
|
-
// Align appbar.top with scroll position (top of screen)
|
|
134
|
-
this._cssPosition = 'sticky';
|
|
135
|
-
this._translateY = 0;
|
|
136
|
-
this._visibleStart = 0;
|
|
137
|
-
} else if (this._cssPosition !== 'sticky') {
|
|
138
|
-
this._visibleStart = (newValue - this._translateY) / this.refs.surface.scrollHeight;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
this._scrollDirection = newValue > oldValue ? 'down' : 'up';
|
|
142
81
|
},
|
|
143
|
-
|
|
144
|
-
.methods({
|
|
145
|
-
onScrollIdle() {
|
|
146
|
-
const _visibleStart = this._visibleStart;
|
|
82
|
+
_scrollListenerLastIdleChanged() {
|
|
147
83
|
if (this._headlineOpacity > 0) {
|
|
148
84
|
// Fill in opacity on idle
|
|
149
85
|
this._headlineOpacity = 1;
|
|
150
86
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if (
|
|
154
|
-
if (_visibleStart <= 0.5) {
|
|
155
|
-
// Reveal all
|
|
156
|
-
this._duration = 250;
|
|
157
|
-
this._easing = 'ease-in';
|
|
158
|
-
this._cssPosition = 'relative';
|
|
159
|
-
this._translateY = this.scrollListenerPositionY;
|
|
87
|
+
},
|
|
88
|
+
_semiStickyTranslateYChanged(oldValue, newValue) {
|
|
89
|
+
if (newValue === 0) {
|
|
160
90
|
this._headlineOpacity = 1;
|
|
161
|
-
} else {
|
|
162
|
-
this._duration = 200;
|
|
163
|
-
this._easing = 'ease-out';
|
|
164
|
-
this._cssPosition = 'relative';
|
|
165
|
-
this._translateY = this.scrollListenerPositionY - this.refs.surface.scrollHeight;
|
|
166
91
|
}
|
|
167
92
|
},
|
|
168
93
|
})
|
|
@@ -178,31 +103,12 @@ export default CustomElement
|
|
|
178
103
|
},
|
|
179
104
|
},
|
|
180
105
|
})
|
|
181
|
-
.on({
|
|
182
|
-
connected() {
|
|
183
|
-
const { surface } = this.refs;
|
|
184
|
-
if (surface.offsetParent) {
|
|
185
|
-
this.startScrollListener(surface.offsetParent ?? window);
|
|
186
|
-
} else {
|
|
187
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
188
|
-
this.startScrollListener(surface.offsetParent ?? window);
|
|
189
|
-
resizeObserver.disconnect();
|
|
190
|
-
});
|
|
191
|
-
resizeObserver.observe(surface);
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
disconnected() {
|
|
195
|
-
this.clearScrollListener();
|
|
196
|
-
},
|
|
197
|
-
})
|
|
198
106
|
.css`
|
|
199
107
|
/* https://m3.material.io/components/bottom-app-bar/specs */
|
|
200
108
|
|
|
201
109
|
:host {
|
|
202
110
|
--mdw-bg: var(--mdw-color__surface);
|
|
203
111
|
--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
112
|
display: contents;
|
|
207
113
|
|
|
208
114
|
z-index:2;
|
|
@@ -210,7 +116,30 @@ export default CustomElement
|
|
|
210
116
|
|
|
211
117
|
#surface {
|
|
212
118
|
position: sticky;
|
|
213
|
-
inset-block-
|
|
119
|
+
inset-block-end: auto;
|
|
120
|
+
|
|
121
|
+
grid-area: app-bar;
|
|
122
|
+
|
|
123
|
+
margin: inherit; /** Pass through */
|
|
124
|
+
|
|
125
|
+
padding: inherit; /** Pass through */
|
|
126
|
+
|
|
127
|
+
filter: none; /* Never receive shadow */
|
|
128
|
+
|
|
129
|
+
transform: translateY(0);
|
|
130
|
+
|
|
131
|
+
z-index: 5;
|
|
132
|
+
|
|
133
|
+
background-color: rgb(var(--mdw-bg));
|
|
134
|
+
|
|
135
|
+
transition: grid-template-columns 100ms, background-color 100ms;
|
|
136
|
+
|
|
137
|
+
will-change: transform;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
#shape{
|
|
141
|
+
position: initial;
|
|
142
|
+
inset: initial;
|
|
214
143
|
|
|
215
144
|
display: grid;
|
|
216
145
|
|
|
@@ -223,8 +152,8 @@ export default CustomElement
|
|
|
223
152
|
overflow-y: visible;
|
|
224
153
|
|
|
225
154
|
box-sizing: border-box;
|
|
226
|
-
inline-size: 100
|
|
227
|
-
|
|
155
|
+
max-inline-size: calc(var(--mdw-content__max-width, 100%) + (2 * var(--mdw-content__padding, 16px) - 4px));
|
|
156
|
+
margin-inline: auto;
|
|
228
157
|
|
|
229
158
|
/* 16px from icon */
|
|
230
159
|
/* inset = (button.width / 2) - (icon.width / 2) */
|
|
@@ -232,26 +161,15 @@ export default CustomElement
|
|
|
232
161
|
/* paddingInlineStart = 16px - ((48px / 2) - (24px / 2)) */
|
|
233
162
|
/* paddingInlineEnd = 16px - ((48px / 2) - (30px / 2)) */
|
|
234
163
|
|
|
235
|
-
padding-inline:
|
|
164
|
+
padding-inline: calc(var(--mdw-content__padding, 16px) - 8px);
|
|
236
165
|
|
|
237
166
|
pointer-events: auto;
|
|
238
167
|
|
|
239
|
-
|
|
168
|
+
z-index: initial;
|
|
240
169
|
|
|
241
|
-
|
|
242
|
-
/* inset-inline: 0; */
|
|
170
|
+
background-color: transparent;
|
|
243
171
|
|
|
244
|
-
background-color: rgb(var(--mdw-bg));
|
|
245
172
|
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
173
|
}
|
|
256
174
|
|
|
257
175
|
#leading {
|
|
@@ -318,10 +236,10 @@ export default CustomElement
|
|
|
318
236
|
/* stylelint-disable-next-line declaration-property-value-disallowed-list */
|
|
319
237
|
margin-block-start: calc(28px - var(--mdw-typescale__headline-small__line-height));
|
|
320
238
|
padding-block-end: 20px;
|
|
321
|
-
|
|
322
239
|
padding-inline: 16px;
|
|
323
240
|
|
|
324
241
|
background-color: rgb(var(--mdw-bg));
|
|
242
|
+
|
|
325
243
|
box-shadow: none;
|
|
326
244
|
|
|
327
245
|
font: var(--mdw-typescale__headline-small__font);
|
|
@@ -385,16 +303,6 @@ export default CustomElement
|
|
|
385
303
|
}
|
|
386
304
|
}
|
|
387
305
|
|
|
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
306
|
#surface[size="small"] {
|
|
399
307
|
gap: 4px;
|
|
400
308
|
grid-template-columns: auto 1fr auto;
|
|
@@ -406,5 +314,15 @@ export default CustomElement
|
|
|
406
314
|
will-change: opacity;
|
|
407
315
|
}
|
|
408
316
|
|
|
317
|
+
#surface:where([color="none"], [color="transparent"]),
|
|
318
|
+
#companion:where([color="none"], [color="transparent"]) {
|
|
319
|
+
background-color: transparent;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
#surface[raised]:where([color="surface"],[color="none"],[color="transparent"]),
|
|
323
|
+
#companion[raised]:where([color="surface"],[color="none"],[color="transparent"]) {
|
|
324
|
+
background-color: rgb(var(--mdw-color__surface-container));
|
|
325
|
+
}
|
|
326
|
+
|
|
409
327
|
`
|
|
410
328
|
.autoRegister('mdw-top-app-bar');
|