@sybilion/uilib 1.4.8 → 1.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/dist/agent-glossary/content-prompt.generated.ts +32 -31
  2. package/dist/agent-glossary/content.generated.ts +32 -31
  3. package/dist/agent-glossary/content.index.md +5 -1
  4. package/dist/agent-glossary/content.md +32 -31
  5. package/dist/agent-glossary/content.prompt.md +32 -31
  6. package/dist/agent-glossary/workspace.generated.ts +26 -27
  7. package/dist/agent-glossary/workspace.index.md +25 -26
  8. package/dist/agent-glossary/workspace.md +25 -26
  9. package/dist/esm/components/ui/AnalysesSelector/AnalysesSelector.js +2 -2
  10. package/dist/esm/components/ui/Button/Button.styl.js +1 -1
  11. package/dist/esm/components/ui/ButtonGroup/ButtonGroup.js +9 -0
  12. package/dist/esm/components/ui/ButtonGroup/ButtonGroup.styl.js +7 -0
  13. package/dist/esm/components/ui/Chart/Chart.js +3 -3
  14. package/dist/esm/components/ui/Chat/ChatPrompt/ChatPrompt.styl.js +1 -1
  15. package/dist/esm/components/ui/Chat/ChatPrompt/ChatPromptComposer.js +1 -1
  16. package/dist/esm/components/ui/Chat/ChatSheet/ChatSheet.js +13 -0
  17. package/dist/esm/components/ui/Chat/ChatSheet/useChatPanelChromeModel.js +10 -7
  18. package/dist/esm/components/ui/Chip/Chip.js +3 -4
  19. package/dist/esm/components/ui/Chip/Chip.styl.js +2 -2
  20. package/dist/esm/components/ui/FileChip/FileChip.js +1 -1
  21. package/dist/esm/components/ui/Page/pageScrollRestoration.js +22 -0
  22. package/dist/esm/components/ui/Page/usePageScrollRestoration.js +73 -0
  23. package/dist/esm/components/ui/Renamer/Renamer.js +1 -1
  24. package/dist/esm/components/ui/Renamer/Renamer.styl.js +1 -1
  25. package/dist/esm/components/ui/Sidebar/Sidebar.js +91 -73
  26. package/dist/esm/components/widgets/DriverCard/DriverCard.js +7 -7
  27. package/dist/esm/components/widgets/DriverCard/DriverPerformanceChart.js +3 -3
  28. package/dist/esm/components/widgets/DriverMap/DriverIcon/DriverIcon.js +2 -2
  29. package/dist/esm/components/widgets/DriverMap/DriverIcon/DriverIcon.styl.js +1 -1
  30. package/dist/esm/components/widgets/DriversComparisonChart/DriversComparisonChart.js +1 -0
  31. package/dist/esm/components/widgets/PerformanceChart/PerformanceTable.js +1 -0
  32. package/dist/esm/components/widgets/SybilionAppHeader/SybilionAppHeader.styl.js +1 -1
  33. package/dist/esm/index.js +4 -2
  34. package/dist/esm/types/src/components/ui/ButtonGroup/ButtonGroup.d.ts +3 -0
  35. package/dist/esm/types/src/components/ui/ButtonGroup/ButtonGroup.types.d.ts +3 -0
  36. package/dist/esm/types/src/components/ui/ButtonGroup/index.d.ts +2 -0
  37. package/dist/esm/types/src/components/ui/Chip/Chip.d.ts +1 -1
  38. package/dist/esm/types/src/components/ui/Chip/Chip.types.d.ts +4 -2
  39. package/dist/esm/types/src/components/ui/Page/index.d.ts +2 -0
  40. package/dist/esm/types/src/components/ui/Page/pageScrollRestoration.d.ts +2 -0
  41. package/dist/esm/types/src/components/ui/Page/usePageScrollRestoration.d.ts +2 -0
  42. package/dist/esm/types/src/components/ui/Sidebar/Sidebar.d.ts +13 -6
  43. package/dist/esm/types/src/docs/pages/ButtonGroupPage.d.ts +1 -0
  44. package/dist/esm/types/src/index.d.ts +1 -1
  45. package/package.json +1 -1
  46. package/src/components/ui/AnalysesSelector/AnalysesSelector.tsx +3 -3
  47. package/src/components/ui/AnalysisLineIcon/AGENT.md +1 -1
  48. package/src/components/ui/Avatar/AGENT.md +1 -1
  49. package/src/components/ui/Button/Button.styl +11 -5
  50. package/src/components/ui/ButtonGroup/AGENT.md +29 -0
  51. package/src/components/ui/ButtonGroup/ButtonGroup.styl +21 -0
  52. package/src/components/ui/{Badge/Badge.styl.d.ts → ButtonGroup/ButtonGroup.styl.d.ts} +0 -6
  53. package/src/components/ui/ButtonGroup/ButtonGroup.tsx +17 -0
  54. package/src/components/ui/ButtonGroup/ButtonGroup.types.ts +3 -0
  55. package/src/components/ui/ButtonGroup/index.ts +2 -0
  56. package/src/components/ui/Chat/ChatPrompt/ChatPrompt.styl +2 -0
  57. package/src/components/ui/Chat/ChatPrompt/ChatPromptComposer.tsx +1 -0
  58. package/src/components/ui/Chat/ChatSheet/ChatSheet.tsx +15 -0
  59. package/src/components/ui/Chat/ChatSheet/useChatPanelChromeModel.tsx +21 -9
  60. package/src/components/ui/Chip/AGENT.md +4 -3
  61. package/src/components/ui/Chip/Chip.styl +17 -0
  62. package/src/components/ui/Chip/Chip.styl.d.ts +2 -0
  63. package/src/components/ui/Chip/Chip.tsx +10 -6
  64. package/src/components/ui/Chip/Chip.types.ts +5 -2
  65. package/src/components/ui/FileChip/FileChip.tsx +1 -1
  66. package/src/components/ui/Gap/AGENT.md +11 -0
  67. package/src/components/ui/Page/AGENT.md +5 -31
  68. package/src/components/ui/Page/index.ts +2 -0
  69. package/src/components/ui/Page/pageScrollRestoration.ts +22 -0
  70. package/src/components/ui/Page/usePageScrollRestoration.ts +90 -0
  71. package/src/components/ui/Renamer/Renamer.styl +1 -1
  72. package/src/components/ui/Renamer/Renamer.tsx +1 -0
  73. package/src/{docs/agent-guidance/sidebar.md → components/ui/Sidebar/AGENT.md} +1 -1
  74. package/src/components/ui/Sidebar/Sidebar.tsx +158 -99
  75. package/src/{docs/agent-guidance/table.md → components/ui/Table/AGENT.md} +1 -2
  76. package/src/{docs/agent-guidance/tabs.md → components/ui/Tabs/AGENT.md} +1 -1
  77. package/src/{docs/agent-guidance/text-shimmer.md → components/ui/TextShimmer/AGENT.md} +1 -1
  78. package/src/components/widgets/DriverCard/DriverCard.tsx +12 -10
  79. package/src/components/widgets/DriverMap/DriverIcon/DriverIcon.styl +1 -0
  80. package/src/components/widgets/DriverMap/DriverIcon/DriverIcon.tsx +3 -3
  81. package/src/components/widgets/SybilionAppHeader/SybilionAppHeader.styl +2 -2
  82. package/src/docs/pages/ButtonGroupPage.tsx +45 -0
  83. package/src/docs/pages/ChipPage.tsx +37 -0
  84. package/src/docs/pages/LegacyPlatformLinkPage.tsx +0 -3
  85. package/src/docs/pages/LightweightChartPage.tsx +1 -1
  86. package/src/docs/pages/ProgressPage.tsx +1 -1
  87. package/src/docs/pages/PullQuotePage.tsx +1 -1
  88. package/src/docs/pages/RegionCoordsPage.tsx +1 -1
  89. package/src/docs/pages/RenamerPage.tsx +1 -1
  90. package/src/docs/pages/SelectPage.tsx +1 -1
  91. package/src/docs/pages/SeparatorPage.tsx +1 -1
  92. package/src/docs/pages/SidebarDatasetsItemsGroupedPage.tsx +1 -1
  93. package/src/docs/pages/SidebarPage.tsx +1 -1
  94. package/src/docs/pages/SkeletonPage.tsx +1 -1
  95. package/src/docs/pages/SliderPage.tsx +1 -1
  96. package/src/docs/pages/SmartTextTruncatePage.tsx +1 -1
  97. package/src/docs/pages/SparklinePage.tsx +1 -1
  98. package/src/docs/pages/TablePage.tsx +1 -1
  99. package/src/docs/pages/TabsPage.tsx +1 -1
  100. package/src/docs/pages/TextShimmerPage.tsx +1 -1
  101. package/src/docs/pages/TextWithDeferTooltipPage.tsx +1 -1
  102. package/src/docs/pages/TimeRangeControlsPage.tsx +1 -1
  103. package/src/docs/pages/ToggleGroupPage.tsx +1 -1
  104. package/src/docs/pages/VimeoEmbedPage.tsx +4 -5
  105. package/src/docs/pages/WorldMapPage.tsx +1 -1
  106. package/src/docs/registry.ts +6 -12
  107. package/src/index.ts +1 -1
  108. package/dist/esm/components/ui/Badge/Badge.js +0 -11
  109. package/dist/esm/components/ui/Badge/Badge.styl.js +0 -7
  110. package/dist/esm/types/src/components/ui/Badge/Badge.d.ts +0 -3
  111. package/dist/esm/types/src/components/ui/Badge/Badge.types.d.ts +0 -6
  112. package/dist/esm/types/src/components/ui/Badge/index.d.ts +0 -2
  113. package/dist/esm/types/src/docs/pages/BadgePage.d.ts +0 -1
  114. package/dist/esm/types/src/docs/pages/TogglePage.d.ts +0 -1
  115. package/src/components/ui/Badge/AGENT.md +0 -16
  116. package/src/components/ui/Badge/Badge.styl +0 -95
  117. package/src/components/ui/Badge/Badge.tsx +0 -31
  118. package/src/components/ui/Badge/Badge.types.ts +0 -7
  119. package/src/components/ui/Badge/index.ts +0 -2
  120. package/src/components/ui/LegacyPlatformLink/AGENT.md +0 -15
  121. package/src/docs/agent-guidance/sidebar-datasets-items-grouped.md +0 -11
  122. package/src/docs/pages/BadgePage.tsx +0 -30
  123. package/src/docs/pages/TogglePage.tsx +0 -27
  124. /package/src/{docs/agent-guidance/lightweight-forecast-chart.md → components/ui/Chart/lightweight/AGENT.md} +0 -0
  125. /package/src/{docs/agent-guidance/progress.md → components/ui/Progress/AGENT.md} +0 -0
  126. /package/src/{docs/agent-guidance/pull-quote.md → components/ui/PullQuote/AGENT.md} +0 -0
  127. /package/src/{docs/agent-guidance/region-coords.md → components/ui/RegionCoords/AGENT.md} +0 -0
  128. /package/src/{docs/agent-guidance/renamer.md → components/ui/Renamer/AGENT.md} +0 -0
  129. /package/src/{docs/agent-guidance/select.md → components/ui/Select/AGENT.md} +0 -0
  130. /package/src/{docs/agent-guidance/separator.md → components/ui/Separator/AGENT.md} +0 -0
  131. /package/src/{docs/agent-guidance/skeleton.md → components/ui/Skeleton/AGENT.md} +0 -0
  132. /package/src/{docs/agent-guidance/slider.md → components/ui/Slider/AGENT.md} +0 -0
  133. /package/src/{docs/agent-guidance/smart-text-truncate.md → components/ui/SmartTextTruncate/AGENT.md} +0 -0
  134. /package/src/{docs/agent-guidance/sparkline.md → components/ui/Sparkline/AGENT.md} +0 -0
  135. /package/src/{docs/agent-guidance/text-with-defer-tooltip.md → components/ui/TextWithDeferTooltip/AGENT.md} +0 -0
  136. /package/src/{docs/agent-guidance/time-range-controls.md → components/ui/TimeRangeControls/AGENT.md} +0 -0
  137. /package/src/{docs/agent-guidance/toggle.md → components/ui/Toggle/AGENT.md} +0 -0
  138. /package/src/{docs/agent-guidance/toggle-group.md → components/ui/ToggleGroup/AGENT.md} +0 -0
  139. /package/src/{docs/agent-guidance/vimeo-embed.md → components/ui/VimeoEmbed/AGENT.md} +0 -0
  140. /package/src/{docs/agent-guidance/world-map.md → components/ui/WorldMap/AGENT.md} +0 -0
