@glasshome/ui 1.40.0 → 1.42.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 (105) hide show
  1. package/SPEC.md +25 -2
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +3 -3
  4. package/dist/lib/anchor-placement.d.ts +30 -0
  5. package/dist/lib/behavior/anchored.d.ts +12 -0
  6. package/dist/lib/behavior/collection.d.ts +24 -0
  7. package/dist/lib/behavior/controllable.d.ts +8 -0
  8. package/dist/lib/behavior/dismiss.d.ts +11 -0
  9. package/dist/lib/behavior/focus-scope.d.ts +18 -0
  10. package/dist/lib/behavior/hide-outside.d.ts +7 -0
  11. package/dist/lib/behavior/layer-stack.d.ts +33 -0
  12. package/dist/lib/behavior/modal-root.d.ts +66 -0
  13. package/dist/lib/behavior/polymorphic.d.ts +6 -0
  14. package/dist/lib/behavior/presence.d.ts +18 -0
  15. package/dist/lib/behavior/solid.d.ts +13 -0
  16. package/dist/lib/motion-classes.d.ts +5 -2
  17. package/dist/lib/overlay-classes.d.ts +4 -1
  18. package/dist/lib/page-cover.d.ts +8 -0
  19. package/dist/lib/shadow-layer.d.ts +8 -6
  20. package/dist/solid/alert-dialog.d.ts +13 -15
  21. package/dist/solid/bottom-sheet/bottom-sheet.d.ts +2 -6
  22. package/dist/solid/bottom-sheet/constants.d.ts +1 -1
  23. package/dist/solid/confirm-dialog.d.ts +22 -0
  24. package/dist/solid/dialog-parts.d.ts +78 -15
  25. package/dist/solid/dialog.d.ts +9 -15
  26. package/dist/solid/docked-panel.d.ts +1 -5
  27. package/dist/solid/icon-nodes.d.ts +13 -0
  28. package/dist/solid/index.d.ts +9 -5
  29. package/dist/solid/index.js +8211 -7974
  30. package/dist/solid/responsive-dialog.d.ts +5 -6
  31. package/dist/solid/sheet.d.ts +6 -13
  32. package/dist/solid/stale-veil.d.ts +7 -0
  33. package/dist/solid/tabs.d.ts +29 -8
  34. package/dist/solid/toggle-group.d.ts +30 -5
  35. package/dist/solid/tooltip.d.ts +71 -9
  36. package/dist/{utils-DXEj_oXa.js → utils-CxAii-e9.js} +606 -414
  37. package/package.json +4 -2
  38. package/src/index.ts +1 -0
  39. package/src/lib/anchor-placement.ts +68 -2
  40. package/src/lib/behavior/anchored.ts +88 -0
  41. package/src/lib/behavior/collection.ts +181 -0
  42. package/src/lib/behavior/controllable.ts +22 -0
  43. package/src/lib/behavior/dismiss.ts +145 -0
  44. package/src/lib/behavior/focus-scope.ts +202 -0
  45. package/src/lib/behavior/hide-outside.ts +85 -0
  46. package/src/lib/behavior/layer-stack.ts +125 -0
  47. package/src/lib/behavior/modal-root.tsx +446 -0
  48. package/src/lib/behavior/polymorphic.tsx +30 -0
  49. package/src/lib/behavior/presence.ts +89 -0
  50. package/src/lib/behavior/solid.ts +30 -0
  51. package/src/lib/clipboard.ts +3 -2
  52. package/src/lib/motion-classes.ts +27 -2
  53. package/src/lib/overlay-classes.ts +9 -4
  54. package/src/lib/page-cover.ts +47 -0
  55. package/src/lib/shadow-layer.ts +48 -66
  56. package/src/solid/alert-dialog.tsx +45 -81
  57. package/src/solid/alert.tsx +1 -1
  58. package/src/solid/area-picker.tsx +2 -1
  59. package/src/solid/badge.tsx +5 -5
  60. package/src/solid/bottom-sheet/bottom-sheet.tsx +72 -128
  61. package/src/solid/bottom-sheet/constants.ts +3 -1
  62. package/src/solid/bottom-sheet/drag-controller.ts +11 -0
  63. package/src/solid/breadcrumb.tsx +4 -4
  64. package/src/solid/button-group.tsx +4 -4
  65. package/src/solid/card.tsx +5 -4
  66. package/src/solid/confirm-dialog.tsx +62 -0
  67. package/src/solid/context-menu.tsx +12 -2
  68. package/src/solid/dialog-parts.tsx +181 -42
  69. package/src/solid/dialog.tsx +46 -74
  70. package/src/solid/dock-edit.tsx +5 -4
  71. package/src/solid/dock.tsx +3 -3
  72. package/src/solid/dropdown-menu.tsx +15 -7
  73. package/src/solid/entity-selector.tsx +2 -1
  74. package/src/solid/form.tsx +4 -3
  75. package/src/solid/hover-card.tsx +7 -2
  76. package/src/solid/icon-nodes.ts +71 -0
  77. package/src/solid/icon-picker.tsx +2 -1
  78. package/src/solid/icon.tsx +42 -39
  79. package/src/solid/image-picker.tsx +14 -13
  80. package/src/solid/index.ts +9 -2
  81. package/src/solid/input-group.tsx +5 -3
  82. package/src/solid/input-otp.tsx +2 -1
  83. package/src/solid/item.tsx +4 -4
  84. package/src/solid/logo.tsx +5 -4
  85. package/src/solid/picker-row.tsx +5 -4
  86. package/src/solid/picker-search.tsx +2 -1
  87. package/src/solid/popover.tsx +18 -10
  88. package/src/solid/responsive-dialog.tsx +17 -10
  89. package/src/solid/sheet.tsx +47 -79
  90. package/src/solid/spotlight.tsx +23 -11
  91. package/src/solid/stale-veil.tsx +20 -0
  92. package/src/solid/switch.tsx +8 -6
  93. package/src/solid/tabs.tsx +373 -53
  94. package/src/solid/toggle-group.tsx +305 -93
  95. package/src/solid/tooltip.tsx +285 -26
  96. package/src/styles/globals.css +6 -2
  97. package/src/styles/theme.css +10 -5
  98. package/dist/lib/when-animations-settle.d.ts +0 -4
  99. package/dist/solid/bottom-sheet/focus-trap.d.ts +0 -6
  100. package/dist/solid/bottom-sheet/scroll-lock.d.ts +0 -2
  101. package/dist/solid/bottom-sheet/sheet-motion.d.ts +0 -1
  102. package/src/lib/when-animations-settle.ts +0 -12
  103. package/src/solid/bottom-sheet/focus-trap.ts +0 -63
  104. package/src/solid/bottom-sheet/scroll-lock.ts +0 -66
  105. package/src/solid/bottom-sheet/sheet-motion.ts +0 -4
