@sybilion/uilib 1.4.11 → 1.4.13

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 (47) hide show
  1. package/dist/esm/components/ui/Button/Button.styl.js +1 -1
  2. package/dist/esm/components/ui/Chat/ChatSheet/ChatSheet.js +2 -2
  3. package/dist/esm/components/ui/Page/PageHeader/PageHeader.js +2 -2
  4. package/dist/esm/components/ui/Page/PageHeader/PageHeader.styl.js +2 -2
  5. package/dist/esm/components/ui/Renamer/Renamer.js +4 -4
  6. package/dist/esm/components/ui/Renamer/Renamer.styl.js +2 -2
  7. package/dist/esm/components/ui/Sidebar/Sidebar.js +20 -7
  8. package/dist/esm/components/ui/Sidebar/Sidebar.styl.js +2 -2
  9. package/dist/esm/components/ui/SmartTextTruncate/SmartTextTruncate.js +260 -67
  10. package/dist/esm/components/ui/SmartTextTruncate/SmartTextTruncate.styl.js +7 -0
  11. package/dist/esm/components/widgets/DriversComparisonChart/DriversComparisonChart.js +21 -5
  12. package/dist/esm/components/widgets/PerformanceChart/PerformanceChart.js +10 -3
  13. package/dist/esm/components/widgets/SidebarDatasetsItemsGrouped/SidebarDatasetsItemsGrouped.js +5 -5
  14. package/dist/esm/components/widgets/SidebarDatasetsItemsGrouped/SidebarDatasetsItemsGrouped.styl.js +2 -2
  15. package/dist/esm/index.js +1 -1
  16. package/dist/esm/types/src/components/ui/Chat/ChatSheet/ChatSheet.d.ts +2 -1
  17. package/dist/esm/types/src/components/ui/Page/PageHeader/PageHeader.d.ts +2 -1
  18. package/dist/esm/types/src/components/ui/Sidebar/Sidebar.d.ts +7 -2
  19. package/dist/esm/types/src/components/ui/SmartTextTruncate/SmartTextTruncate.d.ts +5 -3
  20. package/dist/esm/types/src/components/ui/SmartTextTruncate/index.d.ts +1 -1
  21. package/dist/esm/types/src/components/widgets/DriversComparisonChart/DriversComparisonChart.d.ts +3 -1
  22. package/dist/esm/types/src/components/widgets/PerformanceChart/PerformanceChart.d.ts +4 -1
  23. package/package.json +1 -1
  24. package/src/components/ui/Button/Button.styl +5 -10
  25. package/src/components/ui/Chat/ChatSheet/ChatSheet.tsx +5 -2
  26. package/src/components/ui/Page/PageHeader/PageHeader.styl +5 -0
  27. package/src/components/ui/Page/PageHeader/PageHeader.styl.d.ts +1 -0
  28. package/src/components/ui/Page/PageHeader/PageHeader.tsx +8 -1
  29. package/src/components/ui/Renamer/Renamer.styl +19 -4
  30. package/src/components/ui/Renamer/Renamer.tsx +8 -9
  31. package/src/components/ui/Sidebar/Sidebar.styl +61 -51
  32. package/src/components/ui/Sidebar/Sidebar.styl.d.ts +4 -0
  33. package/src/components/ui/Sidebar/Sidebar.tsx +66 -6
  34. package/src/components/ui/SmartTextTruncate/SmartTextTruncate.styl +34 -0
  35. package/src/components/ui/SmartTextTruncate/SmartTextTruncate.styl.d.ts +10 -0
  36. package/src/components/ui/SmartTextTruncate/SmartTextTruncate.tsx +335 -81
  37. package/src/components/ui/SmartTextTruncate/index.ts +5 -1
  38. package/src/components/widgets/DriversComparisonChart/DriversComparisonChart.tsx +53 -20
  39. package/src/components/widgets/PerformanceChart/PerformanceChart.tsx +21 -2
  40. package/src/components/widgets/SidebarDatasetsItemsGrouped/SidebarDatasetsItemsGrouped.styl +0 -24
  41. package/src/components/widgets/SidebarDatasetsItemsGrouped/SidebarDatasetsItemsGrouped.styl.d.ts +0 -2
  42. package/src/components/widgets/SidebarDatasetsItemsGrouped/SidebarDatasetsItemsGrouped.tsx +5 -11
  43. package/src/docs/components/DocsSidebar/DocsSidebar.tsx +3 -17
  44. package/src/docs/pages/SidebarDatasetsItemsGroupedPage.tsx +4 -1
  45. package/src/docs/pages/SmartTextTruncatePage.styl +22 -0
  46. package/src/docs/pages/SmartTextTruncatePage.styl.d.ts +2 -0
  47. package/src/docs/pages/SmartTextTruncatePage.tsx +21 -1
@@ -1,98 +1,291 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { useRef, useState, useLayoutEffect } from 'react';
2
+ import cn from 'classnames';
3
+ import { memo, useRef, useState, useCallback, useLayoutEffect } from 'react';
4
+ import S from './SmartTextTruncate.styl.js';
3
5
 
4
6
  const ELLIPSIS = ' ... ';
5
7
  const END_CHARS_COUNT = 10;
