@wallarm-org/design-system 0.73.0 → 0.74.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Attribute/AttributeValue.js +1 -1
- package/dist/components/ButtonBase/classes.d.ts +1 -1
- package/dist/components/ButtonBase/classes.js +12 -1
- package/dist/components/InlineEdit/InlineEditControl.js +11 -4
- package/dist/components/InlineEdit/InlineEditInput.js +1 -1
- package/dist/components/InlineEdit/InlineEditNumber.js +1 -1
- package/dist/components/InlineEdit/InlineEditPreviewValue.js +1 -1
- package/dist/components/InlineEdit/InlineEditSelect.js +1 -0
- package/dist/components/InlineEdit/InlineEditTextarea.js +1 -1
- package/dist/components/InlineEdit/InlineEditTime.js +1 -1
- package/dist/components/InlineEdit/classes.js +3 -3
- package/dist/components/Input/classes.d.ts +1 -1
- package/dist/components/Input/classes.js +3 -2
- package/dist/components/InputGroup/InputGroup.d.ts +1 -1
- package/dist/components/InputGroup/InputGroup.js +2 -1
- package/dist/components/NumberInput/classes.d.ts +4 -4
- package/dist/components/NumberInput/classes.js +8 -4
- package/dist/components/Select/SelectButton.d.ts +1 -1
- package/dist/components/Select/SelectButton.js +2 -1
- package/dist/components/Select/SelectInput/SelectInput.d.ts +1 -1
- package/dist/components/Select/SelectInput/SelectInput.js +2 -1
- package/dist/components/Select/SelectInput/SelectInputItemRenderer.d.ts +2 -2
- package/dist/components/Select/SelectInput/SelectInputItemRenderer.js +2 -1
- package/dist/components/Select/SelectInput/SelectInputOverflowRenderer.d.ts +1 -1
- package/dist/components/SimpleCharts/HorizontalBarStack/HorizontalBarStack.d.ts +50 -0
- package/dist/components/SimpleCharts/{HorizontalBar/HorizontalBar.figma.js → HorizontalBarStack/HorizontalBarStack.figma.js} +16 -8
- package/dist/components/SimpleCharts/HorizontalBarStack/HorizontalBarStack.js +239 -0
- package/dist/components/SimpleCharts/HorizontalBarStack/HorizontalBarStackSkeleton.d.ts +14 -0
- package/dist/components/SimpleCharts/HorizontalBarStack/HorizontalBarStackSkeleton.js +56 -0
- package/dist/components/SimpleCharts/HorizontalBarStack/classes.d.ts +19 -0
- package/dist/components/SimpleCharts/HorizontalBarStack/classes.js +49 -0
- package/dist/components/SimpleCharts/{HorizontalBar → HorizontalBarStack}/constants.d.ts +2 -2
- package/dist/components/SimpleCharts/HorizontalBarStack/constants.js +16 -0
- package/dist/components/SimpleCharts/HorizontalBarStack/index.d.ts +2 -0
- package/dist/components/SimpleCharts/HorizontalBarStack/index.js +2 -0
- package/dist/components/SimpleCharts/{HorizontalBar → HorizontalBarStack}/lib/resolveSegments.d.ts +2 -2
- package/dist/components/SimpleCharts/{HorizontalBar → HorizontalBarStack}/lib/resolveSegments.js +2 -2
- package/dist/components/SimpleCharts/LineChart/LineChartHoverPopover.d.ts +4 -0
- package/dist/components/SimpleCharts/LineChart/LineChartHoverPopover.js +3 -7
- package/dist/components/SimpleCharts/LineChart/LineChartHoverPopoverDot.d.ts +7 -13
- package/dist/components/SimpleCharts/LineChart/LineChartHoverPopoverDot.js +3 -16
- package/dist/components/SimpleCharts/LineChart/LineChartHoverPopoverRow.d.ts +5 -1
- package/dist/components/SimpleCharts/LineChart/LineChartHoverPopoverRow.js +9 -28
- package/dist/components/SimpleCharts/LineChart/classes.d.ts +0 -6
- package/dist/components/SimpleCharts/LineChart/classes.js +1 -7
- package/dist/components/SimpleCharts/Metric/Metric.d.ts +14 -0
- package/dist/components/SimpleCharts/Metric/Metric.figma.d.ts +1 -0
- package/dist/components/SimpleCharts/Metric/Metric.figma.js +49 -0
- package/dist/components/SimpleCharts/Metric/Metric.js +17 -0
- package/dist/components/SimpleCharts/Metric/MetricCaption.d.ts +6 -0
- package/dist/components/SimpleCharts/Metric/MetricCaption.js +16 -0
- package/dist/components/SimpleCharts/Metric/MetricDelta.d.ts +10 -0
- package/dist/components/SimpleCharts/Metric/MetricDelta.js +12 -0
- package/dist/components/SimpleCharts/Metric/MetricHeader.d.ts +9 -0
- package/dist/components/SimpleCharts/Metric/MetricHeader.js +16 -0
- package/dist/components/SimpleCharts/Metric/MetricSkeleton.d.ts +12 -0
- package/dist/components/SimpleCharts/Metric/MetricSkeleton.js +31 -0
- package/dist/components/SimpleCharts/Metric/MetricTotal.d.ts +12 -0
- package/dist/components/SimpleCharts/Metric/MetricTotal.js +36 -0
- package/dist/components/SimpleCharts/Metric/MetricValue.d.ts +9 -0
- package/dist/components/SimpleCharts/Metric/MetricValue.js +18 -0
- package/dist/components/SimpleCharts/Metric/classes.d.ts +8 -0
- package/dist/components/SimpleCharts/Metric/classes.js +9 -0
- package/dist/components/SimpleCharts/Metric/index.d.ts +7 -0
- package/dist/components/SimpleCharts/Metric/index.js +7 -0
- package/dist/components/SimpleCharts/index.d.ts +2 -1
- package/dist/components/SimpleCharts/index.js +2 -1
- package/dist/components/SimpleCharts/internal/ChartDelta.d.ts +22 -0
- package/dist/components/SimpleCharts/internal/ChartDelta.js +31 -0
- package/dist/components/SimpleCharts/internal/ChartHoverCard.d.ts +26 -0
- package/dist/components/SimpleCharts/internal/ChartHoverCard.js +57 -0
- package/dist/components/SimpleCharts/internal/index.d.ts +2 -0
- package/dist/components/SimpleCharts/internal/index.js +2 -0
- package/dist/components/Slider/Slider.d.ts +1 -1
- package/dist/components/Slider/classes.d.ts +2 -3
- package/dist/components/TemporalCore/props.d.ts +1 -1
- package/dist/components/Textarea/classes.d.ts +2 -2
- package/dist/components/Textarea/classes.js +4 -2
- package/dist/components/Textarea/useAutoResize.d.ts +1 -0
- package/dist/components/Textarea/useAutoResize.js +5 -4
- package/dist/metadata/components.json +2425 -465
- package/package.json +1 -1
- package/dist/components/SimpleCharts/HorizontalBar/HorizontalBar.d.ts +0 -30
- package/dist/components/SimpleCharts/HorizontalBar/HorizontalBar.js +0 -132
- package/dist/components/SimpleCharts/HorizontalBar/classes.d.ts +0 -11
- package/dist/components/SimpleCharts/HorizontalBar/classes.js +0 -12
- package/dist/components/SimpleCharts/HorizontalBar/constants.js +0 -16
- package/dist/components/SimpleCharts/HorizontalBar/index.d.ts +0 -1
- package/dist/components/SimpleCharts/HorizontalBar/index.js +0 -1
- /package/dist/components/SimpleCharts/{HorizontalBar/HorizontalBar.figma.d.ts → HorizontalBarStack/HorizontalBarStack.figma.d.ts} +0 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useMemo } from "react";
|
|
3
|
+
import { useControlled } from "../../../hooks/index.js";
|
|
4
|
+
import { cn } from "../../../utils/cn.js";
|
|
5
|
+
import { TestIdProvider } from "../../../utils/testId.js";
|
|
6
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "../../Tooltip/index.js";
|
|
7
|
+
import { ChartHoverCard, ChartHoverCardRow } from "../internal/ChartHoverCard.js";
|
|
8
|
+
import { resolveChartColor } from "../lib/chartPalette.js";
|
|
9
|
+
import { makeIsHoverSyncTarget } from "../lib/hoverSync.js";
|
|
10
|
+
import { horizontalBarStackBarClasses, horizontalBarStackBarWrapperClasses, horizontalBarStackHeaderClasses, horizontalBarStackLegendClasses, horizontalBarStackLegendDotClasses, horizontalBarStackLegendItemVariants, horizontalBarStackLegendLabelClasses, horizontalBarStackRemainderClasses, horizontalBarStackRootClasses, horizontalBarStackSegmentVariants, horizontalBarStackTooltipClasses } from "./classes.js";
|
|
11
|
+
import { resolveSegments } from "./lib/resolveSegments.js";
|
|
12
|
+
const isHoverSyncTarget = makeIsHoverSyncTarget([
|
|
13
|
+
'horizontal-bar-stack-segment',
|
|
14
|
+
'horizontal-bar-stack-legend-item'
|
|
15
|
+
]);
|
|
16
|
+
const EMPTY_SELECTION = new Set();
|
|
17
|
+
const formatNumber = (n)=>n.toLocaleString('en-US');
|
|
18
|
+
const HorizontalBarStack = ({ data, children, total, legend = true, activeName: controlledActiveName, onActiveNameChange, selectedNames, onSelect, className, ref, 'data-testid': testId, ...props })=>{
|
|
19
|
+
const segments = useMemo(()=>resolveSegments(data, total), [
|
|
20
|
+
data,
|
|
21
|
+
total
|
|
22
|
+
]);
|
|
23
|
+
const slotTestId = (slot)=>testId ? `${testId}--${slot}` : void 0;
|
|
24
|
+
const legendSegments = useMemo(()=>segments.filter((s)=>!s.isRemainder), [
|
|
25
|
+
segments
|
|
26
|
+
]);
|
|
27
|
+
const byName = useMemo(()=>{
|
|
28
|
+
const set = new Set();
|
|
29
|
+
for (const d of data)set.add(d.name);
|
|
30
|
+
return set;
|
|
31
|
+
}, [
|
|
32
|
+
data
|
|
33
|
+
]);
|
|
34
|
+
const [activeNameValue, setInternalActiveName] = useControlled({
|
|
35
|
+
controlled: controlledActiveName,
|
|
36
|
+
default: null
|
|
37
|
+
});
|
|
38
|
+
const rawActiveName = activeNameValue ?? null;
|
|
39
|
+
const activeName = null !== rawActiveName && byName.has(rawActiveName) ? rawActiveName : null;
|
|
40
|
+
const setActive = useCallback((name)=>{
|
|
41
|
+
setInternalActiveName(name);
|
|
42
|
+
onActiveNameChange?.(name);
|
|
43
|
+
}, [
|
|
44
|
+
setInternalActiveName,
|
|
45
|
+
onActiveNameChange
|
|
46
|
+
]);
|
|
47
|
+
useEffect(()=>{
|
|
48
|
+
if (null != controlledActiveName && !byName.has(controlledActiveName)) onActiveNameChange?.(null);
|
|
49
|
+
}, [
|
|
50
|
+
controlledActiveName,
|
|
51
|
+
byName,
|
|
52
|
+
onActiveNameChange
|
|
53
|
+
]);
|
|
54
|
+
const selectedSet = useMemo(()=>{
|
|
55
|
+
if (!selectedNames?.length) return EMPTY_SELECTION;
|
|
56
|
+
const set = new Set();
|
|
57
|
+
for (const name of selectedNames)if (byName.has(name)) set.add(name);
|
|
58
|
+
return set.size > 0 ? set : EMPTY_SELECTION;
|
|
59
|
+
}, [
|
|
60
|
+
selectedNames,
|
|
61
|
+
byName
|
|
62
|
+
]);
|
|
63
|
+
const interactive = 'function' == typeof onSelect;
|
|
64
|
+
const barAriaLabel = useMemo(()=>legend ? void 0 : legendSegments.length ? legendSegments.map((s)=>`${s.key} ${formatNumber(s.value)}`).join(', ') : void 0, [
|
|
65
|
+
legend,
|
|
66
|
+
legendSegments
|
|
67
|
+
]);
|
|
68
|
+
const hasDuplicateNames = useMemo(()=>{
|
|
69
|
+
const seen = new Set();
|
|
70
|
+
for (const d of data){
|
|
71
|
+
if (seen.has(d.name)) return true;
|
|
72
|
+
seen.add(d.name);
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
}, [
|
|
76
|
+
data
|
|
77
|
+
]);
|
|
78
|
+
useEffect(()=>{
|
|
79
|
+
if (hasDuplicateNames && 'production' !== process.env.NODE_ENV) console.warn("[HorizontalBarStack] `data` contains duplicate `name` values. Names are used as the React key and the `data-name` hook — duplicates cause key collisions and ambiguous selectors. Provide unique names.");
|
|
80
|
+
}, [
|
|
81
|
+
hasDuplicateNames
|
|
82
|
+
]);
|
|
83
|
+
const hasBar = data.length > 0;
|
|
84
|
+
const isDimmed = (key)=>null !== activeName ? key !== activeName : selectedSet.size > 0 ? !selectedSet.has(key) : false;
|
|
85
|
+
const handleMouseLeave = useCallback((event)=>{
|
|
86
|
+
if (isHoverSyncTarget(event.relatedTarget)) return;
|
|
87
|
+
setActive(null);
|
|
88
|
+
}, [
|
|
89
|
+
setActive
|
|
90
|
+
]);
|
|
91
|
+
const handleBlur = useCallback((event)=>{
|
|
92
|
+
if (isHoverSyncTarget(event.relatedTarget)) return;
|
|
93
|
+
setActive(null);
|
|
94
|
+
}, [
|
|
95
|
+
setActive
|
|
96
|
+
]);
|
|
97
|
+
const handleKeyDown = useCallback((name)=>(event)=>{
|
|
98
|
+
if ('Enter' === event.key || ' ' === event.key) {
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
onSelect?.(name);
|
|
101
|
+
}
|
|
102
|
+
}, [
|
|
103
|
+
onSelect
|
|
104
|
+
]);
|
|
105
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
106
|
+
...props,
|
|
107
|
+
ref: ref,
|
|
108
|
+
"data-slot": "horizontal-bar-stack",
|
|
109
|
+
"data-testid": testId,
|
|
110
|
+
className: cn(horizontalBarStackRootClasses, className),
|
|
111
|
+
children: [
|
|
112
|
+
children && /*#__PURE__*/ jsx(TestIdProvider, {
|
|
113
|
+
value: testId,
|
|
114
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
115
|
+
"data-slot": "horizontal-bar-stack-header",
|
|
116
|
+
className: horizontalBarStackHeaderClasses,
|
|
117
|
+
children: children
|
|
118
|
+
})
|
|
119
|
+
}),
|
|
120
|
+
hasBar && /*#__PURE__*/ jsx("div", {
|
|
121
|
+
"data-slot": "horizontal-bar-stack-bar-wrapper",
|
|
122
|
+
className: horizontalBarStackBarWrapperClasses,
|
|
123
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
124
|
+
"data-slot": "horizontal-bar-stack-bar",
|
|
125
|
+
"data-testid": slotTestId('bar'),
|
|
126
|
+
"aria-hidden": legend ? 'true' : void 0,
|
|
127
|
+
role: barAriaLabel ? 'img' : void 0,
|
|
128
|
+
"aria-label": barAriaLabel,
|
|
129
|
+
className: horizontalBarStackBarClasses,
|
|
130
|
+
children: segments.map((seg)=>{
|
|
131
|
+
const seriesSegment = !seg.isRemainder;
|
|
132
|
+
const segment = /*#__PURE__*/ jsx("div", {
|
|
133
|
+
"data-slot": "horizontal-bar-stack-segment",
|
|
134
|
+
"data-testid": slotTestId('segment'),
|
|
135
|
+
"data-name": seg.isRemainder ? void 0 : seg.key,
|
|
136
|
+
"data-remainder": seg.isRemainder ? 'true' : void 0,
|
|
137
|
+
"data-active": seriesSegment && activeName === seg.key ? 'true' : void 0,
|
|
138
|
+
onMouseEnter: seriesSegment ? ()=>setActive(seg.key) : void 0,
|
|
139
|
+
onMouseLeave: seriesSegment ? handleMouseLeave : void 0,
|
|
140
|
+
className: cn(horizontalBarStackSegmentVariants({
|
|
141
|
+
dimmed: isDimmed(seg.key)
|
|
142
|
+
}), seg.isRemainder && horizontalBarStackRemainderClasses, seg.className),
|
|
143
|
+
style: {
|
|
144
|
+
flexGrow: seg.value,
|
|
145
|
+
flexBasis: 0,
|
|
146
|
+
backgroundColor: seg.isRemainder || seg.className ? void 0 : resolveChartColor(seg.color)
|
|
147
|
+
}
|
|
148
|
+
}, seg.key);
|
|
149
|
+
if (!seriesSegment) return segment;
|
|
150
|
+
return /*#__PURE__*/ jsxs(Tooltip, {
|
|
151
|
+
openDelay: 150,
|
|
152
|
+
closeDelay: 100,
|
|
153
|
+
children: [
|
|
154
|
+
/*#__PURE__*/ jsx(TooltipTrigger, {
|
|
155
|
+
asChild: true,
|
|
156
|
+
children: segment
|
|
157
|
+
}),
|
|
158
|
+
/*#__PURE__*/ jsx(TooltipContent, {
|
|
159
|
+
className: horizontalBarStackTooltipClasses,
|
|
160
|
+
children: /*#__PURE__*/ jsx(ChartHoverCard, {
|
|
161
|
+
children: /*#__PURE__*/ jsx(ChartHoverCardRow, {
|
|
162
|
+
color: seg.className ? void 0 : seg.color,
|
|
163
|
+
dotClassName: seg.className,
|
|
164
|
+
label: seg.key,
|
|
165
|
+
value: seg.value
|
|
166
|
+
})
|
|
167
|
+
})
|
|
168
|
+
})
|
|
169
|
+
]
|
|
170
|
+
}, seg.key);
|
|
171
|
+
})
|
|
172
|
+
})
|
|
173
|
+
}),
|
|
174
|
+
legend && legendSegments.length > 0 && /*#__PURE__*/ jsx("div", {
|
|
175
|
+
"data-slot": "horizontal-bar-stack-legend",
|
|
176
|
+
"data-testid": slotTestId('legend'),
|
|
177
|
+
className: horizontalBarStackLegendClasses,
|
|
178
|
+
children: legendSegments.map((seg)=>{
|
|
179
|
+
const active = activeName === seg.key;
|
|
180
|
+
const selected = selectedSet.has(seg.key);
|
|
181
|
+
const dimmed = !selected && !active && selectedSet.size > 0;
|
|
182
|
+
const item = /*#__PURE__*/ jsxs("div", {
|
|
183
|
+
"data-slot": "horizontal-bar-stack-legend-item",
|
|
184
|
+
"data-testid": slotTestId('legend-item'),
|
|
185
|
+
"data-name": seg.key,
|
|
186
|
+
"data-active": active ? 'true' : void 0,
|
|
187
|
+
"data-selected": selected ? 'true' : void 0,
|
|
188
|
+
role: interactive ? 'button' : void 0,
|
|
189
|
+
tabIndex: interactive ? 0 : void 0,
|
|
190
|
+
"aria-current": selected ? 'true' : void 0,
|
|
191
|
+
onClick: interactive ? ()=>onSelect?.(seg.key) : void 0,
|
|
192
|
+
onKeyDown: interactive ? handleKeyDown(seg.key) : void 0,
|
|
193
|
+
onMouseEnter: ()=>setActive(seg.key),
|
|
194
|
+
onMouseLeave: handleMouseLeave,
|
|
195
|
+
onFocus: ()=>setActive(seg.key),
|
|
196
|
+
onBlur: handleBlur,
|
|
197
|
+
className: horizontalBarStackLegendItemVariants({
|
|
198
|
+
interactive,
|
|
199
|
+
active,
|
|
200
|
+
selected,
|
|
201
|
+
dimmed
|
|
202
|
+
}),
|
|
203
|
+
children: [
|
|
204
|
+
/*#__PURE__*/ jsx("span", {
|
|
205
|
+
"data-slot": "horizontal-bar-stack-legend-dot",
|
|
206
|
+
"data-testid": slotTestId('legend-dot'),
|
|
207
|
+
"aria-hidden": "true",
|
|
208
|
+
className: cn(horizontalBarStackLegendDotClasses, seg.className),
|
|
209
|
+
style: {
|
|
210
|
+
backgroundColor: seg.className ? void 0 : resolveChartColor(seg.color)
|
|
211
|
+
}
|
|
212
|
+
}),
|
|
213
|
+
/*#__PURE__*/ jsx("span", {
|
|
214
|
+
className: horizontalBarStackLegendLabelClasses,
|
|
215
|
+
children: seg.key
|
|
216
|
+
})
|
|
217
|
+
]
|
|
218
|
+
}, seg.key);
|
|
219
|
+
if (!interactive) return item;
|
|
220
|
+
return /*#__PURE__*/ jsxs(Tooltip, {
|
|
221
|
+
openDelay: 150,
|
|
222
|
+
closeDelay: 100,
|
|
223
|
+
children: [
|
|
224
|
+
/*#__PURE__*/ jsx(TooltipTrigger, {
|
|
225
|
+
asChild: true,
|
|
226
|
+
children: item
|
|
227
|
+
}),
|
|
228
|
+
/*#__PURE__*/ jsx(TooltipContent, {
|
|
229
|
+
children: selected ? 'Remove filter' : 'Click to filter'
|
|
230
|
+
})
|
|
231
|
+
]
|
|
232
|
+
}, seg.key);
|
|
233
|
+
})
|
|
234
|
+
})
|
|
235
|
+
]
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
HorizontalBarStack.displayName = 'HorizontalBarStack';
|
|
239
|
+
export { HorizontalBarStack };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FC, HTMLAttributes, Ref } from 'react';
|
|
2
|
+
import { type TestableProps } from '../../../utils/testId';
|
|
3
|
+
export interface HorizontalBarStackSkeletonProps extends HTMLAttributes<HTMLDivElement>, TestableProps {
|
|
4
|
+
ref?: Ref<HTMLDivElement>;
|
|
5
|
+
/** Number of legend placeholder pills. Defaults to `3`. */
|
|
6
|
+
legendItems?: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Loading placeholder for `HorizontalBarStack`, matching `BarListSkeleton` /
|
|
10
|
+
* `PieChartSkeleton`. Mirrors the loaded layout — a value-sized block where the
|
|
11
|
+
* header sits, the 8px bar track, and legend pills — so the card doesn't jump
|
|
12
|
+
* when data arrives. Compose inside the `Chart` card in place of the chart.
|
|
13
|
+
*/
|
|
14
|
+
export declare const HorizontalBarStackSkeleton: FC<HorizontalBarStackSkeletonProps>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../../utils/cn.js";
|
|
3
|
+
import { TestIdProvider, useTestId } from "../../../utils/testId.js";
|
|
4
|
+
import { Skeleton } from "../../Skeleton/index.js";
|
|
5
|
+
import { horizontalBarStackBarWrapperClasses, horizontalBarStackLegendClasses, horizontalBarStackRootClasses, horizontalBarStackSkeletonHeaderClasses } from "./classes.js";
|
|
6
|
+
const HorizontalBarStackSkeletonLegendItem = ()=>{
|
|
7
|
+
const testId = useTestId('skeleton-legend-item');
|
|
8
|
+
return /*#__PURE__*/ jsx("div", {
|
|
9
|
+
"data-slot": "horizontal-bar-stack-skeleton-legend-item",
|
|
10
|
+
"data-testid": testId,
|
|
11
|
+
children: /*#__PURE__*/ jsx(Skeleton, {
|
|
12
|
+
width: "72px",
|
|
13
|
+
height: "20px",
|
|
14
|
+
rounded: 6
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
HorizontalBarStackSkeletonLegendItem.displayName = 'HorizontalBarStackSkeletonLegendItem';
|
|
19
|
+
const HorizontalBarStackSkeleton = ({ legendItems = 3, className, ref, 'data-testid': testId, ...props })=>/*#__PURE__*/ jsx(TestIdProvider, {
|
|
20
|
+
value: testId,
|
|
21
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
22
|
+
...props,
|
|
23
|
+
ref: ref,
|
|
24
|
+
"data-slot": "horizontal-bar-stack-skeleton",
|
|
25
|
+
"data-testid": testId,
|
|
26
|
+
"aria-busy": "true",
|
|
27
|
+
"aria-live": "polite",
|
|
28
|
+
className: cn(horizontalBarStackRootClasses, className),
|
|
29
|
+
children: [
|
|
30
|
+
/*#__PURE__*/ jsx("div", {
|
|
31
|
+
className: horizontalBarStackSkeletonHeaderClasses,
|
|
32
|
+
children: /*#__PURE__*/ jsx(Skeleton, {
|
|
33
|
+
width: "72px",
|
|
34
|
+
height: "36px",
|
|
35
|
+
rounded: 6
|
|
36
|
+
})
|
|
37
|
+
}),
|
|
38
|
+
/*#__PURE__*/ jsx("div", {
|
|
39
|
+
className: horizontalBarStackBarWrapperClasses,
|
|
40
|
+
children: /*#__PURE__*/ jsx(Skeleton, {
|
|
41
|
+
width: "100%",
|
|
42
|
+
height: "8px",
|
|
43
|
+
rounded: 6
|
|
44
|
+
})
|
|
45
|
+
}),
|
|
46
|
+
/*#__PURE__*/ jsx("div", {
|
|
47
|
+
className: horizontalBarStackLegendClasses,
|
|
48
|
+
children: Array.from({
|
|
49
|
+
length: legendItems
|
|
50
|
+
}, (_, i)=>/*#__PURE__*/ jsx(HorizontalBarStackSkeletonLegendItem, {}, i))
|
|
51
|
+
})
|
|
52
|
+
]
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
HorizontalBarStackSkeleton.displayName = 'HorizontalBarStackSkeleton';
|
|
56
|
+
export { HorizontalBarStackSkeleton };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const horizontalBarStackRootClasses: string;
|
|
2
|
+
export declare const horizontalBarStackBarWrapperClasses: string;
|
|
3
|
+
export declare const horizontalBarStackBarClasses: string;
|
|
4
|
+
export declare const horizontalBarStackRemainderClasses: string;
|
|
5
|
+
export declare const horizontalBarStackHeaderClasses: string;
|
|
6
|
+
export declare const horizontalBarStackSkeletonHeaderClasses: string;
|
|
7
|
+
export declare const horizontalBarStackLegendClasses: string;
|
|
8
|
+
export declare const horizontalBarStackLegendDotClasses: string;
|
|
9
|
+
export declare const horizontalBarStackLegendLabelClasses: string;
|
|
10
|
+
export declare const horizontalBarStackSegmentVariants: (props?: ({
|
|
11
|
+
dimmed?: boolean | null | undefined;
|
|
12
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
13
|
+
export declare const horizontalBarStackLegendItemVariants: (props?: ({
|
|
14
|
+
interactive?: boolean | null | undefined;
|
|
15
|
+
active?: boolean | null | undefined;
|
|
16
|
+
selected?: boolean | null | undefined;
|
|
17
|
+
dimmed?: boolean | null | undefined;
|
|
18
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
19
|
+
export declare const horizontalBarStackTooltipClasses: string;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
const horizontalBarStackRootClasses = "flex flex-col w-full";
|
|
3
|
+
const horizontalBarStackBarWrapperClasses = "px-16 py-8 w-full";
|
|
4
|
+
const horizontalBarStackBarClasses = "flex h-8 w-full overflow-hidden rounded-4";
|
|
5
|
+
const horizontalBarStackRemainderClasses = "bg-bg-strong-primary";
|
|
6
|
+
const horizontalBarStackHeaderClasses = "px-16 pt-8";
|
|
7
|
+
const horizontalBarStackSkeletonHeaderClasses = horizontalBarStackHeaderClasses;
|
|
8
|
+
const horizontalBarStackLegendClasses = "flex flex-row flex-wrap items-center gap-6 px-12 py-2";
|
|
9
|
+
const horizontalBarStackLegendDotClasses = "inline-block size-8 rounded-2 shrink-0";
|
|
10
|
+
const horizontalBarStackLegendLabelClasses = "text-xs font-mono text-text-primary";
|
|
11
|
+
const horizontalBarStackSegmentVariants = cva('h-full min-w-px transition-opacity', {
|
|
12
|
+
variants: {
|
|
13
|
+
dimmed: {
|
|
14
|
+
true: 'opacity-30',
|
|
15
|
+
false: 'opacity-100'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: {
|
|
19
|
+
dimmed: false
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const horizontalBarStackLegendItemVariants = cva("inline-flex items-center gap-4 px-4 py-2 rounded-4 transition-colors outline-none", {
|
|
23
|
+
variants: {
|
|
24
|
+
interactive: {
|
|
25
|
+
true: "cursor-pointer focus-visible:bg-states-primary-hover focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus-primary",
|
|
26
|
+
false: ''
|
|
27
|
+
},
|
|
28
|
+
active: {
|
|
29
|
+
true: 'bg-states-primary-hover',
|
|
30
|
+
false: 'hover:bg-states-primary-hover'
|
|
31
|
+
},
|
|
32
|
+
selected: {
|
|
33
|
+
true: 'bg-states-primary-active',
|
|
34
|
+
false: ''
|
|
35
|
+
},
|
|
36
|
+
dimmed: {
|
|
37
|
+
true: 'opacity-60',
|
|
38
|
+
false: ''
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
defaultVariants: {
|
|
42
|
+
interactive: false,
|
|
43
|
+
active: false,
|
|
44
|
+
selected: false,
|
|
45
|
+
dimmed: false
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const horizontalBarStackTooltipClasses = "bg-transparent p-0 shadow-none rounded-none overflow-visible";
|
|
49
|
+
export { horizontalBarStackBarClasses, horizontalBarStackBarWrapperClasses, horizontalBarStackHeaderClasses, horizontalBarStackLegendClasses, horizontalBarStackLegendDotClasses, horizontalBarStackLegendItemVariants, horizontalBarStackLegendLabelClasses, horizontalBarStackRemainderClasses, horizontalBarStackRootClasses, horizontalBarStackSegmentVariants, horizontalBarStackSkeletonHeaderClasses, horizontalBarStackTooltipClasses };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ChartColor } from '../types';
|
|
2
2
|
/** Reserved key for the auto-generated remainder tail (must not collide with a datum name). */
|
|
3
|
-
export declare const REMAINDER_KEY = "__horizontal-bar-remainder__";
|
|
3
|
+
export declare const REMAINDER_KEY = "__horizontal-bar-stack-remainder__";
|
|
4
4
|
/**
|
|
5
5
|
* Auto-cycle order for data without an explicit `color`. Leads with the
|
|
6
6
|
* warm hues used in the Figma reference (red → brand/w-orange → amber).
|
|
7
7
|
*/
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const HORIZONTAL_BAR_STACK_PALETTE: ChartColor[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const REMAINDER_KEY = '__horizontal-bar-stack-remainder__';
|
|
2
|
+
const HORIZONTAL_BAR_STACK_PALETTE = [
|
|
3
|
+
'red',
|
|
4
|
+
'brand',
|
|
5
|
+
'amber',
|
|
6
|
+
'blue',
|
|
7
|
+
'green',
|
|
8
|
+
'purple',
|
|
9
|
+
'teal',
|
|
10
|
+
'cyan',
|
|
11
|
+
'indigo',
|
|
12
|
+
'pink',
|
|
13
|
+
'rose',
|
|
14
|
+
'slate'
|
|
15
|
+
];
|
|
16
|
+
export { HORIZONTAL_BAR_STACK_PALETTE, REMAINDER_KEY };
|
package/dist/components/SimpleCharts/{HorizontalBar → HorizontalBarStack}/lib/resolveSegments.d.ts
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ChartColor } from '../../types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { HorizontalBarStackDatum } from '../HorizontalBarStack';
|
|
3
3
|
export interface ResolvedSegment {
|
|
4
4
|
key: string;
|
|
5
5
|
value: number;
|
|
@@ -7,4 +7,4 @@ export interface ResolvedSegment {
|
|
|
7
7
|
className?: string;
|
|
8
8
|
isRemainder: boolean;
|
|
9
9
|
}
|
|
10
|
-
export declare function resolveSegments(data:
|
|
10
|
+
export declare function resolveSegments(data: HorizontalBarStackDatum[], total?: number): ResolvedSegment[];
|
package/dist/components/SimpleCharts/{HorizontalBar → HorizontalBarStack}/lib/resolveSegments.js
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HORIZONTAL_BAR_STACK_PALETTE, REMAINDER_KEY } from "../constants.js";
|
|
2
2
|
const sanitize = (n)=>'number' == typeof n && Number.isFinite(n) && n > 0 ? n : 0;
|
|
3
3
|
function resolveSegments(data, total) {
|
|
4
4
|
const segments = data.map((d, i)=>({
|
|
5
5
|
key: d.name,
|
|
6
6
|
value: sanitize(d.value),
|
|
7
|
-
color: d.color ??
|
|
7
|
+
color: d.color ?? HORIZONTAL_BAR_STACK_PALETTE[i % HORIZONTAL_BAR_STACK_PALETTE.length],
|
|
8
8
|
className: d.className,
|
|
9
9
|
isRemainder: false
|
|
10
10
|
}));
|
|
@@ -2,4 +2,8 @@ import type { FC, HTMLAttributes, Ref } from 'react';
|
|
|
2
2
|
export interface LineChartHoverPopoverProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
3
|
ref?: Ref<HTMLDivElement>;
|
|
4
4
|
}
|
|
5
|
+
/**
|
|
6
|
+
* The line chart's hover popover — the shared `ChartHoverCard` surface with tooltip
|
|
7
|
+
* semantics (`role='tooltip'` + `aria-live`), positioned by the plotting-library tooltip.
|
|
8
|
+
*/
|
|
5
9
|
export declare const LineChartHoverPopover: FC<LineChartHoverPopoverProps>;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const LineChartHoverPopover = ({ ref, className, children, ...props })=>/*#__PURE__*/ jsx("div", {
|
|
5
|
-
...props,
|
|
2
|
+
import { ChartHoverCard } from "../internal/ChartHoverCard.js";
|
|
3
|
+
const LineChartHoverPopover = ({ ref, ...props })=>/*#__PURE__*/ jsx(ChartHoverCard, {
|
|
6
4
|
ref: ref,
|
|
7
|
-
"data-slot": "line-chart-hover-popover",
|
|
8
5
|
role: "tooltip",
|
|
9
6
|
"aria-live": "polite",
|
|
10
|
-
|
|
11
|
-
children: children
|
|
7
|
+
...props
|
|
12
8
|
});
|
|
13
9
|
LineChartHoverPopover.displayName = 'LineChartHoverPopover';
|
|
14
10
|
export { LineChartHoverPopover };
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import type { FC
|
|
2
|
-
import type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* Same shape as `LineChartSeries.color`, so passing `color={series.color}`
|
|
9
|
-
* keeps the dot in sync with its line. Consumer-supplied
|
|
10
|
-
* `style.backgroundColor` still wins when present.
|
|
11
|
-
*/
|
|
12
|
-
color?: ChartColor | (string & {});
|
|
13
|
-
}
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import { type ChartHoverCardDotProps } from '../internal/ChartHoverCard';
|
|
3
|
+
/**
|
|
4
|
+
* The hover popover's series dot — the shared `ChartHoverCardDot`. `color` accepts a palette
|
|
5
|
+
* token or any CSS colour, so `color={series.color}` keeps the dot in sync with its line.
|
|
6
|
+
*/
|
|
7
|
+
export type LineChartHoverPopoverDotProps = ChartHoverCardDotProps;
|
|
14
8
|
export declare const LineChartHoverPopoverDot: FC<LineChartHoverPopoverDotProps>;
|
|
@@ -1,20 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const LineChartHoverPopoverDot = ({ color, className, style, ref, ...props })=>{
|
|
6
|
-
const backgroundColor = style?.backgroundColor ?? resolveSeriesColor(color);
|
|
7
|
-
return /*#__PURE__*/ jsx("span", {
|
|
8
|
-
...props,
|
|
9
|
-
ref: ref,
|
|
10
|
-
"data-slot": "line-chart-hover-popover-dot",
|
|
11
|
-
"aria-hidden": "true",
|
|
12
|
-
className: cn(lineChartHoverPopoverDotClasses, className),
|
|
13
|
-
style: {
|
|
14
|
-
...style,
|
|
15
|
-
backgroundColor
|
|
16
|
-
}
|
|
2
|
+
import { ChartHoverCardDot } from "../internal/ChartHoverCard.js";
|
|
3
|
+
const LineChartHoverPopoverDot = (props)=>/*#__PURE__*/ jsx(ChartHoverCardDot, {
|
|
4
|
+
...props
|
|
17
5
|
});
|
|
18
|
-
};
|
|
19
6
|
LineChartHoverPopoverDot.displayName = 'LineChartHoverPopoverDot';
|
|
20
7
|
export { LineChartHoverPopoverDot };
|
|
@@ -6,7 +6,11 @@ export interface LineChartHoverPopoverRowProps extends HTMLAttributes<HTMLDivEle
|
|
|
6
6
|
series: LineChartSeries;
|
|
7
7
|
/** Raw datum value at the active index. `null`/`undefined` renders an em-dash. */
|
|
8
8
|
value?: number | string | null;
|
|
9
|
-
/** Optional value formatter. Defaults to
|
|
9
|
+
/** Optional value formatter. Defaults to the shared locale formatting. */
|
|
10
10
|
formatValue?: (value: number | string | null | undefined) => ReactNode;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* A hover popover row for one series — the shared `ChartHoverCardRow`, fed from a
|
|
14
|
+
* `LineChartSeries` and keyed by `series.key`.
|
|
15
|
+
*/
|
|
12
16
|
export declare const LineChartHoverPopoverRow: FC<LineChartHoverPopoverRowProps>;
|
|
@@ -1,33 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { LineChartHoverPopoverDot } from "./LineChartHoverPopoverDot.js";
|
|
5
|
-
const defaultFormatValue = (value)=>{
|
|
6
|
-
if (null == value) return '—';
|
|
7
|
-
return 'number' == typeof value ? value.toLocaleString() : String(value);
|
|
8
|
-
};
|
|
9
|
-
const LineChartHoverPopoverRow = ({ series, value, formatValue = defaultFormatValue, ref, className, children, ...props })=>/*#__PURE__*/ jsx("div", {
|
|
10
|
-
...props,
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ChartHoverCardRow } from "../internal/ChartHoverCard.js";
|
|
3
|
+
const LineChartHoverPopoverRow = ({ series, value, formatValue, children, ref, ...props })=>/*#__PURE__*/ jsx(ChartHoverCardRow, {
|
|
11
4
|
ref: ref,
|
|
12
|
-
"data-slot": "line-chart-hover-popover-row",
|
|
13
5
|
"data-key": series.key,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}),
|
|
21
|
-
/*#__PURE__*/ jsx("span", {
|
|
22
|
-
className: lineChartHoverPopoverRowLabelClasses,
|
|
23
|
-
children: series.label
|
|
24
|
-
}),
|
|
25
|
-
/*#__PURE__*/ jsx("span", {
|
|
26
|
-
className: lineChartHoverPopoverRowValueClasses,
|
|
27
|
-
children: formatValue(value)
|
|
28
|
-
})
|
|
29
|
-
]
|
|
30
|
-
})
|
|
6
|
+
color: series.color ?? 'slate',
|
|
7
|
+
label: series.label,
|
|
8
|
+
value: value,
|
|
9
|
+
formatValue: formatValue,
|
|
10
|
+
...props,
|
|
11
|
+
children: children
|
|
31
12
|
});
|
|
32
13
|
LineChartHoverPopoverRow.displayName = 'LineChartHoverPopoverRow';
|
|
33
14
|
export { LineChartHoverPopoverRow };
|
|
@@ -12,13 +12,7 @@ export declare const lineChartLegendItemVariants: (props?: ({
|
|
|
12
12
|
selected?: boolean | null | undefined;
|
|
13
13
|
dimmed?: boolean | null | undefined;
|
|
14
14
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
15
|
-
export declare const lineChartHoverPopoverClasses: string;
|
|
16
15
|
export declare const lineChartHoverPopoverTimestampClasses: string;
|
|
17
|
-
export declare const lineChartHoverPopoverRowClasses: string;
|
|
18
|
-
export declare const lineChartHoverPopoverRowDotClasses: string;
|
|
19
|
-
export declare const lineChartHoverPopoverRowLabelClasses: string;
|
|
20
|
-
export declare const lineChartHoverPopoverRowValueClasses: string;
|
|
21
|
-
export declare const lineChartHoverPopoverDotClasses: string;
|
|
22
16
|
export declare const lineChartZoomPopoverClasses: string;
|
|
23
17
|
export declare const lineChartZoomPopoverRangeClasses: string;
|
|
24
18
|
export declare const lineChartZoomPopoverConfirmClasses: string;
|
|
@@ -78,13 +78,7 @@ const lineChartLegendItemVariants = cva("group/line-chart-legend-item relative f
|
|
|
78
78
|
dimmed: false
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
|
-
const lineChartHoverPopoverClasses = "bg-bg-surface-2 border border-border-primary-light rounded-12 shadow-md px-12 py-8 min-w-160 flex flex-col gap-4 pointer-events-none";
|
|
82
81
|
const lineChartHoverPopoverTimestampClasses = "text-xs font-medium text-text-primary";
|
|
83
|
-
const lineChartHoverPopoverRowClasses = "relative h-16 w-full pl-12 flex items-center gap-8 text-xs font-mono text-text-primary";
|
|
84
|
-
const lineChartHoverPopoverRowDotClasses = "absolute left-0 top-4";
|
|
85
|
-
const lineChartHoverPopoverRowLabelClasses = "truncate min-w-0 font-normal";
|
|
86
|
-
const lineChartHoverPopoverRowValueClasses = "ml-auto shrink-0 font-medium";
|
|
87
|
-
const lineChartHoverPopoverDotClasses = "inline-block size-8 rounded-2";
|
|
88
82
|
const lineChartZoomPopoverClasses = "bg-bg-surface-2 border border-border-primary-light rounded-12 shadow-md px-12 py-8 min-w-160 flex flex-col gap-8";
|
|
89
83
|
const lineChartZoomPopoverRangeClasses = "text-xs font-medium text-text-primary whitespace-nowrap";
|
|
90
84
|
const lineChartZoomPopoverConfirmClasses = "inline-flex items-center justify-center h-24 px-8 w-full rounded-8 bg-states-brand-default-alt text-text-brand text-sm font-medium transition-colors outline-none hover:bg-states-brand-hover focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus-brand";
|
|
@@ -92,4 +86,4 @@ const lineChartTooltipCenterClasses = '-translate-y-1/2';
|
|
|
92
86
|
const lineChartEmptyRootClasses = "relative w-full";
|
|
93
87
|
const lineChartEmptyMessageClasses = "absolute top-0 left-0 right-0 flex items-center justify-center";
|
|
94
88
|
const lineChartEmptyMessageTextClasses = "px-8 bg-bg-surface-1 text-xs font-mono text-text-secondary";
|
|
95
|
-
export { lineChartBodyClasses, lineChartBodyZoomEnabledClasses, lineChartEmptyMessageClasses, lineChartEmptyMessageTextClasses, lineChartEmptyRootClasses,
|
|
89
|
+
export { lineChartBodyClasses, lineChartBodyZoomEnabledClasses, lineChartEmptyMessageClasses, lineChartEmptyMessageTextClasses, lineChartEmptyRootClasses, lineChartHoverPopoverTimestampClasses, lineChartLegendItemVariants, lineChartLegendVariants, lineChartRootClasses, lineChartTooltipCenterClasses, lineChartZoomCursorPopoverClasses, lineChartZoomPopoverClasses, lineChartZoomPopoverConfirmClasses, lineChartZoomPopoverRangeClasses };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FC, HTMLAttributes, Ref } from 'react';
|
|
2
|
+
import { type TestableProps } from '../../../utils/testId';
|
|
3
|
+
export interface MetricProps extends HTMLAttributes<HTMLDivElement>, TestableProps {
|
|
4
|
+
ref?: Ref<HTMLDivElement>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The family's compact stat, as a compound "brick set". Compose:
|
|
8
|
+
* `MetricHeader` (the shared value/total/delta row — also reused by `HorizontalBarStack`),
|
|
9
|
+
* `MetricValue`, `MetricTotal`, `MetricDelta`, and `MetricCaption`.
|
|
10
|
+
*
|
|
11
|
+
* Body-only: the card frame and "Title" header come from `Chart` / `ChartHeader` /
|
|
12
|
+
* `ChartTitle`, like every member of the family.
|
|
13
|
+
*/
|
|
14
|
+
export declare const Metric: FC<MetricProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|