@glasshome/ui 1.43.0 → 1.44.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 (36) hide show
  1. package/SPEC.md +8 -5
  2. package/dist/index.js +2 -2
  3. package/dist/lib/behavior/anchored.d.ts +7 -8
  4. package/dist/lib/behavior/focus-scope.d.ts +4 -2
  5. package/dist/lib/behavior/menu.d.ts +3 -0
  6. package/dist/lib/motion-classes.d.ts +1 -0
  7. package/dist/solid/data-table.d.ts +4 -2
  8. package/dist/solid/index.js +3115 -3123
  9. package/dist/{utils-3Codx-NZ.js → utils-BbIeGt7o.js} +524 -500
  10. package/package.json +1 -1
  11. package/src/lib/behavior/anchored.ts +17 -3
  12. package/src/lib/behavior/collection.ts +9 -18
  13. package/src/lib/behavior/focus-scope.ts +51 -10
  14. package/src/lib/behavior/menu.ts +20 -28
  15. package/src/lib/behavior/modal-root.tsx +2 -2
  16. package/src/lib/clipboard.ts +2 -2
  17. package/src/lib/motion-classes.ts +1 -2
  18. package/src/solid/area-picker.tsx +1 -2
  19. package/src/solid/bottom-sheet/arbitration.ts +4 -11
  20. package/src/solid/bottom-sheet/bottom-sheet.tsx +3 -4
  21. package/src/solid/bottom-sheet/drag-controller.ts +7 -20
  22. package/src/solid/data-table.tsx +48 -22
  23. package/src/solid/dialog-parts.tsx +30 -8
  24. package/src/solid/dock.tsx +41 -41
  25. package/src/solid/entity-selector.tsx +0 -1
  26. package/src/solid/icon-picker.tsx +1 -2
  27. package/src/solid/image-picker.tsx +2 -2
  28. package/src/solid/menu-parts.tsx +1 -20
  29. package/src/solid/option-card.tsx +1 -3
  30. package/src/solid/popover.tsx +10 -12
  31. package/src/solid/select.tsx +4 -15
  32. package/src/solid/selection.tsx +28 -13
  33. package/src/solid/sliding-indicator.tsx +3 -15
  34. package/src/solid/toggle-group.tsx +5 -2
  35. package/src/styles/globals.css +0 -43
  36. package/src/styles/theme.css +5 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glasshome/ui",
3
- "version": "1.43.0",
3
+ "version": "1.44.0",
4
4
  "description": "SolidJS component library for GlassHome",
