@exegia/corpora-ui 0.17.0 → 0.19.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 (114) hide show
  1. package/dist-lib/components/blocks/nav/sidebar-block.d.ts +1 -1
  2. package/dist-lib/components/blocks/scaffold/__tests__/scaffold.test.d.ts +1 -0
  3. package/dist-lib/components/blocks/scaffold/constants.d.ts +23 -0
  4. package/dist-lib/components/blocks/scaffold/index.d.ts +27 -0
  5. package/dist-lib/components/blocks/scaffold/panel-close-button.d.ts +4 -0
  6. package/dist-lib/components/blocks/scaffold/panel-menu-button.d.ts +8 -0
  7. package/dist-lib/components/blocks/scaffold/scaffold-actions.d.ts +10 -0
  8. package/dist-lib/components/blocks/scaffold/scaffold-canvas.d.ts +7 -0
  9. package/dist-lib/components/blocks/scaffold/scaffold-context.d.ts +5 -0
  10. package/dist-lib/components/blocks/scaffold/scaffold-inspector.d.ts +9 -0
  11. package/dist-lib/components/blocks/scaffold/scaffold-main.d.ts +8 -0
  12. package/dist-lib/components/blocks/scaffold/scaffold-panel.d.ts +10 -0
  13. package/dist-lib/components/blocks/scaffold/scaffold-root.d.ts +8 -0
  14. package/dist-lib/components/blocks/scaffold/scaffold-sidebar.d.ts +7 -0
  15. package/dist-lib/components/blocks/scaffold/scaffold-sub-panel.d.ts +3 -0
  16. package/dist-lib/components/blocks/scaffold/scaffold-tab.d.ts +9 -0
  17. package/dist-lib/components/blocks/scaffold/type.d.ts +135 -0
  18. package/dist-lib/components/blocks/scaffold/use-scaffold.d.ts +8 -0
  19. package/dist-lib/components/blocks/scaffold/utils.d.ts +21 -0
  20. package/dist-lib/components/blocks/shell/animated-panel-inset.d.ts +2 -0
  21. package/dist-lib/components/blocks/shell/animated-panel-provider.d.ts +2 -0
  22. package/dist-lib/components/blocks/shell/animated-panel-trigger.d.ts +2 -0
  23. package/dist-lib/components/blocks/shell/animated-panel.d.ts +2 -0
  24. package/dist-lib/components/blocks/shell/animated-sidebar-content.d.ts +2 -0
  25. package/dist-lib/components/blocks/shell/animated-sidebar-footer.d.ts +2 -0
  26. package/dist-lib/components/blocks/shell/animated-sidebar-group-content.d.ts +2 -0
  27. package/dist-lib/components/blocks/shell/animated-sidebar-group-label.d.ts +2 -0
  28. package/dist-lib/components/blocks/shell/animated-sidebar-group.d.ts +2 -0
  29. package/dist-lib/components/blocks/shell/animated-sidebar-header.d.ts +2 -0
  30. package/dist-lib/components/blocks/shell/animated-sidebar-menu-button.d.ts +3 -0
  31. package/dist-lib/components/blocks/shell/animated-sidebar-menu-item.d.ts +2 -0
  32. package/dist-lib/components/blocks/shell/animated-sidebar-menu-sub-button.d.ts +3 -0
  33. package/dist-lib/components/blocks/shell/animated-sidebar-menu-sub-item.d.ts +2 -0
  34. package/dist-lib/components/blocks/shell/animated-sidebar-menu-sub.d.ts +2 -0
  35. package/dist-lib/components/blocks/shell/animated-sidebar-menu.d.ts +2 -0
  36. package/dist-lib/components/blocks/shell/index.d.ts +16 -0
  37. package/dist-lib/components/blocks/shell/type.d.ts +90 -4
  38. package/dist-lib/components/blocks/shell/utils.d.ts +37 -0
  39. package/dist-lib/components/motion/index.d.ts +1 -0
  40. package/dist-lib/components/motion/overflow-actions.d.ts +35 -0
  41. package/dist-lib/components/ui/button-group.d.ts +11 -0
  42. package/dist-lib/components/ui/glasscn/glass-button-group.d.ts +5 -0
  43. package/dist-lib/components/ui/glasscn/glass-container.d.ts +7 -0
  44. package/dist-lib/components/ui/glasscn/glass-separator.d.ts +5 -0
  45. package/dist-lib/components/ui/group.d.ts +17 -0
  46. package/dist-lib/components/ui/separator.d.ts +2 -3
  47. package/dist-lib/components/ui/sheet.d.ts +14 -0
  48. package/dist-lib/components/ui/tooltip.d.ts +6 -0
  49. package/dist-lib/index.d.ts +2 -1
  50. package/dist-lib/index.js +1631 -1101
  51. package/dist-lib/index.js.map +1 -1
  52. package/dist-lib/lib/ease.d.ts +3 -0
  53. package/dist-lib/lib/hooks/use-hover-capable.d.ts +6 -0
  54. package/package.json +2 -1
  55. package/src/components/beste/piece/browser-frame.tsx +2 -2
  56. package/src/components/blocks/nav/sidebar-block.tsx +5 -5
  57. package/src/components/blocks/nav/sidebar-nav-row.tsx +4 -5
  58. package/src/components/blocks/scaffold/__tests__/scaffold.test.tsx +286 -0
  59. package/src/components/blocks/scaffold/constants.ts +32 -0
  60. package/src/components/blocks/scaffold/index.ts +41 -0
  61. package/src/components/blocks/scaffold/panel-close-button.tsx +36 -0
  62. package/src/components/blocks/scaffold/panel-menu-button.tsx +218 -0
  63. package/src/components/blocks/scaffold/scaffold-actions.tsx +88 -0
  64. package/src/components/blocks/scaffold/scaffold-canvas.tsx +29 -0
  65. package/src/components/blocks/scaffold/scaffold-context.ts +18 -0
  66. package/src/components/blocks/scaffold/scaffold-inspector.tsx +80 -0
  67. package/src/components/blocks/scaffold/scaffold-main.tsx +28 -0
  68. package/src/components/blocks/scaffold/scaffold-panel.tsx +88 -0
  69. package/src/components/blocks/scaffold/scaffold-root.tsx +68 -0
  70. package/src/components/blocks/scaffold/scaffold-sidebar.tsx +31 -0
  71. package/src/components/blocks/scaffold/scaffold-sub-panel.tsx +51 -0
  72. package/src/components/blocks/scaffold/scaffold-tab.tsx +66 -0
  73. package/src/components/blocks/scaffold/type.ts +172 -0
  74. package/src/components/blocks/scaffold/use-scaffold.ts +48 -0
  75. package/src/components/blocks/scaffold/utils.ts +46 -0
  76. package/src/components/blocks/shell/animated-panel-inset.tsx +23 -0
  77. package/src/components/blocks/shell/animated-panel-provider.tsx +155 -0
  78. package/src/components/blocks/shell/animated-panel-trigger.tsx +42 -0
  79. package/src/components/blocks/shell/animated-panel.tsx +135 -0
  80. package/src/components/blocks/shell/animated-sidebar-content.tsx +19 -0
  81. package/src/components/blocks/shell/animated-sidebar-footer.tsx +19 -0
  82. package/src/components/blocks/shell/animated-sidebar-group-content.tsx +16 -0
  83. package/src/components/blocks/shell/animated-sidebar-group-label.tsx +29 -0
  84. package/src/components/blocks/shell/animated-sidebar-group.tsx +16 -0
  85. package/src/components/blocks/shell/animated-sidebar-header.tsx +16 -0
  86. package/src/components/blocks/shell/animated-sidebar-menu-button.tsx +151 -0
  87. package/src/components/blocks/shell/animated-sidebar-menu-item.tsx +20 -0
  88. package/src/components/blocks/shell/animated-sidebar-menu-sub-button.tsx +85 -0
  89. package/src/components/blocks/shell/animated-sidebar-menu-sub-item.tsx +19 -0
  90. package/src/components/blocks/shell/animated-sidebar-menu-sub.tsx +44 -0
  91. package/src/components/blocks/shell/animated-sidebar-menu.tsx +26 -0
  92. package/src/components/blocks/shell/index.ts +18 -0
  93. package/src/components/blocks/shell/shell-layout.tsx +28 -36
  94. package/src/components/blocks/shell/type.ts +112 -6
  95. package/src/components/blocks/shell/use-shell-panels.ts +1 -1
  96. package/src/components/blocks/shell/utils.ts +142 -1
  97. package/src/components/docs/demo-controls.tsx +1 -1
  98. package/src/components/motion/index.ts +0 -0
  99. package/src/components/motion/overflow-actions.tsx +376 -0
  100. package/src/components/ui/button-group.tsx +88 -0
  101. package/src/components/ui/glasscn/glass-button-group.tsx +48 -0
  102. package/src/components/ui/glasscn/glass-container.tsx +125 -0
  103. package/src/components/ui/glasscn/glass-separator.tsx +39 -0
  104. package/src/components/ui/glasscn/liquid-glass.tsx +250 -210
  105. package/src/components/ui/group.tsx +92 -0
  106. package/src/components/ui/separator.tsx +11 -11
  107. package/src/components/ui/sheet.tsx +135 -0
  108. package/src/components/ui/tooltip.tsx +66 -0
  109. package/src/index.css +1 -1
  110. package/src/index.ts +13 -1
  111. package/src/lib/ease.ts +26 -0
  112. package/src/lib/hooks/use-hover-capable.ts +23 -0
  113. package/dist-lib/components/motion/animated-sidebar.d.ts +0 -106
  114. package/src/components/motion/animated-sidebar.tsx +0 -1171
