@zonsh/ui 0.2.0 → 0.5.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 (200) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +19 -13
  3. package/dist/components/accordion.js +1 -1
  4. package/dist/components/alert-dialog.js +1 -1
  5. package/dist/components/ascii-field.d.ts +1 -1
  6. package/dist/components/ascii-field.js +2 -1
  7. package/dist/components/bottom-nav.d.ts +86 -0
  8. package/dist/components/bottom-nav.js +175 -0
  9. package/dist/components/breadcrumb.d.ts +9 -0
  10. package/dist/components/breadcrumb.js +6 -1
  11. package/dist/components/button-group.d.ts +1 -1
  12. package/dist/components/button-group.js +2 -2
  13. package/dist/components/button.js +1 -1
  14. package/dist/components/calendar.d.ts +1 -1
  15. package/dist/components/calendar.js +18 -3
  16. package/dist/components/carousel.d.ts +22 -3
  17. package/dist/components/carousel.js +25 -7
  18. package/dist/components/chart.d.ts +20 -0
  19. package/dist/components/chart.js +52 -3
  20. package/dist/components/code-block.d.ts +20 -10
  21. package/dist/components/code-block.js +54 -12
  22. package/dist/components/collapsible.js +3 -3
  23. package/dist/components/color-picker.d.ts +30 -8
  24. package/dist/components/color-picker.js +48 -27
  25. package/dist/components/combobox.d.ts +21 -3
  26. package/dist/components/combobox.js +79 -7
  27. package/dist/components/command.d.ts +23 -3
  28. package/dist/components/command.js +63 -18
  29. package/dist/components/conversation.d.ts +10 -1
  30. package/dist/components/conversation.js +24 -7
  31. package/dist/components/copy-button.d.ts +15 -6
  32. package/dist/components/copy-button.js +27 -10
  33. package/dist/components/data-table.d.ts +66 -6
  34. package/dist/components/data-table.js +376 -23
  35. package/dist/components/date-picker.d.ts +73 -4
  36. package/dist/components/date-picker.js +138 -7
  37. package/dist/components/dialog.d.ts +10 -1
  38. package/dist/components/dialog.js +6 -3
  39. package/dist/components/drawer.d.ts +10 -1
  40. package/dist/components/drawer.js +6 -3
  41. package/dist/components/feature-list.js +2 -2
  42. package/dist/components/field.d.ts +27 -8
  43. package/dist/components/field.js +49 -4
  44. package/dist/components/file-drop.d.ts +26 -4
  45. package/dist/components/file-drop.js +125 -64
  46. package/dist/components/filter-bar.d.ts +50 -3
  47. package/dist/components/filter-bar.js +71 -33
  48. package/dist/components/form.d.ts +4 -2
  49. package/dist/components/form.js +24 -2
  50. package/dist/components/graph.d.ts +41 -0
  51. package/dist/components/graph.js +106 -50
  52. package/dist/components/illustration.js +51 -4
  53. package/dist/components/input-group.d.ts +18 -7
  54. package/dist/components/input-group.js +41 -19
  55. package/dist/components/input.d.ts +2 -2
  56. package/dist/components/input.js +3 -3
  57. package/dist/components/kbd.d.ts +17 -0
  58. package/dist/components/kbd.js +8 -1
  59. package/dist/components/layout.d.ts +2 -1
  60. package/dist/components/layout.js +55 -11
  61. package/dist/components/lightbox.d.ts +100 -0
  62. package/dist/components/lightbox.js +457 -0
  63. package/dist/components/locale.d.ts +44 -0
  64. package/dist/components/locale.js +37 -0
  65. package/dist/components/logo.js +1 -1
  66. package/dist/components/menu.js +3 -1
  67. package/dist/components/menubar.js +60 -13
  68. package/dist/components/message.d.ts +3 -3
  69. package/dist/components/message.js +12 -8
  70. package/dist/components/meter.js +3 -1
  71. package/dist/components/money-input.d.ts +80 -0
  72. package/dist/components/money-input.js +253 -0
  73. package/dist/components/navigation-menu.js +4 -2
  74. package/dist/components/number-field.d.ts +21 -2
  75. package/dist/components/number-field.js +53 -28
  76. package/dist/components/otp-field.d.ts +14 -1
  77. package/dist/components/otp-field.js +10 -2
  78. package/dist/components/pagination.d.ts +13 -7
  79. package/dist/components/pagination.js +18 -7
  80. package/dist/components/pdf-viewer.d.ts +67 -2
  81. package/dist/components/pdf-viewer.js +88 -21
  82. package/dist/components/phone-input.d.ts +79 -0
  83. package/dist/components/phone-input.js +282 -0
  84. package/dist/components/popover.js +1 -1
  85. package/dist/components/progress.js +3 -1
  86. package/dist/components/prompt-input.d.ts +34 -9
  87. package/dist/components/prompt-input.js +37 -17
  88. package/dist/components/radio-group.js +7 -2
  89. package/dist/components/rating.d.ts +73 -0
  90. package/dist/components/rating.js +124 -0
  91. package/dist/components/reasoning.d.ts +16 -1
  92. package/dist/components/reasoning.js +10 -7
  93. package/dist/components/resizable.d.ts +10 -1
  94. package/dist/components/resizable.js +4 -1
  95. package/dist/components/response.d.ts +17 -5
  96. package/dist/components/response.js +58 -18
  97. package/dist/components/scroll-area.d.ts +1 -1
  98. package/dist/components/select.js +14 -3
  99. package/dist/components/separator.js +1 -1
  100. package/dist/components/sidebar.d.ts +20 -4
  101. package/dist/components/sidebar.js +70 -35
  102. package/dist/components/site-header.d.ts +46 -12
  103. package/dist/components/site-header.js +78 -19
  104. package/dist/components/skeleton.d.ts +1 -1
  105. package/dist/components/skeleton.js +1 -1
  106. package/dist/components/slider.js +3 -1
  107. package/dist/components/sortable.d.ts +178 -0
  108. package/dist/components/sortable.js +1282 -0
  109. package/dist/components/sources.d.ts +17 -2
  110. package/dist/components/sources.js +11 -4
  111. package/dist/components/spinner.d.ts +13 -1
  112. package/dist/components/spinner.js +5 -2
  113. package/dist/components/stat.d.ts +91 -0
  114. package/dist/components/stat.js +141 -0
  115. package/dist/components/stepper.d.ts +71 -0
  116. package/dist/components/stepper.js +101 -0
  117. package/dist/components/switch.d.ts +2 -2
  118. package/dist/components/switch.js +2 -2
  119. package/dist/components/table.d.ts +13 -3
  120. package/dist/components/table.js +231 -41
  121. package/dist/components/tabs.js +8 -4
  122. package/dist/components/tags-input.d.ts +18 -2
  123. package/dist/components/tags-input.js +66 -34
  124. package/dist/components/theme.d.ts +16 -2
  125. package/dist/components/theme.js +34 -8
  126. package/dist/components/time-field.d.ts +24 -4
  127. package/dist/components/time-field.js +32 -9
  128. package/dist/components/timeline.d.ts +18 -2
  129. package/dist/components/timeline.js +13 -4
  130. package/dist/components/tippy.d.ts +48 -0
  131. package/dist/components/tippy.js +648 -0
  132. package/dist/components/toast.d.ts +18 -2
  133. package/dist/components/toast.js +12 -3
  134. package/dist/components/toggle-group.js +1 -0
  135. package/dist/components/tool-call.d.ts +19 -8
  136. package/dist/components/tool-call.js +23 -7
  137. package/dist/components/toolbar.d.ts +1 -1
  138. package/dist/components/toolbar.js +10 -2
  139. package/dist/components/tooltip.d.ts +4 -2
  140. package/dist/components/tooltip.js +10 -4
  141. package/dist/components/tour.d.ts +127 -0
  142. package/dist/components/tour.js +673 -0
  143. package/dist/components/tree.js +45 -9
  144. package/dist/components/video-player.d.ts +10 -2
  145. package/dist/components/video-player.js +134 -38
  146. package/dist/illustration.d.ts +2 -0
  147. package/dist/illustration.js +7 -0
  148. package/dist/index.d.ts +11 -3
  149. package/dist/index.js +11 -3
  150. package/dist/lib/code-highlight.d.ts +3 -16
  151. package/dist/lib/code-highlight.js +160 -10
  152. package/dist/lib/code-theme.js +3 -3
  153. package/dist/lib/digit-roll.js +8 -8
  154. package/dist/lib/field-errors.d.ts +28 -0
  155. package/dist/lib/field-errors.js +24 -0
  156. package/dist/lib/field-value.d.ts +13 -0
  157. package/dist/lib/field-value.js +44 -0
  158. package/dist/lib/glide.d.ts +5 -4
  159. package/dist/lib/glide.js +5 -4
  160. package/dist/lib/graph-layout.js +11 -2
  161. package/dist/lib/money.d.ts +73 -0
  162. package/dist/lib/money.js +343 -0
  163. package/dist/lib/phone-countries.d.ts +1 -0
  164. package/dist/lib/phone-countries.js +281 -0
  165. package/dist/lib/phone.d.ts +90 -0
  166. package/dist/lib/phone.js +286 -0
  167. package/dist/lib/platform.d.ts +8 -3
  168. package/dist/lib/platform.js +13 -6
  169. package/dist/lib/row-index.d.ts +15 -0
  170. package/dist/lib/row-index.js +136 -0
  171. package/dist/lib/table-fit.d.ts +3 -2
  172. package/dist/lib/table-fit.js +52 -23
  173. package/dist/lib/theme-script.d.ts +15 -2
  174. package/dist/lib/theme-script.js +23 -3
  175. package/dist/lib/tippy/pixels.d.ts +47 -0
  176. package/dist/lib/tippy/pixels.js +187 -0
  177. package/dist/lib/tippy/sprite.d.ts +86 -0
  178. package/dist/lib/tippy/sprite.js +753 -0
  179. package/dist/messages/de.d.ts +12 -0
  180. package/dist/messages/de.js +326 -0
  181. package/dist/styles/expressive.css +60 -26
  182. package/dist/styles/index.css +11 -2
  183. package/dist/styles/material.css +47 -23
  184. package/dist/styles/parts/ai.css +4 -2
  185. package/dist/styles/parts/controls.css +85 -32
  186. package/dist/styles/parts/data.css +33 -5
  187. package/dist/styles/parts/feedback.css +110 -13
  188. package/dist/styles/parts/foundations.css +1 -1
  189. package/dist/styles/parts/navigation.css +230 -5
  190. package/dist/styles/parts/overlays.css +98 -11
  191. package/dist/styles/parts/pdf.css +13 -7
  192. package/dist/styles/tokens.css +28 -4
  193. package/dist/vite.d.ts +0 -50
  194. package/dist/vite.js +0 -100
  195. package/package.json +28 -33
  196. package/dist/components/code-highlight.d.ts +0 -13
  197. package/dist/components/code-highlight.js +0 -107
  198. package/dist/components/whiteboard.d.ts +0 -80
  199. package/dist/components/whiteboard.js +0 -389
  200. package/dist/styles/parts/whiteboard.css +0 -855
