@trackunit/react-components 1.17.22 → 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.
Files changed (56) hide show
  1. package/index.cjs.js +1309 -185
  2. package/index.esm.js +1309 -185
  3. package/package.json +1 -1
  4. package/src/components/Badge/Badge.d.ts +13 -6
  5. package/src/components/Card/CardBody.d.ts +38 -3
  6. package/src/components/Card/CardFooter.d.ts +44 -3
  7. package/src/components/Card/CardHeader.d.ts +43 -2
  8. package/src/components/CompletionStatusIndicator/CompletionStatusIndicator.d.ts +19 -10
  9. package/src/components/CopyableText/CopyableText.d.ts +28 -2
  10. package/src/components/DetailsList/DetailsList.d.ts +28 -7
  11. package/src/components/EmptyState/EmptyState.d.ts +24 -0
  12. package/src/components/EmptyValue/EmptyValue.d.ts +19 -1
  13. package/src/components/ExternalLink/ExternalLink.d.ts +35 -4
  14. package/src/components/Heading/Heading.d.ts +22 -1
  15. package/src/components/Highlight/Highlight.d.ts +32 -7
  16. package/src/components/HorizontalOverflowScroller/HorizontalOverflowScroller.d.ts +24 -9
  17. package/src/components/Icon/Icon.d.ts +19 -2
  18. package/src/components/KPI/KPISkeleton.d.ts +23 -2
  19. package/src/components/KPICard/KPICardSkeleton.d.ts +23 -2
  20. package/src/components/ListItem/ListItem.d.ts +25 -3
  21. package/src/components/ListItem/ListItemSkeleton.d.ts +24 -2
  22. package/src/components/Menu/MenuDivider/MenuDivider.d.ts +22 -1
  23. package/src/components/Menu/MenuItem/MenuItem.d.ts +30 -1
  24. package/src/components/Menu/MoreMenu/MoreMenu.d.ts +56 -2
  25. package/src/components/Notice/Notice.d.ts +33 -3
  26. package/src/components/Page/Page.d.ts +38 -2
  27. package/src/components/Page/PageContent.d.ts +34 -5
  28. package/src/components/PageHeader/PageHeader.d.ts +8 -4
  29. package/src/components/Pagination/Pagination.d.ts +31 -2
  30. package/src/components/Polygon/Polygon.d.ts +38 -3
  31. package/src/components/Popover/Popover.d.ts +8 -6
  32. package/src/components/Popover/PopoverContent.d.ts +29 -3
  33. package/src/components/Popover/PopoverTitle.d.ts +36 -2
  34. package/src/components/Popover/PopoverTrigger.d.ts +35 -4
  35. package/src/components/Portal/Portal.d.ts +35 -4
  36. package/src/components/PreferenceCard/PreferenceCard.d.ts +25 -3
  37. package/src/components/PreferenceCard/PreferenceCardSkeleton.d.ts +23 -2
  38. package/src/components/Prompt/Prompt.d.ts +42 -8
  39. package/src/components/SectionHeader/SectionHeader.d.ts +23 -3
  40. package/src/components/Sidebar/Sidebar.d.ts +12 -5
  41. package/src/components/Skeleton/SkeletonBlock/SkeletonBlock.d.ts +21 -5
  42. package/src/components/Skeleton/SkeletonLabel/SkeletonLabel.d.ts +21 -5
  43. package/src/components/SkeletonLines/SkeletonLines.d.ts +8 -6
  44. package/src/components/Spacer/Spacer.d.ts +17 -10
  45. package/src/components/Spinner/Spinner.d.ts +27 -6
  46. package/src/components/Tabs/Tab.d.ts +29 -2
  47. package/src/components/Tabs/TabContent.d.ts +46 -1
  48. package/src/components/Tabs/TabList.d.ts +29 -1
  49. package/src/components/Tabs/Tabs.d.ts +14 -1
  50. package/src/components/Tag/Tag.d.ts +13 -6
  51. package/src/components/Text/Text.d.ts +28 -3
  52. package/src/components/ToggleGroup/ToggleGroup.d.ts +30 -1
  53. package/src/components/ValueBar/ValueBar.d.ts +38 -2
  54. package/src/components/ZStack/ZStack.d.ts +23 -4
  55. package/src/components/buttons/Button/Button.d.ts +1 -1
  56. package/src/components/buttons/StarButton/StarButton.d.ts +24 -1
@@ -1,19 +1,50 @@
1
1
  import { HTMLProps, ReactElement, ReactNode, Ref } from "react";
