@42-central/ui-react 0.25.0 → 0.27.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 (232) hide show
  1. package/dist/{chunk-YZJUPYPO.js → chunk-2W7H43WL.js} +3 -3
  2. package/dist/{chunk-YZJUPYPO.js.map → chunk-2W7H43WL.js.map} +1 -1
  3. package/dist/{chunk-NLSJ6T7V.js → chunk-4D2V4JE4.js} +3 -3
  4. package/dist/{chunk-NLSJ6T7V.js.map → chunk-4D2V4JE4.js.map} +1 -1
  5. package/dist/{chunk-QZ4N5LYG.js → chunk-5H5YOPCF.js} +3 -3
  6. package/dist/{chunk-QZ4N5LYG.js.map → chunk-5H5YOPCF.js.map} +1 -1
  7. package/dist/{chunk-6II2DVYR.js → chunk-7KFUFAVP.js} +4 -4
  8. package/dist/{chunk-6II2DVYR.js.map → chunk-7KFUFAVP.js.map} +1 -1
  9. package/dist/{chunk-XUFCI262.js → chunk-7OGZT7U2.js} +12 -4
  10. package/dist/chunk-7OGZT7U2.js.map +1 -0
  11. package/dist/{chunk-PI7X5YFJ.js → chunk-BGDVUC3B.js} +5 -5
  12. package/dist/{chunk-PI7X5YFJ.js.map → chunk-BGDVUC3B.js.map} +1 -1
  13. package/dist/{chunk-7247WBTV.js → chunk-DJ72KP32.js} +3 -3
  14. package/dist/{chunk-7247WBTV.js.map → chunk-DJ72KP32.js.map} +1 -1
  15. package/dist/{chunk-FZSLSUSX.js → chunk-HCHGERDB.js} +3 -3
  16. package/dist/{chunk-FZSLSUSX.js.map → chunk-HCHGERDB.js.map} +1 -1
  17. package/dist/{chunk-H7WOMZXO.js → chunk-HWBFRDX7.js} +16 -8
  18. package/dist/chunk-HWBFRDX7.js.map +1 -0
  19. package/dist/{chunk-HQPU73WV.js → chunk-I4IJOLNA.js} +4 -4
  20. package/dist/{chunk-HQPU73WV.js.map → chunk-I4IJOLNA.js.map} +1 -1
  21. package/dist/{chunk-UDCCOUWR.js → chunk-IA6DCC3N.js} +6 -6
  22. package/dist/{chunk-UDCCOUWR.js.map → chunk-IA6DCC3N.js.map} +1 -1
  23. package/dist/{chunk-36NWC4GV.js → chunk-ISX3AM32.js} +3 -3
  24. package/dist/{chunk-36NWC4GV.js.map → chunk-ISX3AM32.js.map} +1 -1
  25. package/dist/{chunk-LMCUGYHT.js → chunk-L24N5EON.js} +6 -6
  26. package/dist/chunk-L24N5EON.js.map +1 -0
  27. package/dist/{chunk-HRNWWL3Y.js → chunk-L5GH7LLD.js} +61 -29
  28. package/dist/chunk-L5GH7LLD.js.map +1 -0
  29. package/dist/chunk-LJVIZNPE.js +9 -0
  30. package/dist/chunk-LJVIZNPE.js.map +1 -0
  31. package/dist/{chunk-AHKMN3YQ.js → chunk-MCRTAUSZ.js} +6 -6
  32. package/dist/chunk-MCRTAUSZ.js.map +1 -0
  33. package/dist/{chunk-LHUWOA2U.js → chunk-MNYY7UU2.js} +6 -6
  34. package/dist/{chunk-LHUWOA2U.js.map → chunk-MNYY7UU2.js.map} +1 -1
  35. package/dist/{chunk-7HZBD4YZ.js → chunk-NF2PBGD3.js} +36 -23
  36. package/dist/chunk-NF2PBGD3.js.map +1 -0
  37. package/dist/{chunk-54W6VAI3.js → chunk-NNPSBC7O.js} +5 -5
  38. package/dist/{chunk-54W6VAI3.js.map → chunk-NNPSBC7O.js.map} +1 -1
  39. package/dist/{chunk-MW42XVPD.js → chunk-PBSVX5DB.js} +15 -5
  40. package/dist/chunk-PBSVX5DB.js.map +1 -0
  41. package/dist/{chunk-2CL3FKEY.js → chunk-QEMXXQQO.js} +3 -3
  42. package/dist/{chunk-2CL3FKEY.js.map → chunk-QEMXXQQO.js.map} +1 -1
  43. package/dist/{chunk-6UIQJJNJ.js → chunk-QRNQQIQM.js} +5 -5
  44. package/dist/{chunk-6UIQJJNJ.js.map → chunk-QRNQQIQM.js.map} +1 -1
  45. package/dist/{chunk-N66NC6QK.js → chunk-RKCUXOU2.js} +4 -4
  46. package/dist/{chunk-N66NC6QK.js.map → chunk-RKCUXOU2.js.map} +1 -1
  47. package/dist/{chunk-N5M4PDBK.js → chunk-SBZJGFZ6.js} +3 -3
  48. package/dist/{chunk-N5M4PDBK.js.map → chunk-SBZJGFZ6.js.map} +1 -1
  49. package/dist/{chunk-7P32XCEU.js → chunk-SLUOF7XW.js} +2 -2
  50. package/dist/chunk-SLUOF7XW.js.map +1 -0
  51. package/dist/{chunk-SAXWCGWR.js → chunk-SOUDKESO.js} +14 -7
  52. package/dist/chunk-SOUDKESO.js.map +1 -0
  53. package/dist/{chunk-T44RW5DW.js → chunk-ULF5LOBS.js} +4 -4
  54. package/dist/{chunk-T44RW5DW.js.map → chunk-ULF5LOBS.js.map} +1 -1
  55. package/dist/components/ambient-background/index.js +9 -23
  56. package/dist/components/ambient-background/index.js.map +1 -1
  57. package/dist/components/ambient-background/starfield.d.ts.map +1 -1
  58. package/dist/components/app-shell/app-shell.d.ts +55 -10
  59. package/dist/components/app-shell/app-shell.d.ts.map +1 -1
  60. package/dist/components/app-shell/index.d.ts +1 -1
  61. package/dist/components/app-shell/index.d.ts.map +1 -1
  62. package/dist/components/app-shell/index.js +299 -38
  63. package/dist/components/app-shell/index.js.map +1 -1
  64. package/dist/components/autocomplete/index.js +4 -4
  65. package/dist/components/avatar/avatar.d.ts +1 -1
  66. package/dist/components/avatar/avatar.d.ts.map +1 -1
  67. package/dist/components/avatar/index.js +10 -1
  68. package/dist/components/avatar/index.js.map +1 -1
  69. package/dist/components/button-group/button-group.d.ts +10 -2
  70. package/dist/components/button-group/button-group.d.ts.map +1 -1
  71. package/dist/components/button-group/index.js +1 -1
  72. package/dist/components/button-multi-select/index.js +2 -2
  73. package/dist/components/button-select/button-select-control.d.ts +4 -1
  74. package/dist/components/button-select/button-select-control.d.ts.map +1 -1
  75. package/dist/components/button-select/button-select.d.ts +4 -1
  76. package/dist/components/button-select/button-select.d.ts.map +1 -1
  77. package/dist/components/button-select/index.js +2 -2
  78. package/dist/components/calendar-heatmap/index.js +2 -2
  79. package/dist/components/camera/index.js +6 -6
  80. package/dist/components/code-block/chrome.js +5 -5
  81. package/dist/components/code-block/index.js +6 -6
  82. package/dist/components/combobox/index.js +4 -4
  83. package/dist/components/combobox-list/index.js +6 -6
  84. package/dist/components/data-table/data-table-features.d.ts +8 -0
  85. package/dist/components/data-table/data-table-features.d.ts.map +1 -1
  86. package/dist/components/data-table/data-table-group.d.ts +128 -0
  87. package/dist/components/data-table/data-table-group.d.ts.map +1 -0
  88. package/dist/components/data-table/data-table-grouping.d.ts +72 -0
  89. package/dist/components/data-table/data-table-grouping.d.ts.map +1 -0
  90. package/dist/components/data-table/data-table-icons.d.ts +4 -2
  91. package/dist/components/data-table/data-table-icons.d.ts.map +1 -1
  92. package/dist/components/data-table/data-table-meta.d.ts +9 -0
  93. package/dist/components/data-table/data-table-meta.d.ts.map +1 -1
  94. package/dist/components/data-table/data-table-pagination.d.ts +4 -1
  95. package/dist/components/data-table/data-table-pagination.d.ts.map +1 -1
  96. package/dist/components/data-table/data-table-schema.d.ts +4 -0
  97. package/dist/components/data-table/data-table-schema.d.ts.map +1 -1
  98. package/dist/components/data-table/data-table-stack.d.ts +16 -3
  99. package/dist/components/data-table/data-table-stack.d.ts.map +1 -1
  100. package/dist/components/data-table/data-table-toolbar.d.ts +33 -2
  101. package/dist/components/data-table/data-table-toolbar.d.ts.map +1 -1
  102. package/dist/components/data-table/data-table-translations.d.ts +35 -0
  103. package/dist/components/data-table/data-table-translations.d.ts.map +1 -1
  104. package/dist/components/data-table/data-table.d.ts +55 -3
  105. package/dist/components/data-table/data-table.d.ts.map +1 -1
  106. package/dist/components/data-table/index.d.ts +3 -1
  107. package/dist/components/data-table/index.d.ts.map +1 -1
  108. package/dist/components/data-table/index.js +878 -230
  109. package/dist/components/data-table/index.js.map +1 -1
  110. package/dist/components/date-picker/index.js +8 -8
  111. package/dist/components/drawer/index.js +4 -4
  112. package/dist/components/geodesic/a11y.d.ts +3 -3
  113. package/dist/components/geodesic/a11y.d.ts.map +1 -1
  114. package/dist/components/geodesic/badge-frame.d.ts +13 -1
  115. package/dist/components/geodesic/badge-frame.d.ts.map +1 -1
  116. package/dist/components/geodesic/exam-badge.d.ts +4 -1
  117. package/dist/components/geodesic/exam-badge.d.ts.map +1 -1
  118. package/dist/components/geodesic/geometry.d.ts +14 -9
  119. package/dist/components/geodesic/geometry.d.ts.map +1 -1
  120. package/dist/components/geodesic/index.js +62 -23
  121. package/dist/components/geodesic/index.js.map +1 -1
  122. package/dist/components/geodesic/status.d.ts +8 -6
  123. package/dist/components/geodesic/status.d.ts.map +1 -1
  124. package/dist/components/geodesic/styles.css +15 -2
  125. package/dist/components/hover-card/index.js +3 -3
  126. package/dist/components/indicator/index.js +23 -8
  127. package/dist/components/indicator/index.js.map +1 -1
  128. package/dist/components/indicator/indicator.d.ts +15 -6
  129. package/dist/components/indicator/indicator.d.ts.map +1 -1
  130. package/dist/components/kbd/index.js +3 -3
  131. package/dist/components/lightbox/index.js +4 -4
  132. package/dist/components/menu/index.js +4 -4
  133. package/dist/components/modal/index.js +4 -4
  134. package/dist/components/multi-combobox-list/index.js +6 -6
  135. package/dist/components/multi-select/index.js +4 -4
  136. package/dist/components/nav-link/index.js +5 -1
  137. package/dist/components/nav-link/nav-link.d.ts.map +1 -1
  138. package/dist/components/nav-link/tanstack.js +5 -1
  139. package/dist/components/nav-link/tanstack.js.map +1 -1
  140. package/dist/components/notification/create-notifier.d.ts.map +1 -1
  141. package/dist/components/notification/index.js +15 -3
  142. package/dist/components/notification/index.js.map +1 -1
  143. package/dist/components/notification/types.d.ts +5 -0
  144. package/dist/components/notification/types.d.ts.map +1 -1
  145. package/dist/components/number-input/index.js +4 -4
  146. package/dist/components/overlays/index.js +5 -5
  147. package/dist/components/photo-capture/index.js +6 -6
  148. package/dist/components/popover/index.js +3 -3
  149. package/dist/components/schedule/index.js +4 -4
  150. package/dist/components/segment-group/index.js +1 -1
  151. package/dist/components/segment-group/segment-group.d.ts +6 -1
  152. package/dist/components/segment-group/segment-group.d.ts.map +1 -1
  153. package/dist/components/select/index.js +5 -5
  154. package/dist/components/spotlight/index.js +8 -8
  155. package/dist/components/tabs/index.js +1 -1
  156. package/dist/components/tabs/tabs-data.d.ts +4 -1
  157. package/dist/components/tabs/tabs-data.d.ts.map +1 -1
  158. package/dist/components/tabs/tabs.d.ts +4 -1
  159. package/dist/components/tabs/tabs.d.ts.map +1 -1
  160. package/dist/components/tags-input/index.js +3 -3
  161. package/dist/components/time-input/index.js +6 -6
  162. package/dist/components/tooltip/index.js +2 -2
  163. package/dist/components/tree-multi-select/index.js +4 -4
  164. package/dist/components/tree-select/index.js +4 -4
  165. package/dist/index.js +2 -2
  166. package/dist/lib/overlay-container.d.ts.map +1 -1
  167. package/dist/lib/overlay-layer.d.ts +10 -3
  168. package/dist/lib/overlay-layer.d.ts.map +1 -1
  169. package/dist/lib/sidebar-rail.d.ts +21 -0
  170. package/dist/lib/sidebar-rail.d.ts.map +1 -0
  171. package/dist/theme.css +21 -18
  172. package/package.json +1 -1
  173. package/src/as-child.contract.test.tsx +6 -0
  174. package/src/components/ambient-background/starfield.tsx +14 -41
  175. package/src/components/app-shell/app-shell.test.tsx +430 -5
  176. package/src/components/app-shell/app-shell.tsx +484 -24
  177. package/src/components/app-shell/index.ts +2 -0
  178. package/src/components/avatar/avatar.test.tsx +12 -0
  179. package/src/components/avatar/avatar.tsx +9 -0
  180. package/src/components/button-group/button-group.test.tsx +24 -0
  181. package/src/components/button-group/button-group.tsx +21 -4
  182. package/src/components/button-multi-select/button-multi-select.test.tsx +15 -0
  183. package/src/components/button-select/button-select-control.tsx +5 -0
  184. package/src/components/button-select/button-select.test.tsx +25 -0
  185. package/src/components/button-select/button-select.tsx +13 -2
  186. package/src/components/data-table/data-table-features.ts +11 -0
  187. package/src/components/data-table/data-table-group.test.tsx +1007 -0
  188. package/src/components/data-table/data-table-group.tsx +474 -0
  189. package/src/components/data-table/data-table-grouping.ts +160 -0
  190. package/src/components/data-table/data-table-icons.tsx +8 -1
  191. package/src/components/data-table/data-table-meta.ts +9 -0
  192. package/src/components/data-table/data-table-pagination.tsx +5 -1
  193. package/src/components/data-table/data-table-stack.tsx +165 -43
  194. package/src/components/data-table/data-table-toolbar.tsx +110 -2
  195. package/src/components/data-table/data-table-translations.ts +44 -0
  196. package/src/components/data-table/data-table.tsx +420 -150
  197. package/src/components/data-table/index.ts +4 -0
  198. package/src/components/drawer/drawer.tsx +1 -1
  199. package/src/components/geodesic/badge-frame.tsx +67 -13
  200. package/src/components/geodesic/exam-badge.tsx +8 -4
  201. package/src/components/geodesic/geometry.ts +8 -6
  202. package/src/components/geodesic/status.test.ts +11 -2
  203. package/src/components/geodesic/status.ts +11 -7
  204. package/src/components/geodesic/styles.css +15 -2
  205. package/src/components/indicator/indicator.test.tsx +45 -0
  206. package/src/components/indicator/indicator.tsx +40 -13
  207. package/src/components/modal/modal.tsx +1 -1
  208. package/src/components/nav-link/nav-link.test.tsx +121 -1
  209. package/src/components/nav-link/nav-link.tsx +78 -29
  210. package/src/components/notification/create-notifier.tsx +18 -2
  211. package/src/components/notification/notify-in-modal.test.tsx +128 -0
  212. package/src/components/notification/types.ts +5 -0
  213. package/src/components/segment-group/segment-group.test.tsx +22 -0
  214. package/src/components/segment-group/segment-group.tsx +35 -19
  215. package/src/components/tabs/tabs-data.tsx +5 -1
  216. package/src/components/tabs/tabs.test.tsx +28 -0
  217. package/src/components/tabs/tabs.tsx +14 -4
  218. package/src/lib/overlay-container.tsx +2 -1
  219. package/src/lib/overlay-layer.test.tsx +63 -1
  220. package/src/lib/overlay-layer.tsx +29 -6
  221. package/src/lib/sidebar-rail.ts +24 -0
  222. package/src/theme.css +21 -18
  223. package/src/theme.test.ts +14 -11
  224. package/dist/chunk-7HZBD4YZ.js.map +0 -1
  225. package/dist/chunk-7P32XCEU.js.map +0 -1
  226. package/dist/chunk-AHKMN3YQ.js.map +0 -1
  227. package/dist/chunk-H7WOMZXO.js.map +0 -1
  228. package/dist/chunk-HRNWWL3Y.js.map +0 -1
  229. package/dist/chunk-LMCUGYHT.js.map +0 -1
  230. package/dist/chunk-MW42XVPD.js.map +0 -1
  231. package/dist/chunk-SAXWCGWR.js.map +0 -1
  232. package/dist/chunk-XUFCI262.js.map +0 -1