5
5
  "keywords": [
6
6
  "components",
@@ -1,13 +1,18 @@
1
1
  import type { Accessor } from "solid-js";
2
- import { type Align, placeBeside, type Side } from "../anchor-placement.js";
2
+ import { type Align, type Box, placeBeside, type Side } from "../anchor-placement.js";
3
3
  import { effect } from "./solid.js";
4
4
 
5
5
  /** An element, or a point or box with no element of its own: a context menu opens at the pointer. */
6
6
  export interface AnchorLike {
7
- getBoundingClientRect(): { left: number; top: number; width: number; height: number };
7
+ getBoundingClientRect: () => Box;
8
8
  getRootNode?(): Node;
9
9
  }
10
10
 
11
+ export interface Anchored {
12
+ /** Where the part was last placed, from the measure that placed it. */
13
+ placed: () => Box | undefined;
14
+ }
15
+
11
16
  export interface AnchoredOptions {
12
17
  anchor: Accessor<AnchorLike | undefined>;
13
18
  floating: Accessor<HTMLElement | undefined>;
@@ -26,7 +31,8 @@ const SHADOW_ROOT_NODE = 11;
26
31
  // The widget realm's tap guard reads this marker as a placed panel.
27
32
  const ANCHORED = "data-anchored";
28
33
 
29
- export function createAnchored(options: AnchoredOptions): void {
34
+ export function createAnchored(options: AnchoredOptions): Anchored {
35
+ let last: Box | undefined;
30
36
  effect(
31
37
  () =>
32
38
  [
@@ -70,6 +76,12 @@ export function createAnchored(options: AnchoredOptions): void {
70
76
  const top = cover && box.top >= 0 ? Math.min(placed.top, box.top + offset) : placed.top;
71
77
  write("top", `${top}px`);
72
78
  write("left", `${placed.left}px`);
79
+ last = {
80
+ left: placed.left,
81
+ top,
82
+ width: Math.min(size.width, placed.maxWidth),
83
+ height: Math.min(size.height, placed.maxHeight),
84
+ };
73
85
  write("max-width", `${placed.maxWidth}px`);
74
86
  write("max-height", `${placed.maxHeight}px`);
75
87
  if (matchAnchorWidth) write("min-width", `${box.width}px`);
@@ -100,7 +112,9 @@ export function createAnchored(options: AnchoredOptions): void {
100
112
  window.removeEventListener("resize", onResize);
101
113
  if (frame !== undefined) cancelAnimationFrame(frame);
102
114
  floating.removeAttribute(ANCHORED);
115
+ last = undefined;
103
116
  };
104
117
  },
105
118
  );
119
+ return { placed: () => last };
106
120
  }
@@ -1,5 +1,5 @@
1
1
  import { type Accessor, createSignal, onCleanup } from "solid-js";
2
- import { activeOf, focusWithoutTracking } from "./focus-scope.js";
2
+ import { focusedIn, focusWithoutTracking } from "./focus-scope.js";
3
3
  import { effect } from "./solid.js";
4
4
 
5
5
  export const TYPEAHEAD_MS = 1000;
@@ -100,10 +100,10 @@ export function createCollection(options: CollectionOptions): Collection {
100
100
  const enabledItems = (root: HTMLElement) =>
101
101
  [...root.querySelectorAll<HTMLElement>(options.itemSelector)].filter((el) => !skipped(el));
102
102
 
103
- // Tracked from focus events, which a sealed widget already receives; reading activeElement asks the page.
104
- let focused: Element | null = null;
105
- const focusIsWithin = (root: HTMLElement) =>
106
- !!focused && focused.isConnected && root.contains(focused);
103
+ const focusIsWithin = (root: HTMLElement) => {
104
+ const focused = focusedIn(root);
105
+ return !!focused && root.contains(focused);
106
+ };
107
107
 
108
108
  function placeStop(root: HTMLElement | undefined, preferred: readonly string[]) {
109
109
  if (!root || focusIsWithin(root)) return;
@@ -132,26 +132,17 @@ export function createCollection(options: CollectionOptions): Collection {
132
132
  if (options.focus === "roving") {
133
133
  effect(options.root, (root) => {
134
134
  if (!root) return;
135
- // One read when the listeners attach, so an item focused before them (autofocus) keeps the stop.
136
- const current = activeOf(root);
137
- focused = current && root.contains(current) ? current : null;
138
- const item = focused?.closest<HTMLElement>(options.itemSelector);
135
+ // An item focused before the collection mounts (autofocus) keeps the stop.
136
+ const current = focusedIn(root);
137
+ const item = current?.closest<HTMLElement>(options.itemSelector);
139
138
  if (item && root.contains(item)) setOwn(keyOf(item));
140
- const enter = (event: FocusEvent) => {
141
- focused = event.target instanceof Element ? event.target : null;
142
- };
143
139
  const leave = (event: FocusEvent) => {
144
140
  const next = event.relatedTarget;
145
141
  if (next instanceof Element && root.contains(next)) return;
146
- focused = null;
147
142
  refresh();
148
143
  };
149
- root.addEventListener("focusin", enter);
150
144
  root.addEventListener("focusout", leave);
151
- return () => {
152
- root.removeEventListener("focusin", enter);
153
- root.removeEventListener("focusout", leave);
154
- };
145
+ return () => root.removeEventListener("focusout", leave);
155
146
  });
156
147
  effect(
157
148
  () => [options.root(), options.preferred?.() ?? []] as const,
@@ -36,18 +36,59 @@ export interface FocusScope {
36
36
  const DOCUMENT_NODE = 9;
37
37
  const SHADOW_ROOT_NODE = 11;
38
38
 
39
- /** The focused element in the node's own root, or null while focus is in another root. */
40
- export function activeOf(node: Node): Element | null {
41
- const root = node.getRootNode();
42
- if (root.nodeType === DOCUMENT_NODE) return (root as Document).activeElement;
43
- if (root.nodeType !== SHADOW_ROOT_NODE) return null;
44
- let host = (root as ShadowRoot).host;
39
+ const outermostHost = (root: ShadowRoot): Element => {
40
+ let host = root.host;
45
41
  for (let up = host.getRootNode(); up.nodeType === SHADOW_ROOT_NODE; up = host.getRootNode())
46
42
  host = (up as ShadowRoot).host;
43
+ return host;
44
+ };
45
+
46
+ function readFocus(root: Node): Element | null {
47
+ if (root.nodeType === DOCUMENT_NODE) return (root as Document).activeElement;
48
+ const host = outermostHost(root as ShadowRoot);
47
49
  // A shadow root holds focus only while the document's focus sits on its outermost host.
48
50
  return host.ownerDocument.activeElement === host ? (root as ShadowRoot).activeElement : null;
49
51
  }
50
52
 
53
+ const focusByRoot = new WeakMap<Node, { at: Element | null }>();
54
+
55
+ /** The focused element in the node's own root, kept from focusin and focusout, which a sealed widget receives without asking the page. */
56
+ export function focusedIn(node: Node): Element | null {
57
+ const root = node.getRootNode();
58
+ if (root.nodeType !== DOCUMENT_NODE && root.nodeType !== SHADOW_ROOT_NODE) return null;
59
+ let tracked = focusByRoot.get(root);
60
+ if (!tracked) {
61
+ // One read when the listeners attach; a focus move runs its events inside the call that makes it.
62
+ const seen = { at: readFocus(root) };
63
+ root.addEventListener(
64
+ "focusin",
65
+ (e) => {
66
+ seen.at = e.target instanceof Element ? e.target : null;
67
+ },
68
+ true,
69
+ );
70
+ root.addEventListener("focusout", () => (seen.at = null), true);
71
+ focusByRoot.set(root, seen);
72
+ tracked = seen;
73
+ }
74
+ const at = tracked.at;
75
+ if (!at?.isConnected || at.getRootNode() !== root) return null;
76
+ return at === at.ownerDocument.body ? null : at;
77
+ }
78
+
79
+ /** Whether focus sits on nothing, or still inside `el`, so a closing panel may hand it back. */
80
+ export function focusFell(el: Element): boolean {
81
+ const inner = focusedIn(el);
82
+ if (inner) return el.contains(inner);
83
+ const root = el.getRootNode();
84
+ if (root.nodeType === DOCUMENT_NODE) return true;
85
+ // A panel already taken out of the page answers from the page's own focus.
86
+ if (root.nodeType !== SHADOW_ROOT_NODE) return !focusedIn(el.ownerDocument);
87
+ const host = outermostHost(root as ShadowRoot);
88
+ const page = focusedIn(host);
89
+ return !page || page === host;
90
+ }
91
+
51
92
  /** Whether `el` holds focus, from its own focus and blur events, which a sealed widget receives without asking the page. */
52
93
  export function trackFocus(el: Element): { has: () => boolean; stop: () => void } {
53
94
  let has = false;
@@ -70,7 +111,7 @@ export function focusWithoutTracking(
70
111
  ): boolean {
71
112
  if (!el) return false;
72
113
  untrack(() => el.focus({ preventScroll: options?.preventScroll ?? true }));
73
- return activeOf(el) === el;
114
+ return focusedIn(el) === el;
74
115
  }
75
116
 
76
117
  // Scopes in activation order: a later one sits above the earlier ones.
@@ -121,7 +162,7 @@ export function createFocusScope(options: FocusScopeOptions): FocusScope {
121
162
  trapped: boolean,
122
163
  ): { release: () => void; untrap: () => void } => {
123
164
  skipNext = false;
124
- const previous = pendingRestore ? pendingRestore.target : activeOf(container);
165
+ const previous = pendingRestore ? pendingRestore.target : focusedIn(container);
125
166
  pendingRestore = undefined;
126
167
  activeScopes.push(container);
127
168
 
@@ -164,7 +205,7 @@ export function createFocusScope(options: FocusScopeOptions): FocusScope {
164
205
  // Chromium fires focusout while removing the focused node; refocusing then strands keys on a detached node.
165
206
  const pressed = tab;
166
207
  queueMicrotask(() => {
167
- const current = activeOf(container);
208
+ const current = focusedIn(container);
168
209
  if (trapping && container.isConnected && !(current && container.contains(current))) {
169
210
  if (pressed) toCandidate(pressed.shift);
170
211
  else focusWithoutTracking(container);
@@ -197,7 +238,7 @@ export function createFocusScope(options: FocusScopeOptions): FocusScope {
197
238
  queueMicrotask(() => {
198
239
  if (pendingRestore !== pending) return;
199
240
  pendingRestore = undefined;
200
- const current = activeOf(container);
241
+ const current = focusedIn(container);
201
242
  const tookOver = activeScopes.some((scope) => current && scope.contains(current));
202
243
  if (!tookOver && previous instanceof HTMLElement && previous.isConnected) {
203
244
  focusWithoutTracking(previous);
@@ -1,9 +1,10 @@
1
1
  import { type Accessor, createSignal, onCleanup, untrack } from "solid-js";
2
2
  import type { Align, Side } from "../anchor-placement.js";
3
+ import type { Box } from "../anchor-placement.js";
3
4
  import { type AnchorLike, createAnchored } from "./anchored.js";
4
5
  import { createCollection } from "./collection.js";
5
6
  import { createDismiss } from "./dismiss.js";
6
- import { focusWithoutTracking } from "./focus-scope.js";
7
+ import { focusedIn, focusFell, focusWithoutTracking } from "./focus-scope.js";
7
8
  import { registerLayer } from "./layer-stack.js";
8
9
  import { effect } from "./solid.js";
9
10
 
@@ -45,6 +46,8 @@ export interface Menu {
45
46
  open: Accessor<boolean>;
46
47
  dir: Accessor<Dir>;
47
48
  content: Accessor<HTMLElement | undefined>;
49
+ /** Where the open panel sits, as it was placed. */
50
+ placed: () => Box | undefined;
48
51
  setContent: (el: HTMLElement | undefined) => void;
49
52
  trigger: Accessor<HTMLElement | undefined>;
50
53
  setTrigger: (el: HTMLElement | undefined) => void;
@@ -71,9 +74,6 @@ export interface MenuButton {
71
74
  const isDisabled = (el: Element) =>
72
75
  el.getAttribute("aria-disabled") === "true" || el.hasAttribute("data-disabled");
73
76
 
74
- const activeIn = (el: Element): Element | null =>
75
- (el.getRootNode() as Document | ShadowRoot).activeElement;
76
-
77
77
  function inside(point: Point, polygon: Point[]): boolean {
78
78
  let hit = false;
79
79
  for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
@@ -89,16 +89,18 @@ function inside(point: Point, polygon: Point[]): boolean {
89
89
  }
90
90
 
91
91
  /** The pointer's exit point fanned out to the submenu's whole panel. */
92
- function graceArea(exit: Point, panel: DOMRect, side: "left" | "right"): Point[] {
92
+ function graceArea(exit: Point, panel: Box, side: "left" | "right"): Point[] {
93
93
  const toRight = side === "right";
94
- const near = toRight ? panel.left : panel.right;
95
- const far = toRight ? panel.right : panel.left;
94
+ const right = panel.left + panel.width;
95
+ const bottom = panel.top + panel.height;
96
+ const near = toRight ? panel.left : right;
97
+ const far = toRight ? right : panel.left;
96
98
  return [
97
99
  { x: exit.x + (toRight ? -5 : 5), y: exit.y },
98
100
  { x: near, y: panel.top },
99
101
  { x: far, y: panel.top },
100
- { x: far, y: panel.bottom },
101
- { x: near, y: panel.bottom },
102
+ { x: far, y: bottom },
103
+ { x: near, y: bottom },
102
104
  ];
103
105
  }
104
106
 
@@ -161,7 +163,7 @@ export function createMenu(options: MenuOptions): Menu {
161
163
 
162
164
  const holdsFocus = (): boolean => {
163
165
  const el = content();
164
- const focused = el ? activeIn(el) : null;
166
+ const focused = el ? focusedIn(el) : null;
165
167
  if (el && focused && el.contains(focused)) return true;
166
168
  return [...children].some((child) => child.holdsFocus());
167
169
  };
@@ -203,6 +205,7 @@ export function createMenu(options: MenuOptions): Menu {
203
205
  open,
204
206
  dir,
205
207
  content,
208
+ placed: () => anchored.placed(),
206
209
  setContent,
207
210
  trigger,
208
211
  setTrigger,
@@ -258,7 +261,7 @@ export function createMenu(options: MenuOptions): Menu {
258
261
  });
259
262
  createDismiss({ layer, onDismiss: (reason) => hide(reason === "escape") });
260
263
 
261
- createAnchored({
264
+ const anchored = createAnchored({
262
265
  anchor: () => (options.anchor ? options.anchor(trigger()) : trigger()),
263
266
  floating: content,
264
267
  open,
@@ -278,7 +281,7 @@ export function createMenu(options: MenuOptions): Menu {
278
281
 
279
282
  function leaveItem(el: HTMLElement) {
280
283
  setActive(undefined);
281
- const focused = activeIn(el);
284
+ const focused = focusedIn(el);
282
285
  if (focused && el.contains(focused)) focusWithoutTracking(el);
283
286
  }
284
287
 
@@ -312,7 +315,7 @@ export function createMenu(options: MenuOptions): Menu {
312
315
  const entry = item && entryOf(item);
313
316
  if (!item || !entry) return;
314
317
  if (entry.disabled()) return leaveItem(el);
315
- if (untrack(active) !== item.dataset.key || activeIn(item) !== item) focusItem(item);
318
+ if (untrack(active) !== item.dataset.key || focusedIn(item) !== item) focusItem(item);
316
319
  const sub = entry.submenu;
317
320
  if (sub && !untrack(sub.open) && openTimer === undefined) {
318
321
  openTimer = setTimeout(() => {
@@ -329,15 +332,12 @@ export function createMenu(options: MenuOptions): Menu {
329
332
  cancelOpenTimer();
330
333
  const sub = entryOf(item)?.submenu;
331
334
  const panel = sub && untrack(sub.open) ? sub.content() : undefined;
332
- if (panel) {
335
+ const box = panel && sub?.placed();
336
+ if (panel && box) {
333
337
  clearGrace();
334
338
  const side = panel.getAttribute("data-side") === "left" ? "left" : "right";
335
339
  grace = {
336
- area: graceArea(
337
- { x: event.clientX, y: event.clientY },
338
- panel.getBoundingClientRect(),
339
- side,
340
- ),
340
+ area: graceArea({ x: event.clientX, y: event.clientY }, box, side),
341
341
  timer: setTimeout(clearGrace, POINTER_GRACE_MS),
342
342
  };
343
343
  return;
@@ -417,7 +417,7 @@ export function createMenu(options: MenuOptions): Menu {
417
417
  window.removeEventListener("pointerup", release);
418
418
  setActive(undefined);
419
419
  // An outside press on nothing focusable leaves focus nowhere; it goes back to the trigger.
420
- if (!focusLost(el) || (parent && !untrack(parent.open))) return;
420
+ if (!focusFell(el) || (parent && !untrack(parent.open))) return;
421
421
  focusWithoutTracking(trigger());
422
422
  };
423
423
  });
@@ -425,14 +425,6 @@ export function createMenu(options: MenuOptions): Menu {
425
425
  return menu;
426
426
  }
427
427
 
428
- function focusLost(el: HTMLElement): boolean {
429
- const doc = el.ownerDocument;
430
- const focused = doc.activeElement;
431
- if (!focused || focused === doc.body) return true;
432
- const inner = activeIn(el);
433
- return inner !== null && el.contains(inner);
434
- }
435
-
436
428
  /** The APG menu button: a mouse press toggles, a finger toggles on its click, Enter, Space and ArrowDown open on the first item, ArrowUp on the last. */
437
429
  export function createMenuButton(menu: Menu, disabled: Accessor<boolean>): MenuButton {
438
430
  let pointerType = "";
@@ -17,7 +17,7 @@ import { Portal } from "solid-js/web";
17
17
  import { LAYER_ROOT } from "../overlay-classes.js";
18
18
  import { createControllableSignal } from "./controllable.js";
19
19
  import { createDismiss } from "./dismiss.js";
20
- import { activeOf, createFocusScope, focusWithoutTracking } from "./focus-scope.js";
20
+ import { focusedIn, createFocusScope, focusWithoutTracking } from "./focus-scope.js";
21
21
  import { createHideOutside } from "./hide-outside.js";
22
22
  import { layerStack, registerLayer } from "./layer-stack.js";
23
23
  import { Polymorphic } from "./polymorphic.js";
@@ -362,7 +362,7 @@ export function ModalFrame(props: ModalFrameProps): JSX.Element {
362
362
  initialFocus: (container) => {
363
363
  if (!vetoed(local.onOpenAutoFocus, new Event("openautofocus", { cancelable: true })))
364
364
  return null;
365
- const active = activeOf(container);
365
+ const active = focusedIn(container);
366
366
  return active instanceof HTMLElement && container.contains(active) ? active : container;
367
367
  },
368
368
  });
@@ -1,4 +1,4 @@
1
- import { activeOf, focusWithoutTracking } from "./behavior/focus-scope.js";
1
+ import { focusedIn, focusWithoutTracking } from "./behavior/focus-scope.js";
2
2
  /** The one door to the clipboard. Call it from the click: browsers refuse a
3
3
  * copy more than a few seconds after it. Text still loading goes in as a
4
4
  * promise so a ClipboardItem write keeps the gesture (Safari). */
@@ -69,7 +69,7 @@ function copyViaSelection(text: string): boolean {
69
69
  focusWithoutTracking(area);
70
70
  area.select();
71
71
  area.setSelectionRange(0, text.length);
72
- if (activeOf(area) !== area) return false;
72
+ if (focusedIn(area) !== area) return false;
73
73
  return document.execCommand("copy");
74
74
  } catch {
75
75
  return false;
@@ -27,8 +27,7 @@ export const MORPH_MOTION =
27
27
  export const ANCHORED_MOTION =
28
28
  "data-[expanded]:animate-anchored-in data-[closed]:animate-morph-out";
29
29
 
30
- /* Children of a panel arrive staggered through the `gh-stagger` class
31
- * (globals.css): one door, no per-row index, mount-only. */
30
+ /** @deprecated Rows arrive with their panel; the class does nothing. Removed in 2.0.0. */
32
31
  export const STAGGER = "gh-stagger";
33
32
 
34
33
  /* An exit that holds its last frame: a closed surface still mounted (kept, or waiting
@@ -1,7 +1,6 @@
1
1
  import { createMemo, createSignal, For, Show } from "solid-js";
2
2
  import { focusWithoutTracking } from "../lib/behavior/focus-scope.js";
3
3
  import { MENU_ITEM, MENU_ITEM_RADIUS } from "../lib/menu-classes.js";
4
- import { STAGGER } from "../lib/motion-classes.js";
5
4
  import { PICKER_LIST } from "../lib/picker-classes.js";
6
5
  import { cn } from "../lib/utils.js";
7
6
  import { useEntityData } from "./entity-data.js";
@@ -193,7 +192,7 @@ export function AreaPicker(props: AreaPickerProps) {
193
192
  <SelectionScope
194
193
  marker="highlighted"
195
194
  radius={MENU_ITEM_RADIUS}
196
- class={cn("flex flex-col gap-0.5 p-1", STAGGER, PICKER_LIST)}
195
+ class={cn("flex flex-col gap-0.5 p-1", PICKER_LIST)}
197
196
  onMouseLeave={() => setHovered(null)}
198
197
  >
199
198
  <Show when={filtered().length === 0 && missing().length === 0}>
@@ -1,16 +1,9 @@
1
- // Decides drag vs scroll. Walks event.target ancestors; if any scrollable
2
- // ancestor can still scroll in the drag direction, yield to scroll.
3
- // Markers: data-sheet-no-drag (abort), data-sheet-scroll (force scrollable).
1
+ // Decides drag vs scroll. Walks event.target ancestors; if any can still scroll in the drag
2
+ // direction, yield to scroll. Marker: data-sheet-no-drag (abort).
4
3
 
5
4
  type Direction = "down" | "up";
6
5
 
7
- function isScrollableAxis(el: Element): boolean {
8
- if (el.hasAttribute("data-sheet-scroll")) return true;
9
- const overflowY = getComputedStyle(el).overflowY;
10
- if (overflowY !== "auto" && overflowY !== "scroll" && overflowY !== "overlay") return false;
11
- return el.scrollHeight > el.clientHeight;
12
- }
13
-
6
+ // Geometry alone: only a scroller holds a scrollTop, and a false "up" costs just the rubber band.
14
7
  function canScrollFurther(el: Element, dir: Direction): boolean {
15
8
  if (dir === "down") return el.scrollTop > 0;
16
9
  return el.scrollTop + el.clientHeight < el.scrollHeight - 1;
@@ -32,7 +25,7 @@ export function shouldDrag(target: Element | null, root: Element, dy: number, dx
32
25
  const dir: Direction = dy > 0 ? "down" : "up";
33
26
  let cur: Element | null = target;
34
27
  while (cur && cur !== root.parentElement) {
35
- if (isScrollableAxis(cur) && canScrollFurther(cur, dir)) return false;
28
+ if (canScrollFurther(cur, dir)) return false;
36
29
  if (cur === root) break;
37
30
  cur = cur.parentElement;
38
31
  }
@@ -259,7 +259,7 @@ const BottomSheetContent: ParentComponent<BottomSheetContentProps> = (props) =>
259
259
  createEffect(() => {
260
260
  const node = ctx.contentRef();
261
261
  if (!node) return;
262
- if (ctx.state() === "closed") return;
262
+ if (!present()) return;
263
263
  const handle = watchKeyboard(node);
264
264
  onCleanup(() => handle.destroy());
265
265
  });
@@ -323,13 +323,12 @@ const BottomSheetContent: ParentComponent<BottomSheetContentProps> = (props) =>
323
323
  "--bs-duration": `${TRANSITION_MS}ms`,
324
324
  "--bs-ease": EASE,
325
325
  "will-change": "transform",
326
- "touch-action": "pan-y",
326
+ "touch-action": "none",
327
327
  "-webkit-tap-highlight-color": "transparent",
328
328
  }}
329
329
  class={cn(
330
330
  "bs-content",
331
- `fixed inset-x-0 bottom-0 flex ${MODAL_MAX_H} flex-col ${SCROLL_CONTAIN} rounded-t-xl ${OVERLAY_SURFACE_OPAQUE} outline-none`,
332
- "after:absolute after:inset-x-0 after:top-full after:h-1/2 after:bg-inherit",
331
+ `fixed inset-x-0 bottom-0 flex ${MODAL_MAX_H} flex-col ${SCROLL_CONTAIN} overflow-hidden rounded-t-xl ${OVERLAY_SURFACE_OPAQUE} outline-none [--glass-edge:transparent]`,
333
332
  local.class,
334
333
  )}
335
334
  >
@@ -11,6 +11,7 @@ import type { SheetState } from "./state-machine.js";
11
11
  import { VelocityTracker } from "./velocity.js";
12
12
 
13
13
  const TRANSITION_CSS = `transform ${TRANSITION_MS}ms ${EASE}`;
14
+ const reducedMotion = () => matchMedia("(prefers-reduced-motion: reduce)").matches;
14
15
 
15
16
  interface DragHandle {
16
17
  destroy: () => void;
@@ -37,8 +38,6 @@ export function attachDrag(opts: DragOptions): DragHandle {
37
38
  let startX = 0;
38
39
  let pointerTarget: Element | null = null;
39
40
  let dy = 0;
40
- let raf = 0;
41
- let pendingDy: number | null = null;
42
41
  let movedPastDeadZone = false;
43
42
  let dragAborted = false;
44
43
  let height = 0;
@@ -50,21 +49,13 @@ export function attachDrag(opts: DragOptions): DragHandle {
50
49
  return s === "open" || s === "pressing";
51
50
  };
52
51
 
53
- const flushFrame = () => {
54
- raf = 0;
55
- if (pendingDy === null) return;
56
- const value = pendingDy;
57
- pendingDy = null;
52
+ // Written in the move itself: pointermove is already frame-aligned, and a guest's rAF costs a second trip through the realm.
53
+ const follow = (value: number) => {
58
54
  const applied = value < 0 ? dampen(-value) * -1 : value;
59
55
  shownDy = applied;
60
56
  el.style.transform = `translate3d(0, ${applied}px, 0)`;
61
57
  };
62
58
 
63
- const schedule = (newDy: number) => {
64
- pendingDy = newDy;
65
- if (raf === 0) raf = requestAnimationFrame(flushFrame);
66
- };
67
-
68
59
  const onPointerDown = (e: PointerEvent) => {
69
60
  if (e.button !== 0 && e.pointerType !== "touch") return;
70
61
  if (!isDraggableState()) return;
@@ -121,22 +112,17 @@ export function attachDrag(opts: DragOptions): DragHandle {
121
112
  }
122
113
  tracker.add(totalDy, e.timeStamp);
123
114
  dy = totalDy;
124
- schedule(dy);
115
+ follow(dy);
125
116
  };
126
117
 
127
118
  const cleanupDrag = () => {
128
- if (raf !== 0) {
129
- cancelAnimationFrame(raf);
130
- raf = 0;
131
- }
132
- pendingDy = null;
133
119
  pointerId = null;
134
120
  pointerTarget = null;
135
121
  dragAborted = false;
136
122
  };
137
123
 
138
124
  const settleClose = () => {
139
- el.style.transition = TRANSITION_CSS;
125
+ el.style.transition = reducedMotion() ? "none" : TRANSITION_CSS;
140
126
  el.style.animation = "none";
141
127
  el.style.transform = "translate3d(0, 100%, 0)";
142
128
  requestClose();
@@ -144,7 +130,8 @@ export function attachDrag(opts: DragOptions): DragHandle {
144
130
 
145
131
  const settleSnap = () => {
146
132
  setState("snapping");
147
- if (shownDy === 0) {
133
+ if (shownDy === 0 || reducedMotion()) {
134
+ shownDy = 0;
148
135
  el.style.transition = "";
149
136
  el.style.animation = "";
150
137
  el.style.transform = "";