@@ -1,3 +1,4 @@
1
+ import { Transition, Variants } from 'motion/react';
1
2
  export declare const EASE_OUT: readonly [0.16, 1, 0.3, 1];
2
3
  export declare const EASE_IN_OUT: readonly [0.77, 0, 0.175, 1];
3
4
  export declare const EASE_DRAWER: readonly [0.32, 0.72, 0, 1];
@@ -44,3 +45,5 @@ export declare const SPRING_GLIDE: {
44
45
  readonly damping: 50;
45
46
  readonly mass: 0.5;
46
47
  };
48
+ export declare const SHELL_TRANSITION: Transition;
49
+ export declare const ICON_VARIANTS: Variants;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns true only on devices that have a true hover (mouse / trackpad).
3
+ * Touch devices fire phantom `:hover` on tap that sticks until tap-elsewhere
4
+ * — gate hover-only effects (scale lifts, magnetic pulls) behind this.
5
+ */
6
+ export declare function useHoverCapable(): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exegia/corpora-ui",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
4
4
  "description": "shadcn-ready React UI library for the corpora manuscript-research apps.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -46,6 +46,7 @@
46
46
  "class-variance-authority": "^0.7.1",
47
47
  "clsx": "^2.1.1",
48
48
  "cuelume": "^0.2.1",
