claymorph-ui 0.0.0-stage → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +77 -2
  3. package/dist/attach.d.ts +115 -0
  4. package/dist/attach.js +328 -0
  5. package/dist/attach.js.map +1 -0
  6. package/dist/clay.css +1648 -0
  7. package/dist/color.d.ts +5 -0
  8. package/dist/color.js +44 -0
  9. package/dist/color.js.map +1 -0
  10. package/dist/components/action-button.d.ts +31 -0
  11. package/dist/components/action-button.js +158 -0
  12. package/dist/components/action-button.js.map +1 -0
  13. package/dist/components/bars.d.ts +33 -0
  14. package/dist/components/bars.js +135 -0
  15. package/dist/components/bars.js.map +1 -0
  16. package/dist/components/button.d.ts +10 -0
  17. package/dist/components/button.js +36 -0
  18. package/dist/components/button.js.map +1 -0
  19. package/dist/components/card.d.ts +24 -0
  20. package/dist/components/card.js +139 -0
  21. package/dist/components/card.js.map +1 -0
  22. package/dist/components/controls.d.ts +54 -0
  23. package/dist/components/controls.js +310 -0
  24. package/dist/components/controls.js.map +1 -0
  25. package/dist/components/forms.d.ts +41 -0
  26. package/dist/components/forms.js +266 -0
  27. package/dist/components/forms.js.map +1 -0
  28. package/dist/components/group.d.ts +26 -0
  29. package/dist/components/group.js +180 -0
  30. package/dist/components/group.js.map +1 -0
  31. package/dist/components/overlays.d.ts +89 -0
  32. package/dist/components/overlays.js +383 -0
  33. package/dist/components/overlays.js.map +1 -0
  34. package/dist/components/popups.d.ts +55 -0
  35. package/dist/components/popups.js +308 -0
  36. package/dist/components/popups.js.map +1 -0
  37. package/dist/components/slide.d.ts +34 -0
  38. package/dist/components/slide.js +234 -0
  39. package/dist/components/slide.js.map +1 -0
  40. package/dist/components/tabs.d.ts +20 -0
  41. package/dist/components/tabs.js +105 -0
  42. package/dist/components/tabs.js.map +1 -0
  43. package/dist/config.d.ts +48 -0
  44. package/dist/config.js +50 -0
  45. package/dist/config.js.map +1 -0
  46. package/dist/element.d.ts +39 -0
  47. package/dist/element.js +135 -0
  48. package/dist/element.js.map +1 -0
  49. package/dist/engine.d.ts +91 -0
  50. package/dist/engine.js +454 -0
  51. package/dist/engine.js.map +1 -0
  52. package/dist/entries/action-button.d.ts +8 -0
  53. package/dist/entries/action-button.js +8 -0
  54. package/dist/entries/action-button.js.map +1 -0
  55. package/dist/entries/avatar.d.ts +8 -0
  56. package/dist/entries/avatar.js +8 -0
  57. package/dist/entries/avatar.js.map +1 -0
  58. package/dist/entries/badge.d.ts +7 -0
  59. package/dist/entries/badge.js +7 -0
  60. package/dist/entries/badge.js.map +1 -0
  61. package/dist/entries/button-group.d.ts +9 -0
  62. package/dist/entries/button-group.js +9 -0
  63. package/dist/entries/button-group.js.map +1 -0
  64. package/dist/entries/button.d.ts +8 -0
  65. package/dist/entries/button.js +8 -0
  66. package/dist/entries/button.js.map +1 -0
  67. package/dist/entries/card.d.ts +7 -0
  68. package/dist/entries/card.js +7 -0
  69. package/dist/entries/card.js.map +1 -0
  70. package/dist/entries/checkbox.d.ts +9 -0
  71. package/dist/entries/checkbox.js +9 -0
  72. package/dist/entries/checkbox.js.map +1 -0
  73. package/dist/entries/dialog.d.ts +8 -0
  74. package/dist/entries/dialog.js +8 -0
  75. package/dist/entries/dialog.js.map +1 -0
  76. package/dist/entries/input.d.ts +9 -0
  77. package/dist/entries/input.js +9 -0
  78. package/dist/entries/input.js.map +1 -0
  79. package/dist/entries/menu.d.ts +8 -0
  80. package/dist/entries/menu.js +8 -0
  81. package/dist/entries/menu.js.map +1 -0
  82. package/dist/entries/meter.d.ts +8 -0
  83. package/dist/entries/meter.js +8 -0
  84. package/dist/entries/meter.js.map +1 -0
  85. package/dist/entries/popover.d.ts +8 -0
  86. package/dist/entries/popover.js +8 -0
  87. package/dist/entries/popover.js.map +1 -0
  88. package/dist/entries/progress.d.ts +8 -0
  89. package/dist/entries/progress.js +8 -0
  90. package/dist/entries/progress.js.map +1 -0
  91. package/dist/entries/radio.d.ts +9 -0
  92. package/dist/entries/radio.js +9 -0
  93. package/dist/entries/radio.js.map +1 -0
  94. package/dist/entries/segmented.d.ts +8 -0
  95. package/dist/entries/segmented.js +8 -0
  96. package/dist/entries/segmented.js.map +1 -0
  97. package/dist/entries/select.d.ts +8 -0
  98. package/dist/entries/select.js +8 -0
  99. package/dist/entries/select.js.map +1 -0
  100. package/dist/entries/slide-confirm.d.ts +8 -0
  101. package/dist/entries/slide-confirm.js +8 -0
  102. package/dist/entries/slide-confirm.js.map +1 -0
  103. package/dist/entries/slider.d.ts +9 -0
  104. package/dist/entries/slider.js +9 -0
  105. package/dist/entries/slider.js.map +1 -0
  106. package/dist/entries/switch.d.ts +9 -0
  107. package/dist/entries/switch.js +9 -0
  108. package/dist/entries/switch.js.map +1 -0
  109. package/dist/entries/tabs.d.ts +8 -0
  110. package/dist/entries/tabs.js +8 -0
  111. package/dist/entries/tabs.js.map +1 -0
  112. package/dist/entries/toast.d.ts +9 -0
  113. package/dist/entries/toast.js +8 -0
  114. package/dist/entries/toast.js.map +1 -0
  115. package/dist/entries/toggle.d.ts +8 -0
  116. package/dist/entries/toggle.js +8 -0
  117. package/dist/entries/toggle.js.map +1 -0
  118. package/dist/entries/tooltip.d.ts +8 -0
  119. package/dist/entries/tooltip.js +8 -0
  120. package/dist/entries/tooltip.js.map +1 -0
  121. package/dist/highlight.d.ts +26 -0
  122. package/dist/highlight.js +100 -0
  123. package/dist/highlight.js.map +1 -0
  124. package/dist/index.d.ts +29 -0
  125. package/dist/index.js +37 -0
  126. package/dist/shared.d.ts +28 -0
  127. package/dist/shared.js +80 -0
  128. package/dist/shared.js.map +1 -0
  129. package/dist/spring.d.ts +14 -0
  130. package/dist/spring.js +50 -0
  131. package/dist/spring.js.map +1 -0
  132. package/dist/surface.d.ts +88 -0
  133. package/dist/surface.js +240 -0
  134. package/dist/surface.js.map +1 -0
  135. package/package.json +140 -4