2
2
  interface PopoverTriggerProps extends HTMLProps<HTMLElement> {
3
3
  /**
4
- * When enabled the trigger will be rendered as a button
5
- * note that not all elements are valid children of a button
4
+ * The element that acts as the trigger. Typically a Button or IconButton.
5
+ * When `renderButton` is false (default), the child element is cloned with popover props.
6
+ * When `renderButton` is true, children are wrapped in a Button.
6
7
  */
7
8
  children: ReactNode;
9
+ /**
10
+ * When true, wraps children in a default Button element. Use false (default) when passing
11
+ * your own Button or interactive element as children.
12
+ */
8
13
  renderButton?: boolean;
9
14
  /**
10
- * A ref for the component
15
+ * A ref for the component.
11
16
  */
12
17
  ref?: Ref<HTMLElement>;
13
18
  }
14
19
  /**
15
- * The PopoverTrigger component is used to trigger the popover.
20
+ * PopoverTrigger is the clickable element that opens or closes a Popover.
21
+ * It must be used as a direct child of a Popover component. By default, it clones the child element and attaches popover behavior.
22
+ * Set `renderButton` to true to wrap children in a default Button.
23
+ *
24
+ * ### When to use
25
+ * Use PopoverTrigger inside a `Popover` to designate which element opens the popover overlay.
26
+ *
27
+ * ### When not to use
28
+ * Do not use PopoverTrigger outside of a `Popover` context. It relies on `Popover`'s context for state management.
29
+ *
30
+ * @example PopoverTrigger with a custom button
31
+ * ```tsx
32
+ * import { Popover, PopoverTrigger, PopoverContent, IconButton, Icon } from "@trackunit/react-components";
16
33
  *
34
+ * const IconPopover = () => (
35
+ * <Popover placement="bottom">
36
+ * <PopoverTrigger>
37
+ * <IconButton
38
+ * icon={<Icon name="InformationCircle" size="small" />}
39
+ * variant="ghost"
40
+ * />
41
+ * </PopoverTrigger>
42
+ * <PopoverContent>
43
+ * <div className="p-3">Helpful information</div>
44
+ * </PopoverContent>
45
+ * </Popover>
46
+ * );
47
+ * ```
17
48
  * @param {PopoverTriggerProps} props - The props for the PopoverTrigger component
18
49
  * @returns {ReactElement} PopoverTrigger component
19
50
  */
@@ -2,9 +2,40 @@ import { FloatingPortalProps } from "@floating-ui/react";
2
2
  import { ReactElement } from "react";
3
3
  export type PortalProps = FloatingPortalProps;
4
4
  /**
5
- * Portals the floating element into a given container element
6
- * By default they're portalled into an z-index isolated div in
7
- * document body -> div#portal-container.
8
- * alongside other portalled elements.
5
+ * Portal renders its children into a separate DOM node, outside the normal React tree hierarchy.
6
+ * By default, content is portalled into a z-index-isolated `div#portal-container` in the document body.
7
+ * This is used internally by Popover, Tooltip, and other overlay components.
8
+ *
9
+ * ### When to use
10
+ * Use Portal when you need to render content (modals, popovers, tooltips) outside its parent's DOM hierarchy to avoid z-index or overflow clipping issues.
11
+ *
12
+ * ### When not to use
13
+ * Do not use Portal for regular content rendering. Most overlay components (`Popover`, `Tooltip`) already use Portal internally.
14
+ *
15
+ * @example Rendering into a specific container
16
+ * ```tsx
17
+ * import { Portal } from "@trackunit/react-components";
18
+ *
19
+ * const PortalledContent = () => (
20
+ * <Portal root={document.getElementById('sidebar-container')}>
21
+ * <div className="p-4">This content renders in #sidebar-container</div>
22
+ * </Portal>
23
+ * );
24
+ * ```
25
+ * @example Default portal into document body
26
+ * ```tsx
27
+ * import { Portal } from "@trackunit/react-components";
28
+ *
29
+ * const FloatingContent = ({ isVisible }: { isVisible: boolean }) => (
30
+ * isVisible ? (
31
+ * <Portal>
32
+ * <div className="fixed bottom-4 right-4 bg-white p-4 rounded-lg shadow-lg">
33
+ * Toast notification content
34
+ * </div>
35
+ * </Portal>
36
+ * ) : null
37
+ * );
38
+ * @param {PortalProps} props - The props for the Portal component
39
+ * @returns {ReactElement} Portal component
9
40
  */
10
41
  export declare const Portal: (props: FloatingPortalProps) => ReactElement;
@@ -63,9 +63,31 @@ export interface PreferenceCardProps extends CommonProps, Refable<HTMLDivElement
63
63
  children?: ReactNode;