@@ -7,12 +7,21 @@ import { cn } from "../lib/cn.js";
7
7
  import { modPressed } from "../lib/platform.js";
8
8
  import { Button } from "./button.js";
9
9
  import { Drawer, DrawerContent, DrawerTitle } from "./drawer.js";
10
+ import { useMessages } from "./locale.js";
10
11
  import { ScrollArea } from "./scroll-area.js";
11
12
  import { Separator } from "./separator.js";
12
13
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./tooltip.js";
14
+ const defaultMessages = { navigation: "Navigation", toggle: "Toggle sidebar" };
13
15
  const SidebarContext = React.createContext(null);
14
16
  /** The sidebar's density: `default` 38px rows, `sm` 30px rows (`Sidebar size`). */
15
17
  const SidebarSizeContext = React.createContext("default");
18
+ /** The edge the sidebar is on (`Sidebar side`): its icon rail's tooltips open towards the page. */
19
+ const SidebarSideContext = React.createContext("left");
20
+ /**
21
+ * The last desktop toggle came from the keyboard shortcut: the panel then opens and closes at
22
+ * once, as a shortcut someone presses many times a day should; a click on a trigger animates.
23
+ */
24
+ const SidebarInstantContext = React.createContext(false);
16
25
  /** Where a `Sidebar` is rendered: the desktop panel or the mobile sheet. */
17
26
  const SidebarSurfaceContext = React.createContext("panel");
18
27
  /**
@@ -91,12 +100,22 @@ export function SidebarProvider({ defaultOpen = true, open: openProp, onOpenChan
91
100
  if (stored !== undefined)
92
101
  setOpenState(stored);
93
102
  }, [openProp, storageKey]);
94
- const toggleSidebar = React.useCallback(() => {
103
+ const toggle = React.useCallback(() => {
95
104
  if (isMobile)
96
105
  setOpenMobile((value) => !value);
97
106
  else
98
107
  setOpen(!openRef.current);
99
108
  }, [isMobile, setOpen]);
109
+ // Only the shortcut toggles instantly; the trigger and setOpen animate.
110
+ const [instant, setInstant] = React.useState(false);
111
+ const toggleSidebar = React.useCallback(() => {
112
+ setInstant(false);
113
+ toggle();
114
+ }, [toggle]);
115
+ const setOpenAnimated = React.useCallback((value) => {
116
+ setInstant(false);
117
+ setOpen(value);
118
+ }, [setOpen]);
100
119
  // Leaving the mobile layout closes the sheet: narrowing the window again must not reopen it.
101
120
  if (!isMobile && openMobile)
102
121
  setOpenMobile(false);
@@ -117,26 +136,27 @@ export function SidebarProvider({ defaultOpen = true, open: openProp, onOpenChan
117
136
  if (event.target instanceof HTMLElement && event.target.isContentEditable)
118
137
  return;
119
138
  event.preventDefault();
120
- toggleSidebar();
139
+ setInstant(true);
140
+ toggle();
121
141
  };
122
142
  window.addEventListener("keydown", onKeyDown);
123
143
  return () => window.removeEventListener("keydown", onKeyDown);
124
- }, [keyboardShortcut, collapsible, toggleSidebar]);
144
+ }, [keyboardShortcut, collapsible, toggle]);
125
145
  const value = React.useMemo(() => ({
126
146
  state: open || collapsible === "none" ? "expanded" : "collapsed",
127
147
  open,
128
- setOpen,
148
+ setOpen: setOpenAnimated,
129
149
  openMobile,
130
150
  setOpenMobile,
131
151
  isMobile,
132
152
  toggleSidebar,
133
153
  collapsible,
134
- }), [open, setOpen, openMobile, isMobile, toggleSidebar, collapsible]);
135
- return (_jsx(SidebarContext.Provider, { value: value, children: _jsx(TooltipProvider, { children: _jsx("div", { "data-slot": "sidebar-wrapper", className: cn("flex min-h-svh w-full", className), style: {
136
- "--sidebar-width": "16rem",
137
- "--sidebar-width-icon": "calc(var(--control-h) + 25px)",
138
- ...style,
139
- }, ...props, children: children }) }) }));
154
+ }), [open, setOpenAnimated, openMobile, isMobile, toggleSidebar, collapsible]);
155
+ return (_jsx(SidebarContext.Provider, { value: value, children: _jsx(SidebarInstantContext.Provider, { value: instant, children: _jsx(TooltipProvider, { children: _jsx("div", { "data-slot": "sidebar-wrapper", className: cn("flex min-h-svh w-full", className), style: {
156
+ "--sidebar-width": "16rem",
157
+ "--sidebar-width-icon": "calc(var(--control-h) + 25px)",
158
+ ...style,
159
+ }, ...props, children: children }) }) }) }));
140
160
  }
141
161
  /* ── The current row glides ──────────────────────────────────────────────── */
142
162
  const ROW = '[data-slot="sidebar-item"]';
@@ -202,15 +222,17 @@ function CurrentGlide() {
202
222
  }
203
223
  }
204
224
  ghost.style.visibility = "visible";
205
- const duration = parseFloat(getComputedStyle(nav).getPropertyValue("--duration")) || 150;
225
+ // --duration-glide, resolved: the copy's animation-duration (it runs no CSS animation) is
226
+ // set to it, as the token itself is a calc() that getPropertyValue returns unresolved.
227
+ const duration = parseFloat(getComputedStyle(ghost).animationDuration) * 1000 || 0;
206
228
  const at = (b) => ({
207
229
  translate: `${b.x}px ${b.y}px`,
208
230
  width: `${b.w}px`,
209
231
  height: `${b.h}px`,
210
232
  });