@@ -0,0 +1,308 @@
1
+ import { Attachment, fuseOf, hug } from "../attach.js";
2
+ import { luminance, resolveColor } from "../color.js";
3
+ import { ClayElement, NEUTRAL } from "../element.js";
4
+ import { Highlight, withHighlight } from "../highlight.js";
5
+ import { pressable, slab, watch } from "../shared.js";
6
+ import { offsetWithin } from "../surface.js";
7
+ // src/clay/components/popups.ts
8
+ var reducedMotion = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
9
+ /** A soft edge three times wider than the text: sliding it across wipes the text in from the left. */
10
+ var WIPE_IN = "linear-gradient(90deg, #000 45%, transparent 55%)";
11
+ var WIPE_OUT = "linear-gradient(90deg, transparent 45%, #000 55%)";
12
+ function wipe(el, mask, blur, opacity) {
13
+ el.style.setProperty("mask-image", mask);
14
+ el.style.setProperty("-webkit-mask-image", mask);
15
+ el.style.setProperty("mask-size", "300% 100%");
16
+ el.style.setProperty("-webkit-mask-size", "300% 100%");
17
+ const animation = el.animate([{
18
+ maskPosition: "100% 0",
19
+ webkitMaskPosition: "100% 0",
20
+ filter: `blur(${blur[0]})`,
21
+ opacity: opacity[0]
22
+ }, {
23
+ maskPosition: "0% 0",
24
+ webkitMaskPosition: "0% 0",
25
+ filter: `blur(${blur[1]})`,
26
+ opacity: opacity[1]
27
+ }], {
28
+ duration: 520,
29
+ easing: "cubic-bezier(0.22, 1, 0.36, 1)"
30
+ });
31
+ animation.finished.catch(() => void 0).finally(() => {
32
+ for (const name of [
33
+ "mask-image",
34
+ "-webkit-mask-image",
35
+ "mask-size",
36
+ "-webkit-mask-size"
37
+ ]) el.style.removeProperty(name);
38
+ });
39
+ return animation;
40
+ }
41
+ var pillRadius = (box) => box.h / 2;
42
+ /** Puts a copy of the select's text exactly over the real one, to hold or blur away. */
43
+ function ghostOf(value, text) {
44
+ const button = value.offsetParent ?? value.closest("button");
45
+ if (!button) return null;
46
+ const ghost = document.createElement("span");
47
+ ghost.className = "clay-select-ghost";
48
+ ghost.setAttribute("aria-hidden", "true");
49
+ ghost.textContent = text;
50
+ const { x, y } = offsetWithin(value, button);
51
+ ghost.style.left = `${x}px`;
52
+ ghost.style.top = `${y}px`;
53
+ button.append(ghost);
54
+ return ghost;
55
+ }
56
+ /**
57
+ * Pour: a select whose list pours out of its clay trigger, with a well that slides to the option under
58
+ * the pointer. The chosen value is revealed with a blur once the list has gone. With `attached`, the
59
+ * list squeezes out of the trigger like Roll's bead, stays melted onto it, and the trigger bounces as
60
+ * the list tucks back in, which is when the new value shows.
61
+ */
62
+ var ClaySelect = class extends ClayElement {
63
+ static observedAttributes = [
64
+ "color",
65
+ "attached",
66
+ "fuse"
67
+ ];
68
+ requires = "ui-select-trigger button";
69
+ observer = null;
70
+ attachment = null;
71
+ highlight = null;
72
+ release = () => {};
73
+ refit = () => {};
74
+ cleanup = [];
75
+ attributeChangedCallback(name, old, value) {
76
+ super.attributeChangedCallback(name, old, value);
77
+ if (name === "fuse") this.refit();
78
+ }
79
+ get list() {
80
+ return this.querySelector("ui-select-content");
81
+ }
82
+ setup() {
83
+ this.querySelectorAll("ui-select-item").forEach((item, index) => item.style.setProperty("--clay-i", String(index)));
84
+ const list = this.list;
85
+ if (list) {
86
+ this.highlight = new Highlight(list, "[data-slot='select-item']");
87
+ this.cleanup.push(this.highlight.watch(() => this.surfaces[1]?.invalidate()));
88
+ }
89
+ if (list && this.hasAttribute("attached")) {
90
+ this.refit = hug(list, () => fuseOf(this));
91
+ this.attachment = new Attachment(list, {
92
+ trigger: () => this.querySelector("ui-select-trigger button"),
93
+ triggerRadius: (box) => Math.min(box.h / 2, 18),
94
+ triggerColor: () => this.surfaces[0]?.color("--clay-color", NEUTRAL) ?? NEUTRAL,
95
+ color: () => this.surfaces[1]?.color("--clay-popup", NEUTRAL) ?? NEUTRAL,
96
+ radius: 22,
97
+ bevel: 16,
98
+ lift: 1.3,
99
+ fuse: () => fuseOf(this),
100
+ calm: (on) => this.surfaces[0]?.calm(on),
101
+ onTuck: () => {
102
+ this.surfaces[0]?.bounce();
103
+ this.release();
104
+ }
105
+ }, () => this.surfaces[1]);
106
+ this.cleanup.push(this.attachment.connect());
107
+ }
108
+ if (list) {
109
+ const closed = () => !list.hasAttribute("data-open") && !list.hasAttribute("data-ending-style");
110
+ this.cleanup.push(watch(list, [
111
+ "data-open",
112
+ "data-ending-style",
113
+ "hidden"
114
+ ], () => closed() && this.release()));
115
+ }
116
+ this.watchValue();
117
+ }
118
+ /**
119
+ * The chosen value waits while the list is out: the old text stays, held by a copy, until the list
120
+ * is gone, then the new one is revealed with a blur.
121
+ */
122
+ watchValue() {
123
+ const value = this.querySelector("ui-select-value");
124
+ if (!value) return;
125
+ const text = () => value.textContent?.trim() ?? "";
126
+ const shown = () => {
127
+ const list = this.list;
128
+ return !!list && (list.hasAttribute("data-open") || list.hasAttribute("data-ending-style") || list.getClientRects().length > 0);
129
+ };
130
+ const out = () => this.attachment && this.surfaces[1] ? this.attachment.out : shown();
131
+ let previous = text();
132
+ let pending = false;
133
+ let running = null;
134
+ let held = null;
135
+ const unhold = () => {
136
+ held?.ghost?.remove();
137
+ value.style.removeProperty("opacity");
138
+ held = null;
139
+ };
140
+ this.release = () => {
141
+ if (!held) return;
142
+ const { old } = held;
143
+ unhold();
144
+ running = this.reveal(value, old);
145
+ };
146
+ this.observer = new MutationObserver(() => {
147
+ if (pending || text() === previous) return;
148
+ pending = true;
149
+ if (previous && out() && !held) {
150
+ held = {
151
+ old: previous,
152
+ ghost: ghostOf(value, previous)
153
+ };
154
+ value.style.opacity = "0";
155
+ } else if (previous && !held) running = this.reveal(value, previous);
156
+ setTimeout(() => {
157
+ pending = false;
158
+ const next = text();
159
+ if (!next || next === previous) {
160
+ running?.();
161
+ if (held?.old === next) unhold();
162
+ }
163
+ running = null;
164
+ previous = next;
165
+ });
166
+ });
167
+ this.observer.observe(value, {
168
+ childList: true,
169
+ characterData: true,
170
+ subtree: true
171
+ });
172
+ this.cleanup.push(unhold);
173
+ }
174
+ teardown() {
175
+ this.observer?.disconnect();
176
+ for (const fn of this.cleanup) fn();
177
+ this.cleanup = [];
178
+ this.attachment = null;
179
+ this.highlight = null;
180
+ }
181
+ /**
182
+ * The new value is wiped in from the left out of a blur while the old one blurs away in its place.
183
+ * Returns a function that stops it.
184
+ */
185
+ reveal(value, old) {
186
+ if (reducedMotion() || typeof value.animate !== "function") return null;
187
+ const ghost = ghostOf(value, old);
188
+ if (!ghost) return null;
189
+ const out = wipe(ghost, WIPE_OUT, ["0px", "6px"], [1, 0]);
190
+ out.finished.catch(() => void 0).finally(() => ghost.remove());
191
+ const into = wipe(value, WIPE_IN, ["6px", "0px"], [.2, 1]);
192
+ return () => {
193
+ out.cancel();
194
+ into.cancel();
195
+ ghost.remove();
196
+ };
197
+ }
198
+ surfaceFor() {
199
+ const trigger = this.querySelector("ui-select-trigger button");
200
+ const list = this.list;
201
+ const surfaces = [[trigger, { shapes: () => [{
202
+ ...pressable(this.surfaces[0], Math.min(this.surfaces[0].height / 2, 18)),
203
+ blend: this.attachment ? 9 : void 0
204
+ }, ...this.attachment?.joint(trigger) ?? []] }]];
205
+ if (list) {
206
+ const base = this.attachment?.surfaceOptions() ?? {
207
+ swell: false,
208
+ pad: 36,
209
+ shapes: () => [slab(this.surfaces[1], "--clay-popup", 22, 16, 1.4)]
210
+ };
211
+ surfaces.push([list, withHighlight(base, this.highlight, () => this.surfaces[1], this.attachment)]);
212
+ }
213
+ return surfaces;
214
+ }
215
+ };
216
+ /**
217
+ * Pop: a tooltip that pops out as a small clay tag. With `attached`, the tag squeezes out of its button
218
+ * like Roll's bead, stays melted onto it while it's open, and tucks back in.
219
+ */
220
+ var ClayTooltip = class extends ClayElement {
221
+ static observedAttributes = [
222
+ "color",
223
+ "attached",
224
+ "fuse"
225
+ ];
226
+ requires = "ui-tooltip-content";
227
+ attachment = null;
228
+ stop = null;
229
+ refit = () => {};
230
+ get attached() {
231
+ return this.hasAttribute("attached");
232
+ }
233
+ attributeChangedCallback(name, old, value) {
234
+ super.attributeChangedCallback(name, old, value);
235
+ if (name === "fuse") this.refit();
236
+ }
237
+ get content() {
238
+ return this.querySelector("ui-tooltip-content");
239
+ }
240
+ /** The clay element the trigger button sits in, whose colour the tag takes when it has none. */
241
+ get body() {
242
+ const button = this.querySelector("[data-slot='tooltip-trigger'], ui-tooltip-trigger > *");
243
+ for (let el = button?.parentElement; el && el !== this; el = el.parentElement) if (el instanceof ClayElement) return el;
244
+ return button?.closest("[data-clay-host]") ?? button;
245
+ }
246
+ bodyColor() {
247
+ const body = this.body;
248
+ return resolveColor(body ? getComputedStyle(body).getPropertyValue("--clay-color") : "", NEUTRAL);
249
+ }
250
+ updateTone() {
251
+ if (!this.attached || this.hasAttribute("color")) return super.updateTone();
252
+ const l = luminance(this.bodyColor());
253
+ this.dataset.tone = 1.05 / (l + .05) > (l + .05) / (.022 + .05) ? "dark" : "light";
254
+ }
255
+ setup() {
256
+ if (!this.attached) return;
257
+ const content = this.content;
258
+ this.refit = hug(content, () => fuseOf(this));
259
+ for (const node of [...content.childNodes]) {
260
+ if (node.nodeType !== Node.TEXT_NODE || !node.textContent?.trim()) continue;
261
+ const span = document.createElement("span");
262
+ span.className = "clay-tip-text";
263
+ node.replaceWith(span);
264
+ span.append(node);
265
+ }
266
+ this.attachment = new Attachment(content, {
267
+ trigger: () => this.body,
268
+ triggerRadius: (box) => this.body?.getAttribute("shape") === "rounded" ? Math.min(box.h * .34, 18) : pillRadius(box),
269
+ triggerColor: () => this.bodyColor(),
270
+ color: () => this.hasAttribute("color") ? this.surfaces[0]?.color("--clay-color", NEUTRAL) ?? NEUTRAL : this.bodyColor(),
271
+ radius: 13,
272
+ bevel: 9,
273
+ lift: .5,
274
+ fuse: () => fuseOf(this),
275
+ calm: (on) => {
276
+ const body = this.body;
277
+ if (body instanceof ClayElement) body.calm(on);
278
+ },
279
+ onTuck: () => {
280
+ const body = this.body;
281
+ if (body instanceof ClayElement) body.bounce(.8);
282
+ }
283
+ }, () => this.surfaces[0]);
284
+ const stop = this.attachment.connect();
285
+ const body = this.body;
286
+ const attachment = this.attachment;
287
+ const joint = () => body ? attachment.joint(body) : [];
288
+ if (body instanceof ClayElement) body.joints.add(joint);
289
+ this.stop = () => {
290
+ stop();
291
+ if (body instanceof ClayElement) body.joints.delete(joint);
292
+ };
293
+ }
294
+ teardown() {
295
+ this.stop?.();
296
+ this.attachment = null;
297
+ }
298
+ surfaceFor() {
299
+ return [[this.content, this.attachment?.surfaceOptions() ?? {
300
+ swell: false,
301
+ pad: 18,
302
+ shapes: () => [slab(this.surfaces[0], "--clay-color", 12, 8, .6)]
303
+ }]];
304
+ }
305
+ };
306
+ export { ClaySelect, ClayTooltip };
307
+
308
+ //# sourceMappingURL=popups.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popups.js","names":[],"sources":["../../../../src/clay/components/popups.ts"],"sourcesContent":["import { Attachment, BLEND, fuseOf, hug } from \"../attach\"\nimport { luminance, resolveColor } from \"../color\"\nimport { ClayElement, NEUTRAL } from \"../element\"\nimport { Highlight, withHighlight } from \"../highlight\"\nimport { pressable, slab, watch, type Box } from \"../shared\"\nimport { offsetWithin, type SurfaceOptions } from \"../surface\"\n\nconst reducedMotion = () => typeof matchMedia === \"function\" && matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n\n/** A soft edge three times wider than the text: sliding it across wipes the text in from the left. */\nconst WIPE_IN = \"linear-gradient(90deg, #000 45%, transparent 55%)\"\nconst WIPE_OUT = \"linear-gradient(90deg, transparent 45%, #000 55%)\"\n\nfunction wipe(el: HTMLElement, mask: string, blur: [string, string], opacity: [number, number]) {\n el.style.setProperty(\"mask-image\", mask)\n el.style.setProperty(\"-webkit-mask-image\", mask)\n el.style.setProperty(\"mask-size\", \"300% 100%\")\n el.style.setProperty(\"-webkit-mask-size\", \"300% 100%\")\n const animation = el.animate(\n [\n { maskPosition: \"100% 0\", webkitMaskPosition: \"100% 0\", filter: `blur(${blur[0]})`, opacity: opacity[0] },\n { maskPosition: \"0% 0\", webkitMaskPosition: \"0% 0\", filter: `blur(${blur[1]})`, opacity: opacity[1] },\n ] as Keyframe[],\n { duration: 520, easing: \"cubic-bezier(0.22, 1, 0.36, 1)\" }\n )\n animation.finished\n .catch(() => undefined)\n .finally(() => {\n for (const name of [\"mask-image\", \"-webkit-mask-image\", \"mask-size\", \"-webkit-mask-size\"]) el.style.removeProperty(name)\n })\n return animation\n}\n\nconst pillRadius = (box: Box) => box.h / 2\n\n/** Puts a copy of the select's text exactly over the real one, to hold or blur away. */\nfunction ghostOf(value: HTMLElement, text: string) {\n const button = (value.offsetParent as HTMLElement | null) ?? value.closest(\"button\")\n if (!button) return null\n const ghost = document.createElement(\"span\")\n ghost.className = \"clay-select-ghost\"\n ghost.setAttribute(\"aria-hidden\", \"true\")\n ghost.textContent = text\n // Exact to the subpixel, and undoing the trigger's swell, so it sits right on the real text.\n const { x, y } = offsetWithin(value, button)\n ghost.style.left = `${x}px`\n ghost.style.top = `${y}px`\n button.append(ghost)\n return ghost\n}\n\n/**\n * Pour: a select whose list pours out of its clay trigger, with a well that slides to the option under\n * the pointer. The chosen value is revealed with a blur once the list has gone. With `attached`, the\n * list squeezes out of the trigger like Roll's bead, stays melted onto it, and the trigger bounces as\n * the list tucks back in, which is when the new value shows.\n */\nclass ClaySelect extends ClayElement {\n static observedAttributes = [\"color\", \"attached\", \"fuse\"]\n protected readonly requires = \"ui-select-trigger button\"\n private observer: MutationObserver | null = null\n private attachment: Attachment | null = null\n private highlight: Highlight | null = null\n private release: () => void = () => {}\n private refit: () => void = () => {}\n private cleanup: Array<() => void> = []\n\n attributeChangedCallback(name: string, old: string | null, value: string | null) {\n super.attributeChangedCallback(name, old, value)\n if (name === \"fuse\") this.refit()\n }\n\n private get list() {\n return this.querySelector<HTMLElement>(\"ui-select-content\")\n }\n\n protected setup() {\n this.querySelectorAll<HTMLElement>(\"ui-select-item\").forEach((item, index) =>\n item.style.setProperty(\"--clay-i\", String(index))\n )\n const list = this.list\n if (list) {\n this.highlight = new Highlight(list, \"[data-slot='select-item']\")\n this.cleanup.push(this.highlight.watch(() => this.surfaces[1]?.invalidate()))\n }\n if (list && this.hasAttribute(\"attached\")) {\n this.refit = hug(list, () => fuseOf(this))\n this.attachment = new Attachment(\n list,\n {\n trigger: () => this.querySelector(\"ui-select-trigger button\"),\n triggerRadius: (box) => Math.min(box.h / 2, 18),\n triggerColor: () => this.surfaces[0]?.color(\"--clay-color\", NEUTRAL) ?? NEUTRAL,\n color: () => this.surfaces[1]?.color(\"--clay-popup\", NEUTRAL) ?? NEUTRAL,\n radius: 22,\n bevel: 16,\n lift: 1.3,\n fuse: () => fuseOf(this),\n calm: (on) => this.surfaces[0]?.calm(on),\n onTuck: () => {\n this.surfaces[0]?.bounce()\n this.release()\n },\n },\n () => this.surfaces[1]\n )\n this.cleanup.push(this.attachment.connect())\n }\n if (list) {\n // The new value shows once the list has finished closing, or earlier, on an attached list's bounce.\n const closed = () => !list.hasAttribute(\"data-open\") && !list.hasAttribute(\"data-ending-style\")\n this.cleanup.push(watch(list, [\"data-open\", \"data-ending-style\", \"hidden\"], () => closed() && this.release()))\n }\n this.watchValue()\n }\n\n /**\n * The chosen value waits while the list is out: the old text stays, held by a copy, until the list\n * is gone, then the new one is revealed with a blur.\n */\n private watchValue() {\n const value = this.querySelector<HTMLElement>(\"ui-select-value\")\n if (!value) return\n const text = () => value.textContent?.trim() ?? \"\"\n // Out means open or still closing: ui-sdk starts closing in the same moment it changes the value.\n const shown = () => {\n const list = this.list\n return !!list && (list.hasAttribute(\"data-open\") || list.hasAttribute(\"data-ending-style\") || list.getClientRects().length > 0)\n }\n const out = () => (this.attachment && this.surfaces[1] ? this.attachment.out : shown())\n let previous = text()\n let pending = false\n let running: (() => void) | null = null\n let held: { old: string; ghost: HTMLElement | null } | null = null\n const unhold = () => {\n held?.ghost?.remove()\n value.style.removeProperty(\"opacity\")\n held = null\n }\n this.release = () => {\n if (!held) return\n const { old } = held\n unhold()\n running = this.reveal(value, old)\n }\n this.observer = new MutationObserver(() => {\n if (pending || text() === previous) return\n pending = true\n // Before the browser paints the new text: hold the old one while the list is out, or reveal now.\n if (previous && out() && !held) {\n held = { old: previous, ghost: ghostOf(value, previous) }\n value.style.opacity = \"0\"\n } else if (previous && !held) {\n running = this.reveal(value, previous)\n }\n // ui-sdk can swap the text in more than one step: once it settles, drop what changed nothing.\n setTimeout(() => {\n pending = false\n const next = text()\n if (!next || next === previous) {\n running?.()\n if (held?.old === next) unhold()\n }\n running = null\n previous = next\n })\n })\n this.observer.observe(value, { childList: true, characterData: true, subtree: true })\n this.cleanup.push(unhold)\n }\n\n protected teardown() {\n this.observer?.disconnect()\n for (const fn of this.cleanup) fn()\n this.cleanup = []\n this.attachment = null\n this.highlight = null\n }\n\n /**\n * The new value is wiped in from the left out of a blur while the old one blurs away in its place.\n * Returns a function that stops it.\n */\n private reveal(value: HTMLElement, old: string) {\n if (reducedMotion() || typeof value.animate !== \"function\") return null\n const ghost = ghostOf(value, old)\n if (!ghost) return null\n const out = wipe(ghost, WIPE_OUT, [\"0px\", \"6px\"], [1, 0])\n out.finished.catch(() => undefined).finally(() => ghost.remove())\n const into = wipe(value, WIPE_IN, [\"6px\", \"0px\"], [0.2, 1])\n return () => {\n out.cancel()\n into.cancel()\n ghost.remove()\n }\n }\n\n protected surfaceFor(): Array<[HTMLElement, SurfaceOptions]> {\n const trigger = this.querySelector<HTMLElement>(\"ui-select-trigger button\")!\n const list = this.list\n const surfaces: Array<[HTMLElement, SurfaceOptions]> = [\n [\n trigger,\n {\n shapes: () => [\n {\n ...pressable(this.surfaces[0]!, Math.min(this.surfaces[0]!.height / 2, 18)),\n blend: this.attachment ? BLEND : undefined,\n },\n ...(this.attachment?.joint(trigger) ?? []),\n ],\n },\n ],\n ]\n if (list) {\n const base: SurfaceOptions = this.attachment?.surfaceOptions() ?? {\n swell: false,\n pad: 36,\n shapes: () => [slab(this.surfaces[1]!, \"--clay-popup\", 22, 16, 1.4)],\n }\n surfaces.push([list, withHighlight(base, this.highlight, () => this.surfaces[1], this.attachment)])\n }\n return surfaces\n }\n}\n\n/**\n * Pop: a tooltip that pops out as a small clay tag. With `attached`, the tag squeezes out of its button\n * like Roll's bead, stays melted onto it while it's open, and tucks back in.\n */\nclass ClayTooltip extends ClayElement {\n static observedAttributes = [\"color\", \"attached\", \"fuse\"]\n protected readonly requires = \"ui-tooltip-content\"\n private attachment: Attachment | null = null\n private stop: (() => void) | null = null\n private refit: () => void = () => {}\n\n private get attached() {\n return this.hasAttribute(\"attached\")\n }\n\n attributeChangedCallback(name: string, old: string | null, value: string | null) {\n super.attributeChangedCallback(name, old, value)\n if (name === \"fuse\") this.refit()\n }\n\n private get content() {\n return this.querySelector<HTMLElement>(\"ui-tooltip-content\")!\n }\n\n /** The clay element the trigger button sits in, whose colour the tag takes when it has none. */\n private get body() {\n const button = this.querySelector<HTMLElement>(\"[data-slot='tooltip-trigger'], ui-tooltip-trigger > *\")\n // Found by its class, not its canvas: it starts after this tooltip, so it may not have one yet.\n for (let el = button?.parentElement; el && el !== this; el = el.parentElement) {\n if (el instanceof ClayElement) return el\n }\n return button?.closest<HTMLElement>(\"[data-clay-host]\") ?? button\n }\n\n private bodyColor() {\n const body = this.body\n return resolveColor(body ? getComputedStyle(body).getPropertyValue(\"--clay-color\") : \"\", NEUTRAL)\n }\n\n protected updateTone() {\n if (!this.attached || this.hasAttribute(\"color\")) return super.updateTone()\n const l = luminance(this.bodyColor())\n this.dataset.tone = 1.05 / (l + 0.05) > (l + 0.05) / (0.022 + 0.05) ? \"dark\" : \"light\"\n }\n\n protected setup() {\n if (!this.attached) return\n const content = this.content\n this.refit = hug(content, () => fuseOf(this))\n // The tag's own text fades in and out without taking the clay drawn under it along.\n for (const node of [...content.childNodes]) {\n if (node.nodeType !== Node.TEXT_NODE || !node.textContent?.trim()) continue\n const span = document.createElement(\"span\")\n span.className = \"clay-tip-text\"\n node.replaceWith(span)\n span.append(node)\n }\n this.attachment = new Attachment(\n content,\n {\n trigger: () => this.body,\n triggerRadius: (box) => (this.body?.getAttribute(\"shape\") === \"rounded\" ? Math.min(box.h * 0.34, 18) : pillRadius(box)),\n triggerColor: () => this.bodyColor(),\n color: () => (this.hasAttribute(\"color\") ? (this.surfaces[0]?.color(\"--clay-color\", NEUTRAL) ?? NEUTRAL) : this.bodyColor()),\n radius: 13,\n bevel: 9,\n lift: 0.5,\n fuse: () => fuseOf(this),\n calm: (on) => {\n const body = this.body\n if (body instanceof ClayElement) body.calm(on)\n },\n onTuck: () => {\n const body = this.body\n if (body instanceof ClayElement) body.bounce(0.8)\n },\n },\n () => this.surfaces[0]\n )\n const stop = this.attachment.connect()\n const body = this.body\n const attachment = this.attachment\n const joint = () => (body ? attachment.joint(body) : [])\n if (body instanceof ClayElement) body.joints.add(joint)\n this.stop = () => {\n stop()\n if (body instanceof ClayElement) body.joints.delete(joint)\n }\n }\n\n protected teardown() {\n this.stop?.()\n this.attachment = null\n }\n\n protected surfaceFor(): Array<[HTMLElement, SurfaceOptions]> {\n const content = this.content\n return [\n [\n content,\n this.attachment?.surfaceOptions() ?? {\n swell: false,\n pad: 18,\n shapes: () => [slab(this.surfaces[0]!, \"--clay-color\", 12, 8, 0.6)],\n },\n ],\n ]\n }\n}\n\nexport { ClaySelect, ClayTooltip }\n"],"mappings":";;;;;;;AAOA,IAAM,sBAAsB,OAAO,eAAe,cAAc,WAAW,kCAAkC,CAAC,CAAC;;AAG/G,IAAM,UAAU;AAChB,IAAM,WAAW;AAEjB,SAAS,KAAK,IAAiB,MAAc,MAAwB,SAA2B;CAC9F,GAAG,MAAM,YAAY,cAAc,IAAI;CACvC,GAAG,MAAM,YAAY,sBAAsB,IAAI;CAC/C,GAAG,MAAM,YAAY,aAAa,WAAW;CAC7C,GAAG,MAAM,YAAY,qBAAqB,WAAW;CACrD,MAAM,YAAY,GAAG,QACnB,CACE;EAAE,cAAc;EAAU,oBAAoB;EAAU,QAAQ,QAAQ,KAAK,GAAG;EAAI,SAAS,QAAQ;CAAG,GACxG;EAAE,cAAc;EAAQ,oBAAoB;EAAQ,QAAQ,QAAQ,KAAK,GAAG;EAAI,SAA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AM,gBAAgB,OAAO,KAAK,UAAW,KAAK,UAAU;GAC1H,QAAQ;GACR,OAAO;GACP,MAAM;GACN,YAAY,OAAO,IAAI;GACvB,OAAO,OAAO;IACZ,MAAM,OAAO,KAAK;IAClB,IAAI,gBAAgB,aAAa,KAAK,KAAK,EAAE;GAC/C;GACA,cAAc;IACZ,MAAM,OAAO,KAAK;IAClB,IAAI,gBAAgB,aAAa,KAAK,OAAO,EAAG;GAClD;EACF,SACM,KAAK,SAAS,EACtB;EACA,MAAM,OAAO,KAAK,WAAW,QAAQ;EACrC,MAAM,OAAO,KAAK;EAClB,MAAM,aAAa,KAAK;EACxB,MAAM,cAAe,OAAO,WAAW,MAAM,IAAI,IAAI,CAAC;EACtD,IAAI,gBAAgB,aAAa,KAAK,OAAO,IAAI,KAAK;EACtD,KAAK,aAAa;GAChB,KAAK;GACL,IAAI,gBAAgB,aAAa,KAAK,OAAO,OAAO,KAAK;EAC3D;CACF;CAEA,WAAqB;EACnB,KAAK,OAAO;EACZ,KAAK,aAAa;CACpB;CAEA,aAA6D;EAE3D,OAAO,CACL,CAFc,KAAK,SAIjB,KAAK,YAAY,eAAe,KAAK;GACnC,OAAO;GACP,KAAK;GACL,cAAc,CAAC,KAAK,KAAK,SAAS,IAAK,gBAAgB,IAAI,GAAG,EAAG,CAAC;EACpE,CACF,CACF;CACF;AACF"}
@@ -0,0 +1,34 @@
1
+ import { ClayElement } from "../element.js";
2
+ import { type SurfaceOptions } from "../surface.js";
3
+ type SlideState = "idle" | "pending" | "success" | "error";
4
+ /** Drag: slide a clay ball to the end to confirm. Let go early and it rolls back. */
5
+ declare class ClaySlideConfirm extends ClayElement {
6
+ protected readonly requires = "ui-slider-thumb";
7
+ /** Runs once the ball reaches the end. Its promise decides success or error. */
8
+ action: (() => unknown) | null;
9
+ private state;
10
+ private x;
11
+ private grab;
12
+ private done;
13
+ private shake;
14
+ private placed;
15
+ private box;
16
+ private status;
17
+ private reset;
18
+ private cleanup;
19
+ get actionState(): SlideState;
20
+ private get slider();
21
+ private get range();
22
+ private onChange;
23
+ private onCommit;
24
+ protected setup(): void;
25
+ protected teardown(): void;
26
+ private progress;
27
+ private home;
28
+ private run;
29
+ private announce;
30
+ private setState;
31
+ protected surfaceFor(): Array<[HTMLElement, SurfaceOptions]>;
32
+ private shapes;
33
+ }
34
+ export { ClaySlideConfirm, type SlideState };
@@ -0,0 +1,234 @@
1
+ import { mix } from "../color.js";
2
+ import { ClayElement, NEUTRAL } from "../element.js";
3
+ import { clamp, deeper, watch } from "../shared.js";
4
+ import { Spring } from "../spring.js";
5
+ import { offsetWithin } from "../surface.js";
6
+ // src/clay/components/slide.ts
7
+ var ICONS = [
8
+ "<svg data-icon=\"idle\" viewBox=\"0 0 24 24\"><path d=\"M9 5l7 7-7 7\"/></svg>",
9
+ "<svg data-icon=\"pending\" viewBox=\"0 0 24 24\"><path d=\"M12 3a9 9 0 1 0 9 9\"/></svg>",
10
+ "<svg data-icon=\"success\" viewBox=\"0 0 24 24\"><path d=\"M5 12.5l4.5 4.5L19 7\"/></svg>",
11
+ "<svg data-icon=\"error\" viewBox=\"0 0 24 24\"><path d=\"M7 7l10 10M17 7L7 17\"/></svg>"
12
+ ].join("");
13
+ var single = (value) => Array.isArray(value) ? value[0] ?? 0 : value;
14
+ /** Drag: slide a clay ball to the end to confirm. Let go early and it rolls back. */
15
+ var ClaySlideConfirm = class extends ClayElement {
16
+ requires = "ui-slider-thumb";
17
+ /** Runs once the ball reaches the end. Its promise decides success or error. */
18
+ action = null;
19
+ state = "idle";
20
+ x = new Spring(0);
21
+ grab = new Spring(0);
22
+ done = new Spring(0);
23
+ shake = new Spring(0);
24
+ placed = false;
25
+ box = {
26
+ x: 0,
27
+ y: 0,
28
+ w: 0,
29
+ h: 0
30
+ };
31
+ status = null;
32
+ reset = 0;
33
+ cleanup = [];
34
+ get actionState() {
35
+ return this.state;
36
+ }
37
+ get slider() {
38
+ return this.querySelector("ui-slider");
39
+ }
40
+ get range() {
41
+ const slider = this.slider;
42
+ return {
43
+ min: Number(slider.getAttribute("min") ?? 0),
44
+ max: Number(slider.getAttribute("max") ?? 100)
45
+ };
46
+ }
47
+ onChange = (event) => {
48
+ if (this.state !== "idle" && this.state !== "error") {
49
+ event.preventDefault();
50
+ return;
51
+ }
52
+ if (this.state === "error") this.setState("idle");
53
+ this.progress(single(event.detail.value));
54
+ };
55
+ onCommit = (event) => {
56
+ if (this.state !== "idle") return;
57
+ const value = single(event.detail.value);
58
+ const { min, max } = this.range;
59
+ const threshold = Number(this.getAttribute("threshold") ?? .9);
60
+ if (this.action && value >= min + (max - min) * threshold) this.run(this.action);
61
+ else this.home();
62
+ };
63
+ setup() {
64
+ const slider = this.slider;
65
+ const text = (state, value) => {
66
+ const span = document.createElement("span");
67
+ span.dataset.label = state;
68
+ span.textContent = value;
69
+ return span;
70
+ };
71
+ const label = document.createElement("span");
72
+ label.className = "clay-slide-label";
73
+ label.setAttribute("aria-hidden", "true");
74
+ label.append(text("idle", slider.getAttribute("aria-label") ?? ""), text("pending", this.getAttribute("pending-label") ?? "Working…"), text("success", this.getAttribute("success-label") ?? "Done"), text("error", this.getAttribute("error-label") ?? "Try again"));
75
+ this.querySelector("ui-slider-control")?.append(label);
76
+ const icon = document.createElement("span");
77
+ icon.className = "clay-slide-icon";
78
+ icon.setAttribute("aria-hidden", "true");
79
+ icon.innerHTML = ICONS;
80
+ this.querySelector("ui-slider-thumb").append(icon);
81
+ this.status = document.createElement("span");
82
+ this.status.className = "clay-sr";
83
+ this.status.setAttribute("role", "status");
84
+ this.append(this.status);
85
+ slider.addEventListener("valuechange", this.onChange);
86
+ slider.addEventListener("valuecommit", this.onCommit);
87
+ this.cleanup.push(() => slider.removeEventListener("valuechange", this.onChange), () => slider.removeEventListener("valuecommit", this.onCommit), watch(slider, ["style", "data-dragging"], () => this.invalidate()));
88
+ this.progress(single(slider.value ?? 0));
89
+ this.setState("idle");
90
+ }
91
+ teardown() {
92
+ clearTimeout(this.reset);
93
+ for (const fn of this.cleanup) fn();
94
+ this.cleanup = [];
95
+ }
96
+ progress(value) {
97
+ const { min, max } = this.range;
98
+ this.style.setProperty("--clay-slide", clamp((value - min) / (max - min || 1), 0, 1).toFixed(3));
99
+ }
100
+ home() {
101
+ this.slider.value = this.range.min;
102
+ this.progress(this.range.min);
103
+ this.invalidate();
104
+ }
105
+ async run(action) {
106
+ clearTimeout(this.reset);
107
+ this.slider.value = this.range.max;
108
+ this.progress(this.range.max);
109
+ this.setState("pending");
110
+ this.slider.setAttribute("aria-busy", "true");
111
+ try {
112
+ await action();
113
+ this.setState("success");
114
+ this.announce(this.getAttribute("success-label") ?? "Done");
115
+ this.done.v = 6;
116
+ } catch {
117
+ this.setState("error");
118
+ this.announce(this.getAttribute("error-label") ?? "Try again");
119
+ this.shake.v = 160;
120
+ this.home();
121
+ }
122
+ this.slider.removeAttribute("aria-busy");
123
+ const after = Number(this.getAttribute("reset-after") ?? (this.state === "error" ? 2400 : 0));
124
+ if (after > 0) this.reset = window.setTimeout(() => {
125
+ this.setState("idle");
126
+ this.home();
127
+ }, after);
128
+ }
129
+ announce(message) {
130
+ if (this.status) this.status.textContent = message;
131
+ }
132
+ setState(state) {
133
+ this.state = state;
134
+ this.dataset.state = state;
135
+ this.done.target = state === "success" ? 1 : 0;
136
+ this.dispatchEvent(new CustomEvent("statechange", { detail: { state } }));
137
+ this.invalidate();
138
+ }
139
+ surfaceFor() {
140
+ return [[this, {
141
+ swell: false,
142
+ pad: 26,
143
+ pressTarget: this.querySelector("ui-slider-control") ?? this,
144
+ measure: () => {
145
+ this.box = offsetWithin(this.querySelector("ui-slider-control"), this);
146
+ const thumb = offsetWithin(this.querySelector("ui-slider-thumb"), this);
147
+ this.x.target = thumb.x + thumb.w / 2;
148
+ this.grab.target = this.slider.hasAttribute("data-dragging") ? 1 : 0;
149
+ if (!this.placed) {
150
+ this.x.set(this.x.target);
151
+ this.placed = true;
152
+ }
153
+ },
154
+ step: (dt, still) => [
155
+ this.x.step(dt, {
156
+ omega: 20,
157
+ zeta: .58
158
+ }, still),
159
+ this.grab.step(dt, {
160
+ omega: 16,
161
+ zeta: .55
162
+ }, still),
163
+ this.done.step(dt, {
164
+ omega: 12,
165
+ zeta: .45
166
+ }, still),
167
+ this.shake.step(dt, {
168
+ omega: 30,
169
+ zeta: .25
170
+ }, still)
171
+ ].some(Boolean),
172
+ shapes: () => this.shapes()
173
+ }]];
174
+ }
175
+ shapes() {
176
+ const surface = this.surfaces[0];
177
+ const { x, y, w, h } = this.box;
178
+ const body = surface.color("--clay-surface", NEUTRAL);
179
+ const accent = surface.color("--clay-color", NEUTRAL);
180
+ const shift = this.shake.x * .02;
181
+ const grab = Math.max(this.grab.x, surface.press.x);
182
+ const done = clamp(this.done.x, 0, 1.2);
183
+ const d = (h - 12) * (1 + grab * .08 + Math.max(this.done.x - 1, 0) * .3);
184
+ const stretch = clamp(Math.abs(this.x.v) * .001, 0, .3);
185
+ const bw = d * (1 + stretch);
186
+ const bh = d * (1 - stretch * .3);
187
+ const cx = clamp(this.x.x + shift, x + 6 + bw / 2, x + w - 6 - bw / 2);
188
+ const cy = y + h / 2;
189
+ return [
190
+ {
191
+ x: x + shift,
192
+ y,
193
+ w,
194
+ h,
195
+ radius: h / 2,
196
+ color: body,
197
+ height: .85,
198
+ lift: .55
199
+ },
200
+ {
201
+ x: x + 4 + shift,
202
+ y: y + 4,
203
+ w: w - 8,
204
+ h: h - 8,
205
+ radius: (h - 8) / 2,
206
+ color: deeper(body, .09),
207
+ height: -.85
208
+ },
209
+ {
210
+ x: x + 6 + shift,
211
+ y: y + 6,
212
+ w: Math.max(cx - x - 6 + bw / 2, h - 12),
213
+ h: h - 12,
214
+ radius: (h - 12) / 2,
215
+ color: accent,
216
+ height: .6 + done * .3,
217
+ lift: .1
218
+ },
219
+ {
220
+ x: cx - bw / 2,
221
+ y: cy - bh / 2,
222
+ w: bw,
223
+ h: bh,
224
+ radius: bh / 2,
225
+ color: mix(surface.color("--clay-knob"), accent, clamp(done, 0, 1) * .35),
226
+ height: 1,
227
+ lift: .8 + grab * .4
228
+ }
229
+ ];
230
+ }
231
+ };
232
+ export { ClaySlideConfirm };
233
+
234
+ //# sourceMappingURL=slide.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slide.js","names":[],"sources":["../../../../src/clay/components/slide.ts"],"sourcesContent":["import { mix } from \"../color\"\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\ntype SlideState = \"idle\" | \"pending\" | \"success\" | \"error\"\n\nconst ICONS = [\n '<svg data-icon=\"idle\" viewBox=\"0 0 24 24\"><path d=\"M9 5l7 7-7 7\"/></svg>',\n '<svg data-icon=\"pending\" viewBox=\"0 0 24 24\"><path d=\"M12 3a9 9 0 1 0 9 9\"/></svg>',\n '<svg data-icon=\"success\" viewBox=\"0 0 24 24\"><path d=\"M5 12.5l4.5 4.5L19 7\"/></svg>',\n '<svg data-icon=\"error\" viewBox=\"0 0 24 24\"><path d=\"M7 7l10 10M17 7L7 17\"/></svg>',\n].join(\"\")\n\ntype SliderElement = HTMLElement & { value: number | number[] }\ntype SliderEvent = CustomEvent<{ value: number | number[] }>\n\nconst single = (value: number | number[]) => (Array.isArray(value) ? value[0] ?? 0 : value)\n\n/** Drag: slide a clay ball to the end to confirm. Let go early and it rolls back. */\nclass ClaySlideConfirm extends ClayElement {\n protected readonly requires = \"ui-slider-thumb\"\n /** Runs once the ball reaches the end. Its promise decides success or error. */\n action: (() => unknown) | null = null\n private state: SlideState = \"idle\"\n private x = new Spring(0)\n private grab = new Spring(0)\n private done = new Spring(0)\n private shake = new Spring(0)\n private placed = false\n private box = { x: 0, y: 0, w: 0, h: 0 }\n private status: HTMLElement | null = null\n private reset = 0\n private cleanup: Array<() => void> = []\n\n get actionState() {\n return this.state\n }\n\n private get slider() {\n return this.querySelector<SliderElement>(\"ui-slider\")!\n }\n\n private get range() {\n const slider = this.slider\n return { min: Number(slider.getAttribute(\"min\") ?? 0), max: Number(slider.getAttribute(\"max\") ?? 100) }\n }\n\n private onChange = (event: Event) => {\n if (this.state !== \"idle\" && this.state !== \"error\") {\n event.preventDefault()\n return\n }\n if (this.state === \"error\") this.setState(\"idle\")\n this.progress(single((event as SliderEvent).detail.value))\n }\n\n private onCommit = (event: Event) => {\n if (this.state !== \"idle\") return\n const value = single((event as SliderEvent).detail.value)\n const { min, max } = this.range\n const threshold = Number(this.getAttribute(\"threshold\") ?? 0.9)\n if (this.action && value >= min + (max - min) * threshold) void this.run(this.action)\n else this.home()\n }\n\n protected setup() {\n const slider = this.slider\n const text = (state: SlideState, value: string) => {\n const span = document.createElement(\"span\")\n span.dataset.label = state\n span.textContent = value\n return span\n }\n const label = document.createElement(\"span\")\n label.className = \"clay-slide-label\"\n label.setAttribute(\"aria-hidden\", \"true\")\n label.append(\n text(\"idle\", slider.getAttribute(\"aria-label\") ?? \"\"),\n text(\"pending\", this.getAttribute(\"pending-label\") ?? \"Working…\"),\n text(\"success\", this.getAttribute(\"success-label\") ?? \"Done\"),\n text(\"error\", this.getAttribute(\"error-label\") ?? \"Try again\")\n )\n this.querySelector(\"ui-slider-control\")?.append(label)\n\n const icon = document.createElement(\"span\")\n icon.className = \"clay-slide-icon\"\n icon.setAttribute(\"aria-hidden\", \"true\")\n icon.innerHTML = ICONS\n this.querySelector(\"ui-slider-thumb\")!.append(icon)\n\n this.status = document.createElement(\"span\")\n this.status.className = \"clay-sr\"\n this.status.setAttribute(\"role\", \"status\")\n this.append(this.status)\n\n slider.addEventListener(\"valuechange\", this.onChange)\n slider.addEventListener(\"valuecommit\", this.onCommit)\n this.cleanup.push(\n () => slider.removeEventListener(\"valuechange\", this.onChange),\n () => slider.removeEventListener(\"valuecommit\", this.onCommit),\n watch(slider, [\"style\", \"data-dragging\"], () => this.invalidate())\n )\n this.progress(single(slider.value ?? 0))\n this.setState(\"idle\")\n }\n\n protected teardown() {\n clearTimeout(this.reset)\n for (const fn of this.cleanup) fn()\n this.cleanup = []\n }\n\n private progress(value: number) {\n const { min, max } = this.range\n this.style.setProperty(\"--clay-slide\", clamp((value - min) / (max - min || 1), 0, 1).toFixed(3))\n }\n\n private home() {\n this.slider.value = this.range.min\n this.progress(this.range.min)\n this.invalidate()\n }\n\n private async run(action: () => unknown) {\n clearTimeout(this.reset)\n this.slider.value = this.range.max\n this.progress(this.range.max)\n this.setState(\"pending\")\n this.slider.setAttribute(\"aria-busy\", \"true\")\n try {\n await action()\n this.setState(\"success\")\n this.announce(this.getAttribute(\"success-label\") ?? \"Done\")\n this.done.v = 6\n } catch {\n this.setState(\"error\")\n this.announce(this.getAttribute(\"error-label\") ?? \"Try again\")\n this.shake.v = 160\n this.home()\n }\n this.slider.removeAttribute(\"aria-busy\")\n const after = Number(this.getAttribute(\"reset-after\") ?? (this.state === \"error\" ? 2400 : 0))\n if (after > 0) {\n this.reset = window.setTimeout(() => {\n this.setState(\"idle\")\n this.home()\n }, after)\n }\n }\n\n private announce(message: string) {\n if (this.status) this.status.textContent = message\n }\n\n private setState(state: SlideState) {\n this.state = state\n this.dataset.state = state\n this.done.target = state === \"success\" ? 1 : 0\n this.dispatchEvent(new CustomEvent(\"statechange\", { detail: { state } }))\n this.invalidate()\n }\n\n protected surfaceFor(): Array<[HTMLElement, SurfaceOptions]> {\n return [\n [\n this,\n {\n swell: false,\n pad: 26,\n pressTarget: this.querySelector<HTMLElement>(\"ui-slider-control\") ?? this,\n measure: () => {\n this.box = offsetWithin(this.querySelector(\"ui-slider-control\")!, this)\n const thumb = offsetWithin(this.querySelector(\"ui-slider-thumb\")!, this)\n this.x.target = thumb.x + thumb.w / 2\n this.grab.target = this.slider.hasAttribute(\"data-dragging\") ? 1 : 0\n if (!this.placed) {\n this.x.set(this.x.target)\n this.placed = true\n }\n },\n step: (dt, still) =>\n [\n this.x.step(dt, { omega: 20, zeta: 0.58 }, still),\n this.grab.step(dt, { omega: 16, zeta: 0.55 }, still),\n this.done.step(dt, { omega: 12, zeta: 0.45 }, still),\n this.shake.step(dt, { omega: 30, zeta: 0.25 }, still),\n ].some(Boolean),\n shapes: () => this.shapes(),\n },\n ],\n ]\n }\n\n private shapes(): ClayShape[] {\n const surface = this.surfaces[0]!\n const { x, y, w, h } = this.box\n const body = surface.color(\"--clay-surface\", NEUTRAL)\n const accent = surface.color(\"--clay-color\", NEUTRAL)\n const shift = this.shake.x * 0.02\n const grab = Math.max(this.grab.x, surface.press.x)\n const done = clamp(this.done.x, 0, 1.2)\n const d = (h - 12) * (1 + grab * 0.08 + Math.max(this.done.x - 1, 0) * 0.3)\n const stretch = clamp(Math.abs(this.x.v) * 0.001, 0, 0.3)\n const bw = d * (1 + stretch)\n const bh = d * (1 - stretch * 0.3)\n const cx = clamp(this.x.x + shift, x + 6 + bw / 2, x + w - 6 - bw / 2)\n const cy = y + h / 2\n return [\n { x: x + shift, y, w, h, radius: h / 2, color: body, height: 0.85, lift: 0.55 },\n { x: x + 4 + shift, y: y + 4, w: w - 8, h: h - 8, radius: (h - 8) / 2, color: deeper(body, 0.09), height: -0.85 },\n {\n x: x + 6 + shift,\n y: y + 6,\n w: Math.max(cx - x - 6 + bw / 2, h - 12),\n h: h - 12,\n radius: (h - 12) / 2,\n color: accent,\n height: 0.6 + done * 0.3,\n lift: 0.1,\n },\n {\n x: cx - bw / 2,\n y: cy - bh / 2,\n w: bw,\n h: bh,\n radius: bh / 2,\n color: mix(surface.color(\"--clay-knob\"), accent, clamp(done, 0, 1) * 0.35),\n height: 1,\n lift: 0.8 + grab * 0.4,\n },\n ]\n }\n}\n\nexport { ClaySlideConfirm, type SlideState }\n"],"mappings":";;;;;;AASA,IAAM,QAAQ;CACZ;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,EAAE;AAKT,IAAM,UAAU,UAA8B,MAAM,QAAQ,KAAK,IAAI,MAAM,MAAM,IAAI;;AAGrF,IAAM,mBAAN,cAA+B,YAAY;CACzC,WA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I,UAAU;EAC9B,MAAM,KAAK,MAAM,KAAK,EAAE,IAAI,OAAO,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,IAAI,KAAK,CAAC;EACrE,MAAM,KAAK,IAAI,IAAI;EACnB,OAAO;GACL;IAAE,GAAG,IAAI;IAAO;IAAG;IAAG;IAAG,QAAQ,IAAI;IAAG,OAAO;IAAM,QAAQ;IAAM,MAAM;GAAK;GAC9E;IAAE,GAAG,IAAI,IAAI;IAAO,GAAG,IAAI;IAAG,GAAG,IAAI;IAAG,GAAG,IAAI;IAAG,SAAS,IAAI,KAAK;IAAG,OAAO,OAAO,MAAM,GAAI;IAAG,QAAQ;GAAM;GAChH;IACE,GAAG,IAAI,IAAI;IACX,GAAG,IAAI;IACP,GAAG,KAAK,IAAI,KAAK,IAAI,IAAI,KAAK,GAAG,IAAI,EAAE;IACvC,GAAG,IAAI;IACP,SAAS,IAAI,MAAM;IACnB,OAAO;IACP,QAAQ,KAAM,OAAO;IACrB,MAAM;GACR;GACA;IACE,GAAG,KAAK,KAAK;IACb,GAAG,KAAK,KAAK;IACb,GAAG;IACH,GAAG;IACH,QAAQ,KAAK;IACb,OAAO,IAAI,QAAQ,MAAM,aAAa,GAAG,QAAQ,MAAM,MAAM,GAAG,CAAC,IAAI,GAAI;IACzE,QAAQ;IACR,MAAM,KAAM,OAAO;GACrB;EACF;CACF;AACF"}
@@ -0,0 +1,20 @@
1
+ import { ClayElement } from "../element.js";
2
+ import { type SurfaceOptions } from "../surface.js";
3
+ /** Shift: tabs whose selection is a clay bead that rolls to the chosen view. */
4
+ declare class ClayTabs extends ClayElement {
5
+ protected readonly requires = "ui-tabs-list ui-tabs-tab";
6
+ private x;
7
+ private y;
8
+ private w;
9
+ private h;
10
+ private placed;
11
+ private selected;
12
+ private stop;
13
+ private get list();
14
+ protected setup(): void;
15
+ protected teardown(): void;
16
+ protected surfaceFor(): Array<[HTMLElement, SurfaceOptions]>;
17
+ private measure;
18
+ private shapes;
19
+ }
20
+ export { ClayTabs };