64
64
  }
65
65
  /**
66
- * PreferenceCard is a flexible component for displaying add-ons or settings configuration options
67
- * with various states and visual treatments.
68
- * It is recommended to be primarily used as an input component, as it supports checkboxes, radio buttons and toggles.
66
+ * PreferenceCard is a flexible component for displaying add-on options or settings with an optional input control (checkbox, radio, toggle).
67
+ * It supports icons/images, titles with tags, descriptions, and custom child content for advanced layouts.
68
+ *
69
+ * ### When to use
70
+ * Use PreferenceCard for settings pages, feature toggles, or plan selection where each option needs a title, description, and an input control.
71
+ *
72
+ * ### When not to use
73
+ * Do not use PreferenceCard for data display — use `Card`.
74
+ * Do not use for simple toggle settings — use a standalone toggle switch.
75
+ *
76
+ * @example PreferenceCard with checkbox input
77
+ * ```tsx
78
+ * import { PreferenceCard } from "@trackunit/react-components";
79
+ *
80
+ * const FeatureToggle = () => (
81
+ * <PreferenceCard
82
+ * title="Email Notifications"
83
+ * description="Receive email alerts for asset status changes"
84
+ * icon={{ type: "icon", name: "EnvelopeOpen", containerClassName: "bg-primary-100" }}
85
+ * input={<input type="checkbox" />}
86
+ * />
87
+ * );
88
+ * ```
89
+ * @param {PreferenceCardProps} props - The props for the PreferenceCard component
90
+ * @returns {ReactNode} PreferenceCard component
69
91
  */
70
92
  export declare const PreferenceCard: ({ title, description, icon, input, titleTag, cardTag, disabled, className, "data-testid": dataTestId, children, ref: forwardedRef, }: PreferenceCardProps) => ReactNode;
71
93
  export {};
@@ -20,7 +20,28 @@ export interface PreferenceCardSkeletonProps extends Refable<HTMLDivElement> {
20
20
  hasInput?: boolean;
21
21
  }
22
22
  /**
23
- * Skeleton loading indicator that mimics the PreferenceCard component structure.
24
- * Uses the same grid layout, spacing, and visual hierarchy as PreferenceCard.
23
+ * PreferenceCardSkeleton is a loading placeholder that mimics the layout of a PreferenceCard.
24
+ * It renders skeleton lines for the title, description, and optional slots (icon, tags, input).
25
+ * Configure the boolean flags to match the shape of your actual PreferenceCards.
26
+ *
27
+ * ### When to use
28
+ * Use PreferenceCardSkeleton while preference/settings data is loading to maintain layout stability and reduce perceived load time.
29
+ *
30
+ * ### When not to use
31
+ * Do not use PreferenceCardSkeleton for generic loading — use `SkeletonBlock` or `SkeletonLabel`.
32
+ *
33
+ * @example PreferenceCard skeleton with icon and input
34
+ * ```tsx
35
+ * import { PreferenceCardSkeleton } from "@trackunit/react-components";
36
+ *
37
+ * const LoadingSettings = () => (
38
+ * <div className="flex flex-col gap-3">
39
+ * <PreferenceCardSkeleton hasIcon hasInput />
40
+ * <PreferenceCardSkeleton hasIcon hasInput />
41
+ * </div>
42
+ * );
43
+ * ```
44
+ * @param {PreferenceCardSkeletonProps} props - The props for the PreferenceCardSkeleton component
45
+ * @returns {ReactElement} PreferenceCardSkeleton component
25
46
  */
26
47
  export declare const PreferenceCardSkeleton: ({ hasIcon, hasTitleTag, hasCardTag, hasInput, ref, }: PreferenceCardSkeletonProps) => ReactElement;
@@ -3,18 +3,52 @@ interface PromptProps {
3
3
  message: string;
4
4
  }
5
5
  /**
6
- * The usePrompt hook.
7
-
8
- * @param {string} message -
9
- * @param {boolean} when -
10
- * @returns {void} void
6
+ * usePrompt displays a browser confirmation dialog when the user tries to navigate away from the current page.
7
+ * It blocks both in-app navigation (via TanStack Router's `useBlocker`) and browser-level navigation (via `beforeunload`).
8
+ *
9
+ * ### When to use
10
+ * Use usePrompt when the user has unsaved changes (e.g., in a form) and should be warned before navigating away.
11
+ *
12
+ * ### When not to use
13
+ * Do not use usePrompt for non-destructive navigation. Only use when there is genuinely unsaved state that would be lost.
14
+ *
15
+ * @example Warn user about unsaved form changes
16
+ * ```tsx
17
+ * import { usePrompt } from "@trackunit/react-components";
18
+ *
19
+ * const EditForm = ({ isDirty }: { isDirty: boolean }) => {
20
+ * usePrompt("You have unsaved changes. Are you sure you want to leave?", isDirty);
21
+ * return <form>...</form>;
22
+ * };
23
+ * ```
24
+ * @param {string} message - The confirmation message shown to the user
25
+ * @param {boolean} when - Whether the prompt should be active. Defaults to true.
26
+ * @returns {void}
11
27
  */
