@softure-ai/theme-notion 0.11.1 → 0.12.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/CHANGELOG.md CHANGED
@@ -4,6 +4,17 @@ Newest first. Each version lists what changed for an app that uses the theme. Wh
4
4
  production, the version gets a line `verified in: <app>@<commit>` ([docs/05](../../docs/05-adoption-playbook.md),
5
5
  "Definition of done").
6
6
 
7
+ ## 0.12.0
8
+
9
+ - A panel slid in from the right of the app shell (#1044): `AsidePanelProvider` (replaces `SidebarProvider`, keeps
10
+ one side panel open at a time: the left sidebar folds while the panel is open on a wide screen), `AsidePanelToggle`
11
+ (fixed top-right, `aria-expanded`/`aria-controls`, `outline` closed and `secondary` open), `AsidePanel` (an `aside`
12
+ beside the content at two fifths or half the shell, a width switch, Escape and focus; a right `Sheet` on a phone,
13
+ opened for the page only), `AsidePanelSidebarOpener` (brings the sidebar back and closes the panel),
14
+ `useAsidePanel` and `isOverlayOpen(root)`. Kept state through `initialState` and `save(state)`; a failed save keeps
15
+ the choice and reaches `onSaveError`; `isHidden` for screens with no panel. Copy in `notionMessages.en.asidePanel`.
16
+ New exports only.
17
+
7
18
  ## 0.11.1
8
19
 