49
+ "iconsax-reactjs": "^0.0.8",
49
50
  "lucide-react": "^1.31.0",
50
51
  "motion": "^12.43.0",
51
52
  "motion-icons-react": "^1.1.0",
@@ -22,7 +22,7 @@ export function BrowserFrame({
22
22
  className
23
23
  )}
24
24
  >
25
- <div className="flex min-h-96 w-full flex-col overflow-hidden rounded-lg border border-border bg-neutral-50 shadow-lg dark:bg-neutral-900 relative">
25
+ <div className="flex min-h-32 w-full max-h-[500px] flex-col overflow-hidden rounded-lg border border-border bg-neutral-50 shadow-lg dark:bg-neutral-900 relative">
26
26
  <div id="title-bar" className={cn("flex flex-1 w-full items-center gap-2 px-4 py-3 z-20", titleBarStyle(titleStyle, 'title'))}>
27
27
  <div className="flex items-center gap-2" aria-hidden="true">
28
28
  <span className="size-3 cursor-pointer rounded-full bg-rose-500 shadow-md outline outline-rose-800" />
@@ -46,7 +46,7 @@ export function BrowserFrame({
46
46
  </div>
47
47
  )}
48
48
  </div>
49
- <div className={cn("flex flex-1 ", titleBarStyle(titleStyle, "frame"))}>
49
+ <div className={cn("flex flex-1", titleBarStyle(titleStyle, "frame"))}>
50
50
  {children}
51
51
  </div>
52
52
  </div>