12
28
  export declare const usePrompt: (message: string, when?: boolean) => void;
13
29
  /**
14
- * The Prompt function.
30
+ * Prompt is a declarative component wrapper around the `usePrompt` hook. It displays a browser confirmation dialog
31
+ * when the user tries to navigate away while `when` is true.
32
+ *
33
+ * ### When to use
34
+ * Use Prompt when you prefer a declarative approach to navigation blocking (instead of the `usePrompt` hook).
35
+ *
36
+ * ### When not to use
37
+ * Do not use Prompt when `when` is always false — simply omit it.
38
+ *
39
+ * @example Declarative prompt for unsaved changes
40
+ * ```tsx
41
+ * import { Prompt } from "@trackunit/react-components";
15
42
  *
16
- * @param {PromptProps} Props -
17
- * @returns {void} void
43
+ * const EditPage = ({ hasUnsavedChanges }: { hasUnsavedChanges: boolean }) => (
44
+ * <>
45
+ * <Prompt when={hasUnsavedChanges} message="Discard unsaved changes?" />
46
+ * <form>...</form>
47
+ * </>
48
+ * );
49
+ * ```
50
+ * @param {PromptProps} props - The props for the Prompt component
51
+ * @returns {null} Renders nothing; only activates the navigation prompt
18
52
  */
19
53
  export declare const Prompt: ({ when, message }: PromptProps) => null;
20
54
  export {};
@@ -16,9 +16,29 @@ export interface SectionHeaderProps extends CommonProps, Refable<HTMLDivElement>
16
16
  addons?: ReactNode;
17
17
  }
18
18
  /**
19
- * The SectionHeader component is used on sections to set the section title.
20
-
21
- * @param {SectionHeaderProps} props - The props for the section header component
19
+ * SectionHeader renders a section title with an optional subtitle and addon elements (e.g., action buttons, status indicators).
20
+ * It also sets the document title via React Helmet for SEO and browser tab labeling.
21
+ *
22
+ * ### When to use
23
+ * Use SectionHeader to label a distinct section within a page, below a `PageHeader`. It provides consistent heading styles and an optional subtitle.
24
+ *
25
+ * ### When not to use
26
+ * Do not use SectionHeader for the main page title — use `PageHeader`.
27
+ * Do not use for card-level headers — use `CardHeader`.
28
+ *
29
+ * @example Section header with subtitle and addon
30
+ * ```tsx
31
+ * import { SectionHeader, Button } from "@trackunit/react-components";
32
+ *
33
+ * const AssetSection = () => (
34
+ * <SectionHeader
35
+ * title="Maintenance Schedule"
36
+ * subtitle="Upcoming and past maintenance events"
37
+ * addons={<Button variant="secondary" size="small">Add Event</Button>}
38
+ * />
39
+ * );
40
+ * ```
41
+ * @param {SectionHeaderProps} props - The props for the SectionHeader component
22
42
  * @returns {ReactElement} SectionHeader component
23
43
  */
24
44
  export declare const SectionHeader: ({ title, subtitle, "data-testid": dataTestId, addons, ref, }: SectionHeaderProps) => ReactElement;
@@ -46,12 +46,19 @@ export interface SidebarProps extends CommonProps, Refable<HTMLDivElement> {
46
46
  menuListProps?: Omit<ComponentProps<typeof MenuList>, "children">;
47
47
  }