@@ -6,21 +6,28 @@ import {
6
6
  createContext,
7
7
  type Dispatch,
8
8
  type MouseEvent,
9
+ type PointerEvent,
9
10
  type Ref,
11
+ type RefObject,
10
12
  type SetStateAction,
11
13
  useContext,
14
+ useEffect,
12
15
  useId,
13
16
  useRef,
14
17
  useState,
15
18
  } from "react"
19
+ import { flushSync } from "react-dom"
16
20
  import type { NoAsChild } from "../../lib/as-child"
17
21
  import { cn } from "../../lib/cn"
18
22
  import { useMergedRefs } from "../../lib/merge-refs"
19
23
  import { props } from "../../lib/props"
24
+ import { SidebarRailContext } from "../../lib/sidebar-rail"
20
25
  import type { Size } from "../../lib/sizes"
21
26
  import type { WithTestId } from "../../lib/test-id"
22
27
  import { TEXT_COLOR_CLASSES } from "../../lib/typography-size"
23
28
  import { useContainerQuery } from "../../lib/use-container-query"
29
+ import { useIsomorphicLayoutEffect } from "../../lib/use-isomorphic-layout-effect"
30
+ import { type Updater, useUncontrolled } from "../../lib/use-uncontrolled"
24
31
  import { Drawer } from "../drawer/drawer"