@@ -4,7 +4,9 @@ import { PanelLeftIcon } from "lucide-react"
4
4
  import * as React from "react"
5
5
 
6
6
  import {
7
- AnimatedSidebar,
7
+ AnimatedPanel as AnimatedSidebar,
8
+ AnimatedPanelProvider as AnimatedSidebarProvider,
9
+ AnimatedPanelTrigger as AnimatedSidebarTrigger,
8
10
  AnimatedSidebarContent,
9
11
  AnimatedSidebarFooter,
10
12
  AnimatedSidebarGroup,
@@ -12,9 +14,7 @@ import {
12
14
  AnimatedSidebarGroupLabel,
13
15
  AnimatedSidebarHeader,
14
16
  AnimatedSidebarMenu,
15
- AnimatedSidebarProvider,
16
- AnimatedSidebarTrigger,
17
- } from "@/components/motion/animated-sidebar"
17
+ } from "@/components/blocks/shell"
18
18
  import { cn } from "@/lib/utils"
19
19
  import { SidebarNavRow } from "@/components/blocks/nav/sidebar-nav-row"
20
20
 
@@ -34,7 +34,7 @@ export type {
34
34
  * beside your own content. It owns its own sidebar context (⌘B toggles it);
35
35
  * pass `open`/`onOpenChange` to drive the rail, and `openMobile`/
36
36
  * `onOpenMobileChange` to open the drawer from a header button of your own.
37
- * Compose the underlying `AnimatedSidebar*` parts directly when a screen
37
+ * Compose the underlying `AnimatedPanel*` parts directly when a screen
38
38
  * needs something this API does not cover.
39
39
  */
40
40
  export function SidebarBlock({
@@ -2,16 +2,15 @@
2
2
 
3
3
  import * as React from "react"
4
4
 
5
+ import type { IRowProps, ISidebarNavItem, ISidebarNavSubItem } from "@/components/blocks/nav/types"
6
+ import { isActive } from "@/components/blocks/nav/utils"
5
7
  import {
6
8
  AnimatedSidebarMenuButton,
7
9
  AnimatedSidebarMenuItem,
8
10
  AnimatedSidebarMenuSub,
9
11
  AnimatedSidebarMenuSubButton,
10
12
  AnimatedSidebarMenuSubItem,
11
- } from "@/components/motion/animated-sidebar"
12
-
13
- import type { IRowProps, ISidebarNavItem, ISidebarNavSubItem } from "@/components/blocks/nav/types"
14
- import { isActive } from "@/components/blocks/nav/utils"
13
+ } from "@/components/blocks/shell"
15
14
 
16
15
  export function SidebarNavRow({ item, activeId, onNavigate }: IRowProps) {
17
16
  const children = item.items ?? []
@@ -76,4 +75,4 @@ export function SidebarNavRow({ item, activeId, onNavigate }: IRowProps) {
76
75
  ) : null}
77
76
  </AnimatedSidebarMenuItem>
78
77
  )
79
- }
78
+ }
@@ -0,0 +1,286 @@
1
+ import { describe, expect, mock, test } from "bun:test"
2
+ import { render, screen, waitFor } from "@testing-library/react"
3
+ import userEvent from "@testing-library/user-event"
4
+ import type { ReactNode } from "react"
5
+
6
+ import { Scaffold, useScaffold } from "../index"
7
+ import type { TScaffoldPanelChild } from "../type"
8
+
9
+ function Strip() {
10
+ return <span>Strip</span>
11
+ }
12
+
13
+ function Workspace({
14
+ onSwap,
15
+ onCloseSecondary,
16
+ onAdd,
17
+ tabs,
18
+ SecondaryPanel = <Strip />,
19
+ }: {
20
+ onSwap?: () => void
21
+ onCloseSecondary?: () => void
22
+ onAdd?: () => void
23
+ /** Rendered as Actions children — the panel tabs. */
24
+ tabs?: ReactNode
25
+ /** Pass null to render the panel without a secondary strip. */
26
+ SecondaryPanel?: TScaffoldPanelChild | null
27
+ }) {
28
+ const scaffold = useScaffold()
29
+
30
+ return (
31
+ <Scaffold.Root {...scaffold.providerProps}>
32
+ <Scaffold.Sidebar>
33
+ <button onClick={scaffold.toggleInspector} type="button">
34
+ Toggle inspector
35
+ </button>
36
+ </Scaffold.Sidebar>
37
+ <Scaffold.Main>
38
+ <Scaffold.Actions onAdd={onAdd}>{tabs}</Scaffold.Actions>
39
+ <Scaffold.Canvas>
40
+ <Scaffold.Panel
41
+ key="alpha"
42
+ name="Alpha"
43
+ onCloseSecondary={onCloseSecondary}
44
+ onSwap={onSwap}
45
+ SecondaryPanel={SecondaryPanel ?? undefined}
46
+ >
47
+ <span>Primary body</span>
48
+ </Scaffold.Panel>
49
+ </Scaffold.Canvas>
50
+ <Scaffold.Inspector>
51
+ <span>Inspector body</span>
52
+ </Scaffold.Inspector>
53
+ </Scaffold.Main>
54
+ </Scaffold.Root>
55
+ )
56
+ }
57
+
58
+ /** The seam menu's compact toggle (icon-only, named by `swapLabel`). */
59
+ const menuToggle = () =>
60
+ screen.queryByRole("button", { name: "Swap panel content" })
61
+
62
+ /** Under the id'd `#scaffold-actions` ancestor, happy-dom serves stale
63
+ * selector-cache results to `waitFor` queries that start while an
64
+ * AnimatePresence exit is still running — let the exit settle on real
65
+ * timers, then query once. */
66
+ const settleExit = () => new Promise((resolve) => setTimeout(resolve, 400))
67
+
68
+ describe("Scaffold", () => {
69
+ test("renders rail, panel surfaces and secondary strip", () => {
70
+ render(<Workspace />)
71
+
72
+ expect(screen.getByRole("navigation", { name: "Primary" })).toBeDefined()
73
+ const panel = screen.getByRole("region", { name: "Alpha" })
74
+ expect(panel.textContent).toContain("Primary body")
75
+ expect(panel.textContent).toContain("Strip")
76
+ })
77
+
78
+ test("seam menu renders only with a callback; actions stay hidden until opened", () => {
79
+ const { rerender } = render(<Workspace />)
80
+ expect(menuToggle()).toBeNull()
81
+
82
+ rerender(<Workspace onSwap={() => {}} />)
83
+ expect(menuToggle()).toBeDefined()
84
+ // Collapsed: the action segment is aria-hidden and inert.
85
+ expect(screen.queryByRole("button", { name: "Swap" })).toBeNull()
86
+
87
+ // The Close action alone also earns the menu.
88
+ rerender(<Workspace onCloseSecondary={() => {}} />)
89
+ expect(menuToggle()).toBeDefined()
90
+ })
91
+
92
+ test("seam menu Close renders only with onCloseSecondary, fires and collapses", async () => {
93
+ const user = userEvent.setup()
94
+ const onCloseSecondary = mock(() => {})
95
+
96
+ const { rerender } = render(<Workspace onSwap={() => {}} />)
97
+ await user.click(menuToggle() as HTMLElement)
98
+ expect(await screen.findByRole("button", { name: "Swap" })).toBeDefined()
99
+ expect(screen.queryByRole("button", { name: "Close" })).toBeNull()
100
+
101
+ rerender(
102
+ <Workspace onCloseSecondary={onCloseSecondary} onSwap={() => {}} />
103
+ )
104
+ await user.click(screen.getByRole("button", { name: "Close" }))
105
+ expect(onCloseSecondary).toHaveBeenCalledTimes(1)
106
+
107
+ // Acting collapses the menu back to the compact toggle.
108
+ expect(menuToggle()).toBeDefined()
109
+ expect(screen.queryByRole("button", { name: "Close" })).toBeNull()
110
+ })
111
+
112
+ test("seam menu opens; Swap fires onSwap, flips the panel and collapses the menu", async () => {
113
+ const user = userEvent.setup()
114
+ const onSwap = mock(() => {})
115
+ render(<Workspace onSwap={onSwap} />)
116
+
117
+ const panel = screen.getByRole("region", { name: "Alpha" })
118
+ expect(panel.getAttribute("data-swapped")).toBeNull()
119
+
120
+ // The compact toggle trades places with the Expand | Swap actions.
121
+ await user.click(menuToggle() as HTMLElement)
122
+ await user.click(await screen.findByRole("button", { name: "Swap" }))
123
+
124
+ expect(onSwap).toHaveBeenCalledTimes(1)
125
+ expect(panel.getAttribute("data-swapped")).toBe("")
126
+
127
+ // Acting collapses the menu back to the compact toggle; the actions
128
+ // leave with their exit animation.
129
+ expect(
130
+ await screen.findByRole("button", { name: "Swap panel content" })
131
+ ).toBeDefined()
132
+ await waitFor(() =>
133
+ expect(screen.queryByRole("button", { name: "Swap" })).toBeNull()
134
+ )
135
+ })
136
+
137
+ test("expand trades the flexible slot and flips the chevron", async () => {
138
+ const user = userEvent.setup()
139
+ render(<Workspace onSwap={() => {}} />)
140
+
141
+ const panel = screen.getByRole("region", { name: "Alpha" })
142
+ const [top, bottom] = Array.from(
143
+ panel.querySelectorAll('[data-slot^="scaffold-sub-panel"]')
144
+ )
145
+ expect(top.getAttribute("data-expanded")).toBe("")
146
+ expect(bottom.getAttribute("data-expanded")).toBeNull()
147
+
148
+ await user.click(menuToggle() as HTMLElement)
149
+ await user.click(await screen.findByRole("button", { name: "Expand" }))
150
+
151
+ expect(top.getAttribute("data-expanded")).toBeNull()
152
+ expect(bottom.getAttribute("data-expanded")).toBe("")
153
+
154
+ // Reopen: the chevron reflects the flipped state.
155
+ await user.click(
156
+ await screen.findByRole("button", { name: "Swap panel content" })
157
+ )
158
+ const expandButton = await screen.findByRole("button", { name: "Expand" })
159
+ expect(
160
+ expandButton
161
+ .querySelector("svg.lucide-chevron-down")
162
+ ?.classList.contains("rotate-180")
163
+ ).toBe(true)
164
+
165
+ // Expanding again restores the primary slot.
166
+ await user.click(expandButton)
167
+ expect(top.getAttribute("data-expanded")).toBe("")
168
+ expect(bottom.getAttribute("data-expanded")).toBeNull()
169
+ })
170
+
171
+ test("expand chevron mirrors when the panel is swapped", async () => {
172
+ const user = userEvent.setup()
173
+ render(<Workspace onSwap={() => {}} />)
174
+
175
+ // Swap first — column-reverse puts the strip visually on top.
176
+ await user.click(menuToggle() as HTMLElement)
177
+ await user.click(await screen.findByRole("button", { name: "Swap" }))
178
+
179
+ // Primary still holds the flexible slot, but the strip that grows
180
+ // next now sits on top — the chevron points up.
181
+ await user.click(
182
+ await screen.findByRole("button", { name: "Swap panel content" })
183
+ )
184
+ const expandButton = await screen.findByRole("button", { name: "Expand" })
185
+ const chevron = () => expandButton.querySelector("svg.lucide-chevron-down")
186
+ expect(chevron()?.classList.contains("rotate-180")).toBe(true)
187
+
188
+ // After expanding, the primary — now visually at the bottom — grows
189
+ // next: the chevron points down again.
190
+ await user.click(expandButton)
191
+ await user.click(
192
+ await screen.findByRole("button", { name: "Swap panel content" })
193
+ )
194
+ expect(chevron()?.classList.contains("rotate-180")).toBe(false)
195
+ })
196
+
197
+ test("seam menu needs a secondary strip", () => {
198
+ render(<Workspace onSwap={() => {}} SecondaryPanel={null} />)
199
+
200
+ expect(menuToggle()).toBeNull()
201
+ })
202
+
203
+ test("actions cluster: Add renders only with onAdd and fires", async () => {
204
+ const user = userEvent.setup()
205
+ const onAdd = mock(() => {})
206
+
207
+ // Consumers omit onAdd at SCAFFOLD_PANEL_CAPACITY — the segment hides.
208
+ const { rerender } = render(<Workspace />)
209
+ expect(screen.queryByRole("button", { name: "Panel" })).toBeNull()
210
+
211
+ rerender(<Workspace onAdd={onAdd} />)
212
+ await user.click(screen.getByRole("button", { name: "Panel" }))
213
+ expect(onAdd).toHaveBeenCalledTimes(1)
214
+
215
+ rerender(<Workspace />)
216
+ await settleExit()
217
+ expect(screen.queryByRole("button", { name: "Panel" })).toBeNull()
218
+ })
219
+
220
+ test("panel tabs show their label; close renders only with onClose and fires", async () => {
221
+ const user = userEvent.setup()
222
+ const onCloseTab = mock(() => {})
223
+
224
+ // Consumers omit onClose on the last remaining panel's tab.
225
+ const { rerender } = render(
226
+ <Workspace tabs={<Scaffold.Tab key="alpha">Alpha</Scaffold.Tab>} />
227
+ )
228
+ expect(screen.getByText("Alpha")).toBeDefined()
229
+ expect(screen.queryByRole("button", { name: "Close Alpha" })).toBeNull()
230
+
231
+ rerender(
232
+ <Workspace
233
+ tabs={
234
+ <Scaffold.Tab
235
+ key="alpha"
236
+ closeLabel="Close Alpha"
237
+ onClose={onCloseTab}
238
+ >
239
+ Alpha
240
+ </Scaffold.Tab>
241
+ }
242
+ />
243
+ )
244
+ await user.click(screen.getByRole("button", { name: "Close Alpha" }))
245
+ expect(onCloseTab).toHaveBeenCalledTimes(1)
246
+
247
+ // Closing removes the tab — it animates out of the pill.
248
+ rerender(<Workspace tabs={null} />)
249
+ await settleExit()
250
+ expect(screen.queryByText("Alpha")).toBeNull()
251
+ })
252
+
253
+ test("inspector opens from outside state and hides again", async () => {
254
+ const user = userEvent.setup()
255
+ render(<Workspace />)
256
+
257
+ const inspector = () =>
258
+ screen.getByText("Inspector body").closest("aside") as HTMLElement
259
+ expect(inspector().getAttribute("aria-hidden")).toBe("true")
260
+
261
+ await user.click(screen.getByRole("button", { name: "Toggle inspector" }))
262
+ expect(inspector().getAttribute("aria-hidden")).toBeNull()
263
+ expect(
264
+ screen.getByRole("complementary", { name: "Inspector" })
265
+ ).toBeDefined()
266
+
267
+ await user.click(screen.getByRole("button", { name: "Toggle inspector" }))
268
+ expect(inspector().getAttribute("aria-hidden")).toBe("true")
269
+ })
270
+
271
+ test("root manages inspector state itself when uncontrolled", () => {
272
+ render(
273
+ <Scaffold.Root defaultInspectorOpen>
274
+ <Scaffold.Main>
275
+ <Scaffold.Inspector>
276
+ <span>Drawer</span>
277
+ </Scaffold.Inspector>
278
+ </Scaffold.Main>
279
+ </Scaffold.Root>
280
+ )
281
+
282
+ expect(
283
+ screen.getByRole("complementary", { name: "Inspector" })
284
+ ).toBeDefined()
285
+ })
286
+ })
@@ -0,0 +1,32 @@
1
+ /** Icon-rail width in px (the rail sits directly on the desktop backdrop). */
2
+ export const SCAFFOLD_SIDEBAR_WIDTH = 64
3
+
4
+ /** Inspector drawer width in px. */
5
+ export const SCAFFOLD_INSPECTOR_WIDTH = 272
6
+
7
+ /** Most panels the canvas holds at once — omit Actions' `onAdd` when the
8
+ * count reaches it so the Add segment hides. */
9
+ export const SCAFFOLD_PANEL_CAPACITY = 3
10
+
11
+ /** Gap in px between the drawer/actions and the viewport edges. */
12
+ export const SCAFFOLD_EDGE_GUTTER = 10
13
+
14
+ /** Vertical room in px reserved above the canvas for the actions cluster. */
15
+ export const SCAFFOLD_HEADER_HEIGHT = 52
16
+
17
+ /** Height in px of a panel's secondary strip. */
18
+ export const SCAFFOLD_SECONDARY_HEIGHT = 52
19
+
20
+ /** Gap in px between a panel's primary surface and its secondary strip. */
21
+ export const SCAFFOLD_PANEL_GAP = 10
22
+
23
+ /** How long the seam menu lingers expanded after the pointer leaves it (ms)
24
+ * before it collapses back to the compact toggle. The timer keeps counting
25
+ * even when the pointer leaves the window entirely. */
26
+ export const SCAFFOLD_MENU_COLLAPSE_DELAY = 4000
27
+
28
+ /** Morph duration in seconds for drawer slides and panel layout shifts. */
29
+ export const SCAFFOLD_MORPH_DURATION = 0.3
30
+
31
+ /** `--ease-smooth-out` as a motion/react easing tuple. */
32
+ export const SCAFFOLD_EASE = [0.22, 1, 0.36, 1] as const
@@ -0,0 +1,41 @@
1
+ import { PanelCloseButton } from "./panel-close-button"
2
+ import { PanelMenuButton } from "./panel-menu-button.tsx"
3
+ import { ScaffoldActions } from "./scaffold-actions"
4
+ import { ScaffoldCanvas } from "./scaffold-canvas"
5
+ import { ScaffoldInspector } from "./scaffold-inspector"
6
+ import { ScaffoldMain } from "./scaffold-main"
7
+ import { ScaffoldPanel } from "./scaffold-panel"
8
+ import { ScaffoldRoot } from "./scaffold-root"
9
+ import { ScaffoldSidebar } from "./scaffold-sidebar"
10
+ import { ScaffoldTab } from "./scaffold-tab"
11
+ import { ScaffoldSubPanel } from "@/components/blocks/scaffold/scaffold-sub-panel.tsx"
12
+
13
+ export { useScaffoldContext } from "./scaffold-context"
14
+ export { useScaffold } from "./use-scaffold"
15
+ export type * from "./type"
16
+ export * from "./constants"
17
+
18
+ export {
19
+ PanelCloseButton,
20
+ PanelMenuButton,
21
+ ScaffoldActions,
22
+ ScaffoldCanvas,
23
+ ScaffoldInspector,
24
+ ScaffoldMain,
25
+ ScaffoldPanel,
26
+ ScaffoldRoot,
27
+ ScaffoldSidebar,
28
+ ScaffoldTab,
29
+ }
30
+
31
+ export const Scaffold = {
32
+ Root: ScaffoldRoot,
33
+ Sidebar: ScaffoldSidebar,
34
+ Main: ScaffoldMain,
35
+ Actions: ScaffoldActions,
36
+ Canvas: ScaffoldCanvas,
37
+ Panel: ScaffoldPanel,
38
+ Tab: ScaffoldTab,
39
+ Inspector: ScaffoldInspector,
40
+ SubPanel: ScaffoldSubPanel,
41
+ }
@@ -0,0 +1,36 @@
1
+ "use client"
2
+
3
+ import { RiCloseLine } from "@remixicon/react"
4
+ import * as React from "react"
5
+
6
+ import { cn } from "@/lib/utils"
7
+ import type { PanelFloatingButtonProps } from "./type"
8
+ import { floatingButtonClass, revealOnPanelHoverClass } from "./utils"
9
+
10
+ /** Floating close affordance in a panel's top-right corner. */
11
+ export function PanelCloseButton({
12
+ onClick,
13
+ label,
14
+ sound = true,
15
+ className,
16
+ }: PanelFloatingButtonProps): React.ReactElement {
17
+ return (
18
+ <button
19
+ id="scaffold-panel-close-button"
20
+ aria-label={label}
21
+ className={cn(
22
+ floatingButtonClass,
23
+ revealOnPanelHoverClass,
24
+ "absolute top-4 right-3.5 z-10",
25
+ className
26
+ )}
27
+ data-cuelume-press={sound ? "" : undefined}
28
+ data-cuelume-release={sound ? "" : undefined}
29
+ data-slot="scaffold-panel-close"
30
+ onClick={onClick}
31
+ type="button"
32
+ >
33
+ <RiCloseLine aria-hidden className="size-4" />
34
+ </button>
35
+ )
36
+ }