48
48
  /**
49
- * The sidebar components is used to render a responsive sidebar.
50
- * - The sidebar will be rendered horizontally until a given breakpoint where it will be stacked vertically.
51
- * - The sidebar hides items that does not fit in the sidebar and show them in a more menu.
52
- * - **_The sidebar is just a wrapper. You are responsible for styling the children._**
49
+ * Sidebar renders a responsive horizontal/vertical navigation bar that automatically collapses overflowing items into a MoreMenu.
50
+ * It is rendered horizontally until a given breakpoint, then stacks vertically.
53
51
  *
54
- * When using this component make sure to add `setupIntersectionObserver();` to your jest.setup.ts file.
52
+ * **Important:** The Sidebar is just a layout wrapper. You are responsible for styling the children.
53
+ * For the overflow functionality, use `min-w-[*]` or `flex-shrink-0` on child elements.
54
+ *
55
+ * When testing, add `setupIntersectionObserver();` to your `jest.setup.ts` file.
56
+ *
57
+ * ### When to use
58
+ * Use Sidebar for secondary in-page navigation (e.g., switching between views within a page). Works well with `Tabs` for page-level navigation.
59
+ *
60
+ * ### When not to use
61
+ * Do not use Sidebar for primary app navigation (the main menu). For top-level navigation, use the app shell navigation.
55
62
  *
56
63
  * @example Responsive sidebar with navigation items
57
64
  * ```tsx
@@ -38,12 +38,28 @@ export type SkeletonBlockProps = CommonProps & Refable<HTMLDivElement> & {
38
38
  children?: ReactNode;
39
39
  };
40
40
  /**
41
- * Display a single placeholder block for shape-based elements before data gets loaded to reduce load-time frustration.
41
+ * SkeletonBlock renders a single animated placeholder block for shape-based elements (images, icons, buttons, avatars)
42
+ * before data is loaded. It uses exact height and width values to match the element it replaces.
42
43
  *
43
- * Fills the full height for images, badges, buttons, avatars, and other shape-based elements.
44
- * Uses numbers or CSS length values for height.
44
+ * ### When to use
45
+ * Use SkeletonBlock for loading placeholders of shape-based UI elements: images, icons, badges, buttons, avatars, thumbnails.
45
46
  *
46
- * For text content, use SkeletonLabel component instead.
47
- * For multiple text lines, use SkeletonLines component instead.
47
+ * ### When not to use
48
+ * For text content, use `SkeletonLabel` which accounts for text line-height margins.
49
+ * For multiple text lines, use `SkeletonLines`.
50
+ *
51
+ * @example Skeleton block for an avatar and button
52
+ * ```tsx
53
+ * import { SkeletonBlock } from "@trackunit/react-components";
54
+ *
55
+ * const AvatarSkeleton = () => (
56
+ * <div className="flex items-center gap-3">
57
+ * <SkeletonBlock height={40} width={40} className="rounded-full" />
58
+ * <SkeletonBlock height={32} width={120} className="rounded-md" />
59
+ * </div>
60
+ * );
61
+ * ```
62
+ * @param {SkeletonBlockProps} props - The props for the SkeletonBlock component
63
+ * @returns {ReactElement} SkeletonBlock component
48
64
  */
49
65
  export declare const SkeletonBlock: import("react").NamedExoticComponent<SkeletonBlockProps>;
@@ -41,12 +41,28 @@ export type SkeletonLabelProps = CommonProps & Refable<HTMLDivElement> & {
41
41
  children?: ReactNode;
42
42
  };
43
43
  /**
44
- * Display a single placeholder line for text content before data gets loaded to reduce load-time frustration.
44
+ * SkeletonLabel renders a single animated placeholder line for text content. It uses text-size keys (text-xs, text-sm, text-base, etc.)
45
+ * to match the visual cap-height of actual text, with appropriate vertical margins to maintain line-height alignment.
45
46
  *
46
- * Reduces height and adds vertical margins to match the visual space text occupies within its line-height.
47
- * Uses text-size keys (text-xs, text-sm, text-base, etc.) for height to match actual text elements.
47
+ * ### When to use
48
+ * Use SkeletonLabel as a loading placeholder for single text lines: labels, titles, descriptions, values.
48
49
  *
49
- * For multiple text lines, use SkeletonLines component instead.
50
- * For shape-based elements (images, badges, buttons), use SkeletonBlock component instead.
50
+ * ### When not to use
51
+ * For multiple text lines, use `SkeletonLines`.
52
+ * For shape-based elements (images, icons, avatars), use `SkeletonBlock`.
53
+ *
54
+ * @example Skeleton label for a title and description
55
+ * ```tsx
56
+ * import { SkeletonLabel } from "@trackunit/react-components";
57
+ *
58
+ * const TextSkeleton = () => (
59
+ * <div className="flex flex-col gap-1">
60
+ * <SkeletonLabel textSize="text-lg" width={200} />
61
+ * <SkeletonLabel textSize="text-sm" width="80%" />
62
+ * </div>
63
+ * );
64
+ * ```
65
+ * @param {SkeletonLabelProps} props - The props for the SkeletonLabel component
66
+ * @returns {ReactElement} SkeletonLabel component
51
67
  */
52
68
  export declare const SkeletonLabel: import("react").NamedExoticComponent<SkeletonLabelProps>;