@@ -0,0 +1,71 @@
1
+ interface TrustedPolicy {
2
+ createHTML(input: string): string;
3
+ }
4
+ let policy: TrustedPolicy | null | undefined;
5
+
6
+ // Icon bodies come from the build or the host's own icon route; under a
7
+ // require-trusted-types-for CSP the assignment still needs a policy.
8
+ export function trusted(html: string): string {
9
+ if (policy === undefined) {
10
+ const tt = (
11
+ globalThis as {
12
+ trustedTypes?: { createPolicy(name: string, rules: TrustedPolicy): TrustedPolicy };
13
+ }
14
+ ).trustedTypes;
15
+ try {
16
+ policy = tt ? tt.createPolicy("glasshome-ui", { createHTML: (s) => s }) : null;
17
+ } catch {
18
+ policy = null;
19
+ }
20
+ }
21
+ return policy ? policy.createHTML(html) : html;
22
+ }
23
+
24
+ const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
25
+
26
+ function parseBody(body: string): Element {
27
+ const holder = document.createElementNS(SVG_NAMESPACE, "svg");
28
+ holder.innerHTML = trusted(body);
29
+ return holder;
30
+ }
31
+
32
+ export interface BodyParseCache {
33
+ /** Fresh copies of the nodes `parse` makes for `body`; the caller owns them. */
34
+ nodes(body: string): Node[];
35
+ }
36
+
37
+ /**
38
+ * Parses each distinct body once and hands every caller its own deep copy, so no two icons
39
+ * share a node. Holds at most `limit` bodies; past that the oldest is dropped and parsed again
40
+ * if asked for later. A `parse` that throws leaves nothing cached.
41
+ */
42
+ export function createBodyParseCache(
43
+ limit: number,
44
+ parse: (body: string) => Element,
45
+ ): BodyParseCache {
46
+ // A Map iterates in insertion order, so its first key is the oldest body.
47
+ const parsed = new Map<string, Element>();
48
+ return {
49
+ nodes(body) {
50
+ if (!body) return [];
51
+ let holder = parsed.get(body);
52
+ if (!holder) {
53
+ holder = parse(body);
54
+ if (parsed.size >= limit) {
55
+ const oldest = parsed.keys().next();
56
+ if (!oldest.done) parsed.delete(oldest.value);
57
+ }
58
+ parsed.set(body, holder);
59
+ }
60
+ return Array.from(holder.childNodes, (node) => node.cloneNode(true));
61
+ },
62
+ };
63
+ }
64
+
65
+ const MAX_PARSED_BODIES = 512;
66
+ const bodies = createBodyParseCache(MAX_PARSED_BODIES, parseBody);
67
+
68
+ /** The nodes of one icon body, parsed once per distinct body. Needs a DOM. */
69
+ export function iconNodes(body: string): Node[] {
70
+ return bodies.nodes(body);
71
+ }
@@ -1,4 +1,5 @@
1
1
  import { createMemo, createSignal, For, Show } from "solid-js";
