@vollowx/seele 0.13.5 → 0.13.6
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/custom-elements.json +1256 -115
- package/package.json +22 -14
- package/src/all.d.ts +34 -0
- package/src/base/autocomplete.d.ts +56 -0
- package/src/base/autocomplete.js +75 -87
- package/src/base/button.d.ts +13 -0
- package/src/base/button.js +21 -19
- package/src/base/checkbox.d.ts +18 -0
- package/src/base/checkbox.js +39 -34
- package/src/base/controllers/list-controller.d.ts +37 -0
- package/src/base/controllers/list-controller.js +23 -15
- package/src/base/controllers/popover-controller.d.ts +35 -0
- package/src/base/controllers/popover-controller.js +37 -29
- package/src/base/dialog.d.ts +20 -0
- package/src/base/dialog.js +11 -9
- package/src/base/field.d.ts +3 -0
- package/src/base/input.d.ts +44 -0
- package/src/base/input.js +57 -65
- package/src/base/item.d.ts +7 -0
- package/src/base/item.js +2 -1
- package/src/base/list-item.d.ts +15 -0
- package/src/base/list-item.js +22 -22
- package/src/base/list.d.ts +54 -0
- package/src/base/list.js +69 -55
- package/src/base/menu-item.d.ts +6 -0
- package/src/base/menu-item.js +4 -3
- package/src/base/menu.d.ts +76 -0
- package/src/base/menu.js +135 -143
- package/src/base/mixins/attachable.d.ts +9 -0
- package/src/base/mixins/attachable.js +22 -18
- package/src/base/mixins/focus-delegated.d.ts +5 -0
- package/src/base/mixins/focus-delegated.js +6 -8
- package/src/base/mixins/form-associated.d.ts +15 -0
- package/src/base/mixins/form-associated.js +11 -18
- package/src/base/mixins/internals-attached.d.ts +6 -0
- package/src/base/mixins/internals-attached.js +1 -1
- package/src/base/option.d.ts +9 -0
- package/src/base/option.js +7 -8
- package/src/base/radio.d.ts +13 -0
- package/src/base/radio.js +49 -42
- package/src/base/select.d.ts +116 -0
- package/src/base/select.js +130 -128
- package/src/base/slider.d.ts +75 -0
- package/src/base/slider.js +115 -118
- package/src/base/tab-panel.d.ts +9 -0
- package/src/base/tab-panel.js +11 -11
- package/src/base/tab.d.ts +18 -0
- package/src/base/tab.js +25 -24
- package/src/base/tabs.d.ts +19 -0
- package/src/base/tabs.js +84 -81
- package/src/base/toggle-button.d.ts +47 -0
- package/src/base/toggle-button.js +56 -52
- package/src/base/tooltip.d.ts +37 -0
- package/src/base/tooltip.js +70 -65
- package/src/core/decorators.d.ts +2 -0
- package/src/core/decorators.js +4 -3
- package/src/core/focus-visible.d.ts +2 -0
- package/src/core/focus-visible.js +4 -4
- package/src/core/shared.d.ts +1 -0
- package/src/core/unique-id.d.ts +4 -0
- package/src/core/unique-id.js +2 -1
- package/src/m3/autocomplete/autocomplete.d.ts +8 -0
- package/src/m3/autocomplete/autocomplete.js +10 -10
- package/src/m3/badge/badge.d.ts +12 -0
- package/src/m3/badge/badge.js +24 -37
- package/src/m3/button/common-button-toggle.d.ts +31 -0
- package/src/m3/button/common-button-toggle.js +44 -41
- package/src/m3/button/common-button.d.ts +29 -0
- package/src/m3/button/common-button.js +40 -40
- package/src/m3/button/icon-button-toggle.d.ts +24 -0
- package/src/m3/button/icon-button-toggle.js +35 -32
- package/src/m3/button/icon-button.d.ts +23 -0
- package/src/m3/button/icon-button.js +33 -31
- package/src/m3/button-group/connected-button-group.d.ts +19 -0
- package/src/m3/button-group/connected-button-group.js +26 -24
- package/src/m3/button-group/standard-button-group.d.ts +24 -0
- package/src/m3/button-group/standard-button-group.js +71 -65
- package/src/m3/checkbox/checkbox.d.ts +25 -0
- package/src/m3/checkbox/checkbox.js +23 -22
- package/src/m3/dialog/dialog-spring.d.ts +45 -0
- package/src/m3/dialog/dialog-spring.js +83 -86
- package/src/m3/dialog/dialog.d.ts +46 -0
- package/src/m3/dialog/dialog.js +90 -117
- package/src/m3/divider/divider.d.ts +13 -0
- package/src/m3/divider/divider.js +20 -33
- package/src/m3/fab/fab.d.ts +23 -0
- package/src/m3/fab/fab.js +24 -23
- package/src/m3/field/field.d.ts +28 -0
- package/src/m3/field/field.js +40 -55
- package/src/m3/field/filled-field.d.ts +11 -0
- package/src/m3/field/filled-field.js +7 -11
- package/src/m3/field/outlined-field.d.ts +11 -0
- package/src/m3/field/outlined-field.js +8 -12
- package/src/m3/focus-ring/focus-ring.d.ts +32 -0
- package/src/m3/focus-ring/focus-ring.js +38 -23
- package/src/m3/item/item.d.ts +31 -0
- package/src/m3/item/item.js +32 -17
- package/src/m3/list/list-item.d.ts +22 -0
- package/src/m3/list/list-item.js +18 -16
- package/src/m3/list/list.d.ts +15 -0
- package/src/m3/list/list.js +16 -15
- package/src/m3/loading-indicator/loading-indicator.d.ts +26 -0
- package/src/m3/loading-indicator/loading-indicator.js +113 -161
- package/src/m3/menu/menu-item.d.ts +15 -0
- package/src/m3/menu/menu-item.js +10 -4
- package/src/m3/menu/menu.d.ts +22 -0
- package/src/m3/menu/menu.js +20 -18
- package/src/m3/radio/radio-styles.css.js +1 -1
- package/src/m3/radio/radio.d.ts +17 -0
- package/src/m3/radio/radio.js +22 -11
- package/src/m3/ripple/ripple.d.ts +43 -0
- package/src/m3/ripple/ripple.js +82 -89
- package/src/m3/select/filled-select.d.ts +16 -0
- package/src/m3/select/filled-select.js +12 -10
- package/src/m3/select/option.d.ts +15 -0
- package/src/m3/select/option.js +10 -4
- package/src/m3/select/outlined-select.d.ts +16 -0
- package/src/m3/select/outlined-select.js +12 -10
- package/src/m3/select/select.d.ts +13 -0
- package/src/m3/select/select.js +16 -16
- package/src/m3/slider/slider.d.ts +20 -0
- package/src/m3/slider/slider.js +32 -26
- package/src/m3/switch/switch.d.ts +27 -0
- package/src/m3/switch/switch.js +62 -53
- package/src/m3/system/motion.d.ts +12 -0
- package/src/m3/system/motion.js +16 -9
- package/src/m3/tab/tab-panel.d.ts +9 -0
- package/src/m3/tab/tab-panel.js +6 -9
- package/src/m3/tab/tab.d.ts +19 -0
- package/src/m3/tab/tab.js +14 -12
- package/src/m3/tab/tabs.d.ts +25 -0
- package/src/m3/tab/tabs.js +34 -30
- package/src/m3/text-field/filled-text-field.d.ts +13 -0
- package/src/m3/text-field/filled-text-field.js +15 -20
- package/src/m3/text-field/outlined-text-field.d.ts +13 -0
- package/src/m3/text-field/outlined-text-field.js +15 -20
- package/src/m3/toolbar/toolbar.d.ts +26 -0
- package/src/m3/toolbar/toolbar.js +28 -25
- package/src/m3/tooltip/tooltip.d.ts +19 -0
- package/src/m3/tooltip/tooltip.js +15 -14
- package/src/win98/button/button.d.ts +13 -0
- package/src/win98/button/button.js +13 -11
- package/src/win98/button/radio.d.ts +3 -0
- package/src/win98/button/radio.js +5 -4
- package/src/win98/radio/radio.d.ts +3 -0
- package/src/win98/radio/radio.js +5 -4
package/src/m3/list/list.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
2
|
import { customElement, property } from 'lit/decorators.js';
|
|
3
3
|
import { List } from '../../base/list.js';
|
|
4
4
|
import { listStyles } from './list-styles.css.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
constructor(
|
|
12
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @tag md-list
|
|
7
|
+
*
|
|
8
|
+
* TODO: Use listController
|
|
9
|
+
*/
|
|
10
|
+
let M3List = class M3List extends List {
|
|
11
|
+
constructor() {
|
|
12
|
+
// FIXME: Might cause a long list to scroll more than expected
|
|
13
13
|
// override readonly _scrollPadding = 4;
|
|
14
|
+
super(...arguments);
|
|
14
15
|
this.color = 'standard';
|
|
15
16
|
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})
|
|
17
|
+
static { this.styles = [listStyles]; }
|
|
18
|
+
};
|
|
19
|
+
__decorate([
|
|
20
|
+
property({ reflect: true })
|
|
21
21
|
], M3List.prototype, "color", void 0);
|
|
22
|
-
M3List =
|
|
22
|
+
M3List = __decorate([
|
|
23
23
|
customElement('md-list')
|
|
24
24
|
], M3List);
|
|
25
|
+
export { M3List };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
declare const M3LoadingIndicator_base: Constructor<import("../../base/mixins/internals-attached.js").InternalsAttachedInterface> & typeof LitElement;
|
|
3
|
+
/**
|
|
4
|
+
* @tag md-loading
|
|
5
|
+
*
|
|
6
|
+
* TODO: shape system, https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/MaterialShapes.kt?q=file:androidx%2Fcompose%2Fmaterial3%2FMaterialShapes.kt%20class:androidx.compose.material3.MaterialShapes
|
|
7
|
+
* NOTE: this component is not following them color system dynamically, but
|
|
8
|
+
* pulls the color once per second
|
|
9
|
+
* NOTE: the pantagon is completely not following the shape system
|
|
10
|
+
*/
|
|
11
|
+
export declare class M3LoadingIndicator extends M3LoadingIndicator_base {
|
|
12
|
+
#private;
|
|
13
|
+
contained: boolean;
|
|
14
|
+
$canvas: HTMLCanvasElement;
|
|
15
|
+
static styles: any[];
|
|
16
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
17
|
+
constructor();
|
|
18
|
+
firstUpdated(): void;
|
|
19
|
+
disconnectedCallback(): void;
|
|
20
|
+
}
|
|
21
|
+
declare global {
|
|
22
|
+
interface HTMLElementTagNameMap {
|
|
23
|
+
'md-loading': M3LoadingIndicator;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate";
|
|
2
1
|
// Origin: https://github.com/brahmkshatriya/material-osc/blob/main/assets/loading-shape-morph-demo.html
|
|
2
|
+
import { __decorate } from "tslib";
|
|
3
3
|
import { LitElement, html } from 'lit';
|
|
4
4
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
5
5
|
import { InternalsAttached, internals } from '../../base/mixins/internals-attached.js';
|
|
@@ -11,21 +11,30 @@ const TOTAL_POINTS = 240;
|
|
|
11
11
|
const CANVAS_SIZE = 640;
|
|
12
12
|
const RADIUS_BASE = CANVAS_SIZE / 2;
|
|
13
13
|
const CENTER = CANVAS_SIZE / 2;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
/**
|
|
15
|
+
* @tag md-loading
|
|
16
|
+
*
|
|
17
|
+
* TODO: shape system, https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/MaterialShapes.kt?q=file:androidx%2Fcompose%2Fmaterial3%2FMaterialShapes.kt%20class:androidx.compose.material3.MaterialShapes
|
|
18
|
+
* NOTE: this component is not following them color system dynamically, but
|
|
19
|
+
* pulls the color once per second
|
|
20
|
+
* NOTE: the pantagon is completely not following the shape system
|
|
21
|
+
*/
|
|
22
|
+
let M3LoadingIndicator = class M3LoadingIndicator extends InternalsAttached(LitElement) {
|
|
23
|
+
static { this.styles = [loadingIndicatorStyles]; }
|
|
20
24
|
render() {
|
|
21
|
-
return html`<canvas width="${CANVAS_SIZE}" height="${CANVAS_SIZE}" aria-hidden="true"></canvas>`;
|
|
25
|
+
return html `<canvas width="${CANVAS_SIZE}" height="${CANVAS_SIZE}" aria-hidden="true"></canvas>`;
|
|
22
26
|
}
|
|
23
27
|
#ctx;
|
|
24
28
|
#animationFrame;
|
|
25
29
|
#startTime;
|
|
26
30
|
#color;
|
|
27
|
-
constructor(){
|
|
28
|
-
super()
|
|
31
|
+
constructor() {
|
|
32
|
+
super();
|
|
33
|
+
this.contained = false;
|
|
34
|
+
this.#animationFrame = 0;
|
|
35
|
+
this.#startTime = 0;
|
|
36
|
+
this.#color = '#ff0000';
|
|
37
|
+
this.#animate = (now) => {
|
|
29
38
|
if (this.#startTime === 0) {
|
|
30
39
|
this.#startTime = now;
|
|
31
40
|
}
|
|
@@ -36,7 +45,7 @@ export class M3LoadingIndicator extends InternalsAttached(LitElement) {
|
|
|
36
45
|
const from = sampledSequence[step % sampledSequence.length];
|
|
37
46
|
const to = sampledSequence[(step + 1) % sampledSequence.length];
|
|
38
47
|
const stepRotation = step * QUARTER_ROTATION + progress * QUARTER_ROTATION;
|
|
39
|
-
const globalRotation = elapsed % FULL_ROTATION_MS / FULL_ROTATION_MS * 360;
|
|
48
|
+
const globalRotation = ((elapsed % FULL_ROTATION_MS) / FULL_ROTATION_MS) * 360;
|
|
40
49
|
this.#draw(from, to, progress, stepRotation + globalRotation, scalePulse(morphElapsed));
|
|
41
50
|
this.#animationFrame = requestAnimationFrame(this.#animate);
|
|
42
51
|
};
|
|
@@ -56,25 +65,33 @@ export class M3LoadingIndicator extends InternalsAttached(LitElement) {
|
|
|
56
65
|
}
|
|
57
66
|
#cacheColors() {
|
|
58
67
|
const computed = getComputedStyle(this);
|
|
59
|
-
const color = computed
|
|
60
|
-
|
|
68
|
+
const color = computed
|
|
69
|
+
.getPropertyValue(this.contained
|
|
70
|
+
? '--md-sys-color-on-primary-container'
|
|
71
|
+
: '--md-sys-color-primary')
|
|
72
|
+
.trim();
|
|
73
|
+
if (color)
|
|
74
|
+
this.#color = color;
|
|
61
75
|
}
|
|
62
76
|
#draw(from, to, progress, rotation, scale) {
|
|
63
|
-
if (!this.#ctx || !this.$canvas)
|
|
77
|
+
if (!this.#ctx || !this.$canvas)
|
|
78
|
+
return;
|
|
64
79
|
const ctx = this.#ctx;
|
|
65
80
|
ctx.clearRect(0, 0, this.$canvas.width, this.$canvas.height);
|
|
66
81
|
ctx.save();
|
|
67
82
|
ctx.translate(CENTER, CENTER);
|
|
68
83
|
ctx.scale(scale, scale);
|
|
69
|
-
ctx.rotate(rotation * Math.PI / 180);
|
|
84
|
+
ctx.rotate((rotation * Math.PI) / 180);
|
|
70
85
|
ctx.translate(-CENTER, -CENTER);
|
|
71
86
|
ctx.beginPath();
|
|
72
|
-
from.points.forEach((point, i)=>{
|
|
87
|
+
from.points.forEach((point, i) => {
|
|
73
88
|
const next = to.points[i];
|
|
74
89
|
const x = lerp(point.x, next.x, progress);
|
|
75
90
|
const y = lerp(point.y, next.y, progress);
|
|
76
|
-
if (i === 0)
|
|
77
|
-
|
|
91
|
+
if (i === 0)
|
|
92
|
+
ctx.moveTo(x, y);
|
|
93
|
+
else
|
|
94
|
+
ctx.lineTo(x, y);
|
|
78
95
|
});
|
|
79
96
|
ctx.closePath();
|
|
80
97
|
ctx.fillStyle = this.#color;
|
|
@@ -82,239 +99,174 @@ export class M3LoadingIndicator extends InternalsAttached(LitElement) {
|
|
|
82
99
|
ctx.restore();
|
|
83
100
|
}
|
|
84
101
|
#animate;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
property({
|
|
88
|
-
type: Boolean,
|
|
89
|
-
reflect: true
|
|
90
|
-
})
|
|
102
|
+
};
|
|
103
|
+
__decorate([
|
|
104
|
+
property({ type: Boolean, reflect: true })
|
|
91
105
|
], M3LoadingIndicator.prototype, "contained", void 0);
|
|
92
|
-
|
|
106
|
+
__decorate([
|
|
93
107
|
query('canvas')
|
|
94
108
|
], M3LoadingIndicator.prototype, "$canvas", void 0);
|
|
95
|
-
M3LoadingIndicator =
|
|
109
|
+
M3LoadingIndicator = __decorate([
|
|
96
110
|
customElement('md-loading')
|
|
97
111
|
], M3LoadingIndicator);
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
y: 0
|
|
104
|
-
})=>{
|
|
112
|
+
export { M3LoadingIndicator };
|
|
113
|
+
const lerp = (a, b, t) => a + (b - a) * t;
|
|
114
|
+
const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v));
|
|
115
|
+
const dist = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
|
|
116
|
+
const norm = (x, y, fallback = { x: 1, y: 0 }) => {
|
|
105
117
|
const len = Math.hypot(x, y);
|
|
106
|
-
return len < 1e-6 ? fallback : {
|
|
107
|
-
x: x / len,
|
|
108
|
-
y: y / len
|
|
109
|
-
};
|
|
118
|
+
return len < 1e-6 ? fallback : { x: x / len, y: y / len };
|
|
110
119
|
};
|
|
111
120
|
const sequence = [
|
|
112
|
-
[
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
],
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
}));
|
|
121
|
+
[10, 0.85, 0.67, 0.75, 0.5],
|
|
122
|
+
[9, 0.85, 0.755, 0.8, 0.5],
|
|
123
|
+
[5, 0.85, 0.731, 0.45, 1],
|
|
124
|
+
[2, 0.85, 0.67, 0.8, 0.95],
|
|
125
|
+
[8, 0.85, 0.731, 0.6, 0.45],
|
|
126
|
+
[4, 0.925, 0.67, 1, 0.4],
|
|
127
|
+
[2, 0.9, 0.565, 0.8, 0.6],
|
|
128
|
+
].map(([points, outerRadius, innerRadius, outerRoundness, innerRoundness]) => ({
|
|
129
|
+
points,
|
|
130
|
+
outerRadius,
|
|
131
|
+
innerRadius,
|
|
132
|
+
outerRoundness,
|
|
133
|
+
innerRoundness,
|
|
134
|
+
}));
|
|
168
135
|
function springProgress(ms) {
|
|
169
136
|
const t = ms / 1000;
|
|
170
137
|
const stiffness = 200;
|
|
171
138
|
const damping = 0.6;
|
|
172
139
|
const omega0 = Math.sqrt(stiffness);
|
|
173
140
|
const omegaD = omega0 * Math.sqrt(1 - damping * damping);
|
|
174
|
-
const displacement = Math.exp(-damping * omega0 * t) *
|
|
141
|
+
const displacement = Math.exp(-damping * omega0 * t) *
|
|
142
|
+
(-Math.cos(omegaD * t) -
|
|
143
|
+
((damping * omega0) / omegaD) * Math.sin(omegaD * t));
|
|
175
144
|
return clamp(1 + displacement, 0, 1);
|
|
176
145
|
}
|
|
177
146
|
function scalePulse(ms) {
|
|
178
147
|
const t = ms / STEP_MS;
|
|
179
|
-
const smooth = (p)=>p * p * (3 - 2 * p);
|
|
180
|
-
const outCubic = (p)=>1 - (1 - p) ** 3;
|
|
148
|
+
const smooth = (p) => p * p * (3 - 2 * p);
|
|
149
|
+
const outCubic = (p) => 1 - (1 - p) ** 3;
|
|
181
150
|
const segments = [
|
|
182
|
-
[
|
|
183
|
-
|
|
184
|
-
|
|
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
|
-
]
|
|
151
|
+
[0, 0.14, 1, 0.985, smooth],
|
|
152
|
+
[0.14, 0.46, 0.985, 1.04, outCubic],
|
|
153
|
+
[0.46, 0.76, 1.04, 1, smooth],
|
|
203
154
|
];
|
|
204
|
-
const segment = segments.find(([start, end])=>t < end && t >= start);
|
|
205
|
-
if (!segment)
|
|
155
|
+
const segment = segments.find(([start, end]) => t < end && t >= start);
|
|
156
|
+
if (!segment)
|
|
157
|
+
return 1;
|
|
206
158
|
const [start, end, from, to, ease] = segment;
|
|
207
159
|
return lerp(from, to, ease((t - start) / (end - start)));
|
|
208
160
|
}
|
|
209
161
|
function starGeometry(shape) {
|
|
210
162
|
const points = Math.max(2, Math.floor(shape.points));
|
|
211
163
|
const count = points * 2;
|
|
212
|
-
const anchors = Array.from({
|
|
213
|
-
length: count
|
|
214
|
-
}, (_, i)=>{
|
|
164
|
+
const anchors = Array.from({ length: count }, (_, i) => {
|
|
215
165
|
const outer = i % 2 === 0;
|
|
216
166
|
const radius = (outer ? shape.outerRadius : shape.innerRadius) * RADIUS_BASE;
|
|
217
|
-
const angle = i * Math.PI / points;
|
|
167
|
+
const angle = (i * Math.PI) / points;
|
|
218
168
|
return {
|
|
219
169
|
x: CENTER + Math.cos(angle) * radius,
|
|
220
170
|
y: CENTER + Math.sin(angle) * radius,
|
|
221
|
-
outer
|
|
171
|
+
outer,
|
|
222
172
|
};
|
|
223
173
|
});
|
|
224
|
-
const tangents = anchors.map((_, i)=>{
|
|
174
|
+
const tangents = anchors.map((_, i) => {
|
|
225
175
|
const prev = anchors[(i - 1 + count) % count];
|
|
226
176
|
const next = anchors[(i + 1) % count];
|
|
227
177
|
return norm(next.x - prev.x, next.y - prev.y);
|
|
228
178
|
});
|
|
229
|
-
const lengths = anchors.map((anchor, i)=>{
|
|
179
|
+
const lengths = anchors.map((anchor, i) => {
|
|
230
180
|
const prev = anchors[(i - 1 + count) % count];
|
|
231
181
|
const next = anchors[(i + 1) % count];
|
|
232
|
-
const roundness = anchor.outer
|
|
233
|
-
|
|
182
|
+
const roundness = anchor.outer
|
|
183
|
+
? shape.outerRoundness
|
|
184
|
+
: shape.innerRoundness;
|
|
185
|
+
return (Math.max(0, roundness) *
|
|
186
|
+
Math.min(dist(anchor, prev), dist(anchor, next)) *
|
|
187
|
+
0.5);
|
|
234
188
|
});
|
|
235
|
-
const handles = anchors.map((anchor, i)=>{
|
|
189
|
+
const handles = anchors.map((anchor, i) => {
|
|
236
190
|
const tangent = tangents[i];
|
|
237
191
|
const length = lengths[i];
|
|
238
192
|
return {
|
|
239
193
|
in: {
|
|
240
194
|
x: anchor.x - tangent.x * length,
|
|
241
|
-
y: anchor.y - tangent.y * length
|
|
195
|
+
y: anchor.y - tangent.y * length,
|
|
242
196
|
},
|
|
243
197
|
out: {
|
|
244
198
|
x: anchor.x + tangent.x * length,
|
|
245
|
-
y: anchor.y + tangent.y * length
|
|
246
|
-
}
|
|
199
|
+
y: anchor.y + tangent.y * length,
|
|
200
|
+
},
|
|
247
201
|
};
|
|
248
202
|
});
|
|
249
|
-
return {
|
|
250
|
-
anchors,
|
|
251
|
-
handles
|
|
252
|
-
};
|
|
203
|
+
return { anchors, handles };
|
|
253
204
|
}
|
|
254
205
|
function cubic(p0, c1, c2, p1, t) {
|
|
255
206
|
const inv = 1 - t;
|
|
256
207
|
return {
|
|
257
|
-
x: inv ** 3 * p0.x +
|
|
258
|
-
|
|
208
|
+
x: inv ** 3 * p0.x +
|
|
209
|
+
3 * inv * inv * t * c1.x +
|
|
210
|
+
3 * inv * t * t * c2.x +
|
|
211
|
+
t ** 3 * p1.x,
|
|
212
|
+
y: inv ** 3 * p0.y +
|
|
213
|
+
3 * inv * inv * t * c1.y +
|
|
214
|
+
3 * inv * t * t * c2.y +
|
|
215
|
+
t ** 3 * p1.y,
|
|
259
216
|
};
|
|
260
217
|
}
|
|
261
218
|
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);
|
|
219
|
+
const lengths = points.map((point, i) => dist(point, points[(i + 1) % points.length]));
|
|
220
|
+
const perimeter = lengths.reduce((sum, length) => sum + length, 0);
|
|
264
221
|
const sampled = [];
|
|
265
222
|
let edge = 0;
|
|
266
223
|
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){
|
|
224
|
+
for (let i = 0; i < TOTAL_POINTS; i++) {
|
|
225
|
+
const target = (perimeter * i) / TOTAL_POINTS;
|
|
226
|
+
while (consumed + lengths[edge] < target && edge < lengths.length - 1) {
|
|
270
227
|
consumed += lengths[edge++];
|
|
271
228
|
}
|
|
272
229
|
const point = points[edge];
|
|
273
230
|
const next = points[(edge + 1) % points.length];
|
|
274
231
|
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
|
-
});
|
|
232
|
+
sampled.push({ x: lerp(point.x, next.x, t), y: lerp(point.y, next.y, t) });
|
|
279
233
|
}
|
|
280
234
|
return sampled;
|
|
281
235
|
}
|
|
282
236
|
function sampleShape(shape) {
|
|
283
237
|
const { anchors, handles } = starGeometry(shape);
|
|
284
238
|
const dense = [];
|
|
285
|
-
anchors.forEach((anchor, i)=>{
|
|
239
|
+
anchors.forEach((anchor, i) => {
|
|
286
240
|
const next = (i + 1) % anchors.length;
|
|
287
|
-
for(let step = 0; step < 18; step++){
|
|
241
|
+
for (let step = 0; step < 18; step++) {
|
|
288
242
|
dense.push(cubic(anchor, handles[i].out, handles[next].in, anchors[next], step / 18));
|
|
289
243
|
}
|
|
290
244
|
});
|
|
291
|
-
return {
|
|
292
|
-
points: resample(dense)
|
|
293
|
-
};
|
|
245
|
+
return { points: resample(dense) };
|
|
294
246
|
}
|
|
295
247
|
function shifted(points, offset) {
|
|
296
|
-
return points.map((_, i)=>points[(i + offset) % points.length]);
|
|
248
|
+
return points.map((_, i) => points[(i + offset) % points.length]);
|
|
297
249
|
}
|
|
298
250
|
function alignTo(from, to) {
|
|
299
251
|
let bestOffset = 0;
|
|
300
252
|
let bestScore = Infinity;
|
|
301
|
-
for(let offset = 0; offset < to.points.length; offset++){
|
|
253
|
+
for (let offset = 0; offset < to.points.length; offset++) {
|
|
302
254
|
let score = 0;
|
|
303
|
-
for(let i = 0; i < from.points.length; i += 4){
|
|
255
|
+
for (let i = 0; i < from.points.length; i += 4) {
|
|
304
256
|
const point = to.points[(i + offset) % to.points.length];
|
|
305
|
-
score +=
|
|
257
|
+
score +=
|
|
258
|
+
(from.points[i].x - point.x) ** 2 + (from.points[i].y - point.y) ** 2;
|
|
306
259
|
}
|
|
307
260
|
if (score < bestScore) {
|
|
308
261
|
bestScore = score;
|
|
309
262
|
bestOffset = offset;
|
|
310
263
|
}
|
|
311
264
|
}
|
|
312
|
-
return {
|
|
313
|
-
...to,
|
|
314
|
-
points: shifted(to.points, bestOffset)
|
|
315
|
-
};
|
|
265
|
+
return { ...to, points: shifted(to.points, bestOffset) };
|
|
316
266
|
}
|
|
317
|
-
const sampledSequence = sequence
|
|
267
|
+
const sampledSequence = sequence
|
|
268
|
+
.map(sampleShape)
|
|
269
|
+
.reduce((aligned, shape) => {
|
|
318
270
|
aligned.push(aligned.length ? alignTo(aligned.at(-1), shape) : shape);
|
|
319
271
|
return aligned;
|
|
320
272
|
}, []);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { M3ListItem } from '../list/list-item.js';
|
|
2
|
+
declare const M3MenuItem_base: typeof M3ListItem;
|
|
3
|
+
/**
|
|
4
|
+
* @tag md-menu-item
|
|
5
|
+
*
|
|
6
|
+
* @slot - contents in md-item
|
|
7
|
+
*/
|
|
8
|
+
export declare class M3MenuItem extends M3MenuItem_base {
|
|
9
|
+
}
|
|
10
|
+
declare global {
|
|
11
|
+
interface HTMLElementTagNameMap {
|
|
12
|
+
'md-menu-item': M3MenuItem;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export {};
|
package/src/m3/menu/menu-item.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
2
|
import { customElement } from 'lit/decorators.js';
|
|
3
3
|
import { M3ListItem } from '../list/list-item.js';
|
|
4
4
|
import { MenuItemMixin } from '../../base/menu-item.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @tag md-menu-item
|
|
7
|
+
*
|
|
8
|
+
* @slot - contents in md-item
|
|
9
|
+
*/
|
|
10
|
+
let M3MenuItem = class M3MenuItem extends MenuItemMixin(M3ListItem) {
|
|
11
|
+
};
|
|
12
|
+
M3MenuItem = __decorate([
|
|
8
13
|
customElement('md-menu-item')
|
|
9
14
|
], M3MenuItem);
|
|
15
|
+
export { M3MenuItem };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Menu } from '../../base/menu.js';
|
|
2
|
+
/**
|
|
3
|
+
* @tag md-menu
|
|
4
|
+
*
|
|
5
|
+
* @csspart menu-surface
|
|
6
|
+
* @csspart list
|
|
7
|
+
*
|
|
8
|
+
* @slot - menu items
|
|
9
|
+
*/
|
|
10
|
+
export declare class M3Menu extends Menu {
|
|
11
|
+
readonly _durations: {
|
|
12
|
+
show: number;
|
|
13
|
+
hide: number;
|
|
14
|
+
};
|
|
15
|
+
color: 'standard' | 'vibrant';
|
|
16
|
+
static styles: any[];
|
|
17
|
+
}
|
|
18
|
+
declare global {
|
|
19
|
+
interface HTMLElementTagNameMap {
|
|
20
|
+
'md-menu': M3Menu;
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/m3/menu/menu.js
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
2
|
import { customElement } from 'lit/decorators.js';
|
|
3
3
|
import { property } from 'lit/decorators.js';
|
|
4
4
|
import { Menu } from '../../base/menu.js';
|
|
5
5
|
import { menuStyles } from './menu-styles.css.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
/**
|
|
7
|
+
* @tag md-menu
|
|
8
|
+
*
|
|
9
|
+
* @csspart menu-surface
|
|
10
|
+
* @csspart list
|
|
11
|
+
*
|
|
12
|
+
* @slot - menu items
|
|
13
|
+
*/
|
|
14
|
+
let M3Menu = class M3Menu extends Menu {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this._durations = { show: 300, hide: 150 };
|
|
18
|
+
// FIXME: Might cause a long list to scroll more than expected
|
|
17
19
|
// override readonly _scrollPadding = 4;
|
|
18
20
|
this.color = 'standard';
|
|
19
21
|
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
})
|
|
22
|
+
static { this.styles = [menuStyles]; }
|
|
23
|
+
};
|
|
24
|
+
__decorate([
|
|
25
|
+
property({ reflect: true })
|
|
25
26
|
], M3Menu.prototype, "color", void 0);
|
|
26
|
-
M3Menu =
|
|
27
|
+
M3Menu = __decorate([
|
|
27
28
|
customElement('md-menu')
|
|
28
29
|
], M3Menu);
|
|
30
|
+
export { M3Menu };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export const radioStyles = css`:host{--
|
|
2
|
+
export const radioStyles = css`:host{--_d:var(--md-sys-motion-effects-default-duration);--_default:var(--_d) var(--md-sys-motion-effects-default);--_slow:var(--md-sys-motion-effects-slow-duration) var(--md-sys-motion-effects-slow);cursor:pointer;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none;border-radius:20px;outline:0;justify-content:center;align-items:center;width:40px;height:40px;display:inline-flex;position:relative}:host:before,.middle,:host:after{content:"";box-sizing:border-box;border-radius:50%;position:absolute;animation-fill-mode:forwards!important}:host:before{z-index:1;background-color:var(--md-sys-color-on-surface-variant);width:20px;height:20px;transition:background var(--_default)}.middle{z-index:2;background-color:var(--md-sys-color-surface);width:16px;height:16px}:host:after{z-index:3;background-color:var(--md-sys-color-primary);width:10px;height:10px;transform:scale(0)}:host(:state(unchecking)) .middle{animation:uncheck-mid-2 var(--_slow) var(--_d)}:host(:state(unchecking)):after{animation:uncheck-inner-1 var(--_default), uncheck-inner-2 var(--_slow) var(--_d)}:host([checked]):before{background-color:var(--md-sys-color-primary)}:host([checked]):after{transform:scale(1)}:host(:state(checking)) .middle{animation:check-mid-1 var(--_default), check-mid-2 var(--_slow) var(--_d)}:host(:state(checking)):after{animation:check-inner-1 var(--_default), check-inner-2 var(--_slow) var(--_d)}@keyframes uncheck-mid-2{0%,to{z-index:4}0%{transform:scale(0)}to{transform:scale(1)}}@keyframes uncheck-inner-1{0%{background-color:var(--md-sys-color-primary);transform:scale(1)}to{background-color:var(--md-sys-color-on-surface-variant);transform:scale(1.6)}}@keyframes uncheck-inner-2{0%{transform:scale(1.6)}to{transform:scale(1.6)}}@keyframes check-mid-1{0%{transform:scale(1)}to{transform:scale(0)}}@keyframes check-mid-2{0%{transform:scale(.625)}to{transform:scale(1)}}@keyframes check-inner-1{0%,to{transform:scale(0)}}@keyframes check-inner-2{0%,to{transform:scale(1)}}:host([disabled]){pointer-events:none}:host([disabled]):before,:host([disabled]):after{background:color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent)}`;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PropertyValues } from 'lit';
|
|
2
|
+
import { Radio } from '../../base/radio.js';
|
|
3
|
+
import '../focus-ring/focus-ring.js';
|
|
4
|
+
import '../ripple/ripple.js';
|
|
5
|
+
/**
|
|
6
|
+
* @tag md-radio
|
|
7
|
+
*/
|
|
8
|
+
export declare class M3Radio extends Radio {
|
|
9
|
+
static styles: any[];
|
|
10
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
11
|
+
updated(changedProperties: PropertyValues<this>): void;
|
|
12
|
+
}
|
|
13
|
+
declare global {
|
|
14
|
+
interface HTMLElementTagNameMap {
|
|
15
|
+
'md-radio': M3Radio;
|
|
16
|
+
}
|
|
17
|
+
}
|
package/src/m3/radio/radio.js
CHANGED
|
@@ -1,22 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
2
|
import { html } from 'lit';
|
|
3
3
|
import { Radio } from '../../base/radio.js';
|
|
4
4
|
import { customElement } from '../../core/decorators.js';
|
|
5
|
+
import { internals } from '../../base/mixins/internals-attached.js';
|
|
5
6
|
import { radioStyles } from './radio-styles.css.js';
|
|
6
7
|
import { targetStyles } from '../target-styles.css.js';
|
|
7
8
|
import '../focus-ring/focus-ring.js';
|
|
8
9
|
import '../ripple/ripple.js';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
];
|
|
15
|
-
}
|
|
10
|
+
/**
|
|
11
|
+
* @tag md-radio
|
|
12
|
+
*/
|
|
13
|
+
let M3Radio = class M3Radio extends Radio {
|
|
14
|
+
static { this.styles = [targetStyles, radioStyles]; }
|
|
16
15
|
render() {
|
|
17
|
-
return html`<md-focus-ring></md-focus-ring><md-ripple></md-ripple><span part="target"></span> <span class="middle"></span>`;
|
|
16
|
+
return html `<md-focus-ring></md-focus-ring><md-ripple></md-ripple><span part="target"></span> <span class="middle"></span>`;
|
|
17
|
+
}
|
|
18
|
+
updated(changedProperties) {
|
|
19
|
+
super.updated(changedProperties);
|
|
20
|
+
if (changedProperties.has('checked')) {
|
|
21
|
+
const oldValue = changedProperties.get('checked');
|
|
22
|
+
if (oldValue === undefined)
|
|
23
|
+
return;
|
|
24
|
+
this[internals].states.delete('checking');
|
|
25
|
+
this[internals].states.delete('unchecking');
|
|
26
|
+
this[internals].states.add(this.checked ? 'checking' : 'unchecking');
|
|
27
|
+
}
|
|
18
28
|
}
|
|
19
|
-
}
|
|
20
|
-
M3Radio =
|
|
29
|
+
};
|
|
30
|
+
M3Radio = __decorate([
|
|
21
31
|
customElement('md-radio')
|
|
22
32
|
], M3Radio);
|
|
33
|
+
export { M3Radio };
|