@trackunit/react-components 1.17.28 → 1.17.33-alpha-f192ffc2526.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/index.cjs.js CHANGED
@@ -8109,16 +8109,16 @@ const getValueTextVariant = (size, sum, segments, total) => {
8109
8109
  * SegmentedValueBar displays multiple colored segments on a bar to visualize values relative to a total.
8110
8110
  * Supports optional tooltips per segment, showing value and optionally a label.
8111
8111
  */
8112
- const SegmentedValueBar = ({ segments, total, size = "small", showValue = false, unit, valueColor, showTooltip = false, className, "data-testid": dataTestId, }) => {
8112
+ const SegmentedValueBar = ({ segments, total, size = "small", showValue = false, displayValue, unit, valueColor, showTooltip = false, tooltipUnit, className, "data-testid": dataTestId, }) => {
8113
8113
  const computedSegments = computeSegments(segments, total);
8114
8114
  const sum = total > 0 ? computeSum(segments) : 0;
8115
- const valueText = formatValue(sum, unit);
8115
+ const valueText = formatValue(displayValue ?? sum, unit);
8116
8116
  const canShowValue = showValue && size !== "extraSmall";
8117
8117
  const valueTextClassName = cvaValueBarText({ size: getValueTextVariant(size, sum, segments, total) });
8118
8118
  return (jsxRuntime.jsxs("span", { className: valueBarContainerClassName, "data-testid": dataTestId, children: [jsxRuntime.jsx("div", { "aria-label": valueText, className: cvaSegmentedValueBar({ className, size }), "data-testid": dataTestId ? `${dataTestId}-track` : undefined, children: computedSegments.map((segment, index) => {
8119
8119
  const tooltipLabel = segment.label
8120
- ? `${segment.label}: ${formatValue(segment.value, unit)}`
8121
- : formatValue(segment.value, unit);
8120
+ ? `${segment.label}: ${formatValue(segment.value, tooltipUnit ?? unit)}`
8121
+ : formatValue(segment.value, tooltipUnit ?? unit);
8122
8122
  return showTooltip ? (jsxRuntime.jsx(Tooltip, { label: tooltipLabel, placement: "top", children: jsxRuntime.jsx("div", { "data-testid": dataTestId ? `${dataTestId}-segment-${index}` : undefined, style: { backgroundColor: segment.color, width: `${segment.width}%`, height: "100%" } }) }, index)) : (jsxRuntime.jsx("div", { "data-testid": dataTestId ? `${dataTestId}-segment-${index}` : undefined, style: { backgroundColor: segment.color, width: `${segment.width}%`, height: "100%" } }, index));
8123
8123
  }) }), canShowValue ? (jsxRuntime.jsx("span", { className: valueTextClassName, "data-testid": dataTestId ? `${dataTestId}-value` : undefined, children: jsxRuntime.jsx("span", { style: valueColor ? { color: valueColor } : undefined, children: valueText }) })) : null] }));
8124
8124
  };
package/index.esm.js CHANGED
@@ -8107,16 +8107,16 @@ const getValueTextVariant = (size, sum, segments, total) => {
8107
8107
  * SegmentedValueBar displays multiple colored segments on a bar to visualize values relative to a total.
8108
8108
  * Supports optional tooltips per segment, showing value and optionally a label.
8109
8109
  */
8110
- const SegmentedValueBar = ({ segments, total, size = "small", showValue = false, unit, valueColor, showTooltip = false, className, "data-testid": dataTestId, }) => {
8110
+ const SegmentedValueBar = ({ segments, total, size = "small", showValue = false, displayValue, unit, valueColor, showTooltip = false, tooltipUnit, className, "data-testid": dataTestId, }) => {
8111
8111
  const computedSegments = computeSegments(segments, total);
8112
8112
  const sum = total > 0 ? computeSum(segments) : 0;
8113
- const valueText = formatValue(sum, unit);
8113
+ const valueText = formatValue(displayValue ?? sum, unit);
8114
8114
  const canShowValue = showValue && size !== "extraSmall";
8115
8115
  const valueTextClassName = cvaValueBarText({ size: getValueTextVariant(size, sum, segments, total) });
8116
8116
  return (jsxs("span", { className: valueBarContainerClassName, "data-testid": dataTestId, children: [jsx("div", { "aria-label": valueText, className: cvaSegmentedValueBar({ className, size }), "data-testid": dataTestId ? `${dataTestId}-track` : undefined, children: computedSegments.map((segment, index) => {
8117
8117
  const tooltipLabel = segment.label
8118
- ? `${segment.label}: ${formatValue(segment.value, unit)}`
8119
- : formatValue(segment.value, unit);
8118
+ ? `${segment.label}: ${formatValue(segment.value, tooltipUnit ?? unit)}`
8119
+ : formatValue(segment.value, tooltipUnit ?? unit);
8120
8120
  return showTooltip ? (jsx(Tooltip, { label: tooltipLabel, placement: "top", children: jsx("div", { "data-testid": dataTestId ? `${dataTestId}-segment-${index}` : undefined, style: { backgroundColor: segment.color, width: `${segment.width}%`, height: "100%" } }) }, index)) : (jsx("div", { "data-testid": dataTestId ? `${dataTestId}-segment-${index}` : undefined, style: { backgroundColor: segment.color, width: `${segment.width}%`, height: "100%" } }, index));
8121
8121
  }) }), canShowValue ? (jsx("span", { className: valueTextClassName, "data-testid": dataTestId ? `${dataTestId}-value` : undefined, children: jsx("span", { style: valueColor ? { color: valueColor } : undefined, children: valueText }) })) : null] }));
8122
8122
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "1.17.28",
3
+ "version": "1.17.33-alpha-f192ffc2526.0",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -14,10 +14,10 @@
14
14
  "@floating-ui/react": "^0.26.25",
15
15
  "string-ts": "^2.0.0",
16
16
  "tailwind-merge": "^2.0.0",
17
- "@trackunit/ui-design-tokens": "1.11.45",
18
- "@trackunit/css-class-variance-utilities": "1.11.45",
19
- "@trackunit/shared-utils": "1.13.45",
20
- "@trackunit/ui-icons": "1.11.44",
17
+ "@trackunit/ui-design-tokens": "1.11.49-alpha-f192ffc2526.0",
18
+ "@trackunit/css-class-variance-utilities": "1.11.49-alpha-f192ffc2526.0",
19
+ "@trackunit/shared-utils": "1.13.49-alpha-f192ffc2526.0",
20
+ "@trackunit/ui-icons": "1.11.48-alpha-f192ffc2526.0",
21
21
  "@tanstack/react-router": "1.114.29",
22
22
  "es-toolkit": "^1.39.10",
23
23
  "@tanstack/react-virtual": "3.13.12",
@@ -16,10 +16,13 @@ export interface SegmentedValueBarProps extends CommonProps {
16
16
  */
17
17
  readonly size?: SegmentedValueBarSize;
18
18
  /**
19
- * Show the sum of segment values with unit (if provided) on the bar in large version or after the bar in the small version.
20
- * Ignored when size is "extraSmall".
19
+ * Show the sum of segment values next to the bar. Ignored when size is "extraSmall".
21
20
  */
22
21
  readonly showValue?: boolean;
22
+ /**
23
+ * Overrides the displayed value.
24
+ */
25
+ readonly displayValue?: number;
23
26
  /**
24
27
  * Unit appended to the displayed value, e.g. "%", "h", "°C".
25
28
  */
@@ -32,9 +35,13 @@ export interface SegmentedValueBarProps extends CommonProps {
32
35
  * Show a tooltip on hover with the individual segment value (and unit if provided). If a segment has a label, it is shown alongside the value.
33
36
  */
34
37
  readonly showTooltip?: boolean;
38
+ /**
39
+ * Unit for tooltip values. Defaults to `unit`.
40
+ */
41
+ readonly tooltipUnit?: string;
35
42
  }
36
43
  /**
37
44
  * SegmentedValueBar displays multiple colored segments on a bar to visualize values relative to a total.
38
45
  * Supports optional tooltips per segment, showing value and optionally a label.
39
46
  */
40
- export declare const SegmentedValueBar: ({ segments, total, size, showValue, unit, valueColor, showTooltip, className, "data-testid": dataTestId, }: SegmentedValueBarProps) => ReactElement;
47
+ export declare const SegmentedValueBar: ({ segments, total, size, showValue, displayValue, unit, valueColor, showTooltip, tooltipUnit, className, "data-testid": dataTestId, }: SegmentedValueBarProps) => ReactElement;