2
+ import { focusWithoutTracking } from "../lib/behavior/focus-scope.js";
2
3
  import { STAGGER } from "../lib/motion-classes.js";
3
4
  import { PICKER_LIST } from "../lib/picker-classes.js";
4
5
  import { CHIP, ICON_PILL_TINT } from "../lib/pill-classes.js";
@@ -381,7 +382,7 @@ export function IconPicker(props: IconPickerProps) {
381
382
  e.preventDefault();
382
383
  // preventScroll: the panel is portalled at (0,0) until the popper places it,
383
384
  // so a plain focus() scrolls the page to the top.
384
- searchRef?.focus({ preventScroll: true });
385
+ focusWithoutTracking(searchRef);
385
386
  }}
386
387
  onInteractOutside={() => setOpen(false)}
387
388
  >
@@ -1,6 +1,16 @@
1
1
  import type { IconifyIcon } from "@iconify/types";
2
2
  import { iconToSVG } from "@iconify/utils";
3
- import { batch, createMemo, createSignal, type JSX, type Signal, splitProps } from "solid-js";
3
+ import {
4
+ batch,
5
+ createMemo,
6
+ createSignal,
7
+ type JSX,
8
+ mergeProps,
9
+ type Signal,
10
+ splitProps,
11
+ } from "solid-js";
12
+ import { isServer } from "solid-js/web";
13
+ import { iconNodes, trusted } from "./icon-nodes.js";
4
14
 
5
15
  export type IconData = IconifyIcon;
6
16
 
@@ -85,29 +95,6 @@ function lookup(name: string): IconData | undefined {
85
95
  return undefined;
86
96
  }
87
97
 
88
- interface TrustedPolicy {
89
- createHTML(input: string): string;
90
- }
91
- let policy: TrustedPolicy | null | undefined;
92
-
93
- // Icon bodies come from the build or the host's own icon route; under a
94
- // require-trusted-types-for CSP the assignment still needs a policy.
95
- function trusted(html: string): string {
96
- if (policy === undefined) {
97
- const tt = (
98
- globalThis as {
99
- trustedTypes?: { createPolicy(name: string, rules: TrustedPolicy): TrustedPolicy };
100
- }
101
- ).trustedTypes;
102
- try {
103
- policy = tt ? tt.createPolicy("glasshome-ui", { createHTML: (s) => s }) : null;
104
- } catch {
105
- policy = null;
106
- }
107
- }
108
- return policy ? policy.createHTML(html) : html;
109
- }
110
-
111
98
  export interface IconProps extends Omit<
112
99
  JSX.SvgSVGAttributes<SVGSVGElement>,
113
100
  "width" | "height" | "children"
@@ -134,24 +121,40 @@ export function Icon(props: IconProps) {
134
121
  return iconToSVG(data, size);
135
122
  });
136
123
  const body = createMemo(() => built().body);
137
- // A TrustedHTML is a fresh object per call, which the spread would write as a new innerHTML.
138
- const html = createMemo(() => trusted(body()));
139
124
  const named = () =>
140
125
  rest["aria-label"] != null || rest["aria-labelledby"] != null || rest.role != null;