@@ -0,0 +1,90 @@
1
+ import { useCallback, useContext, useEffect, useRef } from 'react';
2
+
3
+ import debounce from '#uilib/tools/debounce';
4
+
5
+ import { PageContext } from './pageContext';
6
+ import { readSavedScrollTop, saveScrollTop } from './pageScrollRestoration';
7
+
8
+ const SCROLL_SAVE_MS = 150;
9
+
10
+ /** Session scroll restoration for a PageScroll ancestor (via PageContext). */
11
+ export function usePageScrollRestoration(scrollRestorationKey: string) {
12
+ const { getPageScrollElement } = useContext(PageContext);
13
+ const debouncedSaveRef = useRef<ReturnType<typeof debounce> | null>(null);
14
+ const latestScrollTopRef = useRef(0);
15
+ const pendingRestoreTopRef = useRef<number | null>(null);
16
+
17
+ const tryRestoreScroll = useCallback(() => {
18
+ const el = getPageScrollElement();
19
+ const top = pendingRestoreTopRef.current;
20
+ if (!el || top == null) return false;
21
+
22
+ const maxTop = Math.max(0, el.scrollHeight - el.clientHeight);
23
+ const targetTop = Math.min(top, maxTop);
24
+ el.scrollTo({ top: targetTop, behavior: 'auto' });
25
+
26
+ const applied = el.scrollTop >= targetTop - 1 || maxTop <= 0;
27
+ if (applied && maxTop > 0) {
28
+ pendingRestoreTopRef.current = null;
29
+ }
30
+
31
+ return applied;
32
+ }, [getPageScrollElement]);
33
+
34
+ useEffect(() => {
35
+ debouncedSaveRef.current?.cancel();
36
+ debouncedSaveRef.current = debounce(
37
+ (key: string, top: number) => {
38
+ saveScrollTop(key, top);
39
+ },
40
+ SCROLL_SAVE_MS,
41
+ { leading: false },
42
+ );
43
+
44
+ return () => {
45
+ debouncedSaveRef.current?.cancel();
46
+ };
47
+ }, []);
48
+
49
+ useEffect(() => {
50
+ const el = getPageScrollElement();
51
+ if (!el) return;
52
+
53
+ const ro = new ResizeObserver(() => {
54
+ if (pendingRestoreTopRef.current != null) {
55
+ tryRestoreScroll();
56
+ }
57
+ });
58
+ ro.observe(el);
59
+
60
+ return () => ro.disconnect();
61
+ }, [getPageScrollElement, tryRestoreScroll]);
62
+
63
+ useEffect(() => {
64
+ const el = getPageScrollElement();
65
+ if (!el) return;
66
+
67
+ latestScrollTopRef.current = el.scrollTop;
68
+
69
+ const savedTop = readSavedScrollTop(scrollRestorationKey);
70
+ if (savedTop != null) {
71
+ pendingRestoreTopRef.current = savedTop;
72
+ tryRestoreScroll();
73
+ }
74
+
75
+ const handleScroll = () => {
76
+ latestScrollTopRef.current = el.scrollTop;
77
+ debouncedSaveRef.current?.(scrollRestorationKey, el.scrollTop);
78
+ };
79
+
80
+ el.addEventListener('scroll', handleScroll, { passive: true });
81
+
82
+ return () => {
83
+ el.removeEventListener('scroll', handleScroll);
84
+ debouncedSaveRef.current?.cancel();
85
+ const storedTop = readSavedScrollTop(scrollRestorationKey) ?? 0;
86
+ const top = Math.max(latestScrollTopRef.current, storedTop);
87
+ saveScrollTop(scrollRestorationKey, top);
88
+ };
89
+ }, [getPageScrollElement, scrollRestorationKey, tryRestoreScroll]);
90
+ }
@@ -30,7 +30,7 @@
30
30
  background-color var(--accent) / 0.1
