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,383 @@
1
+ import { Attachment, BACK, GRIP, OUT, PAST, faceOf, fuseOf, hug, poke, seed, smooth } from "../attach.js";
2
+ import { SPRINGS } from "../config.js";
3
+ import { ClayElement, NEUTRAL } from "../element.js";
4
+ import { Highlight, withHighlight } from "../highlight.js";
5
+ import { clamp, lerpBox, pressable, slab } from "../shared.js";
6
+ import { Spring } from "../spring.js";
7
+ // src/clay/components/overlays.ts
8
+ /**
9
+ * A trigger drawn as a clay button, and a popup drawn as a clay slab that grows out of it. With
10
+ * `attached`, the popup squeezes out of the button like Roll's bead and stays melted onto it.
11
+ */
12
+ var ClayPopupElement = class extends ClayElement {
13
+ static observedAttributes = [
14
+ "color",
15
+ "size",
16
+ "icon",
17
+ "attached",
18
+ "fuse"
19
+ ];
20
+ popupRadius = 22;
21
+ popupBevel = 16;
22
+ popupLift = 1.4;
23
+ /** Dialogs sit in the middle of the page, away from their trigger. */
24
+ attachable = true;
25
+ /** Items a sliding highlight follows, for menus. */
26
+ items = "";
27
+ attachment = null;
28
+ highlight = null;
29
+ refit = () => {};
30
+ cleanup = [];
31
+ attributeChangedCallback(name, old, value) {
32
+ super.attributeChangedCallback(name, old, value);
33
+ if (name === "fuse") this.refit();
34
+ }
35
+ get triggerButton() {
36
+ return this.querySelector(`${this.trigger} :is(button, a)`);
37
+ }
38
+ setup() {
39
+ this.querySelectorAll(`${this.content} :is(ui-menu-item, ui-menu-checkbox-item, ui-menu-radio-item)`).forEach((item, index) => item.style.setProperty("--clay-i", String(index)));
40
+ const content = this.querySelector(this.content);
41
+ const button = this.triggerButton;
42
+ if (content && this.items) {
43
+ this.highlight = new Highlight(content, this.items);
44
+ this.cleanup.push(this.highlight.watch(() => this.surfaces[1]?.invalidate()));
45
+ }
46
+ if (!content || !button || !this.attachable || !this.hasAttribute("attached")) return;
47
+ this.refit = hug(content, () => fuseOf(this));
48
+ this.attachment = new Attachment(content, {
49
+ trigger: () => this.triggerButton,
50
+ triggerRadius: (box) => box.h / 2,
51
+ triggerColor: () => this.surfaces[0]?.color("--clay-color", NEUTRAL) ?? NEUTRAL,
52
+ color: () => this.surfaces[1]?.color("--clay-popup", NEUTRAL) ?? NEUTRAL,
53
+ radius: this.popupRadius,
54
+ bevel: this.popupBevel,
55
+ lift: this.popupLift,
56
+ fuse: () => fuseOf(this),
57
+ calm: (on) => this.surfaces[0]?.calm(on),
58
+ onTuck: () => this.surfaces[0]?.bounce()
59
+ }, () => this.surfaces[1]);
60
+ this.cleanup.push(this.attachment.connect());
61
+ }
62
+ teardown() {
63
+ for (const fn of this.cleanup) fn();
64
+ this.cleanup = [];
65
+ this.attachment = null;
66
+ this.highlight = null;
67
+ }
68
+ surfaceFor() {
69
+ const surfaces = [];
70
+ const trigger = this.triggerButton;
71
+ const content = this.querySelector(this.content);
72
+ let index = 0;
73
+ if (trigger) {
74
+ const at = index++;
75
+ surfaces.push([trigger, { shapes: () => [{
76
+ ...pressable(this.surfaces[at]),
77
+ blend: this.attachment ? 9 : void 0
78
+ }, ...this.attachment?.joint(trigger) ?? []] }]);
79
+ }
80
+ if (content) {
81
+ const at = index++;
82
+ const base = at === 1 && this.attachment?.surfaceOptions() || {
83
+ swell: false,
84
+ pad: 40,
85
+ shapes: () => [slab(this.surfaces[at], "--clay-popup", this.popupRadius, this.popupBevel, this.popupLift)]
86
+ };
87
+ surfaces.push([content, withHighlight(base, this.highlight, () => this.surfaces[at], this.attachment)]);
88
+ }
89
+ return surfaces;
90
+ }
91
+ };
92
+ /** Spill: a menu of actions that spills out of its clay button. */
93
+ var ClayMenu = class extends ClayPopupElement {
94
+ requires = "ui-menu-trigger";
95
+ items = "[data-slot='menu-item'], [data-slot='menu-checkbox-item'], [data-slot='menu-radio-item']";
96
+ trigger = "ui-menu-trigger";
97
+ content = "ui-menu-content";
98
+ popupRadius = 20;
99
+ };
100
+ /** Unfold: a small clay card that unfolds from its button. */
101
+ var ClayPopover = class extends ClayPopupElement {
102
+ requires = "ui-popover-trigger";
103
+ trigger = "ui-popover-trigger";
104
+ content = "ui-popover-content";
105
+ popupRadius = 26;
106
+ popupBevel = 20;
107
+ };
108
+ /** Lift: a dialog lifted out of the page as a thick clay slab. */
109
+ var ClayDialog = class extends ClayPopupElement {
110
+ requires = "ui-dialog-content";
111
+ attachable = false;
112
+ trigger = "ui-dialog-trigger";
113
+ content = "ui-dialog-content";
114
+ popupRadius = 32;
115
+ popupBevel = 26;
116
+ popupLift = 2.4;
117
+ };
118
+ var TOAST_COLOR = {
119
+ success: "--clay-success",
120
+ error: "--clay-danger",
121
+ warning: "--clay-butter"
122
+ };
123
+ var MAX_LINKED = 8;
124
+ var toastColor = (toast) => TOAST_COLOR[toast.getAttribute("data-type") ?? ""] ?? "--clay-popup";
125
+ /**
126
+ * Drop: toasts that drop in as clay slabs, squash as they land and lift back off the same way.
127
+ * With `attached`, the stack is one body: each toast pulls out of the one before it and stays melted
128
+ * onto it, and leaving runs the same path back.
129
+ */
130
+ var ClayToastRegion = class extends ClayElement {
131
+ static observedAttributes = ["attached"];
132
+ requires = "ui-toast-region";
133
+ loose = /* @__PURE__ */ new Map();
134
+ links = /* @__PURE__ */ new Map();
135
+ stack = null;
136
+ observer = null;
137
+ get attached() {
138
+ return this.hasAttribute("attached");
139
+ }
140
+ get region() {
141
+ return this.querySelector("ui-toast-region");
142
+ }
143
+ attributeChangedCallback(name, old, value) {
144
+ super.attributeChangedCallback(name, old, value);
145
+ if (name === "attached" && this.observer && old === null !== (value === null)) this.rebuild();
146
+ }
147
+ setup() {
148
+ this.observer = new MutationObserver(() => this.sync());
149
+ this.observer.observe(this, {
150
+ childList: true,
151
+ subtree: true,
152
+ attributes: true,
153
+ attributeFilter: ["data-type", "data-ending-style"]
154
+ });
155
+ this.sync();
156
+ }
157
+ teardown() {
158
+ this.observer?.disconnect();
159
+ this.observer = null;
160
+ this.reset();
161
+ }
162
+ surfaceFor() {
163
+ return [];
164
+ }
165
+ reset() {
166
+ for (const surface of [...this.surfaces]) this.detach(surface);
167
+ for (const toast of this.links.keys()) {
168
+ toast.style.removeProperty("transform");
169
+ toast.style.removeProperty("--clay-from");
170
+ toast.style.removeProperty("--clay-to");
171
+ }
172
+ this.loose.clear();
173
+ this.links.clear();
174
+ this.stack = null;
175
+ }
176
+ rebuild() {
177
+ this.reset();
178
+ this.sync();
179
+ }
180
+ sync() {
181
+ const toasts = [...this.querySelectorAll("ui-toast")];
182
+ if (this.attached) this.syncStack(toasts);
183
+ else this.syncLoose(toasts);
184
+ const items = this.attached ? [...this.links] : [...this.loose];
185
+ for (const [toast, item] of items) {
186
+ if (!toast.isConnected) continue;
187
+ this.follow(toast, item);
188
+ this.slide(toast, item, 0, false);
189
+ }
190
+ }
191
+ /** Notes where a toast's layout box is now and, if the list moved it, keeps it where it was to glide. */
192
+ follow(toast, item) {
193
+ const top = this.region.getBoundingClientRect().top + toast.offsetTop;
194
+ if (item.top !== null && Math.abs(top - item.top) > .5) {
195
+ item.shift.x += item.top - top;
196
+ item.shift.target = 0;
197
+ }
198
+ item.top = top;
199
+ }
200
+ slide(toast, item, dt, still) {
201
+ const moving = item.shift.step(dt, SPRINGS.travel, still);
202
+ const shift = Math.abs(item.shift.x) < .2 ? "" : `translateY(${item.shift.x.toFixed(1)}px)`;
203
+ if (shift !== item.lastShift) {
204
+ item.lastShift = shift;
205
+ toast.style.transform = shift;
206
+ }
207
+ return moving;
208
+ }
209
+ syncLoose(toasts) {
210
+ for (const [toast, landing] of this.loose) {
211
+ if (!toast.isConnected) {
212
+ this.detach(landing.surface);
213
+ this.loose.delete(toast);
214
+ continue;
215
+ }
216
+ if (toast.hasAttribute("data-ending-style") && !landing.leaving) {
217
+ landing.leaving = true;
218
+ landing.land.target = -.75;
219
+ landing.land.v = 7;
220
+ }
221
+ landing.surface.invalidate();
222
+ }
223
+ for (const toast of toasts) {
224
+ if (this.loose.has(toast)) continue;
225
+ const land = new Spring(1);
226
+ land.target = 0;
227
+ const landing = {
228
+ land,
229
+ shift: new Spring(0),
230
+ top: null,
231
+ lastShift: "",
232
+ leaving: false
233
+ };
234
+ const surface = this.attach(toast, {
235
+ swell: false,
236
+ pad: 34,
237
+ measure: () => this.follow(toast, landing),
238
+ step: (dt, still) => [land.step(dt, {
239
+ omega: 13,
240
+ zeta: .32
241
+ }, still), this.slide(toast, landing, dt, still)].some(Boolean),
242
+ shapes: () => this.landed(toast, landing)
243
+ });
244
+ if (!surface) return;
245
+ this.loose.set(toast, Object.assign(landing, { surface }));
246
+ }
247
+ }
248
+ landed(toast, { surface, land }) {
249
+ const base = slab(surface, toastColor(toast), 22, 16, 1.3);
250
+ const squash = land.x;
251
+ const w = base.w * (1 + squash * .07);
252
+ const h = base.h * (1 - squash * .14);
253
+ return [{
254
+ ...base,
255
+ x: (base.w - w) / 2,
256
+ y: base.h - h,
257
+ w,
258
+ h
259
+ }];
260
+ }
261
+ get towardEdge() {
262
+ return this.region.getAttribute("data-side") === "top" ? -28 : 28;
263
+ }
264
+ syncStack(toasts) {
265
+ if (!this.stack) {
266
+ this.stack = this.attach(this.region, {
267
+ swell: false,
268
+ pad: () => 60 + Math.ceil(Math.max(0, ...[...this.links.values()].map((link) => Math.abs(link.shift.x)))),
269
+ measure: () => this.measureStack(),
270
+ step: (dt, still) => this.stepStack(dt, still),
271
+ shapes: () => this.stackShapes()
272
+ });
273
+ if (!this.stack) return;
274
+ }
275
+ for (const toast of this.links.keys()) if (!toast.isConnected) this.links.delete(toast);
276
+ const staying = (toast) => !toast.hasAttribute("data-ending-style");
277
+ toasts.forEach((toast, index) => {
278
+ if (this.links.has(toast)) return;
279
+ this.stack.visible = true;
280
+ const anchor = toasts.slice(index + 1).find(staying) ?? null;
281
+ const emerge = new Spring(0);
282
+ emerge.target = 1;
283
+ this.links.set(toast, {
284
+ emerge,
285
+ shift: new Spring(0),
286
+ anchor,
287
+ box: null,
288
+ top: null,
289
+ leaving: false,
290
+ lastShift: ""
291
+ });
292
+ toast.style.setProperty("--clay-from", `${this.toward(toast, anchor)}px`);
293
+ });
294
+ toasts.forEach((toast, index) => {
295
+ const link = this.links.get(toast);
296
+ if (!link || link.leaving || staying(toast)) return;
297
+ link.leaving = true;
298
+ link.emerge.target = PAST;
299
+ link.anchor = toasts.slice(index + 1).find(staying) ?? toasts.slice(0, index).reverse().find(staying) ?? null;
300
+ toast.style.setProperty("--clay-to", `${this.toward(toast, link.anchor)}px`);
301
+ });
302
+ this.stack.invalidate();
303
+ }
304
+ /** Which way, in px along the stack, the toast's text should travel to reach its anchor. */
305
+ toward(toast, anchor) {
306
+ if (!anchor) return this.towardEdge;
307
+ const a = anchor.offsetTop + anchor.offsetHeight / 2;
308
+ const b = toast.offsetTop + toast.offsetHeight / 2;
309
+ return clamp(a - b, -28, 28);
310
+ }
311
+ measureStack() {
312
+ for (const [toast, link] of this.links) {
313
+ link.box = {
314
+ x: toast.offsetLeft,
315
+ y: toast.offsetTop,
316
+ w: toast.offsetWidth,
317
+ h: toast.offsetHeight
318
+ };
319
+ this.follow(toast, link);
320
+ }
321
+ }
322
+ stepStack(dt, still) {
323
+ let moving = false;
324
+ for (const [toast, link] of this.links) {
325
+ if (link.emerge.step(dt, link.emerge.target > 0 ? OUT : BACK, still)) moving = true;
326
+ if (this.slide(toast, link, dt, still)) moving = true;
327
+ }
328
+ return moving;
329
+ }
330
+ placed(link) {
331
+ return link.box ? {
332
+ ...link.box,
333
+ y: link.box.y + link.shift.x
334
+ } : null;
335
+ }
336
+ stackShapes() {
337
+ const surface = this.stack;
338
+ const items = [...this.links].map(([toast, link]) => ({
339
+ toast,
340
+ link,
341
+ own: this.placed(link)
342
+ })).filter((item) => !!item.own).sort((a, b) => a.own.y - b.own.y).slice(0, MAX_LINKED);
343
+ const towardTop = this.towardEdge < 0;
344
+ const shapes = [];
345
+ for (const { toast, link, own } of items) {
346
+ const anchor = link.anchor ? this.links.get(link.anchor) : void 0;
347
+ const from = anchor && this.placed(anchor);
348
+ const e = clamp(link.emerge.x, 0, 1.1);
349
+ let box;
350
+ let grip;
351
+ if (from) {
352
+ const face = faceOf(from, own);
353
+ box = lerpBox(seed(from, own, face), own, e);
354
+ const out = poke(from, box, face);
355
+ if (out <= 0) continue;
356
+ grip = smooth(0, GRIP, out);
357
+ } else {
358
+ box = lerpBox({
359
+ x: own.x + own.w * .3,
360
+ y: towardTop ? own.y : own.y + own.h,
361
+ w: own.w * .4,
362
+ h: 0
363
+ }, own, e);
364
+ grip = smooth(0, .3, e);
365
+ }
366
+ if (box.h < 1 || box.w < 1) continue;
367
+ shapes.push({
368
+ ...box,
369
+ radius: Math.min(22, box.h / 2),
370
+ color: surface.color(toastColor(toast), NEUTRAL),
371
+ height: .85,
372
+ bevel: 16,
373
+ lift: 1.3,
374
+ melt: shapes.length ? Math.max((30 + (1 - Math.min(e, 1)) * 10) * grip, .01) : 0,
375
+ blend: 9
376
+ });
377
+ }
378
+ return shapes;
379
+ }
380
+ };
381
+ export { ClayDialog, ClayMenu, ClayPopover, ClayToastRegion };
382
+
383
+ //# sourceMappingURL=overlays.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlays.js","names":[],"sources":["../../../../src/clay/components/overlays.ts"],"sourcesContent":["import { Attachment, BACK, BLEND, faceOf, fuseOf, GLUE, GRIP, hug, OUT, PAST, poke, seed, smooth } from \"../attach\"\nimport { SPRINGS } from \"../config\"\nimport type { ClayShape } from \"../engine\"\nimport { ClayElement, NEUTRAL } from \"../element\"\nimport { Highlight, withHighlight } from \"../highlight\"\nimport { clamp, lerpBox, pressable, slab, type Box } from \"../shared\"\nimport { Spring } from \"../spring\"\nimport type { ClaySurface, SurfaceOptions } from \"../surface\"\n\n/**\n * A trigger drawn as a clay button, and a popup drawn as a clay slab that grows out of it. With\n * `attached`, the popup squeezes out of the button like Roll's bead and stays melted onto it.\n */\nabstract class ClayPopupElement extends ClayElement {\n static observedAttributes = [\"color\", \"size\", \"icon\", \"attached\", \"fuse\"]\n protected abstract readonly trigger: string\n protected abstract readonly content: string\n protected popupRadius = 22\n protected popupBevel = 16\n protected popupLift = 1.4\n /** Dialogs sit in the middle of the page, away from their trigger. */\n protected attachable = true\n /** Items a sliding highlight follows, for menus. */\n protected items = \"\"\n private attachment: Attachment | null = null\n private highlight: Highlight | null = null\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 triggerButton() {\n return this.querySelector<HTMLElement>(`${this.trigger} :is(button, a)`)\n }\n\n protected setup() {\n this.querySelectorAll<HTMLElement>(`${this.content} :is(ui-menu-item, ui-menu-checkbox-item, ui-menu-radio-item)`).forEach(\n (item, index) => item.style.setProperty(\"--clay-i\", String(index))\n )\n const content = this.querySelector<HTMLElement>(this.content)\n const button = this.triggerButton\n if (content && this.items) {\n this.highlight = new Highlight(content, this.items)\n this.cleanup.push(this.highlight.watch(() => this.surfaces[1]?.invalidate()))\n }\n if (!content || !button || !this.attachable || !this.hasAttribute(\"attached\")) return\n this.refit = hug(content, () => fuseOf(this))\n this.attachment = new Attachment(\n content,\n {\n trigger: () => this.triggerButton,\n triggerRadius: (box) => box.h / 2,\n triggerColor: () => this.surfaces[0]?.color(\"--clay-color\", NEUTRAL) ?? NEUTRAL,\n color: () => this.surfaces[1]?.color(\"--clay-popup\", NEUTRAL) ?? NEUTRAL,\n radius: this.popupRadius,\n bevel: this.popupBevel,\n lift: this.popupLift,\n fuse: () => fuseOf(this),\n calm: (on) => this.surfaces[0]?.calm(on),\n onTuck: () => this.surfaces[0]?.bounce(),\n },\n () => this.surfaces[1]\n )\n this.cleanup.push(this.attachment.connect())\n }\n\n protected teardown() {\n for (const fn of this.cleanup) fn()\n this.cleanup = []\n this.attachment = null\n this.highlight = null\n }\n\n protected surfaceFor(): Array<[HTMLElement, SurfaceOptions]> {\n const surfaces: Array<[HTMLElement, SurfaceOptions]> = []\n const trigger = this.triggerButton\n const content = this.querySelector<HTMLElement>(this.content)\n let index = 0\n if (trigger) {\n const at = index++\n surfaces.push([\n trigger,\n {\n shapes: () => [\n { ...pressable(this.surfaces[at]!), blend: this.attachment ? BLEND : undefined },\n ...(this.attachment?.joint(trigger) ?? []),\n ],\n },\n ])\n }\n if (content) {\n const at = index++\n const base = (at === 1 && this.attachment?.surfaceOptions()) || {\n swell: false,\n pad: 40,\n shapes: () => [slab(this.surfaces[at]!, \"--clay-popup\", this.popupRadius, this.popupBevel, this.popupLift)],\n }\n surfaces.push([content, withHighlight(base, this.highlight, () => this.surfaces[at], this.attachment)])\n }\n return surfaces\n }\n}\n\n/** Spill: a menu of actions that spills out of its clay button. */\nclass ClayMenu extends ClayPopupElement {\n protected readonly requires = \"ui-menu-trigger\"\n protected items = \"[data-slot='menu-item'], [data-slot='menu-checkbox-item'], [data-slot='menu-radio-item']\"\n protected readonly trigger = \"ui-menu-trigger\"\n protected readonly content = \"ui-menu-content\"\n protected popupRadius = 20\n}\n\n/** Unfold: a small clay card that unfolds from its button. */\nclass ClayPopover extends ClayPopupElement {\n protected readonly requires = \"ui-popover-trigger\"\n protected readonly trigger = \"ui-popover-trigger\"\n protected readonly content = \"ui-popover-content\"\n protected popupRadius = 26\n protected popupBevel = 20\n}\n\n/** Lift: a dialog lifted out of the page as a thick clay slab. */\nclass ClayDialog extends ClayPopupElement {\n protected readonly requires = \"ui-dialog-content\"\n protected attachable = false\n protected readonly trigger = \"ui-dialog-trigger\"\n protected readonly content = \"ui-dialog-content\"\n protected popupRadius = 32\n protected popupBevel = 26\n protected popupLift = 2.4\n}\n\n/** A toast that glides to its new place when the ones around it come and go, instead of jumping. */\ninterface Sliding {\n /** How far the toast still sits from its layout box after the list moved, in px. */\n shift: Spring\n /** Where its layout box was, from the top of the viewport. */\n top: number | null\n lastShift: string\n}\n\ninterface Landing extends Sliding {\n surface: ClaySurface\n land: Spring\n leaving: boolean\n}\n\ninterface Link extends Sliding {\n /** 0 tucked into its anchor, 1 out in its own place. */\n emerge: Spring\n anchor: HTMLElement | null\n box: Box | null\n leaving: boolean\n}\n\nconst TOAST_COLOR: Record<string, string> = {\n success: \"--clay-success\",\n error: \"--clay-danger\",\n warning: \"--clay-butter\",\n}\n\nconst MAX_LINKED = 8\n\nconst toastColor = (toast: HTMLElement) => TOAST_COLOR[toast.getAttribute(\"data-type\") ?? \"\"] ?? \"--clay-popup\"\n\n/**\n * Drop: toasts that drop in as clay slabs, squash as they land and lift back off the same way.\n * With `attached`, the stack is one body: each toast pulls out of the one before it and stays melted\n * onto it, and leaving runs the same path back.\n */\nclass ClayToastRegion extends ClayElement {\n static observedAttributes = [\"attached\"]\n protected readonly requires = \"ui-toast-region\"\n private loose = new Map<HTMLElement, Landing>()\n private links = new Map<HTMLElement, Link>()\n private stack: ClaySurface | null = null\n private observer: MutationObserver | null = null\n\n private get attached() {\n return this.hasAttribute(\"attached\")\n }\n\n private get region() {\n return this.querySelector<HTMLElement>(\"ui-toast-region\")!\n }\n\n attributeChangedCallback(name: string, old: string | null, value: string | null) {\n super.attributeChangedCallback(name, old, value)\n if (name === \"attached\" && this.observer && (old === null) !== (value === null)) this.rebuild()\n }\n\n protected setup() {\n this.observer = new MutationObserver(() => this.sync())\n this.observer.observe(this, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: [\"data-type\", \"data-ending-style\"],\n })\n this.sync()\n }\n\n protected teardown() {\n this.observer?.disconnect()\n this.observer = null\n this.reset()\n }\n\n protected surfaceFor(): Array<[HTMLElement, SurfaceOptions]> {\n return []\n }\n\n private reset() {\n for (const surface of [...this.surfaces]) this.detach(surface)\n for (const toast of this.links.keys()) {\n toast.style.removeProperty(\"transform\")\n toast.style.removeProperty(\"--clay-from\")\n toast.style.removeProperty(\"--clay-to\")\n }\n this.loose.clear()\n this.links.clear()\n this.stack = null\n }\n\n private rebuild() {\n this.reset()\n this.sync()\n }\n\n private sync() {\n const toasts = [...this.querySelectorAll<HTMLElement>(\"ui-toast\")]\n if (this.attached) this.syncStack(toasts)\n else this.syncLoose(toasts)\n // The list has just changed, before the browser paints it: put every toast back where it was, to\n // glide from there, so none of them jumps for a frame.\n const items: Array<[HTMLElement, Sliding]> = this.attached ? [...this.links] : [...this.loose]\n for (const [toast, item] of items) {\n if (!toast.isConnected) continue\n this.follow(toast, item)\n this.slide(toast, item, 0, false)\n }\n }\n\n /** Notes where a toast's layout box is now and, if the list moved it, keeps it where it was to glide. */\n private follow(toast: HTMLElement, item: Sliding) {\n const top = this.region.getBoundingClientRect().top + toast.offsetTop\n if (item.top !== null && Math.abs(top - item.top) > 0.5) {\n item.shift.x += item.top - top\n item.shift.target = 0\n }\n item.top = top\n }\n\n private slide(toast: HTMLElement, item: Sliding, dt: number, still: boolean) {\n const moving = item.shift.step(dt, SPRINGS.travel, still)\n const shift = Math.abs(item.shift.x) < 0.2 ? \"\" : `translateY(${item.shift.x.toFixed(1)}px)`\n if (shift !== item.lastShift) {\n item.lastShift = shift\n toast.style.transform = shift\n }\n return moving\n }\n\n private syncLoose(toasts: HTMLElement[]) {\n for (const [toast, landing] of this.loose) {\n if (!toast.isConnected) {\n this.detach(landing.surface)\n this.loose.delete(toast)\n continue\n }\n if (toast.hasAttribute(\"data-ending-style\") && !landing.leaving) {\n landing.leaving = true\n landing.land.target = -0.75\n landing.land.v = 7\n }\n landing.surface.invalidate()\n }\n for (const toast of toasts) {\n if (this.loose.has(toast)) continue\n const land = new Spring(1)\n land.target = 0\n const landing = { land, shift: new Spring(0), top: null, lastShift: \"\", leaving: false } as Omit<Landing, \"surface\">\n const surface = this.attach(toast, {\n swell: false,\n pad: 34,\n measure: () => this.follow(toast, landing),\n step: (dt, still) =>\n [land.step(dt, { omega: 13, zeta: 0.32 }, still), this.slide(toast, landing, dt, still)].some(Boolean),\n shapes: () => this.landed(toast, landing as Landing),\n })\n if (!surface) return\n this.loose.set(toast, Object.assign(landing, { surface }))\n }\n }\n\n private landed(toast: HTMLElement, { surface, land }: Landing): ClayShape[] {\n const base = slab(surface, toastColor(toast), 22, 16, 1.3)\n const squash = land.x\n const w = base.w * (1 + squash * 0.07)\n const h = base.h * (1 - squash * 0.14)\n return [{ ...base, x: (base.w - w) / 2, y: base.h - h, w, h }]\n }\n\n private get towardEdge() {\n return this.region.getAttribute(\"data-side\") === \"top\" ? -28 : 28\n }\n\n private syncStack(toasts: HTMLElement[]) {\n if (!this.stack) {\n this.stack = this.attach(this.region, {\n swell: false,\n // A toast held where it was while the stack shrinks sits outside the region: make room for it.\n pad: () => 60 + Math.ceil(Math.max(0, ...[...this.links.values()].map((link) => Math.abs(link.shift.x)))),\n measure: () => this.measureStack(),\n step: (dt, still) => this.stepStack(dt, still),\n shapes: () => this.stackShapes(),\n })\n if (!this.stack) return\n }\n for (const toast of this.links.keys()) if (!toast.isConnected) this.links.delete(toast)\n const staying = (toast: HTMLElement) => !toast.hasAttribute(\"data-ending-style\")\n toasts.forEach((toast, index) => {\n if (this.links.has(toast)) return\n // The stack is on screen as soon as a toast arrives: don't wait frames for the visibility observer.\n this.stack!.visible = true\n const anchor = toasts.slice(index + 1).find(staying) ?? null\n const emerge = new Spring(0)\n emerge.target = 1\n this.links.set(toast, { emerge, shift: new Spring(0), anchor, box: null, top: null, leaving: false, lastShift: \"\" })\n toast.style.setProperty(\"--clay-from\", `${this.toward(toast, anchor)}px`)\n })\n toasts.forEach((toast, index) => {\n const link = this.links.get(toast)\n if (!link || link.leaving || staying(toast)) return\n link.leaving = true\n link.emerge.target = PAST\n link.anchor = toasts.slice(index + 1).find(staying) ?? toasts.slice(0, index).reverse().find(staying) ?? null\n toast.style.setProperty(\"--clay-to\", `${this.toward(toast, link.anchor)}px`)\n })\n this.stack.invalidate()\n }\n\n /** Which way, in px along the stack, the toast's text should travel to reach its anchor. */\n private toward(toast: HTMLElement, anchor: HTMLElement | null) {\n if (!anchor) return this.towardEdge\n const a = anchor.offsetTop + anchor.offsetHeight / 2\n const b = toast.offsetTop + toast.offsetHeight / 2\n return clamp(a - b, -28, 28)\n }\n\n private measureStack() {\n for (const [toast, link] of this.links) {\n link.box = { x: toast.offsetLeft, y: toast.offsetTop, w: toast.offsetWidth, h: toast.offsetHeight }\n this.follow(toast, link)\n }\n }\n\n private stepStack(dt: number, still: boolean) {\n let moving = false\n for (const [toast, link] of this.links) {\n if (link.emerge.step(dt, link.emerge.target > 0 ? OUT : BACK, still)) moving = true\n if (this.slide(toast, link, dt, still)) moving = true\n }\n return moving\n }\n\n private placed(link: Link): Box | null {\n return link.box ? { ...link.box, y: link.box.y + link.shift.x } : null\n }\n\n private stackShapes(): ClayShape[] {\n const surface = this.stack!\n const items = [...this.links]\n .map(([toast, link]) => ({ toast, link, own: this.placed(link) }))\n .filter((item): item is { toast: HTMLElement; link: Link; own: Box } => !!item.own)\n .sort((a, b) => a.own.y - b.own.y)\n .slice(0, MAX_LINKED)\n const towardTop = this.towardEdge < 0\n const shapes: ClayShape[] = []\n for (const { toast, link, own } of items) {\n const anchor = link.anchor ? this.links.get(link.anchor) : undefined\n const from = anchor && this.placed(anchor)\n const e = clamp(link.emerge.x, 0, 1.1)\n let box: Box\n let grip: number\n if (from) {\n // It squeezes out of a sliver inside the edge it shares with its neighbour, like an attached\n // popup out of its button, and melts on as it comes out, so nothing bulges before or after.\n const face = faceOf(from, own)\n box = lerpBox(seed(from, own, face), own, e)\n const out = poke(from, box, face)\n if (out <= 0) continue\n grip = smooth(0, GRIP, out)\n } else {\n box = lerpBox({ x: own.x + own.w * 0.3, y: towardTop ? own.y : own.y + own.h, w: own.w * 0.4, h: 0 }, own, e)\n grip = smooth(0, 0.3, e)\n }\n if (box.h < 1 || box.w < 1) continue\n shapes.push({\n ...box,\n radius: Math.min(22, box.h / 2),\n color: surface.color(toastColor(toast), NEUTRAL),\n height: 0.85,\n bevel: 16,\n lift: 1.3,\n melt: shapes.length ? Math.max((GLUE + (1 - Math.min(e, 1)) * 10) * grip, 0.01) : 0,\n blend: BLEND,\n })\n }\n return shapes\n }\n}\n\nexport { ClayDialog, ClayMenu, ClayPopover, ClayToastRegion }\n"],"mappings":";;;;;;;;;;;AAaA,IAAe,mBAAf,cAAwC,YAAY;CAClD,OAAO,qBAAqB;EAAC;EAAS;EAAQ;EAAQ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,MAAM,GAAG,UAAU;EACtB,MAAM,YAAY,KAAK,aAAa;EACpC,MAAM,SAAsB,CAAC;EAC7B,KAAK,MAAM,EAAE,OAAO,MAAM,SAAS,OAAO;GACxC,MAAM,SAAS,KAAK,SAAS,KAAK,MAAM,IAAI,KAAK,MAAM,IAAI,KAAA;GAC3D,MAAM,OAAO,UAAU,KAAK,OAAO,MAAM;GACzC,MAAM,IAAI,MAAM,KAAK,OAAO,GAAG,GAAG,GAAG;GACrC,IAAI;GACJ,IAAI;GACJ,IAAI,MAAM;IAGR,MAAM,OAAO,OAAO,MAAM,GAAG;IAC7B,MAAM,QAAQ,KAAK,MAAM,KAAK,IAAI,GAAG,KAAK,CAAC;IAC3C,MAAM,MAAM,KAAK,MAAM,KAAK,IAAI;IAChC,IAAI,OAAO,GAAG;IACd,OAAO,OAAO,GAAG,MAAM,GAAG;GAC5B,OAAO;IACL,MAAM,QAAQ;KAAE,GAAG,IAAI,IAAI,IAAI,IAAI;KAAK,GAAG,YAAY,IAAI,IAAI,IAAI,IAAI,IAAI;KAAG,GAAG,IAAI,IAAI;KAAK,GAAG;IAAE,GAAG,KAAK,CAAC;IAC5G,OAAO,OAAO,GAAG,IAAK,CAAC;GACzB;GACA,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,GAAG;GAC5B,OAAO,KAAK;IACV,GAAG;IACH,QAAQ,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC;IAC9B,OAAO,QAAQ,MAAM,WAAW,KAAK,GAAG,OAAO;IAC/C,QAAQ;IACR,OAAO;IACP,MAAM;IACN,MAAM,OAAO,SAAS,KAAK,KAAA,MAAa,IAAI,KAAK,IAAI,GAAG,CAAC,KAAK,MAAM,MAAM,GAAI,IAAI;IAClF,OAAA;GACF,CAAC;EACH;EACA,OAAO;CACT;AACF"}
@@ -0,0 +1,55 @@
1
+ import { ClayElement } from "../element.js";
2
+ import { type SurfaceOptions } from "../surface.js";
3
+ /**
4
+ * Pour: a select whose list pours out of its clay trigger, with a well that slides to the option under
5
+ * the pointer. The chosen value is revealed with a blur once the list has gone. With `attached`, the
6
+ * list squeezes out of the trigger like Roll's bead, stays melted onto it, and the trigger bounces as
7
+ * the list tucks back in, which is when the new value shows.
8
+ */
9
+ declare class ClaySelect extends ClayElement {
10
+ static observedAttributes: string[];
11
+ protected readonly requires = "ui-select-trigger button";
12
+ private observer;
13
+ private attachment;
14
+ private highlight;
15
+ private release;
16
+ private refit;
17
+ private cleanup;
18
+ attributeChangedCallback(name: string, old: string | null, value: string | null): void;
19
+ private get list();
20
+ protected setup(): void;
21
+ /**
22
+ * The chosen value waits while the list is out: the old text stays, held by a copy, until the list
23
+ * is gone, then the new one is revealed with a blur.
24
+ */
25
+ private watchValue;
26
+ protected teardown(): void;
27
+ /**
28
+ * The new value is wiped in from the left out of a blur while the old one blurs away in its place.
29
+ * Returns a function that stops it.
30
+ */
31
+ private reveal;
32
+ protected surfaceFor(): Array<[HTMLElement, SurfaceOptions]>;
33
+ }
34
+ /**
35
+ * Pop: a tooltip that pops out as a small clay tag. With `attached`, the tag squeezes out of its button
36
+ * like Roll's bead, stays melted onto it while it's open, and tucks back in.
37
+ */
38
+ declare class ClayTooltip extends ClayElement {
39
+ static observedAttributes: string[];
40
+ protected readonly requires = "ui-tooltip-content";
41
+ private attachment;
42
+ private stop;
43
+ private refit;
44
+ private get attached();
45
+ attributeChangedCallback(name: string, old: string | null, value: string | null): void;
46
+ private get content();
47
+ /** The clay element the trigger button sits in, whose colour the tag takes when it has none. */
48
+ private get body();
49
+ private bodyColor;
50
+ protected updateTone(): void;
51
+ protected setup(): void;
52
+ protected teardown(): void;
53
+ protected surfaceFor(): Array<[HTMLElement, SurfaceOptions]>;
54
+ }
55
+ export { ClaySelect, ClayTooltip };