141
- return (
142
- <svg
143
- xmlns="http://www.w3.org/2000/svg"
144
- data-slot="icon"
145
- data-icon={local.icon}
146
- aria-hidden={named() ? undefined : "true"}
147
- fill="currentColor"
148
- {...rest}
149
- viewBox={built().attributes.viewBox}
150
- width={built().attributes.width}
151
- height={built().attributes.height}
152
- innerHTML={html()}
153
- />
126
+ const shell = mergeProps(
127
+ {
128
+ xmlns: "http://www.w3.org/2000/svg",
129
+ "data-slot": "icon",
130
+ get "data-icon"() {
131
+ return local.icon;
132
+ },
133
+ get "aria-hidden"() {
134
+ return named() ? undefined : ("true" as const);
135
+ },
136
+ fill: "currentColor",
137
+ },
138
+ rest,
139
+ {
140
+ get viewBox() {
141
+ return built().attributes.viewBox;
142
+ },
143
+ get width() {
144
+ return built().attributes.width;
145
+ },
146
+ get height() {
147
+ return built().attributes.height;
148
+ },
149
+ },
154
150
  );
151
+ if (isServer) {
152
+ // A TrustedHTML is a fresh object per call, which the spread would write as a new innerHTML.
153
+ const html = createMemo(() => trusted(body()));
154
+ return <svg {...shell} innerHTML={html()} />;
155
+ }
156
+ const nodes = createMemo(() => iconNodes(body()));
157
+ return <svg {...shell}>{nodes()}</svg>;
155
158
  }
156
159
 
