@exegia/corpora-ui 0.15.0 → 0.16.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.
- package/dist-lib/components/blocks/shell/type.d.ts +4 -0
- package/dist-lib/components/motion/animated-sidebar.d.ts +2 -2
- package/dist-lib/index.js +3 -3
- package/dist-lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/blocks/shell/__tests__/shell-layout.test.tsx +19 -0
- package/src/components/blocks/shell/shell-layout.tsx +6 -2
- package/src/components/blocks/shell/type.ts +4 -0
- package/src/components/motion/animated-sidebar.tsx +4 -4
package/package.json
CHANGED
|
@@ -73,6 +73,25 @@ describe("ShellLayout", () => {
|
|
|
73
73
|
expect(leftRail().getAttribute("data-state")).toBe("collapsed")
|
|
74
74
|
})
|
|
75
75
|
|
|
76
|
+
test("a panel's trigger node replaces the default icon, keeping the toggle", async () => {
|
|
77
|
+
const user = userEvent.setup()
|
|
78
|
+
render(
|
|
79
|
+
<ShellLayout
|
|
80
|
+
panels={{
|
|
81
|
+
...PANELS,
|
|
82
|
+
right: { ...PANELS.right!, trigger: <span>Custom trigger</span> },
|
|
83
|
+
}}
|
|
84
|
+
variant="web"
|
|
85
|
+
/>
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
const rightTrigger = screen.getByRole("button", { name: "Toggle panel" })
|
|
89
|
+
expect(rightTrigger.textContent).toContain("Custom trigger")
|
|
90
|
+
|
|
91
|
+
await user.click(rightTrigger)
|
|
92
|
+
expect(rightDrawer().getAttribute("data-state")).toBe("expanded")
|
|
93
|
+
})
|
|
94
|
+
|
|
76
95
|
test("a panel's own open flag seeds its side's initial state", () => {
|
|
77
96
|
render(
|
|
78
97
|
<ShellLayout
|
|
@@ -65,12 +65,16 @@ export function ShellLayout({
|
|
|
65
65
|
<header className="flex h-16 items-center justify-between gap-3 px-4 sm:px-6">
|
|
66
66
|
<div className="flex min-w-0 items-center gap-3">
|
|
67
67
|
<AnimatedSidebarTrigger>
|
|
68
|
-
|
|
68
|
+
{panels?.left?.trigger ?? (
|
|
69
|
+
<MotionIcon name="PanelLeft" size={24} animation="press" />
|
|
70
|
+
)}
|
|
69
71
|
</AnimatedSidebarTrigger>
|
|
70
72
|
</div>
|
|
71
73
|
<div className="flex shrink-0 items-center gap-3">
|
|
72
74
|
<AnimatedSidebarTrigger aria-label="Toggle panel" side="right">
|
|
73
|
-
|
|
75
|
+
{panels?.right?.trigger ?? (
|
|
76
|
+
<MotionIcon name="PanelRight" size={24} animation="press" />
|
|
77
|
+
)}
|
|
74
78
|
</AnimatedSidebarTrigger>
|
|
75
79
|
</div>
|
|
76
80
|
</header>
|
|
@@ -23,6 +23,10 @@ export interface IPanel {
|
|
|
23
23
|
id: string
|
|
24
24
|
name: string
|
|
25
25
|
component: ReactNode
|
|
26
|
+
/** Replaces the default icon inside the panel's header trigger. The shell
|
|
27
|
+
* keeps the trigger button itself (toggle wiring, aria-label) — this only
|
|
28
|
+
* swaps what renders inside it. */
|
|
29
|
+
trigger?: ReactNode
|
|
26
30
|
open: boolean
|
|
27
31
|
defaultOpen?: boolean
|
|
28
32
|
side: "left" | "bottom" | "right" | "sidebar"
|
|
@@ -31,7 +31,7 @@ import { EASE_DRAWER, EASE_OUT, SPRING_LAYOUT, SPRING_PRESS } from "@/lib/ease"
|
|
|
31
31
|
import { cn } from "@/lib/utils"
|
|
32
32
|
|
|
33
33
|
export type SidebarSide = "left" | "right"
|
|
34
|
-
/** Open flags keyed by side. Sides left out stay uncontrolled / at their
|
|
34
|
+
/** Open flags keyed by the side. Sides left out stay uncontrolled / at their
|
|
35
35
|
* default — there is no per-side prop, the record IS the API. */
|
|
36
36
|
export type SidebarOpenState = Partial<Record<SidebarSide, boolean>>
|
|
37
37
|
type SidebarVariant = "sidebar" | "floating" | "inset"
|
|
@@ -198,7 +198,7 @@ type SidebarProviderStyle = CSSProperties & {
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
export interface AnimatedSidebarProviderProps extends HTMLAttributes<HTMLDivElement> {
|
|
201
|
-
/** Controlled desktop open state, keyed by side. A side left undefined
|
|
201
|
+
/** Controlled desktop open state, keyed by the side. A side left undefined
|
|
202
202
|
* stays uncontrolled. */
|
|
203
203
|
open?: SidebarOpenState
|
|
204
204
|
/** Initial desktop open state, merged over `{ left: true, right: false }`. */
|
|
@@ -572,7 +572,7 @@ export const AnimatedSidebar = forwardRef<HTMLElement, AnimatedSidebarProps>(
|
|
|
572
572
|
className={cn(
|
|
573
573
|
"group/sidebar relative hidden h-auto shrink-0 will-change-[width] md:block",
|
|
574
574
|
"peer flex!",
|
|
575
|
-
// The
|
|
575
|
+
// The off canvas panel keeps its full width and slides out of the
|
|
576
576
|
// zero-width rail, so clip it rather than letting it bleed past the
|
|
577
577
|
// shell edge. The clip margin lets the panel's own shadow escape
|
|
578
578
|
// without letting the slid-out panel escape with it
|
|
@@ -594,7 +594,7 @@ export const AnimatedSidebar = forwardRef<HTMLElement, AnimatedSidebarProps>(
|
|
|
594
594
|
transition={context.reduce ? REDUCED_TRANSITION : PANEL_TRANSITION}
|
|
595
595
|
className={cn(
|
|
596
596
|
"sticky top-0 flex h-svh w-full flex-col overflow-hidden",
|
|
597
|
-
collapsible === "offcanvas" && "w-
|
|
597
|
+
collapsible === "offcanvas" && "w-(--sidebar-width)",
|
|
598
598
|
|
|
599
599
|
variant === "floating" && "m-2 h-[calc(100svh-1rem)]",
|
|
600
600
|
variant === "inset" && "m-2 h-[calc(100svh-1rem)]",
|