211
233
  running = ghost.animate([at(from), at(to)], {
212
- duration: duration * 2,
213
- easing: getComputedStyle(nav).getPropertyValue("--ease").trim() || "ease-out",
234
+ duration,
235
+ easing: getComputedStyle(nav).getPropertyValue("--ease-glide").trim() || "ease-out",
214
236
  fill: "forwards",
215
237
  });
216
238
  running.onfinish = land;
@@ -229,7 +251,7 @@ function CurrentGlide() {
229
251
  delete row.dataset.glide;
230
252
  };
231
253
  }, []);
232
- return (_jsx("span", { ref: ref, "aria-hidden": true, "data-slot": "sidebar-current-glide", "data-current": "", className: "pointer-events-none invisible absolute top-0 left-0 -z-1 rounded-button material-row" }));
254
+ return (_jsx("span", { ref: ref, "aria-hidden": true, "data-slot": "sidebar-current-glide", "data-current": "", className: "pointer-events-none invisible absolute top-0 left-0 -z-1 rounded-button material-row [animation-duration:var(--duration-glide)]" }));
233
255
  }
234
256
  /**
235
257
  * Hover is one soft fill that follows the pointer up and down the list instead of each row lighting
@@ -307,14 +329,14 @@ function HoverGlide() {
307
329
  nav.removeEventListener("scroll", follow, true);
308
330
  };
309
331
  }, []);
310
- return (_jsx("span", { ref: ref, "aria-hidden": true, "data-slot": "sidebar-hover-glide", className: cn("pointer-events-none absolute top-0 left-0 -z-1 rounded-button bg-(--ink-ghost) opacity-0 data-visible:opacity-100", "transition-[translate,width,height,opacity] duration-[calc(var(--duration)*1.4)] ease-brand data-instant:transition-none") }));
332
+ return (_jsx("span", { ref: ref, "aria-hidden": true, "data-slot": "sidebar-hover-glide", className: cn("pointer-events-none absolute top-0 left-0 -z-1 rounded-button bg-(--ink-ghost) opacity-0 data-visible:opacity-100", "transition-[translate,width,height,opacity] [transition-duration:var(--duration-glide),var(--duration-glide),var(--duration-glide),var(--duration-fade)] ease-(--ease-glide) data-instant:transition-none") }));
311
333
  }
312
334
  /**
313
335
  * Sidebar — section navigation for docs, settings and dashboards.
314
336
  *
315
337
  * A `<nav>` of `SidebarGroup`s, each with an eyebrow `SidebarGroupLabel` and 38px
316
- * `SidebarItem` rows at 12px radius. Rows are flat at rest, share one soft hover fill that glides
317
- * with the pointer, and take the raised material when current. The rule people break: marking the current page with a flat fill or
338
+ * `SidebarItem` rows at 12px radius. Rows are flat at rest, only their label brightens on hover
339
+ * (`hover="glide"` adds one soft fill that follows the pointer), and take the raised material when current. The rule people break: marking the current page with a flat fill or
318
340
  * a bold weight. Set `current` (it writes `aria-current="page"`) and let the material show it.
319
341
  * A sidebar never shows a scrollbar: a long one goes in `<ScrollArea scrollbar={false}>`.
320
342
  *
@@ -322,12 +344,14 @@ function HoverGlide() {
322
344
  * the page by a hairline, holding `SidebarHeader`, `SidebarContent` and `SidebarFooter`. It
323
345
  * collapses on desktop and turns into a sheet on mobile.
324
346
  */
