@trackunit/react-components 1.17.21 → 1.17.23
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 +1373 -185
- package/index.esm.js +1373 -186
- package/package.json +1 -1
- package/src/components/Badge/Badge.d.ts +13 -6
- package/src/components/Card/CardBody.d.ts +38 -3
- package/src/components/Card/CardFooter.d.ts +44 -3
- package/src/components/Card/CardHeader.d.ts +43 -2
- package/src/components/CompletionStatusIndicator/CompletionStatusIndicator.d.ts +19 -10
- package/src/components/CopyableText/CopyableText.d.ts +28 -2
- package/src/components/DetailsList/DetailsList.d.ts +28 -7
- package/src/components/EmptyState/EmptyState.d.ts +24 -0
- package/src/components/EmptyValue/EmptyValue.d.ts +19 -1
- package/src/components/ExternalLink/ExternalLink.d.ts +35 -4
- package/src/components/Heading/Heading.d.ts +22 -1
- package/src/components/Highlight/Highlight.d.ts +32 -7
- package/src/components/HorizontalOverflowScroller/HorizontalOverflowScroller.d.ts +24 -9
- package/src/components/Icon/Icon.d.ts +19 -2
- package/src/components/KPI/KPISkeleton.d.ts +23 -2
- package/src/components/KPICard/KPICardSkeleton.d.ts +23 -2
- package/src/components/ListItem/ListItem.d.ts +25 -3
- package/src/components/ListItem/ListItemSkeleton.d.ts +24 -2
- package/src/components/Menu/MenuDivider/MenuDivider.d.ts +22 -1
- package/src/components/Menu/MenuItem/MenuItem.d.ts +30 -1
- package/src/components/Menu/MoreMenu/MoreMenu.d.ts +56 -2
- package/src/components/Notice/Notice.d.ts +33 -3
- package/src/components/Page/Page.d.ts +38 -2
- package/src/components/Page/PageContent.d.ts +34 -5
- package/src/components/PageHeader/PageHeader.d.ts +8 -4
- package/src/components/Pagination/Pagination.d.ts +31 -2
- package/src/components/Polygon/Polygon.d.ts +38 -3
- package/src/components/Popover/Popover.d.ts +8 -6
- package/src/components/Popover/PopoverContent.d.ts +29 -3
- package/src/components/Popover/PopoverTitle.d.ts +36 -2
- package/src/components/Popover/PopoverTrigger.d.ts +35 -4
- package/src/components/Portal/Portal.d.ts +35 -4
- package/src/components/PreferenceCard/PreferenceCard.d.ts +25 -3
- package/src/components/PreferenceCard/PreferenceCardSkeleton.d.ts +23 -2
- package/src/components/Prompt/Prompt.d.ts +42 -8
- package/src/components/SectionHeader/SectionHeader.d.ts +23 -3
- package/src/components/Sidebar/Sidebar.d.ts +12 -5
- package/src/components/Skeleton/SkeletonBlock/SkeletonBlock.d.ts +21 -5
- package/src/components/Skeleton/SkeletonLabel/SkeletonLabel.d.ts +21 -5
- package/src/components/SkeletonLines/SkeletonLines.d.ts +8 -6
- package/src/components/Spacer/Spacer.d.ts +17 -10
- package/src/components/Spinner/Spinner.d.ts +27 -6
- package/src/components/Tabs/Tab.d.ts +29 -2
- package/src/components/Tabs/TabContent.d.ts +46 -1
- package/src/components/Tabs/TabList.d.ts +29 -1
- package/src/components/Tabs/Tabs.d.ts +14 -1
- package/src/components/Tag/Tag.d.ts +13 -6
- package/src/components/Text/Text.d.ts +28 -3
- package/src/components/ToggleGroup/ToggleGroup.d.ts +30 -1
- package/src/components/ValueBar/SegmentedValueBar.d.ts +40 -0
- package/src/components/ValueBar/SegmentedValueBar.variants.d.ts +3 -0
- package/src/components/ValueBar/SegmentedValueBarHelper.d.ts +16 -0
- package/src/components/ValueBar/SegmentedValueBarTypes.d.ts +6 -0
- package/src/components/ValueBar/ValueBar.d.ts +38 -2
- package/src/components/ZStack/ZStack.d.ts +23 -4
- package/src/components/buttons/Button/Button.d.ts +1 -1
- package/src/components/buttons/StarButton/StarButton.d.ts +24 -1
- package/src/index.d.ts +2 -0
|
@@ -46,14 +46,21 @@ export interface TagProps extends CommonProps {
|
|
|
46
46
|
onMouseEnter?: MouseEventHandler<HTMLDivElement>;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
49
|
+
* Tag is used for labeling or categorizing items in the UI. Common use cases include indicating asset status,
|
|
50
|
+
* marking features as Beta, or displaying selected options in multi-select inputs.
|
|
51
|
+
* Tags support dismissal (close button), icons, and multiple color variants.
|
|
52
52
|
*
|
|
53
|
-
*
|
|
53
|
+
* ### When to use
|
|
54
|
+
* Use Tag to label statuses, categories, or user selections. It supports colors for intent (success, warning, danger) and activity states.
|
|
55
|
+
*
|
|
56
|
+
* ### When not to use
|
|
57
|
+
* Do not use Tag for numeric counts — use `Badge`.
|
|
58
|
+
* Do not use Tag for highlighting data values — use `Highlight`.
|
|
59
|
+
*
|
|
60
|
+
* How to choose between Tag, `Badge` and `Highlight`?
|
|
54
61
|
* - Use a Tag for labeling statuses, categories, or selections.
|
|
55
|
-
* - Use a
|
|
56
|
-
* - Use a
|
|
62
|
+
* - Use a `Badge` to indicate notifications or counts of applied elements, such as filters.
|
|
63
|
+
* - Use a `Highlight` to draw attention to values in plain text that require special attention or have crossed a threshold.
|
|
57
64
|
*
|
|
58
65
|
* @example Status tags with different colors
|
|
59
66
|
* ```tsx
|
|
@@ -63,12 +63,37 @@ export interface TextProps extends CommonProps {
|
|
|
63
63
|
title?: string;
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
66
|
+
* Text applies Trackunit default typography styles to body text. It renders as a `<p>`, `<span>`, or `<div>` element
|
|
67
|
+
* and supports size, weight, alignment, and style variants (subtle, inverted, uppercase, etc.).
|
|
67
68
|
*
|
|
68
|
-
*
|
|
69
|
+
* ### When to use
|
|
70
|
+
* Use Text for body content, descriptions, labels, and any non-heading text. It ensures consistent typography across the application.
|
|
69
71
|
*
|
|
70
|
-
*
|
|
72
|
+
* ### When not to use
|
|
73
|
+
* Do not use Text for page or section headings — use `Heading` instead.
|
|
71
74
|
*
|
|
75
|
+
* @example Text with different sizes and weights
|
|
76
|
+
* ```tsx
|
|
77
|
+
* import { Text } from "@trackunit/react-components";
|
|
78
|
+
*
|
|
79
|
+
* const TextExamples = () => (
|
|
80
|
+
* <div>
|
|
81
|
+
* <Text size="large" weight="bold">Large bold text</Text>
|
|
82
|
+
* <Text size="medium">Default body text</Text>
|
|
83
|
+
* <Text size="small" subtle>Small subtle caption</Text>
|
|
84
|
+
* </div>
|
|
85
|
+
* );
|
|
86
|
+
* ```
|
|
87
|
+
* @example Inline text using span
|
|
88
|
+
* ```tsx
|
|
89
|
+
* import { Text } from "@trackunit/react-components";
|
|
90
|
+
*
|
|
91
|
+
* const InlineExample = () => (
|
|
92
|
+
* <Text>
|
|
93
|
+
* Asset status: <Text type="span" weight="bold">Active</Text>
|
|
94
|
+
* </Text>
|
|
95
|
+
* );
|
|
96
|
+
* ```
|
|
72
97
|
* @param {TextProps} props - The props for the Text component
|
|
73
98
|
* @returns {ReactElement} Text component
|
|
74
99
|
*/
|
|
@@ -58,8 +58,37 @@ export type ToggleGroupProps<TSelectedId extends string = string> = CommonProps
|
|
|
58
58
|
setSelected: Dispatch<SetStateAction<TSelectedId>>;
|
|
59
59
|
};
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* ToggleGroup allows users to toggle between two or more closely related options and immediately apply the selection.
|
|
62
|
+
* It renders a segmented control with a sliding background indicator. Supports text-only, icon-only, and text+icon modes.
|
|
62
63
|
*
|
|
64
|
+
* ### When to use
|
|
65
|
+
* Use ToggleGroup when the user needs to switch between 2-5 mutually exclusive options that take effect immediately (e.g., view modes, map/list toggle, time ranges).
|
|
66
|
+
*
|
|
67
|
+
* ### When not to use
|
|
68
|
+
* Do not use ToggleGroup for navigation — use `Tabs`.
|
|
69
|
+
* Do not use ToggleGroup for form selections with many options — use a Select or RadioGroup.
|
|
70
|
+
*
|
|
71
|
+
* @example ToggleGroup for view mode switching
|
|
72
|
+
* ```tsx
|
|
73
|
+
* import { ToggleGroup } from "@trackunit/react-components";
|
|
74
|
+
* import { useState } from "react";
|
|
75
|
+
*
|
|
76
|
+
* const ViewToggle = () => {
|
|
77
|
+
* const [selected, setSelected] = useState("list");
|
|
78
|
+
*
|
|
79
|
+
* return (
|
|
80
|
+
* <ToggleGroup
|
|
81
|
+
* selected={selected}
|
|
82
|
+
* setSelected={setSelected}
|
|
83
|
+
* onChange={(id) => console.log("Selected:", id)}
|
|
84
|
+
* list={[
|
|
85
|
+
* { id: "list", title: "List", iconName: "Bars3" },
|
|
86
|
+
* { id: "map", title: "Map", iconName: "MapPin" },
|
|
87
|
+
* ]}
|
|
88
|
+
* />
|
|
89
|
+
* );
|
|
90
|
+
* };
|
|
91
|
+
* ```
|
|
63
92
|
* @param {ToggleGroupProps} props - The props for the ToggleGroup component
|
|
64
93
|
* @returns {ReactElement} ToggleGroup component
|
|
65
94
|
*/
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
import { CommonProps } from "../../common/CommonProps";
|
|
3
|
+
import type { SegmentedValueBarSize, ValueBarSegment } from "./SegmentedValueBarTypes";
|
|
4
|
+
export interface SegmentedValueBarProps extends CommonProps {
|
|
5
|
+
/**
|
|
6
|
+
* Array of segments to display. Each segment has a numeric value and a color and optionally a label.
|
|
7
|
+
* Segments render in the order they are provided; the component does not sort or reorder them.
|
|
8
|
+
*/
|
|
9
|
+
readonly segments: Array<ValueBarSegment>;
|
|
10
|
+
/**
|
|
11
|
+
* The total value that segments are measured against.
|
|
12
|
+
*/
|
|
13
|
+
readonly total: number;
|
|
14
|
+
/**
|
|
15
|
+
* Size of the bar. Determines height and whether value text can be displayed.
|
|
16
|
+
*/
|
|
17
|
+
readonly size?: SegmentedValueBarSize;
|
|
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".
|
|
21
|
+
*/
|
|
22
|
+
readonly showValue?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Unit appended to the displayed value, e.g. "%", "h", "°C".
|
|
25
|
+
*/
|
|
26
|
+
readonly unit?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Custom color for the displayed value text.
|
|
29
|
+
*/
|
|
30
|
+
readonly valueColor?: string;
|
|
31
|
+
/**
|
|
32
|
+
* 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
|
+
*/
|
|
34
|
+
readonly showTooltip?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* SegmentedValueBar displays multiple colored segments on a bar to visualize values relative to a total.
|
|
38
|
+
* Supports optional tooltips per segment, showing value and optionally a label.
|
|
39
|
+
*/
|
|
40
|
+
export declare const SegmentedValueBar: ({ segments, total, size, showValue, unit, valueColor, showTooltip, className, "data-testid": dataTestId, }: SegmentedValueBarProps) => ReactElement;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SegmentedValueBarSize, ValueBarSegment } from "./SegmentedValueBarTypes";
|
|
2
|
+
type ComputedSegment = {
|
|
3
|
+
readonly width: number;
|
|
4
|
+
readonly value: number;
|
|
5
|
+
readonly color: string;
|
|
6
|
+
readonly label?: string;
|
|
7
|
+
};
|
|
8
|
+
/** Formats a numeric value to one decimal place with an optional unit suffix. */
|
|
9
|
+
export declare const formatValue: (value: number, unit?: string) => string;
|
|
10
|
+
/** Returns the sum of all positive segment values. */
|
|
11
|
+
export declare const computeSum: (segments: Array<ValueBarSegment>) => number;
|
|
12
|
+
/** Computes percentage widths for each positive segment, scaling proportionally when the sum exceeds total. */
|
|
13
|
+
export declare const computeSegments: (segments: Array<ValueBarSegment>, total: number) => Array<ComputedSegment>;
|
|
14
|
+
/** Determines the text variant size for value overlay placement on the bar. */
|
|
15
|
+
export declare const getValueTextVariant: (size: SegmentedValueBarSize, sum: number, segments: Array<ValueBarSegment>, total: number) => "small" | "large";
|
|
16
|
+
export {};
|
|
@@ -45,8 +45,44 @@ export interface ValueBarProps extends CommonProps, Refable<HTMLSpanElement> {
|
|
|
45
45
|
zeroScoreAllowed?: boolean;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
* ValueBar
|
|
49
|
-
|
|
48
|
+
* ValueBar displays a numeric value as a colored progress bar within a defined range.
|
|
49
|
+
* The bar color changes based on the score (value relative to min/max) using either default or custom level colors.
|
|
50
|
+
* It can optionally display the numeric value and unit alongside the bar.
|
|
51
|
+
*
|
|
52
|
+
* ### When to use
|
|
53
|
+
* Use ValueBar to visualize a metric relative to a range (e.g., battery level, fuel percentage, utilization rate, temperature).
|
|
54
|
+
*
|
|
55
|
+
* ### When not to use
|
|
56
|
+
* Do not use ValueBar for progress through a multi-step process. Use a stepper or progress indicator instead.
|
|
57
|
+
*
|
|
58
|
+
* @example Basic value bar with percentage
|
|
59
|
+
* ```tsx
|
|
60
|
+
* import { ValueBar } from "@trackunit/react-components";
|
|
61
|
+
*
|
|
62
|
+
* const BatteryLevel = () => (
|
|
63
|
+
* <ValueBar value={72} min={0} max={100} unit="%" showValue />
|
|
64
|
+
* );
|
|
65
|
+
* ```
|
|
66
|
+
* @example Value bar with custom level colors
|
|
67
|
+
* ```tsx
|
|
68
|
+
* import { ValueBar } from "@trackunit/react-components";
|
|
69
|
+
*
|
|
70
|
+
* const TemperatureBar = () => (
|
|
71
|
+
* <ValueBar
|
|
72
|
+
* value={85}
|
|
73
|
+
* min={0}
|
|
74
|
+
* max={120}
|
|
75
|
+
* unit="°C"
|
|
76
|
+
* showValue
|
|
77
|
+
* size="large"
|
|
78
|
+
* levelColors={[
|
|
79
|
+
* { min: 0, max: 0.5, color: "#22c55e" },
|
|
80
|
+
* { min: 0.5, max: 0.75, color: "#f59e0b" },
|
|
81
|
+
* { min: 0.75, max: 1, color: "#ef4444" },
|
|
82
|
+
* ]}
|
|
83
|
+
* />
|
|
84
|
+
* );
|
|
85
|
+
* ```
|
|
50
86
|
* @param {ValueBarProps} props - The props for the ValueBar component
|
|
51
87
|
* @returns {ReactElement} ValueBar component
|
|
52
88
|
*/
|
|
@@ -5,10 +5,29 @@ export type ZStackProps = CommonProps & Refable<HTMLDivElement> & {
|
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
|
-
* ZStack
|
|
9
|
-
*
|
|
8
|
+
* ZStack stacks its children on the z-axis (overlaying them on top of each other).
|
|
9
|
+
* It is a CSS grid-based alternative to `position: absolute` that avoids side effects like elements being removed from the document flow.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* ### When to use
|
|
12
|
+
* Use ZStack when you need to overlay elements on top of each other (e.g., an image with a badge overlay, or a scroll container with fade indicators).
|
|
13
|
+
*
|
|
14
|
+
* ### When not to use
|
|
15
|
+
* Do not use ZStack for standard stacking/layout — use flex or grid containers instead.
|
|
16
|
+
*
|
|
17
|
+
* @example Overlaying a badge on a thumbnail
|
|
18
|
+
* ```tsx
|
|
19
|
+
* import { ZStack, Badge, Icon } from "@trackunit/react-components";
|
|
20
|
+
*
|
|
21
|
+
* const ThumbnailWithBadge = () => (
|
|
22
|
+
* <ZStack>
|
|
23
|
+
* <Icon name="Truck" size="large" />
|
|
24
|
+
* <div className="self-start justify-self-end">
|
|
25
|
+
* <Badge count={3} color="danger" />
|
|
26
|
+
* </div>
|
|
27
|
+
* </ZStack>
|
|
28
|
+
* );
|
|
29
|
+
* ```
|
|
30
|
+
* @param {ZStackProps} props - The props for the ZStack component
|
|
31
|
+
* @returns {ReactElement} ZStack component
|
|
13
32
|
*/
|
|
14
33
|
export declare const ZStack: ({ children, className, "data-testid": dataTestId, ref }: ZStackProps) => ReactElement;
|
|
@@ -51,7 +51,7 @@ export interface ButtonProps extends MappedOmit<ButtonCommonProps, "size"> {
|
|
|
51
51
|
* Use buttons to communicate actions users can take and to allow users to interact with the page. Each page should have one primary button, and any remaining calls to action should be represented as lower emphasis buttons.
|
|
52
52
|
*
|
|
53
53
|
* ### When not to use
|
|
54
|
-
* Do not use buttons as navigational elements. Instead, use
|
|
54
|
+
* Do not use buttons as navigational elements. Instead, use `Links` when the desired action is to take the user to a new page.
|
|
55
55
|
*
|
|
56
56
|
* @example Basic button with click handler
|
|
57
57
|
* ```tsx
|
|
@@ -1,12 +1,35 @@
|
|
|
1
1
|
import { MouseEventHandler, ReactElement } from "react";
|
|
2
2
|
import { Refable } from "../../../common/Refable";
|
|
3
3
|
interface StarButtonProps extends Refable<HTMLDivElement> {
|
|
4
|
+
/**
|
|
5
|
+
* Whether the item is currently starred/favorited. Controls the icon color (primary when starred, neutral when not).
|
|
6
|
+
*/
|
|
4
7
|
starred: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Click handler triggered when the star icon is clicked.
|
|
10
|
+
*/
|
|
5
11
|
onClick: MouseEventHandler<HTMLDivElement>;
|
|
6
12
|
}
|
|
7
13
|
/**
|
|
8
|
-
*
|
|
14
|
+
* StarButton renders a clickable star icon for toggling favorite/starred state.
|
|
15
|
+
* The star appears in the primary color when starred and neutral when unstarred.
|
|
9
16
|
*
|
|
17
|
+
* ### When to use
|
|
18
|
+
* Use StarButton for favorite or bookmark actions on list items, cards, or tables.
|
|
19
|
+
*
|
|
20
|
+
* ### When not to use
|
|
21
|
+
* Do not use StarButton for primary actions — use `Button` or `IconButton`.
|
|
22
|
+
*
|
|
23
|
+
* @example Star button for favoriting an asset
|
|
24
|
+
* ```tsx
|
|
25
|
+
* import { StarButton } from "@trackunit/react-components";
|
|
26
|
+
* import { useState } from "react";
|
|
27
|
+
*
|
|
28
|
+
* const FavoriteToggle = () => {
|
|
29
|
+
* const [starred, setStarred] = useState(false);
|
|
30
|
+
* return <StarButton starred={starred} onClick={() => setStarred(s => !s)} />;
|
|
31
|
+
* };
|
|
32
|
+
* ```
|
|
10
33
|
* @param {StarButtonProps} props - The props for the StarButton component
|
|
11
34
|
* @returns {ReactElement} StarButton component
|
|
12
35
|
*/
|
package/src/index.d.ts
CHANGED
|
@@ -97,6 +97,8 @@ export * from "./components/Text/Text";
|
|
|
97
97
|
export * from "./components/ToggleGroup/ToggleGroup";
|
|
98
98
|
export * from "./components/ToggleGroup/ToggleGroup.variants";
|
|
99
99
|
export * from "./components/Tooltip/Tooltip";
|
|
100
|
+
export * from "./components/ValueBar/SegmentedValueBar";
|
|
101
|
+
export * from "./components/ValueBar/SegmentedValueBarTypes";
|
|
100
102
|
export * from "./components/ValueBar/ValueBar";
|
|
101
103
|
export { getValueBarColorByValue } from "./components/ValueBar/ValueBarHelper";
|
|
102
104
|
export * from "./components/ValueBar/ValueBarTypes";
|