@exegia/corpora-ui 0.20.0 → 0.22.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/auth/auth-flow-atom.d.ts +77 -0
- package/dist-lib/components/blocks/auth/auth-session-atom.d.ts +28 -0
- package/dist-lib/components/blocks/auth/auth-state-type.d.ts +71 -0
- package/dist-lib/components/blocks/auth/auth-state.d.ts +9 -0
- package/dist-lib/components/blocks/auth/use-auth-state.d.ts +52 -0
- package/dist-lib/components/blocks/layout.d.ts +4 -1
- package/dist-lib/components/blocks/nav/sidebar/__tests__/ai-sidebar-atom.test.d.ts +1 -0
- package/dist-lib/components/blocks/nav/sidebar/ai-sidebar-atom.d.ts +217 -0
- package/dist-lib/components/blocks/nav/sidebar/index.d.ts +3 -1
- package/dist-lib/components/blocks/nav/sidebar/sidebar-context.d.ts +3 -0
- package/dist-lib/components/blocks/nav/sidebar/sidebar-row.d.ts +3 -1
- package/dist-lib/components/blocks/nav/sidebar/type.d.ts +109 -29
- package/dist-lib/components/blocks/nav/sidebar/use-ai-sidebar-state.d.ts +29 -0
- package/dist-lib/components/blocks/nav/sidebar/use-ai-sidebar.d.ts +6 -1
- package/dist-lib/components/blocks/nav/sidebar/utils.d.ts +1 -1
- package/dist-lib/components/blocks/profile/index.d.ts +7 -0
- package/dist-lib/components/blocks/profile/profile-card-atom.d.ts +68 -0
- package/dist-lib/components/blocks/profile/profile-card-block.d.ts +28 -39
- package/dist-lib/components/blocks/profile/type.d.ts +80 -0
- package/dist-lib/components/blocks/profile/use-profile-card-state.d.ts +24 -0
- package/dist-lib/components/blocks/profile/use-profile-card.d.ts +34 -0
- package/dist-lib/components/blocks/shell/__tests__/shell-fit-atom.test.d.ts +1 -0
- package/dist-lib/components/blocks/shell/__tests__/shell-metrics.test.d.ts +1 -0
- package/dist-lib/components/blocks/shell/animated-panel-provider.d.ts +1 -1
- package/dist-lib/components/blocks/shell/animated-panel.d.ts +1 -1
- package/dist-lib/components/blocks/shell/index.d.ts +4 -12
- package/dist-lib/components/blocks/shell/shell-fit-atom.d.ts +68 -0
- package/dist-lib/components/blocks/shell/shell-metrics.d.ts +54 -0
- package/dist-lib/components/blocks/shell/type.d.ts +115 -3
- package/dist-lib/components/blocks/shell/use-shell-fit-state.d.ts +25 -0
- package/dist-lib/components/blocks/shell/use-shell-fit.d.ts +14 -0
- package/dist-lib/components/blocks/shell/use-shell-panels.d.ts +12 -1
- package/dist-lib/components/blocks/shell/utils.d.ts +32 -0
- package/dist-lib/components/composed/__tests__/logo.test.d.ts +1 -0
- package/dist-lib/components/composed/logo.d.ts +34 -0
- package/dist-lib/components/composed/tree/__tests__/tree-atom.test.d.ts +1 -0
- package/dist-lib/components/composed/tree/constants.d.ts +4 -4
- package/dist-lib/components/composed/tree/index.d.ts +3 -1
- package/dist-lib/components/composed/tree/tree-atom.d.ts +160 -0
- package/dist-lib/components/composed/tree/tree-node.d.ts +6 -1
- package/dist-lib/components/composed/tree/type.d.ts +116 -18
- package/dist-lib/components/composed/tree/use-tree-dnd.d.ts +18 -7
- package/dist-lib/components/composed/tree/use-tree-state.d.ts +25 -0
- package/dist-lib/components/composed/tree/use-tree.d.ts +4 -0
- package/dist-lib/components/composed/user-avatar.d.ts +5 -28
- package/dist-lib/components/user-avatar/__tests__/user-avatar.test.d.ts +1 -0
- package/dist-lib/components/user-avatar/component.d.ts +1 -8
- package/dist-lib/components/user-avatar/index.d.ts +5 -0
- package/dist-lib/components/user-avatar/presence-badge.d.ts +16 -0
- package/dist-lib/components/user-avatar/type.d.ts +53 -0
- package/dist-lib/components/user-avatar/use-user-avatar-state.d.ts +26 -0
- package/dist-lib/components/user-avatar/use-user-avatar.d.ts +37 -0
- package/dist-lib/components/user-avatar/user-avatar-atom.d.ts +64 -0
- package/dist-lib/components/user-avatar/utils.d.ts +22 -0
- package/dist-lib/index.d.ts +6 -3
- package/dist-lib/index.js +3732 -2670
- package/dist-lib/index.js.map +1 -1
- package/dist-lib/state/exegia-provider.d.ts +51 -0
- package/dist-lib/state/index.d.ts +4 -0
- package/dist-lib/state/store.d.ts +17 -0
- package/package.json +15 -12
- package/src/components/blocks/auth/__tests__/auth-state-atom.test.tsx +247 -0
- package/src/components/blocks/auth/auth-flow-atom.ts +238 -0
- package/src/components/blocks/auth/auth-session-atom.ts +82 -0
- package/src/components/blocks/auth/auth-state-type.ts +97 -0
- package/src/components/blocks/auth/auth-state.ts +52 -0
- package/src/components/blocks/auth/use-auth-state.ts +127 -0
- package/src/components/blocks/layout.ts +30 -2
- package/src/components/blocks/nav/sidebar/__tests__/ai-sidebar-atom.test.tsx +325 -0
- package/src/components/blocks/nav/sidebar/ai-sidebar-atom.ts +698 -0
- package/src/components/blocks/nav/sidebar/ai-sidebar.tsx +48 -42
- package/src/components/blocks/nav/sidebar/index.ts +53 -1
- package/src/components/blocks/nav/sidebar/sidebar-context.ts +15 -0
- package/src/components/blocks/nav/sidebar/sidebar-row.tsx +119 -50
- package/src/components/blocks/nav/sidebar/type.ts +125 -30
- package/src/components/blocks/nav/sidebar/use-ai-sidebar-state.ts +123 -0
- package/src/components/blocks/nav/sidebar/use-ai-sidebar.ts +301 -248
- package/src/components/blocks/nav/sidebar/utils.ts +1 -1
- package/src/components/blocks/profile/__tests__/profile-card-block.test.tsx +194 -0
- package/src/components/blocks/profile/index.ts +28 -0
- package/src/components/blocks/profile/profile-card-atom.ts +247 -0
- package/src/components/blocks/profile/profile-card-block.tsx +153 -74
- package/src/components/blocks/profile/type.ts +95 -0
- package/src/components/blocks/profile/use-profile-card-state.ts +67 -0
- package/src/components/blocks/profile/use-profile-card.ts +126 -0
- package/src/components/blocks/shell/__tests__/shell-fit-atom.test.tsx +360 -0
- package/src/components/blocks/shell/__tests__/shell-layout.test.tsx +192 -3
- package/src/components/blocks/shell/__tests__/shell-metrics.test.ts +108 -0
- package/src/components/blocks/shell/animated-panel-inset.tsx +5 -1
- package/src/components/blocks/shell/animated-panel-provider.tsx +77 -11
- package/src/components/blocks/shell/animated-panel-trigger.tsx +4 -0
- package/src/components/blocks/shell/animated-panel.tsx +126 -29
- package/src/components/blocks/shell/index.ts +18 -13
- package/src/components/blocks/shell/shell-fit-atom.ts +243 -0
- package/src/components/blocks/shell/shell-layout.tsx +55 -53
- package/src/components/blocks/shell/shell-metrics.ts +79 -0
- package/src/components/blocks/shell/type.ts +130 -3
- package/src/components/blocks/shell/use-shell-fit-state.ts +49 -0
- package/src/components/blocks/shell/use-shell-fit.ts +135 -0
- package/src/components/blocks/shell/use-shell-panels.ts +57 -4
- package/src/components/blocks/shell/utils.ts +44 -4
- package/src/components/composed/__tests__/logo.test.tsx +60 -0
- package/src/components/composed/logo.tsx +159 -0
- package/src/components/composed/tree/CLAUDE.md +132 -0
- package/src/components/composed/tree/__tests__/tree-atom.test.tsx +217 -0
- package/src/components/composed/tree/__tests__/tree.test.tsx +162 -37
- package/src/components/composed/tree/__tests__/use-tree.test.tsx +2 -1
- package/src/components/composed/tree/constants.ts +4 -4
- package/src/components/composed/tree/index.ts +38 -0
- package/src/components/composed/tree/tree-atom.ts +590 -0
- package/src/components/composed/tree/tree-node.tsx +117 -78
- package/src/components/composed/tree/tree.tsx +24 -16
- package/src/components/composed/tree/type.ts +125 -15
- package/src/components/composed/tree/use-tree-dnd.ts +82 -51
- package/src/components/composed/tree/use-tree-state.ts +105 -0
- package/src/components/composed/tree/use-tree.ts +185 -184
- package/src/components/composed/user-avatar.tsx +11 -99
- package/src/components/user-avatar/__tests__/user-avatar.test.tsx +286 -0
- package/src/components/user-avatar/component.tsx +151 -22
- package/src/components/user-avatar/fallback.tsx +3 -1
- package/src/components/user-avatar/index.ts +19 -0
- package/src/components/user-avatar/presence-badge.tsx +56 -0
- package/src/components/user-avatar/type.ts +58 -0
- package/src/components/user-avatar/use-user-avatar-state.ts +60 -0
- package/src/components/user-avatar/use-user-avatar.ts +180 -0
- package/src/components/user-avatar/user-avatar-atom.ts +218 -0
- package/src/components/user-avatar/utils.ts +94 -0
- package/src/index.ts +35 -3
- package/src/state/exegia-provider.tsx +79 -0
- package/src/state/index.ts +4 -0
- package/src/state/store.ts +19 -0
- package/dist-lib/components/blocks/nav/sidebar-block.d.ts +0 -14
- package/dist-lib/components/blocks/nav/sidebar-nav-row.d.ts +0 -3
- package/dist-lib/components/blocks/nav/types.d.ts +0 -60
- package/dist-lib/components/blocks/nav/utils.d.ts +0 -1
- package/dist-lib/components/blocks/shell/animated-sidebar-content.d.ts +0 -2
- package/dist-lib/components/blocks/shell/animated-sidebar-footer.d.ts +0 -2
- package/dist-lib/components/blocks/shell/animated-sidebar-group-content.d.ts +0 -2
- package/dist-lib/components/blocks/shell/animated-sidebar-group-label.d.ts +0 -2
- package/dist-lib/components/blocks/shell/animated-sidebar-group.d.ts +0 -2
- package/dist-lib/components/blocks/shell/animated-sidebar-header.d.ts +0 -2
- package/dist-lib/components/blocks/shell/animated-sidebar-menu-button.d.ts +0 -3
- package/dist-lib/components/blocks/shell/animated-sidebar-menu-item.d.ts +0 -2
- package/dist-lib/components/blocks/shell/animated-sidebar-menu-sub-button.d.ts +0 -3
- package/dist-lib/components/blocks/shell/animated-sidebar-menu-sub-item.d.ts +0 -2
- package/dist-lib/components/blocks/shell/animated-sidebar-menu-sub.d.ts +0 -2
- package/dist-lib/components/blocks/shell/animated-sidebar-menu.d.ts +0 -2
- package/src/components/blocks/nav/__tests__/sidebar-block.test.tsx +0 -125
- package/src/components/blocks/nav/sidebar-block.tsx +0 -142
- package/src/components/blocks/nav/sidebar-nav-row.tsx +0 -78
- package/src/components/blocks/nav/types.ts +0 -65
- package/src/components/blocks/nav/utils.ts +0 -4
- package/src/components/blocks/shell/animated-sidebar-content.tsx +0 -19
- package/src/components/blocks/shell/animated-sidebar-footer.tsx +0 -19
- package/src/components/blocks/shell/animated-sidebar-group-content.tsx +0 -16
- package/src/components/blocks/shell/animated-sidebar-group-label.tsx +0 -29
- package/src/components/blocks/shell/animated-sidebar-group.tsx +0 -16
- package/src/components/blocks/shell/animated-sidebar-header.tsx +0 -16
- package/src/components/blocks/shell/animated-sidebar-menu-button.tsx +0 -151
- package/src/components/blocks/shell/animated-sidebar-menu-item.tsx +0 -20
- package/src/components/blocks/shell/animated-sidebar-menu-sub-button.tsx +0 -85
- package/src/components/blocks/shell/animated-sidebar-menu-sub-item.tsx +0 -19
- package/src/components/blocks/shell/animated-sidebar-menu-sub.tsx +0 -44
- package/src/components/blocks/shell/animated-sidebar-menu.tsx +0 -26
- /package/dist-lib/components/blocks/{nav/__tests__/sidebar-block.test.d.ts → auth/__tests__/auth-state-atom.test.d.ts} +0 -0
|
@@ -17,10 +17,18 @@ export interface SidebarResourceMenuControls {
|
|
|
17
17
|
close: () => void;
|
|
18
18
|
rename: () => void;
|
|
19
19
|
}
|
|
20
|
+
/** Key for one sidebar's state in the store. Any stable string;
|
|
21
|
+
* `useAISidebar` generates one when you don't pass it. */
|
|
22
|
+
export type AISidebarInstanceId = string;
|
|
20
23
|
/** Options for `useAISidebar`. `items`, `activeId` and `expandedIds` are
|
|
21
24
|
* each controlled when passed and hook-owned via their `default*` twin
|
|
22
25
|
* otherwise. */
|
|
23
26
|
export interface UseAISidebarOptions {
|
|
27
|
+
/** Key this sidebar's state under a name your app can address —
|
|
28
|
+
* `useAISidebarState("app-resources")` / `useAISidebarActions(...)` reach
|
|
29
|
+
* it from anywhere under `ExegiaProvider`. Without one the hook generates
|
|
30
|
+
* a key and the state is dropped when the component unmounts. */
|
|
31
|
+
sidebarId?: AISidebarInstanceId;
|
|
24
32
|
items?: SidebarResource[];
|
|
25
33
|
defaultItems?: SidebarResource[];
|
|
26
34
|
onItemsChange?: (items: SidebarResource[]) => void;
|
|
@@ -39,6 +47,8 @@ export interface UseAISidebarOptions {
|
|
|
39
47
|
* toolbar, a command palette, a route change. Returned by `useAISidebar`
|
|
40
48
|
* and accepted by `<AISidebar controller={…} />`. */
|
|
41
49
|
export interface AISidebarController {
|
|
50
|
+
/** The key this sidebar's state is stored under. */
|
|
51
|
+
sidebarId: AISidebarInstanceId;
|
|
42
52
|
items: SidebarResource[];
|
|
43
53
|
/** Visible rows in order, each with its depth and parent id. */
|
|
44
54
|
flat: FlatResource[];
|
|
@@ -74,6 +84,8 @@ export interface AISidebarController {
|
|
|
74
84
|
movePending: boolean;
|
|
75
85
|
/** Live-region text for the last move or rename outcome. */
|
|
76
86
|
announcement: string;
|
|
87
|
+
/** Back to the values the sidebar mounted with. */
|
|
88
|
+
reset: () => void;
|
|
77
89
|
/** @internal Row wiring the view threads through — drag state, the
|
|
78
90
|
* hover pill and roving keyboard nav all belong to the rendering. */
|
|
79
91
|
dnd: AISidebarDndState;
|
|
@@ -82,10 +94,15 @@ export interface AISidebarController {
|
|
|
82
94
|
setRowRef: (id: string, node: HTMLDivElement | null) => void;
|
|
83
95
|
}
|
|
84
96
|
/** @internal */
|
|
85
|
-
export interface AISidebarDndState {
|
|
97
|
+
export interface AISidebarDndState extends AISidebarRowDndHandlers {
|
|
86
98
|
draggingId: string | null;
|
|
87
99
|
dropTarget: DropTarget | null;
|
|
88
100
|
onRootDragOver: (event: DragEvent<HTMLDivElement>) => void;
|
|
101
|
+
}
|
|
102
|
+
/** @internal The drag handlers a row needs, stable for the life of the
|
|
103
|
+
* sidebar — they read drag state out of the store when they run instead of
|
|
104
|
+
* closing over it, so handing them to every row costs no re-renders. */
|
|
105
|
+
export interface AISidebarRowDndHandlers {
|
|
89
106
|
onDrop: (event: DragEvent<HTMLDivElement>) => void;
|
|
90
107
|
onRowDragStart: (event: DragEvent<HTMLDivElement>, id: string) => void;
|
|
91
108
|
onRowDragEnd: () => void;
|
|
@@ -130,36 +147,99 @@ export interface DropTarget {
|
|
|
130
147
|
id: string | null;
|
|
131
148
|
position: SidebarResourceDropPosition;
|
|
132
149
|
}
|
|
150
|
+
/** A row takes its place in the tree and nothing else: selection,
|
|
151
|
+
* expansion, focus, rename, drag and hover state all arrive through its own
|
|
152
|
+
* atoms, and the rendering options through the sidebar context. */
|
|
133
153
|
export interface ResourceRowProps {
|
|
134
154
|
row: FlatResource;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
onMenuOpenChange: (open: boolean) => void;
|
|
149
|
-
onRenameCancel: () => void;
|
|
150
|
-
onRenameCommit: (label: string) => void;
|
|
151
|
-
onRenameStart: () => void;
|
|
152
|
-
onSelect: () => void;
|
|
153
|
-
onToggle: () => void;
|
|
154
|
-
/** Some row in the tree is hovered — mounts the pill fade wrapper. */
|
|
155
|
-
hoverActive?: boolean;
|
|
156
|
-
/** This row owns the sliding hover pill. */
|
|
157
|
-
hoverPill?: boolean;
|
|
158
|
-
/** Shared motion layoutId that lets the pill travel between rows. */
|
|
159
|
-
hoverLayoutId?: string;
|
|
160
|
-
onHoverChange?: (hovered: boolean) => void;
|
|
161
|
-
renderIcon?: (item: SidebarResource) => ReactNode;
|
|
155
|
+
}
|
|
156
|
+
/** @internal What a row needs from the block, threaded through context so
|
|
157
|
+
* the rows stay prop-light.
|
|
158
|
+
*
|
|
159
|
+
* Deliberately free of sidebar state and of the controller. Rows read state
|
|
160
|
+
* from per-row atoms, so this value keeps its identity for the life of the
|
|
161
|
+
* sidebar and hovering or expanding one row no longer re-renders every row
|
|
162
|
+
* through context. */
|
|
163
|
+
export interface AISidebarContextValue {
|
|
164
|
+
sidebarId: AISidebarInstanceId;
|
|
165
|
+
/** Shared motion layoutId that lets the hover pill travel between rows. */
|
|
166
|
+
hoverLayoutId: string;
|
|
167
|
+
renderIcon?: AISidebarProps["renderIcon"];
|
|
162
168
|
renderMenu?: AISidebarProps["renderMenu"];
|
|
163
169
|
renderActionsTrigger?: AISidebarProps["renderActionsTrigger"];
|
|
164
|
-
|
|
170
|
+
/** Registers the row's DOM node with the block, which owns the ref map —
|
|
171
|
+
* DOM nodes never go in the store. */
|
|
172
|
+
setRowRef: (id: string, node: HTMLDivElement | null) => void;
|
|
173
|
+
onRowKeyDown: (event: KeyboardEvent<HTMLDivElement>, row: FlatResource) => void;
|
|
174
|
+
onRowHover: (id: string, hovered: boolean) => void;
|
|
175
|
+
/** Closing returns DOM focus to the row that owned the menu, so it goes
|
|
176
|
+
* through the block rather than the store. */
|
|
177
|
+
closeMenu: () => void;
|
|
178
|
+
dnd: AISidebarRowDndHandlers;
|
|
179
|
+
}
|
|
180
|
+
/** Everything observable about one sidebar, for consumers reading it by id. */
|
|
181
|
+
export interface AISidebarState {
|
|
182
|
+
items: SidebarResource[];
|
|
183
|
+
/** Visible rows in order, each with its depth and parent id. */
|
|
184
|
+
flat: FlatResource[];
|
|
185
|
+
selectedId: string | null;
|
|
186
|
+
expandedIds: ReadonlySet<string>;
|
|
187
|
+
focusedId: string | null;
|
|
188
|
+
renamingId: string | null;
|
|
189
|
+
menuOpenId: string | null;
|
|
190
|
+
draggingId: string | null;
|
|
191
|
+
dropTarget: DropTarget | null;
|
|
192
|
+
hoveredId: string | null;
|
|
193
|
+
/** A move is in flight — further moves are refused until it settles. */
|
|
194
|
+
movePending: boolean;
|
|
195
|
+
/** Live-region text for the last move or rename outcome. */
|
|
196
|
+
announcement: string;
|
|
197
|
+
}
|
|
198
|
+
/** Everything doable to one sidebar from outside its component. */
|
|
199
|
+
export interface AISidebarActions {
|
|
200
|
+
select: (id: string) => void;
|
|
201
|
+
expand: (id: string) => void;
|
|
202
|
+
collapse: (id: string) => void;
|
|
203
|
+
toggleExpanded: (id: string) => void;
|
|
204
|
+
expandAll: () => void;
|
|
205
|
+
collapseAll: () => void;
|
|
206
|
+
reveal: (id: string) => void;
|
|
207
|
+
/** Moves the roving-focus target. DOM focus follows only for callers that
|
|
208
|
+
* hold the controller — the ref map lives in the block, not the store. */
|
|
209
|
+
focus: (id: string) => void;
|
|
210
|
+
startRename: (id: string) => void;
|
|
211
|
+
cancelRename: () => void;
|
|
212
|
+
rename: (id: string, label: string) => void;
|
|
213
|
+
openMenu: (id: string) => void;
|
|
214
|
+
closeMenu: () => void;
|
|
215
|
+
move: (move: SidebarResourceMove) => Promise<void>;
|
|
216
|
+
setItems: (items: SidebarResource[]) => void;
|
|
217
|
+
reset: () => void;
|
|
218
|
+
}
|
|
219
|
+
/** @internal Projection of `useAISidebar`'s options — primitives only, so
|
|
220
|
+
* the store write runs once per real change instead of once per render. */
|
|
221
|
+
export interface AISidebarConfig {
|
|
222
|
+
controlsItems: boolean;
|
|
223
|
+
controlsActiveId: boolean;
|
|
224
|
+
controlsExpandedIds: boolean;
|
|
225
|
+
}
|
|
226
|
+
/** @internal Latest option callbacks. Only write atoms read this, so it can
|
|
227
|
+
* be refreshed every commit without re-rendering anything. */
|
|
228
|
+
export interface AISidebarHandlers {
|
|
229
|
+
onItemsChange?: (items: SidebarResource[]) => void;
|
|
230
|
+
onMove?: (move: SidebarResourceMove) => void | Promise<void>;
|
|
231
|
+
onMoveError?: (error: unknown, move: SidebarResourceMove) => void;
|
|
232
|
+
onRename?: (item: SidebarResource, label: string) => void | Promise<void>;
|
|
233
|
+
onActiveChange?: (id: string) => void;
|
|
234
|
+
onExpandedChange?: (ids: string[]) => void;
|
|
235
|
+
}
|
|
236
|
+
/** @internal What an instance starts from, replayed by
|
|
237
|
+
* `resetAISidebarAtom`. */
|
|
238
|
+
export interface AISidebarSeed {
|
|
239
|
+
items: SidebarResource[];
|
|
240
|
+
/** Hook-owned selection — the `defaultActiveId`, never the controlled
|
|
241
|
+
* `activeId`. */
|
|
242
|
+
activeId: string | null;
|
|
243
|
+
focusedId: string | null;
|
|
244
|
+
expandedIds: string[];
|
|
165
245
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AISidebarActions, AISidebarInstanceId, AISidebarState } from './type.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Read the sidebar registered under `sidebarId` from anywhere below
|
|
4
|
+
* `ExegiaProvider` — no controller, no props, no provider of its own.
|
|
5
|
+
*
|
|
6
|
+
* ```tsx
|
|
7
|
+
* const { selectedId, movePending } = useAISidebarState("app-resources")
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* This returns the whole state object, so the caller re-renders on any
|
|
11
|
+
* change. A component that reads one field should subscribe to that field's
|
|
12
|
+
* atom instead: `useAtomValue(aiSidebarActiveIdAtom("app-resources"))`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useAISidebarState(sidebarId: AISidebarInstanceId): AISidebarState;
|
|
15
|
+
/**
|
|
16
|
+
* Drive the sidebar registered under `sidebarId` from anywhere. Writes only —
|
|
17
|
+
* the caller never re-renders when the sidebar changes, so this is what a
|
|
18
|
+
* command palette, a keyboard shortcut or a route guard should reach for.
|
|
19
|
+
*
|
|
20
|
+
* `focus` and `closeMenu` move the store's roving target; DOM focus follows
|
|
21
|
+
* only for callers that hold the controller, because the row refs live in
|
|
22
|
+
* the block rather than the store.
|
|
23
|
+
*
|
|
24
|
+
* ```tsx
|
|
25
|
+
* const resources = useAISidebarActions("app-resources")
|
|
26
|
+
* <Button onClick={resources.collapseAll}>Collapse all</Button>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function useAISidebarActions(sidebarId: AISidebarInstanceId): AISidebarActions;
|
|
@@ -8,7 +8,7 @@ export type { UseAISidebarOptions };
|
|
|
8
8
|
*
|
|
9
9
|
* `items`, `activeId` and `expandedIds` are each controlled when passed
|
|
10
10
|
* and hook-owned via their `default*` twin otherwise. Reorder and rename
|
|
11
|
-
* are applied to the data optimistically
|
|
11
|
+
* are applied to the data optimistically and rolled back if
|
|
12
12
|
* `onMove`/`onRename` rejects, so a consumer never reduces the tree
|
|
13
13
|
* itself — `moveResource` and `renameResource` are exported for the ones
|
|
14
14
|
* who keep their data elsewhere.
|
|
@@ -18,5 +18,10 @@ export type { UseAISidebarOptions };
|
|
|
18
18
|
* <AISidebar controller={sidebar} />
|
|
19
19
|
* <Button onClick={sidebar.collapseAll}>Collapse all</Button>
|
|
20
20
|
* ```
|
|
21
|
+
*
|
|
22
|
+
* State lives in Jotai atoms keyed by `sidebarId`, so anything under
|
|
23
|
+
* `ExegiaProvider` can drive this sidebar without the controller — name it
|
|
24
|
+
* and reach for `useAISidebarState(sidebarId)` /
|
|
25
|
+
* `useAISidebarActions(sidebarId)` elsewhere.
|
|
21
26
|
*/
|
|
22
27
|
export declare function useAISidebar(options: UseAISidebarOptions): AISidebarController;
|
|
@@ -4,7 +4,7 @@ export declare const ROW_REVEAL: {
|
|
|
4
4
|
readonly ease: readonly [0.16, 1, 0.3, 1];
|
|
5
5
|
};
|
|
6
6
|
export declare function canContain(item: SidebarResource): boolean;
|
|
7
|
-
export declare function flattenResources(items: SidebarResource[], expanded:
|
|
7
|
+
export declare function flattenResources(items: SidebarResource[], expanded: ReadonlySet<string>, depth?: number, parentId?: string | null): FlatResource[];
|
|
8
8
|
export declare function findResource(items: SidebarResource[], id: string): SidebarResource | undefined;
|
|
9
9
|
/** Ids of every ancestor of `id` (nearest last); empty when absent. */
|
|
10
10
|
export declare function ancestorIdsOf(items: SidebarResource[], id: string): string[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ProfileCardBlock, defaultProfileCardItems, } from './profile-card-block';
|
|
2
|
+
export type { ProfileCardBlockProps } from './profile-card-block';
|
|
3
|
+
export { useProfileCard } from './use-profile-card';
|
|
4
|
+
export type { ProfileCardBinding, UseProfileCardOptions } from './use-profile-card';
|
|
5
|
+
export { useProfileCardActions, useProfileCardState, } from './use-profile-card-state';
|
|
6
|
+
export { profileCardBusyAtom, profileCardCollapsedAtom, profileCardMenuOpenAtom, profileCardPendingActionIdAtom, profileCardStateAtom, profileCardVariantAtom, removeProfileCardInstance, resetProfileCardAtom, selectProfileCardActionAtom, setProfileCardMenuOpenAtom, setProfileCardVariantAtom, toggleProfileCardVariantAtom, } from './profile-card-atom';
|
|
7
|
+
export type * from './type';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ProfileCardAction, ProfileCardConfig, ProfileCardHandlers, ProfileCardInstanceId, ProfileCardState, ProfileCardVariant } from './type';
|
|
2
|
+
type Family<AtomType> = ((id: ProfileCardInstanceId) => AtomType) & {
|
|
3
|
+
remove: (id: ProfileCardInstanceId) => void;
|
|
4
|
+
};
|
|
5
|
+
export declare const profileCardVariantAtom: Family<import('jotai').PrimitiveAtom<ProfileCardVariant> & {
|
|
6
|
+
init: ProfileCardVariant;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const profileCardMenuOpenAtom: Family<import('jotai').PrimitiveAtom<boolean> & {
|
|
9
|
+
init: boolean;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const profileCardPendingActionIdAtom: Family<import('jotai').PrimitiveAtom<string | null> & {
|
|
12
|
+
init: string | null;
|
|
13
|
+
}>;
|
|
14
|
+
/** @internal */
|
|
15
|
+
export declare const profileCardConfigAtom: Family<import('jotai').PrimitiveAtom<ProfileCardConfig> & {
|
|
16
|
+
init: ProfileCardConfig;
|
|
17
|
+
}>;
|
|
18
|
+
/** @internal */
|
|
19
|
+
export declare const profileCardHandlersAtom: Family<import('jotai').PrimitiveAtom<ProfileCardHandlers> & {
|
|
20
|
+
init: ProfileCardHandlers;
|
|
21
|
+
}>;
|
|
22
|
+
export declare const profileCardCollapsedAtom: Family<import('jotai').Atom<boolean>>;
|
|
23
|
+
export declare const profileCardBusyAtom: Family<import('jotai').Atom<boolean>>;
|
|
24
|
+
/** Whole-state read for callers that want the object; the field atoms are
|
|
25
|
+
* cheaper for components that watch one thing. */
|
|
26
|
+
export declare const profileCardStateAtom: Family<import('jotai').Atom<ProfileCardState>>;
|
|
27
|
+
/** Reports through `onVariantChange` always; writes the store only when no
|
|
28
|
+
* `variant` prop controls the card — the prop is truth then. */
|
|
29
|
+
export declare const setProfileCardVariantAtom: Family<import('jotai').WritableAtom<null, [variant: ProfileCardVariant], void> & {
|
|
30
|
+
init: null;
|
|
31
|
+
}>;
|
|
32
|
+
export declare const toggleProfileCardVariantAtom: Family<import('jotai').WritableAtom<null, [], void> & {
|
|
33
|
+
init: null;
|
|
34
|
+
}>;
|
|
35
|
+
/** Inert while an `open` prop controls the menu. */
|
|
36
|
+
export declare const setProfileCardMenuOpenAtom: Family<import('jotai').WritableAtom<null, [open: boolean], void> & {
|
|
37
|
+
init: null;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Run an action's `onSelect`. A returned promise marks the card busy until it
|
|
41
|
+
* settles; a rejection goes to `onError` and the card leaves its busy state
|
|
42
|
+
* either way. Because the pending id is a store value, it survives the card
|
|
43
|
+
* unmounting mid-flight (sign-out typically unmounts it) — the settle just
|
|
44
|
+
* writes to an instance nobody renders any more.
|
|
45
|
+
*/
|
|
46
|
+
export declare const selectProfileCardActionAtom: Family<import('jotai').WritableAtom<null, [action: ProfileCardAction], void> & {
|
|
47
|
+
init: null;
|
|
48
|
+
}>;
|
|
49
|
+
/** @internal Projection of the mounted component's controlled props. */
|
|
50
|
+
export declare const projectProfileCardPropsAtom: Family<import('jotai').WritableAtom<null, [config: ProfileCardConfig, variant: ProfileCardVariant | undefined, menuOpen: boolean | undefined], void> & {
|
|
51
|
+
init: null;
|
|
52
|
+
}>;
|
|
53
|
+
/** @internal */
|
|
54
|
+
export declare const setProfileCardHandlersAtom: Family<import('jotai').WritableAtom<null, [handlers: ProfileCardHandlers], void> & {
|
|
55
|
+
init: null;
|
|
56
|
+
}>;
|
|
57
|
+
/** @internal Seed the uncontrolled variant on mount without firing
|
|
58
|
+
* `onVariantChange`. */
|
|
59
|
+
export declare const seedProfileCardVariantAtom: Family<import('jotai').WritableAtom<null, [variant: ProfileCardVariant], void> & {
|
|
60
|
+
init: null;
|
|
61
|
+
}>;
|
|
62
|
+
export declare const resetProfileCardAtom: Family<import('jotai').WritableAtom<null, [], void> & {
|
|
63
|
+
init: null;
|
|
64
|
+
}>;
|
|
65
|
+
/** Forget a card entirely — every family drops the key so the store can
|
|
66
|
+
* release its state. Call on teardown of a named instance. */
|
|
67
|
+
export declare function removeProfileCardInstance(id: ProfileCardInstanceId): void;
|
|
68
|
+
export {};
|
|
@@ -1,42 +1,7 @@
|
|
|
1
1
|
import { DropdownMenuContent, MenuPrimitive } from '../../ui/menu';
|
|
2
|
+
import { ProfileCardItem, ProfileCardUser, ProfileCardVariant } from './type';
|
|
2
3
|
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
export interface ProfileCardUser {
|
|
5
|
-
name: string;
|
|
6
|
-
/** Secondary line under the name — a handle, an email, a role. */
|
|
7
|
-
username?: string;
|
|
8
|
-
/** Avatar image URL. Falls back to the initials when absent or broken. */
|
|
9
|
-
avatar?: string;
|
|
10
|
-
/** Fallback initials. Derived from `name` when omitted. */
|
|
11
|
-
initials?: string;
|
|
12
|
-
}
|
|
13
|
-
/** An actionable row of the menu. */
|
|
14
|
-
export interface ProfileCardAction {
|
|
15
|
-
type?: "item";
|
|
16
|
-
id: string;
|
|
17
|
-
label: string;
|
|
18
|
-
icon?: React.ReactNode;
|
|
19
|
-
/** Right-aligned hint, e.g. "⌘K". Purely decorative — bind the key yourself. */
|
|
20
|
-
shortcut?: string;
|
|
21
|
-
disabled?: boolean;
|
|
22
|
-
variant?: "default" | "destructive";
|
|
23
|
-
/** Returning a promise puts the card in its loading state until it settles. */
|
|
24
|
-
onSelect?: () => void | Promise<void>;
|
|
25
|
-
}
|
|
26
|
-
/** A heading over the rows that follow it, up to the next separator. */
|
|
27
|
-
export interface ProfileCardLabel {
|
|
28
|
-
type: "label";
|
|
29
|
-
label: string;
|
|
30
|
-
}
|
|
31
|
-
/** A rule between two sections. */
|
|
32
|
-
export interface ProfileCardSeparator {
|
|
33
|
-
type: "separator";
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* One entry of `items`. Authored flat; the block renders each run between
|
|
37
|
-
* separators as its own menu group so a label actually names its section.
|
|
38
|
-
*/
|
|
39
|
-
export type ProfileCardItem = ProfileCardAction | ProfileCardLabel | ProfileCardSeparator;
|
|
4
|
+
export type { ProfileCardAction, ProfileCardActions, ProfileCardInstanceId, ProfileCardItem, ProfileCardLabel, ProfileCardSeparator, ProfileCardState, ProfileCardUser, ProfileCardVariant, } from './type';
|
|
40
5
|
/**
|
|
41
6
|
* The menu the card ships with. Spread it to keep the shape and attach your
|
|
42
7
|
* own handlers, or ignore it and pass `items` of your own.
|
|
@@ -62,6 +27,31 @@ export interface ProfileCardBlockProps {
|
|
|
62
27
|
* width, so `align` stops mattering horizontally.
|
|
63
28
|
*/
|
|
64
29
|
menuWidth?: "content" | "card";
|
|
30
|
+
/**
|
|
31
|
+
* `expanded` shows avatar, name and handle; `collapsed` folds the card to
|
|
32
|
+
* its avatar — for an icon-collapsed sidebar rail. The fold animates: the
|
|
33
|
+
* identity lines and chevron slide to zero width, the avatar stays put.
|
|
34
|
+
* Controlled when passed. Left unset, the card follows the `AnimatedPanel`
|
|
35
|
+
* it sits in (a panel footer folds with the rail on its own), and
|
|
36
|
+
* outside a panel starts from `defaultVariant`.
|
|
37
|
+
*/
|
|
38
|
+
variant?: ProfileCardVariant;
|
|
39
|
+
defaultVariant?: ProfileCardVariant;
|
|
40
|
+
onVariantChange?: (variant: ProfileCardVariant) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Name this card's slice of the store so `useProfileCardState(id)` /
|
|
43
|
+
* `useProfileCardActions(id)` can read or drive it (fold it, open its
|
|
44
|
+
* menu) from anywhere under `ExegiaProvider`. Unnamed cards key off
|
|
45
|
+
* `useId` and are dropped on unmount.
|
|
46
|
+
*/
|
|
47
|
+
profileCardId?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Presence badge on the avatar — overrides `user.presence`. Name the avatar
|
|
50
|
+
* with `avatarId` and `useUserAvatarActions(id).setPresence()` can flip it
|
|
51
|
+
* from a socket handler instead.
|
|
52
|
+
*/
|
|
53
|
+
presence?: ProfileCardUser["presence"];
|
|
54
|
+
avatarId?: string;
|
|
65
55
|
/**
|
|
66
56
|
* Emit cuelume press/release on the card and play the open/close cues.
|
|
67
57
|
* Inert unless the app opts into interaction sound via `bindSounds()`.
|
|
@@ -78,5 +68,4 @@ export interface ProfileCardBlockProps {
|
|
|
78
68
|
* popup is a plain action menu. `items` is the whole menu — a flat list of
|
|
79
69
|
* actions, separators and labels — defaulting to `defaultProfileCardItems`.
|
|
80
70
|
*/
|
|
81
|
-
export declare function ProfileCardBlock({ user, items, align, side, sideOffset, menuWidth, open, defaultOpen, onOpenChange, sound, onError, className, }: ProfileCardBlockProps): React.ReactElement;
|
|
82
|
-
export {};
|
|
71
|
+
export declare function ProfileCardBlock({ user, items, align, side, sideOffset, menuWidth, variant: variantProp, defaultVariant, onVariantChange, profileCardId, presence, avatarId, open, defaultOpen, onOpenChange, sound, onError, className, }: ProfileCardBlockProps): React.ReactElement;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { UserPresence } from '../../user-avatar';
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
/** The identity shown on the card. */
|
|
4
|
+
export interface ProfileCardUser {
|
|
5
|
+
name: string;
|
|
6
|
+
/** Secondary line under the name — a handle, an email, a role. */
|
|
7
|
+
username?: string;
|
|
8
|
+
/** Avatar image URL. Falls back to the initials when absent or broken. */
|
|
9
|
+
avatar?: string;
|
|
10
|
+
/** Fallback initials. Derived from `name` when omitted. */
|
|
11
|
+
initials?: string;
|
|
12
|
+
/** Presence badge on the avatar. Omitted, no badge. */
|
|
13
|
+
presence?: UserPresence;
|
|
14
|
+
}
|
|
15
|
+
/** An actionable row of the menu. */
|
|
16
|
+
export interface ProfileCardAction {
|
|
17
|
+
type?: "item";
|
|
18
|
+
id: string;
|
|
19
|
+
label: string;
|
|
20
|
+
icon?: React.ReactNode;
|
|
21
|
+
/** Right-aligned hint, e.g. "⌘K". Purely decorative — bind the key yourself. */
|
|
22
|
+
shortcut?: string;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
variant?: "default" | "destructive";
|
|
25
|
+
/** Returning a promise puts the card in its loading state until it settles. */
|
|
26
|
+
onSelect?: () => void | Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
/** A heading over the rows that follow it, up to the next separator. */
|
|
29
|
+
export interface ProfileCardLabel {
|
|
30
|
+
type: "label";
|
|
31
|
+
label: string;
|
|
32
|
+
}
|
|
33
|
+
/** A rule between two sections. */
|
|
34
|
+
export interface ProfileCardSeparator {
|
|
35
|
+
type: "separator";
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* One entry of `items`. Authored flat; the block renders each run between
|
|
39
|
+
* separators as its own menu group so a label actually names its section.
|
|
40
|
+
*/
|
|
41
|
+
export type ProfileCardItem = ProfileCardAction | ProfileCardLabel | ProfileCardSeparator;
|
|
42
|
+
/** `expanded` shows avatar, name and handle; `collapsed` folds to the avatar
|
|
43
|
+
* alone — for an icon-collapsed sidebar rail. */
|
|
44
|
+
export type ProfileCardVariant = "expanded" | "collapsed";
|
|
45
|
+
/** Key for one card's state in the store. Any stable string; `useProfileCard`
|
|
46
|
+
* generates one when the component does not name itself. */
|
|
47
|
+
export type ProfileCardInstanceId = string;
|
|
48
|
+
/** Everything the store knows about one card. */
|
|
49
|
+
export interface ProfileCardState {
|
|
50
|
+
variant: ProfileCardVariant;
|
|
51
|
+
menuOpen: boolean;
|
|
52
|
+
/** Id of the action whose promise is in flight, `null` while idle. */
|
|
53
|
+
pendingActionId: string | null;
|
|
54
|
+
/** `pendingActionId !== null` — the trigger is disabled and shows a spinner. */
|
|
55
|
+
busy: boolean;
|
|
56
|
+
}
|
|
57
|
+
/** Write-only handles onto one card. Nothing here re-renders the caller. */
|
|
58
|
+
export interface ProfileCardActions {
|
|
59
|
+
setVariant: (variant: ProfileCardVariant) => void;
|
|
60
|
+
toggleVariant: () => void;
|
|
61
|
+
/** Convenience over `setVariant`. */
|
|
62
|
+
collapse: () => void;
|
|
63
|
+
expand: () => void;
|
|
64
|
+
setMenuOpen: (open: boolean) => void;
|
|
65
|
+
openMenu: () => void;
|
|
66
|
+
closeMenu: () => void;
|
|
67
|
+
reset: () => void;
|
|
68
|
+
}
|
|
69
|
+
/** @internal Which fields the mounted component controls from props. The
|
|
70
|
+
* store must never overwrite a controlled value. */
|
|
71
|
+
export interface ProfileCardConfig {
|
|
72
|
+
controlsVariant: boolean;
|
|
73
|
+
controlsMenuOpen: boolean;
|
|
74
|
+
}
|
|
75
|
+
/** @internal Latest option callbacks. Only write atoms read this, so it can
|
|
76
|
+
* be refreshed every commit without re-rendering anything. */
|
|
77
|
+
export interface ProfileCardHandlers {
|
|
78
|
+
onVariantChange?: (variant: ProfileCardVariant) => void;
|
|
79
|
+
onError?: (error: unknown) => void;
|
|
80
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ProfileCardActions, ProfileCardInstanceId, ProfileCardState } from './type';
|
|
2
|
+
/**
|
|
3
|
+
* Read the card registered under `profileCardId` from anywhere below
|
|
4
|
+
* `ExegiaProvider` — no props, no ref, no provider of its own.
|
|
5
|
+
*
|
|
6
|
+
* ```tsx
|
|
7
|
+
* const { variant, busy } = useProfileCardState("account")
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* Returns the whole state object, so the caller re-renders on any change. A
|
|
11
|
+
* component that watches one field should subscribe to that atom instead:
|
|
12
|
+
* `useAtomValue(profileCardVariantAtom("account"))`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useProfileCardState(profileCardId: ProfileCardInstanceId): ProfileCardState;
|
|
15
|
+
/**
|
|
16
|
+
* Write-only handles onto the card registered under `profileCardId`. Nothing
|
|
17
|
+
* here subscribes, so a rail toggle can fold the card without re-rendering
|
|
18
|
+
* when the card changes.
|
|
19
|
+
*
|
|
20
|
+
* ```tsx
|
|
21
|
+
* const { collapse, expand } = useProfileCardActions("account")
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function useProfileCardActions(profileCardId: ProfileCardInstanceId): ProfileCardActions;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ProfileCardAction, ProfileCardInstanceId, ProfileCardVariant } from './type';
|
|
2
|
+
export interface UseProfileCardOptions {
|
|
3
|
+
profileCardId?: ProfileCardInstanceId;
|
|
4
|
+
/** Controlled fold. `undefined` leaves the store (and `defaultVariant`) in charge. */
|
|
5
|
+
variant?: ProfileCardVariant;
|
|
6
|
+
defaultVariant?: ProfileCardVariant;
|
|
7
|
+
onVariantChange?: (variant: ProfileCardVariant) => void;
|
|
8
|
+
/** Controlled menu. */
|
|
9
|
+
open?: boolean;
|
|
10
|
+
defaultOpen?: boolean;
|
|
11
|
+
onError?: (error: unknown) => void;
|
|
12
|
+
}
|
|
13
|
+
export interface ProfileCardBinding {
|
|
14
|
+
profileCardId: ProfileCardInstanceId;
|
|
15
|
+
variant: ProfileCardVariant;
|
|
16
|
+
collapsed: boolean;
|
|
17
|
+
menuOpen: boolean;
|
|
18
|
+
busy: boolean;
|
|
19
|
+
/** Hand to the menu's `onOpenChange` (first argument). Stable. */
|
|
20
|
+
setMenuOpen: (open: boolean) => void;
|
|
21
|
+
/** Run an action: `onSelect`, promise → busy, rejection → `onError`. Stable. */
|
|
22
|
+
select: (action: ProfileCardAction) => void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Binds one profile card to its slice of the store: projects the controlled
|
|
26
|
+
* `variant` / `open` props (one-way, with write gates so the store never
|
|
27
|
+
* overwrites a prop), publishes the latest handlers, and returns the values
|
|
28
|
+
* the component renders from.
|
|
29
|
+
*
|
|
30
|
+
* Unnamed cards key off `useId` and are dropped on unmount; a named
|
|
31
|
+
* `profileCardId` outlives its component, so a fold set from elsewhere
|
|
32
|
+
* (`useProfileCardActions(id).collapse()`) survives a route change.
|
|
33
|
+
*/
|
|
34
|
+
export declare function useProfileCard(options: UseProfileCardOptions): ProfileCardBinding;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AnimatedSidebarProviderProps } from './type';
|
|
2
|
-
export declare function AnimatedPanelProvider({ children, open, defaultOpen, onOpenChange, openMobile, defaultOpenMobile, onOpenMobileChange, className, style, ...props }: AnimatedSidebarProviderProps): import("react").JSX.Element;
|
|
2
|
+
export declare function AnimatedPanelProvider({ children, shellId, defaultPanelWidth, open, defaultOpen, onOpenChange, openMobile, defaultOpenMobile, onOpenMobileChange, onNarrowChange, className, style, ...props }: AnimatedSidebarProviderProps): import("react").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AnimatedSidebarProps } from './type';
|
|
2
|
-
export declare function AnimatedPanel({ side, variant, collapsible, ariaLabel, children, className, panelClassName, style, ref, ...props }: AnimatedSidebarProps): import("react").JSX.Element;
|
|
2
|
+
export declare function AnimatedPanel({ side, variant, collapsible, ariaLabel, children, className, panelClassName, style, ref, ...props }: AnimatedSidebarProps): import("react").JSX.Element | null;
|
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
import { ShellLayout } from './shell-layout';
|
|
2
2
|
export type * from './type';
|
|
3
|
+
export * from './shell-metrics';
|
|
3
4
|
export * from './use-shell-panels';
|
|
5
|
+
export { useShellFit } from './use-shell-fit';
|
|
6
|
+
export { useShellFitActions, useShellFitState } from './use-shell-fit-state';
|
|
7
|
+
export { removeShellFitInstance, resetShellPanelWidthAtom, resizeShellPanelAtom, shellFitFitsAtom, shellFitMeasuredAtom, shellFitMetricsAtom, shellFitPanelBoundsAtom, shellFitPanelWidthAtom, shellFitRequestedWidthAtom, shellFitStateAtom, } from './shell-fit-atom';
|
|
4
8
|
export * from './utils';
|
|
5
9
|
export * from './animated-panel';
|
|
6
10
|
export * from './animated-panel-inset';
|
|
7
11
|
export * from './animated-panel-provider';
|
|
8
12
|
export * from './animated-panel-trigger';
|
|
9
|
-
export * from './animated-sidebar-header';
|
|
10
|
-
export * from './animated-sidebar-content';
|
|
11
|
-
export * from './animated-sidebar-footer';
|
|
12
|
-
export * from './animated-sidebar-group';
|
|
13
|
-
export * from './animated-sidebar-group-label';
|
|
14
|
-
export * from './animated-sidebar-group-content';
|
|
15
|
-
export * from './animated-sidebar-menu';
|
|
16
|
-
export * from './animated-sidebar-menu-item';
|
|
17
|
-
export * from './animated-sidebar-menu-sub';
|
|
18
|
-
export * from './animated-sidebar-menu-sub-item';
|
|
19
|
-
export * from './animated-sidebar-menu-sub-button';
|
|
20
|
-
export * from './animated-sidebar-menu-button';
|
|
21
13
|
export { ShellLayout as default };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ShellMetrics } from './shell-metrics';
|
|
2
|
+
import { ShellFitInstanceId, ShellFitPanelBounds, ShellFitSeed, ShellFitState } from './type';
|
|
3
|
+
/**
|
|
4
|
+
* A string-keyed atom family.
|
|
5
|
+
*
|
|
6
|
+
* `jotai/utils`' `atomFamily` is deprecated for Jotai v3, and we need only
|
|
7
|
+
* the string-keyed case with a `remove` — so this stays in-house rather than
|
|
8
|
+
* adding `jotai-family` as a second Jotai package to keep version-aligned.
|
|
9
|
+
* Dropping a key lets the store's WeakMap release that instance's state.
|
|
10
|
+
*/
|
|
11
|
+
type Family<AtomType> = ((id: ShellFitInstanceId) => AtomType) & {
|
|
12
|
+
remove: (id: ShellFitInstanceId) => void;
|
|
13
|
+
};
|
|
14
|
+
/** The shell's own measurement of its columns. `useShellFit` is the only
|
|
15
|
+
* writer; read `shellFitMeasuredAtom` to get it with the "no layout yet" case
|
|
16
|
+
* already resolved. */
|
|
17
|
+
export declare const shellFitMetricsAtom: Family<import('jotai').PrimitiveAtom<ShellMetrics> & {
|
|
18
|
+
init: ShellMetrics;
|
|
19
|
+
}>;
|
|
20
|
+
/** The width the user dragged to, before clamping — null while the panel sits
|
|
21
|
+
* at `--panel-width`. Read `shellFitPanelWidthAtom` for the width the panel
|
|
22
|
+
* actually renders at: clamping on read is what lets a narrowing viewport
|
|
23
|
+
* pull the panel down without forgetting the width they asked for. */
|
|
24
|
+
export declare const shellFitRequestedWidthAtom: Family<import('jotai').PrimitiveAtom<number | null> & {
|
|
25
|
+
init: number | null;
|
|
26
|
+
}>;
|
|
27
|
+
/** The metrics, or null when the shell has no layout to report — a server
|
|
28
|
+
* render, a `display: none` host, a test with no layout engine. A zero is not
|
|
29
|
+
* a width, and treating it as one would pin the panel to nothing. */
|
|
30
|
+
export declare const shellFitMeasuredAtom: Family<import('jotai').Atom<ShellMetrics | null>>;
|
|
31
|
+
/** Whether the shell can hold a secondary panel at all. */
|
|
32
|
+
export declare const shellFitFitsAtom: Family<import('jotai').Atom<boolean>>;
|
|
33
|
+
/** The range a resize may land in. */
|
|
34
|
+
export declare const shellFitPanelBoundsAtom: Family<import('jotai').Atom<ShellFitPanelBounds>>;
|
|
35
|
+
/** The width the secondary panel renders at, or null before the first
|
|
36
|
+
* measurement, where the caller falls back to `--panel-width`. */
|
|
37
|
+
export declare const shellFitPanelWidthAtom: Family<import('jotai').Atom<number | null>>;
|
|
38
|
+
/** The whole fit of one shell. This changes on every measurement, so a
|
|
39
|
+
* component that reads one field should subscribe to that field's atom
|
|
40
|
+
* instead: `useAtomValue(shellFitFitsAtom("app-shell"))`. */
|
|
41
|
+
export declare const shellFitStateAtom: Family<import('jotai').Atom<ShellFitState>>;
|
|
42
|
+
/** @internal The measurement's way in. Silent, and inert when the numbers did
|
|
43
|
+
* not move — a resize event that changes nothing must not re-render a shell. */
|
|
44
|
+
export declare const measureShellFitAtom: Family<import('jotai').WritableAtom<null, [metrics: ShellMetrics], void> & {
|
|
45
|
+
init: null;
|
|
46
|
+
}>;
|
|
47
|
+
/** Resize the secondary panel. Clamped on the way in, so a drag past the
|
|
48
|
+
* gutter parks at the bound instead of banking travel it has to give back —
|
|
49
|
+
* and a caller with no idea how wide the shell is can still ask for 900. */
|
|
50
|
+
export declare const resizeShellPanelAtom: Family<import('jotai').WritableAtom<null, [width: number], void> & {
|
|
51
|
+
init: null;
|
|
52
|
+
}>;
|
|
53
|
+
/** Back to the width the shell mounted with — `defaultPanelWidth`, or
|
|
54
|
+
* `--panel-width` when there was none. */
|
|
55
|
+
export declare const resetShellPanelWidthAtom: Family<import('jotai').WritableAtom<null, [], void> & {
|
|
56
|
+
init: null;
|
|
57
|
+
}>;
|
|
58
|
+
/** @internal Seed the instance once. A seed describes the mount, not every
|
|
59
|
+
* render, so a `defaultPanelWidth` that arrives later never overwrites a
|
|
60
|
+
* width the user dragged to. */
|
|
61
|
+
export declare const mountShellFitAtom: Family<import('jotai').WritableAtom<null, [seed: ShellFitSeed], void> & {
|
|
62
|
+
init: null;
|
|
63
|
+
}>;
|
|
64
|
+
/** Drop every atom for `id`. `useShellFit` calls this on unmount for shells it
|
|
65
|
+
* keyed itself; an explicit `shellId` is the app's key and outlives its
|
|
66
|
+
* component, so a resized panel survives a route change. */
|
|
67
|
+
export declare function removeShellFitInstance(id: ShellFitInstanceId): void;
|
|
68
|
+
export {};
|