325
- export function Sidebar({ side = "left", variant = "sidebar", size = "default", className, children, ...props }) {
347
+ export function Sidebar({ side = "left", variant = "sidebar", size = "default", hover = "text", className, children, ...props }) {
326
348
  const shell = React.useContext(SidebarContext);
349
+ const instant = React.useContext(SidebarInstantContext);
350
+ const text = useMessages("sidebar", defaultMessages);
327
351
  const dense = size === "sm";
328
352
  // Dense: every control inside (the rows, a search field, a header button) is 30px.
329
353
  const sizeClass = dense ? "[--control-h:var(--control-h-sm)]" : undefined;
330
- const content = (_jsxs(SidebarSizeContext.Provider, { value: size, children: [_jsx(HoverGlide, {}), _jsx(CurrentGlide, {}), children] }));
354
+ const content = (_jsx(SidebarSizeContext.Provider, { value: size, children: _jsxs(SidebarSideContext.Provider, { value: side, children: [hover === "glide" && _jsx(HoverGlide, {}), _jsx(CurrentGlide, {}), children] }) }));
331
355
  if (!shell) {
332
356
  return (_jsx("nav", { "data-slot": "sidebar", "data-size": size, className: cn("relative isolate flex w-full flex-col", dense ? "gap-5" : "gap-7", sizeClass, className), ...props, children: content }));
333
357
  }
@@ -339,12 +363,12 @@ export function Sidebar({ side = "left", variant = "sidebar", size = "default",
339
363
  return (_jsx("nav", { "data-slot": "sidebar", "data-side": side, "data-variant": variant, "data-size": size, "data-state": "expanded", className: cn(panelClass, sizeClass, "sticky top-0 h-svh max-h-full w-(--sidebar-width) shrink-0 border-border/60", variant !== "sidebar" ? undefined : side === "left" ? "border-e" : "border-s", className), ...props, children: content }));
340
364
  }
341
365
  if (isMobile) {
342
- return (_jsx(Drawer, { side: side, open: openMobile, onOpenChange: setOpenMobile, children: _jsx(DrawerContent, { "data-slot": "sidebar-sheet", className: cn("w-[min(18rem,calc(100vw-3rem))] **:data-[slot=drawer-body]:gap-0 **:data-[slot=drawer-body]:p-0"), children: _jsxs(SidebarSurfaceContext.Provider, { value: "sheet", children: [_jsx(DrawerTitle, { className: "sr-only", children: props["aria-label"] ?? "Navigation" }), _jsx("nav", { "data-slot": "sidebar", "data-side": side, "data-size": size, className: cn(panelClass, "relative min-h-0 flex-1 bg-background", sizeClass, className), ...props, children: content })] }) }) }));
366
+ return (_jsx(Drawer, { side: side, open: openMobile, onOpenChange: setOpenMobile, children: _jsx(DrawerContent, { "data-slot": "sidebar-sheet", className: cn("w-[min(18rem,calc(100vw-3rem))] **:data-[slot=drawer-body]:gap-0 **:data-[slot=drawer-body]:p-0"), children: _jsxs(SidebarSurfaceContext.Provider, { value: "sheet", children: [_jsx(DrawerTitle, { className: "sr-only", children: props["aria-label"] ?? text.navigation }), _jsx("nav", { "data-slot": "sidebar", "data-side": side, "data-size": size, className: cn(panelClass, "relative min-h-0 flex-1 bg-background", sizeClass, className), ...props, children: content })] }) }) }));
343
367
  }
344
368
  const offcanvas = state === "collapsed" && collapsible === "offcanvas";
345
- return (_jsx("div", { "data-slot": "sidebar-shell", "data-variant": variant, "data-size": size, style: dense
369
+ return (_jsx("div", { "data-slot": "sidebar-shell", "data-instant": instant ? "" : undefined, "data-variant": variant, "data-size": size, style: dense
346
370
  ? { "--sidebar-width-icon": "calc(var(--control-h-sm) + 25px)" }
347
- : undefined, "data-state": state, "data-collapsible": state === "collapsed" ? collapsible : undefined, "data-side": side, className: cn("group/sidebar sticky top-0 hidden h-svh max-h-full w-(--sidebar-width) shrink-0 overflow-clip md:block", "transition-[width] duration-(--duration) ease-brand", "data-[collapsible=icon]:w-(--sidebar-width-icon) data-[collapsible=offcanvas]:w-0"), children: _jsx("nav", { "data-slot": "sidebar", "data-side": side, "data-size": size, inert: offcanvas || undefined, className: cn(panelClass, sizeClass, "absolute inset-y-0 w-(--sidebar-width) border-border/60 transition-[width] duration-(--duration) ease-brand", "group-data-[collapsible=icon]/sidebar:w-(--sidebar-width-icon)", side === "left" ? "left-0" : "right-0", variant !== "sidebar" ? undefined : side === "left" ? "border-e" : "border-s", className), ...props, children: content }) }));
371
+ : undefined, "data-state": state, "data-collapsible": state === "collapsed" ? collapsible : undefined, "data-side": side, className: cn("group/sidebar sticky top-0 hidden h-svh max-h-full w-(--sidebar-width) shrink-0 overflow-clip md:block", "transition-[width] duration-(--duration) ease-brand data-instant:transition-none", "data-[collapsible=icon]:w-(--sidebar-width-icon) data-[collapsible=offcanvas]:w-0"), children: _jsx("nav", { "data-slot": "sidebar", "data-side": side, "data-size": size, inert: offcanvas || undefined, className: cn(panelClass, sizeClass, "absolute inset-y-0 w-(--sidebar-width) border-border/60 transition-[width] duration-(--duration) ease-brand group-data-instant/sidebar:transition-none", "group-data-[collapsible=icon]/sidebar:w-(--sidebar-width-icon)", side === "left" ? "start-0" : "end-0", variant !== "sidebar" ? undefined : side === "left" ? "border-e" : "border-s", className), ...props, children: content }) }));
348
372
  }
349
373
  /** The top of an app-shell sidebar: a logo, a workspace switcher, a search row. Never scrolls. */
350
374
  export function SidebarHeader({ className, ...props }) {
@@ -380,7 +404,7 @@ export function SidebarGroup({ className, ...props }) {
380
404
  */
381
405
  export function SidebarGroupLabel({ className, ...props }) {
382
406
  const dense = React.useContext(SidebarSizeContext) === "sm";
383
- return (_jsx("div", { "data-slot": "sidebar-group-label", className: cn("overflow-hidden eyebrow whitespace-nowrap transition-[margin,opacity] duration-(--duration) ease-brand", "group-data-[collapsible=icon]/sidebar:pointer-events-none group-data-[collapsible=icon]/sidebar:opacity-0",
407
+ return (_jsx("div", { "data-slot": "sidebar-group-label", className: cn("overflow-hidden eyebrow whitespace-nowrap transition-[margin,opacity] duration-(--duration) ease-brand group-data-instant/sidebar:transition-none", "group-data-[collapsible=icon]/sidebar:pointer-events-none group-data-[collapsible=icon]/sidebar:opacity-0",
384
408
  // Fixed heights (line + padding) so the fold is exact: 16 + 8 = 24px, dense 14 + 6 = 20px.
385
409
  dense
386
410
  ? "px-2.5 pb-1.5 text-[11px] leading-[14px] group-data-[collapsible=icon]/sidebar:-mt-5"
@@ -396,10 +420,11 @@ function textOf(node) {
396
420
  /**
397
421
  * One navigation row. Renders an `<a>`; pass `render={<Link to="…" />}` for router links.
398
422
  * Leading icons are 16px; a trailing `Kbd`, `Tag` or `SidebarMenuBadge` is pushed to the end
399
- * with `ml-auto`. In an icon-collapsed app shell it shrinks to a 38px square with a tooltip.
423
+ * with `ms-auto`. In an icon-collapsed app shell it shrinks to a 38px square with a tooltip.
400
424
  */
401
425
  export function SidebarItem({ current, tooltip, render, ref, className, children, onClick, ...props }) {
402
426
  const shell = React.useContext(SidebarContext);
427
+ const side = React.useContext(SidebarSideContext);
403
428
  const surface = React.useContext(SidebarSurfaceContext);
404
429
  const dense = React.useContext(SidebarSizeContext) === "sm";
405
430
  const inShell = shell !== null;
@@ -423,9 +448,11 @@ export function SidebarItem({ current, tooltip, render, ref, className, children
423
448
  className: cn(
424
449
  // cursor-pointer: rows may render as a <button> (theme switch, account menu), which has no pointer by default.
425
450
  "flex min-h-(--control-h) w-full cursor-pointer items-center rounded-button material-row font-body leading-none no-underline focus-ring select-none", dense ? "gap-2 px-2.5 text-[13px]" : "gap-2.5 px-3 text-sm", "aria-disabled:pointer-events-none aria-disabled:opacity-50",
426
- // Hover is quieter than current: the label brightens over the sidebar's gliding fill (HoverGlide),
451
+ // Hover is quieter than current: the label brightens (over the gliding fill with hover="glide"),
427
452
  // the row itself takes no fill, edge or shadow. The raised row means "you are here".
428
453
  "hover:not-aria-[current=page]:bg-transparent! hover:not-aria-[current=page]:bg-none! hover:not-aria-[current=page]:shadow-none!",
454
+ // A row rests in the muted ink, so the hovered one stands out in full: black, or white in dark mode.
455
+ "not-aria-[current=page]:text-muted-foreground hover:not-aria-[current=page]:text-foreground",
429
456
  // While the current row glides (CurrentGlide), the old and new rows stay flat.
430
457
  "data-glide:transition-none! data-[glide=hidden]:bg-transparent! data-[glide=hidden]:bg-none! data-[glide=hidden]:shadow-none!", "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", inShell && "overflow-hidden whitespace-nowrap", inShell &&
431
458
  // A square in the icon rail with the 16px icon centred: (row - icon - border) / 2 a side.
@@ -439,11 +466,11 @@ export function SidebarItem({ current, tooltip, render, ref, className, children
439
466
  const label = tooltip ?? textOf(children);
440
467
  if (!label)
441
468
  return element;
442
- return (_jsxs(Tooltip, { disabled: !iconRail, children: [_jsx(TooltipTrigger, { render: element }), _jsx(TooltipContent, { side: "right", align: "center", sideOffset: 10, children: label })] }));
469
+ return (_jsxs(Tooltip, { disabled: !iconRail, children: [_jsx(TooltipTrigger, { render: element }), _jsx(TooltipContent, { side: side === "left" ? "inline-end" : "inline-start", align: "center", sideOffset: 10, children: label })] }));
443
470
  }
444
471
  /** A count at the end of a row ("12"): mono, tabular, muted. Hidden in the icon rail. */
445
472
  export function SidebarMenuBadge({ className, ...props }) {
446
- return (_jsx("span", { "data-slot": "sidebar-menu-badge", className: cn("ml-auto pl-2 font-mono text-xs leading-none text-muted-foreground tabular-nums group-data-[collapsible=icon]/sidebar:hidden", className), ...props }));
473
+ return (_jsx("span", { "data-slot": "sidebar-menu-badge", className: cn("ms-auto ps-2 font-mono text-xs leading-none text-muted-foreground tabular-nums group-data-[collapsible=icon]/sidebar:hidden", className), ...props }));
447
474
  }
448
475
  /* ── Controls ──────────────────────────────────────────────────────────────── */
449
476
  /**
@@ -452,14 +479,15 @@ export function SidebarMenuBadge({ className, ...props }) {
452
479
  */
453
480
  export function SidebarTrigger({ variant = "ghost", size = "icon", className, children, onClick, ...props }) {
454
481
  const { toggleSidebar, isMobile, open, openMobile } = useSidebar();
455
- return (_jsx(Button, { "data-slot": "sidebar-trigger", variant: variant, size: size, "aria-label": "Toggle sidebar", "aria-expanded": isMobile ? openMobile : open, className: cn("text-muted-foreground",
482
+ const text = useMessages("sidebar", defaultMessages);
483
+ return (_jsx(Button, { "data-slot": "sidebar-trigger", variant: variant, size: size, "aria-label": text.toggle, "aria-expanded": isMobile ? openMobile : open, className: cn("text-muted-foreground",
456
484
  // The circle pads its glyph by ~10px; pull what follows in, and give a separator after
457
485
  // it a little more room, so the gaps either side of the separator read the same.
458
- size === "icon" && "-mr-1.5 [&+[data-slot=separator]]:mr-1", size === "icon-sm" && "-mr-1 [&+[data-slot=separator]]:mr-0.75", className), onClick: (event) => {
486
+ size === "icon" && "-me-1.5 [&+[data-slot=separator]]:me-1", size === "icon-sm" && "-me-1 [&+[data-slot=separator]]:me-0.75", className), onClick: (event) => {
459
487
  onClick?.(event);
460
488
  if (!event.defaultPrevented)
461
489
  toggleSidebar();
462
- }, ...props, children: children ?? _jsx(PanelLeftIcon, { "aria-hidden": true }) }));
490
+ }, ...props, children: children ?? _jsx(PanelLeftIcon, { "aria-hidden": true, className: "rtl:-scale-x-100" }) }));
463
491
  }
464
492
  /**
465
493
  * A thin strip along the sidebar's inner edge: hover shows the hairline in `--control-focus`,
@@ -468,15 +496,20 @@ export function SidebarTrigger({ variant = "ghost", size = "icon", className, ch
468
496
  export function SidebarRail({ className, onClick, ...props }) {
469
497
  const { toggleSidebar, state, isMobile, collapsible } = useSidebar();
470
498
  const surface = React.useContext(SidebarSurfaceContext);
499
+ const text = useMessages("sidebar", defaultMessages);
471
500
  if (isMobile || surface === "sheet" || collapsible === "none")
472
501
  return null;
473
- return (_jsx("button", { type: "button", "data-slot": "sidebar-rail", "aria-label": "Toggle sidebar", title: "Toggle sidebar", tabIndex: -1, onClick: (event) => {
502
+ return (_jsx("button", { type: "button", "data-slot": "sidebar-rail", "aria-label": text.toggle, title: text.toggle, tabIndex: -1, onClick: (event) => {
474
503
  onClick?.(event);
475
504
  if (!event.defaultPrevented)
476
505
  toggleSidebar();
477
- }, className: cn("absolute inset-y-0 z-20 w-2 border-0 bg-transparent p-0 outline-none", "after:absolute after:inset-y-0 after:w-px after:bg-transparent after:transition-[background-color] after:duration-(--duration) after:ease-brand after:content-[''] hover:after:bg-control-focus", "group-data-[side=left]/sidebar:right-0 group-data-[side=right]/sidebar:left-0 group-data-[side=left]/sidebar:after:right-[-1px] group-data-[side=right]/sidebar:after:left-[-1px]", state === "expanded"
478
- ? "group-data-[side=left]/sidebar:cursor-w-resize group-data-[side=right]/sidebar:cursor-e-resize"
479
- : "group-data-[side=left]/sidebar:cursor-e-resize group-data-[side=right]/sidebar:cursor-w-resize", className), ...props }));
506
+ }, className: cn("absolute inset-y-0 z-20 w-2 border-0 bg-transparent p-0 outline-none", "after:absolute after:inset-y-0 after:w-px after:bg-transparent after:transition-[background-color] after:duration-(--duration) after:ease-brand after:content-[''] hover:after:bg-control-focus",
507
+ // On the edge next to the page: the end of a start sidebar, in either direction.
508
+ "group-data-[side=left]/sidebar:end-0 group-data-[side=right]/sidebar:start-0 group-data-[side=left]/sidebar:after:-end-px group-data-[side=right]/sidebar:after:-start-px",
509
+ // The cursor points the way the panel will go: towards its edge to close, away to open.
510
+ state === "expanded"
511
+ ? "group-data-[side=left]/sidebar:cursor-w-resize group-data-[side=right]/sidebar:cursor-e-resize rtl:group-data-[side=left]/sidebar:cursor-e-resize rtl:group-data-[side=right]/sidebar:cursor-w-resize"
512
+ : "group-data-[side=left]/sidebar:cursor-e-resize group-data-[side=right]/sidebar:cursor-w-resize rtl:group-data-[side=left]/sidebar:cursor-w-resize rtl:group-data-[side=right]/sidebar:cursor-e-resize", className), ...props }));
480
513
  }
481
514
  /**
482
515
  * The main area beside an app-shell sidebar: a `<main>` column that takes the remaining width.
@@ -485,5 +518,7 @@ export function SidebarRail({ className, onClick, ...props }) {
485
518
  * Otherwise it has no fill of its own: the page ground shows through.
486
519
  */
487
520
  export function SidebarInset({ className, ...props }) {
488
- return (_jsx("main", { "data-slot": "sidebar-inset", className: cn("relative flex min-w-0 flex-1 flex-col", className), ...props }));
521
+ return (_jsx("main", { "data-slot": "sidebar-inset",
522
+ // Clear of a BottomNav on a phone: --bottom-nav-h is 0 wherever no bar is shown.
523
+ className: cn("relative flex min-w-0 flex-1 flex-col pb-(--bottom-nav-h)", className), ...props }));
489
524
  }
@@ -1,4 +1,19 @@
1
1
  import * as React from "react";
2
+ export interface SiteHeaderMessages {
3
+ /** The name of the links' `nav` landmark. */
4
+ nav: string;
5
+ /** The phone menu button. */
6
+ openMenu: string;
7
+ /** The phone panel's close button. */
8
+ closeMenu: string;
9
+ /** The phone panel's title. */
10
+ menu: string;
11
+ }
12
+ declare module "./locale" {
13
+ interface Messages {
14
+ siteHeader: SiteHeaderMessages;
15
+ }
16
+ }
2
17
  /** A page inside a `SiteHeaderLink`'s dropdown panel. */
3
18
  export interface SiteHeaderLinkItem {
4
19
  label: React.ReactNode;
@@ -28,32 +43,51 @@ export interface SiteHeaderProps extends Omit<React.ComponentProps<"header">, "c
28
43
  logo: React.ReactNode;
29
44
  /** Primary navigation, in order, about five links: e.g. "Product", "Docs", "Pricing", "Blog", "About". */
30
45
  links: SiteHeaderLink[];
31
- /** Right-most slot, after the hairline divider: locale switch, theme toggle, one CTA at most. */
46
+ /** The slot at the end: locale switch, theme toggle, one CTA at most. */
32
47
  actions?: React.ReactNode;
33
48
  /**
34
- * Force the scrolled treatment (background/80, blur, hairline). By default it switches on
35
- * once the window scrolls past `scrollThreshold`.
49
+ * Where the links sit. `end` (default): with the actions at the end of the bar, after a hairline
50
+ * divider. `start`: right after the logo, with the actions on their own at the end — for an app
51
+ * whose bar reads logo, sections, then search and account.
52
+ */
53
+ align?: "start" | "end";
54
+ /**
55
+ * Force the scrolled treatment (the page ground and a hairline), e.g. for a page that scrolls
56
+ * in a container of its own. By default it comes in as the window scrolls past
57
+ * `scrollThreshold`, over the bar's own height.
36
58
  */
37
59
  scrolled?: boolean;
38
- /** Pixels of scroll before the header gains its background. Defaults to 8. */
60
+ /** Pixels of scroll before the ground starts to come in. Defaults to 8. */
39
61
  scrollThreshold?: number;
40
- /** Accessible name of the `<nav>`. Defaults to "Main". */
62
+ /** Accessible name of the `<nav>`. Defaults to "Main", or `messages.siteHeader.nav`. */
41
63
  navLabel?: string;
42
- /** Accessible names for the mobile menu buttons. */
64
+ /**
65
+ * Accessible names for the mobile menu buttons. Default `messages.siteHeader` `openMenu`,
66
+ * `closeMenu` and `menu`.
67
+ */
43
68
  menuLabels?: {
44
69
  open?: string;
45
70
  close?: string;
46
71
  title?: string;
47
72
  };
73
+ /**
74
+ * The phone menu: below 48rem of header the links fold into a menu button that opens a full
75
+ * panel. `false` leaves it out, for an app with navigation of its own on phones (a bottom tab
76
+ * bar): the links show from 48rem up, and the actions stay in the bar at every width.
77
+ * Default `true`.
78
+ */
79
+ menu?: boolean;
48
80
  }
49
81
  /**
50
82
  * SiteHeader — the sticky top bar of an zon site, composed from `NavigationMenu`.
51
83
  *
52
84
  * `NavigationMenu` is the primitive (links, triggers, the shared dropdown popup); SiteHeader
53
- * is the pattern around it: logo left; the menu, a hairline divider and an actions slot right;
54
- * transparent at the top of the page, `background/80` with a backdrop blur and a hairline once
55
- * the page scrolls; and below `md` a full-height panel opened by a menu button. Give an entry
56
- * `items` and it opens a dropdown panel. The rule people break: filling the bar with buttons.
57
- * One CTA at most — the links are the navigation, the actions slot is for locale and theme.
85
+ * is the pattern around it: logo at the start; the menu, a hairline divider and an actions slot at
86
+ * the end (or the menu beside the logo, with `align="start"`); transparent at the top of the page,
87
+ * and once it scrolls the page ground itself (its colour, grain and faint light, lined up with the
88
+ * page's) fading in over a hairline, so content passes under the bar rather than through a band of
89
+ * another colour; and below 48rem of bar a full-height panel opened by a menu button. Give an
90
+ * entry `items` and it opens a dropdown panel. The rule people break: filling the bar with
91
+ * buttons. One CTA at most — the links are the navigation, the actions slot is for locale and theme.
58
92
  */
59
- export declare function SiteHeader({ logo, links, actions, scrolled: scrolledProp, scrollThreshold, navLabel, menuLabels, className, dir, ...props }: SiteHeaderProps): React.JSX.Element;
93
+ export declare function SiteHeader({ logo, links, actions, align, scrolled: scrolledProp, scrollThreshold, navLabel: navLabelProp, menuLabels, menu, className, style, dir, ...props }: SiteHeaderProps): React.JSX.Element;
@@ -7,7 +7,17 @@ import * as React from "react";
7
7
  import { cn } from "../lib/cn.js";
8
8
  import { usePopupDir } from "./_overlay.js";
9
9
  import { Button } from "./button.js";
10
+ import { useMessages } from "./locale.js";
10
11
  import { NavigationMenu, NavigationMenuContent, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, } from "./navigation-menu.js";
12
+ const defaultMessages = {
13
+ nav: "Main",
14
+ openMenu: "Open menu",
15
+ closeMenu: "Close menu",
16
+ menu: "Menu",
17
+ };
18
+ /** The phone panel's links come in this far apart, the first four of them (the rest with the fourth). */
19
+ const PANEL_STAGGER_MS = 30;
20
+ const PANEL_STAGGER_MAX = 4;
11
21
  /** A link in the mobile panel: a plain `<a>`, or the entry's router link through `render`. */
12
22
  function PanelLink({ render, href, ...props }) {
13
23
  return useRender({
@@ -16,35 +26,72 @@ function PanelLink({ render, href, ...props }) {
16
26
  props: { ...props, href: render ? undefined : href },
17
27
  });
18
28
  }
19
- function useScrolled(threshold, forced) {
29
+ /**
30
+ * Whether the window has scrolled past `threshold`, and the scrolled ground with it: 0 until
31
+ * `threshold`, then up to 1 over the bar's own height. Where the browser ties animations to the
32
+ * scroll, the stylesheet draws it from the scroll position itself (navigation.css), in the same
33
+ * frame the page moves; this measures the bar's height for it (`--site-header-span`). Elsewhere it
34
+ * writes the ground as `--site-header-ground`, once a frame. Tied to the scroll, the bar is solid
35
+ * by the time content a bar's height down reaches it, however fast the page moves.
36
+ */
37
+ function useScrollGround(ref, threshold, forced) {
20
38
  const [scrolled, setScrolled] = React.useState(false);
21
39
  React.useEffect(() => {
22
- if (forced !== undefined || typeof window === "undefined")
40
+ const header = ref.current;
41
+ if (forced !== undefined || !header)
23
42
  return;
24
- const update = () => setScrolled(window.scrollY > threshold);
43
+ const linked = typeof CSS !== "undefined" && CSS.supports("animation-timeline: scroll()");
44
+ let frame = 0;
45
+ let span = 0;
46
+ const update = () => {
47
+ frame = 0;
48
+ const y = window.scrollY;
49
+ // Written only when it changes: a style change while the page scrolls makes work for the
50
+ // browser in the very frames the bar has to keep up in.
51
+ const height = Math.max(header.offsetHeight, 1);
52
+ if (height !== span)
53
+ header.style.setProperty("--site-header-span", `${(span = height)}px`);
54
+ if (!linked)
55
+ header.style.setProperty("--site-header-ground", String(Math.min(1, Math.max(0, (y - threshold) / span))));
56
+ setScrolled(y > threshold);
57
+ };
58
+ const schedule = () => {
59
+ frame ||= requestAnimationFrame(update);
60
+ };
25
61
  update();
26
- window.addEventListener("scroll", update, { passive: true });
27
- return () => window.removeEventListener("scroll", update);
28
- }, [threshold, forced]);
62
+ window.addEventListener("scroll", schedule, { passive: true });
63
+ window.addEventListener("resize", schedule, { passive: true });
64
+ return () => {
65
+ cancelAnimationFrame(frame);
66
+ window.removeEventListener("scroll", schedule);
67
+ window.removeEventListener("resize", schedule);
68
+ header.style.removeProperty("--site-header-span");
69
+ header.style.removeProperty("--site-header-ground");
70
+ };
71
+ }, [ref, threshold, forced]);
29
72
  return forced ?? scrolled;
30
73
  }
31
74
  /**
32
75
  * SiteHeader — the sticky top bar of an zon site, composed from `NavigationMenu`.
33
76
  *
34
77
  * `NavigationMenu` is the primitive (links, triggers, the shared dropdown popup); SiteHeader
35
- * is the pattern around it: logo left; the menu, a hairline divider and an actions slot right;
36
- * transparent at the top of the page, `background/80` with a backdrop blur and a hairline once
37
- * the page scrolls; and below `md` a full-height panel opened by a menu button. Give an entry
38
- * `items` and it opens a dropdown panel. The rule people break: filling the bar with buttons.
39
- * One CTA at most — the links are the navigation, the actions slot is for locale and theme.
78
+ * is the pattern around it: logo at the start; the menu, a hairline divider and an actions slot at
79
+ * the end (or the menu beside the logo, with `align="start"`); transparent at the top of the page,
80
+ * and once it scrolls the page ground itself (its colour, grain and faint light, lined up with the
81
+ * page's) fading in over a hairline, so content passes under the bar rather than through a band of
82
+ * another colour; and below 48rem of bar a full-height panel opened by a menu button. Give an
83
+ * entry `items` and it opens a dropdown panel. The rule people break: filling the bar with
84
+ * buttons. One CTA at most — the links are the navigation, the actions slot is for locale and theme.
40
85
  */
41
- export function SiteHeader({ logo, links, actions, scrolled: scrolledProp, scrollThreshold = 8, navLabel = "Main", menuLabels, className, dir, ...props }) {
42
- const scrolled = useScrolled(scrollThreshold, scrolledProp);
86
+ export function SiteHeader({ logo, links, actions, align = "end", scrolled: scrolledProp, scrollThreshold = 8, navLabel: navLabelProp, menuLabels, menu = true, className, style, dir, ...props }) {
87
+ const text = useMessages("siteHeader", defaultMessages);
88
+ const navLabel = navLabelProp ?? text.nav;
89
+ const headerRef = React.useRef(null);
90
+ const menuButtonRef = React.useRef(null);
91
+ const scrolled = useScrollGround(headerRef, scrollThreshold, scrolledProp);
43
92
  const [open, setOpen] = React.useState(false);
44
93
  // The phone panel is portalled out of the page: it takes the header's direction itself.
45
94
  const panelDir = usePopupDir(dir);
46
- const headerRef = React.useRef(null);
47
- const menuButtonRef = React.useRef(null);
48
95
  // The header switches by its own width, not the window's: a container query hides the menu
49
96
  // button from 48rem of header up. Close the panel once the header grows past that and the
50
97
  // button is gone.
@@ -60,8 +107,20 @@ export function SiteHeader({ logo, links, actions, scrolled: scrolledProp, scrol
60
107
  observer.observe(header);
61
108
  return () => observer.disconnect();
62
109
  }, [open]);
63
- return (_jsx("header", { ref: headerRef, "data-slot": "site-header", "data-scrolled": scrolled ? "" : undefined, dir: dir, className: cn("@container/site-header sticky top-0 z-40 w-full border-b border-transparent", "transition-[background-color,border-color,backdrop-filter] duration-(--duration) ease-(--ease)", "data-scrolled:border-border/60 data-scrolled:bg-background/80 data-scrolled:backdrop-blur-md", className), ...props, children: _jsxs("div", { className: "container-page flex min-h-16 items-center justify-between gap-6", children: [_jsx("div", { "data-slot": "site-header-logo", className: "flex shrink-0 items-center", children: logo }), _jsxs("div", { className: "hidden items-center gap-4 @3xl/site-header:flex", children: [_jsx(NavigationMenu, { "aria-label": navLabel, children: _jsx(NavigationMenuList, { children: links.map((link, i) => (_jsx(NavigationMenuItem, { children: link.items?.length ? (_jsxs(_Fragment, { children: [_jsx(NavigationMenuTrigger, { children: link.label }), _jsx(NavigationMenuContent, { children: _jsx("ul", { className: "m-0 grid list-none gap-1 p-0 sm:w-[400px]", children: link.items.map((item, j) => (_jsx("li", { children: _jsxs(NavigationMenuLink, { variant: "row", href: item.render ? undefined : item.href, render: item.render, active: item.current, children: [item.label, item.description != null && _jsx("small", { children: item.description })] }) }, j))) }) })] })) : (_jsx(NavigationMenuLink, { href: link.render ? undefined : link.href, render: link.render, active: link.current, children: link.label })) }, i))) }) }), actions != null && (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, className: "h-5 w-px bg-border" }), _jsx("div", { "data-slot": "site-header-actions", className: "flex items-center gap-2", children: actions })] }))] }), _jsxs(BaseDialog.Root, { open: open, onOpenChange: setOpen, children: [_jsx(BaseDialog.Trigger, { ref: menuButtonRef, render: _jsx(Button, { variant: "ghost", size: "icon", className: "@3xl/site-header:hidden" }), "aria-label": menuLabels?.open ?? "Open menu", children: _jsx(MenuIcon, {}) }), _jsx(BaseDialog.Portal, { children: _jsxs(BaseDialog.Popup, { "data-slot": "site-header-panel", dir: panelDir, className: cn("fixed inset-0 z-50 flex flex-col overflow-y-auto bg-background text-foreground outline-none", "transition-[opacity,translate] duration-(--duration) ease-(--ease)", "data-ending-style:-translate-y-2 data-ending-style:opacity-0 data-starting-style:-translate-y-2 data-starting-style:opacity-0"), children: [_jsx(BaseDialog.Title, { className: "sr-only", children: menuLabels?.title ?? "Menu" }), _jsxs("div", { className: "container-page flex min-h-16 items-center justify-between gap-6 border-b border-border/60", children: [_jsx("div", { className: "flex shrink-0 items-center", children: logo }), _jsx(BaseDialog.Close, { render: _jsx(Button, { variant: "ghost", size: "icon" }), "aria-label": menuLabels?.close ?? "Close menu", children: _jsx(XIcon, {}) })] }), _jsx("nav", { "aria-label": navLabel, className: "container-page flex-1", children: _jsx("ul", { className: "m-0 list-none p-0", children: links.map((link, i) => {
64
- const index = (_jsx("span", { className: "w-6 shrink-0 font-mono text-[12px] text-muted-foreground tabular-nums", children: String(i + 1).padStart(2, "0") }));
65
- return (_jsxs("li", { className: "border-b border-border/60", children: [link.href != null || link.render != null ? (_jsxs(PanelLink, { render: link.render, href: link.href, "aria-current": link.current ? "page" : undefined, onClick: () => setOpen(false), className: "flex items-baseline gap-5 py-5 text-foreground no-underline focus-ring", children: [index, _jsx("span", { className: "display text-[32px]", children: link.label })] })) : (_jsxs("div", { className: "flex items-baseline gap-5 pt-5 pb-2 text-foreground", children: [index, _jsx("span", { className: "display text-[32px]", children: link.label })] })), link.items?.length ? (_jsx("ul", { className: "m-0 -mt-1 list-none ps-11 pb-4", children: link.items.map((item, j) => (_jsx("li", { children: _jsx(PanelLink, { render: item.render, href: item.href, "aria-current": item.current ? "page" : undefined, onClick: () => setOpen(false), className: "flex min-h-(--control-h) items-center text-[17px] text-foreground-soft no-underline focus-ring aria-[current=page]:text-foreground", children: item.label }) }, j))) })) : null] }, i));
66
- }) }) }), actions != null && (_jsx("div", { className: "container-page flex items-center gap-3 py-6", children: actions }))] }) })] })] }) }));
110
+ const nav = (_jsx(NavigationMenu, { "aria-label": navLabel,
111
+ // Beside the logo, or without the phone menu, the links leave the bar below 48rem of it.
112
+ className: cn((align === "start" || !menu) && "hidden @3xl/site-header:block"), children: _jsx(NavigationMenuList, { children: links.map((link, i) => (_jsx(NavigationMenuItem, { children: link.items?.length ? (_jsxs(_Fragment, { children: [_jsx(NavigationMenuTrigger, { children: link.label }), _jsx(NavigationMenuContent, { children: _jsx("ul", { className: "m-0 grid list-none gap-1 p-0 sm:w-[400px]", children: link.items.map((item, j) => (_jsx("li", { children: _jsxs(NavigationMenuLink, { variant: "row", href: item.render ? undefined : item.href, render: item.render, active: item.current, children: [item.label, item.description != null && _jsx("small", { children: item.description })] }) }, j))) }) })] })) : (_jsx(NavigationMenuLink, { href: link.render ? undefined : link.href, render: link.render, active: link.current, children: link.label })) }, i))) }) }));
113
+ const actionsSlot = actions != null && (_jsx("div", { "data-slot": "site-header-actions", className: "flex items-center gap-2", children: actions }));
114
+ return (_jsxs("header", { ref: headerRef, "data-slot": "site-header", "data-scrolled": scrolled ? "" : undefined, "data-forced": scrolledProp === undefined ? undefined : "", dir: dir,
115
+ // The ground and its hairline are drawn in navigation.css, from --site-header-ground.
116
+ className: cn("@container/site-header sticky top-0 z-40 w-full border-b", className), style: {
117
+ ...style,
118
+ "--site-header-from": `${scrollThreshold}px`,
119
+ ...(scrolledProp !== undefined && { "--site-header-ground": scrolledProp ? 1 : 0 }),
120
+ }, ...props, children: [_jsx("span", { "aria-hidden": true, "data-slot": "site-header-ground" }), _jsxs("div", { className: cn("container-page flex min-h-16 items-center", align === "start" ? "gap-8" : "justify-between gap-6"), children: [_jsx("div", { "data-slot": "site-header-logo", className: "flex shrink-0 items-center", children: logo }), align === "start" ? (_jsxs(_Fragment, { children: [nav, actionsSlot && (_jsx("div", { className: cn("ms-auto items-center", menu ? "hidden @3xl/site-header:flex" : "flex"), children: actionsSlot }))] })) : (_jsxs("div", { className: cn("items-center gap-4", menu ? "hidden @3xl/site-header:flex" : "flex"), children: [nav, actionsSlot && (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, className: cn("h-5 w-px bg-border", !menu && "hidden @3xl/site-header:block") }), actionsSlot] }))] })), menu && (_jsxs(BaseDialog.Root, { open: open, onOpenChange: setOpen, children: [_jsx(BaseDialog.Trigger, { ref: menuButtonRef, render: _jsx(Button, { variant: "ghost", size: "icon", className: cn("@3xl/site-header:hidden", align === "start" && "ms-auto") }), "aria-label": menuLabels?.open ?? text.openMenu, children: _jsx(MenuIcon, {}) }), _jsx(BaseDialog.Portal, { children: _jsxs(BaseDialog.Popup, { "data-slot": "site-header-panel", dir: panelDir, className: cn("fixed inset-0 z-50 flex flex-col overflow-y-auto bg-background text-foreground outline-none", "pt-[env(safe-area-inset-top,0px)] pb-[env(safe-area-inset-bottom,0px)]", "transition-[opacity,translate] duration-(--duration) ease-(--ease)", "data-ending-style:-translate-y-2 data-ending-style:opacity-0 data-starting-style:-translate-y-2 data-starting-style:opacity-0"), children: [_jsx(BaseDialog.Title, { className: "sr-only", children: menuLabels?.title ?? text.menu }), _jsxs("div", { className: "container-page flex min-h-16 items-center justify-between gap-6 border-b border-border/60", children: [_jsx("div", { className: "flex shrink-0 items-center", children: logo }), _jsx(BaseDialog.Close, { render: _jsx(Button, { variant: "ghost", size: "icon" }), "aria-label": menuLabels?.close ?? text.closeMenu, children: _jsx(XIcon, {}) })] }), _jsx("nav", { "aria-label": navLabel, className: "container-page flex-1", children: _jsx("ul", { className: "m-0 list-none p-0", children: links.map((link, i) => {
121
+ const index = (_jsx("span", { className: "w-6 shrink-0 font-mono text-[12px] text-muted-foreground tabular-nums", children: String(i + 1).padStart(2, "0") }));
122
+ return (_jsxs("li", { className: "border-b border-border/60 transition-[opacity,translate] duration-(--duration) ease-(--ease) starting:translate-y-2 starting:opacity-0", style: {
123
+ transitionDelay: `${Math.min(i, PANEL_STAGGER_MAX - 1) * PANEL_STAGGER_MS}ms`,
124
+ }, children: [link.href != null || link.render != null ? (_jsxs(PanelLink, { render: link.render, href: link.href, "aria-current": link.current ? "page" : undefined, onClick: () => setOpen(false), className: "flex items-baseline gap-5 py-5 text-foreground no-underline focus-ring", children: [index, _jsx("span", { className: "display text-[32px]", children: link.label })] })) : (_jsxs("div", { className: "flex items-baseline gap-5 pt-5 pb-2 text-foreground", children: [index, _jsx("span", { className: "display text-[32px]", children: link.label })] })), link.items?.length ? (_jsx("ul", { className: "m-0 -mt-1 list-none ps-11 pb-4", children: link.items.map((item, j) => (_jsx("li", { children: _jsx(PanelLink, { render: item.render, href: item.href, "aria-current": item.current ? "page" : undefined, onClick: () => setOpen(false), className: "flex min-h-(--control-h) items-center text-[17px] text-foreground-soft no-underline focus-ring aria-[current=page]:text-foreground", children: item.label }) }, j))) })) : null] }, i));
125
+ }) }) }), actions != null && (_jsx("div", { className: "container-page flex items-center gap-3 py-6", children: actions }))] }) })] }))] })] }));
67
126
  }
@@ -20,7 +20,7 @@ export interface SkeletonProps extends React.ComponentProps<"div"> {
20
20
  }
21
21
  /**
22
22
  * Skeleton — a placeholder in `--control-surface` that holds the place of content while it
23
- * loads, with one soft highlight sweeping across it every 1.6s (static under reduced motion).
23
+ * loads, with one soft highlight sweeping across it every 1.6s (breathing in opacity under reduced motion).
24
24
  *
25
25
  * The radius follows what it stands in for: `text` lines are square, `field` is 10px, `button`
26
26
  * is 12px, `circle` is round, `card` is 20px. Skeletons are `aria-hidden`; announce loading on
@@ -17,7 +17,7 @@ const skeletonShapes = {
17
17
  };
18
18
  /**
19
19
  * Skeleton — a placeholder in `--control-surface` that holds the place of content while it
20
- * loads, with one soft highlight sweeping across it every 1.6s (static under reduced motion).
20
+ * loads, with one soft highlight sweeping across it every 1.6s (breathing in opacity under reduced motion).
21
21
  *
22
22
  * The radius follows what it stands in for: `text` lines are square, `field` is 10px, `button`
23
23
  * is 12px, `circle` is round, `card` is 20px. Skeletons are `aria-hidden`; announce loading on
@@ -5,6 +5,7 @@ import * as React from "react";
5
5
  import { cn, sx } from "../lib/cn.js";
6
6
  import { useFormReset } from "../lib/form-reset.js";
7
7
  import { mergeRefs } from "../lib/merge-refs.js";
8
+ import { useLocale } from "./locale.js";
8
9
  /* ── Squash and stretch ────────────────────────────────────────────────────── */
9
10
  /** How far a thumb stretches at most (0.4 = 40% longer along the track). */
10
11
  const MAX_STRETCH = 0.4;
@@ -123,7 +124,8 @@ thumbAlignment = "edge", className, children, ref, ...props }) {
123
124
  const [resetKey, formRef] = useFormReset();
124
125
  const refs = React.useMemo(() => mergeRefs(formRef, ref), [formRef, ref]);
125
126
  useSquash(control, squash, resetKey);
126
- return (_jsxs(BaseSlider.Root, { ref: refs, "data-slot": "slider", thumbAlignment: thumbAlignment, className: sx("group/slider flex w-full flex-col gap-2 data-[orientation=vertical]:h-full data-[orientation=vertical]:w-auto data-disabled:[&>[data-slot=slider-control]]:opacity-55", className), ...props, children: [hasHeader && (_jsxs("div", { "data-slot": "slider-header", className: "flex items-baseline justify-between gap-4", children: [label != null && (_jsx(BaseSlider.Label, { "data-slot": "slider-label", className: "text-sm leading-snug font-medium text-foreground select-none group-data-disabled/slider:text-foreground-soft", children: label })), showValue && (_jsx(BaseSlider.Value, { "data-slot": "slider-value", className: "ms-auto font-mono text-xs text-muted-foreground tabular-nums group-data-disabled/slider:opacity-55", children: (formatted) => formatted.join(" – ") }))] })), _jsx(BaseSlider.Control, { ref: control, "data-slot": "slider-control", className: "flex w-full touch-none items-center py-2 select-none data-disabled:cursor-not-allowed data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-32 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col data-[orientation=vertical]:px-2 data-[orientation=vertical]:py-0", children: _jsxs(BaseSlider.Track, { "data-slot": "slider-track", className: "relative h-1.5 w-full material-field rounded-full select-none data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5", children: [_jsx(BaseSlider.Indicator, { "data-slot": "slider-indicator", className: "rounded-full bg-foreground-soft select-none" }), Array.from({ length: count }, (_, index) => (_jsx(BaseSlider.Thumb, { index: index, "aria-label": thumbLabels?.[index], "data-slot": "slider-thumb", className: cn("size-[18px] cursor-grab rounded-full bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent select-none", "shadow-thumb", "transition-[background-color,box-shadow] duration-(--duration) ease-brand", "hover:not-data-disabled:bg-control-hover data-dragging:cursor-grabbing",
127
+ const locale = useLocale();
128
+ return (_jsxs(BaseSlider.Root, { ref: refs, "data-slot": "slider", thumbAlignment: thumbAlignment, className: sx("group/slider flex w-full flex-col gap-2 data-[orientation=vertical]:h-full data-[orientation=vertical]:w-auto data-disabled:[&>[data-slot=slider-control]]:opacity-55", className), locale: locale, ...props, children: [hasHeader && (_jsxs("div", { "data-slot": "slider-header", className: "flex items-baseline justify-between gap-4", children: [label != null && (_jsx(BaseSlider.Label, { "data-slot": "slider-label", className: "text-sm leading-snug font-medium text-foreground select-none group-data-disabled/slider:text-foreground-soft", children: label })), showValue && (_jsx(BaseSlider.Value, { "data-slot": "slider-value", className: "ms-auto font-mono text-xs text-muted-foreground tabular-nums group-data-disabled/slider:opacity-55", children: (formatted) => formatted.join(" – ") }))] })), _jsx(BaseSlider.Control, { ref: control, "data-slot": "slider-control", className: "flex w-full touch-none items-center py-2 select-none data-disabled:cursor-not-allowed data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-32 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col data-[orientation=vertical]:px-2 data-[orientation=vertical]:py-0", children: _jsxs(BaseSlider.Track, { "data-slot": "slider-track", className: "relative h-1.5 w-full material-field rounded-full select-none data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5", children: [_jsx(BaseSlider.Indicator, { "data-slot": "slider-indicator", className: "rounded-full bg-foreground-soft select-none" }), Array.from({ length: count }, (_, index) => (_jsx(BaseSlider.Thumb, { index: index, "aria-label": thumbLabels?.[index], "data-slot": "slider-thumb", className: cn("size-[18px] cursor-grab rounded-full bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent select-none", "shadow-thumb", "transition-[background-color,box-shadow] duration-(--duration) ease-brand", "hover:not-data-disabled:bg-control-hover data-dragging:cursor-grabbing",
127
129
  // Held, it takes the hover fill; with `squash`, dragged, it squashes and stretches (useSquash).
128
130
  "active:not-data-disabled:bg-control-hover data-dragging:bg-control-hover", "has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-0 has-[:focus-visible]:outline-control-focus", "data-disabled:cursor-not-allowed") }, index))), children] }) })] }, resetKey));
129
131
  }