@@ -122,14 +122,16 @@ type PresetSkeletonLinesProps = CommonProps & Refable<HTMLDivElement> & {
122
122
  */
123
123
  export type SkeletonLinesProps = UniformSkeletonLinesProps | CustomSkeletonLinesProps | PresetSkeletonLinesProps;
124
124
  /**
125
- * Display multiple placeholder lines before data gets loaded to reduce load-time frustration.
125
+ * SkeletonLines renders multiple animated placeholder text lines before data loads.
126
+ * It supports three modes: uniform (identical lines), custom (per-line config), and preset (common patterns like paragraphs or articles).
127
+ * Built on top of SkeletonLabel for text-specific margins and sizing.
126
128
  *
127
- * Supports three modes:
128
- * - **Uniform mode** (default): Display identical lines using `count` prop
129
- * - **Custom mode**: Display customized lines with per-line configuration using `variant="custom"` and `lines` prop
130
- * - **Preset mode**: Display common patterns using `variant="preset"` and `preset` name
129
+ * ### When to use
130
+ * Use SkeletonLines for loading placeholders of multi-line text content: paragraphs, descriptions, articles, or any text block.
131
131
  *
132
- * Built on top of the [SkeletonLabel](?path=/docs/components-loading-states-skeletonlabel--docs) component for text-specific margins and sizing.
132
+ * ### When not to use
133
+ * For single text lines, use `SkeletonLabel`.
134
+ * For shape-based elements, use `SkeletonBlock`.
133
135
  *
134
136
  * @example
135
137
  * // Uniform lines (simple mode)
@@ -14,18 +14,25 @@ export interface SpacerProps extends CommonProps, Refable<HTMLDivElement> {
14
14
  border?: boolean;
15
15
  }
16
16
  /**
17
- * The Spacer component is used for adding a bit of space in the ui.
17
+ * Spacer adds vertical whitespace between elements. It can optionally render a visible border line as a divider.
18
18
  *
19
- * @example basic usage
19
+ * ### When to use
20
+ * Use Spacer to add consistent vertical gaps between sections or to render a horizontal divider line.
21
+ *
22
+ * ### When not to use
23
+ * Do not use Spacer for horizontal gaps — use Tailwind flex/grid gap utilities. Do not use for structural layout — use CSS grid or flex.
24
+ *
25
+ * @example Spacer as a divider
20
26
  * ```tsx
21
- * import { Spacer } from "@trackunit/react-components";
22
- * const MySpacer = () => {
23
- * return (
24
- * <div>
25
- * <Spacer size="small" border data-testid="my-spacer-testid" />
26
- * </div>
27
- * );
28
- * };
27
+ * import { Spacer, Text } from "@trackunit/react-components";
28
+ *
29
+ * const DividedSections = () => (
30
+ * <div>
31
+ * <Text>Section 1 content</Text>
32
+ * <Spacer size="medium" border />
33
+ * <Text>Section 2 content</Text>
34
+ * </div>
35
+ * );
29
36
  * ```
30
37
  * @param {SpacerProps} props - The props for the Spacer component
31
38
  * @returns {ReactElement} Spacer component
@@ -28,16 +28,37 @@ export interface SpinnerProps extends CommonProps, Refable<HTMLDivElement> {
28
28
  label?: string;
29
29
  }
30
30
  /**
31
- * The spinner component provides visual feedback that data is being processed.
31
+ * Spinner provides visual feedback that data is being processed. It reassures users that their action is being handled
32
+ * during short operations (1-5 seconds) such as saving, loading, or refreshing data.
32
33
  *
33
- * Spinners are used when performing actions. They notify to the user that their request is being processed. Although they do not provide details about what is occurring on the back-end, they reassure the user that their action is being processed.
34
+ * ### When to use
35
+ * Use Spinner for short-duration loading states: button actions, table refreshes, inline data fetches, or modal content loading.
34
36
  *
35
- * Common actions that benefit from spinners include any create, update, or delete actions that may have a lot of data to process. It can be used in a table, after a primary or secondary button click, or even in a modal.
37
+ * ### When not to use
38
+ * Do not use Spinner for long loading states where content structure is known — use `SkeletonBlock` or `SkeletonLabel` instead.
39
+ * Do not use Spinner for full-page loading — use `EmptyState` with `loading` prop.
36
40
  *
37
- * Use a spinner component for any action that cannot be performed instantly and will only require a short time (between 1 to 5 seconds) to process.
41
+ * @example Centered spinner during data load
42
+ * ```tsx
43
+ * import { Spinner } from "@trackunit/react-components";
38
44
  *
39
- * Use when retrieving or refreshing small data amounts, such as status.
40
-
45
+ * const LoadingContent = () => (
46
+ * <div className="h-64">
47
+ * <Spinner centering="centered" label="Loading assets..." />
48
+ * </div>
49
+ * );
50
+ * ```
51
+ * @example Small inline spinner
52
+ * ```tsx
53
+ * import { Spinner } from "@trackunit/react-components";
54
+ *
55
+ * const InlineLoading = () => (
56
+ * <div className="flex items-center gap-2">
57
+ * <Spinner size="small" centering="vertically" />
58
+ * <span>Saving...</span>
59
+ * </div>
60
+ * );
61
+ * ```
41
62
  * @param {SpinnerProps} props - The props for the Spinner component
42
63
  * @returns {ReactElement} Spinner component
43
64
  */
@@ -41,7 +41,34 @@ export interface TabProps extends TabsTriggerProps, Refable<HTMLButtonElement> {
41
41
  appendTabStylesToChildIfAsChild?: boolean;
42
42
  }
43
43
  /**
44
- * Wrapper for radix tab component.
45
- * We add a custom implementation of the asChild prop to make it easy to make the child element look like other tabs.
44
+ * Tab is an individual tab trigger within a TabList.
45
+ * Each Tab requires a unique `value` prop that corresponds to a TabContent with the same value.
46
+ * Supports optional icons, suffixes (e.g., badges), and rendering as a custom child element via `asChild`.
47
+ *
48
+ * ### When to use
49
+ * Use Tab inside a `TabList` to create clickable tab triggers. Each Tab maps to a `TabContent` panel.
50
+ *
51
+ * ### When not to use
52
+ * Do not use Tab outside of a `TabList`/`Tabs` context. For standalone buttons, use `Button`.
53
+ *
54
+ * @example Tab with icon and badge suffix
55
+ * ```tsx
56
+ * import { Tabs, TabList, Tab, TabContent, Badge } from "@trackunit/react-components";
57
+ *
58
+ * const TabsWithBadge = () => (
59
+ * <Tabs defaultValue="alerts">
60
+ * <TabList>
61
+ * <Tab value="alerts" iconName="Bell" suffix={<Badge count={3} color="danger" />}>
62
+ * Alerts
63
+ * </Tab>
64
+ * <Tab value="history" iconName="Clock">History</Tab>
65
+ * </TabList>
66
+ * <TabContent value="alerts">Active alerts</TabContent>
67
+ * <TabContent value="history">Event history</TabContent>
68
+ * </Tabs>
69
+ * );
70
+ * ```
71
+ * @param {TabProps} props - The props for the Tab component
72
+ * @returns {ReactElement} Tab component
46
73
  */
47
74
  export declare const Tab: ({ value, isFullWidth, iconName, "data-testid": dataTestId, className, children, suffix, asChild, appendTabStylesToChildIfAsChild, ref, ...rest }: TabProps) => ReactElement;
@@ -3,13 +3,58 @@ import { IconName } from "@trackunit/ui-icons";
3
3
  import { ReactElement, ReactNode } from "react";
4
4
  import { Refable } from "../../common/Refable";
5
5
  export interface TabContentProps extends TabsContentProps, Refable<HTMLDivElement> {
6
+ /**
7
+ * A custom class name to be attached to the content wrapper element.
8
+ */
6
9
  className?: string;
10
+ /**
11
+ * An ID that can be used in tests to locate the component. A "-content" suffix is appended automatically.
12
+ */
7
13
  "data-testid"?: string;
14
+ /**
15
+ * The content to render when this tab panel is active.
16
+ */
8
17
  children?: ReactNode;
18
+ /**
19
+ * An optional suffix element, typically a badge or icon, displayed alongside the tab content.
20
+ */
9
21
  suffix?: ReactNode;
22
+ /**
23
+ * The name of an icon to associate with this tab content panel.
24
+ */
10
25
  iconName?: IconName;
11
26
  }
12
27
  /**
13
- * Wrapper for radix tab content component.
28
+ * TabContent is the content panel displayed when its corresponding Tab is active.
29
+ * Each TabContent must have a `value` prop that matches the `value` of its corresponding Tab trigger.
30
+ * TabContent is only rendered when its tab is selected (unless `forceMount` is set).
31
+ *
32
+ * ### When to use
33
+ * Use TabContent inside a `Tabs` component, one for each `Tab` trigger.
34
+ *
35
+ * ### When not to use
36
+ * Do not use TabContent outside of a `Tabs` context. For conditionally shown content, use standard conditional rendering.
37
+ *
38
+ * @example Tabs with styled content panels
39
+ * ```tsx
40
+ * import { Tabs, TabList, Tab, TabContent, Text } from "@trackunit/react-components";
41
+ *
42
+ * const AssetTabs = () => (
43
+ * <Tabs defaultValue="overview">
44
+ * <TabList>
45
+ * <Tab value="overview">Overview</Tab>
46
+ * <Tab value="maintenance">Maintenance</Tab>
47
+ * </TabList>
48
+ * <TabContent value="overview">
49
+ * <Text>Asset overview information</Text>
50
+ * </TabContent>
51
+ * <TabContent value="maintenance">
52
+ * <Text>Maintenance schedule and history</Text>
53
+ * </TabContent>
54
+ * </Tabs>
55
+ * );
56
+ * ```
57
+ * @param {TabContentProps} props - The props for the TabContent component
58
+ * @returns {ReactElement} TabContent component
14
59
  */
15
60
  export declare const TabContent: ({ className, "data-testid": dataTestId, children, ref, ...rest }: TabContentProps) => ReactElement;
@@ -23,6 +23,34 @@ export interface TabListProps extends TabsListProps, Refable<HTMLDivElement> {
23
23
  autoScrollToActive?: boolean;
24
24
  }
25
25
  /**
26
- * Wrapper for radix tab list component.
26
+ * TabList is the container for Tab triggers inside a Tabs component.
27
+ * It renders a horizontal row of tab triggers and handles horizontal scroll behavior when tabs overflow.
28
+ * By default, it auto-scrolls the active tab into view.
29
+ *
30
+ * ### When to use
31
+ * Use TabList as a direct child of `Tabs` to wrap the `Tab` triggers. It handles layout and scrolling.
32
+ *
33
+ * ### When not to use
34
+ * Do not use TabList outside of a `Tabs` context. For horizontal navigation lists, use a standard nav element.
35
+ *
36
+ * @example TabList with auto-scroll disabled
37
+ * ```tsx
38
+ * import { Tabs, TabList, Tab, TabContent } from "@trackunit/react-components";
39
+ *
40
+ * const StaticTabs = () => (
41
+ * <Tabs defaultValue="first">
42
+ * <TabList autoScrollToActive={false}>
43
+ * <Tab value="first">First</Tab>
44
+ * <Tab value="second">Second</Tab>
45
+ * <Tab value="third">Third</Tab>
46
+ * </TabList>
47
+ * <TabContent value="first">First panel</TabContent>
48
+ * <TabContent value="second">Second panel</TabContent>
49
+ * <TabContent value="third">Third panel</TabContent>
50
+ * </Tabs>
51
+ * );
52
+ * ```
53
+ * @param {TabListProps} props - The props for the TabList component
54
+ * @returns {ReactElement} TabList component
27
55
  */
28
56
  export declare const TabList: ({ className, "data-testid": dataTestId, children, autoScrollToActive, ref, ...rest }: TabListProps) => ReactElement;
@@ -24,7 +24,18 @@ export interface TabsProps extends TabsRootProps, Refable<HTMLDivElement> {
24
24
  "data-testid"?: string;
25
25
  }
26
26
  /**
27
- * Tabs are used to group different but related content, allowing users to navigate views without leaving the page. They always contain at least two items and one tab is active at a time. Tabs can be used on full page layouts or in components such as modals or tables.
27
+ * Tabs group different but related content, allowing users to navigate views without leaving the page.
28
+ * They always contain at least two items and one tab is active at a time.
29
+ * Tabs can be used on full page layouts or in components such as modals or tables.
30
+ *
31
+ * Compose Tabs with TabList, Tab, and TabContent.
32
+ *
33
+ * ### When to use
34
+ * Use tabs to switch between related content sections within the same context (e.g., different views of an asset, or settings categories).
35
+ *
36
+ * ### When not to use
37
+ * Do not use tabs for primary navigation between unrelated pages. Use `Sidebar` or route-based navigation instead.
38
+ * Avoid tabs when there is only one content panel — just show the content directly.
28
39
  *
29
40
  * @example Basic tabs with content panels
30
41
  * ```tsx
@@ -58,5 +69,7 @@ export interface TabsProps extends TabsRootProps, Refable<HTMLDivElement> {
58
69
  * </Tabs>
59
70
  * );
60
71
  * ```
72
+ * @param {TabsProps} props - The props for the Tabs component
73
+ * @returns {ReactElement} Tabs component
61
74
  */
62
75
  export declare const Tabs: ({ children, forceRender, className, "data-testid": dataTestId, fullWidth, ref, ...rest }: TabsProps) => ReactElement;