claymorph-ui 0.0.0-stage → 0.4.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/LICENSE +21 -0
- package/README.md +130 -2
- package/dist/attach.d.ts +115 -0
- package/dist/attach.js +328 -0
- package/dist/attach.js.map +1 -0
- package/dist/clay.css +1648 -0
- package/dist/color.d.ts +5 -0
- package/dist/color.js +44 -0
- package/dist/color.js.map +1 -0
- package/dist/components/action-button.d.ts +31 -0
- package/dist/components/action-button.js +158 -0
- package/dist/components/action-button.js.map +1 -0
- package/dist/components/bars.d.ts +33 -0
- package/dist/components/bars.js +135 -0
- package/dist/components/bars.js.map +1 -0
- package/dist/components/button.d.ts +10 -0
- package/dist/components/button.js +36 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/card.d.ts +24 -0
- package/dist/components/card.js +139 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/controls.d.ts +54 -0
- package/dist/components/controls.js +310 -0
- package/dist/components/controls.js.map +1 -0
- package/dist/components/forms.d.ts +41 -0
- package/dist/components/forms.js +266 -0
- package/dist/components/forms.js.map +1 -0
- package/dist/components/group.d.ts +26 -0
- package/dist/components/group.js +180 -0
- package/dist/components/group.js.map +1 -0
- package/dist/components/overlays.d.ts +89 -0
- package/dist/components/overlays.js +383 -0
- package/dist/components/overlays.js.map +1 -0
- package/dist/components/popups.d.ts +55 -0
- package/dist/components/popups.js +308 -0
- package/dist/components/popups.js.map +1 -0
- package/dist/components/slide.d.ts +34 -0
- package/dist/components/slide.js +234 -0
- package/dist/components/slide.js.map +1 -0
- package/dist/components/tabs.d.ts +20 -0
- package/dist/components/tabs.js +105 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/config.d.ts +48 -0
- package/dist/config.js +50 -0
- package/dist/config.js.map +1 -0
- package/dist/element.d.ts +39 -0
- package/dist/element.js +135 -0
- package/dist/element.js.map +1 -0
- package/dist/engine.d.ts +91 -0
- package/dist/engine.js +454 -0
- package/dist/engine.js.map +1 -0
- package/dist/entries/action-button.d.ts +8 -0
- package/dist/entries/action-button.js +8 -0
- package/dist/entries/action-button.js.map +1 -0
- package/dist/entries/avatar.d.ts +8 -0
- package/dist/entries/avatar.js +8 -0
- package/dist/entries/avatar.js.map +1 -0
- package/dist/entries/badge.d.ts +7 -0
- package/dist/entries/badge.js +7 -0
- package/dist/entries/badge.js.map +1 -0
- package/dist/entries/button-group.d.ts +9 -0
- package/dist/entries/button-group.js +9 -0
- package/dist/entries/button-group.js.map +1 -0
- package/dist/entries/button.d.ts +8 -0
- package/dist/entries/button.js +8 -0
- package/dist/entries/button.js.map +1 -0
- package/dist/entries/card.d.ts +7 -0
- package/dist/entries/card.js +7 -0
- package/dist/entries/card.js.map +1 -0
- package/dist/entries/checkbox.d.ts +9 -0
- package/dist/entries/checkbox.js +9 -0
- package/dist/entries/checkbox.js.map +1 -0
- package/dist/entries/dialog.d.ts +8 -0
- package/dist/entries/dialog.js +8 -0
- package/dist/entries/dialog.js.map +1 -0
- package/dist/entries/input.d.ts +9 -0
- package/dist/entries/input.js +9 -0
- package/dist/entries/input.js.map +1 -0
- package/dist/entries/menu.d.ts +8 -0
- package/dist/entries/menu.js +8 -0
- package/dist/entries/menu.js.map +1 -0
- package/dist/entries/meter.d.ts +8 -0
- package/dist/entries/meter.js +8 -0
- package/dist/entries/meter.js.map +1 -0
- package/dist/entries/popover.d.ts +8 -0
- package/dist/entries/popover.js +8 -0
- package/dist/entries/popover.js.map +1 -0
- package/dist/entries/progress.d.ts +8 -0
- package/dist/entries/progress.js +8 -0
- package/dist/entries/progress.js.map +1 -0
- package/dist/entries/radio.d.ts +9 -0
- package/dist/entries/radio.js +9 -0
- package/dist/entries/radio.js.map +1 -0
- package/dist/entries/segmented.d.ts +8 -0
- package/dist/entries/segmented.js +8 -0
- package/dist/entries/segmented.js.map +1 -0
- package/dist/entries/select.d.ts +8 -0
- package/dist/entries/select.js +8 -0
- package/dist/entries/select.js.map +1 -0
- package/dist/entries/slide-confirm.d.ts +8 -0
- package/dist/entries/slide-confirm.js +8 -0
- package/dist/entries/slide-confirm.js.map +1 -0
- package/dist/entries/slider.d.ts +9 -0
- package/dist/entries/slider.js +9 -0
- package/dist/entries/slider.js.map +1 -0
- package/dist/entries/switch.d.ts +9 -0
- package/dist/entries/switch.js +9 -0
- package/dist/entries/switch.js.map +1 -0
- package/dist/entries/tabs.d.ts +8 -0
- package/dist/entries/tabs.js +8 -0
- package/dist/entries/tabs.js.map +1 -0
- package/dist/entries/toast.d.ts +9 -0
- package/dist/entries/toast.js +8 -0
- package/dist/entries/toast.js.map +1 -0
- package/dist/entries/toggle.d.ts +8 -0
- package/dist/entries/toggle.js +8 -0
- package/dist/entries/toggle.js.map +1 -0
- package/dist/entries/tooltip.d.ts +8 -0
- package/dist/entries/tooltip.js +8 -0
- package/dist/entries/tooltip.js.map +1 -0
- package/dist/highlight.d.ts +26 -0
- package/dist/highlight.js +100 -0
- package/dist/highlight.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +37 -0
- package/dist/shared.d.ts +28 -0
- package/dist/shared.js +80 -0
- package/dist/shared.js.map +1 -0
- package/dist/spring.d.ts +14 -0
- package/dist/spring.js +50 -0
- package/dist/spring.js.map +1 -0
- package/dist/surface.d.ts +88 -0
- package/dist/surface.js +240 -0
- package/dist/surface.js.map +1 -0
- package/package.json +140 -4
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { mix } from "../color.js";
|
|
2
|
+
import { SPRINGS } from "../config.js";
|
|
3
|
+
import { ClayElement, NEUTRAL } from "../element.js";
|
|
4
|
+
import "../attach.js";
|
|
5
|
+
import { clamp, deeper, watch } from "../shared.js";
|
|
6
|
+
import { Spring } from "../spring.js";
|
|
7
|
+
import { offsetWithin } from "../surface.js";
|
|
8
|
+
// src/clay/components/forms.ts
|
|
9
|
+
var userInvalid = (field) => {
|
|
10
|
+
try {
|
|
11
|
+
return field.matches(":user-invalid") || field.getAttribute("aria-invalid") === "true";
|
|
12
|
+
} catch {
|
|
13
|
+
return field.getAttribute("aria-invalid") === "true";
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var LABEL = ":scope > :is(ui-field-label, [data-slot='field-label'])";
|
|
17
|
+
var HINT = ":scope > :is(ui-field-description, [data-slot='field-description'])";
|
|
18
|
+
var layout = (el) => el && el.offsetParent ? {
|
|
19
|
+
x: el.offsetLeft,
|
|
20
|
+
y: el.offsetTop,
|
|
21
|
+
w: el.offsetWidth,
|
|
22
|
+
h: el.offsetHeight
|
|
23
|
+
} : null;
|
|
24
|
+
/**
|
|
25
|
+
* Type: a text field carved into the clay. Its rim glows while focused and the well gives a little as
|
|
26
|
+
* you type. With `attached`, the label and hint are beads melted onto the rim.
|
|
27
|
+
*/
|
|
28
|
+
var ClayInput = class extends ClayElement {
|
|
29
|
+
static observedAttributes = [
|
|
30
|
+
"color",
|
|
31
|
+
"size",
|
|
32
|
+
"attached"
|
|
33
|
+
];
|
|
34
|
+
requires = "input, textarea";
|
|
35
|
+
focused = new Spring(0);
|
|
36
|
+
pulse = new Spring(0);
|
|
37
|
+
out = new Spring(0);
|
|
38
|
+
invalid = false;
|
|
39
|
+
label = null;
|
|
40
|
+
hint = null;
|
|
41
|
+
lastVars = "";
|
|
42
|
+
reach = 24;
|
|
43
|
+
cleanup = [];
|
|
44
|
+
get field() {
|
|
45
|
+
return this.querySelector("input, textarea");
|
|
46
|
+
}
|
|
47
|
+
get attached() {
|
|
48
|
+
return this.hasAttribute("attached");
|
|
49
|
+
}
|
|
50
|
+
setup() {
|
|
51
|
+
const field = this.field;
|
|
52
|
+
const check = () => {
|
|
53
|
+
const invalid = userInvalid(field);
|
|
54
|
+
if (invalid !== this.invalid) {
|
|
55
|
+
this.invalid = invalid;
|
|
56
|
+
this.toggleAttribute("data-invalid", invalid);
|
|
57
|
+
this.invalidate();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const handlers = [
|
|
61
|
+
["focus", () => (this.focused.target = 1, this.surfaces[0]?.wake())],
|
|
62
|
+
["blur", () => (this.focused.target = 0, check(), this.surfaces[0]?.wake())],
|
|
63
|
+
["input", () => (this.pulse.v += 5, check(), this.surfaces[0]?.wake())],
|
|
64
|
+
["invalid", check]
|
|
65
|
+
];
|
|
66
|
+
for (const [type, handler] of handlers) {
|
|
67
|
+
field.addEventListener(type, handler);
|
|
68
|
+
this.cleanup.push(() => field.removeEventListener(type, handler));
|
|
69
|
+
}
|
|
70
|
+
this.cleanup.push(watch(field, ["aria-invalid", "disabled"], () => (check(), this.invalidate())));
|
|
71
|
+
if (document.activeElement === field) this.focused.set(1);
|
|
72
|
+
this.out.target = 1;
|
|
73
|
+
}
|
|
74
|
+
teardown() {
|
|
75
|
+
for (const fn of this.cleanup) fn();
|
|
76
|
+
this.cleanup = [];
|
|
77
|
+
}
|
|
78
|
+
surfaceFor() {
|
|
79
|
+
return [[this, {
|
|
80
|
+
swell: false,
|
|
81
|
+
pad: () => this.reach,
|
|
82
|
+
measure: () => {
|
|
83
|
+
this.label = this.attached ? layout(this.querySelector(LABEL)) : null;
|
|
84
|
+
this.hint = this.attached ? layout(this.querySelector(HINT)) : null;
|
|
85
|
+
const { offsetWidth: w, offsetHeight: h } = this;
|
|
86
|
+
this.reach = 24;
|
|
87
|
+
for (const box of [this.label, this.hint]) if (box) this.reach = Math.max(this.reach, Math.ceil(Math.max(-box.y, -box.x, box.x + box.w - w, box.y + box.h - h)) + 28);
|
|
88
|
+
},
|
|
89
|
+
step: (dt, still) => {
|
|
90
|
+
const moving = [
|
|
91
|
+
this.focused.step(dt, SPRINGS.settle, still),
|
|
92
|
+
this.pulse.step(dt, {
|
|
93
|
+
omega: 22,
|
|
94
|
+
zeta: .3
|
|
95
|
+
}, still),
|
|
96
|
+
this.out.step(dt, {
|
|
97
|
+
omega: 11,
|
|
98
|
+
zeta: .45
|
|
99
|
+
}, still)
|
|
100
|
+
].some(Boolean);
|
|
101
|
+
const vars = `${this.focused.x.toFixed(3)}|${this.out.x.toFixed(3)}`;
|
|
102
|
+
if (vars !== this.lastVars) {
|
|
103
|
+
this.lastVars = vars;
|
|
104
|
+
this.style.setProperty("--clay-pull", this.focused.x.toFixed(3));
|
|
105
|
+
this.style.setProperty("--clay-out", this.out.x.toFixed(3));
|
|
106
|
+
}
|
|
107
|
+
return moving;
|
|
108
|
+
},
|
|
109
|
+
shapes: () => this.shapes()
|
|
110
|
+
}]];
|
|
111
|
+
}
|
|
112
|
+
shapes() {
|
|
113
|
+
const surface = this.surfaces[0];
|
|
114
|
+
const { width: w, height: h } = surface;
|
|
115
|
+
const body = surface.color("--clay-surface", NEUTRAL);
|
|
116
|
+
const f = clamp(this.focused.x, 0, 1);
|
|
117
|
+
const glow = this.invalid ? mix(surface.color("--clay-danger", NEUTRAL), surface.color("--clay-danger-text", NEUTRAL), .3) : mix(surface.color("--clay-color", NEUTRAL), surface.color("--clay-ring", NEUTRAL), .45);
|
|
118
|
+
const rim = mix(body, glow, this.invalid ? .45 + f * .4 : f * .85);
|
|
119
|
+
const radius = this.field instanceof HTMLTextAreaElement ? 20 : Math.min(h / 2, 20);
|
|
120
|
+
const shapes = [{
|
|
121
|
+
x: 0,
|
|
122
|
+
y: 0,
|
|
123
|
+
w,
|
|
124
|
+
h,
|
|
125
|
+
radius,
|
|
126
|
+
color: rim,
|
|
127
|
+
height: .8 + f * .1,
|
|
128
|
+
lift: .45 + f * .15,
|
|
129
|
+
bevel: Math.min(h / 2, 18),
|
|
130
|
+
glow: f * .55
|
|
131
|
+
}];
|
|
132
|
+
const out = clamp(this.out.x, 0, 1.2);
|
|
133
|
+
for (const [box, dir, tint] of [[
|
|
134
|
+
this.label,
|
|
135
|
+
-1,
|
|
136
|
+
.5
|
|
137
|
+
], [
|
|
138
|
+
this.hint,
|
|
139
|
+
1,
|
|
140
|
+
.2
|
|
141
|
+
]]) {
|
|
142
|
+
if (!box) continue;
|
|
143
|
+
const shift = dir * (f * 4 - (1 - out) * 18);
|
|
144
|
+
const bead = {
|
|
145
|
+
x: box.x,
|
|
146
|
+
y: box.y + shift,
|
|
147
|
+
w: box.w,
|
|
148
|
+
h: box.h
|
|
149
|
+
};
|
|
150
|
+
const color = mix(body, rim, tint);
|
|
151
|
+
shapes.push({
|
|
152
|
+
...bead,
|
|
153
|
+
radius: bead.h / 2,
|
|
154
|
+
color,
|
|
155
|
+
height: .8,
|
|
156
|
+
melt: 18,
|
|
157
|
+
lift: .4
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
shapes.push({
|
|
161
|
+
x: 5,
|
|
162
|
+
y: 5,
|
|
163
|
+
w: w - 10,
|
|
164
|
+
h: h - 10,
|
|
165
|
+
radius: Math.max(radius - 5, 4),
|
|
166
|
+
color: mix(deeper(body, .07), [
|
|
167
|
+
1,
|
|
168
|
+
1,
|
|
169
|
+
1
|
|
170
|
+
], f * .1),
|
|
171
|
+
height: -.75 - f * .25 - this.pulse.x * .04,
|
|
172
|
+
bevel: Math.min((h - 10) / 2, 14)
|
|
173
|
+
});
|
|
174
|
+
return shapes;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
/** Pick: radios carved as dents in the clay. A bead hops into the one you choose. */
|
|
178
|
+
var ClayRadio = class extends ClayElement {
|
|
179
|
+
requires = "ui-radio";
|
|
180
|
+
boxes = [];
|
|
181
|
+
x = new Spring(0);
|
|
182
|
+
y = new Spring(0);
|
|
183
|
+
pop = new Spring(0);
|
|
184
|
+
placed = false;
|
|
185
|
+
stop = null;
|
|
186
|
+
setup() {
|
|
187
|
+
this.stop = watch(this, ["data-checked", "data-disabled"], () => this.invalidate());
|
|
188
|
+
}
|
|
189
|
+
teardown() {
|
|
190
|
+
this.stop?.();
|
|
191
|
+
}
|
|
192
|
+
surfaceFor() {
|
|
193
|
+
return [[this, {
|
|
194
|
+
swell: false,
|
|
195
|
+
pad: 18,
|
|
196
|
+
measure: () => this.measure(),
|
|
197
|
+
step: (dt, still) => [
|
|
198
|
+
this.x.step(dt, SPRINGS.travel, still),
|
|
199
|
+
this.y.step(dt, SPRINGS.travel, still),
|
|
200
|
+
this.pop.step(dt, {
|
|
201
|
+
omega: 16,
|
|
202
|
+
zeta: .4
|
|
203
|
+
}, still)
|
|
204
|
+
].some(Boolean),
|
|
205
|
+
shapes: () => this.shapes()
|
|
206
|
+
}]];
|
|
207
|
+
}
|
|
208
|
+
measure() {
|
|
209
|
+
const radios = [...this.querySelectorAll("ui-radio")].slice(0, 7);
|
|
210
|
+
this.boxes = radios.map((radio) => offsetWithin(radio, this));
|
|
211
|
+
const index = radios.findIndex((radio) => radio.hasAttribute("data-checked"));
|
|
212
|
+
const box = this.boxes[index];
|
|
213
|
+
this.pop.target = box ? 1 : 0;
|
|
214
|
+
if (box) {
|
|
215
|
+
this.x.target = box.x + box.w / 2;
|
|
216
|
+
this.y.target = box.y + box.h / 2;
|
|
217
|
+
}
|
|
218
|
+
if (!this.placed) {
|
|
219
|
+
this.x.set(this.x.target);
|
|
220
|
+
this.y.set(this.y.target);
|
|
221
|
+
this.pop.set(this.pop.target);
|
|
222
|
+
this.placed = true;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
shapes() {
|
|
226
|
+
const surface = this.surfaces[0];
|
|
227
|
+
const body = surface.color("--clay-surface", NEUTRAL);
|
|
228
|
+
const shapes = [];
|
|
229
|
+
for (const box of this.boxes) shapes.push({
|
|
230
|
+
x: box.x - 3,
|
|
231
|
+
y: box.y - 3,
|
|
232
|
+
w: box.w + 6,
|
|
233
|
+
h: box.h + 6,
|
|
234
|
+
radius: (box.h + 6) / 2,
|
|
235
|
+
color: body,
|
|
236
|
+
height: .85,
|
|
237
|
+
lift: .4
|
|
238
|
+
}, {
|
|
239
|
+
x: box.x + 2,
|
|
240
|
+
y: box.y + 2,
|
|
241
|
+
w: box.w - 4,
|
|
242
|
+
h: box.h - 4,
|
|
243
|
+
radius: (box.h - 4) / 2,
|
|
244
|
+
color: deeper(body, .1),
|
|
245
|
+
height: -.9
|
|
246
|
+
});
|
|
247
|
+
const size = (this.boxes[0]?.w ?? 0) - 9;
|
|
248
|
+
const speed = Math.hypot(this.x.v, this.y.v);
|
|
249
|
+
const shrink = clamp(speed * .0016, 0, .45);
|
|
250
|
+
const d = size * clamp(this.pop.x, 0, 1.3) * (1 - shrink);
|
|
251
|
+
if (d > .5) shapes.push({
|
|
252
|
+
x: this.x.x - d / 2,
|
|
253
|
+
y: this.y.x - d / 2,
|
|
254
|
+
w: d,
|
|
255
|
+
h: d,
|
|
256
|
+
radius: d / 2,
|
|
257
|
+
color: surface.color("--clay-color", NEUTRAL),
|
|
258
|
+
height: 1,
|
|
259
|
+
lift: .35 + shrink
|
|
260
|
+
});
|
|
261
|
+
return shapes;
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
export { ClayInput, ClayRadio };
|
|
265
|
+
|
|
266
|
+
//# sourceMappingURL=forms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forms.js","names":[],"sources":["../../../../src/clay/components/forms.ts"],"sourcesContent":["import { mix } from \"../color\"\nimport { SPRINGS } from \"../config\"\nimport type { ClayShape } from \"../engine\"\nimport { ClayElement, NEUTRAL } from \"../element\"\nimport { GLUE } from \"../attach\"\nimport { clamp, deeper, watch } from \"../shared\"\nimport { Spring } from \"../spring\"\nimport { offsetWithin, type SurfaceOptions } from \"../surface\"\n\nconst userInvalid = (field: Element) => {\n try {\n return field.matches(\":user-invalid\") || field.getAttribute(\"aria-invalid\") === \"true\"\n } catch {\n return field.getAttribute(\"aria-invalid\") === \"true\"\n }\n}\n\nconst LABEL = \":scope > :is(ui-field-label, [data-slot='field-label'])\"\nconst HINT = \":scope > :is(ui-field-description, [data-slot='field-description'])\"\n\nconst layout = (el: HTMLElement | null) =>\n el && el.offsetParent ? { x: el.offsetLeft, y: el.offsetTop, w: el.offsetWidth, h: el.offsetHeight } : null\n\n/**\n * Type: a text field carved into the clay. Its rim glows while focused and the well gives a little as\n * you type. With `attached`, the label and hint are beads melted onto the rim.\n */\nclass ClayInput extends ClayElement {\n static observedAttributes = [\"color\", \"size\", \"attached\"]\n protected readonly requires = \"input, textarea\"\n private focused = new Spring(0)\n private pulse = new Spring(0)\n private out = new Spring(0)\n private invalid = false\n private label: { x: number; y: number; w: number; h: number } | null = null\n private hint: { x: number; y: number; w: number; h: number } | null = null\n private lastVars = \"\"\n private reach = 24\n private cleanup: Array<() => void> = []\n\n private get field() {\n return this.querySelector<HTMLInputElement | HTMLTextAreaElement>(\"input, textarea\")!\n }\n\n private get attached() {\n return this.hasAttribute(\"attached\")\n }\n\n protected setup() {\n const field = this.field\n const check = () => {\n const invalid = userInvalid(field)\n if (invalid !== this.invalid) {\n this.invalid = invalid\n this.toggleAttribute(\"data-invalid\", invalid)\n this.invalidate()\n }\n }\n const handlers: Array<[string, () => void]> = [\n [\"focus\", () => ((this.focused.target = 1), this.surfaces[0]?.wake())],\n [\"blur\", () => ((this.focused.target = 0), check(), this.surfaces[0]?.wake())],\n [\"input\", () => ((this.pulse.v += 5), check(), this.surfaces[0]?.wake())],\n [\"invalid\", check],\n ]\n for (const [type, handler] of handlers) {\n field.addEventListener(type, handler)\n this.cleanup.push(() => field.removeEventListener(type, handler))\n }\n this.cleanup.push(watch(field, [\"aria-invalid\", \"disabled\"], () => (check(), this.invalidate())))\n if (document.activeElement === field) this.focused.set(1)\n this.out.target = 1\n }\n\n protected teardown() {\n for (const fn of this.cleanup) fn()\n this.cleanup = []\n }\n\n protected surfaceFor(): Array<[HTMLElement, SurfaceOptions]> {\n return [\n [\n this,\n {\n swell: false,\n pad: () => this.reach,\n measure: () => {\n this.label = this.attached ? layout(this.querySelector<HTMLElement>(LABEL)) : null\n this.hint = this.attached ? layout(this.querySelector<HTMLElement>(HINT)) : null\n const { offsetWidth: w, offsetHeight: h } = this\n this.reach = 24\n for (const box of [this.label, this.hint]) {\n if (box) this.reach = Math.max(this.reach, Math.ceil(Math.max(-box.y, -box.x, box.x + box.w - w, box.y + box.h - h)) + 28)\n }\n },\n step: (dt, still) => {\n const moving = [\n this.focused.step(dt, SPRINGS.settle, still),\n this.pulse.step(dt, { omega: 22, zeta: 0.3 }, still),\n this.out.step(dt, { omega: 11, zeta: 0.45 }, still),\n ].some(Boolean)\n const vars = `${this.focused.x.toFixed(3)}|${this.out.x.toFixed(3)}`\n if (vars !== this.lastVars) {\n this.lastVars = vars\n this.style.setProperty(\"--clay-pull\", this.focused.x.toFixed(3))\n this.style.setProperty(\"--clay-out\", this.out.x.toFixed(3))\n }\n return moving\n },\n shapes: () => this.shapes(),\n },\n ],\n ]\n }\n\n private shapes(): ClayShape[] {\n const surface = this.surfaces[0]!\n const { width: w, height: h } = surface\n const body = surface.color(\"--clay-surface\", NEUTRAL)\n const f = clamp(this.focused.x, 0, 1)\n const glow = this.invalid\n ? mix(surface.color(\"--clay-danger\", NEUTRAL), surface.color(\"--clay-danger-text\", NEUTRAL), 0.3)\n : mix(surface.color(\"--clay-color\", NEUTRAL), surface.color(\"--clay-ring\", NEUTRAL), 0.45)\n const rim = mix(body, glow, this.invalid ? 0.45 + f * 0.4 : f * 0.85)\n const radius = this.field instanceof HTMLTextAreaElement ? 20 : Math.min(h / 2, 20)\n const shapes: ClayShape[] = [\n {\n x: 0,\n y: 0,\n w,\n h,\n radius,\n color: rim,\n height: 0.8 + f * 0.1,\n lift: 0.45 + f * 0.15,\n bevel: Math.min(h / 2, 18),\n glow: f * 0.55,\n },\n ]\n const out = clamp(this.out.x, 0, 1.2)\n for (const [box, dir, tint] of [\n [this.label, -1, 0.5],\n [this.hint, 1, 0.2],\n ] as const) {\n if (!box) continue\n const shift = dir * (f * 4 - (1 - out) * 18)\n const bead = { x: box.x, y: box.y + shift, w: box.w, h: box.h }\n const color = mix(body, rim, tint)\n shapes.push({ ...bead, radius: bead.h / 2, color, height: 0.8, melt: GLUE * 0.6, lift: 0.4 })\n }\n shapes.push({\n x: 5,\n y: 5,\n w: w - 10,\n h: h - 10,\n radius: Math.max(radius - 5, 4),\n color: mix(deeper(body, 0.07), [1, 1, 1], f * 0.1),\n height: -0.75 - f * 0.25 - this.pulse.x * 0.04,\n bevel: Math.min((h - 10) / 2, 14),\n })\n return shapes\n }\n}\n\n/** Pick: radios carved as dents in the clay. A bead hops into the one you choose. */\nclass ClayRadio extends ClayElement {\n protected readonly requires = \"ui-radio\"\n private boxes: Array<{ x: number; y: number; w: number; h: number }> = []\n private x = new Spring(0)\n private y = new Spring(0)\n private pop = new Spring(0)\n private placed = false\n private stop: (() => void) | null = null\n\n protected setup() {\n this.stop = watch(this, [\"data-checked\", \"data-disabled\"], () => this.invalidate())\n }\n\n protected teardown() {\n this.stop?.()\n }\n\n protected surfaceFor(): Array<[HTMLElement, SurfaceOptions]> {\n return [\n [\n this,\n {\n swell: false,\n pad: 18,\n measure: () => this.measure(),\n step: (dt, still) =>\n [\n this.x.step(dt, SPRINGS.travel, still),\n this.y.step(dt, SPRINGS.travel, still),\n this.pop.step(dt, { omega: 16, zeta: 0.4 }, still),\n ].some(Boolean),\n shapes: () => this.shapes(),\n },\n ],\n ]\n }\n\n private measure() {\n const radios = [...this.querySelectorAll<HTMLElement>(\"ui-radio\")].slice(0, 7)\n this.boxes = radios.map((radio) => offsetWithin(radio, this))\n const index = radios.findIndex((radio) => radio.hasAttribute(\"data-checked\"))\n const box = this.boxes[index]\n this.pop.target = box ? 1 : 0\n if (box) {\n this.x.target = box.x + box.w / 2\n this.y.target = box.y + box.h / 2\n }\n if (!this.placed) {\n this.x.set(this.x.target)\n this.y.set(this.y.target)\n this.pop.set(this.pop.target)\n this.placed = true\n }\n }\n\n private shapes(): ClayShape[] {\n const surface = this.surfaces[0]!\n const body = surface.color(\"--clay-surface\", NEUTRAL)\n const shapes: ClayShape[] = []\n for (const box of this.boxes) {\n shapes.push(\n { x: box.x - 3, y: box.y - 3, w: box.w + 6, h: box.h + 6, radius: (box.h + 6) / 2, color: body, height: 0.85, lift: 0.4 },\n { x: box.x + 2, y: box.y + 2, w: box.w - 4, h: box.h - 4, radius: (box.h - 4) / 2, color: deeper(body, 0.1), height: -0.9 }\n )\n }\n const size = (this.boxes[0]?.w ?? 0) - 9\n const speed = Math.hypot(this.x.v, this.y.v)\n const shrink = clamp(speed * 0.0016, 0, 0.45)\n const d = size * clamp(this.pop.x, 0, 1.3) * (1 - shrink)\n if (d > 0.5) {\n shapes.push({\n x: this.x.x - d / 2,\n y: this.y.x - d / 2,\n w: d,\n h: d,\n radius: d / 2,\n color: surface.color(\"--clay-color\", NEUTRAL),\n height: 1,\n lift: 0.35 + shrink,\n })\n }\n return shapes\n }\n}\n\nexport { ClayInput, ClayRadio }\n"],"mappings":";;;;;;;;AASA,IAAM,eAAe,UAAmB;CACtC,IAAI;EACF,OAAO,MAAM,QAAQ,eAAe,KAAK,MAAM,aAAa,cAAc,MAAM;CAClF,QAAQ;EACN,OAAO,MAAM,aAAa,cAAc,MAAM;CAChD;AACF;AAEA,IAAM,QAAQ;AACd,IAAM,OAAO;AAEb,IAAM,UAAU,OACd,MAAM,GAAG,eAAe;CAAE,GAAG,GAAG;CAAY,GAAG,GAAG;CAAW,GAAG,GAAG;CAAa,GAAG,GAAG;AAAa,IAAI;;;;;AAMzG,IAAM,YAAN,cAAwB,YAAY;CAClC,OAAO,qBAAqB;EAAC;EAAS;EAAQ;CAAU;CACxD,WAA8B;CAC9B,UAAkB,IAAI,OAAO,CAAC;CAC9B,QAAgB,IAAI,OAAO,CAAC;CAC5B,MAAc,IAAI,OAAO,CAAC;CAC1B,UAAkB;CAClB,QAAuE;CACvE,OAAsE;CACtE,WAAmB;CACnB,QAAgB;CAChB,UAAqC,CAAC;CAEtC,IAAY,QAAQ;EAClB,OAAO,KAAK,cAAsD,iBAAiB;CACrF;CAEA,IAAY,WAAW;EACrB,OAAO,KAAK,aAAa,UAAU;CACrC;CAEA,QAAkB;EAChB,MAAM,QAAQ,KAAK;EACnB,MAAM,cAAc;GAClB,MAAM,UAAU,YAAY,KAAK;GACjC,IAAI,YAAY,KAAK,SAAS;IAC5B,KAAK,UAAU;IACf,KAAK,g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KAAK,OACrB,OAAO,KACL;GAAE,GAAG,IAAI,IAAI;GAAG,GAAG,IAAI,IAAI;GAAG,GAAG,IAAI,IAAI;GAAG,GAAG,IAAI,IAAI;GAAG,SAAS,IAAI,IAAI,KAAK;GAAG,OAAO;GAAM,QAAQ;GAAM,MAAM;EAAI,GACxH;GAAE,GAAG,IAAI,IAAI;GAAG,GAAG,IAAI,IAAI;GAAG,GAAG,IAAI,IAAI;GAAG,GAAG,IAAI,IAAI;GAAG,SAAS,IAAI,IAAI,KAAK;GAAG,OAAO,OAAO,MAAM,EAAG;GAAG,QAAQ;EAAK,CAC5H;EAEF,MAAM,QAAQ,KAAK,MAAM,EAAE,EAAE,KAAK,KAAK;EACvC,MAAM,QAAQ,KAAK,MAAM,KAAK,EAAE,GAAG,KAAK,EAAE,CAAC;EAC3C,MAAM,SAAS,MAAM,QAAQ,OAAQ,GAAG,GAAI;EAC5C,MAAM,IAAI,OAAO,MAAM,KAAK,IAAI,GAAG,GAAG,GAAG,KAAK,IAAI;EAClD,IAAI,IAAI,IACN,OAAO,KAAK;GACV,GAAG,KAAK,EAAE,IAAI,IAAI;GAClB,GAAG,KAAK,EAAE,IAAI,IAAI;GAClB,GAAG;GACH,GAAG;GACH,QAAQ,IAAI;GACZ,OAAO,QAAQ,MAAM,gBAAgB,OAAO;GAC5C,QAAQ;GACR,MAAM,MAAO;EACf,CAAC;EAEH,OAAO;CACT;AACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ClayElement } from "../element.js";
|
|
2
|
+
import { type SurfaceOptions } from "../surface.js";
|
|
3
|
+
/** Latch: a toggle whose body sinks into a coloured well while it's on, and pops back out. */
|
|
4
|
+
declare class ClayToggle extends ClayElement {
|
|
5
|
+
static observedAttributes: string[];
|
|
6
|
+
protected readonly requires = "ui-toggle button";
|
|
7
|
+
private latch;
|
|
8
|
+
private placed;
|
|
9
|
+
private stop;
|
|
10
|
+
protected setup(): void;
|
|
11
|
+
protected teardown(): void;
|
|
12
|
+
protected surfaceFor(): Array<[HTMLElement, SurfaceOptions]>;
|
|
13
|
+
private shapes;
|
|
14
|
+
}
|
|
15
|
+
/** Fuse: related buttons fused into one clay body. Each part gives on its own. */
|
|
16
|
+
declare class ClayButtonGroup extends ClayElement {
|
|
17
|
+
static observedAttributes: string[];
|
|
18
|
+
protected readonly requires = "button";
|
|
19
|
+
private items;
|
|
20
|
+
private cleanup;
|
|
21
|
+
protected setup(): void;
|
|
22
|
+
protected teardown(): void;
|
|
23
|
+
protected surfaceFor(): Array<[HTMLElement, SurfaceOptions]>;
|
|
24
|
+
private shapes;
|
|
25
|
+
}
|
|
26
|
+
export { ClayButtonGroup, ClayToggle };
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { mix } from "../color.js";
|
|
2
|
+
import { SPRINGS } from "../config.js";
|
|
3
|
+
import { ClayElement, NEUTRAL } from "../element.js";
|
|
4
|
+
import { clamp, deeper, watch } from "../shared.js";
|
|
5
|
+
import { Spring } from "../spring.js";
|
|
6
|
+
import { offsetWithin } from "../surface.js";
|
|
7
|
+
// src/clay/components/group.ts
|
|
8
|
+
var isOn = (button) => button.getAttribute("aria-pressed") === "true";
|
|
9
|
+
/** Latch: a toggle whose body sinks into a coloured well while it's on, and pops back out. */
|
|
10
|
+
var ClayToggle = class extends ClayElement {
|
|
11
|
+
static observedAttributes = [
|
|
12
|
+
"color",
|
|
13
|
+
"size",
|
|
14
|
+
"shape"
|
|
15
|
+
];
|
|
16
|
+
requires = "ui-toggle button";
|
|
17
|
+
latch = new Spring(0);
|
|
18
|
+
placed = false;
|
|
19
|
+
stop = null;
|
|
20
|
+
setup() {
|
|
21
|
+
const sync = () => {
|
|
22
|
+
this.dataset.pressed = String(isOn(this.querySelector("ui-toggle button")));
|
|
23
|
+
this.invalidate();
|
|
24
|
+
};
|
|
25
|
+
this.stop = watch(this, ["aria-pressed"], sync);
|
|
26
|
+
sync();
|
|
27
|
+
}
|
|
28
|
+
teardown() {
|
|
29
|
+
this.stop?.();
|
|
30
|
+
}
|
|
31
|
+
surfaceFor() {
|
|
32
|
+
return [[this, {
|
|
33
|
+
measure: () => {
|
|
34
|
+
const on = isOn(this.querySelector("ui-toggle button")) ? 1 : 0;
|
|
35
|
+
this.latch.target = on;
|
|
36
|
+
if (!this.placed) {
|
|
37
|
+
this.latch.set(on);
|
|
38
|
+
this.placed = true;
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
step: (dt, still) => this.latch.step(dt, {
|
|
42
|
+
omega: 17,
|
|
43
|
+
zeta: .42
|
|
44
|
+
}, still),
|
|
45
|
+
shapes: () => this.shapes()
|
|
46
|
+
}]];
|
|
47
|
+
}
|
|
48
|
+
shapes() {
|
|
49
|
+
const surface = this.surfaces[0];
|
|
50
|
+
const { width: w, height: h } = surface;
|
|
51
|
+
const press = surface.press.x;
|
|
52
|
+
const l = this.latch.x;
|
|
53
|
+
const on = clamp(l, 0, 1);
|
|
54
|
+
const body = surface.color("--clay-surface", NEUTRAL);
|
|
55
|
+
const accent = surface.color("--clay-color", NEUTRAL);
|
|
56
|
+
const radius = this.getAttribute("shape") === "rounded" ? Math.min(h * .34, 18) : h / 2;
|
|
57
|
+
const inset = 4 + on * 1.5;
|
|
58
|
+
return [{
|
|
59
|
+
x: 0,
|
|
60
|
+
y: 0,
|
|
61
|
+
w,
|
|
62
|
+
h,
|
|
63
|
+
radius,
|
|
64
|
+
color: body,
|
|
65
|
+
height: 1 - press * .35 - on * .15,
|
|
66
|
+
lift: 1 + surface.hover.x * .3 - press * .5 - on * .45
|
|
67
|
+
}, {
|
|
68
|
+
x: inset,
|
|
69
|
+
y: inset,
|
|
70
|
+
w: w - inset * 2,
|
|
71
|
+
h: h - inset * 2,
|
|
72
|
+
radius: Math.max(radius - inset, 4),
|
|
73
|
+
color: mix(mix(body, [
|
|
74
|
+
1,
|
|
75
|
+
1,
|
|
76
|
+
1
|
|
77
|
+
], .18), accent, on),
|
|
78
|
+
height: .55 - l * 1.35 - press * .3
|
|
79
|
+
}];
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
/** Fuse: related buttons fused into one clay body. Each part gives on its own. */
|
|
83
|
+
var ClayButtonGroup = class extends ClayElement {
|
|
84
|
+
static observedAttributes = ["color", "size"];
|
|
85
|
+
requires = "button";
|
|
86
|
+
items = [];
|
|
87
|
+
cleanup = [];
|
|
88
|
+
setup() {
|
|
89
|
+
if (!this.hasAttribute("role")) this.setAttribute("role", "group");
|
|
90
|
+
this.items = [...this.querySelectorAll("button")].slice(0, 16).map((button) => ({
|
|
91
|
+
button,
|
|
92
|
+
box: {
|
|
93
|
+
x: 0,
|
|
94
|
+
y: 0,
|
|
95
|
+
w: 0,
|
|
96
|
+
h: 0
|
|
97
|
+
},
|
|
98
|
+
hover: new Spring(0),
|
|
99
|
+
press: new Spring(0),
|
|
100
|
+
on: new Spring(0),
|
|
101
|
+
placed: false
|
|
102
|
+
}));
|
|
103
|
+
for (const item of this.items) {
|
|
104
|
+
const set = (spring, value) => {
|
|
105
|
+
spring.target = value && !item.button.disabled ? 1 : 0;
|
|
106
|
+
this.surfaces[0]?.wake();
|
|
107
|
+
};
|
|
108
|
+
const handlers = [
|
|
109
|
+
["pointerenter", () => set(item.hover, 1)],
|
|
110
|
+
["pointerleave", () => (set(item.hover, 0), set(item.press, 0))],
|
|
111
|
+
["pointerdown", (event) => event.button === 0 && set(item.press, 1)],
|
|
112
|
+
["pointerup", () => set(item.press, 0)],
|
|
113
|
+
["pointercancel", () => set(item.press, 0)],
|
|
114
|
+
["keydown", (event) => {
|
|
115
|
+
const key = event.key;
|
|
116
|
+
if (!event.repeat && (key === " " || key === "Enter")) set(item.press, 1);
|
|
117
|
+
}],
|
|
118
|
+
["keyup", () => set(item.press, 0)],
|
|
119
|
+
["blur", () => set(item.press, 0)]
|
|
120
|
+
];
|
|
121
|
+
for (const [type, handler] of handlers) {
|
|
122
|
+
item.button.addEventListener(type, handler);
|
|
123
|
+
this.cleanup.push(() => item.button.removeEventListener(type, handler));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
this.cleanup.push(watch(this, ["aria-pressed", "disabled"], () => this.invalidate()));
|
|
127
|
+
}
|
|
128
|
+
teardown() {
|
|
129
|
+
for (const fn of this.cleanup) fn();
|
|
130
|
+
this.cleanup = [];
|
|
131
|
+
}
|
|
132
|
+
surfaceFor() {
|
|
133
|
+
return [[this, {
|
|
134
|
+
swell: false,
|
|
135
|
+
measure: () => {
|
|
136
|
+
for (const item of this.items) {
|
|
137
|
+
item.box = offsetWithin(item.button, this);
|
|
138
|
+
item.on.target = isOn(item.button) ? 1 : 0;
|
|
139
|
+
if (!item.placed) {
|
|
140
|
+
item.on.set(item.on.target);
|
|
141
|
+
item.placed = true;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
step: (dt, still) => this.items.flatMap((item) => [
|
|
146
|
+
item.hover.step(dt, SPRINGS.hover, still),
|
|
147
|
+
item.press.step(dt, SPRINGS.press, still),
|
|
148
|
+
item.on.step(dt, {
|
|
149
|
+
omega: 17,
|
|
150
|
+
zeta: .45
|
|
151
|
+
}, still)
|
|
152
|
+
]).some(Boolean),
|
|
153
|
+
shapes: () => this.shapes()
|
|
154
|
+
}]];
|
|
155
|
+
}
|
|
156
|
+
shapes() {
|
|
157
|
+
const color = this.surfaces[0].color("--clay-color", NEUTRAL);
|
|
158
|
+
const sunk = deeper(color, .14);
|
|
159
|
+
return this.items.map((item, index) => {
|
|
160
|
+
const { x, y, w, h } = item.box;
|
|
161
|
+
const press = item.press.x;
|
|
162
|
+
const on = clamp(item.on.x, 0, 1);
|
|
163
|
+
const give = press * 2.5 - item.hover.x * 1;
|
|
164
|
+
return {
|
|
165
|
+
x: x + give,
|
|
166
|
+
y: y + give * .6,
|
|
167
|
+
w: w - give * 2,
|
|
168
|
+
h: h - give * 1.2,
|
|
169
|
+
radius: h / 2,
|
|
170
|
+
color: mix(color, sunk, on),
|
|
171
|
+
height: 1 + item.hover.x * .12 - press * .55 - item.on.x * 1.3,
|
|
172
|
+
melt: index === 0 ? 0 : 16,
|
|
173
|
+
lift: 1 + item.hover.x * .2 - press * .4
|
|
174
|
+
};
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
export { ClayButtonGroup, ClayToggle };
|
|
179
|
+
|
|
180
|
+
//# sourceMappingURL=group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group.js","names":[],"sources":["../../../../src/clay/components/group.ts"],"sourcesContent":["import { mix } from \"../color\"\nimport { SPRINGS } from \"../config\"\nimport type { ClayShape } from \"../engine\"\nimport { ClayElement, NEUTRAL } from \"../element\"\nimport { clamp, deeper, watch } from \"../shared\"\nimport { Spring } from \"../spring\"\nimport { offsetWithin, type SurfaceOptions } from \"../surface\"\n\nconst isOn = (button: Element) => button.getAttribute(\"aria-pressed\") === \"true\"\n\n/** Latch: a toggle whose body sinks into a coloured well while it's on, and pops back out. */\nclass ClayToggle extends ClayElement {\n static observedAttributes = [\"color\", \"size\", \"shape\"]\n protected readonly requires = \"ui-toggle button\"\n private latch = new Spring(0)\n private placed = false\n private stop: (() => void) | null = null\n\n protected setup() {\n const sync = () => {\n this.dataset.pressed = String(isOn(this.querySelector(\"ui-toggle button\")!))\n this.invalidate()\n }\n this.stop = watch(this, [\"aria-pressed\"], sync)\n sync()\n }\n\n protected teardown() {\n this.stop?.()\n }\n\n protected surfaceFor(): Array<[HTMLElement, SurfaceOptions]> {\n return [\n [\n this,\n {\n measure: () => {\n const on = isOn(this.querySelector(\"ui-toggle button\")!) ? 1 : 0\n this.latch.target = on\n if (!this.placed) {\n this.latch.set(on)\n this.placed = true\n }\n },\n step: (dt, still) => this.latch.step(dt, { omega: 17, zeta: 0.42 }, still),\n shapes: () => this.shapes(),\n },\n ],\n ]\n }\n\n private shapes(): ClayShape[] {\n const surface = this.surfaces[0]!\n const { width: w, height: h } = surface\n const press = surface.press.x\n const l = this.latch.x\n const on = clamp(l, 0, 1)\n const body = surface.color(\"--clay-surface\", NEUTRAL)\n const accent = surface.color(\"--clay-color\", NEUTRAL)\n const radius = this.getAttribute(\"shape\") === \"rounded\" ? Math.min(h * 0.34, 18) : h / 2\n const inset = 4 + on * 1.5\n return [\n {\n x: 0,\n y: 0,\n w,\n h,\n radius,\n color: body,\n height: 1 - press * 0.35 - on * 0.15,\n lift: 1 + surface.hover.x * 0.3 - press * 0.5 - on * 0.45,\n },\n {\n x: inset,\n y: inset,\n w: w - inset * 2,\n h: h - inset * 2,\n radius: Math.max(radius - inset, 4),\n color: mix(mix(body, [1, 1, 1], 0.18), accent, on),\n height: 0.55 - l * 1.35 - press * 0.3,\n },\n ]\n }\n}\n\ninterface Item {\n button: HTMLButtonElement\n box: { x: number; y: number; w: number; h: number }\n hover: Spring\n press: Spring\n on: Spring\n placed: boolean\n}\n\n/** Fuse: related buttons fused into one clay body. Each part gives on its own. */\nclass ClayButtonGroup extends ClayElement {\n static observedAttributes = [\"color\", \"size\"]\n protected readonly requires = \"button\"\n private items: Item[] = []\n private cleanup: Array<() => void> = []\n\n protected setup() {\n if (!this.hasAttribute(\"role\")) this.setAttribute(\"role\", \"group\")\n this.items = [...this.querySelectorAll(\"button\")].slice(0, 16).map((button) => ({\n button,\n box: { x: 0, y: 0, w: 0, h: 0 },\n hover: new Spring(0),\n press: new Spring(0),\n on: new Spring(0),\n placed: false,\n }))\n for (const item of this.items) {\n const set = (spring: Spring, value: number) => {\n spring.target = value && !item.button.disabled ? 1 : 0\n this.surfaces[0]?.wake()\n }\n const handlers: Array<[string, (event: Event) => void]> = [\n [\"pointerenter\", () => set(item.hover, 1)],\n [\"pointerleave\", () => (set(item.hover, 0), set(item.press, 0))],\n [\"pointerdown\", (event) => (event as PointerEvent).button === 0 && set(item.press, 1)],\n [\"pointerup\", () => set(item.press, 0)],\n [\"pointercancel\", () => set(item.press, 0)],\n [\"keydown\", (event) => {\n const key = (event as KeyboardEvent).key\n if (!(event as KeyboardEvent).repeat && (key === \" \" || key === \"Enter\")) set(item.press, 1)\n }],\n [\"keyup\", () => set(item.press, 0)],\n [\"blur\", () => set(item.press, 0)],\n ]\n for (const [type, handler] of handlers) {\n item.button.addEventListener(type, handler)\n this.cleanup.push(() => item.button.removeEventListener(type, handler))\n }\n }\n this.cleanup.push(watch(this, [\"aria-pressed\", \"disabled\"], () => this.invalidate()))\n }\n\n protected teardown() {\n for (const fn of this.cleanup) fn()\n this.cleanup = []\n }\n\n protected surfaceFor(): Array<[HTMLElement, SurfaceOptions]> {\n return [\n [\n this,\n {\n swell: false,\n measure: () => {\n for (const item of this.items) {\n item.box = offsetWithin(item.button, this)\n item.on.target = isOn(item.button) ? 1 : 0\n if (!item.placed) {\n item.on.set(item.on.target)\n item.placed = true\n }\n }\n },\n step: (dt, still) =>\n this.items\n .flatMap((item) => [\n item.hover.step(dt, SPRINGS.hover, still),\n item.press.step(dt, SPRINGS.press, still),\n item.on.step(dt, { omega: 17, zeta: 0.45 }, still),\n ])\n .some(Boolean),\n shapes: () => this.shapes(),\n },\n ],\n ]\n }\n\n private shapes(): ClayShape[] {\n const surface = this.surfaces[0]!\n const color = surface.color(\"--clay-color\", NEUTRAL)\n const sunk = deeper(color, 0.14)\n return this.items.map((item, index) => {\n const { x, y, w, h } = item.box\n const press = item.press.x\n const on = clamp(item.on.x, 0, 1)\n const give = press * 2.5 - item.hover.x * 1\n return {\n x: x + give,\n y: y + give * 0.6,\n w: w - give * 2,\n h: h - give * 1.2,\n radius: h / 2,\n color: mix(color, sunk, on),\n height: 1 + item.hover.x * 0.12 - press * 0.55 - item.on.x * 1.3,\n melt: index === 0 ? 0 : 16,\n lift: 1 + item.hover.x * 0.2 - press * 0.4,\n }\n })\n }\n}\n\nexport { ClayButtonGroup, ClayToggle }\n"],"mappings":";;;;;;;AAQA,IAAM,QAAQ,WAAoB,OAAO,aAAa,cAAc,MAAM;;AAG1E,IAAM,aAAN,cAAyB,YAAY;CACnC,OAAO,qBAAqB;EAAC;EAAS;EAAQ;CAAO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CAEA,SAA8B;EAE5B,MAAM,QADU,KAAK,SAAS,EAChB,CAAQ,MAAM,gBAAgB,OAAO;EACnD,MAAM,OAAO,OAAO,OAAO,GAAI;EAC/B,OAAO,KAAK,MAAM,KAAK,MAAM,UAAU;GACrC,MAAM,EAAE,GAAG,GAAG,GAAG,MAAM,KAAK;GAC5B,MAAM,QAAQ,KAAK,MAAM;GACzB,MAAM,KAAK,MAAM,KAAK,GAAG,GAAG,GAAG,CAAC;GAChC,MAAM,OAAO,QAAQ,MAAM,KAAK,MAAM,IAAI;GAC1C,OAAO;IACL,GAAG,IAAI;IACP,GAAG,IAAI,OAAO;IACd,GAAG,IAAI,OAAO;IACd,GAAG,IAAI,OAAO;IACd,QAAQ,IAAI;IACZ,OAAO,IAAI,OAAO,MAAM,EAAE;IAC1B,QAAQ,IAAI,KAAK,MAAM,IAAI,MAAO,QAAQ,MAAO,KAAK,GAAG,IAAI;IAC7D,MAAM,UAAU,IAAI,IAAI;IACxB,MAAM,IAAI,KAAK,MAAM,IAAI,KAAM,QAAQ;GACzC;EACF,CAAC;CACH;AACF"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ClayElement } from "../element.js";
|
|
2
|
+
import type { SurfaceOptions } from "../surface.js";
|
|
3
|
+
/**
|
|
4
|
+
* A trigger drawn as a clay button, and a popup drawn as a clay slab that grows out of it. With
|
|
5
|
+
* `attached`, the popup squeezes out of the button like Roll's bead and stays melted onto it.
|
|
6
|
+
*/
|
|
7
|
+
declare abstract class ClayPopupElement extends ClayElement {
|
|
8
|
+
static observedAttributes: string[];
|
|
9
|
+
protected abstract readonly trigger: string;
|
|
10
|
+
protected abstract readonly content: string;
|
|
11
|
+
protected popupRadius: number;
|
|
12
|
+
protected popupBevel: number;
|
|
13
|
+
protected popupLift: number;
|
|
14
|
+
/** Dialogs sit in the middle of the page, away from their trigger. */
|
|
15
|
+
protected attachable: boolean;
|
|
16
|
+
/** Items a sliding highlight follows, for menus. */
|
|
17
|
+
protected items: string;
|
|
18
|
+
private attachment;
|
|
19
|
+
private highlight;
|
|
20
|
+
private refit;
|
|
21
|
+
private cleanup;
|
|
22
|
+
attributeChangedCallback(name: string, old: string | null, value: string | null): void;
|
|
23
|
+
private get triggerButton();
|
|
24
|
+
protected setup(): void;
|
|
25
|
+
protected teardown(): void;
|
|
26
|
+
protected surfaceFor(): Array<[HTMLElement, SurfaceOptions]>;
|
|
27
|
+
}
|
|
28
|
+
/** Spill: a menu of actions that spills out of its clay button. */
|
|
29
|
+
declare class ClayMenu extends ClayPopupElement {
|
|
30
|
+
protected readonly requires = "ui-menu-trigger";
|
|
31
|
+
protected items: string;
|
|
32
|
+
protected readonly trigger = "ui-menu-trigger";
|
|
33
|
+
protected readonly content = "ui-menu-content";
|
|
34
|
+
protected popupRadius: number;
|
|
35
|
+
}
|
|
36
|
+
/** Unfold: a small clay card that unfolds from its button. */
|
|
37
|
+
declare class ClayPopover extends ClayPopupElement {
|
|
38
|
+
protected readonly requires = "ui-popover-trigger";
|
|
39
|
+
protected readonly trigger = "ui-popover-trigger";
|
|
40
|
+
protected readonly content = "ui-popover-content";
|
|
41
|
+
protected popupRadius: number;
|
|
42
|
+
protected popupBevel: number;
|
|
43
|
+
}
|
|
44
|
+
/** Lift: a dialog lifted out of the page as a thick clay slab. */
|
|
45
|
+
declare class ClayDialog extends ClayPopupElement {
|
|
46
|
+
protected readonly requires = "ui-dialog-content";
|
|
47
|
+
protected attachable: boolean;
|
|
48
|
+
protected readonly trigger = "ui-dialog-trigger";
|
|
49
|
+
protected readonly content = "ui-dialog-content";
|
|
50
|
+
protected popupRadius: number;
|
|
51
|
+
protected popupBevel: number;
|
|
52
|
+
protected popupLift: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Drop: toasts that drop in as clay slabs, squash as they land and lift back off the same way.
|
|
56
|
+
* With `attached`, the stack is one body: each toast pulls out of the one before it and stays melted
|
|
57
|
+
* onto it, and leaving runs the same path back.
|
|
58
|
+
*/
|
|
59
|
+
declare class ClayToastRegion extends ClayElement {
|
|
60
|
+
static observedAttributes: string[];
|
|
61
|
+
protected readonly requires = "ui-toast-region";
|
|
62
|
+
private loose;
|
|
63
|
+
private links;
|
|
64
|
+
private stack;
|
|
65
|
+
private observer;
|
|
66
|
+
private get attached();
|
|
67
|
+
private get region();
|
|
68
|
+
attributeChangedCallback(name: string, old: string | null, value: string | null): void;
|
|
69
|
+
protected setup(): void;
|
|
70
|
+
protected teardown(): void;
|
|
71
|
+
protected surfaceFor(): Array<[HTMLElement, SurfaceOptions]>;
|
|
72
|
+
private reset;
|
|
73
|
+
private rebuild;
|
|
74
|
+
private sync;
|
|
75
|
+
/** Notes where a toast's layout box is now and, if the list moved it, keeps it where it was to glide. */
|
|
76
|
+
private follow;
|
|
77
|
+
private slide;
|
|
78
|
+
private syncLoose;
|
|
79
|
+
private landed;
|
|
80
|
+
private get towardEdge();
|
|
81
|
+
private syncStack;
|
|
82
|
+
/** Which way, in px along the stack, the toast's text should travel to reach its anchor. */
|
|
83
|
+
private toward;
|
|
84
|
+
private measureStack;
|
|
85
|
+
private stepStack;
|
|
86
|
+
private placed;
|
|
87
|
+
private stackShapes;
|
|
88
|
+
}
|
|
89
|
+
export { ClayDialog, ClayMenu, ClayPopover, ClayToastRegion };
|