25
32
 
26
33
  /**
@@ -31,10 +38,14 @@ import { Drawer } from "../drawer/drawer"
31
38
  * Aside sits below Header, full height only within the remaining row,
32
39
  * beside Main. No Footer — add one only once a real consumer needs it.
33
40
  *
34
- * Sidebar is always visible on desktop — there's no way to hide it when
35
- * there's room to show it. Below `breakpoint`, it becomes an overlay
36
- * `Drawer` instead, toggled by `AppShell.SidebarTrigger` (which renders
37
- * nothing on desktop — there's nothing to toggle). Aside works
41
+ * On desktop, Sidebar is a grid column that can be collapsed — opt in by
42
+ * rendering an `AppShell.SidebarCollapseTrigger` (or driving `collapsed`):
43
+ * the column animates to zero and the sidebar slides off the start edge,
44
+ * coming back as a floating card while the pointer rests on that edge
45
+ * (fumadocs' docs sidebar behaves the same way). Below `breakpoint`, it
46
+ * becomes an overlay `Drawer` instead, toggled by `AppShell.SidebarTrigger`
47
+ * (which renders nothing on desktop — `SidebarCollapseTrigger` is its
48
+ * desktop counterpart, and renders nothing on mobile). Aside works
38
49
  * differently: it's always mounted (no JS/container-query gating at all,
39
50
  * unlike Sidebar) and purely CSS-driven — hidden below a `@xl` container
40
51
  * breakpoint, visible above it — mirroring how fumadocs' own docs layout
@@ -71,7 +82,14 @@ export type AppShellState = {
71
82
  setMobileOpen: Dispatch<SetStateAction<boolean>>
72
83
  /** Whether `AppShell` is narrower than its `breakpoint`, so Sidebar is a drawer. */