9
20
  - `tabsListVariants` can be called from a Server Component (#1008): the class builder of `TabsList` moved out of the
package/README.md CHANGED
@@ -74,7 +74,8 @@ import { CircleCheck } from "lucide-react";
74
74
 
75
75
  **Copy.** The components' built-in texts are accessible names in English (`notionMessages.en`). Pass the app's own
76
76
  wording by props: `Breadcrumb aria-label`, `BreadcrumbEllipsis label`, `PageHeader crumbsLabel`,
77
- `DialogContent closeLabel`, `DialogFooter closeLabel` (the `showCloseButton` button's text), `SheetContent closeLabel`, `SidePanel closeLabel`, `Steps stateLabels`,
77
+ `DialogContent closeLabel`, `DialogFooter closeLabel` (the `showCloseButton` button's text), `SheetContent closeLabel`, `SidePanel closeLabel`, `AsidePanelToggle showLabel hideLabel`,
78
+ `AsidePanel widenLabel narrowLabel closeLabel`, `AsidePanelSidebarOpener label`, `Steps stateLabels`,
78
79
  `Sidebar mobileTitle mobileDescription`, `SidebarTrigger label`, `SidebarRail label`, `Spinner aria-label`,
79
80
  `CommandDialog title description` (`title` also names its search field), `Command label` (the search field's
80
81
  name outside a `CommandDialog`; without it the field has none), `SortableList instructions announcements`, `SortableHandle label`.
@@ -131,7 +132,8 @@ sidebar, skeleton, sonner (`Toaster`), spinner, switch, table, tabs, textarea, t
131
132
  word), `PageHeader` (breadcrumb, icon box, title, description, actions), `PropertyList` (fields of one record),
132
133
  `DetailTable` (an item's details as a label and value table), `FoldRow` (a list row folding open to a `DetailTable`
133
134
  and more, a native `<details>`), `PageFrame` (a page outside the app shell, the target of `sft-bridge.css`),
134
- `SidePanel` (a non-modal panel at a side of a canvas, below), `SheetMenu`, `SheetMenuItem` and `SheetMenuButton`
135
+ `SidePanel` (a non-modal panel at a side of a canvas, below), `AsidePanelProvider`, `AsidePanelToggle`,
136
+ `AsidePanel` and `AsidePanelSidebarOpener` (a panel slid in from the right of the app shell, beside the content, below), `SheetMenu`, `SheetMenuItem` and `SheetMenuButton`
135
137
  (navigation rows in a side `Sheet`, a phone's drawer, below), `TabBar` (a screen's tabs as links with an optional icon
136
138
  and count, the shown tab in the address; `Tabs` keeps it in client state), `MarkPopover` (a counted tag that opens a
137
139
  list of what it counts, below), `FilterChip` and `FilterChipAdd` (a list's filter pills, below), `Steps` (numbered
@@ -225,6 +227,45 @@ Escape inside or the close button calls `onClose`, and the caller moves focus ba
225
227
  </div>
226
228
  ```
227
229
 
230
+ **`AsidePanel`.** A column of the app shell that slides in from the right, beside `SidebarInset`: the content
231
+ narrows next to it and stays usable (`SidePanel` is a panel over a canvas instead). `AsidePanelProvider` replaces
232
+ `SidebarProvider` (every other prop passes through) and keeps one side panel open at a time: while the panel is open
233
+ on a wide screen the left `Sidebar` (offcanvas) is folded, and opening the sidebar any way (its trigger, Ctrl+B,
234
+ `AsidePanelSidebarOpener`) closes the panel; closing the panel brings the sidebar back unless the user folded it.
235
+
236
+ - `AsidePanelToggle`: one icon button fixed at the top-right edge, in the same place open or closed, with
237
+ `aria-expanded`, `aria-controls` and a label that switches between show and hide; `outline` while closed,
238
+ `secondary` while open. Opening from it moves focus to the panel's heading (`tabIndex=-1`).
239
+ - `AsidePanel title`: an `aside` (`sticky top-0 h-dvh`, `border-l`) with a header holding the heading and a ghost
240
+ width switch: `standard` (two fifths) or `half` (the shell split half and half). Escape closes it and returns focus
241
+ to the toggle unless a dialog, menu, listbox or popover is open (`isOverlayOpen(document)`: Radix
242
+ `data-state="open"`, `:popover-open` or `dialog[open]`; a closed popover left in the page does not count).
243
+ Below `MOBILE_BREAKPOINT` it is a right `Sheet`, opened for that page only: the kept state never opens it there.
244
+ Its children render only while it is open, so pass a lazily loaded body (`next/dynamic` with `ssr: false`) and
245
+ screens that never open it never load its code.
246
+ - `AsidePanelSidebarOpener`: an icon button fixed at the top-left edge, shown only while the sidebar is folded on a
247
+ wide screen; it brings the sidebar back and closes the panel.
248
+ - Kept state: `initialState` (`{ isOpen, width }`) and `save(state)`, called after each change on a wide screen; keep
249
+ it per signed-in user (the app's database), so the panel opens the same way across screens, reloads and devices. A
250
+ failed save keeps the choice on the page and reaches `onSaveError`. `isHidden` marks a screen that offers no panel:
251
+ no toggle, no panel, and the sidebar stays open whatever the kept state says. `useAsidePanel()` reads the state.
252
+
253
+ ```tsx
254
+ const MapPanel = dynamic(() => import("./map-panel"), { ssr: false });
255
+
256
+ <AsidePanelProvider initialState={panelState} save={savePanelState} isHidden={!offersMap}>
257
+ <AppSidebar />
258
+ <SidebarInset>
259
+ <AsidePanelSidebarOpener />
260
+ <AsidePanelToggle />
261
+ {children}
262
+ </SidebarInset>
263
+ <AsidePanel title="Map">
264
+ <MapPanel />
265
+ </AsidePanel>
266
+ </AsidePanelProvider>
267
+ ```
268
+
228
269
  **`SheetMenu`.** A phone's navigation drawer: a `Sheet` from the right with a heading and a ghost close button,
229
270
  navigation rows at the top and one row at the foot, the way a desktop `Sidebar` ends with its foot menu.
230
271
  `SheetMenu` (`ul`), `SheetMenuItem` (`li`) and `SheetMenuButton` (the row) mirror `SidebarMenu`, `SidebarMenuItem`
package/dist/index.d.ts CHANGED
@@ -41,6 +41,8 @@ export { tabsListVariants } from "./ui/tabs-variants.js";
41
41
  export * from "./ui/textarea.js";
42
42
  export * from "./ui/tooltip.js";
43
43
  export { ICON_STROKE_WIDTH } from "./notion/icon-stroke.js";
44
+ export { AsidePanel, AsidePanelProvider, AsidePanelSidebarOpener, AsidePanelToggle, useAsidePanel, type AsidePanelProps, type AsidePanelProviderProps, type AsidePanelSidebarOpenerProps, type AsidePanelState, type AsidePanelToggleProps, type AsidePanelWidth, } from "./notion/AsidePanel.js";
45
+ export { isOverlayOpen } from "./notion/overlay-open.js";
44
46
  export { Code, CodeBlock, type CodeBlockProps } from "./notion/Code.js";
45
47
  export { DetailTable, type DetailRow, type DetailTableProps } from "./notion/DetailTable.js";
46
48
  export { FilterChip, FilterChipAdd, type FilterChipAddProps, type FilterChipProps } from "./notion/FilterChip.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1E,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB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oB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -43,6 +43,8 @@ export { tabsListVariants } from "./ui/tabs-variants.js";
43
43
  export * from "./ui/textarea.js";
44
44
  export * from "./ui/tooltip.js";
45
45
  export { ICON_STROKE_WIDTH } from "./notion/icon-stroke.js";
46
+ export { AsidePanel, AsidePanelProvider, AsidePanelSidebarOpener, AsidePanelToggle, useAsidePanel, } from "./notion/AsidePanel.js";
47
+ export { isOverlayOpen } from "./notion/overlay-open.js";
46
48
  export { Code, CodeBlock } from "./notion/Code.js";
47
49
  export { DetailTable } from "./notion/DetailTable.js";
48
50
  export { FilterChip, FilterChipAdd } from "./notion/FilterChip.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wGAAwG;AACxG,oGAAoG;AACpG,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,cAAc,EAAuB,MAAM,qBAAqB,CAAC;AAE1E,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC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EAAoB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAoE,MAAM,mBAAmB,CAAC;AAC5G,OAAO,EAAE,MAAM,EAAqC,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAA0G,MAAM,sBAAsB,CAAC;AACxJ,OAAO,EAAE,aAAa,EAA2B,MAAM,2BAA2B,CAAC;AACnF,OAAO,EACL,WAAW,EACX,UAAU,EACV,UAAU,GAQX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAA0B,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAa,MAAM,mBAAmB,CAAC"}
@@ -3,6 +3,13 @@
3
3
  * replace it with the app's own wording from its message layer.
4
4
  */
5
5
  export declare const en: {
6
+ readonly asidePanel: {
7
+ readonly show: "Show the panel";
8
+ readonly hide: "Hide the panel";
9
+ readonly widen: "Widen the panel";
10
+ readonly narrow: "Narrow the panel";
11
+ readonly showSidebar: "Show the menu and hide the panel";
12
+ };
6
13
  readonly breadcrumb: {
7
14
  readonly label: "breadcrumb";
8
15
  readonly more: "More";
@@ -1 +1 @@
1
- {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/messages/en.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCL,CAAC"}
1
+ {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/messages/en.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CL,CAAC"}
@@ -3,6 +3,13 @@
3
3
  * replace it with the app's own wording from its message layer.
4
4
  */
5
5
  export const en = {
6
+ asidePanel: {
7
+ show: "Show the panel",
8
+ hide: "Hide the panel",
9
+ widen: "Widen the panel",
10
+ narrow: "Narrow the panel",
11
+ showSidebar: "Show the menu and hide the panel",
12
+ },
6
13
  breadcrumb: { label: "breadcrumb", more: "More" },
7
14
  dialog: { close: "Close" },
8
15
  filterChip: { add: "Add filter" },
@@ -1 +1 @@
1
- {"version":3,"file":"en.js","sourceRoot":"","sources":["../../src/messages/en.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,EAAE,GAAG;IAChB,UAAU,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE;IACjD,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;IAC1B,UAAU,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE;IACjC,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;IACzB,SAAS,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;IAC7B,OAAO,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,MAAM,EAAE,gBAAgB,EAAE;IAChH,OAAO,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE;IAC7B,QAAQ,EAAE;QACR,YAAY,EACV,mIAAmI;QACrI,QAAQ,EAAE,mDAAmD;QAC7D,KAAK,EAAE,iDAAiD;QACxD,OAAO,EAAE,mDAAmD;QAC5D,SAAS,EAAE,qCAAqC;QAChD,MAAM,EAAE,iBAAiB;KAC1B;IACD,MAAM,EAAE;QACN,MAAM,EAAE,cAAc;QACtB,SAAS,EAAE,eAAe;QAC1B,IAAI,EAAE,mBAAmB;QACzB,OAAO,EAAE,iBAAiB;QAC1B,QAAQ,EAAE,aAAa;QACvB,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,cAAc;QACrB,MAAM,EAAE,eAAe;QACvB,MAAM,EAAE,eAAe;QACv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BAAiB;KAC1B;IACD,MAAM,EAAE;QACN,MAAM,EAAE,cAAc;QACtB,SAAS,EAAE,eAAe;QAC1B,IAAI,EAAE,mBAAmB;QACzB,OAAO,EAAE,iBAAiB;QAC1B,QAAQ,EAAE,aAAa;QACvB,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,cAAc;QACrB,MAAM,EAAE,eAAe;QACvB,MAAM,EAAE,eAAe;QACvB,QAAQ,EAAE,kBAAkB;QAC5B,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,WAAW;QACtB,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,QAAQ;KACjB;IACD,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE;IAC5E,OAAO,EAAE,EAAE,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,gCAAgC,EAAE;CAC5E,CAAC"}
@@ -2,6 +2,13 @@ import { en } from "./en.js";
2
2
  /** The built-in English dictionary; replace a text through the component's prop (README, "Copy"). */
3
3
  export declare const notionMessages: {
4
4
  en: {
5
+ readonly asidePanel: {
6
+ readonly show: "Show the panel";
7
+ readonly hide: "Hide the panel";
8
+ readonly widen: "Widen the panel";
9
+ readonly narrow: "Narrow the panel";
10
+ readonly showSidebar: "Show the menu and hide the panel";
11
+ };
5
12
  readonly breadcrumb: {
6
13
  readonly label: "breadcrumb";
7
14
  readonly more: "More";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE7B,qGAAqG;AACrG,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAS,CAAC;AAErC,MAAM,MAAM,cAAc,GAAG,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE7B,qGAAqG;AACrG,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAS,CAAC;AAErC,MAAM,MAAM,cAAc,GAAG,OAAO,EAAE,CAAC"}
@@ -0,0 +1,64 @@
1
+ import { type ComponentProps, type ReactNode, type RefObject } from "react";
2
+ import { SidebarProvider } from "../ui/sidebar.js";
3
+ export type AsidePanelWidth = "standard" | "half";
4
+ export interface AsidePanelState {
5
+ readonly isOpen: boolean;
6
+ readonly width: AsidePanelWidth;
7
+ }
8
+ export type AsidePanelProviderProps = Omit<ComponentProps<typeof SidebarProvider>, "open" | "onOpenChange" | "hidden"> & {
9
+ readonly initialState: AsidePanelState;
10
+ readonly save?: (state: AsidePanelState) => void | Promise<void>;
11
+ readonly onSaveError?: (error: unknown) => void;
12
+ readonly isHidden?: boolean;
13
+ readonly panelId?: string;
14
+ };
15
+ interface AsidePanelContextValue {
16
+ readonly panelId: string;
17
+ readonly isOpen: boolean;
18
+ readonly width: AsidePanelWidth;
19
+ readonly isMobile: boolean;
20
+ readonly isHidden: boolean;
21
+ readonly isSidebarFolded: boolean;
22
+ readonly toggleRef: RefObject<HTMLButtonElement | null>;
23
+ readonly isHeadingFocusRequested: RefObject<boolean>;
24
+ readonly toggle: () => void;
25
+ readonly close: () => void;
26
+ readonly setWidth: (width: AsidePanelWidth) => void;
27
+ readonly openSidebar: () => void;
28
+ }
29
+ /** The panel's state and actions, for an app that builds its own toggle or reads whether the panel is open. */
30
+ export declare function useAsidePanel(): Pick<AsidePanelContextValue, "panelId" | "isOpen" | "width" | "isMobile" | "isHidden" | "isSidebarFolded" | "toggle" | "close" | "setWidth" | "openSidebar">;
31
+ /**
32
+ * The app shell's provider: renders `SidebarProvider` and keeps one side panel open at a time. While the right panel
33
+ * is open on a wide screen, the left sidebar is folded (offcanvas); opening the sidebar any way closes the panel.
34
+ * Use it in place of `SidebarProvider`; every other `SidebarProvider` prop passes through.
35
+ */
36
+ export declare function AsidePanelProvider({ initialState, save, onSaveError, isHidden, panelId, defaultOpen, children, ...props }: AsidePanelProviderProps): import("react").JSX.Element;
37
+ export interface AsidePanelToggleProps {
38
+ readonly showLabel?: string;
39
+ readonly hideLabel?: string;
40
+ readonly className?: string;
41
+ }
42
+ /** The icon button at the top-right edge that shows and hides the panel; it stays in place either way. */
43
+ export declare function AsidePanelToggle({ showLabel, hideLabel, className }: AsidePanelToggleProps): import("react").JSX.Element | null;
44
+ export interface AsidePanelSidebarOpenerProps {
45
+ readonly label?: string;
46
+ readonly className?: string;
47
+ }
48
+ /** The icon button at the top-left edge, shown only while the sidebar is folded: brings it back, closes the panel. */
49
+ export declare function AsidePanelSidebarOpener({ label, className }: AsidePanelSidebarOpenerProps): import("react").JSX.Element | null;
50
+ export interface AsidePanelProps {
51
+ readonly title: string;
52
+ readonly children: ReactNode;
53
+ readonly widenLabel?: string;
54
+ readonly narrowLabel?: string;
55
+ readonly closeLabel?: string;
56
+ readonly className?: string;
57
+ }
58
+ /**
59
+ * The panel: an `aside` beside the shell's content on a wide screen (the content narrows next to it), a right `Sheet`
60
+ * on a phone. Place it after `SidebarInset` inside `AsidePanelProvider`.
61
+ */
62
+ export declare function AsidePanel({ title, children, widenLabel, narrowLabel, closeLabel, className, }: AsidePanelProps): import("react").JSX.Element | null;
63
+ export {};
64
+ //# sourceMappingURL=AsidePanel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AsidePanel.d.ts","sourceRoot":"","sources":["../../src/notion/AsidePanel.tsx"],"names":[],"mappings":"AAIA,OAAO,EAQL,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAMf,OAAO,EAAE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QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,UAAsC,EACtC,WAAwC,EACxC,UAAU,EACV,SAAS,GACV,EAAE,eAAe,sCAuFjB"}
@@ -0,0 +1,154 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useIsMobile } from "@softure-ai/theme-kit/react";
4
+ import { ChevronsLeft, ChevronsRight, PanelLeft, PanelRightClose, PanelRightOpen } from "lucide-react";
5
+ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
6
+ import { cn } from "../lib/utils.js";
7
+ import { en as messages } from "../messages/en.js";
8
+ import { Button } from "../ui/button.js";
9
+ import { Sheet, SheetContent, SheetHeader, SheetTitle } from "../ui/sheet.js";
10
+ import { SidebarProvider } from "../ui/sidebar.js";
11
+ import { ICON_STROKE_WIDTH } from "./icon-stroke.js";
12
+ import { isOverlayOpen } from "./overlay-open.js";
13
+ const AsidePanelContext = createContext(null);
14
+ /** The panel's state and actions, for an app that builds its own toggle or reads whether the panel is open. */
15
+ export function useAsidePanel() {
16
+ const context = useContext(AsidePanelContext);
17
+ if (context === null)
18
+ throw new Error("useAsidePanel must be used within an AsidePanelProvider.");
19
+ return context;
20
+ }
21
+ function useAsidePanelContext(component) {
22
+ const context = useContext(AsidePanelContext);
23
+ if (context === null)
24
+ throw new Error(`${component} must be used within an AsidePanelProvider.`);
25
+ return context;
26
+ }
27
+ /**
28
+ * The app shell's provider: renders `SidebarProvider` and keeps one side panel open at a time. While the right panel
29
+ * is open on a wide screen, the left sidebar is folded (offcanvas); opening the sidebar any way closes the panel.
30
+ * Use it in place of `SidebarProvider`; every other `SidebarProvider` prop passes through.
31
+ */
32
+ export function AsidePanelProvider({ initialState, save, onSaveError, isHidden = false, panelId = "aside-panel", defaultOpen = true, children, ...props }) {
33
+ const isMobile = useIsMobile();
34
+ const [kept, setKept] = useState(initialState);
35
+ const [isMobileOpen, setMobileOpen] = useState(false);
36
+ const [isSidebarOpen, setSidebarOpen] = useState(defaultOpen);
37
+ const toggleRef = useRef(null);
38
+ const isHeadingFocusRequested = useRef(false);
39
+ const isOpen = isHidden ? false : isMobile ? isMobileOpen : kept.isOpen;
40
+ const isSidebarShown = isSidebarOpen && !(kept.isOpen && !isMobile && !isHidden);
41
+ const keep = useCallback((next) => {
42
+ setKept(next);
43
+ if (save === undefined)
44
+ return;
45
+ // The choice stays on the page when the save fails; the app hears about it through `onSaveError`.
46
+ Promise.resolve()
47
+ .then(() => save(next))
48
+ .catch((error) => onSaveError?.(error));
49
+ }, [save, onSaveError]);
50
+ const setPanelOpen = useCallback((next) => {
51
+ if (isMobile)
52
+ setMobileOpen(next);
53
+ else if (next !== kept.isOpen)
54
+ keep({ ...kept, isOpen: next });
55
+ }, [isMobile, kept, keep]);
56
+ const toggle = useCallback(() => {
57
+ if (!isOpen)
58
+ isHeadingFocusRequested.current = true;
59
+ setPanelOpen(!isOpen);
60
+ }, [isOpen, setPanelOpen]);
61
+ const close = useCallback(() => setPanelOpen(false), [setPanelOpen]);
62
+ const setWidth = useCallback((width) => {
63
+ if (width !== kept.width)
64
+ keep({ ...kept, width });
65
+ }, [kept, keep]);
66
+ const openSidebar = useCallback(() => {
67
+ setSidebarOpen(true);
68
+ if (kept.isOpen && !isMobile)
69
+ keep({ ...kept, isOpen: false });
70
+ }, [isMobile, kept, keep]);
71
+ const changeSidebar = useCallback((next) => {
72
+ if (next)
73
+ openSidebar();
74
+ else
75
+ setSidebarOpen(false);
76
+ }, [openSidebar]);
77
+ const value = useMemo(() => ({
78
+ panelId,
79
+ isOpen,
80
+ width: kept.width,
81
+ isMobile,
82
+ isHidden,
83
+ isSidebarFolded: !isSidebarShown,
84
+ toggleRef,
85
+ isHeadingFocusRequested,
86
+ toggle,
87
+ close,
88
+ setWidth,
89
+ openSidebar,
90
+ }), [panelId, isOpen, kept.width, isMobile, isHidden, isSidebarShown, toggle, close, setWidth, openSidebar]);
91
+ return (_jsx(AsidePanelContext.Provider, { value: value, children: _jsx(SidebarProvider, { open: isSidebarShown, onOpenChange: changeSidebar, ...props, children: children }) }));
92
+ }
93
+ /** The icon button at the top-right edge that shows and hides the panel; it stays in place either way. */
94
+ export function AsidePanelToggle({ showLabel = messages.asidePanel.show, hideLabel = messages.asidePanel.hide, className }) {
95
+ const { panelId, isOpen, isHidden, toggleRef, toggle } = useAsidePanelContext("AsidePanelToggle");
96
+ if (isHidden)
97
+ return null;
98
+ const Icon = isOpen ? PanelRightClose : PanelRightOpen;
99
+ return (_jsx(Button, { ref: toggleRef, type: "button", "data-slot": "aside-panel-toggle", variant: isOpen ? "secondary" : "outline", size: "icon", "aria-expanded": isOpen, "aria-controls": panelId, "aria-label": isOpen ? hideLabel : showLabel, className: cn("fixed top-[calc(--spacing(2)+env(safe-area-inset-top))] right-[calc(--spacing(2)+env(safe-area-inset-right))] z-20", className), onClick: toggle, children: _jsx(Icon, { "aria-hidden": "true", strokeWidth: ICON_STROKE_WIDTH }) }));
100
+ }
101
+ /** The icon button at the top-left edge, shown only while the sidebar is folded: brings it back, closes the panel. */
102
+ export function AsidePanelSidebarOpener({ label = messages.asidePanel.showSidebar, className }) {
103
+ const { isMobile, isSidebarFolded, openSidebar } = useAsidePanelContext("AsidePanelSidebarOpener");
104
+ if (isMobile || !isSidebarFolded)
105
+ return null;
106
+ return (_jsx(Button, { type: "button", "data-slot": "aside-panel-sidebar-opener", variant: "outline", size: "icon", "aria-label": label, className: cn("fixed top-[calc(--spacing(2)+env(safe-area-inset-top))] left-[calc(--spacing(2)+env(safe-area-inset-left))] z-20", className), onClick: openSidebar, children: _jsx(PanelLeft, { "aria-hidden": "true", strokeWidth: ICON_STROKE_WIDTH }) }));
107
+ }
108
+ /**
109
+ * The panel: an `aside` beside the shell's content on a wide screen (the content narrows next to it), a right `Sheet`
110
+ * on a phone. Place it after `SidebarInset` inside `AsidePanelProvider`.
111
+ */
112
+ export function AsidePanel({ title, children, widenLabel = messages.asidePanel.widen, narrowLabel = messages.asidePanel.narrow, closeLabel, className, }) {
113
+ const { panelId, isOpen, width, isMobile, isHidden, toggleRef, isHeadingFocusRequested, close, setWidth } = useAsidePanelContext("AsidePanel");
114
+ const headingRef = useRef(null);
115
+ const headingId = `${panelId}-heading`;
116
+ const isDesktopOpen = isOpen && !isMobile && !isHidden;
117
+ // Opening from the toggle moves focus to the heading; a panel kept open on load leaves focus alone.
118
+ useEffect(() => {
119
+ if (!isDesktopOpen || !isHeadingFocusRequested.current)
120
+ return;
121
+ isHeadingFocusRequested.current = false;
122
+ headingRef.current?.focus();
123
+ }, [isDesktopOpen, isHeadingFocusRequested]);
124
+ // Escape closes the panel and returns focus to the toggle, unless an open overlay takes the key first.
125
+ useEffect(() => {
126
+ if (!isDesktopOpen)
127
+ return;
128
+ const closeOnEscape = (event) => {
129
+ if (event.key !== "Escape" || event.defaultPrevented || isOverlayOpen(document))
130
+ return;
131
+ close();
132
+ toggleRef.current?.focus();
133
+ };
134
+ document.addEventListener("keydown", closeOnEscape);
135
+ return () => document.removeEventListener("keydown", closeOnEscape);
136
+ }, [isDesktopOpen, close, toggleRef]);
137
+ if (isHidden)
138
+ return null;
139
+ if (isMobile) {
140
+ return (_jsx(Sheet, { open: isOpen, onOpenChange: (next) => !next && close(), children: _jsxs(SheetContent, { id: panelId, side: "right", "data-slot": "aside-panel-sheet", "aria-describedby": undefined, closeLabel: closeLabel, className: cn("w-full gap-0 sm:max-w-none", className), onOpenAutoFocus: (event) => {
141
+ event.preventDefault();
142
+ headingRef.current?.focus();
143
+ }, onCloseAutoFocus: (event) => {
144
+ event.preventDefault();
145
+ toggleRef.current?.focus();
146
+ }, children: [_jsx(SheetHeader, { className: "border-b border-border", children: _jsx(SheetTitle, { ref: headingRef, tabIndex: -1, className: "outline-none", children: title }) }), _jsx("div", { "data-slot": "aside-panel-content", className: "min-h-0 flex-1 overflow-y-auto", children: isOpen ? children : null })] }) }));
147
+ }
148
+ if (!isOpen)
149
+ return null;
150
+ const isHalf = width === "half";
151
+ const WidthIcon = isHalf ? ChevronsRight : ChevronsLeft;
152
+ return (_jsxs("aside", { id: panelId, "data-slot": "aside-panel", "data-width": width, "aria-labelledby": headingId, className: cn("sticky top-0 flex h-dvh w-2/5 shrink-0 flex-col border-l border-border bg-background text-foreground data-[width=half]:w-1/2", className), children: [_jsxs("div", { "data-slot": "aside-panel-header", className: "flex h-11 shrink-0 items-center gap-2 border-b border-border pr-12 pl-4", children: [_jsx("h2", { ref: headingRef, id: headingId, tabIndex: -1, className: "min-w-0 flex-1 truncate text-heading-3 outline-none", children: title }), _jsx(Button, { type: "button", variant: "ghost", size: "icon", "aria-label": isHalf ? narrowLabel : widenLabel, onClick: () => setWidth(isHalf ? "standard" : "half"), children: _jsx(WidthIcon, { "aria-hidden": "true", strokeWidth: ICON_STROKE_WIDTH }) })] }), _jsx("div", { "data-slot": "aside-panel-content", className: "min-h-0 flex-1 overflow-y-auto", children: children })] }));
153
+ }
154
+ //# sourceMappingURL=AsidePanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AsidePanel.js","sourceRoot":"","sources":["../../src/notion/AsidePanel.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACvG,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GAIT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,EAAE,IAAI,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EA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AAC,SAAS,EAAC,gCAAgC,YAC5E,QAAQ,GACL,IACA,CACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Whether a dialog, menu, listbox or popover is open under `root`: one with Radix `data-state="open"`, one that
3
+ * matches `:popover-open`, or a `dialog[open]`. A closed popover that stays in the page with `role="dialog"` does
4
+ * not count. A keyboard handler reads it before acting on Escape, so the overlay closes first.
5
+ */
6
+ export declare function isOverlayOpen(root: ParentNode): boolean;
7
+ //# sourceMappingURL=overlay-open.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlay-open.d.ts","sourceRoot":"","sources":["../../src/notion/overlay-open.ts"],"names":[],"mappings":"AAqBA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAEvD"}
@@ -0,0 +1,28 @@
1
+ // Kept out of the "use client" AsidePanel module so a Server Component or a plain script can call it too.
2
+ // Overlays that handle Escape themselves: a Radix dialog, menu, listbox or popover while it is open, a native modal.
3
+ const OPEN_OVERLAY_SELECTORS = [
4
+ '[role="dialog"][data-state="open"]',
5
+ '[role="alertdialog"][data-state="open"]',
6
+ '[role="menu"][data-state="open"]',
7
+ '[role="listbox"][data-state="open"]',
8
+ "dialog[open]",
9
+ ":popover-open",
10
+ ];
11
+ function hasMatch(root, selector) {
12
+ try {
13
+ return root.querySelector(selector) !== null;
14
+ }
15
+ catch {
16
+ // A DOM that does not know the selector (`:popover-open` in an older engine) has no such overlay open.
17
+ return false;
18
+ }
19
+ }
20
+ /**
21
+ * Whether a dialog, menu, listbox or popover is open under `root`: one with Radix `data-state="open"`, one that
22
+ * matches `:popover-open`, or a `dialog[open]`. A closed popover that stays in the page with `role="dialog"` does
23
+ * not count. A keyboard handler reads it before acting on Escape, so the overlay closes first.
24
+ */
25
+ export function isOverlayOpen(root) {
26
+ return OPEN_OVERLAY_SELECTORS.some((selector) => hasMatch(root, selector));
27
+ }
28
+ //# sourceMappingURL=overlay-open.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlay-open.js","sourceRoot":"","sources":["../../src/notion/overlay-open.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAE1G,qHAAqH;AACrH,MAAM,sBAAsB,GAAG;IAC7B,oCAAoC;IACpC,yCAAyC;IACzC,kCAAkC;IAClC,qCAAqC;IACrC,cAAc;IACd,eAAe;CACP,CAAC;AAEX,SAAS,QAAQ,CAAC,IAAgB,EAAE,QAAgB;IAClD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,uGAAuG;QACvG,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,IAAgB;IAC5C,OAAO,sBAAsB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC7E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softure-ai/theme-notion",
3
- "version": "0.11.1",
3
+ "version": "0.12.0",
4
4
  "description": "SOFTURE AI Notion theme: shadcn/ui components (new-york v4, Radix, Tailwind CSS v4, lucide) with the Notion design system's tokens and deltas, ready to import.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/index.ts CHANGED
@@ -45,6 +45,20 @@ export * from "./ui/textarea.js";
45
45
  export * from "./ui/tooltip.js";
46
46
 
47
47
  export { ICON_STROKE_WIDTH } from "./notion/icon-stroke.js";
48
+ export {
49
+ AsidePanel,
50
+ AsidePanelProvider,
51
+ AsidePanelSidebarOpener,
52
+ AsidePanelToggle,
53
+ useAsidePanel,
54
+ type AsidePanelProps,
55
+ type AsidePanelProviderProps,
56
+ type AsidePanelSidebarOpenerProps,
57
+ type AsidePanelState,
58
+ type AsidePanelToggleProps,
59
+ type AsidePanelWidth,
60
+ } from "./notion/AsidePanel.js";
61
+ export { isOverlayOpen } from "./notion/overlay-open.js";
48
62
  export { Code, CodeBlock, type CodeBlockProps } from "./notion/Code.js";
49
63
  export { DetailTable, type DetailRow, type DetailTableProps } from "./notion/DetailTable.js";
50
64
  export { FilterChip, FilterChipAdd, type FilterChipAddProps, type FilterChipProps } from "./notion/FilterChip.js";
@@ -3,6 +3,13 @@
3
3
  * replace it with the app's own wording from its message layer.
4
4
  */
5
5
  export const en = {
6
+ asidePanel: {
7
+ show: "Show the panel",
8
+ hide: "Hide the panel",
9
+ widen: "Widen the panel",
10
+ narrow: "Narrow the panel",
11
+ showSidebar: "Show the menu and hide the panel",
12
+ },
6
13
  breadcrumb: { label: "breadcrumb", more: "More" },
7
14
  dialog: { close: "Close" },
8
15
  filterChip: { add: "Add filter" },
@@ -0,0 +1,346 @@
1
+ "use client";
2
+
3
+ import { useIsMobile } from "@softure-ai/theme-kit/react";
4
+ import { ChevronsLeft, ChevronsRight, PanelLeft, PanelRightClose, PanelRightOpen } from "lucide-react";
5
+ import {
6
+ createContext,
7
+ useCallback,
8
+ useContext,
9
+ useEffect,
10
+ useMemo,
11
+ useRef,
12
+ useState,
13
+ type ComponentProps,
14
+ type ReactNode,
15
+ type RefObject,
16
+ } from "react";
17
+
18
+ import { cn } from "../lib/utils.js";
19
+ import { en as messages } from "../messages/en.js";
20
+ import { Button } from "../ui/button.js";
21
+ import { Sheet, SheetContent, SheetHeader, SheetTitle } from "../ui/sheet.js";
22
+ import { SidebarProvider } from "../ui/sidebar.js";
23
+
24
+ import { ICON_STROKE_WIDTH } from "./icon-stroke.js";
25
+ import { isOverlayOpen } from "./overlay-open.js";
26
+
27
+ // `standard` takes two fifths of the shell, `half` splits the shell half and half between the content and the panel.
28
+ export type AsidePanelWidth = "standard" | "half";
29
+
30
+ // What the app keeps per signed-in user, so the panel opens the same way across screens, reloads and devices.
31
+ export interface AsidePanelState {
32
+ readonly isOpen: boolean;
33
+ readonly width: AsidePanelWidth;
34
+ }
35
+
36
+ export type AsidePanelProviderProps = Omit<ComponentProps<typeof SidebarProvider>, "open" | "onOpenChange" | "hidden"> & {
37
+ // The kept state the panel starts from on a wide screen; a phone always starts closed.
38
+ readonly initialState: AsidePanelState;
39
+ // Called with the new state after each change on a wide screen; a failed save keeps the choice on the page.
40
+ readonly save?: (state: AsidePanelState) => void | Promise<void>;
41
+ // Receives a failed save (a rejected promise or a thrown error).
42
+ readonly onSaveError?: (error: unknown) => void;
43
+ // A screen that offers no panel: no toggle, no panel, and the sidebar stays open whatever the kept state says.
44
+ readonly isHidden?: boolean;
45
+ // The panel's `id`, which the toggle points at with `aria-controls`.
46
+ readonly panelId?: string;
47
+ };
48
+
49
+ interface AsidePanelContextValue {
50
+ readonly panelId: string;
51
+ readonly isOpen: boolean;
52
+ readonly width: AsidePanelWidth;
53
+ readonly isMobile: boolean;
54
+ readonly isHidden: boolean;
55
+ readonly isSidebarFolded: boolean;
56
+ readonly toggleRef: RefObject<HTMLButtonElement | null>;
57
+ readonly isHeadingFocusRequested: RefObject<boolean>;
58
+ readonly toggle: () => void;
59
+ readonly close: () => void;
60
+ readonly setWidth: (width: AsidePanelWidth) => void;
61
+ readonly openSidebar: () => void;
62
+ }
63
+
64
+ const AsidePanelContext = createContext<AsidePanelContextValue | null>(null);
65
+
66
+ /** The panel's state and actions, for an app that builds its own toggle or reads whether the panel is open. */
67
+ export function useAsidePanel(): Pick<AsidePanelContextValue, "panelId" | "isOpen" | "width" | "isMobile" | "isHidden" | "isSidebarFolded" | "toggle" | "close" | "setWidth" | "openSidebar"> {
68
+ const context = useContext(AsidePanelContext);
69
+ if (context === null) throw new Error("useAsidePanel must be used within an AsidePanelProvider.");
70
+ return context;
71
+ }
72
+
73
+ function useAsidePanelContext(component: string): AsidePanelContextValue {
74
+ const context = useContext(AsidePanelContext);
75
+ if (context === null) throw new Error(`${component} must be used within an AsidePanelProvider.`);
76
+ return context;
77
+ }
78
+
79
+ /**
80
+ * The app shell's provider: renders `SidebarProvider` and keeps one side panel open at a time. While the right panel
81
+ * is open on a wide screen, the left sidebar is folded (offcanvas); opening the sidebar any way closes the panel.
82
+ * Use it in place of `SidebarProvider`; every other `SidebarProvider` prop passes through.
83
+ */
84
+ export function AsidePanelProvider({
85
+ initialState,
86
+ save,
87
+ onSaveError,
88
+ isHidden = false,
89
+ panelId = "aside-panel",
90
+ defaultOpen = true,
91
+ children,
92
+ ...props
93
+ }: AsidePanelProviderProps) {
94
+ const isMobile = useIsMobile();
95
+ const [kept, setKept] = useState<AsidePanelState>(initialState);
96
+ const [isMobileOpen, setMobileOpen] = useState(false);
97
+ const [isSidebarOpen, setSidebarOpen] = useState(defaultOpen);
98
+ const toggleRef = useRef<HTMLButtonElement>(null);
99
+ const isHeadingFocusRequested = useRef(false);
100
+
101
+ const isOpen = isHidden ? false : isMobile ? isMobileOpen : kept.isOpen;
102
+ const isSidebarShown = isSidebarOpen && !(kept.isOpen && !isMobile && !isHidden);
103
+
104
+ const keep = useCallback(
105
+ (next: AsidePanelState) => {
106
+ setKept(next);
107
+ if (save === undefined) return;
108
+ // The choice stays on the page when the save fails; the app hears about it through `onSaveError`.
109
+ Promise.resolve()
110
+ .then(() => save(next))
111
+ .catch((error: unknown) => onSaveError?.(error));
112
+ },
113
+ [save, onSaveError],
114
+ );
115
+
116
+ const setPanelOpen = useCallback(
117
+ (next: boolean) => {
118
+ if (isMobile) setMobileOpen(next);
119
+ else if (next !== kept.isOpen) keep({ ...kept, isOpen: next });
120
+ },
121
+ [isMobile, kept, keep],
122
+ );
123
+
124
+ const toggle = useCallback(() => {
125
+ if (!isOpen) isHeadingFocusRequested.current = true;
126
+ setPanelOpen(!isOpen);
127
+ }, [isOpen, setPanelOpen]);
128
+
129
+ const close = useCallback(() => setPanelOpen(false), [setPanelOpen]);
130
+
131
+ const setWidth = useCallback(
132
+ (width: AsidePanelWidth) => {
133
+ if (width !== kept.width) keep({ ...kept, width });
134
+ },
135
+ [kept, keep],
136
+ );
137
+
138
+ const openSidebar = useCallback(() => {
139
+ setSidebarOpen(true);
140
+ if (kept.isOpen && !isMobile) keep({ ...kept, isOpen: false });
141
+ }, [isMobile, kept, keep]);
142
+
143
+ const changeSidebar = useCallback(
144
+ (next: boolean) => {
145
+ if (next) openSidebar();
146
+ else setSidebarOpen(false);
147
+ },
148
+ [openSidebar],
149
+ );
150
+
151
+ const value = useMemo<AsidePanelContextValue>(
152
+ () => ({
153
+ panelId,
154
+ isOpen,
155
+ width: kept.width,
156
+ isMobile,
157
+ isHidden,
158
+ isSidebarFolded: !isSidebarShown,
159
+ toggleRef,
160
+ isHeadingFocusRequested,
161
+ toggle,
162
+ close,
163
+ setWidth,
164
+ openSidebar,
165
+ }),
166
+ [panelId, isOpen, kept.width, isMobile, isHidden, isSidebarShown, toggle, close, setWidth, openSidebar],
167
+ );
168
+
169
+ return (
170
+ <AsidePanelContext.Provider value={value}>
171
+ <SidebarProvider open={isSidebarShown} onOpenChange={changeSidebar} {...props}>
172
+ {children}
173
+ </SidebarProvider>
174
+ </AsidePanelContext.Provider>
175
+ );
176
+ }
177
+
178
+ export interface AsidePanelToggleProps {
179
+ // The accessible names while closed and while open, from the app's message layer.
180
+ readonly showLabel?: string;
181
+ readonly hideLabel?: string;
182
+ readonly className?: string;
183
+ }
184
+
185
+ /** The icon button at the top-right edge that shows and hides the panel; it stays in place either way. */
186
+ export function AsidePanelToggle({ showLabel = messages.asidePanel.show, hideLabel = messages.asidePanel.hide, className }: AsidePanelToggleProps) {
187
+ const { panelId, isOpen, isHidden, toggleRef, toggle } = useAsidePanelContext("AsidePanelToggle");
188
+ if (isHidden) return null;
189
+ const Icon = isOpen ? PanelRightClose : PanelRightOpen;
190
+
191
+ return (
192
+ <Button
193
+ ref={toggleRef}
194
+ type="button"
195
+ data-slot="aside-panel-toggle"
196
+ variant={isOpen ? "secondary" : "outline"}
197
+ size="icon"
198
+ aria-expanded={isOpen}
199
+ aria-controls={panelId}
200
+ aria-label={isOpen ? hideLabel : showLabel}
201
+ className={cn("fixed top-[calc(--spacing(2)+env(safe-area-inset-top))] right-[calc(--spacing(2)+env(safe-area-inset-right))] z-20", className)}
202
+ onClick={toggle}
203
+ >
204
+ <Icon aria-hidden="true" strokeWidth={ICON_STROKE_WIDTH} />
205
+ </Button>
206
+ );
207
+ }
208
+
209
+ export interface AsidePanelSidebarOpenerProps {
210
+ // The accessible name ("show the menu and hide the panel"), from the app's message layer.
211
+ readonly label?: string;
212
+ readonly className?: string;
213
+ }
214
+
215
+ /** The icon button at the top-left edge, shown only while the sidebar is folded: brings it back, closes the panel. */
216
+ export function AsidePanelSidebarOpener({ label = messages.asidePanel.showSidebar, className }: AsidePanelSidebarOpenerProps) {
217
+ const { isMobile, isSidebarFolded, openSidebar } = useAsidePanelContext("AsidePanelSidebarOpener");
218
+ if (isMobile || !isSidebarFolded) return null;
219
+
220
+ return (
221
+ <Button
222
+ type="button"
223
+ data-slot="aside-panel-sidebar-opener"
224
+ variant="outline"
225
+ size="icon"
226
+ aria-label={label}
227
+ className={cn("fixed top-[calc(--spacing(2)+env(safe-area-inset-top))] left-[calc(--spacing(2)+env(safe-area-inset-left))] z-20", className)}
228
+ onClick={openSidebar}
229
+ >
230
+ <PanelLeft aria-hidden="true" strokeWidth={ICON_STROKE_WIDTH} />
231
+ </Button>
232
+ );
233
+ }
234
+
235
+ export interface AsidePanelProps {
236
+ readonly title: string;
237
+ // The panel's body, rendered only while the panel is open: pass a lazily loaded component (`next/dynamic` with
238
+ // `ssr: false`, or `React.lazy`), so screens that never open the panel never load its code.
239
+ readonly children: ReactNode;
240
+ // The width switch's accessible names, from the app's message layer.
241
+ readonly widenLabel?: string;
242
+ readonly narrowLabel?: string;
243
+ // The phone sheet's close button text.
244
+ readonly closeLabel?: string;
245
+ readonly className?: string;
246
+ }
247
+
248
+ /**
249
+ * The panel: an `aside` beside the shell's content on a wide screen (the content narrows next to it), a right `Sheet`
250
+ * on a phone. Place it after `SidebarInset` inside `AsidePanelProvider`.
251
+ */
252
+ export function AsidePanel({
253
+ title,
254
+ children,
255
+ widenLabel = messages.asidePanel.widen,
256
+ narrowLabel = messages.asidePanel.narrow,
257
+ closeLabel,
258
+ className,
259
+ }: AsidePanelProps) {
260
+ const { panelId, isOpen, width, isMobile, isHidden, toggleRef, isHeadingFocusRequested, close, setWidth } = useAsidePanelContext("AsidePanel");
261
+ const headingRef = useRef<HTMLHeadingElement>(null);
262
+ const headingId = `${panelId}-heading`;
263
+ const isDesktopOpen = isOpen && !isMobile && !isHidden;
264
+
265
+ // Opening from the toggle moves focus to the heading; a panel kept open on load leaves focus alone.
266
+ useEffect(() => {
267
+ if (!isDesktopOpen || !isHeadingFocusRequested.current) return;
268
+ isHeadingFocusRequested.current = false;
269
+ headingRef.current?.focus();
270
+ }, [isDesktopOpen, isHeadingFocusRequested]);
271
+
272
+ // Escape closes the panel and returns focus to the toggle, unless an open overlay takes the key first.
273
+ useEffect(() => {
274
+ if (!isDesktopOpen) return;
275
+ const closeOnEscape = (event: KeyboardEvent) => {
276
+ if (event.key !== "Escape" || event.defaultPrevented || isOverlayOpen(document)) return;
277
+ close();
278
+ toggleRef.current?.focus();
279
+ };
280
+ document.addEventListener("keydown", closeOnEscape);
281
+ return () => document.removeEventListener("keydown", closeOnEscape);
282
+ }, [isDesktopOpen, close, toggleRef]);
283
+
284
+ if (isHidden) return null;
285
+
286
+ if (isMobile) {
287
+ return (
288
+ <Sheet open={isOpen} onOpenChange={(next) => !next && close()}>
289
+ <SheetContent
290
+ id={panelId}
291
+ side="right"
292
+ data-slot="aside-panel-sheet"
293
+ aria-describedby={undefined}
294
+ closeLabel={closeLabel}
295
+ className={cn("w-full gap-0 sm:max-w-none", className)}
296
+ onOpenAutoFocus={(event) => {
297
+ event.preventDefault();
298
+ headingRef.current?.focus();
299
+ }}
300
+ onCloseAutoFocus={(event) => {
301
+ event.preventDefault();
302
+ toggleRef.current?.focus();
303
+ }}
304
+ >
305
+ <SheetHeader className="border-b border-border">
306
+ <SheetTitle ref={headingRef} tabIndex={-1} className="outline-none">
307
+ {title}
308
+ </SheetTitle>
309
+ </SheetHeader>
310
+ <div data-slot="aside-panel-content" className="min-h-0 flex-1 overflow-y-auto">
311
+ {isOpen ? children : null}
312
+ </div>
313
+ </SheetContent>
314
+ </Sheet>
315
+ );
316
+ }
317
+
318
+ if (!isOpen) return null;
319
+ const isHalf = width === "half";
320
+ const WidthIcon = isHalf ? ChevronsRight : ChevronsLeft;
321
+
322
+ return (
323
+ <aside
324
+ id={panelId}
325
+ data-slot="aside-panel"
326
+ data-width={width}
327
+ aria-labelledby={headingId}
328
+ className={cn(
329
+ "sticky top-0 flex h-dvh w-2/5 shrink-0 flex-col border-l border-border bg-background text-foreground data-[width=half]:w-1/2",
330
+ className,
331
+ )}
332
+ >
333
+ <div data-slot="aside-panel-header" className="flex h-11 shrink-0 items-center gap-2 border-b border-border pr-12 pl-4">
334
+ <h2 ref={headingRef} id={headingId} tabIndex={-1} className="min-w-0 flex-1 truncate text-heading-3 outline-none">
335
+ {title}
336
+ </h2>
337
+ <Button type="button" variant="ghost" size="icon" aria-label={isHalf ? narrowLabel : widenLabel} onClick={() => setWidth(isHalf ? "standard" : "half")}>
338
+ <WidthIcon aria-hidden="true" strokeWidth={ICON_STROKE_WIDTH} />
339
+ </Button>
340
+ </div>
341
+ <div data-slot="aside-panel-content" className="min-h-0 flex-1 overflow-y-auto">
342
+ {children}
343
+ </div>
344
+ </aside>
345
+ );
346
+ }
@@ -0,0 +1,29 @@
1
+ // Kept out of the "use client" AsidePanel module so a Server Component or a plain script can call it too.
2
+
3
+ // Overlays that handle Escape themselves: a Radix dialog, menu, listbox or popover while it is open, a native modal.
4
+ const OPEN_OVERLAY_SELECTORS = [
5
+ '[role="dialog"][data-state="open"]',
6
+ '[role="alertdialog"][data-state="open"]',
7
+ '[role="menu"][data-state="open"]',
8
+ '[role="listbox"][data-state="open"]',
9
+ "dialog[open]",
10
+ ":popover-open",
11
+ ] as const;
12
+
13
+ function hasMatch(root: ParentNode, selector: string): boolean {
14
+ try {
15
+ return root.querySelector(selector) !== null;
16
+ } catch {
17
+ // A DOM that does not know the selector (`:popover-open` in an older engine) has no such overlay open.
18
+ return false;
19
+ }
20
+ }
21
+
22
+ /**
23
+ * Whether a dialog, menu, listbox or popover is open under `root`: one with Radix `data-state="open"`, one that
24
+ * matches `:popover-open`, or a `dialog[open]`. A closed popover that stays in the page with `role="dialog"` does
25
+ * not count. A keyboard handler reads it before acting on Escape, so the overlay closes first.
26
+ */
27
+ export function isOverlayOpen(root: ParentNode): boolean {
28
+ return OPEN_OVERLAY_SELECTORS.some((selector) => hasMatch(root, selector));
29
+ }