@sybilion/uilib 1.3.99 → 1.3.101
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/esm/components/ui/AnalysesSelector/AnalysesSelector.js +61 -14
- package/dist/esm/components/ui/AnalysesSelector/AnalysesSelector.styl.js +2 -2
- package/dist/esm/components/ui/AnalysesSelector/SelectInlineRenamer.js +102 -0
- package/dist/esm/components/ui/Banner/Banner.js +11 -0
- package/dist/esm/components/ui/Banner/Banner.styl.js +7 -0
- package/dist/esm/components/ui/Chart/Chart.js +9 -5
- package/dist/esm/components/ui/Chart/chartForecastVisualization.constants.js +23 -0
- package/dist/esm/components/ui/Chart/components/ConfidenceBands.js +9 -0
- package/dist/esm/components/ui/Chart/components/CustomChartLegend/CustomChartLegend.js +2 -2
- package/dist/esm/components/ui/Chart/components/ForecastBoundaries.js +32 -0
- package/dist/esm/components/ui/Chart/components/ForecastLine.js +24 -0
- package/dist/esm/components/ui/Chart/components/HistoricalLine.js +24 -0
- package/dist/esm/components/ui/Chart/hooks/useChartAnimation.js +17 -0
- package/dist/esm/components/ui/Chart/hooks/useChartColors.js +12 -0
- package/dist/esm/components/ui/Chart/hooks/useLegendState.js +30 -0
- package/dist/esm/components/ui/Chart/tools/formatters.js +19 -3
- package/dist/esm/components/ui/ChartAreaInteractive/ChartAreaInteractive.helpers.js +1 -10
- package/dist/esm/components/ui/Select/Select.js +3 -3
- package/dist/esm/components/widgets/DriverCard/DriverCard.js +6 -6
- package/dist/esm/components/widgets/DriverCard/DriverPerformanceChart.js +9 -5
- package/dist/esm/components/widgets/DriversComparisonChart/DriversComparisonChart.styl.js +1 -1
- package/dist/esm/components/widgets/PerformanceChart/PerformanceChart.styl.js +1 -1
- package/dist/esm/index.js +11 -1
- package/dist/esm/types/src/components/ui/AnalysesSelector/AnalysesSelector.d.ts +1 -1
- package/dist/esm/types/src/components/ui/AnalysesSelector/AnalysesSelector.types.d.ts +7 -1
- package/dist/esm/types/src/components/ui/AnalysesSelector/SelectInlineRenamer.d.ts +12 -0
- package/dist/esm/types/src/components/ui/Banner/Banner.d.ts +2 -0
- package/dist/esm/types/src/components/ui/Banner/Banner.types.d.ts +10 -0
- package/dist/esm/types/src/components/ui/Banner/index.d.ts +2 -0
- package/dist/esm/types/src/components/ui/Chart/Chart.d.ts +9 -0
- package/dist/esm/types/src/components/ui/Chart/components/index.d.ts +1 -1
- package/dist/esm/types/src/components/ui/Chart/tools/formatters.d.ts +3 -1
- package/dist/esm/types/src/components/ui/ChartAreaInteractive/index.d.ts +1 -1
- package/dist/esm/types/src/components/ui/Select/Select.d.ts +1 -1
- package/dist/esm/types/src/components/ui/Select/Select.types.d.ts +1 -0
- package/dist/esm/types/src/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/ui/AnalysesSelector/AnalysesSelector.styl +62 -1
- package/src/components/ui/AnalysesSelector/AnalysesSelector.styl.d.ts +8 -0
- package/src/components/ui/AnalysesSelector/AnalysesSelector.tsx +136 -27
- package/src/components/ui/AnalysesSelector/AnalysesSelector.types.ts +7 -2
- package/src/components/ui/AnalysesSelector/SelectInlineRenamer.tsx +191 -0
- package/src/components/ui/Banner/Banner.styl +28 -0
- package/src/components/ui/Banner/Banner.styl.d.ts +9 -0
- package/src/components/ui/Banner/Banner.tsx +32 -0
- package/src/components/ui/Banner/Banner.types.ts +8 -0
- package/src/components/ui/Banner/index.ts +2 -0
- package/src/components/ui/Chart/Chart.tsx +16 -0
- package/src/components/ui/Chart/components/CustomChartLegend/CustomChartLegend.tsx +2 -3
- package/src/components/ui/Chart/components/index.ts +5 -1
- package/src/components/ui/Chart/tools/formatters.ts +20 -2
- package/src/components/ui/ChartAreaInteractive/index.ts +15 -1
- package/src/components/ui/Select/Select.tsx +13 -5
- package/src/components/ui/Select/Select.types.ts +1 -0
- package/src/components/widgets/DriverCard/DriverCard.tsx +7 -8
- package/src/components/widgets/DriversComparisonChart/DriversComparisonChart.styl +0 -1
- package/src/components/widgets/PerformanceChart/PerformanceChart.styl +1 -1
- package/src/index.ts +1 -0
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { useRef, useMemo, useEffect } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { useRef, useMemo, useEffect, useState } from 'react';
|
|
5
4
|
import { AnalysisLineIcon } from '../AnalysisLineIcon/AnalysisLineIcon.js';
|
|
6
5
|
import { Badge } from '../Badge/Badge.js';
|
|
7
6
|
import { LabelWithId } from '../LabelWithId/LabelWithId.js';
|
|
8
|
-
import
|
|
7
|
+
import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '../Select/Select.js';
|
|
9
8
|
import { TextShimmer } from '../TextShimmer/TextShimmer.js';
|
|
10
|
-
import cn from 'classnames';
|
|
11
9
|
import { getLatestByUpdatedAt } from '../../../utils/analysisDate.js';
|
|
10
|
+
import { EyeClosedIcon, EyeIcon } from '@phosphor-icons/react';
|
|
11
|
+
import S from './AnalysesSelector.styl.js';
|
|
12
|
+
import { SelectInlineRenamer } from './SelectInlineRenamer.js';
|
|
12
13
|
|
|
13
14
|
const isFailed = (item) => item.status?.toLowerCase() === 'fail';
|
|
14
15
|
const isDashedIcon = (item) => item.id !== -1;
|
|
15
16
|
const defaultIsAnalysisInProgress = (status) => ['pending', 'running', 'cancelling'].includes(status?.toLowerCase() ?? '');
|
|
17
|
+
const shouldBlockSelectKeydownWhileRenaming = (e) => {
|
|
18
|
+
if (!(e.target instanceof HTMLInputElement)) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return (e.key === 'ArrowUp' ||
|
|
22
|
+
e.key === 'ArrowDown' ||
|
|
23
|
+
e.key === ' ' ||
|
|
24
|
+
e.key === 'Enter');
|
|
25
|
+
};
|
|
16
26
|
function renderItemContent(item) {
|
|
17
27
|
const failed = isFailed(item);
|
|
18
28
|
if (failed) {
|
|
19
|
-
return (jsx(Badge, { variant: "red",
|
|
29
|
+
return (jsx(Badge, { variant: "red", className: S.itemBadge, children: "failed" }));
|
|
20
30
|
}
|
|
21
31
|
const color = item.color || 'var(--foreground)';
|
|
22
32
|
return (jsx(AnalysisLineIcon, { color: color, variant: isDashedIcon(item) ? 'dashed' : 'solid' }));
|
|
@@ -29,7 +39,7 @@ function renderIcon(icon) {
|
|
|
29
39
|
}
|
|
30
40
|
return (jsx("span", { "data-slot": "analysis-icon", className: cn(S.icon, S.iconWrapper), children: icon }));
|
|
31
41
|
}
|
|
32
|
-
function AnalysesSelector({ items, selectedIds, onItemToggle, inlineMode = false, placeholder, disabled, size = 'md', variant = 'default', darker = false, className, triggerProps, onFailedItemClick, showHistorical = true, enableToggleHidden = false, maxVisibleItems = 1, preventDeselection = false, hiddenSeries: hiddenSeriesProp = new Set(), onToggleSeries = () => { }, isAnalysisInProgress: isAnalysisInProgressProp = defaultIsAnalysisInProgress, }) {
|
|
42
|
+
function AnalysesSelector({ items, selectedIds, onItemToggle, inlineMode = false, placeholder, disabled, size = 'md', variant = 'default', darker = false, className, triggerProps, onFailedItemClick, showHistorical = true, enableToggleHidden = false, maxVisibleItems = 1, preventDeselection = false, hiddenSeries: hiddenSeriesProp = new Set(), onToggleSeries = () => { }, isAnalysisInProgress: isAnalysisInProgressProp = defaultIsAnalysisInProgress, rename, }) {
|
|
33
43
|
const historicalAutoSelectedRef = useRef(false);
|
|
34
44
|
const hiddenSeries = hiddenSeriesProp;
|
|
35
45
|
const toggleSeries = (analysisId) => {
|
|
@@ -130,6 +140,18 @@ function AnalysesSelector({ items, selectedIds, onItemToggle, inlineMode = false
|
|
|
130
140
|
onItemToggle(-1);
|
|
131
141
|
}
|
|
132
142
|
}, [showHistorical, selectedIds, onItemToggle]);
|
|
143
|
+
const selectedItem = items.find(item => selectedSet.has(item.id)) ?? items[0];
|
|
144
|
+
const selectedId = selectedItem?.id;
|
|
145
|
+
const [isRenaming, setIsRenaming] = useState(false);
|
|
146
|
+
const [selectOpen, setSelectOpen] = useState(false);
|
|
147
|
+
useEffect(() => {
|
|
148
|
+
setIsRenaming(false);
|
|
149
|
+
}, [selectedId, rename?.value]);
|
|
150
|
+
useEffect(() => {
|
|
151
|
+
if (isRenaming) {
|
|
152
|
+
setSelectOpen(false);
|
|
153
|
+
}
|
|
154
|
+
}, [isRenaming]);
|
|
133
155
|
const handleSelectValue = (value) => {
|
|
134
156
|
if (!value)
|
|
135
157
|
return;
|
|
@@ -175,14 +197,39 @@ function AnalysesSelector({ items, selectedIds, onItemToggle, inlineMode = false
|
|
|
175
197
|
}
|
|
176
198
|
if (items.length === 0)
|
|
177
199
|
return null;
|
|
178
|
-
const selectedId = items.find(item => selectedSet.has(item.id))?.id ?? items[0]?.id;
|
|
179
200
|
const selectValue = selectedId != null ? String(selectedId) : '';
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
201
|
+
const showRenamer = rename && selectedItem && rename.renameableItemIds.has(selectedItem.id);
|
|
202
|
+
const singleItemSelect = items.length < 2;
|
|
203
|
+
const { className: triggerClassName, ...restTriggerProps } = triggerProps ?? {};
|
|
204
|
+
const triggerStyle = {
|
|
205
|
+
minWidth: 'auto',
|
|
206
|
+
height: 'auto',
|
|
207
|
+
fontSize: 'var(--text-xs)',
|
|
208
|
+
pointerEvents: singleItemSelect && !showRenamer ? 'none' : undefined,
|
|
209
|
+
};
|
|
210
|
+
const triggerClassNameMerged = cn(S.selectTrigger, isRenaming && S.selectTriggerRenaming, triggerClassName);
|
|
211
|
+
const renamerTriggerContent = showRenamer ? (jsxs("div", { className: cn(S.selectTriggerContent, disabled && S.selectTriggerRenamerDisabled), children: [renderItemContent(selectedItem), renderIcon(selectedItem.icon), jsx(SelectInlineRenamer, { value: rename.value, displayLabel: selectedItem.label, onChange: rename.onChange, disabled: disabled, className: S.selectTriggerRenamer, isRenaming: isRenaming, onEnterRenaming: () => setIsRenaming(prev => !prev) })] })) : null;
|
|
212
|
+
return (jsx("div", { className: cn(S.root, className), children: jsxs(Select, { value: selectValue, onValueChange: handleSelectValue, disabled: disabled, open: isRenaming || singleItemSelect ? false : selectOpen, onOpenChange: open => {
|
|
213
|
+
if (!isRenaming && !singleItemSelect) {
|
|
214
|
+
setSelectOpen(open);
|
|
215
|
+
}
|
|
216
|
+
}, children: [jsx(SelectTrigger, { asChild: showRenamer, size: size, variant: variant, darker: darker, hideChevron: singleItemSelect, ...restTriggerProps, ...(showRenamer
|
|
217
|
+
? {}
|
|
218
|
+
: {
|
|
219
|
+
style: triggerStyle,
|
|
220
|
+
className: triggerClassNameMerged,
|
|
221
|
+
onKeyDown: (e) => {
|
|
222
|
+
if (isRenaming && shouldBlockSelectKeydownWhileRenaming(e)) {
|
|
223
|
+
e.preventDefault();
|
|
224
|
+
e.stopPropagation();
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
}), children: showRenamer ? (jsx("div", { className: triggerClassNameMerged, style: triggerStyle, onKeyDown: e => {
|
|
228
|
+
if (isRenaming && shouldBlockSelectKeydownWhileRenaming(e)) {
|
|
229
|
+
e.preventDefault();
|
|
230
|
+
e.stopPropagation();
|
|
231
|
+
}
|
|
232
|
+
}, children: renamerTriggerContent })) : (jsx(LabelWithId, { className: S.selectTriggerLabelWithId, id: selectValue, label: jsx(SelectValue, { placeholder: selectPlaceholder }) })) }), jsx(SelectContent, { children: items.map(item => (jsx(SelectItem, { value: String(item.id), selected: selectedSet.has(item.id), textValue: item.label, children: renderSelectItem(item) }, item.id))) })] }) }));
|
|
186
233
|
}
|
|
187
234
|
|
|
188
235
|
export { AnalysesSelector };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styleInject from 'style-inject';
|
|
2
2
|
|
|
3
|
-
var css_248z = ".AnalysesSelector_root__V8v0T{align-items:center;display:flex;flex-wrap:wrap;justify-content:flex-start}.AnalysesSelector_variant-default__lbURP.AnalysesSelector_single__rAPT6{background-color:var(--background);border-radius:var(--p-4);padding:0 var(--p-2)}.AnalysesSelector_item__d3pDt{align-items:center;cursor:pointer;display:flex;gap:var(--p-2);margin:var(--p-1);transition:opacity .2s ease;-webkit-user-select:none;-moz-user-select:none;user-select:none}.AnalysesSelector_item__d3pDt.AnalysesSelector_disabled__6JhJQ,.AnalysesSelector_item__d3pDt:hover{opacity:.5}.AnalysesSelector_item__d3pDt.AnalysesSelector_disabled__6JhJQ:hover{opacity:.8}.AnalysesSelector_item__d3pDt.AnalysesSelector_historical__hAqpN{pointer-events:none}.AnalysesSelector_item__d3pDt.AnalysesSelector_dimmed__mYWY7{opacity:.5}.AnalysesSelector_icon__1Tb0U{flex-shrink:0;height:16px;max-height:16px;max-width:16px;overflow:hidden;width:16px}.AnalysesSelector_iconImage__r9yJx{display:block;-o-object-fit:contain;object-fit:contain}.AnalysesSelector_iconWrapper__2Kx8j{align-items:center;display:flex;justify-content:center;position:relative}.AnalysesSelector_iconWrapper__2Kx8j>img{height:100%;max-height:100%;max-width:100%;-o-object-fit:contain;object-fit:contain;width:100%}[data-slot=select-item] [data-slot=analysis-icon]{flex-shrink:0;height:16px!important;max-height:16px!important;max-width:16px!important;-o-object-fit:contain;object-fit:contain;overflow:hidden;width:16px!important}.AnalysesSelector_label__m-9Ml{flex
|
|
4
|
-
var S = {"root":"AnalysesSelector_root__V8v0T","variant-default":"AnalysesSelector_variant-default__lbURP","single":"AnalysesSelector_single__rAPT6","item":"AnalysesSelector_item__d3pDt","disabled":"AnalysesSelector_disabled__6JhJQ","historical":"AnalysesSelector_historical__hAqpN","dimmed":"AnalysesSelector_dimmed__mYWY7","icon":"AnalysesSelector_icon__1Tb0U","iconImage":"AnalysesSelector_iconImage__r9yJx","iconWrapper":"AnalysesSelector_iconWrapper__2Kx8j","label":"AnalysesSelector_label__m-9Ml","selectItemContent":"AnalysesSelector_selectItemContent__iRsNR","selectTrigger":"AnalysesSelector_selectTrigger__Avjkd","selectTriggerLabelWithId":"AnalysesSelector_selectTriggerLabelWithId__C32ph","itemLabelWithId":"AnalysesSelector_itemLabelWithId__8c0mY"};
|
|
3
|
+
var css_248z = ".AnalysesSelector_root__V8v0T{align-items:center;display:flex;flex-wrap:wrap;justify-content:flex-start}.AnalysesSelector_selectTriggerRenamer__rZmCN{min-width:0}.AnalysesSelector_selectInlineRenamer__pGAz0{align-items:center;display:flex;min-width:0}.AnalysesSelector_selectInlineRenamerInput__7al7v{border-radius:var(--p-2);margin-left:calc(var(--p-2)*-1);max-width:calc(100% - var(--p-4))!important;padding:0 var(--p-2)}.AnalysesSelector_renamerEditButton__lJ-8-{flex-shrink:0;opacity:.5;transition:opacity .2s ease-out}.AnalysesSelector_selectInlineRenamer__pGAz0:hover .AnalysesSelector_renamerEditButton__lJ-8-{opacity:1}.AnalysesSelector_variant-default__lbURP.AnalysesSelector_single__rAPT6{background-color:var(--background);border-radius:var(--p-4);padding:0 var(--p-2)}.AnalysesSelector_item__d3pDt{align-items:center;cursor:pointer;display:flex;gap:var(--p-2);margin:var(--p-1);transition:opacity .2s ease;-webkit-user-select:none;-moz-user-select:none;user-select:none}.AnalysesSelector_item__d3pDt.AnalysesSelector_disabled__6JhJQ,.AnalysesSelector_item__d3pDt:hover{opacity:.5}.AnalysesSelector_item__d3pDt.AnalysesSelector_disabled__6JhJQ:hover{opacity:.8}.AnalysesSelector_item__d3pDt.AnalysesSelector_historical__hAqpN{pointer-events:none}.AnalysesSelector_item__d3pDt.AnalysesSelector_dimmed__mYWY7{opacity:.5}.AnalysesSelector_itemBadge__WImMg{margin-bottom:-2px;margin-top:-2px}.AnalysesSelector_icon__1Tb0U{flex-shrink:0;height:16px;max-height:16px;max-width:16px;overflow:hidden;width:16px}.AnalysesSelector_iconImage__r9yJx{display:block;-o-object-fit:contain;object-fit:contain}.AnalysesSelector_iconWrapper__2Kx8j{align-items:center;display:flex;justify-content:center;position:relative}.AnalysesSelector_iconWrapper__2Kx8j>img{height:100%;max-height:100%;max-width:100%;-o-object-fit:contain;object-fit:contain;width:100%}[data-slot=select-item] [data-slot=analysis-icon]{flex-shrink:0;height:16px!important;max-height:16px!important;max-width:16px!important;-o-object-fit:contain;object-fit:contain;overflow:hidden;width:16px!important}.AnalysesSelector_label__m-9Ml{flex:1 1 auto;font-size:var(--text-xs);min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.AnalysesSelector_selectItemContent__iRsNR{align-items:center;display:flex;flex:1;flex-direction:row;flex-wrap:nowrap;gap:var(--p-2);min-width:0;width:100%}.AnalysesSelector_selectTrigger__Avjkd{font-size:var(--text-xs);height:auto;min-width:auto}.AnalysesSelector_selectTriggerRenaming__w0xCm{max-width:100%!important;width:100%!important}.AnalysesSelector_selectTriggerRenaming__w0xCm .AnalysesSelector_selectTriggerContent__RwRJL{flex:1;min-width:0;width:100%}.AnalysesSelector_selectTriggerRenaming__w0xCm .AnalysesSelector_selectTriggerRenamer__rZmCN{min-width:0}.AnalysesSelector_selectTriggerLabelWithId__C32ph{display:flex}.AnalysesSelector_selectTriggerContent__RwRJL{align-items:center;display:flex;gap:var(--p-2);min-height:var(--p-9);min-width:0}.AnalysesSelector_selectTriggerContent__RwRJL>:last-child{flex-shrink:0;max-width:100%;min-width:0}.AnalysesSelector_selectTriggerRenamerDisabled__bA8-G button{pointer-events:none}.AnalysesSelector_itemLabelWithId__8c0mY{align-items:center;display:flex;flex-grow:1;min-width:0}";
|
|
4
|
+
var S = {"root":"AnalysesSelector_root__V8v0T","selectTriggerRenamer":"AnalysesSelector_selectTriggerRenamer__rZmCN","selectInlineRenamer":"AnalysesSelector_selectInlineRenamer__pGAz0","selectInlineRenamerInput":"AnalysesSelector_selectInlineRenamerInput__7al7v","renamerEditButton":"AnalysesSelector_renamerEditButton__lJ-8-","variant-default":"AnalysesSelector_variant-default__lbURP","single":"AnalysesSelector_single__rAPT6","item":"AnalysesSelector_item__d3pDt","disabled":"AnalysesSelector_disabled__6JhJQ","historical":"AnalysesSelector_historical__hAqpN","dimmed":"AnalysesSelector_dimmed__mYWY7","itemBadge":"AnalysesSelector_itemBadge__WImMg","icon":"AnalysesSelector_icon__1Tb0U","iconImage":"AnalysesSelector_iconImage__r9yJx","iconWrapper":"AnalysesSelector_iconWrapper__2Kx8j","label":"AnalysesSelector_label__m-9Ml","selectItemContent":"AnalysesSelector_selectItemContent__iRsNR","selectTrigger":"AnalysesSelector_selectTrigger__Avjkd","selectTriggerRenaming":"AnalysesSelector_selectTriggerRenaming__w0xCm","selectTriggerContent":"AnalysesSelector_selectTriggerContent__RwRJL","selectTriggerLabelWithId":"AnalysesSelector_selectTriggerLabelWithId__C32ph","selectTriggerRenamerDisabled":"AnalysesSelector_selectTriggerRenamerDisabled__bA8-G","itemLabelWithId":"AnalysesSelector_itemLabelWithId__8c0mY"};
|
|
5
5
|
styleInject(css_248z);
|
|
6
6
|
|
|
7
7
|
export { S as default };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
4
|
+
import { Button } from '../Button/Button.js';
|
|
5
|
+
import { Input } from '../Input/Input.js';
|
|
6
|
+
import { TextShimmer } from '../TextShimmer/TextShimmer.js';
|
|
7
|
+
import { Tooltip, TooltipTrigger, TooltipContent } from '../Tooltip/Tooltip.js';
|
|
8
|
+
import { PencilSimpleIcon } from '@phosphor-icons/react';
|
|
9
|
+
import S from './AnalysesSelector.styl.js';
|
|
10
|
+
|
|
11
|
+
const LABEL_MAX = 64;
|
|
12
|
+
const MANUALLY_ADJUSTED_NAME = 'Manually adjusted';
|
|
13
|
+
const MANUALLY_ADJUSTED_RENAME_MAX = LABEL_MAX - MANUALLY_ADJUSTED_NAME.length;
|
|
14
|
+
const stopSelectBubble = (e) => {
|
|
15
|
+
e.stopPropagation();
|
|
16
|
+
};
|
|
17
|
+
const stopSelectOpen = (e) => {
|
|
18
|
+
e.preventDefault();
|
|
19
|
+
e.stopPropagation();
|
|
20
|
+
};
|
|
21
|
+
const stopRenamerKeyboardBubble = (e) => {
|
|
22
|
+
e.stopPropagation();
|
|
23
|
+
e.nativeEvent.stopImmediatePropagation();
|
|
24
|
+
};
|
|
25
|
+
function SelectInlineRenamer({ value, displayLabel, onChange, onEnterRenaming, disabled, className, isRenaming, }) {
|
|
26
|
+
const [draft, setDraft] = useState(value);
|
|
27
|
+
const [isSaving, setIsSaving] = useState(false);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (!isSaving) {
|
|
30
|
+
setDraft(value);
|
|
31
|
+
}
|
|
32
|
+
}, [value, isSaving]);
|
|
33
|
+
const exitRenaming = useCallback(() => {
|
|
34
|
+
if (isRenaming) {
|
|
35
|
+
onEnterRenaming();
|
|
36
|
+
}
|
|
37
|
+
}, [isRenaming, onEnterRenaming]);
|
|
38
|
+
const persistRename = useCallback(async (trimmed) => {
|
|
39
|
+
setIsSaving(true);
|
|
40
|
+
setDraft(trimmed);
|
|
41
|
+
exitRenaming();
|
|
42
|
+
try {
|
|
43
|
+
await onChange(trimmed);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
setDraft(value);
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
setIsSaving(false);
|
|
50
|
+
}
|
|
51
|
+
}, [exitRenaming, onChange, value]);
|
|
52
|
+
const commit = useCallback(() => {
|
|
53
|
+
const trimmed = draft.trim();
|
|
54
|
+
if (trimmed && trimmed !== value) {
|
|
55
|
+
void persistRename(trimmed);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
exitRenaming();
|
|
59
|
+
setDraft(value);
|
|
60
|
+
}, [draft, exitRenaming, persistRename, value]);
|
|
61
|
+
const cancel = useCallback(() => {
|
|
62
|
+
exitRenaming();
|
|
63
|
+
setDraft(value);
|
|
64
|
+
}, [exitRenaming, value]);
|
|
65
|
+
const onKeyDown = useCallback((e) => {
|
|
66
|
+
stopRenamerKeyboardBubble(e);
|
|
67
|
+
if (e.key === 'Enter' && draft.trim()) {
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
const trimmed = draft.trim();
|
|
70
|
+
if (trimmed !== value) {
|
|
71
|
+
void persistRename(trimmed);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
exitRenaming();
|
|
75
|
+
setDraft(trimmed);
|
|
76
|
+
}
|
|
77
|
+
if (e.key === 'Escape') {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
cancel();
|
|
80
|
+
}
|
|
81
|
+
}, [cancel, draft, exitRenaming, persistRename, value]);
|
|
82
|
+
const onKeyUp = useCallback((e) => {
|
|
83
|
+
if (e.key !== ' ')
|
|
84
|
+
return;
|
|
85
|
+
e.preventDefault();
|
|
86
|
+
e.stopPropagation();
|
|
87
|
+
}, []);
|
|
88
|
+
const onDraftChange = useCallback((e) => {
|
|
89
|
+
setDraft(e.target.value.slice(0, MANUALLY_ADJUSTED_RENAME_MAX));
|
|
90
|
+
}, []);
|
|
91
|
+
if (isRenaming) {
|
|
92
|
+
return (jsx(Input, { className: cn(S.selectInlineRenamerInput, className), autoFocus: true, variant: "clean", size: "sm", value: draft, maxLength: MANUALLY_ADJUSTED_RENAME_MAX, onChange: onDraftChange, onBlur: commit, onKeyDown: onKeyDown, onKeyUp: onKeyUp, onPointerDown: stopSelectBubble, onClick: stopSelectBubble }));
|
|
93
|
+
}
|
|
94
|
+
const triggerLabel = isSaving ? draft : (displayLabel ?? value);
|
|
95
|
+
return (jsxs("div", { className: cn(S.selectInlineRenamer, className), children: [isSaving ? (jsx(TextShimmer, { as: "span", className: S.label, children: triggerLabel })) : (jsx("span", { className: S.label, children: triggerLabel })), !disabled && !isSaving && (jsxs(Tooltip, { children: [jsx(TooltipTrigger, { asChild: true, children: jsx(Button, { variant: "ghost", size: "sm", type: "button", className: S.renamerEditButton, onPointerDown: stopSelectOpen, onClick: e => {
|
|
96
|
+
e.stopPropagation();
|
|
97
|
+
setDraft(value);
|
|
98
|
+
onEnterRenaming();
|
|
99
|
+
}, children: jsx(PencilSimpleIcon, { size: 16 }) }) }), jsx(TooltipContent, { side: "bottom", children: "Rename" })] }))] }));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export { SelectInlineRenamer };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { Button } from '../Button/Button.js';
|
|
4
|
+
import { XIcon, InfoIcon } from 'lucide-react';
|
|
5
|
+
import S from './Banner.styl.js';
|
|
6
|
+
|
|
7
|
+
function Banner({ children, className, icon: Icon = InfoIcon, onClose, }) {
|
|
8
|
+
return (jsxs("div", { className: cn(S.root, className), "data-slot": "banner", children: [Icon !== false && jsx(Icon, { className: S.icon, size: 16 }), children, onClose && (jsx(Button, { variant: "ghost", icon: true, type: "button", onClick: onClose, className: S.closeButton, children: jsx(XIcon, { size: 16 }) }))] }));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { Banner };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import styleInject from 'style-inject';
|
|
2
|
+
|
|
3
|
+
var css_248z = ".Banner_root__zegJA{align-items:center;background-color:var(--card);border-radius:var(--p-2);display:flex;flex-wrap:wrap;margin-bottom:var(--p-10);margin-top:calc(var(--p-4)*-1);padding:var(--p-3) var(--p-4);width:-moz-fit-content;width:fit-content}.Banner_root__zegJA a{padding:0 var(--p-1)}.Banner_icon__q5xFu{display:inline-block;margin-right:var(--p-3)}.Banner_closeButton__cj0WU{margin-left:var(--p-1);opacity:.5;transition:opacity .2s ease}.Banner_closeButton__cj0WU:hover{opacity:1}";
|
|
4
|
+
var S = {"root":"Banner_root__zegJA","icon":"Banner_icon__q5xFu","closeButton":"Banner_closeButton__cj0WU"};
|
|
5
|
+
styleInject(css_248z);
|
|
6
|
+
|
|
7
|
+
export { S as default };
|
|
@@ -5,22 +5,26 @@ import 'classnames';
|
|
|
5
5
|
import 'react';
|
|
6
6
|
import './Chart.context.js';
|
|
7
7
|
import './Chart.styl.js';
|
|
8
|
-
import '@phosphor-icons/react';
|
|
9
|
-
import '@radix-ui/react-select';
|
|
10
|
-
import 'lucide-react';
|
|
11
|
-
import '../Select/Select.styl.js';
|
|
12
8
|
import '../AnalysisLineIcon/AnalysisLineIcon.styl.js';
|
|
13
9
|
import '@radix-ui/react-slot';
|
|
14
10
|
import '../Badge/Badge.styl.js';
|
|
15
11
|
import '../LabelWithId/LabelWithId.styl.js';
|
|
16
|
-
import '
|
|
12
|
+
import '@radix-ui/react-select';
|
|
13
|
+
import 'lucide-react';
|
|
14
|
+
import '../Select/Select.styl.js';
|
|
17
15
|
import '../TextShimmer/TextShimmer.js';
|
|
16
|
+
import '@phosphor-icons/react';
|
|
17
|
+
import '../AnalysesSelector/AnalysesSelector.styl.js';
|
|
18
|
+
import '../Button/Button.styl.js';
|
|
19
|
+
import '../Input/Input.js';
|
|
20
|
+
import '../Tooltip/Tooltip.js';
|
|
18
21
|
import './components/CustomChartLegend/CustomChartLegend.styl.js';
|
|
19
22
|
import '../ChartAreaInteractive/ChartLines.js';
|
|
20
23
|
import '../Skeleton/Skeleton.styl.js';
|
|
21
24
|
import 'lightweight-charts';
|
|
22
25
|
import './lightweight/LightweightForecastChart.styl.js';
|
|
23
26
|
import './components/ChartEmptyState/ChartEmptyState.styl.js';
|
|
27
|
+
export { DEFAULT_QUANTILE_BAND_COLOR, QuantileBands } from './components/QuantileBands.js';
|
|
24
28
|
|
|
25
29
|
const ChartTooltip = RechartsPrimitive.Tooltip;
|
|
26
30
|
const ChartLegend = RechartsPrimitive.Legend;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const FORECAST_COLORS = {
|
|
2
|
+
historical: {
|
|
3
|
+
light: '#000000',
|
|
4
|
+
dark: '#ffffff',
|
|
5
|
+
},
|
|
6
|
+
forecast: {
|
|
7
|
+
light: '#3a0087',
|
|
8
|
+
dark: '#8b5cf6',
|
|
9
|
+
},
|
|
10
|
+
confidence: {
|
|
11
|
+
light: 'rgba(58, 0, 135, 0.35)',
|
|
12
|
+
dark: 'rgba(139, 92, 246, 0.35)',
|
|
13
|
+
},
|
|
14
|
+
boundary: {
|
|
15
|
+
positive: '#77d400',
|
|
16
|
+
negative: '#fc512b',
|
|
17
|
+
neutral: '#ffae00',
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
const ANIMATION_DURATION = 800;
|
|
21
|
+
const ANIMATION_BEGIN = 0;
|
|
22
|
+
|
|
23
|
+
export { ANIMATION_BEGIN, ANIMATION_DURATION, FORECAST_COLORS };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Area } from 'recharts';
|
|
3
|
+
import { ANIMATION_DURATION, ANIMATION_BEGIN } from '../chartForecastVisualization.constants.js';
|
|
4
|
+
|
|
5
|
+
function ConfidenceBands({ color, hidden = false, animate = false, }) {
|
|
6
|
+
return (jsxs(Fragment, { children: [jsx(Area, { type: "monotone", dataKey: "lower_boundary", stroke: "transparent", fill: "transparent", isAnimationActive: animate, animationDuration: ANIMATION_DURATION, animationBegin: ANIMATION_BEGIN, connectNulls: true, hide: hidden }), jsx(Area, { type: "monotone", dataKey: "upper_boundary", stroke: "transparent", fill: color, fillOpacity: 0.35, isAnimationActive: animate, animationDuration: ANIMATION_DURATION, animationBegin: ANIMATION_BEGIN, connectNulls: true, hide: hidden })] }));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { ConfidenceBands };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import cn from 'classnames';
|
|
3
2
|
import { useMemo, useCallback } from 'react';
|
|
4
3
|
import { AnalysesSelector } from '../../../AnalysesSelector/AnalysesSelector.js';
|
|
5
4
|
import S from './CustomChartLegend.styl.js';
|
|
5
|
+
import cn from 'classnames';
|
|
6
6
|
|
|
7
7
|
function extractIdFromDataKey(dataKey) {
|
|
8
8
|
if (!dataKey)
|
|
@@ -58,7 +58,7 @@ function CustomChartLegend({ payload, onClick, hiddenSeries, className, onAnalys
|
|
|
58
58
|
}, [onClick, payload, hiddenSeries, onAnalysisSelect]);
|
|
59
59
|
if (!items.length)
|
|
60
60
|
return null;
|
|
61
|
-
return (jsx("div", { className: cn(S.legendContainer, className), children: jsx(AnalysesSelector, { items: items, selectedIds: selectedIds, onItemToggle: handleItemToggle, inlineMode: true, size: "
|
|
61
|
+
return (jsx("div", { className: cn(S.legendContainer, className), children: jsx(AnalysesSelector, { items: items, selectedIds: selectedIds, onItemToggle: handleItemToggle, inlineMode: true, size: "xs", variant: "clear", onFailedItemClick: onFailedAnalysisClick, enableToggleHidden: true, maxVisibleItems: maxVisibleItems, preventDeselection: preventDeselection, hiddenSeries: hiddenSeries ?? new Set(), onToggleSeries: handleToggleSeriesVisibility }) }));
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
export { CustomChartLegend };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { ReferenceLine } from 'recharts';
|
|
3
|
+
import { FORECAST_COLORS } from '../chartForecastVisualization.constants.js';
|
|
4
|
+
|
|
5
|
+
function ForecastBoundaries({ changePoints, chartData, isDarkTheme, }) {
|
|
6
|
+
const meanCPD = changePoints.MeanCPD.change_points[0];
|
|
7
|
+
const sensitivity = changePoints.MeanCPD.cpd_metrics.sensitivity_threshold;
|
|
8
|
+
if (!meanCPD)
|
|
9
|
+
return null;
|
|
10
|
+
const sign = meanCPD.sign;
|
|
11
|
+
const prevCoef = meanCPD.prev_coef[0];
|
|
12
|
+
// Calculate boundary values
|
|
13
|
+
const upperBoundary = prevCoef + sensitivity;
|
|
14
|
+
const lowerBoundary = prevCoef - sensitivity;
|
|
15
|
+
// Determine color based on trend sign
|
|
16
|
+
const boundaryColor = sign === 0
|
|
17
|
+
? FORECAST_COLORS.boundary.neutral
|
|
18
|
+
: sign > 0
|
|
19
|
+
? FORECAST_COLORS.boundary.positive
|
|
20
|
+
: FORECAST_COLORS.boundary.negative;
|
|
21
|
+
return (jsxs(Fragment, { children: [jsx(ReferenceLine, { y: upperBoundary, stroke: boundaryColor, strokeDasharray: "5 5", strokeWidth: 2, label: {
|
|
22
|
+
value: 'Upper Boundary',
|
|
23
|
+
position: 'insideTopRight',
|
|
24
|
+
fill: isDarkTheme ? '#9ca3af' : '#6b7280',
|
|
25
|
+
} }), sign <= 0 && (jsx(ReferenceLine, { y: lowerBoundary, stroke: boundaryColor, strokeDasharray: "5 5", strokeWidth: 2, label: {
|
|
26
|
+
value: 'Lower Boundary',
|
|
27
|
+
position: 'insideBottomRight',
|
|
28
|
+
fill: isDarkTheme ? '#9ca3af' : '#6b7280',
|
|
29
|
+
} }))] }));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { ForecastBoundaries };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Line } from 'recharts';
|
|
3
|
+
|
|
4
|
+
function ForecastLine({ color, isDarkTheme, hidden, animate, animationDuration, animationBegin, name = 'Forecast', dataKey = 'forecast', }) {
|
|
5
|
+
return (jsx(Line, { type: "monotone", dataKey: dataKey, stroke: color, strokeWidth: 1, strokeDasharray: "4 2", dot: props => {
|
|
6
|
+
const { index, payload } = props;
|
|
7
|
+
// Show dot only at the last forecast data point
|
|
8
|
+
if (payload &&
|
|
9
|
+
payload[dataKey] !== undefined &&
|
|
10
|
+
index === props.payload?.length - 1) {
|
|
11
|
+
return (jsx("circle", { cx: props.cx, cy: props.cy, r: 3, fill: color }, `forecast-dot-${index}`));
|
|
12
|
+
}
|
|
13
|
+
return jsx("g", {}, `forecast-dot-empty-${index}`);
|
|
14
|
+
}, activeDot: {
|
|
15
|
+
r: 6,
|
|
16
|
+
fill: color,
|
|
17
|
+
stroke: isDarkTheme ? '#000000' : '#FFFFFF',
|
|
18
|
+
strokeWidth: 3,
|
|
19
|
+
filter: 'drop-shadow(0px 2px 4px rgba(0, 0, 0, 0.2))',
|
|
20
|
+
style: { zIndex: 20 },
|
|
21
|
+
}, name: name, hide: hidden, isAnimationActive: animate, animationDuration: animationDuration, animationBegin: animationBegin, animationEasing: "ease-out", connectNulls: true }));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { ForecastLine };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Line } from 'recharts';
|
|
3
|
+
|
|
4
|
+
function HistoricalLine({ color, isDarkTheme, hidden, animate, animationDuration, animationBegin, name = 'Historical', dataKey = 'historical', }) {
|
|
5
|
+
return (jsx(Line, { type: "monotone", dataKey: dataKey, stroke: color, strokeWidth: 1, dot: props => {
|
|
6
|
+
const { index, payload } = props;
|
|
7
|
+
// Show dot only at the last historical data point
|
|
8
|
+
if (payload &&
|
|
9
|
+
payload[dataKey] !== undefined &&
|
|
10
|
+
index === props.payload?.length - 1) {
|
|
11
|
+
return (jsx("circle", { cx: props.cx, cy: props.cy, r: 3, fill: color }, `historical-dot-${index}`));
|
|
12
|
+
}
|
|
13
|
+
return jsx("g", {}, `historical-dot-empty-${index}`);
|
|
14
|
+
}, activeDot: {
|
|
15
|
+
r: 6,
|
|
16
|
+
fill: color,
|
|
17
|
+
stroke: isDarkTheme ? '#000000' : '#FFFFFF',
|
|
18
|
+
strokeWidth: 3,
|
|
19
|
+
filter: 'drop-shadow(0px 2px 4px rgba(0, 0, 0, 0.2))',
|
|
20
|
+
style: { zIndex: 20 },
|
|
21
|
+
}, name: name, hide: hidden, isAnimationActive: animate, animationDuration: animationDuration, animationBegin: animationBegin, animationEasing: "ease-out", connectNulls: true }));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { HistoricalLine };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hook to manage chart animation state
|
|
5
|
+
* Triggers animation on data change and resets after duration
|
|
6
|
+
*/
|
|
7
|
+
function useChartAnimation(chartData, duration = 1000) {
|
|
8
|
+
const [shouldAnimate, setShouldAnimate] = useState(false);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
setShouldAnimate(true);
|
|
11
|
+
const timer = setTimeout(() => setShouldAnimate(false), duration);
|
|
12
|
+
return () => clearTimeout(timer);
|
|
13
|
+
}, [chartData, duration]);
|
|
14
|
+
return shouldAnimate;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { useChartAnimation };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function useChartColors(colors, isDarkTheme) {
|
|
2
|
+
const result = {};
|
|
3
|
+
for (const key in colors) {
|
|
4
|
+
const colorScheme = colors[key];
|
|
5
|
+
if (colorScheme?.light && colorScheme?.dark) {
|
|
6
|
+
result[key] = isDarkTheme ? colorScheme.dark : colorScheme.light;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { useChartColors };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hook to manage chart legend state
|
|
5
|
+
* Handles showing/hiding series on legend click
|
|
6
|
+
*/
|
|
7
|
+
function useLegendState() {
|
|
8
|
+
const [hiddenSeries, setHiddenSeries] = useState(new Set());
|
|
9
|
+
const toggleSeries = (seriesName) => {
|
|
10
|
+
setHiddenSeries(prev => {
|
|
11
|
+
const newSet = new Set(prev);
|
|
12
|
+
if (newSet.has(seriesName)) {
|
|
13
|
+
newSet.delete(seriesName);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
newSet.add(seriesName);
|
|
17
|
+
}
|
|
18
|
+
return newSet;
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const clearHiddenSeries = () => {
|
|
22
|
+
setHiddenSeries(new Set());
|
|
23
|
+
};
|
|
24
|
+
const showOnlySeries = (dataKey, allDataKeys) => {
|
|
25
|
+
setHiddenSeries(new Set(allDataKeys.filter(key => key !== dataKey)));
|
|
26
|
+
};
|
|
27
|
+
return { hiddenSeries, toggleSeries, clearHiddenSeries, showOnlySeries };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { useLegendState };
|
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Format number for display (with k/m abbreviations)
|
|
2
|
+
* Format number for display (with k/m/b abbreviations)
|
|
3
3
|
*/
|
|
4
4
|
const formatNumber = (value) => {
|
|
5
|
+
if (Math.abs(value) >= 1000000000) {
|
|
6
|
+
return (value / 1000000000).toFixed(1).replace(/\.0$/, '') + 'B';
|
|
7
|
+
}
|
|
5
8
|
if (Math.abs(value) >= 1000000) {
|
|
6
9
|
return (value / 1000000).toFixed(1).replace(/\.0$/, '') + 'M';
|
|
7
10
|
}
|
|
8
|
-
|
|
11
|
+
if (Math.abs(value) >= 1000) {
|
|
9
12
|
return (value / 1000).toFixed(1).replace(/\.0$/, '') + 'K';
|
|
10
13
|
}
|
|
11
14
|
return value.toFixed(0);
|
|
12
15
|
};
|
|
16
|
+
/** Shorter Y-axis style labels (integer B/M/K) for tight layouts. */
|
|
17
|
+
const formatCompactAxisNumber = (value) => {
|
|
18
|
+
if (Math.abs(value) >= 1000000000) {
|
|
19
|
+
return `${Math.round(value / 1000000000)}B`;
|
|
20
|
+
}
|
|
21
|
+
if (Math.abs(value) >= 1000000) {
|
|
22
|
+
return `${Math.round(value / 1000000)}M`;
|
|
23
|
+
}
|
|
24
|
+
if (Math.abs(value) >= 1000) {
|
|
25
|
+
return `${Math.round(value / 1000)}K`;
|
|
26
|
+
}
|
|
27
|
+
return value.toFixed(0);
|
|
28
|
+
};
|
|
13
29
|
/**
|
|
14
30
|
* Round a number based on its magnitude
|
|
15
31
|
* - 2 digits (10-99): round to nearest 10
|
|
@@ -78,4 +94,4 @@ const formatDate = (dateStr, long = false) => {
|
|
|
78
94
|
});
|
|
79
95
|
};
|
|
80
96
|
|
|
81
|
-
export { formatDate, formatNumber, formatYAxisNumber, generateRoundedYTicks };
|
|
97
|
+
export { formatCompactAxisNumber, formatDate, formatNumber, formatYAxisNumber, generateRoundedYTicks };
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
// Helper function to format large numbers with k/m abbreviations
|
|
2
|
-
const formatNumber = (value) => {
|
|
3
|
-
if (value >= 1000000) {
|
|
4
|
-
return (value / 1000000).toFixed(1).replace(/\.0$/, '') + 'm';
|
|
5
|
-
}
|
|
6
|
-
else if (value >= 1000) {
|
|
7
|
-
return (value / 1000).toFixed(1).replace(/\.0$/, '') + 'k';
|
|
8
|
-
}
|
|
9
|
-
return value.toFixed(0);
|
|
10
|
-
};
|
|
11
2
|
// Find pin position for a specific date in the current filtered data
|
|
12
3
|
const findPinPositionForDate = (targetDate, filteredData) => {
|
|
13
4
|
if (!filteredData.length)
|
|
@@ -207,4 +198,4 @@ const isAnalysisFailed = (analysis) => {
|
|
|
207
198
|
const isAnalysisNotFailed = (analysis) => !isAnalysisFailed(analysis);
|
|
208
199
|
const isAnalysisDone = (analysis) => analysis.status?.toLowerCase() === 'done';
|
|
209
200
|
|
|
210
|
-
export { DRAG_TIME_RANGE_PREFIX, encodeDragTimeRange, filterDataForTimeRange, findPinPositionForDate,
|
|
201
|
+
export { DRAG_TIME_RANGE_PREFIX, encodeDragTimeRange, filterDataForTimeRange, findPinPositionForDate, isAnalysisDone, isAnalysisFailed, isAnalysisNotFailed, isTimeRangePreset, longDateFormatter, parseDragTimeRange, shortDateFormatter };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
4
4
|
import { ChevronDownIcon, ChevronUpIcon } from 'lucide-react';
|
|
@@ -13,8 +13,8 @@ function SelectGroup({ ...props }) {
|
|
|
13
13
|
function SelectValue({ ...props }) {
|
|
14
14
|
return jsx(SelectPrimitive.Value, { "data-slot": "select-value", ...props });
|
|
15
15
|
}
|
|
16
|
-
function SelectTrigger({ className, size = 'md', variant = 'default', darker = false, children, hideChevron = false, ...props }) {
|
|
17
|
-
return (
|
|
16
|
+
function SelectTrigger({ className, size = 'md', variant = 'default', darker = false, children, hideChevron = false, asChild = false, ...props }) {
|
|
17
|
+
return (jsx(SelectPrimitive.Trigger, { "data-slot": "select-trigger", "data-size": size, "data-variant": variant, className: cn(S.selectTrigger, darker && S.darker, className), asChild: asChild, ...props, children: asChild ? (children) : (jsxs(Fragment, { children: [children, !hideChevron && (jsx(SelectPrimitive.Icon, { asChild: true, children: jsx(ChevronDownIcon, { className: S.selectIcon }) }))] })) }));
|
|
18
18
|
}
|
|
19
19
|
function SelectContent({ className, children, position = 'popper', ...props }) {
|
|
20
20
|
return (jsx(SelectPrimitive.Portal, { children: jsxs(SelectPrimitive.Content, { "data-slot": "select-content", className: cn(S.selectContent, position === 'popper' && S.selectContentPopper, className), position: position, ...props, children: [jsx(SelectScrollUpButton, {}), jsx(SelectPrimitive.Viewport, { className: cn(S.selectViewport, position === 'popper' && S.selectViewportPopper, className), children: children }), jsx(SelectScrollDownButton, {})] }) }));
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import React__default, { useMemo } from 'react';
|
|
3
2
|
import { CoffeeIcon, TrendUpIcon, TrendDownIcon } from '@phosphor-icons/react';
|
|
3
|
+
import React__default, { useMemo } from 'react';
|
|
4
|
+
import { Tooltip, TooltipTrigger, TooltipContent } from '../../ui/Tooltip/Tooltip.js';
|
|
4
5
|
import { Badge } from '../../ui/Badge/Badge.js';
|
|
5
|
-
import {
|
|
6
|
+
import { DriverPerformanceChart } from './DriverPerformanceChart.js';
|
|
6
7
|
import { LabelWithId } from '../../ui/LabelWithId/LabelWithId.js';
|
|
8
|
+
import S from './DriverCard.styl.js';
|
|
7
9
|
import { Skeleton } from '../../ui/Skeleton/Skeleton.js';
|
|
8
|
-
import { Tooltip, TooltipTrigger, TooltipContent } from '../../ui/Tooltip/Tooltip.js';
|
|
9
10
|
import { getCategoryIcon } from '../DriverMap/driverCategoryIcon.js';
|
|
10
|
-
import
|
|
11
|
-
import { DriverPerformanceChart } from './DriverPerformanceChart.js';
|
|
11
|
+
import { Card, CardContent } from '../../ui/Card/Card.js';
|
|
12
12
|
|
|
13
13
|
function DriverCard({ selectedDriver, isLoading, inQueue = false, driverSelector, }) {
|
|
14
14
|
const importanceDisplay = useMemo(() => {
|
|
@@ -74,7 +74,7 @@ function DriverCard({ selectedDriver, isLoading, inQueue = false, driverSelector
|
|
|
74
74
|
return (jsx(Card, { className: S.root, children: jsx(CardContent, { centered: true, fullHeight: true, noScroll: true, children: jsxs("div", { className: S.queueMessage, children: [jsx(CoffeeIcon, { size: 24, weight: "regular" }), jsxs("div", { children: [jsx("p", { children: "Retrieving drivers data." }), jsx("p", { children: "This may take a while." })] })] }) }) }));
|
|
75
75
|
}
|
|
76
76
|
if (isLoading) {
|
|
77
|
-
return (jsx(Card, { className: S.root, children: jsx(CardContent, { noScroll: true, children: jsxs("div", { className: S.skeletonContainer, children: [jsx(Skeleton, { className: `${S.skeletonItem} ${S.hs} ${S.w75}` }), jsx(Skeleton, { className: `${S.skeletonItem} ${S.hm} ${S.w50}` }), jsx(Skeleton, { className: `${S.skeletonItem} ${S.hs} ${S.w33}` }), jsxs("div", { className: S.skeletonGroup, children: [jsx(Skeleton, { className: `${S.skeletonItem} ${S.hs} ${S.wFull}` }), jsx(Skeleton, { className: `${S.skeletonItem} ${S.hs} ${S.w75}` }), jsx(Skeleton, { className: `${S.skeletonItem} ${S.hs} ${S.w50}` })] }), jsx(Skeleton, { className: `${S.skeletonItem} ${S.hl} ${S.wFull}` }), jsxs("div", { className: S.skeletonGroup, children: [jsx(Skeleton, { className: `${S.skeletonItem} ${S.hs} ${S.wFull}` }), jsx(Skeleton, { className: `${S.skeletonItem} ${S.hs} ${S.w75}` })] })] }) }) }));
|
|
77
|
+
return (jsx(Card, { className: S.root, radiusSize: "xl", children: jsx(CardContent, { noScroll: true, children: jsxs("div", { className: S.skeletonContainer, children: [jsx(Skeleton, { className: `${S.skeletonItem} ${S.hs} ${S.w75}` }), jsx(Skeleton, { className: `${S.skeletonItem} ${S.hm} ${S.w50}` }), jsx(Skeleton, { className: `${S.skeletonItem} ${S.hs} ${S.w33}` }), jsxs("div", { className: S.skeletonGroup, children: [jsx(Skeleton, { className: `${S.skeletonItem} ${S.hs} ${S.wFull}` }), jsx(Skeleton, { className: `${S.skeletonItem} ${S.hs} ${S.w75}` }), jsx(Skeleton, { className: `${S.skeletonItem} ${S.hs} ${S.w50}` })] }), jsx(Skeleton, { className: `${S.skeletonItem} ${S.hl} ${S.wFull}` }), jsxs("div", { className: S.skeletonGroup, children: [jsx(Skeleton, { className: `${S.skeletonItem} ${S.hs} ${S.wFull}` }), jsx(Skeleton, { className: `${S.skeletonItem} ${S.hs} ${S.w75}` })] })] }) }) }));
|
|
78
78
|
}
|
|
79
79
|
if (!selectedDriver) {
|
|
80
80
|
return (jsx(Card, { className: S.root, children: jsx(CardContent, { centered: true, fullHeight: true, noScroll: true, children: jsx("span", { className: S.noDriverSelected, children: "No driver selected" }) }) }));
|