@vollowx/seele 0.12.10 → 0.13.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/README.md +34 -58
- package/package.json +6 -5
- package/src/all.js +5 -0
- package/src/base/autocomplete.js +1 -4
- package/src/base/dialog.js +32 -0
- package/src/base/input.js +2 -40
- package/src/base/list.js +1 -1
- package/src/base/menu.js +1 -9
- package/src/base/select.js +1 -1
- package/src/base/slider.js +2 -23
- package/src/base/tabs.js +1 -5
- package/src/m3/autocomplete/autocomplete-styles.css.js +1 -1
- package/src/m3/autocomplete/autocomplete.js +1 -20
- package/src/m3/badge/badge-styles.css.js +1 -1
- package/src/m3/badge/badge.js +1 -6
- package/src/m3/button/common-button-styles.css.js +1 -1
- package/src/m3/button/common-button-toggle.js +1 -9
- package/src/m3/button/common-button.js +1 -7
- package/src/m3/button/icon-button-styles.css.js +1 -1
- package/src/m3/button/icon-button-toggle.js +1 -7
- package/src/m3/button/icon-button.js +1 -6
- package/src/m3/button/shared-button-styles.css.js +1 -1
- package/src/m3/button/shared-button-toggle-styles.css.js +1 -1
- package/src/m3/button-group/standard-button-group-styles.css.js +2 -0
- package/src/m3/button-group/standard-button-group.js +130 -0
- package/src/m3/checkbox/checkbox-styles.css.js +1 -1
- package/src/m3/checkbox/checkbox.js +2 -12
- package/src/m3/dialog/dialog-styles.css.js +2 -0
- package/src/m3/dialog/dialog.js +215 -0
- package/src/m3/divider/divider-styles.css.js +1 -1
- package/src/m3/fab/fab-styles.css.js +1 -1
- package/src/m3/fab/fab.js +1 -7
- package/src/m3/field/field-styles.css.js +1 -1
- package/src/m3/field/field.js +3 -16
- package/src/m3/field/filled-field-styles.css.js +1 -1
- package/src/m3/field/filled-field.js +1 -15
- package/src/m3/field/outlined-field-styles.css.js +1 -1
- package/src/m3/field/outlined-field.js +2 -18
- package/src/m3/focus-ring/focus-ring-styles.css.js +1 -1
- package/src/m3/item/item.js +1 -12
- package/src/m3/list/list-item.js +1 -18
- package/src/m3/loading-indicator/loading-indicator-styles.css.js +2 -0
- package/src/m3/loading-indicator/loading-indicator.js +320 -0
- package/src/m3/menu/menu-styles.css.js +1 -1
- package/src/m3/ripple/ripple-styles.css.js +1 -1
- package/src/m3/select/filled-select.js +1 -26
- package/src/m3/select/outlined-select.js +1 -26
- package/src/m3/select/select-styles.css.js +1 -1
- package/src/m3/select/select.js +1 -22
- package/src/m3/slider/slider-styles.css.js +1 -1
- package/src/m3/slider/slider.js +5 -38
- package/src/m3/switch/switch-styles.css.js +1 -1
- package/src/m3/switch/switch.js +3 -22
- package/src/m3/system/base.css +0 -1
- package/src/m3/system/typography.css +5 -5
- package/src/m3/tab/tab-styles.css.js +1 -1
- package/src/m3/tab/tab.js +1 -9
- package/src/m3/tab/tabs-styles.css.js +1 -1
- package/src/m3/tab/tabs.js +1 -4
- package/src/m3/text-field/filled-text-field.js +1 -12
- package/src/m3/text-field/outlined-text-field.js +1 -14
- package/src/m3/text-field/text-field-styles.css.js +1 -1
- package/src/m3/toolbar/toolbar-styles.css.js +1 -1
- package/src/m3/toolbar/toolbar.js +1 -8
- package/src/m3/tooltip/tooltip-styles.css.js +1 -1
- package/src/win98/button/button-styles.css.js +2 -0
- package/src/win98/button/button.js +19 -0
- package/src/m3/system/motion.css +0 -30
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate";
|
|
2
|
+
// Origin: https://github.com/brahmkshatriya/material-osc/blob/main/assets/loading-shape-morph-demo.html
|
|
3
|
+
import { LitElement, html } from 'lit';
|
|
4
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
5
|
+
import { InternalsAttached, internals } from '../../base/mixins/internals-attached.js';
|
|
6
|
+
import { loadingIndicatorStyles } from './loading-indicator-styles.css.js';
|
|
7
|
+
const STEP_MS = 650;
|
|
8
|
+
const FULL_ROTATION_MS = 4666;
|
|
9
|
+
const QUARTER_ROTATION = 90;
|
|
10
|
+
const TOTAL_POINTS = 240;
|
|
11
|
+
const CANVAS_SIZE = 640;
|
|
12
|
+
const RADIUS_BASE = CANVAS_SIZE / 2;
|
|
13
|
+
const CENTER = CANVAS_SIZE / 2;
|
|
14
|
+
export class M3LoadingIndicator extends InternalsAttached(LitElement) {
|
|
15
|
+
static{
|
|
16
|
+
this.styles = [
|
|
17
|
+
loadingIndicatorStyles
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
render() {
|
|
21
|
+
return html`<canvas width="${CANVAS_SIZE}" height="${CANVAS_SIZE}" aria-hidden="true"></canvas>`;
|
|
22
|
+
}
|
|
23
|
+
#ctx;
|
|
24
|
+
#animationFrame;
|
|
25
|
+
#startTime;
|
|
26
|
+
#color;
|
|
27
|
+
constructor(){
|
|
28
|
+
super(), this.contained = false, this.#animationFrame = 0, this.#startTime = 0, this.#color = '#ff0000', this.#animate = (now)=>{
|
|
29
|
+
if (this.#startTime === 0) {
|
|
30
|
+
this.#startTime = now;
|
|
31
|
+
}
|
|
32
|
+
const elapsed = now - this.#startTime;
|
|
33
|
+
const step = Math.floor(elapsed / STEP_MS);
|
|
34
|
+
const morphElapsed = elapsed % STEP_MS;
|
|
35
|
+
const progress = springProgress(morphElapsed);
|
|
36
|
+
const from = sampledSequence[step % sampledSequence.length];
|
|
37
|
+
const to = sampledSequence[(step + 1) % sampledSequence.length];
|
|
38
|
+
const stepRotation = step * QUARTER_ROTATION + progress * QUARTER_ROTATION;
|
|
39
|
+
const globalRotation = elapsed % FULL_ROTATION_MS / FULL_ROTATION_MS * 360;
|
|
40
|
+
this.#draw(from, to, progress, stepRotation + globalRotation, scalePulse(morphElapsed));
|
|
41
|
+
this.#animationFrame = requestAnimationFrame(this.#animate);
|
|
42
|
+
};
|
|
43
|
+
this[internals].role = 'progressbar';
|
|
44
|
+
this[internals].ariaValueMin = '0';
|
|
45
|
+
this[internals].ariaValueMax = '1';
|
|
46
|
+
}
|
|
47
|
+
firstUpdated() {
|
|
48
|
+
this.#ctx = this.$canvas.getContext('2d');
|
|
49
|
+
this.#cacheColors();
|
|
50
|
+
setInterval(this.#cacheColors.bind(this), 1000);
|
|
51
|
+
this.#animationFrame = requestAnimationFrame(this.#animate);
|
|
52
|
+
}
|
|
53
|
+
disconnectedCallback() {
|
|
54
|
+
super.disconnectedCallback();
|
|
55
|
+
cancelAnimationFrame(this.#animationFrame);
|
|
56
|
+
}
|
|
57
|
+
#cacheColors() {
|
|
58
|
+
const computed = getComputedStyle(this);
|
|
59
|
+
const color = computed.getPropertyValue(this.contained ? '--md-sys-color-on-primary-container' : '--md-sys-color-primary').trim();
|
|
60
|
+
if (color) this.#color = color;
|
|
61
|
+
}
|
|
62
|
+
#draw(from, to, progress, rotation, scale) {
|
|
63
|
+
if (!this.#ctx || !this.$canvas) return;
|
|
64
|
+
const ctx = this.#ctx;
|
|
65
|
+
ctx.clearRect(0, 0, this.$canvas.width, this.$canvas.height);
|
|
66
|
+
ctx.save();
|
|
67
|
+
ctx.translate(CENTER, CENTER);
|
|
68
|
+
ctx.scale(scale, scale);
|
|
69
|
+
ctx.rotate(rotation * Math.PI / 180);
|
|
70
|
+
ctx.translate(-CENTER, -CENTER);
|
|
71
|
+
ctx.beginPath();
|
|
72
|
+
from.points.forEach((point, i)=>{
|
|
73
|
+
const next = to.points[i];
|
|
74
|
+
const x = lerp(point.x, next.x, progress);
|
|
75
|
+
const y = lerp(point.y, next.y, progress);
|
|
76
|
+
if (i === 0) ctx.moveTo(x, y);
|
|
77
|
+
else ctx.lineTo(x, y);
|
|
78
|
+
});
|
|
79
|
+
ctx.closePath();
|
|
80
|
+
ctx.fillStyle = this.#color;
|
|
81
|
+
ctx.fill();
|
|
82
|
+
ctx.restore();
|
|
83
|
+
}
|
|
84
|
+
#animate;
|
|
85
|
+
}
|
|
86
|
+
_ts_decorate([
|
|
87
|
+
property({
|
|
88
|
+
type: Boolean,
|
|
89
|
+
reflect: true
|
|
90
|
+
})
|
|
91
|
+
], M3LoadingIndicator.prototype, "contained", void 0);
|
|
92
|
+
_ts_decorate([
|
|
93
|
+
query('canvas')
|
|
94
|
+
], M3LoadingIndicator.prototype, "$canvas", void 0);
|
|
95
|
+
M3LoadingIndicator = _ts_decorate([
|
|
96
|
+
customElement('md-loading')
|
|
97
|
+
], M3LoadingIndicator);
|
|
98
|
+
const lerp = (a, b, t)=>a + (b - a) * t;
|
|
99
|
+
const clamp = (v, lo, hi)=>Math.max(lo, Math.min(hi, v));
|
|
100
|
+
const dist = (a, b)=>Math.hypot(a.x - b.x, a.y - b.y);
|
|
101
|
+
const norm = (x, y, fallback = {
|
|
102
|
+
x: 1,
|
|
103
|
+
y: 0
|
|
104
|
+
})=>{
|
|
105
|
+
const len = Math.hypot(x, y);
|
|
106
|
+
return len < 1e-6 ? fallback : {
|
|
107
|
+
x: x / len,
|
|
108
|
+
y: y / len
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
const sequence = [
|
|
112
|
+
[
|
|
113
|
+
10,
|
|
114
|
+
0.85,
|
|
115
|
+
0.67,
|
|
116
|
+
0.75,
|
|
117
|
+
0.5
|
|
118
|
+
],
|
|
119
|
+
[
|
|
120
|
+
9,
|
|
121
|
+
0.85,
|
|
122
|
+
0.755,
|
|
123
|
+
0.8,
|
|
124
|
+
0.5
|
|
125
|
+
],
|
|
126
|
+
[
|
|
127
|
+
5,
|
|
128
|
+
0.85,
|
|
129
|
+
0.731,
|
|
130
|
+
0.45,
|
|
131
|
+
1
|
|
132
|
+
],
|
|
133
|
+
[
|
|
134
|
+
2,
|
|
135
|
+
0.85,
|
|
136
|
+
0.67,
|
|
137
|
+
0.8,
|
|
138
|
+
0.95
|
|
139
|
+
],
|
|
140
|
+
[
|
|
141
|
+
8,
|
|
142
|
+
0.85,
|
|
143
|
+
0.731,
|
|
144
|
+
0.6,
|
|
145
|
+
0.45
|
|
146
|
+
],
|
|
147
|
+
[
|
|
148
|
+
4,
|
|
149
|
+
0.925,
|
|
150
|
+
0.67,
|
|
151
|
+
1,
|
|
152
|
+
0.4
|
|
153
|
+
],
|
|
154
|
+
[
|
|
155
|
+
2,
|
|
156
|
+
0.9,
|
|
157
|
+
0.565,
|
|
158
|
+
0.8,
|
|
159
|
+
0.6
|
|
160
|
+
]
|
|
161
|
+
].map(([points, outerRadius, innerRadius, outerRoundness, innerRoundness])=>({
|
|
162
|
+
points,
|
|
163
|
+
outerRadius,
|
|
164
|
+
innerRadius,
|
|
165
|
+
outerRoundness,
|
|
166
|
+
innerRoundness
|
|
167
|
+
}));
|
|
168
|
+
function springProgress(ms) {
|
|
169
|
+
const t = ms / 1000;
|
|
170
|
+
const stiffness = 200;
|
|
171
|
+
const damping = 0.6;
|
|
172
|
+
const omega0 = Math.sqrt(stiffness);
|
|
173
|
+
const omegaD = omega0 * Math.sqrt(1 - damping * damping);
|
|
174
|
+
const displacement = Math.exp(-damping * omega0 * t) * (-Math.cos(omegaD * t) - damping * omega0 / omegaD * Math.sin(omegaD * t));
|
|
175
|
+
return clamp(1 + displacement, 0, 1);
|
|
176
|
+
}
|
|
177
|
+
function scalePulse(ms) {
|
|
178
|
+
const t = ms / STEP_MS;
|
|
179
|
+
const smooth = (p)=>p * p * (3 - 2 * p);
|
|
180
|
+
const outCubic = (p)=>1 - (1 - p) ** 3;
|
|
181
|
+
const segments = [
|
|
182
|
+
[
|
|
183
|
+
0,
|
|
184
|
+
0.14,
|
|
185
|
+
1,
|
|
186
|
+
0.985,
|
|
187
|
+
smooth
|
|
188
|
+
],
|
|
189
|
+
[
|
|
190
|
+
0.14,
|
|
191
|
+
0.46,
|
|
192
|
+
0.985,
|
|
193
|
+
1.04,
|
|
194
|
+
outCubic
|
|
195
|
+
],
|
|
196
|
+
[
|
|
197
|
+
0.46,
|
|
198
|
+
0.76,
|
|
199
|
+
1.04,
|
|
200
|
+
1,
|
|
201
|
+
smooth
|
|
202
|
+
]
|
|
203
|
+
];
|
|
204
|
+
const segment = segments.find(([start, end])=>t < end && t >= start);
|
|
205
|
+
if (!segment) return 1;
|
|
206
|
+
const [start, end, from, to, ease] = segment;
|
|
207
|
+
return lerp(from, to, ease((t - start) / (end - start)));
|
|
208
|
+
}
|
|
209
|
+
function starGeometry(shape) {
|
|
210
|
+
const points = Math.max(2, Math.floor(shape.points));
|
|
211
|
+
const count = points * 2;
|
|
212
|
+
const anchors = Array.from({
|
|
213
|
+
length: count
|
|
214
|
+
}, (_, i)=>{
|
|
215
|
+
const outer = i % 2 === 0;
|
|
216
|
+
const radius = (outer ? shape.outerRadius : shape.innerRadius) * RADIUS_BASE;
|
|
217
|
+
const angle = i * Math.PI / points;
|
|
218
|
+
return {
|
|
219
|
+
x: CENTER + Math.cos(angle) * radius,
|
|
220
|
+
y: CENTER + Math.sin(angle) * radius,
|
|
221
|
+
outer
|
|
222
|
+
};
|
|
223
|
+
});
|
|
224
|
+
const tangents = anchors.map((_, i)=>{
|
|
225
|
+
const prev = anchors[(i - 1 + count) % count];
|
|
226
|
+
const next = anchors[(i + 1) % count];
|
|
227
|
+
return norm(next.x - prev.x, next.y - prev.y);
|
|
228
|
+
});
|
|
229
|
+
const lengths = anchors.map((anchor, i)=>{
|
|
230
|
+
const prev = anchors[(i - 1 + count) % count];
|
|
231
|
+
const next = anchors[(i + 1) % count];
|
|
232
|
+
const roundness = anchor.outer ? shape.outerRoundness : shape.innerRoundness;
|
|
233
|
+
return Math.max(0, roundness) * Math.min(dist(anchor, prev), dist(anchor, next)) * 0.5;
|
|
234
|
+
});
|
|
235
|
+
const handles = anchors.map((anchor, i)=>{
|
|
236
|
+
const tangent = tangents[i];
|
|
237
|
+
const length = lengths[i];
|
|
238
|
+
return {
|
|
239
|
+
in: {
|
|
240
|
+
x: anchor.x - tangent.x * length,
|
|
241
|
+
y: anchor.y - tangent.y * length
|
|
242
|
+
},
|
|
243
|
+
out: {
|
|
244
|
+
x: anchor.x + tangent.x * length,
|
|
245
|
+
y: anchor.y + tangent.y * length
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
});
|
|
249
|
+
return {
|
|
250
|
+
anchors,
|
|
251
|
+
handles
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
function cubic(p0, c1, c2, p1, t) {
|
|
255
|
+
const inv = 1 - t;
|
|
256
|
+
return {
|
|
257
|
+
x: inv ** 3 * p0.x + 3 * inv * inv * t * c1.x + 3 * inv * t * t * c2.x + t ** 3 * p1.x,
|
|
258
|
+
y: inv ** 3 * p0.y + 3 * inv * inv * t * c1.y + 3 * inv * t * t * c2.y + t ** 3 * p1.y
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
function resample(points) {
|
|
262
|
+
const lengths = points.map((point, i)=>dist(point, points[(i + 1) % points.length]));
|
|
263
|
+
const perimeter = lengths.reduce((sum, length)=>sum + length, 0);
|
|
264
|
+
const sampled = [];
|
|
265
|
+
let edge = 0;
|
|
266
|
+
let consumed = 0;
|
|
267
|
+
for(let i = 0; i < TOTAL_POINTS; i++){
|
|
268
|
+
const target = perimeter * i / TOTAL_POINTS;
|
|
269
|
+
while(consumed + lengths[edge] < target && edge < lengths.length - 1){
|
|
270
|
+
consumed += lengths[edge++];
|
|
271
|
+
}
|
|
272
|
+
const point = points[edge];
|
|
273
|
+
const next = points[(edge + 1) % points.length];
|
|
274
|
+
const t = (target - consumed) / (lengths[edge] || 1);
|
|
275
|
+
sampled.push({
|
|
276
|
+
x: lerp(point.x, next.x, t),
|
|
277
|
+
y: lerp(point.y, next.y, t)
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
return sampled;
|
|
281
|
+
}
|
|
282
|
+
function sampleShape(shape) {
|
|
283
|
+
const { anchors, handles } = starGeometry(shape);
|
|
284
|
+
const dense = [];
|
|
285
|
+
anchors.forEach((anchor, i)=>{
|
|
286
|
+
const next = (i + 1) % anchors.length;
|
|
287
|
+
for(let step = 0; step < 18; step++){
|
|
288
|
+
dense.push(cubic(anchor, handles[i].out, handles[next].in, anchors[next], step / 18));
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
return {
|
|
292
|
+
points: resample(dense)
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
function shifted(points, offset) {
|
|
296
|
+
return points.map((_, i)=>points[(i + offset) % points.length]);
|
|
297
|
+
}
|
|
298
|
+
function alignTo(from, to) {
|
|
299
|
+
let bestOffset = 0;
|
|
300
|
+
let bestScore = Infinity;
|
|
301
|
+
for(let offset = 0; offset < to.points.length; offset++){
|
|
302
|
+
let score = 0;
|
|
303
|
+
for(let i = 0; i < from.points.length; i += 4){
|
|
304
|
+
const point = to.points[(i + offset) % to.points.length];
|
|
305
|
+
score += (from.points[i].x - point.x) ** 2 + (from.points[i].y - point.y) ** 2;
|
|
306
|
+
}
|
|
307
|
+
if (score < bestScore) {
|
|
308
|
+
bestScore = score;
|
|
309
|
+
bestOffset = offset;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return {
|
|
313
|
+
...to,
|
|
314
|
+
points: shifted(to.points, bestOffset)
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
const sampledSequence = sequence.map(sampleShape).reduce((aligned, shape)=>{
|
|
318
|
+
aligned.push(aligned.length ? alignTo(aligned.at(-1), shape) : shape);
|
|
319
|
+
return aligned;
|
|
320
|
+
}, []);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const menuStyles = css`:host{min-width:112px;display:contents}[part=menu]{background:var(--md-sys-color-surface-container);box-shadow:var(--md-sys-elevation-shadow-2);box-sizing:border-box;color:var(--md-sys-color-on-surface);height:inherit;max-height:var(--md-menu-max-height,inherit);max-width:inherit;min-width:inherit;opacity:0;-webkit-user-select:none;user-select:none;z-index:1000;border-radius:16px;outline:0;padding:4px;position:absolute;inset:auto;overflow-y:auto;transform:scaleY(.35)}:host([color=vibrant]){
|
|
2
|
+
export const menuStyles = css`:host{min-width:112px;display:contents}[part=menu]{background:var(--md-sys-color-surface-container);box-shadow:var(--md-sys-elevation-shadow-2);box-sizing:border-box;color:var(--md-sys-color-on-surface);height:inherit;max-height:var(--md-menu-max-height,inherit);max-width:inherit;min-width:inherit;opacity:0;-webkit-user-select:none;user-select:none;z-index:1000;border-radius:16px;outline:0;padding:4px;position:absolute;inset:auto;overflow-y:auto;transform:scaleY(.35)}:host([color=vibrant]){--md-item-supporting-text-color:var(--md-sys-color-on-tertiary-container);background-color:var(--md-sys-color-tertiary-container);color:var(--md-sys-color-on-tertiary-container)}& ::slotted([selected]){--md-item-supporting-text-color:var(--md-sys-color-on-tertiary);background-color:var(--md-sys-color-tertiary);color:var(--md-sys-color-on-tertiary)}[part=items]{opacity:0;flex-direction:column;gap:2px;display:flex}:host(:state(closed)) [part=menu]{display:none}:host(:state(opening)){transition:opacity 67ms,transform var(--md-sys-motion-spatial-default-duration) var(--md-sys-motion-spatial-default);display:block;transform:scaleY(1)}& [part=items]{opacity:1;transition:opacity 67ms linear 67ms}& [part=items]{opacity:1}& [part=items]{opacity:0;transition:opacity 67ms}`;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const rippleStyles = css`:host{border-radius:inherit;pointer-events:none;display:block;position:absolute;inset:0;overflow:hidden}[part~=ripple]{background-image:radial-gradient(closest-side,
|
|
2
|
+
export const rippleStyles = css`:host{border-radius:inherit;pointer-events:none;display:block;position:absolute;inset:0;overflow:hidden}[part~=ripple]{background-image:radial-gradient(closest-side,var(--md-ripple-color,currentColor) max(calc(100% - 70px),65%),transparent 100%);position:absolute;top:0;left:0}:host:before{background-color:var(--md-ripple-color,currentColor);border-radius:inherit;content:"";opacity:0;transition:opacity 67ms linear;display:block;position:absolute;inset:0}:host(:state(hover)):before{opacity:.08}`;
|
|
@@ -11,32 +11,7 @@ export class MdFilledSelect extends M3Select {
|
|
|
11
11
|
];
|
|
12
12
|
}
|
|
13
13
|
renderField() {
|
|
14
|
-
return html
|
|
15
|
-
<md-filled-field
|
|
16
|
-
id="field"
|
|
17
|
-
part="field"
|
|
18
|
-
.label=${this.label}
|
|
19
|
-
.populated=${!!this.value}
|
|
20
|
-
.disabled=${this.disabled}
|
|
21
|
-
.required=${this.required}
|
|
22
|
-
.error=${this.error}
|
|
23
|
-
.focused=${this.open || this.focused}
|
|
24
|
-
supportingtext=${this.supportingText}
|
|
25
|
-
@click=${this.toggle}
|
|
26
|
-
@keydown=${this._handleFieldKeydown}
|
|
27
|
-
@focus=${()=>this.focused = true}
|
|
28
|
-
@blur=${()=>this.focused = false}
|
|
29
|
-
tabindex=${this.disabled ? '-1' : '0'}
|
|
30
|
-
role="combobox"
|
|
31
|
-
aria-haspopup="listbox"
|
|
32
|
-
aria-expanded=${this.open}
|
|
33
|
-
aria-controls="menu"
|
|
34
|
-
aria-disabled=${this.disabled}
|
|
35
|
-
aria-required=${this.required}
|
|
36
|
-
>
|
|
37
|
-
${this.renderFieldContent()}
|
|
38
|
-
</md-filled-field>
|
|
39
|
-
`;
|
|
14
|
+
return html`<md-filled-field id="field" part="field" .label="${this.label}" .populated="${!!this.value}" .disabled="${this.disabled}" .required="${this.required}" .error="${this.error}" .focused="${this.open || this.focused}" supportingtext="${this.supportingText}" @click="${this.toggle}" @keydown="${this._handleFieldKeydown}" @focus="${()=>this.focused = true}" @blur="${()=>this.focused = false}" tabindex="${this.disabled ? '-1' : '0'}" role="combobox" aria-haspopup="listbox" aria-expanded="${this.open}" aria-controls="menu" aria-disabled="${this.disabled}" aria-required="${this.required}">${this.renderFieldContent()}</md-filled-field>`;
|
|
40
15
|
}
|
|
41
16
|
}
|
|
42
17
|
MdFilledSelect = _ts_decorate([
|
|
@@ -11,32 +11,7 @@ export class MdOutlinedSelect extends M3Select {
|
|
|
11
11
|
];
|
|
12
12
|
}
|
|
13
13
|
renderField() {
|
|
14
|
-
return html
|
|
15
|
-
<md-outlined-field
|
|
16
|
-
id="field"
|
|
17
|
-
part="field"
|
|
18
|
-
.label=${this.label}
|
|
19
|
-
.populated=${!!this.value}
|
|
20
|
-
.disabled=${this.disabled}
|
|
21
|
-
.required=${this.required}
|
|
22
|
-
.error=${this.error}
|
|
23
|
-
.focused=${this.open || this.focused}
|
|
24
|
-
supportingtext=${this.supportingText}
|
|
25
|
-
@click=${this.toggle}
|
|
26
|
-
@keydown=${this._handleFieldKeydown}
|
|
27
|
-
@focus=${()=>this.focused = true}
|
|
28
|
-
@blur=${()=>this.focused = false}
|
|
29
|
-
tabindex=${this.disabled ? '-1' : '0'}
|
|
30
|
-
role="combobox"
|
|
31
|
-
aria-haspopup="listbox"
|
|
32
|
-
aria-expanded=${this.open}
|
|
33
|
-
aria-controls="menu"
|
|
34
|
-
aria-disabled=${this.disabled}
|
|
35
|
-
aria-required=${this.required}
|
|
36
|
-
>
|
|
37
|
-
${this.renderFieldContent()}
|
|
38
|
-
</md-outlined-field>
|
|
39
|
-
`;
|
|
14
|
+
return html`<md-outlined-field id="field" part="field" .label="${this.label}" .populated="${!!this.value}" .disabled="${this.disabled}" .required="${this.required}" .error="${this.error}" .focused="${this.open || this.focused}" supportingtext="${this.supportingText}" @click="${this.toggle}" @keydown="${this._handleFieldKeydown}" @focus="${()=>this.focused = true}" @blur="${()=>this.focused = false}" tabindex="${this.disabled ? '-1' : '0'}" role="combobox" aria-haspopup="listbox" aria-expanded="${this.open}" aria-controls="menu" aria-disabled="${this.disabled}" aria-required="${this.required}">${this.renderFieldContent()}</md-outlined-field>`;
|
|
40
15
|
}
|
|
41
16
|
}
|
|
42
17
|
MdOutlinedSelect = _ts_decorate([
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const selectStyles = css`:host{-webkit-user-select:none;user-select:none;min-width:210px;display:inline-block;position:relative}[part=field]{cursor:pointer;outline:
|
|
2
|
+
export const selectStyles = css`:host{-webkit-user-select:none;user-select:none;min-width:210px;display:inline-block;position:relative}[part=field]{cursor:pointer;outline:0;width:100%}[part=value]{font:var(--md-sys-typography-body-large);height:1.5em}[part=menu]{--md-menu-max-height:300px;min-width:100%}`;
|
package/src/m3/select/select.js
CHANGED
|
@@ -7,28 +7,7 @@ import { Select } from '../../base/select.js';
|
|
|
7
7
|
* @fires {Event} input - Fired when the selected value has changed.
|
|
8
8
|
*/ export class M3Select extends Select {
|
|
9
9
|
renderMenu() {
|
|
10
|
-
return html
|
|
11
|
-
<md-menu
|
|
12
|
-
part="menu"
|
|
13
|
-
id="menu"
|
|
14
|
-
for="field"
|
|
15
|
-
type="listbox"
|
|
16
|
-
data-tabindex="-1"
|
|
17
|
-
?quick="${this.quick}"
|
|
18
|
-
offset="${this.offset}"
|
|
19
|
-
align="${this.align}"
|
|
20
|
-
align-strategy="${this.alignStrategy}"
|
|
21
|
-
keep-open-blur
|
|
22
|
-
no-focus-control
|
|
23
|
-
?open="${this.open}"
|
|
24
|
-
@open="${()=>this.open = true}"
|
|
25
|
-
@close="${()=>this.open = false}"
|
|
26
|
-
@item-focus="${this._handleMenuItemFocus}"
|
|
27
|
-
@select="${this._handleMenuSelect}"
|
|
28
|
-
>
|
|
29
|
-
<slot part="items" @slotchange=${this._handleSlotChange}></slot>
|
|
30
|
-
</md-menu>
|
|
31
|
-
`;
|
|
10
|
+
return html`<md-menu part="menu" id="menu" for="field" type="listbox" data-tabindex="-1" ?quick="${this.quick}" offset="${this.offset}" align="${this.align}" align-strategy="${this.alignStrategy}" keep-open-blur no-focus-control ?open="${this.open}" @open="${()=>this.open = true}" @close="${()=>this.open = false}" @item-focus="${this._handleMenuItemFocus}" @select="${this._handleMenuSelect}"><slot part="items" @slotchange="${this._handleSlotChange}"></slot></md-menu>`;
|
|
32
11
|
}
|
|
33
12
|
constructor(...args){
|
|
34
13
|
super(...args), this.label = '', this.supportingText = '', this.focused = false;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const sliderStyles = css`:host{--_target-size:48px;--_half-target:calc(var(--_target-size) / 2);--_handle-width-start:var(--md-slider-handle-width,4px);--_handle-width-end:var(--md-slider-handle-width,4px);--_handle-height:var(--md-slider-handle-height,44px);--_handle-shape:var(--md-slider-handle-shape,20px);--_handle-margin:6px;--_tick-size:var(--md-slider-tick-size,2px);--_track-shape:8px;--_track-height:var(--md-slider-track-height,16px);vertical-align:middle;min-inline-size:200px;display:inline-flex}md-focus-ring{width:16px;height:56px;inset:unset}:host([disabled]){opacity:.38}:host([disabled]) input{cursor:default;pointer-events:none}.container{--_start-px:calc(100% * var(--_start));--_end-px:calc(100% * var(--_end));--_inv-start-px:calc(100% * (1 - var(--_start)));--_inv-end-px:calc(100% * (1 - var(--_end)));--_mask-offset-start:calc(var(--_handle-width-start) / 2 + var(--_handle-margin));--_mask-offset-end:calc(var(--_handle-width-end) / 2 + var(--_handle-margin));--_cut-start:calc(var(--_start-px) + var(--_mask-offset-start));--_cut-end:calc(var(--_inv-end-px) + var(--_mask-offset-end));--_cut-inv-start:calc(var(--_inv-start-px) + var(--_mask-offset-start));--_cut-inv-end:calc(var(--_end-px) + var(--_mask-offset-end));block-size:var(--_target-size);pointer-events:none;touch-action:none;user-select:none;flex:1;align-items:center;display:flex;position:relative}.track
|
|
2
|
+
export const sliderStyles = css`:host{--_target-size:48px;--_half-target:calc(var(--_target-size) / 2);--_handle-width-start:var(--md-slider-handle-width,4px);--_handle-width-end:var(--md-slider-handle-width,4px);--_handle-height:var(--md-slider-handle-height,44px);--_handle-shape:var(--md-slider-handle-shape,20px);--_handle-margin:6px;--_tick-size:var(--md-slider-tick-size,2px);--_track-shape:8px;--_track-height:var(--md-slider-track-height,16px);vertical-align:middle;min-inline-size:200px;display:inline-flex}md-focus-ring{width:16px;height:56px;inset:unset}:host([disabled]){opacity:.38}:host([disabled]) input{cursor:default;pointer-events:none}.container{--_start-px:calc(100% * var(--_start));--_end-px:calc(100% * var(--_end));--_inv-start-px:calc(100% * (1 - var(--_start)));--_inv-end-px:calc(100% * (1 - var(--_end)));--_mask-offset-start:calc(var(--_handle-width-start) / 2 + var(--_handle-margin));--_mask-offset-end:calc(var(--_handle-width-end) / 2 + var(--_handle-margin));--_cut-start:calc(var(--_start-px) + var(--_mask-offset-start));--_cut-end:calc(var(--_inv-end-px) + var(--_mask-offset-end));--_cut-inv-start:calc(var(--_inv-start-px) + var(--_mask-offset-start));--_cut-inv-end:calc(var(--_end-px) + var(--_mask-offset-end));block-size:var(--_target-size);pointer-events:none;touch-action:none;user-select:none;flex:1;align-items:center;display:flex;position:relative}.tickmarks,.track{block-size:var(--_track-height);align-items:center;display:flex;position:absolute;inset-inline:0}.tickmarks div,.track div{inset:0 calc(var(--_target-size)/ 2);position:absolute}.track div{border-radius:var(--_track-shape)}.track .inactive-after,.track .inactive-before{background:var(--md-sys-color-secondary-container)}.track .active{background:var(--md-sys-color-primary)}:host([disabled]) .track .inactive-after,:host([disabled]) .track .inactive-before{background:var(--md-sys-color-on-surface);opacity:.315789}:host([disabled]) .track .active{background:var(--md-sys-color-on-surface)}.tickmarks div{--_tick-color:var(--md-sys-color-on-secondary-container);background-size:calc((100% - var(--_tick-size) * 2)/ var(--_ticks)) 100%;background-image:radial-gradient(circle at var(--_tick-size) center,var(--_tick-color) 0,var(--_tick-color) calc(var(--_tick-size)/ 2),transparent calc(var(--_tick-size)/ 2))}.tickmarks .active{--_tick-color:var(--md-sys-color-on-primary)}:host([disabled]) .tickmarks div{--_tick-color:var(--md-sys-color-on-surface)}:host([disabled]) .tickmarks .active{--_tick-color:var(--md-sys-color-inverse-on-surface)}.inactive-before{clip-path:inset(0 var(--_cut-inv-start) 0 0 round 2px)}.inactive-after{clip-path:inset(0 0 0 var(--_cut-inv-end) round 2px)}.active{clip-path:inset(0 var(--_cut-end) 0 0 round 2px)}.ranged .active{clip-path:inset(0 var(--_cut-end) 0 var(--_cut-start) round 2px)}:host(:dir(rtl)) .inactive-before{clip-path:inset(0 0 0 var(--_cut-inv-start) round 2px)}:host(:dir(rtl)) .inactive-after{clip-path:inset(0 var(--_cut-inv-end) 0 0 round 2px)}:host(:dir(rtl)) .active{clip-path:inset(0 0 0 var(--_cut-end) round 2px)}:host(:dir(rtl)) .ranged .active{clip-path:inset(0 var(--_cut-start) 0 var(--_cut-end) round 2px)}.handles-padded{block-size:100%;inline-size:100%;padding-inline:calc(var(--_target-size)/ 2);box-sizing:border-box;position:absolute;inset:0}.handles{block-size:100%;inline-size:100%;inline-size:calc(var(--_end-px) - var(--_start-px));position:relative;inset-block:0;inset-inline-start:var(--_start-px)}.handle{--md-ripple-color:var(--md-sys-color-primary);block-size:var(--_target-size);inline-size:var(--_target-size);border-radius:var(--_handle-shape);place-content:center;place-items:center;display:flex;position:absolute}.handle.start{inset-inline-start:calc(0px - var(--_half-target))}.handle.end{inset-inline-end:calc(0px - var(--_half-target))}.nub{height:var(--_handle-height);width:var(--_handle-width-end);border-radius:var(--_handle-shape);background:var(--md-sys-color-primary);transition:width var(--md-sys-motion-effects-fast-duration) var(--md-sys-motion-effects-fast);position:absolute}.start .nub{width:var(--_handle-width-start)}:host([disabled]) .nub{background:var(--md-sys-color-on-surface)}.onTop.isOverlapping .nub{border:1px solid var(--md-sys-color-surface)}.label{box-sizing:border-box;color:var(--md-sys-color-inverse-on-surface);background:var(--md-sys-color-inverse-surface);font:var(--md-sys-typography-label-large);opacity:0;border-radius:9999px;place-content:center;place-items:center;min-block-size:44px;min-inline-size:48px;padding:0 16px;transition:opacity 67ms linear;display:flex;position:absolute;inset-block-end:100%;transform:translateY(-2px)}:host(:not(:disabled)) :where(:has(input:active)) .label,:host(:not(:disabled)) :where(:has(input:focus-visible)) .label{opacity:1}@media (hover:hover) and (pointer:fine){:host(:not(:disabled)) :where(:has(input:hover)) .label{opacity:1}}input[type=range]{opacity:0;-webkit-tap-highlight-color:transparent;box-sizing:border-box;cursor:pointer;pointer-events:auto;appearance:none;width:100%;height:100%;margin:0;position:absolute}input[type=range]:focus{outline:0}:host(:not([disabled])) :has(input.start:active){--_handle-width-start:2px}:host(:not([disabled])) :has(input.end:active){--_handle-width-end:2px}::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;block-size:var(--_target-size);inline-size:var(--_target-size);opacity:0;z-index:2}::-moz-range-thumb{appearance:none;block-size:var(--_target-size);inline-size:var(--_target-size);opacity:0;z-index:2;transform:scaleX(0)}.ranged input{--track-len:calc(100% - var(--_target-size));--mid-frac:calc(var(--_start) + ((var(--_end) - var(--_start)) / 2));--clip-px:calc(var(--_half-target) + var(--track-len) * var(--mid-frac))}.ranged input.start{clip-path:inset(0 calc(100% - var(--clip-px)) 0 0)}.ranged input.end{clip-path:inset(0 0 0 var(--clip-px))}.ranged input.start:dir(rtl){clip-path:inset(0 0 0 calc(100% - var(--clip-px)))}.ranged input.end:dir(rtl){clip-path:inset(0 var(--clip-px) 0 0)}.onTop{z-index:1}`;
|
package/src/m3/slider/slider.js
CHANGED
|
@@ -52,56 +52,23 @@ export class M3Slider extends Slider {
|
|
|
52
52
|
start: false,
|
|
53
53
|
label: labelEnd
|
|
54
54
|
};
|
|
55
|
-
return html
|
|
56
|
-
class="container ${classMap(containerClasses)}"
|
|
57
|
-
style=${styleMap(containerStyles)}
|
|
58
|
-
>
|
|
59
|
-
${when(this.range, ()=>this.renderInput(inputStartProps))}
|
|
60
|
-
${this.renderInput(inputEndProps)} ${this.renderTrack()}
|
|
61
|
-
<div class="handles-padded">
|
|
62
|
-
<div class="handles">
|
|
63
|
-
${when(this.range, ()=>this.renderHandle(handleStartProps))}
|
|
64
|
-
${this.renderHandle(handleEndProps)}
|
|
65
|
-
</div>
|
|
66
|
-
</div>
|
|
67
|
-
</div>`;
|
|
55
|
+
return html`<div class="container ${classMap(containerClasses)}" style="${styleMap(containerStyles)}">${when(this.range, ()=>this.renderInput(inputStartProps))} ${this.renderInput(inputEndProps)} ${this.renderTrack()}<div class="handles-padded"><div class="handles">${when(this.range, ()=>this.renderHandle(handleStartProps))} ${this.renderHandle(handleEndProps)}</div></div></div>`;
|
|
68
56
|
}
|
|
69
57
|
renderTrack() {
|
|
70
|
-
return html
|
|
71
|
-
<div class="track">
|
|
72
|
-
<div class="inactive-before"></div>
|
|
73
|
-
<div class="active"></div>
|
|
74
|
-
<div class="inactive-after"></div>
|
|
75
|
-
</div>
|
|
76
|
-
${this.ticks ? html`
|
|
77
|
-
<div class="tickmarks">
|
|
78
|
-
<div class="inactive-before"></div>
|
|
79
|
-
<div class="active"></div>
|
|
80
|
-
<div class="inactive-after"></div>
|
|
81
|
-
</div>
|
|
82
|
-
` : nothing}
|
|
83
|
-
`;
|
|
58
|
+
return html`<div class="track"><div class="inactive-before"></div><div class="active"></div><div class="inactive-after"></div></div>${this.ticks ? html`<div class="tickmarks"><div class="inactive-before"></div><div class="active"></div><div class="inactive-after"></div></div>` : nothing}`;
|
|
84
59
|
}
|
|
85
60
|
renderLabel(value) {
|
|
86
|
-
return html`<div class="label" aria-hidden="true"
|
|
87
|
-
<span part="label">${value}</span>
|
|
88
|
-
</div>`;
|
|
61
|
+
return html`<div class="label" aria-hidden="true"><span part="label">${value}</span></div>`;
|
|
89
62
|
}
|
|
90
63
|
renderHandle({ start, label }) {
|
|
91
64
|
const onTop = !this.disabled && start === this.startOnTop;
|
|
92
65
|
const isOverlapping = !this.disabled && this.handlesOverlapping;
|
|
93
66
|
const name = start ? 'start' : 'end';
|
|
94
|
-
return html`<div
|
|
95
|
-
class="handle ${classMap({
|
|
67
|
+
return html`<div class="handle ${classMap({
|
|
96
68
|
[name]: true,
|
|
97
69
|
onTop,
|
|
98
70
|
isOverlapping
|
|
99
|
-
})}"
|
|
100
|
-
>
|
|
101
|
-
<md-focus-ring part="focus-ring" for=${name}></md-focus-ring>
|
|
102
|
-
<div class="nub"></div>
|
|
103
|
-
${when(this.labeled, ()=>this.renderLabel(label))}
|
|
104
|
-
</div>`;
|
|
71
|
+
})}"><md-focus-ring part="focus-ring" for="${name}"></md-focus-ring><div class="nub"></div>${when(this.labeled, ()=>this.renderLabel(label))}</div>`;
|
|
105
72
|
}
|
|
106
73
|
}
|
|
107
74
|
M3Slider = _ts_decorate([
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const switchStyles = css`:host{--_outline-color:var(--md-sys-color-outline);--_track-color:var(--md-sys-color-surface-container-highest);--_thumb-color:var(--md-sys-color-outline);--_icon-color:var(--md-sys-color-surface-container-highest);--_ripple-color:var(--md-sys-color-on-surface);background-color:color-mix(in srgb,
|
|
2
|
+
export const switchStyles = css`:host{--_outline-color:var(--md-sys-color-outline);--_track-color:var(--md-sys-color-surface-container-highest);--_thumb-color:var(--md-sys-color-outline);--_icon-color:var(--md-sys-color-surface-container-highest);--_ripple-color:var(--md-sys-color-on-surface);background-color:color-mix(in srgb,var(--_track-color) var(--_track-opacity,100%),transparent);border-color:color-mix(in srgb,var(--_outline-color) var(--_outline-opacity,100%),transparent);box-sizing:border-box;cursor:pointer;-webkit-tap-highlight-color:transparent;touch-action:none;height:32px;transition:background-color var(--md-sys-motion-effects-fast-duration) var(--md-sys-motion-effects-fast),border-color var(--md-sys-motion-effects-fast-duration) var(--md-sys-motion-effects-fast);-webkit-user-select:none;user-select:none;vertical-align:top;border-style:solid;border-width:2px;border-radius:9999px;outline:0;place-content:center;place-items:center;width:52px;display:inline-grid;position:relative}:host(:state(checked)){--_outline-color:var(--md-sys-color-primary);--_track-color:var(--md-sys-color-primary);--_thumb-color:var(--md-sys-color-on-primary);--_icon-color:var(--md-sys-color-on-primary-container);--_ripple-color:var(--md-sys-color-primary)}:host(:disabled){--_outline-color:var(--md-sys-color-on-surface);--_outline-opacity:12%;--_track-color:var(--md-sys-color-surface-variant);--_track-opacity:12%;--_thumb-color:var(--md-sys-color-on-surface);--_thumb-opacity:38%;--_icon-color:var(--md-sys-color-surface-container-highest);cursor:default;pointer-events:none}:host(:disabled:state(checked)){--_outline-color:var(--md-sys-color-surface);--_track-color:var(--md-sys-color-on-surface);--_thumb-color:var(--md-sys-color-surface);--_thumb-opacity:100%;--_icon-color:var(--md-sys-color-on-surface)}:host([icons]:not(:state(checked)):not([checkedicononly])) [part~=icon-off],:host([icons]:state(checked)) [part~=icon-on]{--_icon-opacity:100%}:host([icons]:state(checked):disabled) [part~=icon-on]{--_icon-opacity:38%}@media (hover:hover) and (pointer:fine){:host(:hover){--_thumb-color:var(--md-sys-color-on-surface-variant)}:host(:state(checked):hover){--_thumb-color:var(--md-sys-color-primary-container)}}@media (forced-colors:active){:host{forced-color-adjust:none}}[part~=thumb]{--_thumb-diameter:16px;--_thumb-diff-default:20px;background-color:color-mix(in srgb,var(--_thumb-color) var(--_thumb-opacity,100%),transparent);height:var(--_thumb-diameter);transition:background-color var(--md-sys-motion-effects-fast-duration) var(--md-sys-motion-effects-fast),width var(--md-sys-motion-spatial-fast-duration) var(--md-sys-motion-spatial-fast),height var(--md-sys-motion-spatial-fast-duration) var(--md-sys-motion-spatial-fast),margin var(--md-sys-motion-spatial-fast-duration) var(--md-sys-motion-spatial-fast);width:var(--_thumb-diameter);z-index:1;border-radius:50%;place-content:center;place-items:center;margin-inline-start:calc(var(--_thumb-diff-pointer,0px) - var(--_thumb-diff-default));display:grid;position:absolute}:host(:state(checked)) [part~=thumb]{--_thumb-diameter:24px;--_thumb-diff-default:-20px;background-color:var(--_thumb-color)}:host([icons]:not([checkedicononly])) [part~=thumb]{--_thumb-diameter:24px}:host(:active) [part~=thumb]{--_thumb-color:var(--md-sys-color-on-surface-variant);--_thumb-diameter:28px!important}:host(:state(checked):active) [part~=thumb]{--_thumb-color:var(--md-sys-color-primary-container)}[part~=icons]{fill:color-mix(in srgb,var(--_icon-color) var(--_icon-opacity,0),transparent);width:16px;height:16px;transition:fill 67ms linear;position:absolute}md-focus-ring{inset:-4px}md-ripple{color:var(--_ripple-color);height:40px;inset:unset;width:40px}`;
|
package/src/m3/switch/switch.js
CHANGED
|
@@ -16,32 +16,13 @@ export class M3Switch extends ToggleButton {
|
|
|
16
16
|
];
|
|
17
17
|
}
|
|
18
18
|
render() {
|
|
19
|
-
return html
|
|
20
|
-
<md-focus-ring></md-focus-ring>
|
|
21
|
-
<div part="thumb">
|
|
22
|
-
<md-ripple spacebehavior="always"></md-ripple>
|
|
23
|
-
<span part="target"></span>
|
|
24
|
-
${this.renderOffIcon()}${this.renderOnIcon()}
|
|
25
|
-
</div>
|
|
26
|
-
`;
|
|
19
|
+
return html`<md-focus-ring></md-focus-ring><div part="thumb"><md-ripple spacebehavior="always"></md-ripple><span part="target"></span> ${this.renderOffIcon()}${this.renderOnIcon()}</div>`;
|
|
27
20
|
}
|
|
28
21
|
renderOnIcon() {
|
|
29
|
-
return html
|
|
30
|
-
<svg part="icons icon-on" viewBox="0 0 24 24" aria-hidden="true">
|
|
31
|
-
<path
|
|
32
|
-
d="M9.55 18.2 3.65 12.3 5.275 10.675 9.55 14.95 18.725 5.775 20.35 7.4Z"
|
|
33
|
-
/>
|
|
34
|
-
</svg>
|
|
35
|
-
`;
|
|
22
|
+
return html`<svg part="icons icon-on" viewBox="0 0 24 24" aria-hidden="true"><path d="M9.55 18.2 3.65 12.3 5.275 10.675 9.55 14.95 18.725 5.775 20.35 7.4Z"/></svg>`;
|
|
36
23
|
}
|
|
37
24
|
renderOffIcon() {
|
|
38
|
-
return html
|
|
39
|
-
<svg part="icons icon-off" viewBox="0 0 24 24" aria-hidden="true">
|
|
40
|
-
<path
|
|
41
|
-
d="M6.4 19.2 4.8 17.6 10.4 12 4.8 6.4 6.4 4.8 12 10.4 17.6 4.8 19.2 6.4 13.6 12 19.2 17.6 17.6 19.2 12 13.6Z"
|
|
42
|
-
/>
|
|
43
|
-
</svg>
|
|
44
|
-
`;
|
|
25
|
+
return html`<svg part="icons icon-off" viewBox="0 0 24 24" aria-hidden="true"><path d="M6.4 19.2 4.8 17.6 10.4 12 4.8 6.4 6.4 4.8 12 10.4 17.6 4.8 19.2 6.4 13.6 12 19.2 17.6 17.6 19.2 12 13.6Z"/></svg>`;
|
|
45
26
|
}
|
|
46
27
|
connectedCallback() {
|
|
47
28
|
super.connectedCallback();
|
package/src/m3/system/base.css
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
|
|
4
4
|
--md-sys-typography-display-large: 400 3.5625rem / 4rem
|
|
5
5
|
var(--md-sys-typography-family);
|
|
6
|
-
--md-sys-typography-display-medium: 400 2.8125rem / 3.
|
|
6
|
+
--md-sys-typography-display-medium: 400 2.8125rem / 3.25rem
|
|
7
7
|
var(--md-sys-typography-family);
|
|
8
|
-
--md-sys-typography-display-small: 400 2.25rem /
|
|
8
|
+
--md-sys-typography-display-small: 400 2.25rem / 2.75rem
|
|
9
9
|
var(--md-sys-typography-family);
|
|
10
|
-
--md-sys-typography-headline-large: 400
|
|
10
|
+
--md-sys-typography-headline-large: 400 2rem / 2.5rem
|
|
11
11
|
var(--md-sys-typography-family);
|
|
12
|
-
--md-sys-typography-headline-medium: 400
|
|
12
|
+
--md-sys-typography-headline-medium: 400 1.75rem / 2.25rem
|
|
13
13
|
var(--md-sys-typography-family);
|
|
14
|
-
--md-sys-typography-headline-small: 400
|
|
14
|
+
--md-sys-typography-headline-small: 400 1.5rem / 2rem
|
|
15
15
|
var(--md-sys-typography-family);
|
|
16
16
|
--md-sys-typography-title-large: 400 1.375rem / 1.75rem
|
|
17
17
|
var(--md-sys-typography-family);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const tabStyles = css`:host{--md-focus-ring-shape:12px;box-sizing:border-box;color:var(--md-sys-color-on-surface-variant);cursor:pointer;font:var(--md-sys-typography-title-small);-webkit-tap-highlight-color:transparent;text-wrap-mode:nowrap;user-select:none
|
|
2
|
+
export const tabStyles = css`:host{--md-focus-ring-shape:12px;box-sizing:border-box;color:var(--md-sys-color-on-surface-variant);cursor:pointer;font:var(--md-sys-typography-title-small);-webkit-tap-highlight-color:transparent;text-wrap-mode:nowrap;user-select:none;outline:0;flex-shrink:0;justify-content:center;padding:0 16px;display:inline-flex;position:relative}:host([selected]){color:var(--_tab-selected-color)}:host([selected]) md-focus-ring{margin-bottom:calc(var(--_tab-indicator-height) + 2px)}[part=content]{flex-direction:var(--_tab-flex-dir,row);align-items:center;gap:var(--_tab-gap,8px);height:var(--_tab-height,48px);justify-content:center;display:inline-flex}[part~=icon]{fill:currentColor;block-size:1em;inline-size:1em;font-size:24px}`;
|
package/src/m3/tab/tab.js
CHANGED
|
@@ -14,15 +14,7 @@ export class M3Tab extends Tab {
|
|
|
14
14
|
];
|
|
15
15
|
}
|
|
16
16
|
render() {
|
|
17
|
-
return html
|
|
18
|
-
<md-focus-ring inward></md-focus-ring>
|
|
19
|
-
<md-ripple inward></md-ripple>
|
|
20
|
-
<span part="target"></span>
|
|
21
|
-
<div part="content">
|
|
22
|
-
<slot part="icon" name="icon" aria-hidden="true"></slot>
|
|
23
|
-
<slot part="label"></slot>
|
|
24
|
-
</div>
|
|
25
|
-
`;
|
|
17
|
+
return html`<md-focus-ring inward></md-focus-ring><md-ripple inward></md-ripple><span part="target"></span><div part="content"><slot part="icon" name="icon" aria-hidden="true"></slot><slot part="label"></slot></div>`;
|
|
26
18
|
}
|
|
27
19
|
}
|
|
28
20
|
_ts_decorate([
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const tabsStyles = css`:host{--_tab-selected-color:var(--md-sys-color-primary);--_tab-indicator-height:3px;border-bottom:1px solid var(--md-sys-color-outline-variant);box-sizing:border-box;scroll-behavior:smooth;scrollbar-width:none;display:block;position:relative;overflow:auto hidden}[part=tablist]{display:flex}[part=indicator]{height:var(--_tab-indicator-height);background-color:var(--md-sys-color-primary);transition:var(--md-sys-motion-
|
|
2
|
+
export const tabsStyles = css`:host{--_tab-selected-color:var(--md-sys-color-primary);--_tab-indicator-height:3px;border-bottom:1px solid var(--md-sys-color-outline-variant);box-sizing:border-box;scroll-behavior:smooth;scrollbar-width:none;display:block;position:relative;overflow:auto hidden}[part=tablist]{display:flex}[part=indicator]{height:var(--_tab-indicator-height);background-color:var(--md-sys-color-primary);transition:left var(--md-sys-motion-spatial-default-duration) var(--md-sys-motion-spatial-default),width var(--md-sys-motion-spatial-default-duration) var(--md-sys-motion-spatial-default);will-change:left,width;border-radius:3px 3px 0 0;position:absolute;bottom:0}::slotted(*){flex:1}:host([secondary]){--_tab-selected-color:var(--md-sys-color-on-surface);--_tab-indicator-height:2px}:host([secondary]) [part=indicator]{border-radius:0}:host([iconsabove]){--_tab-flex-dir:column;--_tab-height:64px;--_tab-gap:2px}`;
|