6
- function SmartTextTruncate({ children, className, ...props }) {
8
+ const RESIZE_SETTLE_MS = 120;
9
+ const GLOBAL_KEY = '__sybilionSmartTextTruncate';
10
+ const RESIZE_ROOT_SELECTOR = '[data-smart-text-truncate-resize-root]';
11
+ const DRAG_THRESHOLD_PX = 3;
12
+ function getGlobalState() {
13
+ const w = window;
14
+ if (!w[GLOBAL_KEY]) {
15
+ w[GLOBAL_KEY] = {
16
+ store: {
17
+ isPanelDragging: false,
18
+ isResizeRootDragging: false,
19
+ },
20
+ settleTimer: null,
21
+ resizeRafId: 0,
22
+ recalcCallbacks: new Set(),
23
+ resizeRootListenersInit: false,
24
+ panelDragActive: false,
25
+ };
26
+ }
27
+ return w[GLOBAL_KEY];
28
+ }
29
+ let pendingResizeRootDrag = null;
30
+ function getIsFastMode(store) {
31
+ return store.isPanelDragging || store.isResizeRootDragging;
32
+ }
33
+ function syncFastModeDom(store) {
34
+ if (typeof document === 'undefined') {
35
+ return;
36
+ }
37
+ if (getIsFastMode(store)) {
38
+ document.documentElement.dataset.smartTextTruncateFast = '';
39
+ }
40
+ else {
41
+ delete document.documentElement.dataset.smartTextTruncateFast;
42
+ }
43
+ }
44
+ function clearSettleTimer() {
45
+ const g = getGlobalState();
46
+ if (g.settleTimer) {
47
+ clearTimeout(g.settleTimer);
48
+ g.settleTimer = null;
49
+ }
50
+ }
51
+ function runSettleRecalc() {
52
+ getGlobalState().recalcCallbacks.forEach(recalc => recalc());
53
+ }
54
+ function scheduleSettle() {
55
+ const g = getGlobalState();
56
+ clearSettleTimer();
57
+ g.settleTimer = setTimeout(() => {
58
+ g.settleTimer = null;
59
+ runSettleRecalc();
60
+ }, RESIZE_SETTLE_MS);
61
+ }
62
+ function notifyContainerResize() {
63
+ const g = getGlobalState();
64
+ if (getIsFastMode(g.store)) {
65
+ return;
66
+ }
67
+ scheduleSettle();
68
+ }
69
+ function beginResizeRootDrag() {
70
+ const g = getGlobalState();
71
+ if (g.store.isResizeRootDragging) {
72
+ return;
73
+ }
74
+ clearSettleTimer();
75
+ g.store = { ...g.store, isResizeRootDragging: true };
76
+ syncFastModeDom(g.store);
77
+ }
78
+ function endResizeRootDrag() {
79
+ const g = getGlobalState();
80
+ pendingResizeRootDrag = null;
81
+ if (!g.store.isResizeRootDragging) {
82
+ return;
83
+ }
84
+ g.store = { ...g.store, isResizeRootDragging: false };
85
+ syncFastModeDom(g.store);
86
+ scheduleSettle();
87
+ }
88
+ function onResizeRootPointerDown(e) {
89
+ if (e.button !== 0) {
90
+ return;
91
+ }
92
+ const root = e.target?.closest(RESIZE_ROOT_SELECTOR);
93
+ if (!root) {
94
+ return;
95
+ }
96
+ clearSettleTimer();
97
+ pendingResizeRootDrag = {
98
+ pointerId: e.pointerId,
99
+ startX: e.clientX,
100
+ startY: e.clientY,
101
+ };
102
+ }
103
+ function onResizeRootPointerMove(e) {
104
+ const pending = pendingResizeRootDrag;
105
+ if (!pending || e.pointerId !== pending.pointerId) {
106
+ return;
107
+ }
108
+ const dx = e.clientX - pending.startX;
109
+ const dy = e.clientY - pending.startY;
110
+ if (Math.hypot(dx, dy) < DRAG_THRESHOLD_PX) {
111
+ return;
112
+ }
113
+ beginResizeRootDrag();
114
+ }
115
+ function onResizeRootPointerUp(e) {
116
+ const pending = pendingResizeRootDrag;
117
+ if (!pending || e.pointerId !== pending.pointerId) {
118
+ return;
119
+ }
120
+ endResizeRootDrag();
121
+ }
122
+ function ensureResizeRootListeners() {
123
+ const g = getGlobalState();
124
+ if (g.resizeRootListenersInit) {
125
+ return;
126
+ }
127
+ g.resizeRootListenersInit = true;
128
+ window.addEventListener('pointerdown', onResizeRootPointerDown);
129
+ window.addEventListener('pointermove', onResizeRootPointerMove);
130
+ window.addEventListener('pointerup', onResizeRootPointerUp);
131
+ window.addEventListener('pointercancel', onResizeRootPointerUp);
132
+ }
133
+ function scheduleContainerResize() {
134
+ const g = getGlobalState();
135
+ if (g.resizeRafId !== 0) {
136
+ return;
137
+ }
138
+ g.resizeRafId = requestAnimationFrame(() => {
139
+ g.resizeRafId = 0;
140
+ notifyContainerResize();
141
+ });
142
+ }
143
+ let sharedResizeObserver = null;
144
+ let widthProbe = null;
145
+ function observeWidthProbe(container) {
146
+ if (widthProbe) {
147
+ return;
148
+ }
149
+ if (!sharedResizeObserver) {
150
+ sharedResizeObserver = new ResizeObserver(() => {
151
+ const g = getGlobalState();
152
+ if (getIsFastMode(g.store)) {
153
+ return;
154
+ }
155
+ scheduleContainerResize();
156
+ });
157
+ }
158
+ widthProbe = container;
159
+ sharedResizeObserver.observe(container);
160
+ }
161
+ function unobserveWidthProbe(container) {
162
+ if (widthProbe !== container) {
163
+ return;
164
+ }
165
+ sharedResizeObserver?.unobserve(container);
166
+ widthProbe = null;
167
+ }
168
+ /** Panel resize handle — call on first pointer move after press, not on pointer down. */
169
+ function notifyPanelWidthDragStart() {
170
+ const g = getGlobalState();
171
+ if (g.panelDragActive) {
172
+ return;
173
+ }
174
+ clearSettleTimer();
175
+ g.panelDragActive = true;
176
+ g.store = { ...g.store, isPanelDragging: true };
177
+ syncFastModeDom(g.store);
178
+ }
179
+ function notifyPanelWidthDragEnd() {
180
+ const g = getGlobalState();
181
+ if (!g.panelDragActive) {
182
+ return;
183
+ }
184
+ g.panelDragActive = false;
185
+ g.store = { ...g.store, isPanelDragging: false };
186
+ syncFastModeDom(g.store);
187
+ scheduleSettle();
188
+ }
189
+ function computeTruncatedText(fullTextEl, text, containerWidth) {
190
+ if (text.length <= END_CHARS_COUNT) {
191
+ return text;
192
+ }
193
+ fullTextEl.textContent = text;
194
+ if (fullTextEl.scrollWidth <= containerWidth) {
195
+ return text;
196
+ }
197
+ const endPart = text.slice(-END_CHARS_COUNT);
198
+ let left = 0;
199
+ let right = text.length - END_CHARS_COUNT;
200
+ let bestStart = 0;
201
+ while (left <= right) {
202
+ const mid = Math.floor((left + right) / 2);
203
+ const startPart = text.slice(0, mid);
204
+ const truncated = startPart + ELLIPSIS + endPart;
205
+ fullTextEl.textContent = truncated;
206
+ if (fullTextEl.scrollWidth <= containerWidth) {
207
+ bestStart = mid;
208
+ left = mid + 1;
209
+ }
210
+ else {
211
+ right = mid - 1;
212
+ }
213
+ }
214
+ if (bestStart === 0) {
215
+ fullTextEl.textContent = ELLIPSIS + endPart;
216
+ if (fullTextEl.scrollWidth <= containerWidth) {
217
+ return ELLIPSIS + endPart;
218
+ }
219
+ return endPart;
220
+ }
221
+ return text.slice(0, bestStart) + ELLIPSIS + endPart;
222
+ }
223
+ const SmartTextTruncate = memo(function SmartTextTruncate({ children, className, ...props }) {
7
224
  const containerRef = useRef(null);
8
225
  const fullTextRef = useRef(null);
226
+ const lastMeasuredWidthRef = useRef(0);
227
+ const childrenRef = useRef(children);
228
+ childrenRef.current = children;
9
229
  const [displayText, setDisplayText] = useState(typeof children === 'string' ? children : '');
10
- const [resizeTrigger, setResizeTrigger] = useState(0);
11
- useLayoutEffect(() => {
230
+ const displayTextRef = useRef(displayText);
231
+ displayTextRef.current = displayText;
232
+ const recalc = useCallback(() => {
233
+ if (getIsFastMode(getGlobalState().store)) {
234
+ return;
235
+ }
12
236
  const container = containerRef.current;
13
237
  const fullText = fullTextRef.current;
14
- if (!container || !fullText || typeof children !== 'string') {
238
+ const text = childrenRef.current;
239
+ if (!container || !fullText || typeof text !== 'string') {
15
240
  return;
16
241
  }
17
- const text = children;
18
- // If text is shorter than END_CHARS_COUNT, no truncation needed
19
242
  if (text.length <= END_CHARS_COUNT) {
20
- setDisplayText(text);
243
+ if (displayTextRef.current !== text) {
244
+ setDisplayText(text);
245
+ }
21
246
  return;
22
247
  }
23
- // Measure container width
24
248
  const containerWidth = container.clientWidth;
25
249
  if (containerWidth === 0) {
26
- // Container not yet rendered, keep current text
27
250
  return;
28
251
  }
29
- // Measure full text width
30
- fullText.textContent = text;
31
- const fullTextWidth = fullText.scrollWidth;
32
- // If text fits, show full text
33
- if (fullTextWidth <= containerWidth) {
34
- setDisplayText(text);
252
+ if (containerWidth === lastMeasuredWidthRef.current &&
253
+ lastMeasuredWidthRef.current !== 0) {
35
254
  return;
36
255
  }
37
- // Calculate truncated text: <start>...<last 10 chars>
38
- const endPart = text.slice(-END_CHARS_COUNT);
39
- // Binary search for optimal start length
40
- let left = 0;
41
- let right = text.length - END_CHARS_COUNT;
42
- let bestStart = 0;
43
- while (left <= right) {
44
- const mid = Math.floor((left + right) / 2);
45
- const startPart = text.slice(0, mid);
46
- const truncated = startPart + ELLIPSIS + endPart;
47
- fullText.textContent = truncated;
48
- const truncatedWidth = fullText.scrollWidth;
49
- if (truncatedWidth <= containerWidth) {
50
- bestStart = mid;
51
- left = mid + 1;
52
- }
53
- else {
54
- right = mid - 1;
55
- }
56
- }
57
- // Ensure we have at least some start text
58
- if (bestStart === 0) {
59
- // If even just ellipsis + end doesn't fit, show only end part
60
- fullText.textContent = ELLIPSIS + endPart;
61
- if (fullText.scrollWidth <= containerWidth) {
62
- setDisplayText(ELLIPSIS + endPart);
63
- }
64
- else {
65
- // Last resort: show only end part without ellipsis
66
- setDisplayText(endPart);
67
- }
68
- }
69
- else {
70
- setDisplayText(text.slice(0, bestStart) + ELLIPSIS + endPart);
256
+ lastMeasuredWidthRef.current = containerWidth;
257
+ const nextText = computeTruncatedText(fullText, text, containerWidth);
258
+ if (nextText !== displayTextRef.current) {
259
+ setDisplayText(nextText);
71
260
  }
72
- }, [children, resizeTrigger]);
73
- // Handle ResizeObserver for container resizing
261
+ }, []);
262
+ useLayoutEffect(() => {
263
+ lastMeasuredWidthRef.current = 0;
264
+ recalc();
265
+ }, [children, recalc]);
266
+ useLayoutEffect(() => {
267
+ ensureResizeRootListeners();
268
+ const g = getGlobalState();
269
+ g.recalcCallbacks.add(recalc);
270
+ return () => {
271
+ g.recalcCallbacks.delete(recalc);
272
+ };
273
+ }, [recalc]);
74
274
  useLayoutEffect(() => {
275
+ ensureResizeRootListeners();
75
276
  const container = containerRef.current;
76
- if (!container)
277
+ if (!container) {
77
278
  return;
78
- const resizeObserver = new ResizeObserver(() => {
79
- // Trigger recalculation by updating resizeTrigger
80
- setResizeTrigger(prev => prev + 1);
81
- });
82
- resizeObserver.observe(container);
279
+ }
280
+ observeWidthProbe(container);
83
281
  return () => {
84
- resizeObserver.disconnect();
282
+ unobserveWidthProbe(container);
85
283
  };
86
284
  }, []);
87
285
  if (typeof children !== 'string') {
88
286
  return (jsx("span", { className: className, ...props, children: children }));
89
287
  }
90
- return (jsxs("span", { ref: containerRef, className: className, ...props, style: { position: 'relative', ...props.style }, children: [displayText, jsx("span", { ref: fullTextRef, style: {
91
- position: 'absolute',
92
- visibility: 'hidden',
93
- whiteSpace: 'nowrap',
94
- top: '-9999px',
95
- }, "aria-hidden": "true", children: children })] }));
96
- }
288
+ return (jsxs("span", { ref: containerRef, className: cn(S.root, className), ...props, children: [jsx("span", { className: S.measuredLabel, children: displayText || children }), jsx("span", { className: S.liveLabel, children: children }), jsx("span", { ref: fullTextRef, className: S.fullText, "aria-hidden": "true", children: children })] }));
289
+ });
97
290
 
98
- export { SmartTextTruncate };
291
+ export { SmartTextTruncate, notifyPanelWidthDragEnd, notifyPanelWidthDragStart };
@@ -0,0 +1,7 @@
1
+ import styleInject from 'style-inject';
2
+
3
+ var css_248z = ".SmartTextTruncate_root__GtH6n{min-width:0;overflow:hidden;position:relative}.SmartTextTruncate_measuredLabel__f2OgX{display:block;min-width:0;overflow:hidden;white-space:nowrap}.SmartTextTruncate_liveLabel__pAn3y{display:none;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}html[data-smart-text-truncate-fast] .SmartTextTruncate_measuredLabel__f2OgX{display:none}html[data-smart-text-truncate-fast] .SmartTextTruncate_liveLabel__pAn3y{display:block}html[data-smart-text-truncate-fast] .SmartTextTruncate_fullText__juggj{display:none}.SmartTextTruncate_fullText__juggj{position:absolute;top:-9999px;visibility:hidden;white-space:nowrap}";
4
+ var S = {"root":"SmartTextTruncate_root__GtH6n","measuredLabel":"SmartTextTruncate_measuredLabel__f2OgX","liveLabel":"SmartTextTruncate_liveLabel__pAn3y","fullText":"SmartTextTruncate_fullText__juggj"};
5
+ styleInject(css_248z);
6
+
7
+ export { S as default };
@@ -39,11 +39,20 @@ function toForecastDataKey(id) {
39
39
  const s = String(id);
40
40
  return s.startsWith('forecast_') ? s : `forecast_${id}`;
41
41
  }
42
- function DriversComparisonChart({ payload, datasetHistorical = [], loading = false, chartLoading = false, statusHint = null, statusTone = 'muted', runAnalysisHint = false, timeRange: timeRangeProp, onTimeRangeChange, isDarkTheme = false, className, seriesInitKey, viewTab: viewTabProp, onViewTabChange, }) {
42
+ function DriversComparisonChart({ payload, datasetHistorical = [], loading = false, chartLoading = false, statusHint = null, statusTone = 'muted', runAnalysisHint = false, timeRange: timeRangeProp, onTimeRangeChange, isDarkTheme = false, className, seriesInitKey, viewTab: viewTabProp, onViewTabChange, hiddenSeries: hiddenSeriesProp, onHiddenSeriesChange, }) {
43
43
  const [internalTimeRange, setInternalTimeRange] = useState(ALL_TIME_RANGE);
44
44
  const [internalViewTab, setInternalViewTab] = useState('overlapped');
45
- const [hiddenSeries, setHiddenSeries] = useState(new Set());
45
+ const [internalHiddenSeries, setInternalHiddenSeries] = useState(new Set());
46
46
  const viewTab = viewTabProp ?? internalViewTab;
47
+ const hiddenSeriesControlled = hiddenSeriesProp !== undefined;
48
+ const hiddenSeries = hiddenSeriesProp ?? internalHiddenSeries;
49
+ const setHiddenSeries = useCallback((update) => {
50
+ if (onHiddenSeriesChange) {
51
+ onHiddenSeriesChange(update);
52
+ return;
53
+ }
54
+ setInternalHiddenSeries(update);
55
+ }, [onHiddenSeriesChange]);
47
56
  const timeRange = timeRangeProp ?? internalTimeRange;
48
57
  const handleTimeRangeChange = useCallback((val) => {
49
58
  if (!val)
@@ -63,7 +72,7 @@ function DriversComparisonChart({ payload, datasetHistorical = [], loading = fal
63
72
  next.add(key);
64
73
  return next;
65
74
  });
66
- }, []);
75
+ }, [setHiddenSeries]);
67
76
  const showSeries = useCallback((id) => {
68
77
  const key = toForecastDataKey(id);
69
78
  setHiddenSeries(prev => {
@@ -73,7 +82,7 @@ function DriversComparisonChart({ payload, datasetHistorical = [], loading = fal
73
82
  next.delete(key);
74
83
  return next;
75
84
  });
76
- }, []);
85
+ }, [setHiddenSeries]);
77
86
  const payloadForView = useMemo(() => applyDriversComparisonViewToPayload(payload, viewTab), [payload, viewTab]);
78
87
  const sortedDriversWithData = useMemo(() => {
79
88
  const driversList = payloadForView?.drivers ?? [];
@@ -133,6 +142,8 @@ function DriversComparisonChart({ payload, datasetHistorical = [], loading = fal
133
142
  const seriesInitKeyResolved = seriesInitKey ?? `${tableSeriesRows.map(r => r.id).join(',') || 'none'}`;
134
143
  const backtestsSeriesInitKeyRef = useRef('');
135
144
  useEffect(() => {
145
+ if (hiddenSeriesControlled)
146
+ return;
136
147
  if (tableSeriesRows.length === 0)
137
148
  return;
138
149
  const initKey = seriesInitKeyResolved;
@@ -149,7 +160,12 @@ function DriversComparisonChart({ payload, datasetHistorical = [], loading = fal
149
160
  });
150
161
  return next;
151
162
  });
152
- }, [seriesInitKeyResolved, tableSeriesRows]);
163
+ }, [
164
+ hiddenSeriesControlled,
165
+ seriesInitKeyResolved,
166
+ setHiddenSeries,
167
+ tableSeriesRows,
168
+ ]);
153
169
  const driversComparisonChartData = useMemo(() => buildDriversComparisonChartData(mergedWithHistorical, datasetHistorical, chartForecastData.map(f => f.id), historicalWindowFloor), [
154
170
  chartForecastData,
155
171
  datasetHistorical,
@@ -48,8 +48,8 @@ function spaghettiForecastLineColor(id, index) {
48
48
  return SPAGHETTI_CUSTOM_PERFORMANCE_LINE_COLOR;
49
49
  return FORECAST_LINE_COLORS[index % FORECAST_LINE_COLORS.length];
50
50
  }
51
- function PerformanceChart({ performanceData, historicalData = [], combinedData = [], forecastData = {}, userSeries = [], spaghettiUserSeries = [], customPerformanceMatrix = null, customPerformanceLabel = null, loading = false, chartLoading = false, performanceSectionPending = false, isEmpty = false, perfFetchSettled = true, performanceDataLoading = false, performanceAnalysisId = null, statusHint = null, statusTone = 'muted', runAnalysisHint = false, timeRange: timeRangeProp, onTimeRangeChange, isDarkTheme = false, className, seriesInitKey, toolbarStart, onEditCustomPerformance, showAddEditCustomDataButton = false, addEditCustomDataDisabled = false, hiddenSeries: hiddenSeriesProp, onToggleLegendSeries, onEnsureSeriesVisible, onHiddenSeriesChange, }) {
52
- const [viewTab, setViewTab] = useState('perHorizon');
51
+ function PerformanceChart({ performanceData, historicalData = [], combinedData = [], forecastData = {}, userSeries = [], spaghettiUserSeries = [], customPerformanceMatrix = null, customPerformanceLabel = null, loading = false, chartLoading = false, performanceSectionPending = false, isEmpty = false, perfFetchSettled = true, performanceDataLoading = false, performanceAnalysisId = null, statusHint = null, statusTone = 'muted', runAnalysisHint = false, timeRange: timeRangeProp, onTimeRangeChange, viewTab: viewTabProp, onViewTabChange, isDarkTheme = false, className, seriesInitKey, toolbarStart, onEditCustomPerformance, showAddEditCustomDataButton = false, addEditCustomDataDisabled = false, hiddenSeries: hiddenSeriesProp, onToggleLegendSeries, onEnsureSeriesVisible, onHiddenSeriesChange, }) {
52
+ const [internalViewTab, setInternalViewTab] = useState('perHorizon');
53
53
  const [pinMonth, setPinMonth] = useState(undefined);
54
54
  const [spaghettiTimeRange, setSpaghettiTimeRange] = useState('All');
55
55
  const [perHorizonChartTimeRange, setPerHorizonChartTimeRange] = useState('All');
@@ -64,6 +64,13 @@ function PerformanceChart({ performanceData, historicalData = [], combinedData =
64
64
  });
65
65
  const hiddenSeriesControlled = hiddenSeriesProp !== undefined;
66
66
  const hiddenSeries = hiddenSeriesProp ?? internalHiddenSeries;
67
+ const viewTab = viewTabProp ?? internalViewTab;
68
+ const handleViewTabChange = useCallback((tab) => {
69
+ onViewTabChange?.(tab);
70
+ if (viewTabProp === undefined) {
71
+ setInternalViewTab(tab);
72
+ }
73
+ }, [onViewTabChange, viewTabProp]);
67
74
  const setHiddenSeries = useCallback((update) => {
68
75
  if (onHiddenSeriesChange) {
69
76
  onHiddenSeriesChange(update);
@@ -799,7 +806,7 @@ function PerformanceChart({ performanceData, historicalData = [], combinedData =
799
806
  const showEmptyOverlay = (runAnalysisHint || Boolean(statusHint) || isEmpty) && !loading;
800
807
  return (jsx("div", { className: cn(S.root, performanceSectionPending && !spaghettiTabShowsChartData && S.loading, isLoaded && S.loaded, isEmpty && S.isEmpty, className), children: jsxs(Tabs, { variant: "button", value: viewTab, onValueChange: v => {
801
808
  if (v === 'perHorizon' || v === 'spaghetti') {
802
- setViewTab(v);
809
+ handleViewTabChange(v);
803
810
  }
804
811
  }, className: S.viewTabs, children: [jsxs("div", { className: S.toolbarRow, children: [toolbarStart, jsxs(TabsList, { className: S.viewTabsList, children: [jsx(TabsTrigger, { value: "perHorizon", children: "Per horizon plot" }), jsx(TabsTrigger, { value: "spaghetti", children: "Spaghetti plots" })] }), jsx("div", { className: S.toolBarRight, children: viewTab === 'perHorizon' && performanceData && (jsx(HorizonsSelector, { selectedHorizon: selectedHorizon, onHorizonChange: setSelectedHorizon, availableHorizons: availableHorizons })) })] }), jsxs("div", { className: cn(S.perHorizonChartWrap, performanceSectionPending && S.perHorizonChartWrapLoading), children: [jsx(ChartAreaInteractive, { disableHistoricalAnimation: true, disableTimeRangeSelector: true, enableTimeRangeBrush: true, disableAnimation: isSpaghettiView, chartContainerClassName: S.chartContainer, chartData: perHorizonChartProps.chartData, forecastData: perHorizonChartProps.forecastData, timeRange: activeTimeRange, onTimeRangeChange: handlePerformanceChartTimeRangeChange, pinMonth: pinMonth, onPinMonthChange: updatePinMonth, isDarkTheme: isDarkTheme, loading: perHorizonChartProps.loading || chartLoading, yMin: perHorizonChartProps.yMin, yMax: perHorizonChartProps.yMax, autoScaleYAxis: false, maxVisibleItems: 2, preventDeselection: true, showLegend: false, footerActions: performanceUnderChartLegend ?? undefined, hasCombinedData: perHorizonChartProps.hasCombinedData, hiddenSeries: hiddenSeries, toggleLegendSeries: toggleLegendSeriesKey, ensureAnalysisSeriesVisible: ensureSeriesVisible }), showEmptyOverlay && (jsx("div", { className: S.chartEmptyOverlay, role: "status", "aria-live": "polite", children: jsx(ChartEmptyState, { variant: "inline", hint: runAnalysisHint ? ('Run a completed analysis to load performance data for an analysis.') : isEmpty ? (jsxs(Fragment, { children: ["No performance data for this dataset.", jsx("br", {}), "Please contact", ' ', jsx("a", { href: "mailto:support@sybilion.com", children: "support team" }), " to gain access to the latest performance data."] })) : undefined, status: statusHint ?? undefined, statusTone: statusTone }) })), performanceSectionPending && (jsx("div", { className: S.performanceLoadingLayer, "aria-busy": "true", "aria-live": "polite", children: jsx("div", { className: S.emptyState, children: jsx(TextShimmer, { as: "span", className: S.performanceLoadingText, children: "Loading performance data\u2026" }) }) }))] }), !performanceDataLoading && performanceData && (jsx(PerformanceTable, { forecastModels: forecastModelsData, adjustParameters: adjustParameters, onAdjustParametersChange: setAdjustParameters, customPerformance: customPerformanceTableRow, onEditCustomPerformance: onEditCustomPerformance, showAddEditCustomDataButton: showAddEditCustomDataButton, addEditCustomDataDisabled: addEditCustomDataDisabled }))] }) }));
805
812
  }
@@ -2,7 +2,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { useMemo, useState, useEffect } from 'react';
3
3
  import { SidebarGroup, SidebarMenu, SidebarMenuItem, SidebarMenuButton, SidebarMenuSub, SidebarMenuSubItem, SidebarMenuSubButton } from '../../ui/Sidebar/Sidebar.js';
4
4
  import { SmartTextTruncate } from '../../ui/SmartTextTruncate/SmartTextTruncate.js';
5
- import { PackageOpen, ChevronDown, ChevronRight } from 'lucide-react';
5
+ import { PackageOpen } from 'lucide-react';
6
6
  import S from './SidebarDatasetsItemsGrouped.styl.js';
7
7
  import { groupSidebarDatasets } from './groupSidebarDatasets.js';
8
8
 
@@ -44,10 +44,10 @@ function SidebarDatasetsItemsGrouped({ groupBy, datasets, preItems, postItems, s
44
44
  return (jsx(SidebarGroup, { className: className, children: jsxs(SidebarMenu, { children: [preItems, grouped.map(([groupName, groupDatasets]) => {
45
45
  const isExpanded = expanded.has(groupName);
46
46
  const parentActive = groupDatasets.some(d => d.id === selectedDatasetId);
47
- return (jsxs(SidebarMenuItem, { children: [jsxs(SidebarMenuButton, { type: "button", isActive: parentActive, onClick: () => toggleGroup(groupName), children: [jsx(PackageOpen, { strokeWidth: 1.5, size: 16 }), jsx(SmartTextTruncate, { children: groupName }), jsx("div", { className: S.chevronContainer, children: isExpanded ? (jsx(ChevronDown, { size: 12 })) : (jsx(ChevronRight, { size: 12 })) })] }), isExpanded && (jsxs(SidebarMenuSub, { className: S.subMenuContainer, children: [jsx("div", { className: S.subMenuBorder }), groupDatasets.map(dataset => (jsx(SidebarMenuSubItem, { className: S.subMenuItem, children: jsx(SidebarMenuSubButton, { href: `#dataset-${dataset.id}`, isActive: dataset.id === selectedDatasetId, onClick: e => {
48
- e.preventDefault();
49
- onDatasetClick?.(dataset.id);
50
- }, children: jsx(SmartTextTruncate, { "data-dataset-id": dataset.id, children: dataset.name }) }) }, dataset.id)))] }))] }, groupName));
47
+ return (jsxs(SidebarMenuItem, { children: [jsx(SidebarMenuButton, { type: "button", isActive: parentActive, hasSubItems: true, isExpanded: isExpanded, onClick: () => toggleGroup(groupName), icon: jsx(PackageOpen, { strokeWidth: 1.5, size: 16 }), children: groupName }), isExpanded && (jsx(SidebarMenuSub, { className: S.subMenuContainer, children: groupDatasets.map(dataset => (jsx(SidebarMenuSubItem, { className: S.subMenuItem, children: jsx(SidebarMenuSubButton, { href: `#dataset-${dataset.id}`, isActive: dataset.id === selectedDatasetId, onClick: e => {
48
+ e.preventDefault();
49
+ onDatasetClick?.(dataset.id);
50
+ }, children: jsx(SmartTextTruncate, { "data-dataset-id": dataset.id, children: dataset.name }) }) }, dataset.id))) }))] }, groupName));
51
51
  }), postItems] }) }));
52
52
  }
53
53
 
@@ -1,7 +1,7 @@
1
1
  import styleInject from 'style-inject';
2
2
 
3
- var css_248z = ".SidebarDatasetsItemsGrouped_chevronContainer__CoQnn{margin-left:auto}.SidebarDatasetsItemsGrouped_subMenuContainer__utcha{position:relative}.SidebarDatasetsItemsGrouped_subMenuBorder__LN-Fq{background:var(--sidebar-border);bottom:26px;left:var(--p-5);position:absolute;top:0;width:1px}.SidebarDatasetsItemsGrouped_subMenuItem__9gFCe{margin-left:var(--p-6);position:relative}.SidebarDatasetsItemsGrouped_subMenuItem__9gFCe:before{border-bottom:1px solid var(--sidebar-border);border-bottom-left-radius:var(--p-2);border-left:1px solid var(--sidebar-border);bottom:0;content:\"\";height:var(--p-3);left:calc(var(--p-1)*-1);position:absolute;top:var(--p-2);width:var(--p-3)}";
4
- var S = {"chevronContainer":"SidebarDatasetsItemsGrouped_chevronContainer__CoQnn","subMenuContainer":"SidebarDatasetsItemsGrouped_subMenuContainer__utcha","subMenuBorder":"SidebarDatasetsItemsGrouped_subMenuBorder__LN-Fq","subMenuItem":"SidebarDatasetsItemsGrouped_subMenuItem__9gFCe"};
3
+ var css_248z = ".SidebarDatasetsItemsGrouped_subMenuContainer__utcha,.SidebarDatasetsItemsGrouped_subMenuItem__9gFCe{position:relative}";
4
+ var S = {"subMenuContainer":"SidebarDatasetsItemsGrouped_subMenuContainer__utcha","subMenuItem":"SidebarDatasetsItemsGrouped_subMenuItem__9gFCe"};
5
5
  styleInject(css_248z);
6
6
 
7
7
  export { S as default };
package/dist/esm/index.js CHANGED
@@ -95,7 +95,7 @@ export { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHe
95
95
  export { DISMISS_CHAT_FOR_LAYOUT_EVENT, PanelResizeHandle, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarResizeHandle, SidebarSeparator, SidebarTrigger, useSidebar, useSidebarActions, useSidebarState } from './components/ui/Sidebar/Sidebar.js';
96
96
  export { Skeleton } from './components/ui/Skeleton/Skeleton.js';
97
97
  export { Slider } from './components/ui/Slider/Slider.js';
98
- export { SmartTextTruncate } from './components/ui/SmartTextTruncate/SmartTextTruncate.js';
98
+ export { SmartTextTruncate, notifyPanelWidthDragEnd, notifyPanelWidthDragStart } from './components/ui/SmartTextTruncate/SmartTextTruncate.js';
99
99
  export { Sparkline } from './components/ui/Sparkline/Sparkline.js';
100
100
  export { Switch } from './components/ui/Switch/Switch.js';
101
101
  export { Table, TableBody, TableCell, TableCellValue, TableFooter, TableHead, TableHeader, TableRow } from './components/ui/Table/Table.js';
@@ -13,6 +13,7 @@ export interface ChatSheetProps extends Omit<UseChatPanelChromeModelInput, 'embe
13
13
  /** Imperative open / new-chat for triggers outside `renderTrigger` (e.g. sidebar). */
14
14
  actionsRef?: React.MutableRefObject<ChatSheetActions | null>;
15
15
  renderTrigger?: (toggleOpen: () => void, isOpen: boolean) => React.ReactNode;
16
+ triggerIcon?: React.ReactNode;
16
17
  triggerLabel?: React.ReactNode;
17
18
  /** aria-label for icon-only trigger (required when trigger has no visible text) */
18
19
  triggerAriaLabel?: string;
@@ -23,4 +24,4 @@ export interface ChatSheetProps extends Omit<UseChatPanelChromeModelInput, 'embe
23
24
  */
24
25
  inline?: boolean;
25
26
  }
26
- export declare function ChatSheet({ triggerLabel, triggerAriaLabel, actionsRef, renderTrigger, presets, scopeId, onMessage, onScriptComplete, renderMessageChart, renderSystemMessage, emptyState, allowedAttachments, allowPdfAttachments, onAttachmentsDropped, slashCommandItems, onSlashItemCommand, transformSendPayload, inline, }: ChatSheetProps): import("react/jsx-runtime").JSX.Element;
27
+ export declare function ChatSheet({ triggerIcon, triggerLabel, triggerAriaLabel, actionsRef, renderTrigger, presets, scopeId, onMessage, onScriptComplete, renderMessageChart, renderSystemMessage, emptyState, allowedAttachments, allowPdfAttachments, onAttachmentsDropped, slashCommandItems, onSlashItemCommand, transformSendPayload, inline, }: ChatSheetProps): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { BreadcrumbItem } from '#uilib/components/ui/Page/Breadcrumbs/Breadcrumbs.types';
2
- export declare function PageHeader({ breadcrumbs, breadcrumbClientLogo, breadcrumbCompanyName, breadcrumbSidebarTrigger, title, subheader, actions, }: {
2
+ export declare function PageHeader({ breadcrumbs, breadcrumbClientLogo, breadcrumbCompanyName, breadcrumbSidebarTrigger, title, subheader, actions, sticky, }: {
3
3
  breadcrumbs?: BreadcrumbItem[];
4
4
  breadcrumbClientLogo?: React.ReactNode;
5
5
  breadcrumbCompanyName?: string;
@@ -8,4 +8,5 @@ export declare function PageHeader({ breadcrumbs, breadcrumbClientLogo, breadcru
8
8
  title: React.ReactNode;
9
9
  subheader?: React.ReactNode;
10
10
  actions?: React.ReactNode;
11
+ sticky?: boolean;
11
12
  }): import("react/jsx-runtime").JSX.Element;
@@ -82,8 +82,13 @@ declare function SidebarGroupAction({ className, asChild, ...props }: ComponentP
82
82
  }): import("react/jsx-runtime").JSX.Element;
83
83
  declare function SidebarMenu({ className, ...props }: ComponentProps<'ul'>): import("react/jsx-runtime").JSX.Element;
84
84
  declare function SidebarMenuItem({ className, ...props }: ComponentProps<'li'>): import("react/jsx-runtime").JSX.Element;
85
- declare function SidebarMenuButton({ asChild, isActive, variant, size, className, ...props }: ButtonProps & {
85
+ declare function SidebarMenuButton({ asChild, isActive, hasSubItems, isExpanded, variant, size, className, icon, children, ...props }: Omit<ButtonProps, 'icon'> & {
86
+ icon?: React.ReactNode;
86
87
  isActive?: boolean;
88
+ /** When true, renders an expand/collapse chevron (requires a non–asChild button). */
89
+ hasSubItems?: boolean;
90
+ /** Chevron direction when `hasSubItems` is true. */
91
+ isExpanded?: boolean;
87
92
  }): import("react/jsx-runtime").JSX.Element;
88
93
  declare function SidebarMenuAction({ className, asChild, showOnHover, ...props }: ComponentProps<'button'> & {
89
94
  asChild?: boolean;
@@ -92,7 +97,7 @@ declare function SidebarMenuAction({ className, asChild, showOnHover, ...props }
92
97
  declare function SidebarMenuBadge({ className, ...props }: ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
93
98
  declare function SidebarMenuSub({ className, ...props }: ComponentProps<'ul'>): import("react/jsx-runtime").JSX.Element;
94
99
  declare function SidebarMenuSubItem({ className, ...props }: ComponentProps<'li'>): import("react/jsx-runtime").JSX.Element;
95
- declare function SidebarMenuSubButton({ asChild, size, isActive, tooltip, className, onClick, ...props }: ComponentProps<'a'> & {
100
+ declare function SidebarMenuSubButton({ asChild, size, isActive, tooltip, className, onClick, children, ...props }: ComponentProps<'a'> & {
96
101
  asChild?: boolean;
97
102
  size?: 'sm' | 'md' | 'lg';
98
103
  isActive?: boolean;
@@ -1,3 +1,5 @@
1
- import type { SmartTextTruncateProps } from './SmartTextTruncate.types';
2
- declare function SmartTextTruncate({ children, className, ...props }: SmartTextTruncateProps): import("react/jsx-runtime").JSX.Element;
3
- export { SmartTextTruncate };
1
+ /** Panel resize handle — call on first pointer move after press, not on pointer down. */
2
+ declare function notifyPanelWidthDragStart(): void;
3
+ declare function notifyPanelWidthDragEnd(): void;
4
+ declare const SmartTextTruncate: import("react").NamedExoticComponent<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>>;
5
+ export { SmartTextTruncate, notifyPanelWidthDragStart, notifyPanelWidthDragEnd, };
@@ -1,2 +1,2 @@
1
- export { SmartTextTruncate } from './SmartTextTruncate';
1
+ export { SmartTextTruncate, notifyPanelWidthDragStart, notifyPanelWidthDragEnd, } from './SmartTextTruncate';
2
2
  export type { SmartTextTruncateProps } from './SmartTextTruncate.types';
@@ -17,6 +17,8 @@ export type DriversComparisonChartProps = {
17
17
  seriesInitKey?: string;
18
18
  viewTab?: DriversComparisonViewTab;
19
19
  onViewTabChange?: (tab: DriversComparisonViewTab) => void;
20
+ hiddenSeries?: Set<string>;
21
+ onHiddenSeriesChange?: (update: Set<string> | ((prev: Set<string>) => Set<string>)) => void;
20
22
  };
21
23
  export type { DriversComparisonViewTab } from './driversComparisonChart.helpers';
22
- export declare function DriversComparisonChart({ payload, datasetHistorical, loading, chartLoading, statusHint, statusTone, runAnalysisHint, timeRange: timeRangeProp, onTimeRangeChange, isDarkTheme, className, seriesInitKey, viewTab: viewTabProp, onViewTabChange, }: DriversComparisonChartProps): import("react/jsx-runtime").JSX.Element;
24
+ export declare function DriversComparisonChart({ payload, datasetHistorical, loading, chartLoading, statusHint, statusTone, runAnalysisHint, timeRange: timeRangeProp, onTimeRangeChange, isDarkTheme, className, seriesInitKey, viewTab: viewTabProp, onViewTabChange, hiddenSeries: hiddenSeriesProp, onHiddenSeriesChange, }: DriversComparisonChartProps): import("react/jsx-runtime").JSX.Element;
@@ -39,6 +39,9 @@ export type PerformanceChartProps = {
39
39
  onTimeRangeChange?: (range: string, meta?: {
40
40
  viewTab: PerformanceViewTab;
41
41
  }) => void;
42
+ /** Controlled Per horizon / Spaghetti tab; omit for internal state. */
43
+ viewTab?: PerformanceViewTab;
44
+ onViewTabChange?: (tab: PerformanceViewTab) => void;
42
45
  isDarkTheme?: boolean;
43
46
  className?: string;
44
47
  seriesInitKey?: string;
@@ -51,4 +54,4 @@ export type PerformanceChartProps = {
51
54
  onEnsureSeriesVisible?: (key: string) => void;
52
55
  onHiddenSeriesChange?: (update: Set<string> | ((prev: Set<string>) => Set<string>)) => void;
53
56
  };
54
- export declare function PerformanceChart({ performanceData, historicalData, combinedData, forecastData, userSeries, spaghettiUserSeries, customPerformanceMatrix, customPerformanceLabel, loading, chartLoading, performanceSectionPending, isEmpty, perfFetchSettled, performanceDataLoading, performanceAnalysisId, statusHint, statusTone, runAnalysisHint, timeRange: timeRangeProp, onTimeRangeChange, isDarkTheme, className, seriesInitKey, toolbarStart, onEditCustomPerformance, showAddEditCustomDataButton, addEditCustomDataDisabled, hiddenSeries: hiddenSeriesProp, onToggleLegendSeries, onEnsureSeriesVisible, onHiddenSeriesChange, }: PerformanceChartProps): import("react/jsx-runtime").JSX.Element;
57
+ export declare function PerformanceChart({ performanceData, historicalData, combinedData, forecastData, userSeries, spaghettiUserSeries, customPerformanceMatrix, customPerformanceLabel, loading, chartLoading, performanceSectionPending, isEmpty, perfFetchSettled, performanceDataLoading, performanceAnalysisId, statusHint, statusTone, runAnalysisHint, timeRange: timeRangeProp, onTimeRangeChange, viewTab: viewTabProp, onViewTabChange, isDarkTheme, className, seriesInitKey, toolbarStart, onEditCustomPerformance, showAddEditCustomDataButton, addEditCustomDataDisabled, hiddenSeries: hiddenSeriesProp, onToggleLegendSeries, onEnsureSeriesVisible, onHiddenSeriesChange, }: PerformanceChartProps): import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sybilion/uilib",
3
- "version": "1.4.11",
3
+ "version": "1.4.13",
4
4
  "description": "Sybilion Design System — React UI components (Webpack + Stylus)",
5
5
  "publishConfig": {
6
6
  "access": "public",