31
31
 
32
32
  .button
33
- padding-left 0
33
+ // padding-left 0
34
34
  opacity 0.5
35
35
  transition opacity 0.2s ease-out
36
36
 
@@ -110,6 +110,7 @@ export function Renamer({
110
110
  <Tooltip>
111
111
  <TooltipTrigger asChild>
112
112
  <Button
113
+ icon
113
114
  className={S.button}
114
115
  variant="ghost"
115
116
  onPointerDown={e => {
@@ -12,4 +12,4 @@ Sidebar provides the primitives for building application navigation rails: Sideb
12
12
 
13
13
  ## Do
14
14
 
15
- - Mark the current route’s item with isActive so users can orient themselves.
15
+ - Mark the current route's item with isActive so users can orient themselves.
@@ -100,23 +100,31 @@ export type SetSidebarOpenOptions = {
100
100
  layoutAutoClose?: boolean;
101
101
  };
102
102
 
103
- type SidebarContextProps = {
104
- isOpen: boolean;
103
+ type SidebarActionsContextProps = {
105
104
  setOpen: (open: boolean, options?: SetSidebarOpenOptions) => void;
106
105
  toggleSidebar: () => void;
107
- sidebarWidthPx: number;
108
106
  setSidebarWidthPx: (px: number, options?: SetPanelWidthOptions) => void;
109
- chatWidthPx: number;
110
107
  setChatWidthPx: (px: number, options?: SetPanelWidthOptions) => void;
111
- chatPanelOpen: boolean;
112
108
  setChatPanelOpen: (open: boolean) => void;
113
109
  getShellWidth: () => number;
110
+ /** Read shell chat open without subscribing to SidebarStateContext. */
111
+ getChatPanelOpen: () => boolean;
112
+ };
113
+
114
+ type SidebarStateContextProps = {
115
+ isOpen: boolean;
116
+ sidebarWidthPx: number;
117
+ chatWidthPx: number;
118
+ chatPanelOpen: boolean;
114
119
  /** Portal target for the AI chat side panel (right column). */
115
120
  chatPanelContainer: HTMLDivElement | null;
116
121
  /** App shell wrapper; used to set `--chat-panel-width` (and `--chat-panel-height` on mobile only). */
117
122
  sidebarWrapperRef: RefObject<HTMLDivElement | null>;
118
123
  };
119
124
 
125
+ type SidebarContextProps = SidebarStateContextProps &
126
+ SidebarActionsContextProps;
127
+
120
128
  type SidebarProps = ComponentProps<'div'> & {
121
129
  defaultOpen?: boolean;
122
130
  open?: boolean;
@@ -128,17 +136,43 @@ type SidebarProps = ComponentProps<'div'> & {
128
136
  brandText?: string;
129
137
  };
130
138
 
131
- const SidebarContext = createContext<SidebarContextProps | null>(null);
139
+ const SidebarActionsContext = createContext<SidebarActionsContextProps | null>(
140
+ null,
141
+ );
142
+ const SidebarStateContext = createContext<SidebarStateContextProps | null>(
143
+ null,
144
+ );
145
+
146
+ function useSidebarActions() {
147
+ const context = useContext(SidebarActionsContext);
148
+ if (!context) {
149
+ throw new Error('useSidebarActions must be used within a SidebarProvider.');
150
+ }
151
+
152
+ return context;
153
+ }
132
154
 
133
- function useSidebar() {
134
- const context = useContext(SidebarContext);
155
+ function useSidebarState() {
156
+ const context = useContext(SidebarStateContext);
135
157
  if (!context) {
136
- throw new Error('useSidebar must be used within a SidebarProvider.');
158
+ throw new Error('useSidebarState must be used within a SidebarProvider.');
137
159
  }
138
160
 
139
161
  return context;
140
162
  }
141
163
 
164
+ function useSidebar(): SidebarContextProps {
165
+ const actions = useSidebarActions();
166
+ const state = useSidebarState();
167
+ return useMemo(
168
+ () => ({
169
+ ...state,
170
+ ...actions,
171
+ }),
172
+ [state, actions],
173
+ );
174
+ }
175
+
142
176
  function SidebarProvider({
143
177
  defaultOpen = (getCookie('isSidebarOpen') as unknown as boolean) ?? true,
144
178
  className,
@@ -184,10 +218,14 @@ function SidebarProvider({
184
218
  const [chatPanelOpen, _setChatPanelOpen] = useState(false);
185
219
  const sidebarWidthRef = useRef(sidebarWidthPx);
186
220
  const chatWidthRef = useRef(chatWidthPx);
221
+ const isOpenRef = useRef(isOpen);
222
+ const chatPanelOpenRef = useRef(chatPanelOpen);
187
223
  /** Left nav was auto-closed because chat opened on a narrow shell; reopen when chat closes. */
188
224
  const sidebarAutoClosedForChatRef = useRef(false);
189
225
  sidebarWidthRef.current = sidebarWidthPx;
190
226
  chatWidthRef.current = chatWidthPx;
227
+ isOpenRef.current = isOpen;
228
+ chatPanelOpenRef.current = chatPanelOpen;
191
229
 
192
230
  const mergeWrapperRef = useCallback((el: HTMLDivElement | null) => {
193
231
  wrapperRef.current = el;
@@ -204,40 +242,39 @@ function SidebarProvider({
204
242
  return typeof window !== 'undefined' ? window.innerWidth : 1200;
205
243
  }, []);
206
244
 
245
+ const getChatPanelOpen = useCallback(
246
+ (): boolean => chatPanelOpenRef.current,
247
+ [],
248
+ );
249
+
207
250
  const setSidebarWidthPx = useCallback(
208
251
  (px: number, options?: SetPanelWidthOptions) => {
209
252
  const persist = options?.persist !== false;
210
253
  const shellW = getShellWidth();
211
254
  const next = clampSidebarWidthPx(px, shellW, {
212
- chatPanelOpen,
213
- chatWidthPx,
255
+ chatPanelOpen: chatPanelOpenRef.current,
256
+ chatWidthPx: chatWidthRef.current,
214
257
  });
215
258
  _setSidebarWidthPx(next);
216
259
  if (persist && allowPersistSidebarWidth) {
217
260
  LS.set(sidebarLsKey, next);
218
261
  }
219
262
  },
220
- [
221
- getShellWidth,
222
- chatPanelOpen,
223
- chatWidthPx,
224
- sidebarLsKey,
225
- allowPersistSidebarWidth,
226
- ],
263
+ [getShellWidth, sidebarLsKey, allowPersistSidebarWidth],
227
264
  );
228
265
 
229
266
  const setChatWidthPx = useCallback(
230
267
  (px: number, options?: SetPanelWidthOptions) => {
231
268
  const persist = options?.persist !== false;
232
269
  const shellW = getShellWidth();
233
- const effectiveSidebarW = isOpen ? sidebarWidthPx : 0;
270
+ const effectiveSidebarW = isOpenRef.current ? sidebarWidthRef.current : 0;
234
271
  const next = clampChatWidthPx(px, shellW, effectiveSidebarW);
235
272
  _setChatWidthPx(next);
236
273
  if (persist && getCookiePreferences(userId)?.functional) {
237
274
  LS.set(CHAT_WIDTH_STORAGE_KEY, next);
238
275
  }
239
276
  },
240
- [getShellWidth, isOpen, sidebarWidthPx, userId],
277
+ [getShellWidth, userId],
241
278
  );
242
279
 
243
280
  const handleShellResize = useCallback(
@@ -251,14 +288,22 @@ function SidebarProvider({
251
288
  const cScaled = Math.round((c * shellW) / prev);
252
289
  const effS = (navOpen: boolean, sidebarPx: number) =>
253
290
  navOpen ? sidebarPx : 0;
254
- let cNext = clampChatWidthPx(cScaled, shellW, effS(isOpen, sScaled));
291
+ let cNext = clampChatWidthPx(
292
+ cScaled,
293
+ shellW,
294
+ effS(isOpenRef.current, sScaled),
295
+ );
255
296
  let sNext = clampSidebarWidthPx(sScaled, shellW, {
256
- chatPanelOpen,
297
+ chatPanelOpen: chatPanelOpenRef.current,
257
298
  chatWidthPx: cNext,
258
299
  });
259
- cNext = clampChatWidthPx(cScaled, shellW, effS(isOpen, sNext));
300
+ cNext = clampChatWidthPx(
301
+ cScaled,
302
+ shellW,
303
+ effS(isOpenRef.current, sNext),
304
+ );
260
305
  sNext = clampSidebarWidthPx(sScaled, shellW, {
261
- chatPanelOpen,
306
+ chatPanelOpen: chatPanelOpenRef.current,
262
307
  chatWidthPx: cNext,
263
308
  });
264
309
  _setSidebarWidthPx(sNext);
@@ -272,7 +317,7 @@ function SidebarProvider({
272
317
  }
273
318
  prevShellWidthRef.current = shellW;
274
319
  },
275
- [chatPanelOpen, isOpen, userId, sidebarLsKey, allowPersistSidebarWidth],
320
+ [userId, sidebarLsKey, allowPersistSidebarWidth],
276
321
  );
277
322
 
278
323
  const fitPanelWidthsToShell = useCallback(() => {
@@ -280,15 +325,15 @@ function SidebarProvider({
280
325
  if (shellW <= 0) return;
281
326
  const s = sidebarWidthRef.current;
282
327
  const c = chatWidthRef.current;
283
- const effS = isOpen ? s : 0;
328
+ const effS = isOpenRef.current ? s : 0;
284
329
  let cNext = clampChatWidthPx(c, shellW, effS);
285
330
  let sNext = clampSidebarWidthPx(s, shellW, {
286
- chatPanelOpen,
331
+ chatPanelOpen: chatPanelOpenRef.current,
287
332
  chatWidthPx: cNext,
288
333
  });
289
- cNext = clampChatWidthPx(c, shellW, isOpen ? sNext : 0);
334
+ cNext = clampChatWidthPx(c, shellW, isOpenRef.current ? sNext : 0);
290
335
  sNext = clampSidebarWidthPx(s, shellW, {
291
- chatPanelOpen,
336
+ chatPanelOpen: chatPanelOpenRef.current,
292
337
  chatWidthPx: cNext,
293
338
  });
294
339
  if (sNext !== s || cNext !== c) {
@@ -301,14 +346,7 @@ function SidebarProvider({
301
346
  LS.set(CHAT_WIDTH_STORAGE_KEY, cNext);
302
347
  }
303
348
  }
304
- }, [
305
- chatPanelOpen,
306
- getShellWidth,
307
- isOpen,
308
- userId,
309
- sidebarLsKey,
310
- allowPersistSidebarWidth,
311
- ]);
349
+ }, [getShellWidth, userId, sidebarLsKey, allowPersistSidebarWidth]);
312
350
 
313
351
  useLayoutEffect(() => {
314
352
  if (!shellEl || isSidebarSheetLayout) return;
@@ -328,36 +366,39 @@ function SidebarProvider({
328
366
  if (isSidebarSheetLayout) return;
329
367
  const shellW = getShellWidth();
330
368
  const layoutAfterOpen = {
331
- mainSidebarOpen: openingMain || isOpen,
332
- chatPanelOpen: openingChat || chatPanelOpen,
333
- sidebarWidthPx,
334
- chatWidthPx,
369
+ mainSidebarOpen: openingMain || isOpenRef.current,
370
+ chatPanelOpen: openingChat || chatPanelOpenRef.current,
371
+ sidebarWidthPx: sidebarWidthRef.current,
372
+ chatWidthPx: chatWidthRef.current,
335
373
  };
336
374
  if (shellFitsSidebarsLayout(shellW, layoutAfterOpen)) return;
337
- if (openingMain && chatPanelOpen) {
375
+ if (openingMain && chatPanelOpenRef.current) {
338
376
  _setChatPanelOpen(false);
339
377
  if (typeof window !== 'undefined') {
340
378
  window.dispatchEvent(new CustomEvent(DISMISS_CHAT_FOR_LAYOUT_EVENT));
341
379
  }
342
- } else if (openingChat && isOpen) {
380
+ } else if (openingChat && isOpenRef.current) {
343
381
  sidebarAutoClosedForChatRef.current = true;
344
382
  setIsOpen(false);
345
383
  }
346
384
  },
347
- [
348
- isSidebarSheetLayout,
349
- getShellWidth,
350
- isOpen,
351
- chatPanelOpen,
352
- sidebarWidthPx,
353
- chatWidthPx,
354
- ],
385
+ [isSidebarSheetLayout, getShellWidth],
355
386
  );
356
387
 
357
388
  const setChatPanelOpen = useCallback(
358
389
  (open: boolean) => {
359
390
  if (open) {
360
391
  closeOppositeSidebarIfNoSpace(false, true);
392
+ const shellW = getShellWidth();
393
+ if (shellW > 0 && !isSidebarSheetLayout) {
394
+ const navOpenAfter =
395
+ isOpenRef.current && !sidebarAutoClosedForChatRef.current;
396
+ const effNav = navOpenAfter ? sidebarWidthRef.current : 0;
397
+ const cNext = clampChatWidthPx(chatWidthRef.current, shellW, effNav);
398
+ if (cNext !== chatWidthRef.current) {
399
+ _setChatWidthPx(cNext);
400
+ }
401
+ }
361
402
  _setChatPanelOpen(true);
362
403
  return;
363
404
  }
@@ -370,7 +411,12 @@ function SidebarProvider({
370
411
  }
371
412
  }
372
413
  },
373
- [closeOppositeSidebarIfNoSpace, userId],
414
+ [
415
+ closeOppositeSidebarIfNoSpace,
416
+ getShellWidth,
417
+ isSidebarSheetLayout,
418
+ userId,
419
+ ],
374
420
  );
375
421
 
376
422
  const setOpen = useCallback(
@@ -407,7 +453,10 @@ function SidebarProvider({
407
453
  [isSidebarSheetLayout, userId, closeOppositeSidebarIfNoSpace],
408
454
  );
409
455
 
410
- const toggleSidebar = useCallback(() => setOpen(!isOpen), [isOpen, setOpen]);
456
+ const toggleSidebar = useCallback(
457
+ () => setOpen(!isOpenRef.current),
458
+ [setOpen],
459
+ );
411
460
 
412
461
  useEffect(() => {
413
462
  const shell = wrapperRef.current;
@@ -452,67 +501,73 @@ function SidebarProvider({
452
501
  },
453
502
  });
454
503
 
455
- const contextValue = useMemo<SidebarContextProps>(
504
+ const sidebarActionsValue = useMemo<SidebarActionsContextProps>(
456
505
  () => ({
457
- isOpen,
458
506
  setOpen,
459
507
  toggleSidebar,
460
- sidebarWidthPx,
461
508
  setSidebarWidthPx,
462
- chatWidthPx,
463
509
  setChatWidthPx,
464
- chatPanelOpen,
465
510
  setChatPanelOpen,
466
511
  getShellWidth,
467
- chatPanelContainer,
468
- sidebarWrapperRef: wrapperRef,
512
+ getChatPanelOpen,
469
513
  }),
470
514
  [
471
- isOpen,
472
515
  setOpen,
473
516
  toggleSidebar,
474
- sidebarWidthPx,
475
517
  setSidebarWidthPx,
476
- chatWidthPx,
477
518
  setChatWidthPx,
478
- chatPanelOpen,
519
+ setChatPanelOpen,
479
520
  getShellWidth,
480
- chatPanelContainer,
521
+ getChatPanelOpen,
481
522
  ],
482
523
  );
483
524
 
525
+ const sidebarStateValue = useMemo<SidebarStateContextProps>(
526
+ () => ({
527
+ isOpen,
528
+ sidebarWidthPx,
529
+ chatWidthPx,
530
+ chatPanelOpen,
531
+ chatPanelContainer,
532
+ sidebarWrapperRef: wrapperRef,
533
+ }),
534
+ [isOpen, sidebarWidthPx, chatWidthPx, chatPanelOpen, chatPanelContainer],
535
+ );
536
+
484
537
  return (
485
- <SidebarContext.Provider value={contextValue}>
486
- <TooltipProvider delayDuration={0}>
487
- <div
488
- ref={mergeWrapperRef}
489
- data-slot="sidebar-wrapper"
490
- data-state={isOpen ? 'expanded' : 'collapsed'}
491
- style={
492
- {
493
- '--sidebar-width': `${sidebarWidthPx}px`,
494
- '--sidebar-width-icon': SIDEBAR_WIDTH_ICON,
495
- ...style,
496
- } as CSSProperties
497
- }
498
- className={cn(S.sidebarWrapper, className)}
499
- {...props}
500
- >
538
+ <SidebarActionsContext.Provider value={sidebarActionsValue}>
539
+ <SidebarStateContext.Provider value={sidebarStateValue}>
540
+ <TooltipProvider delayDuration={0}>
501
541
  <div
502
- className={S.sidebarMainShell}
503
- // style={{ viewTransitionName: 'sidebar-gap' }}
542
+ ref={mergeWrapperRef}
543
+ data-slot="sidebar-wrapper"
544
+ data-state={isOpen ? 'expanded' : 'collapsed'}
545
+ style={
546
+ {
547
+ '--sidebar-width': `${sidebarWidthPx}px`,
548
+ '--sidebar-width-icon': SIDEBAR_WIDTH_ICON,
549
+ ...style,
550
+ } as CSSProperties
551
+ }
552
+ className={cn(S.sidebarWrapper, className)}
553
+ {...props}
504
554
  >
505
- {children}
555
+ <div
556
+ className={S.sidebarMainShell}
557
+ // style={{ viewTransitionName: 'sidebar-gap' }}
558
+ >
559
+ {children}
560
+ </div>
561
+ <div
562
+ ref={onChatPanelMount}
563
+ className={S.chatPanelMount}
564
+ data-slot="chat-panel-mount"
565
+ // style={{ viewTransitionName: 'sidebar-container' }}
566
+ />
506
567
  </div>
507
- <div
508
- ref={onChatPanelMount}
509
- className={S.chatPanelMount}
510
- data-slot="chat-panel-mount"
511
- // style={{ viewTransitionName: 'sidebar-container' }}
512
- />
513
- </div>
514
- </TooltipProvider>
515
- </SidebarContext.Provider>
568
+ </TooltipProvider>
569
+ </SidebarStateContext.Provider>
570
+ </SidebarActionsContext.Provider>
516
571
  );
517
572
  }
518
573
 
@@ -530,7 +585,8 @@ function Sidebar({
530
585
  ...props
531
586
  }: SidebarProps) {
532
587
  const isSidebarSheetLayout = useIsSidebarSheetLayout();
533
- const { isOpen, setOpen } = useSidebar();
588
+ const { isOpen } = useSidebarState();
589
+ const { setOpen } = useSidebarActions();
534
590
 
535
591
  const prevSheetLayoutRef = useRef(isSidebarSheetLayout);
536
592
 
@@ -605,7 +661,7 @@ function SidebarTrigger({
605
661
  onClick,
606
662
  ...props
607
663
  }: ComponentProps<typeof Button>) {
608
- const { toggleSidebar } = useSidebar();
664
+ const { toggleSidebar } = useSidebarActions();
609
665
 
610
666
  return (
611
667
  <Button
@@ -627,7 +683,7 @@ function SidebarTrigger({
627
683
  }
628
684
 
629
685
  function SidebarRail({ className, ...props }: ComponentProps<'button'>) {
630
- const { toggleSidebar } = useSidebar();
686
+ const { toggleSidebar } = useSidebarActions();
631
687
 
632
688
  return (
633
689
  <button
@@ -728,8 +784,8 @@ function SidebarResizeHandle({
728
784
  side = 'left',
729
785
  ...props
730
786
  }: ComponentProps<'div'> & { side?: 'left' | 'right' }) {
731
- const { isOpen, sidebarWidthPx, setSidebarWidthPx, getShellWidth } =
732
- useSidebar();
787
+ const { isOpen, sidebarWidthPx } = useSidebarState();
788
+ const { setSidebarWidthPx, getShellWidth } = useSidebarActions();
733
789
  const isSidebarSheetLayout = useIsSidebarSheetLayout();
734
790
 
735
791
  const edge: 'leading' | 'trailing' = side === 'left' ? 'trailing' : 'leading';
@@ -966,7 +1022,8 @@ function SidebarMenuSubButton({
966
1022
  tooltip?: string | ComponentProps<typeof TooltipContent>;
967
1023
  }) {
968
1024
  const Comp = asChild ? Slot : 'a';
969
- const { isOpen, setOpen } = useSidebar();
1025
+ const { isOpen } = useSidebarState();
1026
+ const { setOpen } = useSidebarActions();
970
1027
  const isSidebarSheetLayout = useIsSidebarSheetLayout();
971
1028
 
972
1029
  const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => {
@@ -1028,4 +1085,6 @@ export {
1028
1085
  SidebarSeparator,
1029
1086
  SidebarTrigger,
1030
1087
  useSidebar,
1088
+ useSidebarActions,
1089
+ useSidebarState,
1031
1090
  };
@@ -13,5 +13,4 @@ Table is a set of semantic primitives — Table, TableHeader, TableBody, TableRo
13
13
  ## Do
14
14
 
15
15
  - Keep column headers short and use TableHead cells so the markup stays accessible.
16
- - Use size=
17
- - on Table when you need tighter row density.
16
+ - Use size on Table when you need tighter row density.
@@ -18,4 +18,4 @@ Tabs organise related content into panels that share the same space, with only o
18
18
 
19
19
  ## Don't
20
20
 
21
- - Don’t use more tabs than fit comfortably in the available width.
21
+ - Don't use more tabs than fit comfortably in the available width.
@@ -2,7 +2,7 @@ TextShimmer animates a shimmer effect across its text content to signal that an
2
2
 
3
3
  ## When to use
4
4
 
5
- - To indicate an in-progress operation with a descriptive label, such as “Generating…”.
5
+ - To indicate an in-progress operation with a descriptive label, such as "Generating…".
6
6
  - For streaming or AI-generated content where text appears gradually.
7
7
 
8
8
  ## When not to use
@@ -1,15 +1,16 @@
1
- import { Card, CardContent } from '../../ui/Card';
2
- import { CoffeeIcon, TrendDownIcon, TrendUpIcon } from '@phosphor-icons/react';
3
1
  import React, { useMemo } from 'react';
4
- import { Tooltip, TooltipContent, TooltipTrigger } from '../../ui/Tooltip';
5
2
 
6
- import { Badge } from '../../ui/Badge';
7
- import type { DriverData } from '../DriverMap/driverMapGeography';
8
- import { DriverPerformanceChart } from './DriverPerformanceChart';
3
+ import { CoffeeIcon, TrendDownIcon, TrendUpIcon } from '@phosphor-icons/react';
4
+
5
+ import { Card, CardContent } from '../../ui/Card';
6
+ import { Chip } from '../../ui/Chip';
9
7
  import { LabelWithId } from '../../ui/LabelWithId';
10
- import S from './DriverCard.styl';
11
8
  import { Skeleton } from '../../ui/Skeleton';
9
+ import { Tooltip, TooltipContent, TooltipTrigger } from '../../ui/Tooltip';
12
10
  import { getCategoryIcon } from '../DriverMap/driverCategoryIcon';
11
+ import type { DriverData } from '../DriverMap/driverMapGeography';
12
+ import S from './DriverCard.styl';
13
+ import { DriverPerformanceChart } from './DriverPerformanceChart';
13
14
 
14
15
  export interface DriverCardProps {
15
16
  selectedDriver: DriverData | null;
@@ -199,13 +200,14 @@ export function DriverCard({
199
200
 
200
201
  {/* Direction and Lag Information */}
201
202
  <div className={S.directionLagSection}>
202
- <Badge
203
- variant={direction > 0 ? 'green' : 'red'}
203
+ <Chip
204
+ variant={direction > 0 ? 'positive' : 'negative'}
205
+ squared
204
206
  className={S.directionBadge}
205
207
  >
206
208
  <DirectionIcon className={S.trendIcon} />
207
209
  {directionText} correlation
208
- </Badge>
210
+ </Chip>
209
211
 
210
212
  <span className={S.lagInfo}>Lag: {lag}</span>
211
213
  </div>
@@ -21,6 +21,7 @@ $msOffset = 30ms
21
21
  pointer-events none
22
22
 
23
23
  .badge
24
+ justify-content center
24
25
  padding 0.25rem
25
26
  transition all $dur ease-out
26
27
  pointer-events none
@@ -1,6 +1,6 @@
1
1
  import cn from 'classnames';
2
2
 
3
- import { Badge } from '#uilib/components/ui/Badge';
3
+ import { Chip } from '#uilib/components/ui/Chip';
4
4
  import {
5
5
  Tooltip,
6
6
  TooltipContent,
@@ -57,9 +57,9 @@ export function DriverIcon({
57
57
  zIndex: isSelected ? 2 : '',
58
58
  }}
59
59
  >
60
- <Badge className={S.badge}>
60
+ <Chip variant="neutral" squared className={S.badge}>
61
61
  <div className={S.icon}>{getCategoryIcon(driver.category)}</div>
62
- </Badge>
62
+ </Chip>
63
63
  </button>
64
64
  </TooltipTrigger>
65
65