@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
|
@@ -25,7 +25,28 @@ export interface KPICardSkeletonProps extends CommonProps, Styleable, Refable<HT
|
|
|
25
25
|
children?: ReactNode;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
28
|
+
* KPICardSkeleton is a loading placeholder that mimics the layout of a KPICard.
|
|
29
|
+
* It renders skeleton lines for the KPI title/value, and optional icon, trends, value bar, and notice slots.
|
|
30
|
+
*
|
|
31
|
+
* ### When to use
|
|
32
|
+
* Use KPICardSkeleton while `KPICard` data is loading to maintain layout stability in dashboards and metric displays.
|
|
33
|
+
*
|
|
34
|
+
* ### When not to use
|
|
35
|
+
* Do not use KPICardSkeleton for generic card loading — use a `Card` with `SkeletonLabel` inside.
|
|
36
|
+
*
|
|
37
|
+
* @example KPICard skeletons in a dashboard row
|
|
38
|
+
* ```tsx
|
|
39
|
+
* import { KPICardSkeleton } from "@trackunit/react-components";
|
|
40
|
+
*
|
|
41
|
+
* const LoadingMetrics = () => (
|
|
42
|
+
* <div className="grid grid-cols-3 gap-4">
|
|
43
|
+
* <KPICardSkeleton hasIcon hasTrends />
|
|
44
|
+
* <KPICardSkeleton hasIcon hasValueBar />
|
|
45
|
+
* <KPICardSkeleton hasNotice />
|
|
46
|
+
* </div>
|
|
47
|
+
* );
|
|
48
|
+
* ```
|
|
49
|
+
* @param {KPICardSkeletonProps} props - The props for the KPICardSkeleton component
|
|
50
|
+
* @returns {ReactElement} KPICardSkeleton component
|
|
30
51
|
*/
|
|
31
52
|
export declare const KPICardSkeleton: ({ hasIcon, hasTrends, hasValueBar, hasNotice, children, className, "data-testid": dataTestId, style, ref, ...rest }: KPICardSkeletonProps) => ReactElement;
|
|
@@ -36,10 +36,32 @@ export interface ListItemProps extends CommonProps, ListItemVirtualizationProps,
|
|
|
36
36
|
thumbnailBackground?: `${ThemeColors}-${ThemeColorShades}` | `${ThemeColors}`;
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* ListItem presents a concise row of information for quick scanning and navigation. It supports a title, description, meta text, thumbnail,
|
|
40
|
+
* and a details slot. When `onClick` is provided, the item becomes interactive with a chevron indicator.
|
|
40
41
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
42
|
+
* ### When to use
|
|
43
|
+
* Use ListItem inside a `List` to display items such as assets, events, users, or notifications with consistent layout.
|
|
44
|
+
*
|
|
45
|
+
* ### When not to use
|
|
46
|
+
* Do not use ListItem outside of a `List` component for standalone clickable elements — use `Card` or `Button`.
|
|
47
|
+
*
|
|
48
|
+
* @example ListItem with thumbnail and details
|
|
49
|
+
* ```tsx
|
|
50
|
+
* import { ListItem, Icon, Tag } from "@trackunit/react-components";
|
|
51
|
+
*
|
|
52
|
+
* const AssetListItem = () => (
|
|
53
|
+
* <ListItem
|
|
54
|
+
* title="Excavator CAT 320"
|
|
55
|
+
* description="Serial: SN-2024-00142"
|
|
56
|
+
* meta="Last seen: 2 hours ago"
|
|
57
|
+
* thumbnail={<Icon name="Truck" size="small" />}
|
|
58
|
+
* details={<Tag color="success" size="small">Active</Tag>}
|
|
59
|
+
* onClick={() => console.log("Navigate to asset")}
|
|
60
|
+
* />
|
|
61
|
+
* );
|
|
62
|
+
* ```
|
|
63
|
+
* @param {ListItemProps} props - The props for the ListItem component
|
|
64
|
+
* @returns {ReactElement} ListItem component
|
|
43
65
|
*/
|
|
44
66
|
export declare const ListItem: ({ className, "data-testid": dataTestId, onClick, details, title, description, meta, thumbnail, thumbnailColor, thumbnailBackground, ...rest }: ListItemProps) => ReactElement;
|
|
45
67
|
export {};
|
|
@@ -22,7 +22,29 @@ export interface ListItemSkeletonProps {
|
|
|
22
22
|
hasDetails?: boolean;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
25
|
+
* ListItemSkeleton is a loading placeholder that mimics the layout of a ListItem.
|
|
26
|
+
* It renders skeleton lines for the title, description, meta, thumbnail, and details slots.
|
|
27
|
+
* Use it inside a List to indicate that list data is loading.
|
|
28
|
+
*
|
|
29
|
+
* ### When to use
|
|
30
|
+
* Use ListItemSkeleton as the loading state inside a `List` when data is being fetched. Configure it to match the shape of your actual ListItems.
|
|
31
|
+
*
|
|
32
|
+
* ### When not to use
|
|
33
|
+
* Do not use ListItemSkeleton for non-list loading states. Use `SkeletonBlock` or `SkeletonLabel` for generic loading placeholders.
|
|
34
|
+
*
|
|
35
|
+
* @example ListItemSkeleton matching a typical asset list item
|
|
36
|
+
* ```tsx
|
|
37
|
+
* import { ListItemSkeleton } from "@trackunit/react-components";
|
|
38
|
+
*
|
|
39
|
+
* const LoadingList = () => (
|
|
40
|
+
* <div>
|
|
41
|
+
* <ListItemSkeleton hasThumbnail hasDescription hasMeta={false} />
|
|
42
|
+
* <ListItemSkeleton hasThumbnail hasDescription hasMeta={false} />
|
|
43
|
+
* <ListItemSkeleton hasThumbnail hasDescription hasMeta={false} />
|
|
44
|
+
* </div>
|
|
45
|
+
* );
|
|
46
|
+
* ```
|
|
47
|
+
* @param {ListItemSkeletonProps} props - The props for the ListItemSkeleton component
|
|
48
|
+
* @returns {ReactElement} ListItemSkeleton component
|
|
27
49
|
*/
|
|
28
50
|
export declare const ListItemSkeleton: ({ hasThumbnail, thumbnailShape, hasDescription, hasMeta, hasDetails, }: ListItemSkeletonProps) => ReactElement;
|
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
import { ReactElement } from "react";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* MenuDivider renders a horizontal line to visually separate groups of items within a MenuList.
|
|
4
|
+
*
|
|
5
|
+
* ### When to use
|
|
6
|
+
* Use MenuDivider between groups of related `MenuItem` elements to create logical sections within a menu.
|
|
7
|
+
*
|
|
8
|
+
* ### When not to use
|
|
9
|
+
* Do not use MenuDivider outside of a `MenuList`. For general-purpose dividers, use `Spacer` with `border`.
|
|
10
|
+
*
|
|
11
|
+
* @example Menu with grouped sections
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import { MenuList, MenuItem, MenuDivider, Icon } from "@trackunit/react-components";
|
|
14
|
+
*
|
|
15
|
+
* const GroupedMenu = () => (
|
|
16
|
+
* <MenuList>
|
|
17
|
+
* <MenuItem id="edit" label="Edit" prefix={<Icon name="PencilSquare" size="small" />} />
|
|
18
|
+
* <MenuItem id="duplicate" label="Duplicate" prefix={<Icon name="DocumentDuplicate" size="small" />} />
|
|
19
|
+
* <MenuDivider />
|
|
20
|
+
* <MenuItem id="delete" label="Delete" variant="danger" prefix={<Icon name="Trash" size="small" />} />
|
|
21
|
+
* </MenuList>
|
|
22
|
+
* );
|
|
23
|
+
* ```
|
|
24
|
+
* @returns {ReactElement} MenuDivider component
|
|
4
25
|
*/
|
|
5
26
|
export declare const MenuDivider: () => ReactElement;
|
|
@@ -86,8 +86,37 @@ export interface MenuItemProps extends CommonProps, Refable<HTMLDivElement> {
|
|
|
86
86
|
fieldSize?: VariantProps<typeof cvaMenuItemStyle>["fieldSize"];
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
|
-
*
|
|
89
|
+
* MenuItem represents a single actionable item within a MenuList.
|
|
90
|
+
* It supports labels, icons (prefix/suffix), selected and focused states, and danger variants.
|
|
90
91
|
*
|
|
92
|
+
* ### When to use
|
|
93
|
+
* Use MenuItem inside a `MenuList` for individual actions (edit, delete, duplicate) or selectable options.
|
|
94
|
+
*
|
|
95
|
+
* ### When not to use
|
|
96
|
+
* Do not use MenuItem outside of a `MenuList` context. For standalone clickable items, use `Button` or `ListItem`.
|
|
97
|
+
*
|
|
98
|
+
* @example MenuItem with icon prefix
|
|
99
|
+
* ```tsx
|
|
100
|
+
* import { MenuList, MenuItem, Icon } from "@trackunit/react-components";
|
|
101
|
+
*
|
|
102
|
+
* const ActionMenu = () => (
|
|
103
|
+
* <MenuList>
|
|
104
|
+
* <MenuItem
|
|
105
|
+
* id="edit"
|
|
106
|
+
* label="Edit asset"
|
|
107
|
+
* prefix={<Icon name="PencilSquare" size="small" />}
|
|
108
|
+
* onClick={() => console.log("Edit clicked")}
|
|
109
|
+
* />
|
|
110
|
+
* <MenuItem
|
|
111
|
+
* id="delete"
|
|
112
|
+
* label="Delete asset"
|
|
113
|
+
* prefix={<Icon name="Trash" size="small" />}
|
|
114
|
+
* variant="danger"
|
|
115
|
+
* onClick={() => console.log("Delete clicked")}
|
|
116
|
+
* />
|
|
117
|
+
* </MenuList>
|
|
118
|
+
* );
|
|
119
|
+
* ```
|
|
91
120
|
* @param {MenuItemProps} props - The props for the MenuItem component
|
|
92
121
|
* @returns {ReactElement} MenuItem component
|
|
93
122
|
*/
|
|
@@ -10,17 +10,71 @@ export type MenuPlacement = "above" | "below";
|
|
|
10
10
|
type FilteredIconProps = MakePropertyOptional<MappedOmit<IconProps, "onClick">, "name">;
|
|
11
11
|
type FilteredIconButtonProps = Omit<IconButtonProps, "icon" | "onClick">;
|
|
12
12
|
export interface MoreMenuProps extends CommonProps, Refable<HTMLDivElement> {
|
|
13
|
+
/**
|
|
14
|
+
* Content to render inside the popover. Receives a `close` callback as a render prop, or accepts static ReactNode children.
|
|
15
|
+
*/
|
|
13
16
|
children: PopoverContentChildren;
|
|
17
|
+
/**
|
|
18
|
+
* Props to forward to the underlying Popover component (e.g., `placement`, `offset`).
|
|
19
|
+
*/
|
|
14
20
|
popoverProps?: PopoverProps;
|
|
21
|
+
/**
|
|
22
|
+
* Props to customize the kebab icon (e.g., `size`, `className`). The `name` defaults to "EllipsisHorizontal".
|
|
23
|
+
*/
|
|
15
24
|
iconProps?: FilteredIconProps;
|
|
25
|
+
/**
|
|
26
|
+
* Props to customize the trigger IconButton (e.g., `size`, `variant`).
|
|
27
|
+
*/
|
|
16
28
|
iconButtonProps?: FilteredIconButtonProps;
|
|
29
|
+
/**
|
|
30
|
+
* A custom portal ID for the popover content. Useful when rendering inside modals or other portal containers.
|
|
31
|
+
*/
|
|
17
32
|
customPortalId?: string;
|
|
33
|
+
/**
|
|
34
|
+
* A custom trigger element to replace the default kebab IconButton.
|
|
35
|
+
*/
|
|
18
36
|
customButton?: ReactNode;
|
|
19
37
|
}
|
|
20
38
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
39
|
+
* MoreMenu (kebab menu) renders a three-dot button that opens a popover with a list of actions.
|
|
40
|
+
* It is typically filled with a MenuList containing MenuItem elements.
|
|
23
41
|
*
|
|
42
|
+
* ### When to use
|
|
43
|
+
* Use MoreMenu when you have overflow actions that don't fit in the main UI. Common for row-level actions in tables, card headers, or list items.
|
|
44
|
+
*
|
|
45
|
+
* ### When not to use
|
|
46
|
+
* Do not use MoreMenu for primary actions that should always be visible. Use `Button` instead.
|
|
47
|
+
*
|
|
48
|
+
* @example Action items with render prop — Pass a function as `children` to receive the `close` callback and dismiss the menu after an action.
|
|
49
|
+
* ```tsx
|
|
50
|
+
* import { MoreMenu, MenuList, MenuItem, Icon } from "@trackunit/react-components";
|
|
51
|
+
*
|
|
52
|
+
* const AssetActions = () => (
|
|
53
|
+
* <MoreMenu>
|
|
54
|
+
* {(close) => (
|
|
55
|
+
* <MenuList onClick={close}>
|
|
56
|
+
* <MenuItem id="edit" label="Edit" prefix={<Icon name="PencilSquare" size="small" />} />
|
|
57
|
+
* <MenuItem id="delete" label="Delete" variant="danger" prefix={<Icon name="Trash" size="small" />} />
|
|
58
|
+
* </MenuList>
|
|
59
|
+
* )}
|
|
60
|
+
* </MoreMenu>
|
|
61
|
+
* );
|
|
62
|
+
* ```
|
|
63
|
+
* @example Custom trigger button — Use `customButton` to replace the default kebab icon with any element, like a labeled Button.
|
|
64
|
+
* ```tsx
|
|
65
|
+
* import { MoreMenu, MenuList, MenuItem, Button } from "@trackunit/react-components";
|
|
66
|
+
*
|
|
67
|
+
* const CustomTriggerMenu = () => (
|
|
68
|
+
* <MoreMenu customButton={<Button variant="secondary" size="small">Actions</Button>}>
|
|
69
|
+
* {(close) => (
|
|
70
|
+
* <MenuList onClick={close}>
|
|
71
|
+
* <MenuItem id="export" label="Export" />
|
|
72
|
+
* <MenuItem id="archive" label="Archive" />
|
|
73
|
+
* </MenuList>
|
|
74
|
+
* )}
|
|
75
|
+
* </MoreMenu>
|
|
76
|
+
* );
|
|
77
|
+
* ```
|
|
24
78
|
* @param {MoreMenuProps} props - The props for the MoreMenu component
|
|
25
79
|
* @returns {ReactElement} MoreMenu component
|
|
26
80
|
*/
|
|
@@ -43,12 +43,42 @@ export interface NoticeProps extends CommonProps, Refable<HTMLDivElement> {
|
|
|
43
43
|
withTooltip?: boolean;
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* Notice is a non-interactive element that communicates informational messages the user should see, without prompting an action.
|
|
47
|
+
* It displays an optional icon and text label, with optional tooltip support.
|
|
47
48
|
*
|
|
48
|
-
*
|
|
49
|
+
* ### When to use
|
|
50
|
+
* Use Notice to communicate non-essential, contextual information that does not require action (e.g., status notes, informational hints).
|
|
49
51
|
*
|
|
50
|
-
*
|
|
52
|
+
* ### When not to use
|
|
53
|
+
* Do not use Notice for essential information that requires user action — use `Alert` instead.
|
|
54
|
+
* Do not use Notice for asset state indicators — use `Indicator` instead.
|
|
51
55
|
*
|
|
56
|
+
* @example Notice with icon and label
|
|
57
|
+
* ```tsx
|
|
58
|
+
* import { Notice } from "@trackunit/react-components";
|
|
59
|
+
*
|
|
60
|
+
* const InfoNotice = () => (
|
|
61
|
+
* <Notice
|
|
62
|
+
* iconName="InformationCircle"
|
|
63
|
+
* label="Last synced 5 minutes ago"
|
|
64
|
+
* color="info"
|
|
65
|
+
* />
|
|
66
|
+
* );
|
|
67
|
+
* ```
|
|
68
|
+
* @example Warning notice with tooltip
|
|
69
|
+
* ```tsx
|
|
70
|
+
* import { Notice } from "@trackunit/react-components";
|
|
71
|
+
*
|
|
72
|
+
* const WarningNotice = () => (
|
|
73
|
+
* <Notice
|
|
74
|
+
* iconName="ExclamationTriangle"
|
|
75
|
+
* label="Low battery"
|
|
76
|
+
* color="warning"
|
|
77
|
+
* withTooltip
|
|
78
|
+
* tooltipLabel="Battery level is below 20%"
|
|
79
|
+
* />
|
|
80
|
+
* );
|
|
81
|
+
* ```
|
|
52
82
|
* @param {NoticeProps} props - The props for the Notice component
|
|
53
83
|
* @returns {ReactElement} Notice component
|
|
54
84
|
*/
|
|
@@ -8,14 +8,50 @@ import { cvaPage } from "./Page.variants";
|
|
|
8
8
|
*/
|
|
9
9
|
export type Layout = VariantProps<typeof cvaPage>["layout"];
|
|
10
10
|
/**
|
|
11
|
-
* The props for the
|
|
11
|
+
* The props for the Page component.
|
|
12
12
|
*/
|
|
13
13
|
export interface PageProps extends CommonProps, Refable<HTMLDivElement> {
|
|
14
|
+
/**
|
|
15
|
+
* The layout mode of the page. Controls how content is arranged within the page container.
|
|
16
|
+
*/
|
|
14
17
|
layout: Layout;
|
|
18
|
+
/**
|
|
19
|
+
* The child elements to render inside the page.
|
|
20
|
+
*/
|
|
15
21
|
children?: ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* An ID that can be used in tests to locate the component. Defaults to "page".
|
|
24
|
+
*/
|
|
16
25
|
"data-testid"?: string;
|
|
17
26
|
}
|
|
18
27
|
/**
|
|
19
|
-
*
|
|
28
|
+
* Page is the top-level layout container that applies consistent padding and layout to page content.
|
|
29
|
+
* Use it in combination with PageContent and PageHeader.
|
|
30
|
+
*
|
|
31
|
+
* ### When to use
|
|
32
|
+
* Use Page as the outermost wrapper for a page view. It provides the base layout structure (padding, spacing) for the page.
|
|
33
|
+
*
|
|
34
|
+
* ### When not to use
|
|
35
|
+
* Do not use Page for card-level or section-level layout. Use `Card` or standard flex/grid containers instead.
|
|
36
|
+
*
|
|
37
|
+
* @example Page with header and content
|
|
38
|
+
* ```tsx
|
|
39
|
+
* import { Page, PageContent, PageHeader } from "@trackunit/react-components";
|
|
40
|
+
*
|
|
41
|
+
* const AssetListPage = () => (
|
|
42
|
+
* <Page layout="default">
|
|
43
|
+
* <PageHeader
|
|
44
|
+
* title="Assets"
|
|
45
|
+
* accessoryType="actions"
|
|
46
|
+
* primaryAction={{ actionText: "Add Asset", actionCallback: () => {} }}
|
|
47
|
+
* />
|
|
48
|
+
* <PageContent layout="default">
|
|
49
|
+
* <p>Asset list content goes here</p>
|
|
50
|
+
* </PageContent>
|
|
51
|
+
* </Page>
|
|
52
|
+
* );
|
|
53
|
+
* ```
|
|
54
|
+
* @param {PageProps} props - The props for the Page component
|
|
55
|
+
* @returns {ReactElement} Page component
|
|
20
56
|
*/
|
|
21
57
|
export declare const Page: ({ layout, className, children, "data-testid": dataTestId, ref }: PageProps) => ReactElement;
|
|
@@ -8,18 +8,47 @@ import { cvaPageContent } from "./Page.variants";
|
|
|
8
8
|
*/
|
|
9
9
|
export type PageContentLayout = VariantProps<typeof cvaPageContent>["layout"];
|
|
10
10
|
/**
|
|
11
|
-
* The props for the
|
|
11
|
+
* The props for the PageContent component.
|
|
12
12
|
*/
|
|
13
13
|
interface PageContentProps extends CommonProps, Refable<HTMLDivElement> {
|
|
14
|
+
/**
|
|
15
|
+
* The layout mode for the page content area. Controls content arrangement and spacing.
|
|
16
|
+
*/
|
|
14
17
|
layout: PageContentLayout;
|
|
18
|
+
/**
|
|
19
|
+
* The child elements to render inside the page content area.
|
|
20
|
+
*/
|
|
15
21
|
children?: ReactNode;
|
|
16
22
|
}
|
|
17
23
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
24
|
+
* PageContent is the main content area inside a Page.
|
|
25
|
+
* It applies consistent padding to the content section. Must be used within a Page component.
|
|
20
26
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
27
|
+
* ### When to use
|
|
28
|
+
* Use PageContent to wrap the main content of a page, below a `PageHeader`. It provides consistent padding and layout.
|
|
29
|
+
*
|
|
30
|
+
* ### When not to use
|
|
31
|
+
* Do not use PageContent outside of a `Page`. For standalone content wrappers, use `Card` or `CardBody`.
|
|
32
|
+
*
|
|
33
|
+
* @example PageContent inside a Page
|
|
34
|
+
* ```tsx
|
|
35
|
+
* import { Page, PageContent, PageHeader, Card, CardBody, Text } from "@trackunit/react-components";
|
|
36
|
+
*
|
|
37
|
+
* const DetailPage = () => (
|
|
38
|
+
* <Page layout="default">
|
|
39
|
+
* <PageHeader title="Asset Details" />
|
|
40
|
+
* <PageContent layout="default">
|
|
41
|
+
* <Card>
|
|
42
|
+
* <CardBody>
|
|
43
|
+
* <Text>Asset information goes here</Text>
|
|
44
|
+
* </CardBody>
|
|
45
|
+
* </Card>
|
|
46
|
+
* </PageContent>
|
|
47
|
+
* </Page>
|
|
48
|
+
* );
|
|
49
|
+
* ```
|
|
50
|
+
* @param {PageContentProps} props - The props for the PageContent component
|
|
51
|
+
* @returns {ReactElement} PageContent component
|
|
23
52
|
*/
|
|
24
53
|
export declare const PageContent: ({ className, children, "data-testid": dataTestId, layout, ref, }: PageContentProps) => ReactElement;
|
|
25
54
|
export {};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { ReactElement } from "react";
|
|
2
2
|
import { PageHeaderProps } from "./types";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* PageHeader displays the header of a page, providing context about the current location within the application.
|
|
5
|
+
* It supports a title, optional description tooltip, tag, action buttons, KPI metrics, and tabs for in-page navigation.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
* PageHeader
|
|
8
|
-
*
|
|
7
|
+
* ### When to use
|
|
8
|
+
* Use PageHeader at the top of a `Page` to display the page title, description, and primary/secondary actions.
|
|
9
|
+
*
|
|
10
|
+
* ### When not to use
|
|
11
|
+
* Do not use PageHeader for section-level headings within a page. Use `SectionHeader` instead.
|
|
12
|
+
* Do not use for card-level headers — use `CardHeader`.
|
|
9
13
|
*
|
|
10
14
|
* @example Page header with actions
|
|
11
15
|
* ```tsx
|
|
@@ -55,8 +55,37 @@ export interface PaginationProps extends Refable<HTMLDivElement> {
|
|
|
55
55
|
cursorBase?: boolean;
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
|
-
* Pagination
|
|
59
|
-
|
|
58
|
+
* Pagination provides previous/next page navigation with an optional page counter and jump-to-page input.
|
|
59
|
+
* It supports both offset-based pagination (with `pageIndex` and `pageCount`) and cursor-based pagination (with `cursorBase`).
|
|
60
|
+
*
|
|
61
|
+
* ### When to use
|
|
62
|
+
* Use Pagination below a table or list when data is split across multiple pages and the user needs to navigate between them.
|
|
63
|
+
*
|
|
64
|
+
* ### When not to use
|
|
65
|
+
* Do not use Pagination for infinite scroll patterns. Use the `useInfiniteScroll` hook instead.
|
|
66
|
+
*
|
|
67
|
+
* @example Basic offset-based pagination
|
|
68
|
+
* ```tsx
|
|
69
|
+
* import { Pagination } from "@trackunit/react-components";
|
|
70
|
+
* import { useState } from "react";
|
|
71
|
+
*
|
|
72
|
+
* const PaginatedList = () => {
|
|
73
|
+
* const [page, setPage] = useState(0);
|
|
74
|
+
* const totalPages = 10;
|
|
75
|
+
*
|
|
76
|
+
* return (
|
|
77
|
+
* <Pagination
|
|
78
|
+
* pageIndex={page}
|
|
79
|
+
* pageCount={totalPages}
|
|
80
|
+
* canPreviousPage={page > 0}
|
|
81
|
+
* canNextPage={page < totalPages - 1}
|
|
82
|
+
* previousPage={() => setPage(p => p - 1)}
|
|
83
|
+
* nextPage={() => setPage(p => p + 1)}
|
|
84
|
+
* getTranslatedCount={(count) => `of ${count}`}
|
|
85
|
+
* />
|
|
86
|
+
* );
|
|
87
|
+
* };
|
|
88
|
+
* ```
|
|
60
89
|
* @param {PaginationProps} props - The props for the Pagination component
|
|
61
90
|
* @returns {ReactElement} Pagination component
|
|
62
91
|
*/
|
|
@@ -3,16 +3,51 @@ import { CommonProps } from "../../common/CommonProps";
|
|
|
3
3
|
import { Refable } from "../../common/Refable";
|
|
4
4
|
type Point = [number, number];
|
|
5
5
|
export interface PolygonProps extends CommonProps, Refable<SVGSVGElement> {
|
|
6
|
+
/**
|
|
7
|
+
* Array of [x, y] coordinate pairs defining the polygon's vertices. Points are normalized to fit within the given size.
|
|
8
|
+
*/
|
|
6
9
|
points: Array<Point>;
|
|
10
|
+
/**
|
|
11
|
+
* The pixel dimensions (width and height) of the SVG viewport.
|
|
12
|
+
*/
|
|
7
13
|
size: number;
|
|
14
|
+
/**
|
|
15
|
+
* Fill and stroke color of the polygon.
|
|
16
|
+
*
|
|
17
|
+
* @default "black"
|
|
18
|
+
*/
|
|
8
19
|
color?: "white" | "black";
|
|
20
|
+
/**
|
|
21
|
+
* Whether the fill should be semi-transparent (20% opacity) and the stroke slightly transparent (80% opacity).
|
|
22
|
+
*
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
9
25
|
opaque?: boolean;
|
|
10
26
|
}
|
|
11
27
|
/**
|
|
12
|
-
*
|
|
28
|
+
* Polygon renders an SVG polygon from a set of coordinate points. Points are automatically normalized to fit within the specified size.
|
|
29
|
+
* It supports fill/stroke color options and optional opacity for overlay effects.
|
|
13
30
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
31
|
+
* ### When to use
|
|
32
|
+
* Use Polygon for rendering geofence boundaries, map overlays, or any custom shape defined by coordinate points.
|
|
33
|
+
*
|
|
34
|
+
* ### When not to use
|
|
35
|
+
* Do not use Polygon for standard UI elements — use the design system components instead.
|
|
36
|
+
*
|
|
37
|
+
* @example Rendering a triangle
|
|
38
|
+
* ```tsx
|
|
39
|
+
* import { Polygon } from "@trackunit/react-components";
|
|
40
|
+
*
|
|
41
|
+
* const Triangle = () => (
|
|
42
|
+
* <Polygon
|
|
43
|
+
* points={[[0, 100], [50, 0], [100, 100]]}
|
|
44
|
+
* size={64}
|
|
45
|
+
* color="black"
|
|
46
|
+
* />
|
|
47
|
+
* );
|
|
48
|
+
* ```
|
|
49
|
+
* @param {PolygonProps} props - The props for the Polygon component
|
|
50
|
+
* @returns {ReactElement} Polygon component
|
|
16
51
|
*/
|
|
17
52
|
export declare const Polygon: ({ points, size, color, opaque, className, "data-testid": dataTestId, ref, }: PolygonProps) => ReactElement;
|
|
18
53
|
export {};
|
|
@@ -14,14 +14,16 @@ type ModalCallback = {
|
|
|
14
14
|
placement: PopoverPlacement;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* - The context is used to share the state of the popover, such as the open state and the reference element.
|
|
17
|
+
* Popover is a floating overlay that appears relative to a trigger element. It provides a context for
|
|
18
|
+
* PopoverTrigger and PopoverContent children,
|
|
19
|
+
* managing open/close state, positioning, and focus management.
|
|
21
20
|
*
|
|
22
|
-
*
|
|
21
|
+
* ### When to use
|
|
22
|
+
* Use Popover for contextual information, menus, or forms that should appear near a trigger element without navigating away.
|
|
23
23
|
*
|
|
24
|
-
*
|
|
24
|
+
* ### When not to use
|
|
25
|
+
* Do not use Popover for simple text hints — use `Tooltip` instead.
|
|
26
|
+
* For full-screen overlays or blocking dialogs, use a Modal.
|
|
25
27
|
*
|
|
26
28
|
* @example Basic popover with trigger
|
|
27
29
|
* ```tsx
|
|
@@ -37,11 +37,37 @@ export interface PopoverContentProps extends Omit<HTMLProps<HTMLDivElement>, "ch
|
|
|
37
37
|
ref?: Ref<HTMLDivElement>;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* PopoverContent displays the floating content inside a Popover.
|
|
41
|
+
* It renders in a portal and manages focus, positioning, and accessibility. Must be a child of a Popover.
|
|
41
42
|
*
|
|
42
|
-
*
|
|
43
|
-
* in a portal and manages focus, positioning, and accessibility features.
|
|
43
|
+
* The `children` prop can be a ReactNode or a render function that receives a `close` callback to programmatically dismiss the popover.
|
|
44
44
|
*
|
|
45
|
+
* ### When to use
|
|
46
|
+
* Use PopoverContent inside a `Popover` to define what appears in the floating overlay.
|
|
47
|
+
*
|
|
48
|
+
* ### When not to use
|
|
49
|
+
* Do not use PopoverContent outside of a `Popover` context. It relies on `Popover`'s context for positioning and state.
|
|
50
|
+
*
|
|
51
|
+
* @example PopoverContent with close callback
|
|
52
|
+
* ```tsx
|
|
53
|
+
* import { Popover, PopoverTrigger, PopoverContent, Button, Text } from "@trackunit/react-components";
|
|
54
|
+
*
|
|
55
|
+
* const DismissablePopover = () => (
|
|
56
|
+
* <Popover>
|
|
57
|
+
* <PopoverTrigger>
|
|
58
|
+
* <Button variant="secondary">Open</Button>
|
|
59
|
+
* </PopoverTrigger>
|
|
60
|
+
* <PopoverContent>
|
|
61
|
+
* {(close) => (
|
|
62
|
+
* <div className="p-4">
|
|
63
|
+
* <Text>Popover content here</Text>
|
|
64
|
+
* <Button onClick={close} size="small">Done</Button>
|
|
65
|
+
* </div>
|
|
66
|
+
* )}
|
|
67
|
+
* </PopoverContent>
|
|
68
|
+
* </Popover>
|
|
69
|
+
* );
|
|
70
|
+
* ```
|
|
45
71
|
* @param {PopoverContentProps} props - The props for the PopoverContent component
|
|
46
72
|
* @returns {ReactElement} The popover content element
|
|
47
73
|
*/
|
|
@@ -2,19 +2,53 @@ import { ReactElement, ReactNode } from "react";
|
|
|
2
2
|
import { CommonProps } from "../../common/CommonProps";
|
|
3
3
|
import { Refable } from "../../common/Refable";
|
|
4
4
|
export interface PopoverTitleProps extends CommonProps, Refable<HTMLDivElement> {
|
|
5
|
+
/**
|
|
6
|
+
* An optional action element (e.g., a close button or link) rendered to the right of the title.
|
|
7
|
+
*/
|
|
5
8
|
action?: ReactNode;
|
|
6
9
|
/**
|
|
7
10
|
* Whether there should be a divider between the title and the content.
|
|
8
11
|
*/
|
|
9
12
|
divider?: boolean;
|
|
10
13
|
/**
|
|
11
|
-
* The
|
|
14
|
+
* The title text or elements to display.
|
|
12
15
|
*/
|
|
13
16
|
children?: ReactNode;
|
|
14
17
|
}
|
|
15
18
|
/**
|
|
16
|
-
*
|
|
19
|
+
* PopoverTitle renders a styled title bar at the top of a PopoverContent panel.
|
|
20
|
+
* It displays uppercase bold text with an optional action element and divider.
|
|
21
|
+
*
|
|
22
|
+
* ### When to use
|
|
23
|
+
* Use PopoverTitle inside `PopoverContent` when the popover needs a labeled header, optionally with an action (e.g., a close button).
|
|
24
|
+
*
|
|
25
|
+
* ### When not to use
|
|
26
|
+
* Do not use PopoverTitle outside of a `Popover` context. For standalone headings, use `Heading`.
|
|
27
|
+
*
|
|
28
|
+
* @example Popover with titled content
|
|
29
|
+
* ```tsx
|
|
30
|
+
* import { Popover, PopoverTrigger, PopoverContent, PopoverTitle, Button, Text } from "@trackunit/react-components";
|
|
17
31
|
*
|
|
32
|
+
* const TitledPopover = () => (
|
|
33
|
+
* <Popover placement="bottom-start">
|
|
34
|
+
* <PopoverTrigger>
|
|
35
|
+
* <Button variant="secondary">Details</Button>
|
|
36
|
+
* </PopoverTrigger>
|
|
37
|
+
* <PopoverContent>
|
|
38
|
+
* {(close) => (
|
|
39
|
+
* <div className="w-64">
|
|
40
|
+
* <PopoverTitle divider action={<Button variant="ghost" size="small" onClick={close}>Close</Button>}>
|
|
41
|
+
* Asset Info
|
|
42
|
+
* </PopoverTitle>
|
|
43
|
+
* <div className="p-3">
|
|
44
|
+
* <Text size="small">Additional information about this asset.</Text>
|
|
45
|
+
* </div>
|
|
46
|
+
* </div>
|
|
47
|
+
* )}
|
|
48
|
+
* </PopoverContent>
|
|
49
|
+
* </Popover>
|
|
50
|
+
* );
|
|
51
|
+
* ```
|
|
18
52
|
* @param {PopoverTitleProps} props - The props for the PopoverTitle component
|
|
19
53
|
* @returns {ReactElement} PopoverTitle component
|
|
20
54
|
*/
|