73
84
  isMobile: boolean
74
- /** Id of the mobile drawer's content, which `SidebarTrigger`'s `aria-controls` points at. */
85
+ /** Whether the desktop sidebar is collapsed. Has no effect below
86
+ * `breakpoint`, where the sidebar is a drawer either way. */
87
+ collapsed: boolean
88
+ /** Collapses or expands the desktop sidebar — e.g. from a keyboard
89
+ * shortcut. Goes through `onCollapsedChange` when `collapsed` is controlled. */
90
+ setCollapsed: (updater: Updater<boolean>) => void
91
+ /** Id of the sidebar — the drawer's content on mobile, the docked column on
92
+ * desktop — which both triggers' `aria-controls` point at. */
75
93
  sidebarId: string
76
94
  }
77
95
 
@@ -110,6 +128,14 @@ export type AppShellProps = HTMLArkProps<"div"> &
110
128
  * overlay `Drawer` instead of a grid column — measured against the
111
129
  * container itself via `ResizeObserver`, not the viewport. @default 768 */
112
130
  breakpoint?: number
131
+ /** Whether the desktop sidebar is collapsed (controlled). Ignored below
132
+ * `breakpoint`. */
133
+ collapsed?: boolean
134
+ /** Initial collapsed state (uncontrolled). @default false */
135
+ defaultCollapsed?: boolean
136
+ /** Called when a `SidebarCollapseTrigger` (or `useAppShell().setCollapsed`)
137
+ * collapses or expands the desktop sidebar. */
138
+ onCollapsedChange?: (collapsed: boolean) => void
113
139
  /** Lands on the grid root; also used internally to measure `breakpoint`
114
140
  * against the container's own width. */
115
141
  ref?: Ref<HTMLDivElement>
@@ -117,6 +143,9 @@ export type AppShellProps = HTMLArkProps<"div"> &
117
143
 