157
160
  function sizeOrDefault(size: { width: string | null; height: string | null }) {
@@ -8,6 +8,7 @@ import {
8
8
  Show,
9
9
  Switch,
10
10
  } from "solid-js";
11
+ import { focusWithoutTracking } from "../lib/behavior/focus-scope.js";
11
12
  import { FIELD_CHROME } from "../lib/input-classes.js";
12
13
  import { PICKER_LIST } from "../lib/picker-classes.js";
13
14
  import { SECTION_INNER_RADIUS } from "../lib/section-tokens.js";
@@ -18,10 +19,8 @@ import {
18
19
  AlertDialogAction,
19
20
  AlertDialogCancel,
20
21
  AlertDialogContent,
21
- AlertDialogDescription,
22
22
  AlertDialogFooter,
23
- AlertDialogHeader,
24
- AlertDialogTitle,
23
+ AlertDialogHead,
25
24
  } from "./alert-dialog.js";
26
25
  import { Badge } from "./badge.js";
27
26
  import { Button } from "./button.js";
@@ -180,8 +179,8 @@ function ImageGallery(
180
179
  const deleteDescription = createMemo(() => {
181
180
  const used = pendingDelete()?.usedBy ?? 0;
182
181
  return used === 0
183
- ? "This image isn't used by any widget."
184
- : `This image is used in ${used} widget${used === 1 ? "" : "s"}. Deleting it will leave those widgets without an image.`;
182
+ ? "No widget uses it."
183
+ : `${used} widget${used === 1 ? "" : "s"} will lose the image.`;
185
184
  });
186
185
 
187
186
  const chosenPreset = () => {
@@ -220,7 +219,7 @@ function ImageGallery(
220
219
  const fail = (cause: unknown) => setError(toMediaStoreError(cause));
221
220
 
222
221
  // A control that disables or leaves drops focus to the page, which a sealed dialog's trap moves outside, closing the gallery.
223
- const holdFocus = () => panel?.focus({ preventScroll: true });
222
+ const holdFocus = () => focusWithoutTracking(panel);
224
223
  const focused = () => (panel?.getRootNode() as Document | ShadowRoot | undefined)?.activeElement;
225
224
  const focusLost = () => {
226
225
  const at = focused();
@@ -315,7 +314,7 @@ function ImageGallery(
315
314
  // A key pressed as the gallery opens lands on the panel, never on a tile it would pick.
316
315
  onOpenAutoFocus={(event: Event) => {
317
316
  event.preventDefault();
318
- panel?.focus({ preventScroll: true });
317
+ focusWithoutTracking(panel);
319
318
  }}
320
319
  onInteractOutside={(event) => {
321
320
  // The delete confirmation takes focus; the gallery stays open to show the result.
@@ -355,7 +354,7 @@ function ImageGallery(
355
354
  const again = panel?.querySelector<HTMLElement>(
356
355
  '[data-slot="image-picker-retry"]',
357
356
  );
358
- if (focused() === panel) again?.focus({ preventScroll: true });
357
+ if (focused() === panel) focusWithoutTracking(again);
359
358
  }}
360
359
  >
361
360
  Try again
@@ -512,14 +511,16 @@ function ImageGallery(
512
511
  // The confirmation has no trigger to return to; the page would get focus and the gallery would close.
513
512
  event.preventDefault();
514
513
  if (!deleteConfirmed && deleteFrom instanceof HTMLElement && deleteFrom.isConnected) {
515
- deleteFrom.focus({ preventScroll: true });
514
+ focusWithoutTracking(deleteFrom);
516
515
  } else holdFocus();
517
516
  }}
518
517
  >
519
- <AlertDialogHeader>
520
- <AlertDialogTitle>Delete image?</AlertDialogTitle>
521
- <AlertDialogDescription>{deleteDescription()}</AlertDialogDescription>
522
- </AlertDialogHeader>
518
+ <AlertDialogHead
519
+ icon="lucide:image-off"
520
+ tone="var(--destructive)"
521
+ title="Delete image?"
522
+ line={deleteDescription()}
523
+ />
523
524
  <AlertDialogFooter>
524
525
  <AlertDialogCancel aria-label="Cancel">Cancel</AlertDialogCancel>
525
526
  <AlertDialogAction
@@ -8,7 +8,8 @@ export { SECTION_ROW_SURFACE } from "../lib/card-classes.js";
8
8
  export { copyImage, copyText } from "../lib/clipboard.js";
9
9
  export { createHold, HOLD_GRACE_MS, HOLD_MS, spendLongPress } from "../lib/hold.js";
10
10
  export type { Hold, HoldOptions, HoldPress } from "../lib/hold.js";
11
- export { RISE_MOTION, SETTLE_MOTION, TRAVEL_MOTION } from "../lib/motion-classes.js";
11
+ export { RISE_MOTION, SETTLE_MOTION, STALE_CONTENT, TRAVEL_MOTION } from "../lib/motion-classes.js";
12
+ export { COVERING_ATTR, coverPage } from "../lib/page-cover.js";
12
13
  export { OVERLAY_SURFACE } from "../lib/overlay-classes.js";
13
14
  // Section tokens re-exported from the Solid entry for convenience.
14
15
  export {
@@ -29,6 +30,7 @@ export {
29
30
  AlertDialogContent,
30
31
  AlertDialogDescription,
31
32
  AlertDialogFooter,
33
+ AlertDialogHead,
32
34
  AlertDialogHeader,
33
35
  AlertDialogTitle,
34
36
  AlertDialogTrigger,
@@ -148,11 +150,14 @@ export {
148
150
  DialogContent,
149
151
  DialogDescription,
150
152
  DialogFooter,
153
+ DialogHead,
151
154
  DialogHeader,
152
155
  DialogTitle,
153
156
  DialogTrigger,
154
157
  } from "./dialog.js";
155
- export type { ModalSize } from "./dialog-parts.js";
158
+ export { useDialogDormant } from "../lib/behavior/modal-root.js";
159
+ export { ConfirmDialog, type ConfirmDialogProps } from "./confirm-dialog.js";
160
+ export type { ModalHeadProps, ModalMedia, ModalSize } from "./dialog-parts.js";
156
161
  export type { DockIconButtonProps, DockItem, DockPlacement, DockProps } from "./dock.js";
157
162
  export { Dock } from "./dock.js";
158
163
  export {
@@ -315,6 +320,7 @@ export {
315
320
  ResponsiveDialogContent,
316
321
  ResponsiveDialogDescription,
317
322
  ResponsiveDialogFooter,
323
+ ResponsiveDialogHead,
318
324
  ResponsiveDialogHeader,
319
325
  ResponsiveDialogTitle,
320
326
  ResponsiveDialogTrigger,
@@ -381,6 +387,7 @@ export { FaceToggle, FaceToggleGroup } from "./face-toggle.js";
381
387
  export { GlyphTile, GlyphTileGroup } from "./glyph-tile.js";
382
388
  export { Spinner } from "./spinner.js";
383
389
  export { Spotlight } from "./spotlight.js";
390
+ export { StaleVeil } from "./stale-veil.js";
384
391
  export { StepIndicator } from "./step-indicator.js";
385
392
  export { SwatchPicker } from "./swatch-picker.js";
386
393
  export { Switch } from "./switch.js";
@@ -1,5 +1,6 @@
1
1
  import { cva, type VariantProps } from "cva";
2
2
  import { type Component, type ComponentProps, splitProps } from "solid-js";
3
+ import { focusWithoutTracking } from "../lib/behavior/focus-scope.js";
3
4
  import { CONTROL_H, FIELD_TEXT, INPUT_SURFACE } from "../lib/input-classes.js";
4
5
  import { cn } from "../lib/utils.js";
5
6
  import { Button } from "./button.js";
@@ -63,9 +64,10 @@ const InputGroupAddon: Component<
63
64
  if ((e.target as HTMLElement).closest("button")) {
64
65
  return;
65
66
  }
66
- (e.currentTarget as HTMLElement).parentElement
67
- ?.querySelector<HTMLInputElement>("input")
68
- ?.focus();
67
+ focusWithoutTracking(
68
+ (e.currentTarget as HTMLElement).parentElement?.querySelector<HTMLInputElement>("input"),
69
+ { preventScroll: false },
70
+ );
69
71
  }}
70
72
  {...rest}
71
73
  />
@@ -8,6 +8,7 @@ import {
8
8
  splitProps,
9
9
  useContext,
10
10
  } from "solid-js";
11
+ import { focusWithoutTracking } from "../lib/behavior/focus-scope.js";
11
12
  import { CONTROL_H, FOCUS_RING, INPUT_SURFACE } from "../lib/input-classes.js";
12
13
  import { cn } from "../lib/utils.js";
13
14
  import { Icon } from "./icon.js";
@@ -96,7 +97,7 @@ const InputOTP: ParentComponent<
96
97
  <div
97
98
  data-slot="input-otp"
98
99
  class={cn("flex items-center gap-2 has-[:disabled]:opacity-50", local.containerClass)}
99
- onClick={() => inputRef.focus()}
100
+ onClick={() => focusWithoutTracking(inputRef, { preventScroll: false })}
100
101
  {...rest}
101
102
  >
102
103
  <input
@@ -1,6 +1,6 @@
1
1
  import { cva, type VariantProps } from "cva";
2
2
  import { type Component, type ComponentProps, splitProps, type ValidComponent } from "solid-js";
3
- import { Dynamic } from "solid-js/web";
3
+ import { Polymorphic } from "../lib/behavior/polymorphic.js";
4
4
  import { ICON_PILL } from "../lib/pill-classes.js";
5
5
  import { cn } from "../lib/utils.js";
6
6
  import { Separator } from "./separator.js";
@@ -54,10 +54,10 @@ const Item: Component<
54
54
  const [local, rest] = splitProps(props, ["class", "variant", "size", "as"] as const);
55
55
  const variant = () => local.variant ?? "default";
56
56
  const size = () => local.size ?? "default";
57
- const Comp = () => local.as || "div";
58
57
  return (
59
- <Dynamic
60
- component={Comp()}
58
+ <Polymorphic
59
+ defaultAs="div"
60
+ as={local.as}
61
61
  data-slot="item"
62
62
  data-variant={variant()}
63
63
  data-size={size()}
@@ -1,5 +1,5 @@
1
1
  import { type Component, type ComponentProps, type JSX, splitProps } from "solid-js";
2
- import { Dynamic } from "solid-js/web";
2
+ import { Polymorphic } from "../lib/behavior/polymorphic.js";
3
3
  import {
4
4
  LOGO_DEFAULT_SIZE,
5
5
  LOGO_DEFAULT_SRC,
@@ -48,8 +48,9 @@ const Logo: Component<LogoProps> = (props) => {
48
48
  const size = () => local.size ?? LOGO_DEFAULT_SIZE;
49
49
  const s = () => LOGO_SIZES[size()];
50
50
  return (
51
- <Dynamic
52
- component={local.href ? "a" : "div"}
51
+ <Polymorphic
52
+ defaultAs="div"
53
+ as={local.href ? "a" : undefined}
53
54
  data-slot="logo"
54
55
  class={cn(LOGO_ROOT_CLASS, s().gap, local.class)}
55
56
  href={local.href}
@@ -72,7 +73,7 @@ const Logo: Component<LogoProps> = (props) => {
72
73
  </span>
73
74
  )}
74
75
  </span>
75
- </Dynamic>
76
+ </Polymorphic>
76
77
  );
77
78
  };
78
79
 
@@ -6,7 +6,7 @@ import {
6
6
  splitProps,
7
7
  type ValidComponent,
8
8
  } from "solid-js";
9
- import { Dynamic } from "solid-js/web";
9
+ import { Polymorphic } from "../lib/behavior/polymorphic.js";
10
10
  import { MENU_ITEM } from "../lib/menu-classes.js";
11
11
  import { ICON_PILL, ICON_PILL_TINT } from "../lib/pill-classes.js";
12
12
  import { cn } from "../lib/utils.js";
@@ -46,8 +46,9 @@ export function PickerRow(props: PickerRowProps) {
46
46
  const subtitle = children(() => local.subtitle);
47
47
  const meta = children(() => local.meta);
48
48
  return (
49
- <Dynamic
50
- component={local.as ?? "div"}
49
+ <Polymorphic
50
+ defaultAs="div"
51
+ as={local.as}
51
52
  class={cn(
52
53
  MENU_ITEM,
53
54
  "w-full cursor-pointer gap-3 py-0 text-left",
@@ -108,6 +109,6 @@ export function PickerRow(props: PickerRowProps) {
108
109
  />
109
110
  </div>
110
111
  </Show>
111
- </Dynamic>
112
+ </Polymorphic>
112
113
  );
113
114
  }
@@ -1,4 +1,5 @@
1
1
  import { type JSX, Show, splitProps } from "solid-js";
2
+ import { focusWithoutTracking } from "../lib/behavior/focus-scope.js";
2
3
  import { CONTROL_H, FIELD_TEXT } from "../lib/input-classes.js";
3
4
  import { CONTROL_H_TOUCH } from "../lib/picker-classes.js";
4
5
  import { cn } from "../lib/utils.js";
@@ -76,7 +77,7 @@ export function PickerSearch(props: PickerSearchProps) {
76
77
  class="text-muted-foreground hover:text-foreground shrink-0 rounded-sm p-1 transition-colors"
77
78
  onClick={() => {
78
79
  local.onValueChange?.("");
79
- input?.focus();
80
+ focusWithoutTracking(input, { preventScroll: false });
80
81
  }}
81
82
  >
82
83
  <Icon icon="mdi:close-circle" width={16} height={16} />
@@ -9,7 +9,12 @@ import {
9
9
  useContext,
10
10
  } from "solid-js";
11
11
  import { INPUT_SURFACE } from "../lib/input-classes.js";
12
- import { inShadowRoot, shadowLayer } from "../lib/shadow-layer.js";
12
+ import {
13
+ createCoveredRoot,
14
+ inShadowRoot,
15
+ ReportCovered,
16
+ shadowLayer,
17
+ } from "../lib/shadow-layer.js";
13
18
  import { nestedLayerAttrs, Z_CLASS } from "../lib/layers.js";
14
19
  import { FIELD_MOTION, MORPH_MOTION, STAGGER } from "../lib/motion-classes.js";
15
20
  import { anchorToTriggerTop, FLOATING_PANEL } from "../lib/overlay-classes.js";
@@ -39,16 +44,19 @@ const PopoverRoot: Component<PopoverProps> = (props) => {
39
44
  const surface = () => local.surface ?? "overlay";
40
45
  // Modal in a shadow root, Kobalte would aria-hide the realm's host, popover included.
41
46
  const inShadow = inShadowRoot(usePortalMount());
47
+ const cover = createCoveredRoot();
42
48
  return (
43
49
  <PopoverSurfaceContext.Provider value={surface}>
44
- <PopoverPrimitive
45
- gutter={local.gutter ?? 0}
46
- getAnchorRect={local.getAnchorRect ?? anchorToTriggerTop}
47
- flip={false}
48
- overlap
49
- {...rest}
50
- modal={inShadow ? false : rest.modal}
51
- />
50
+ <ReportCovered.Provider value={cover.report}>
51
+ <PopoverPrimitive
52
+ gutter={local.gutter ?? 0}
53
+ getAnchorRect={local.getAnchorRect ?? anchorToTriggerTop}
54
+ flip={false}
55
+ overlap
56
+ {...rest}
57
+ modal={inShadow || cover.covered() ? false : rest.modal}
58
+ />
59
+ </ReportCovered.Provider>
52
60
  </PopoverSurfaceContext.Provider>
53
61
  );
54
62
  };
@@ -115,7 +123,7 @@ const PopoverContent: Component<PopoverContentProps> = (props) => {
115
123
  onCloseAutoFocus={layer.onCloseAutoFocus}
116
124
  data-slot="popover-content"
117
125
  data-surface={surface()}
118
- {...nestedLayerAttrs(popover.isModal())}
126
+ {...nestedLayerAttrs(popover.isModal() || layer.covered())}
119
127
  class={cn(surface() === "field" ? FIELD_PANEL : OVERLAY_PANEL, local.class)}
120
128
  {...rest}
121
129
  />
@@ -3,7 +3,6 @@ import {
3
3
  type Component,
4
4
  type ComponentProps,
5
5
  createContext,
6
- createSignal,
7
6
  type JSX,
8
7
  type ParentComponent,
9
8
  Show,
@@ -12,6 +11,7 @@ import {
12
11
  type ValidComponent,
13
12
  } from "solid-js";
14
13
  import type { buttonVariants } from "../lib/button-variants.js";
14
+ import { createControllableSignal } from "../lib/behavior/controllable.js";
15
15
  import { createIsMobile } from "../lib/use-is-mobile.js";
16
16
  import {
17
17
  BottomSheet,
@@ -25,7 +25,7 @@ import {
25
25
  } from "./bottom-sheet/index.js";
26
26
  import { Button } from "./button.js";
27
27
  import { Dialog, DialogContent, DialogDescription, DialogTitle, DialogTrigger } from "./dialog.js";
28
- import { createModalParts, type ModalSize } from "./dialog-parts.js";
28
+ import { createModalHead, createModalParts, type ModalSize } from "./dialog-parts.js";
29
29
 
30
30
  interface ResponsiveDialogContextValue {
31
31
  open: () => boolean;
@@ -46,27 +46,27 @@ interface ResponsiveDialogProps {
46
46
  open?: boolean;
47
47
  onOpenChange?: (open: boolean) => void;
48
48
  defaultOpen?: boolean;
49
+ /** The centred dialog stays mounted and dormant between opens; the bottom sheet ignores it. */
50
+ keep?: boolean;
49
51
  }
50
52
 
51
53
  /** Centred kobalte dialog from `sm` up, drag-to-dismiss bottom sheet below it.
52
54
  * Both branches render the same parts, so a call site never branches. */
53
55
  const ResponsiveDialog: ParentComponent<ResponsiveDialogProps> = (props) => {
54
- const [uncontrolledOpen, setUncontrolledOpen] = createSignal(props.defaultOpen ?? false);
56
+ const [open, setOpen] = createControllableSignal<boolean>({
57
+ value: () => props.open,
58
+ defaultValue: () => props.defaultOpen ?? false,
59
+ onChange: (next) => props.onOpenChange?.(next),
60
+ });
55
61
  const mobile = createIsMobile();
56
62
  const isMobile = () => mobile() === true;
57
63
 
58
- const open = () => (props.open !== undefined ? props.open === true : uncontrolledOpen());
59
- const setOpen = (next: boolean) => {
60
- if (props.open === undefined) setUncontrolledOpen(next);
61
- props.onOpenChange?.(next);
62
- };
63
-
64
64
  return (
65
65
  <ResponsiveDialogContext.Provider value={{ open, setOpen, isMobile }}>
66
66
  <Show
67
67
  when={isMobile()}
68
68
  fallback={
69
- <Dialog open={open()} onOpenChange={setOpen}>
69
+ <Dialog open={open()} onOpenChange={setOpen} keep={props.keep}>
70
70
  {props.children}
71
71
  </Dialog>
72
72
  }
@@ -153,6 +153,12 @@ const ResponsiveDialogDescription: Component<ComponentProps<"p">> = (props) => {
153
153
  );
154
154
  };
155
155
 
156
+ const ResponsiveDialogHead = createModalHead(
157
+ ResponsiveDialogHeader,
158
+ ResponsiveDialogTitle,
159
+ ResponsiveDialogDescription,
160
+ );
161
+
156
162
  /** Defaults to the footer's outline button; an icon-only close passes `ghost`
157
163
  * so the glyph is not boxed. */
158
164
  const ResponsiveDialogClose: ParentComponent<
@@ -182,6 +188,7 @@ export {
182
188
  ResponsiveDialogContent,
183
189
  ResponsiveDialogDescription,
184
190
  ResponsiveDialogFooter,
191
+ ResponsiveDialogHead,
185
192
  ResponsiveDialogHeader,
186
193
  ResponsiveDialogTitle,
187
194
  ResponsiveDialogTrigger,