118
144
  const AppShellRoot = ({
119
145
  breakpoint = 768,
146
+ collapsed: collapsedProp,
147
+ defaultCollapsed,
148
+ onCollapsedChange,
120
149
  className,
121
150
  style,
122
151
  children,
@@ -127,14 +156,25 @@ const AppShellRoot = ({
127
156
  }: AppShellProps) => {
128
157
  const rootRef = useRef<HTMLDivElement>(null)
129
158
  const [mobileOpen, setMobileOpen] = useState(false)
159
+ const [collapsed, setCollapsed] = useUncontrolled({
160
+ value: collapsedProp,
161
+ defaultValue: defaultCollapsed,
162
+ finalValue: false,
163
+ onChange: onCollapsedChange,
164
+ })
130
165
  const isMobile = useContainerQuery(rootRef, breakpoint)
131
166
  const sidebarId = `app-shell-sidebar-${useId()}`
132
167
 
133
168
  const mergedRef = useMergedRefs(ref, rootRef)
134
169
  return (
135
- <AppShellContext.Provider value={{ mobileOpen, setMobileOpen, isMobile, sidebarId }}>
170
+ <AppShellContext.Provider
171
+ value={{ mobileOpen, setMobileOpen, isMobile, collapsed, setCollapsed, sidebarId }}
172
+ >
136
173
  <ark.div
137
- {...props({ "data-testid": testId })}
174
+ {...props({
175
+ "data-testid": testId,
176
+ "data-sidebar-collapsed": collapsed && !isMobile,
177
+ })}
138
178
  {...rest}
139
179
  ref={mergedRef}
140
180
  // The drawer is portaled out of this element in the DOM, but React
@@ -167,10 +207,35 @@ const SIDEBAR_WIDTH: Record<Size, string> = {
167
207
  xl: "w-96",
168
208
  }
169
209
 
210
+ /** The icon rail's width: exactly the expanded sidebar's icon column —
211
+ * SidebarBody's 16px padding + NavLink's 10px row padding on each side of a
212
+ * 16px icon, plus the aside's 1px end border. At this width nothing has to re-lay out on a rail: every icon
213
+ * (and the header's trigger, and the footer's avatar) sits where it does
214
+ * when expanded, so opening and closing only animates the width, with
215
+ * nothing jumping as the labels come and go. A NavLink row is then a 36px
216
+ * square by itself. */
217
+ const RAIL_WIDTH = "w-[calc(--spacing(17)+1px)]"
218
+
219
+ /** How long (ms) the pointer must stay *still* on an icon rail before it
220
+ * peeks open. Any movement past `RAIL_REST_TOLERANCE` restarts the count, so
221
+ * travelling across the icons (and reading their tooltips, 200ms) never opens
222
+ * it — only a deliberate rest does. */
223
+ const RAIL_PEEK_DELAY = 1200
224
+ /** How far (px) the pointer may drift and still count as resting — a hand on
225
+ * a mouse or trackpad is never perfectly still. */
226
+ const RAIL_REST_TOLERANCE = 4
227
+
228
+ export type AppShellSidebarCollapse = "hide" | "icons"
229
+
170
230
  export type AppShellSidebarProps = NoAsChild<HTMLArkProps<"aside">> &
171
231
  WithTestId & {
172
232
  /** Width when expanded, from the kit's Size scale. @default "md" */
173
233
  size?: Size
234
+ /** What collapsing does on desktop. `"hide"` slides the sidebar off the
235
+ * edge, peeking back as a card on hover at the edge. `"icons"` shrinks it
236
+ * to a 68px icon rail: labels turn into tooltips, and resting on the rail
237
+ * peeks the full sidebar over the page. @default "hide" */
238
+ collapse?: AppShellSidebarCollapse
174
239
  }
175
240
 
176
241
  /**
@@ -205,13 +270,22 @@ export type AppShellSidebarProps = NoAsChild<HTMLArkProps<"aside">> &
205
270
  */
206
271
  const AppShellSidebar = ({
207
272
  size = "md",
273
+ collapse = "hide",
208
274
  className,
209
275
  children,
210
276
  testId,
211
277
  asChild: _asChild,
212
278
  ...rest
213
279
  }: AppShellSidebarProps) => {
214
- const { isMobile, mobileOpen, setMobileOpen, sidebarId } = useAppShell()
280
+ const { isMobile, mobileOpen, setMobileOpen, collapsed, sidebarId } = useAppShell()
281
+ const columnRef = useRef<HTMLDivElement>(null)
282
+ const asideRef = useRef<HTMLElement>(null)
283
+ const icons = collapse === "icons"
284
+ const { peeking, restPoint, onPointerEnter, onPointerMove, onPointerLeave, onScrollActivity } =
285
+ useSidebarPeek(collapsed, columnRef, asideRef, icons ? RAIL_PEEK_DELAY : 0)
286
+ // Icons only: collapsed to the rail and not peeking.
287
+ const rail = icons && collapsed && !peeking
288
+ useRailAnchor(icons && collapsed && !isMobile, peeking, asideRef, restPoint)
215
289
 
216
290
  if (isMobile) {
217
291
  return (
@@ -232,26 +306,350 @@ const AppShellSidebar = ({
232
306
  )
233
307
  }
234
308
 
309
+ // Two layers, as in fumadocs: the column is what the grid track sizes
310
+ // itself to (and what animates to zero), while the aside is positioned
311
+ // inside it at a fixed width — so its content never reflows mid-collapse,
312
+ // and the same element can float back out as a card while collapsed.
235
313
  return (
236
- <ark.aside
237
- {...props({ "data-testid": testId })}
238
- {...rest}
314
+ <div
315
+ ref={columnRef}
316
+ id={sidebarId}
239
317
  className={cn(
240
- "[grid-area:sidebar] flex flex-col overflow-hidden",
241
- TEXT_COLOR_CLASSES.primary,
242
- // Brand-derived border/fill, matching InputBase/Popover/Modal/Drawer/Table's
243
- // own chrome (border-brand-900/20 dark:border-white/15, bg-brand-50/90
244
- // dark:bg-brand-950/85) rather than a neutral gray.
245
- "border-e border-brand-900/20 bg-brand-50/90 dark:border-white/15 dark:bg-brand-950/85",
246
- SIDEBAR_WIDTH[size],
247
- className,
318
+ "[grid-area:sidebar] relative z-10",
319
+ "transition-[width] duration-250 ease-out motion-reduce:transition-none",
320
+ collapsed ? (icons ? RAIL_WIDTH : "w-0") : SIDEBAR_WIDTH[size],
248
321
  )}
249
322
  >
250
- {children}
251
- </ark.aside>
323
+ {collapsed && !icons && (
324
+ // The hot strip along the start edge that brings the card back. Before
325
+ // the aside in the DOM so a peeking card paints over it.
326
+ <div
327
+ aria-hidden
328
+ data-sidebar-edge=""
329
+ className="absolute inset-y-0 inset-s-0 w-4"
330
+ onPointerEnter={onPointerEnter}
331
+ onPointerLeave={onPointerLeave}
332
+ />
333
+ )}
334
+ <ark.aside
335
+ {...props({
336
+ "data-testid": testId,
337
+ "data-collapsed": collapsed,
338
+ "data-peeking": peeking,
339
+ "data-sidebar-rail": rail,
340
+ })}
341
+ {...rest}
342
+ ref={asideRef}
343
+ // Off-screen links must not take Tab focus, nor be read out. A rail
344
+ // is on screen, so it stays interactive.
345
+ inert={collapsed && !icons && !peeking}
346
+ onPointerEnter={(event) => {
347
+ rest.onPointerEnter?.(event)
348
+ onPointerEnter(event)
349
+ }}
350
+ // Capture: `scroll` doesn't bubble from SidebarBody, and a wheel
351
+ // that can't scroll (at an end) is still the user scrolling.
352
+ onWheelCapture={(event) => {
353
+ rest.onWheelCapture?.(event)
354
+ onScrollActivity()
355
+ }}
356
+ onScrollCapture={(event) => {
357
+ rest.onScrollCapture?.(event)
358
+ onScrollActivity()
359
+ }}
360
+ onPointerMove={(event) => {
361
+ rest.onPointerMove?.(event)
362
+ onPointerMove(event)
363
+ }}
364
+ onPointerLeave={(event) => {
365
+ rest.onPointerLeave?.(event)
366
+ onPointerLeave(event)
367
+ }}
368
+ className={cn(
369
+ "absolute inset-y-0 inset-s-0 flex flex-col overflow-hidden",
370
+ TEXT_COLOR_CLASSES.primary,
371
+ // Brand-derived border/fill, matching InputBase/Popover/Modal/Drawer/Table's
372
+ // own chrome (border-brand-900/20 dark:border-white/15, bg-brand-50/90
373
+ // dark:bg-brand-950/85) rather than a neutral gray.
374
+ "border-e border-brand-900/20 bg-brand-50/90 dark:border-white/15 dark:bg-brand-950/85",
375
+ "transition-[width,translate,inset-block,border-radius,box-shadow] duration-250 ease-out motion-reduce:transition-none",
376
+ rail ? RAIL_WIDTH : SIDEBAR_WIDTH[size],
377
+ // A peeking rail widens in place, over the page.
378
+ icons && peeking && "shadow-lg backdrop-blur-sm",
379
+ collapsed &&
380
+ !icons && [
381
+ // Collapsed, it's a floating panel over scrolling content — so it
382
+ // takes Popover's blur, which the docked column doesn't need.
383
+ "inset-y-2 rounded-xl border backdrop-blur-sm",
384
+ peeking
385
+ ? "translate-x-2 shadow-lg rtl:-translate-x-2"
386
+ : "-translate-x-full rtl:translate-x-full",
387
+ ],
388
+ className,
389
+ )}
390
+ >
391
+ <SidebarRailContext.Provider value={icons ? { active: rail } : null}>
392
+ {children}
393
+ </SidebarRailContext.Provider>
394
+ </ark.aside>
395
+ </div>
252
396
  )
253
397
  }
254
398
 
399
+ /** Pointer-leave grace period (ms) when the pointer leaves near the shell's
400
+ * edge — overshooting the window edge shouldn't snap the card shut. */
401
+ const PEEK_LEAVE_DELAY = 500
402
+ /** How close to the shell's edge (px) a pointer-leave counts as "near". */
403
+ const PEEK_EDGE_DISTANCE = 100
404
+
405
+ /**
406
+ * Hover-to-peek for a collapsed sidebar, ported from fumadocs'
407
+ * `SidebarContent`. Entering the edge strip (or the card itself) shows the
408
+ * card; leaving hides it — at once when the pointer heads into the page, after
409
+ * a grace period when it leaves near the edge. An icon rail (`enterDelay`)
410
+ * instead waits for the pointer to come to rest: the count restarts whenever
411
+ * it moves more than `RAIL_REST_TOLERANCE`, and leaving cancels it. Touch is
412
+ * ignored (there is no hover to end it), and so is arming while the aside is
413
+ * still animating —
414
+ * otherwise collapsing with the pointer over the sidebar would peek it right
415
+ * back. Leaving is never ignored, so a card can't get stuck open.
416
+ */
417
+ function useSidebarPeek(
418
+ collapsed: boolean,
419
+ columnRef: RefObject<HTMLElement | null>,
420
+ asideRef: RefObject<HTMLElement | null>,
421
+ /** How long the pointer must stay before the card shows — 0 at the hide
422
+ * mode's edge strip, a dwell on an icon rail, where hovering an icon
423
+ * should show its tooltip first. */
424
+ enterDelay: number,
425
+ ) {
426
+ const [hovered, setHovered] = useState(false)
427
+ const [wasCollapsed, setWasCollapsed] = useState(collapsed)
428
+ const timer = useRef<number | undefined>(undefined)
429
+ /** Where the pointer was when the current rest began; null when not armed. */
430
+ const restOrigin = useRef<{ x: number; y: number } | null>(null)
431
+ /** Where the pointer rested when the rail last peeked open. */
432
+ const restPoint = useRef<{ x: number; y: number } | null>(null)
433
+
434
+ // Any collapse or expand starts from a hidden card.
435
+ if (wasCollapsed !== collapsed) {
436
+ setWasCollapsed(collapsed)
437
+ setHovered(false)
438
+ }
439
+ useEffect(() => () => window.clearTimeout(timer.current), [])
440
+
441
+ const ignored = (event: PointerEvent<HTMLElement>) =>
442
+ !collapsed ||
443
+ event.pointerType === "touch" ||
444
+ (asideRef.current?.getAnimations?.().length ?? 0) > 0
445
+
446
+ /** (Re)start the rest count from where the pointer is now. */
447
+ const armRest = (event: PointerEvent<HTMLElement>) => {
448
+ restOrigin.current = { x: event.clientX, y: event.clientY }
449
+ restartRest()
450
+ }
451
+
452
+ const restartRest = () => {
453
+ window.clearTimeout(timer.current)
454
+ timer.current = window.setTimeout(() => {
455
+ restPoint.current = restOrigin.current
456
+ restOrigin.current = null
457
+ setHovered(true)
458
+ }, enterDelay)
459
+ }
460
+
461
+ const onPointerEnter = (event: PointerEvent<HTMLElement>) => {
462
+ if (ignored(event)) return
463
+ if (enterDelay > 0) return armRest(event)
464
+ window.clearTimeout(timer.current)
465
+ setHovered(true)
466
+ }
467
+
468
+ const onPointerMove = (event: PointerEvent<HTMLElement>) => {
469
+ if (enterDelay === 0 || hovered || ignored(event)) return
470
+ const origin = restOrigin.current
471
+ // Also arms a rest the enter couldn't (the pointer was already over the
472
+ // aside when it finished animating).
473
+ if (
474
+ !origin ||
475
+ Math.hypot(event.clientX - origin.x, event.clientY - origin.y) > RAIL_REST_TOLERANCE
476
+ ) {
477
+ armRest(event)
478
+ }
479
+ }
480
+
481
+ /**
482
+ * Scrolling the rail is not resting on it, even with the pointer parked:
483
+ * the rows are sliding under it, and the one it ends on is the one the user
484
+ * means. So a wheel or scroll restarts the count, and the rail opens only
485
+ * once both the pointer *and* the list have been still — not mid-scroll, on
486
+ * whichever row happened to be passing. Only while a rest is pending (the
487
+ * pointer is over the rail), so the anchoring's own scrolling, which runs
488
+ * while open or after the pointer left, never arms one.
489
+ */
490
+ const onScrollActivity = () => {
491
+ if (enterDelay === 0 || hovered || !restOrigin.current) return
492
+ restartRest()
493
+ }
494
+
495
+ const onPointerLeave = (event: PointerEvent<HTMLElement>) => {
496
+ if (!collapsed || event.pointerType === "touch") return
497
+ restOrigin.current = null
498
+ window.clearTimeout(timer.current)
499
+ // Measured against the shell, not the viewport: AppShell may be embedded.
500
+ const shell = columnRef.current?.parentElement ?? document.documentElement
501
+ const { left, right } = shell.getBoundingClientRect()
502
+ const fromEdge = Math.min(event.clientX - left, right - event.clientX)
503
+ timer.current = window.setTimeout(
504
+ () => setHovered(false),
505
+ fromEdge > PEEK_EDGE_DISTANCE ? 0 : PEEK_LEAVE_DELAY,
506
+ )
507
+ }
508
+
509
+ return {
510
+ peeking: collapsed && hovered,
511
+ restPoint,
512
+ onPointerEnter,
513
+ onPointerMove,
514
+ onPointerLeave,
515
+ onScrollActivity,
516
+ }
517
+ }
518
+
519
+ /** The nearest scrolling ancestor of `node` inside `within` — SidebarBody,
520
+ * unless a consumer put the row in a scroller of their own. */
521
+ function scrollerOf(node: Element, within: Element): HTMLElement | null {
522
+ for (let el = node.parentElement; el && el !== within; el = el.parentElement) {
523
+ const { overflowY } = getComputedStyle(el)
524
+ if (overflowY === "auto" || overflowY === "scroll") return el
525
+ }
526
+ return null
527
+ }
528
+
529
+ /** Longest gap (ms) between wheel events that still counts as one stream —
530
+ * trackpad momentum fires every frame or so; a new, deliberate scroll starts
531
+ * after a pause. */
532
+ const WHEEL_STREAM_GAP = 150
533
+
534
+ /** Safety stop (ms) for the anchoring: it normally ends with the transition's
535
+ * own animations (width 250ms, Collapse 300ms). */
536
+ const ANCHOR_MAX_DURATION = 1000
537
+
538
+ /**
539
+ * Keeps the row under the pointer where it is while an icon rail peeks open,
540
+ * and while it closes again. Opening unfolds nested rows (NavLink's Collapse)
541
+ * above it, which would otherwise push it down and out from under the pointer;
542
+ * so every time the scroller's content resizes during the transition, the
543
+ * scroller scrolls by exactly the distance it drifted. Self-correcting (it
544
+ * re-measures against the starting position each time), it follows the
545
+ * transition until its animations finish. Meanwhile it owns the list's scroll:
546
+ * wheel events wait the ~300ms out (trackpad momentum would otherwise fight
547
+ * it).
548
+ *
549
+ * The element is picked once, under the pointer at the moment the rail opens,
550
+ * and reused on close: folding everything back above the same element walks
551
+ * the scroll back to where the rail was, so a rail is never left scrolled.
552
+ * Where the list is too short to scroll that far, it stays as close as the
553
+ * scroll allows.
554
+ */
555
+ function useRailAnchor(
556
+ enabled: boolean,
557
+ peeking: boolean,
558
+ asideRef: RefObject<HTMLElement | null>,
559
+ restPoint: RefObject<{ x: number; y: number } | null>,
560
+ ) {
561
+ const anchor = useRef<Element | null>(null)
562
+
563
+ // A layout effect: it runs before the first frame of the transition paints,
564
+ // while everything still sits where it did, so the starting position is
565
+ // the true pre-open one.
566
+ useIsomorphicLayoutEffect(() => {
567
+ const aside = asideRef.current
568
+ if (!enabled || !aside) return
569
+ if (peeking) {
570
+ const point = restPoint.current
571
+ const hit = point ? document.elementFromPoint?.(point.x, point.y) : null
572
+ anchor.current = hit && aside.contains(hit) ? hit : null
573
+ }
574
+ const target = anchor.current
575
+ if (!peeking) anchor.current = null
576
+ if (!target?.isConnected) return
577
+ const scroller = scrollerOf(target, aside)
578
+ if (!scroller) return
579
+
580
+ const top = target.getBoundingClientRect().top
581
+ // No "a scroll we didn't make means the user took over" check: the
582
+ // browser makes some itself. Scrolled to the bottom, anything that changes
583
+ // the scroller's height mid-transition (a footer whose text rewraps as the
584
+ // rail widens) clamps the scroll and fires one, and treating that as the
585
+ // user dropped the correction halfway, at random. The wheel is held below,
586
+ // and nothing else scrolls a sidebar in a 300ms window.
587
+ const correct = () => {
588
+ const drift = target.getBoundingClientRect().top - top
589
+ if (drift !== 0) scroller.scrollTop += drift
590
+ }
591
+ // A ResizeObserver, not requestAnimationFrame: its callbacks run after
592
+ // layout and before paint, so each frame is corrected before it's drawn.
593
+ // rAF runs before layout, sees the previous frame, and always lags one —
594
+ // visible as a jolt on Collapse's fast-starting first frame.
595
+ const observer = new ResizeObserver(correct)
596
+ // The scroller too, not just its content: its own height changing (a
597
+ // footer rewrapping) can move the row as well.
598
+ observer.observe(scroller)
599
+ for (const child of scroller.children) observer.observe(child)
600
+ // The browser's own scroll anchoring would adjust the same scroll from its
601
+ // own anchor node; keep it out while this one runs.
602
+ const overflowAnchor = scroller.style.overflowAnchor
603
+ scroller.style.overflowAnchor = "none"
604
+ // Wheel scrolling waits out the transition (~300ms), and any wheel stream
605
+ // already running through it. A trackpad keeps sending momentum wheel
606
+ // events for a second or more after a flick: the user has stopped
607
+ // scrolling, but the events still scroll the list (which, corrected, is no
608
+ // longer resting against the edge that absorbed them), and nothing in a
609
+ // WheelEvent tells inertia from intent. Letting them through dragged the
610
+ // row out from under the pointer, at random. Momentum is one unbroken
611
+ // stream, so the first wheel event after a pause is the user's again.
612
+ let stopped = false
613
+ let lastWheel = Number.NEGATIVE_INFINITY
614
+ const holdWheel = (event: WheelEvent) => {
615
+ const continuing = event.timeStamp - lastWheel < WHEEL_STREAM_GAP
616
+ lastWheel = event.timeStamp
617
+ if (!stopped || continuing) event.preventDefault()
618
+ else releaseWheel()
619
+ }
620
+ const releaseWheel = () => scroller.removeEventListener("wheel", holdWheel)
621
+ const stop = () => {
622
+ if (stopped) return
623
+ stopped = true
624
+ observer.disconnect()
625
+ scroller.style.overflowAnchor = overflowAnchor
626
+ }
627
+ scroller.addEventListener("wheel", holdWheel, { passive: false })
628
+ // Done once the transition is: reading the animations here also flushes
629
+ // the style change, so the width and Collapse transitions already exist.
630
+ // Without getAnimations, only the timeout ends it.
631
+ let settle = 0
632
+ if (aside.getAnimations) {
633
+ const running = aside.getAnimations({ subtree: true })
634
+ Promise.allSettled(running.map((animation) => animation.finished)).then(() => {
635
+ // One frame late, on purpose. `finished` resolves at the start of the
636
+ // final frame, before that frame lays out the animations' end values;
637
+ // stopping right away skipped the last few px of the unfold, leaving
638
+ // the row 3px off (more or less, by frame timing). The next frame's
639
+ // rAF runs after that layout and its ResizeObserver correction.
640
+ settle = requestAnimationFrame(stop)
641
+ })
642
+ }
643
+ const timeout = window.setTimeout(stop, ANCHOR_MAX_DURATION)
644
+ return () => {
645
+ stop()
646
+ releaseWheel()
647
+ window.clearTimeout(timeout)
648
+ cancelAnimationFrame(settle)
649
+ }
650
+ }, [enabled, peeking])
651
+ }
652
+
255
653
  // Shared by SidebarHeader and Header so the two sit at the same height and
256
654
  // Header's bottom border lines up level with SidebarHeader's own bottom edge
257
655
  // — sizing each off its own padding + content independently (the original
@@ -274,7 +672,8 @@ const AppShellSidebarHeader = ({ className, testId, ...rest }: AppShellSidebarHe
274
672
  export type AppShellSidebarBodyProps = ComponentPropsWithoutRef<"div"> & WithTestId
275
673
 
276
674
  /**
277
- * The scroll region — the only part of Sidebar that scrolls. The mask fades
675
+ * The scroll region — the only part of Sidebar that scrolls. On an icon rail
676
+ * its scrollbar is hidden (no room for one). The mask fades
278
677
  * content at the top/bottom edges instead of clipping it on a hard line
279
678
  * (fumadocs' own docs sidebar uses the same static mask on its nav
280
679
  * viewport); `overscroll-contain` stops scrolling the list from chaining
@@ -284,6 +683,10 @@ const AppShellSidebarBody = ({ className, testId, ...rest }: AppShellSidebarBody
284
683
  <div
285
684
  className={cn(
286
685
  "min-h-0 flex-1 overflow-y-auto overscroll-contain p-4",
686
+ // A classic (non-overlay) scrollbar would take ~15px of a 68px rail and
687
+ // push the icons off-centre. The rail still scrolls by wheel, touch and
688
+ // focus, and the edge mask below still shows there's more.
689
+ "sidebar-rail:[scrollbar-width:none]",
287
690
  "[mask-image:linear-gradient(to_bottom,transparent,black_12px,black_calc(100%-12px),transparent)]",
288
691
  className,
289
692
  )}
@@ -507,8 +910,9 @@ const AppShellAside = ({ size = "md", className, testId, ...rest }: AppShellAsid
507
910
  export type AppShellSidebarTriggerProps = HTMLArkProps<"button"> & WithTestId
508
911
 
509
912
  /**
510
- * Opens/closes the mobile `Drawer`. Renders nothing above `breakpoint` —
511
- * Sidebar is always visible on desktop, so there's nothing to toggle.
913
+ * Opens/closes the mobile `Drawer`. Renders nothing above `breakpoint`,
914
+ * where the sidebar is a grid column — `SidebarCollapseTrigger` is the
915
+ * desktop counterpart that collapses it.
512
916
  * `asChild`-able, like every other kit trigger. Carries `aria-expanded` and
513
917
  * `aria-controls` (the drawer's content), like any disclosure button.
514
918
  */
@@ -532,12 +936,68 @@ const AppShellSidebarTrigger = ({ onClick, testId, ...rest }: AppShellSidebarTri
532
936
  )
533
937
  }
534
938
 
939
+ export type AppShellSidebarCollapseTriggerProps = HTMLArkProps<"button"> & WithTestId
940
+
941
+ /**
942
+ * Collapses/expands the desktop sidebar — `SidebarTrigger`'s desktop
943
+ * counterpart, and its mirror image: renders nothing below `breakpoint`,
944
+ * where the sidebar is a drawer and there's nothing to collapse. Rendering one
945
+ * is what opts a shell into collapsing. `asChild`-able; carries
946
+ * `aria-expanded`, `aria-controls` and `data-collapsed`.
947
+ *
948
+ * Usually rendered twice: in `SidebarHeader` to collapse, and in `Header` to
949
+ * expand again (the one in the sidebar slides away with it) — the Header one
950
+ * often only while `useAppShell().collapsed`. Collapsing from the one inside
951
+ * the sidebar hands focus to a collapse trigger outside it, including one
952
+ * that only just rendered, since the collapsed sidebar is `inert` and would
953
+ * otherwise drop focus on the floor.
954
+ */
955
+ const AppShellSidebarCollapseTrigger = ({
956
+ onClick,
957
+ testId,
958
+ ...rest
959
+ }: AppShellSidebarCollapseTriggerProps) => {
960
+ const { isMobile, collapsed, setCollapsed, sidebarId } = useAppShell()
961
+
962
+ if (isMobile) return null
963
+
964
+ return (
965
+ <ark.button
966
+ type="button"
967
+ aria-expanded={!collapsed}
968
+ aria-controls={sidebarId}
969
+ data-app-shell-collapse-trigger=""
970
+ {...props({ "data-testid": testId, "data-collapsed": collapsed })}
971
+ {...rest}
972
+ onClick={(event) => {
973
+ onClick?.(event)
974
+ const button = event.currentTarget
975
+ // Commit synchronously, so a trigger that only renders while
976
+ // collapsed (an "expand" button in Header) exists to take focus.
977
+ flushSync(() => setCollapsed((value) => !value))
978
+ // Collapsed out of sight (`collapse="hide"`), the sidebar is now
979
+ // inert and this button with it. A rail stays usable, so focus stays.
980
+ const sidebar = document.getElementById(sidebarId)
981
+ if (sidebar && button.closest("[inert]")) {
982
+ const outside = [
983
+ ...(sidebar.parentElement?.querySelectorAll<HTMLElement>(
984
+ "[data-app-shell-collapse-trigger]",
985
+ ) ?? []),
986
+ ].find((trigger) => !sidebar.contains(trigger))
987
+ outside?.focus()
988
+ }
989
+ }}
990
+ />
991
+ )
992
+ }
993
+
535
994
  export const AppShell = Object.assign(AppShellRoot, {
536
995
  Sidebar: AppShellSidebar,
537
996
  SidebarHeader: AppShellSidebarHeader,
538
997
  SidebarBody: AppShellSidebarBody,
539
998
  SidebarFooter: AppShellSidebarFooter,
540
999
  SidebarTrigger: AppShellSidebarTrigger,
1000
+ SidebarCollapseTrigger: AppShellSidebarCollapseTrigger,
541
1001
  Header: AppShellHeader,
542
1002
  Main: AppShellMain,
543
1003
  Full: AppShellFull,
@@ -10,6 +10,8 @@ export {
10
10
  type AppShellMainSize,
11
11
  type AppShellProps,
12
12
  type AppShellSidebarBodyProps,
13
+ type AppShellSidebarCollapse,
14
+ type AppShellSidebarCollapseTriggerProps,
13
15
  type AppShellSidebarFooterProps,
14
16
  type AppShellSidebarHeaderProps,
15
17
  type AppShellSidebarProps,
@@ -40,6 +40,18 @@ describe("Avatar", () => {
40
40
  expect(root.className).toContain("[--avatar-r:32]")
41
41
  })
42
42
 
43
+ it.each([
44
+ ["2xl", "size-22", "[--avatar-r:44]"],
45
+ ["3xl", "size-32", "[--avatar-r:64]"],
46
+ ] as const)("supports the larger %s step, with its own --avatar-r", (size, box, radius) => {
47
+ const { container } = render(<Avatar size={size} name="Ada Lovelace" />)
48
+ const classes = (container.firstElementChild as HTMLElement).className.split(/\s+/)
49
+ expect(classes).toContain(box)
50
+ expect(classes).toContain(radius)
51
+ // The md default's box doesn't survive alongside the requested step.
52
+ expect(classes).not.toContain("size-10")
53
+ })
54
+
43
55
  it("writes --avatar-corner-r for any non-circular radius, omits it for full", () => {
44
56
  const rounded = render(<Avatar radius="md" />).container.firstElementChild as HTMLElement
45
57
  const full = render(<Avatar radius="full" />).container.firstElementChild as HTMLElement