@trackunit/react-components 1.10.5 → 1.10.7
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 +127 -63
- package/index.esm.js +127 -63
- package/package.json +1 -1
- package/src/components/PageHeader/PageHeader.d.ts +1 -1
- package/src/components/PageHeader/components/PageHeaderSecondaryActions.d.ts +8 -5
- package/src/components/PageHeader/types.d.ts +42 -19
- package/src/hooks/useContainerBreakpoints.d.ts +7 -1
- package/src/hooks/useContinuousTimeout.d.ts +1 -1
- package/src/hooks/useDevicePixelRatio.d.ts +6 -0
- package/src/hooks/useGeometry.d.ts +10 -8
- package/src/hooks/useInfiniteScroll.d.ts +3 -1
- package/src/hooks/useIsTextTruncated.d.ts +7 -1
- package/src/hooks/useIsTextWrapping.d.ts +7 -1
- package/src/hooks/useScrollDetection.d.ts +2 -1
- package/src/hooks/useTimeout.d.ts +1 -1
- package/src/hooks/useViewportBreakpoints.d.ts +7 -1
- package/src/hooks/useWindowActivity.d.ts +2 -1
|
@@ -30,23 +30,19 @@ export type PageHeaderPrimaryActionType = PageHeaderActionType & {
|
|
|
30
30
|
};
|
|
31
31
|
interface BasePageHeaderProps extends CommonProps {
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* Main title of the page.
|
|
34
34
|
*/
|
|
35
35
|
title: string | ReactNode;
|
|
36
36
|
/**
|
|
37
|
-
* The description to be displayed inside the
|
|
37
|
+
* The description to be displayed inside the tooltip for the title.
|
|
38
38
|
*/
|
|
39
39
|
description?: string | ReactNode;
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
42
|
-
*/
|
|
43
|
-
primaryAction?: PageHeaderPrimaryActionType;
|
|
44
|
-
/**
|
|
45
|
-
* A tag that is displayed on the side of the header.
|
|
41
|
+
* A tag that can be displayed next to the title.
|
|
46
42
|
*/
|
|
47
43
|
tagLabel?: string;
|
|
48
44
|
/**
|
|
49
|
-
*
|
|
45
|
+
* The color value of the tag component.
|
|
50
46
|
*/
|
|
51
47
|
tagColor?: TagColors;
|
|
52
48
|
/**
|
|
@@ -58,12 +54,12 @@ interface BasePageHeaderProps extends CommonProps {
|
|
|
58
54
|
*/
|
|
59
55
|
showLoading?: boolean;
|
|
60
56
|
/**
|
|
61
|
-
* The link to the previous page
|
|
62
|
-
* an IconButton component to the left of the
|
|
57
|
+
* The link to the previous page that will be rendered inside
|
|
58
|
+
* an IconButton component to the left of the title. Allows the user to navigate back to the previous page.
|
|
63
59
|
*/
|
|
64
60
|
backTo?: string;
|
|
65
61
|
/**
|
|
66
|
-
* The icon
|
|
62
|
+
* The icon of the tooltip besides the title. Can be used to display a tooltip with more information about the page.
|
|
67
63
|
*/
|
|
68
64
|
descriptionIcon?: IconName;
|
|
69
65
|
/**
|
|
@@ -71,13 +67,40 @@ interface BasePageHeaderProps extends CommonProps {
|
|
|
71
67
|
*/
|
|
72
68
|
tabsList?: ReactElement<TabListProps>;
|
|
73
69
|
}
|
|
74
|
-
|
|
70
|
+
type WithActions = {
|
|
71
|
+
/**
|
|
72
|
+
* Whether the page header should display KPI metrics, actions or nothing.
|
|
73
|
+
* You can only display one of the two.
|
|
74
|
+
*/
|
|
75
|
+
accessoryType: "actions";
|
|
76
|
+
/**
|
|
77
|
+
* The main action of the page.
|
|
78
|
+
*/
|
|
79
|
+
primaryAction?: PageHeaderPrimaryActionType;
|
|
80
|
+
/**
|
|
81
|
+
* Any additional actions to be displayed in the header. If there are more than two actions, they are automatically grouped within a `<MoreMenu />` component.
|
|
82
|
+
*/
|
|
75
83
|
secondaryActions?: Array<PageHeaderSecondaryActionType> | ReactNode;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Groups secondary actions in a More Menu regardless of count.
|
|
86
|
+
*/
|
|
87
|
+
groupSecondaryActions?: boolean;
|
|
88
|
+
};
|
|
89
|
+
type WithKpiMetrics = {
|
|
90
|
+
/**
|
|
91
|
+
* Whether the page header should display KPI metrics, actions or nothing.
|
|
92
|
+
*/
|
|
93
|
+
accessoryType: "kpi-metrics";
|
|
94
|
+
/**
|
|
95
|
+
* The KPI metrics to display in the header. Cannot be used in combination with secondaryActions.
|
|
96
|
+
*/
|
|
97
|
+
kpiMetrics: Array<PageHeaderKpiMetricsType>;
|
|
98
|
+
};
|
|
99
|
+
type WithNothing = {
|
|
100
|
+
/**
|
|
101
|
+
* Whether the page header should display KPI metrics, actions or nothing.
|
|
102
|
+
*/
|
|
103
|
+
accessoryType: "none";
|
|
104
|
+
};
|
|
105
|
+
export type PageHeaderProps = BasePageHeaderProps & (WithActions | WithKpiMetrics | WithNothing);
|
|
83
106
|
export {};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { type RefObject } from "react";
|
|
2
2
|
import { type BreakpointState } from "./breakpoint-utils";
|
|
3
|
+
type UseContainerBreakpointsOptions = {
|
|
4
|
+
skip?: boolean;
|
|
5
|
+
};
|
|
3
6
|
/**
|
|
4
7
|
* A custom React hook that provides real-time information about a container's size.
|
|
5
8
|
*
|
|
@@ -7,6 +10,8 @@ import { type BreakpointState } from "./breakpoint-utils";
|
|
|
7
10
|
* an object with boolean values indicating which breakpoints are currently active.
|
|
8
11
|
*
|
|
9
12
|
* @param {RefObject<HTMLElement>} ref - Reference to the container element to observe
|
|
13
|
+
* @param {object} [options] - Configuration options
|
|
14
|
+
* @param {boolean} [options.skip] - Whether to skip observing for breakpoint changes (default: false)
|
|
10
15
|
* @returns {BreakpointState} An object containing boolean values for each container size breakpoint.
|
|
11
16
|
* @example
|
|
12
17
|
* const MyComponent = () => {
|
|
@@ -26,4 +31,5 @@ import { type BreakpointState } from "./breakpoint-utils";
|
|
|
26
31
|
* );
|
|
27
32
|
* }
|
|
28
33
|
*/
|
|
29
|
-
export declare const useContainerBreakpoints: (ref: RefObject<HTMLElement | null
|
|
34
|
+
export declare const useContainerBreakpoints: (ref: RefObject<HTMLElement | null>, options?: UseContainerBreakpointsOptions) => BreakpointState;
|
|
35
|
+
export {};
|
|
@@ -13,7 +13,7 @@ interface UseContinuousTimeoutProps extends UseTimeoutProps {
|
|
|
13
13
|
* @param {number} options.maxRetries - Maximum number of retry attempts.
|
|
14
14
|
* @returns {object} An object containing functions to start and stop the timeout, current retry count, and the timeout status.
|
|
15
15
|
*/
|
|
16
|
-
export declare const useContinuousTimeout: ({ onTimeout, onMaxRetries, duration, maxRetries }: UseContinuousTimeoutProps) => {
|
|
16
|
+
export declare const useContinuousTimeout: ({ onTimeout, onMaxRetries, duration, maxRetries, }: UseContinuousTimeoutProps) => {
|
|
17
17
|
startTimeouts: () => void;
|
|
18
18
|
stopTimeouts: () => void;
|
|
19
19
|
isRunning: boolean;
|
|
@@ -19,6 +19,12 @@ export interface DevicePixelRatioOptions {
|
|
|
19
19
|
* @default `3`
|
|
20
20
|
*/
|
|
21
21
|
maxDpr?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Whether to skip observing for device pixel ratio changes
|
|
24
|
+
*
|
|
25
|
+
* @default `false`
|
|
26
|
+
*/
|
|
27
|
+
skip?: boolean;
|
|
22
28
|
}
|
|
23
29
|
/**
|
|
24
30
|
* Get the device pixel ratio, potentially rounded and capped.
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { RefObject } from "react";
|
|
2
|
-
|
|
3
|
-
skip?: boolean;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Custom hook to get the geometry of an element.
|
|
7
|
-
* Size and position of the element relative to the viewport.
|
|
8
|
-
*/
|
|
9
|
-
export declare const useGeometry: (ref: RefObject<HTMLElement | null>, { skip }?: UseGeometryOptions) => {
|
|
2
|
+
type Geometry = {
|
|
10
3
|
width: number;
|
|
11
4
|
height: number;
|
|
12
5
|
top: number;
|
|
@@ -16,4 +9,13 @@ export declare const useGeometry: (ref: RefObject<HTMLElement | null>, { skip }?
|
|
|
16
9
|
x: number;
|
|
17
10
|
y: number;
|
|
18
11
|
};
|
|
12
|
+
interface UseGeometryOptions {
|
|
13
|
+
skip?: boolean;
|
|
14
|
+
onChange?: (geometry: Geometry) => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Custom hook to get the geometry of an element.
|
|
18
|
+
* Size and position of the element relative to the viewport.
|
|
19
|
+
*/
|
|
20
|
+
export declare const useGeometry: (ref: RefObject<HTMLElement | null>, { skip, onChange }?: UseGeometryOptions) => Geometry;
|
|
19
21
|
export {};
|
|
@@ -8,6 +8,7 @@ interface InfiniteScrollProps<TScrollElement extends Element, TItemElement exten
|
|
|
8
8
|
estimateSize?: (index: number) => number;
|
|
9
9
|
overscan?: number;
|
|
10
10
|
onChange?: (virtualizer: Virtualizer<TScrollElement, TItemElement>) => void;
|
|
11
|
+
skip?: boolean;
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
14
|
* Custom hook for implementing infinite scrolling in a table using TanStack Virtual.
|
|
@@ -19,6 +20,7 @@ interface InfiniteScrollProps<TScrollElement extends Element, TItemElement exten
|
|
|
19
20
|
* @param props.estimateSize - Optional function to estimate item height.
|
|
20
21
|
* @param props.overscan - Optional number of items to render outside the visible area.
|
|
21
22
|
* @param props.onChange - Optional callback when virtualizer changes.
|
|
23
|
+
* @param props.skip - Whether to skip automatic loading of more data (default: false).
|
|
22
24
|
* @returns {Virtualizer} The virtualizer instance with all its properties and methods.
|
|
23
25
|
* @description
|
|
24
26
|
* This hook is used to implement infinite scrolling in a table. It uses TanStack Virtual's
|
|
@@ -32,5 +34,5 @@ interface InfiniteScrollProps<TScrollElement extends Element, TItemElement exten
|
|
|
32
34
|
* estimateSize: () => 35,
|
|
33
35
|
* });
|
|
34
36
|
*/
|
|
35
|
-
export declare const useInfiniteScroll: <TScrollElement extends Element, TItemElement extends Element>({ pagination, scrollElementRef, count, estimateSize, overscan, onChange, }: InfiniteScrollProps<TScrollElement, TItemElement>) => Virtualizer<TScrollElement, TItemElement>;
|
|
37
|
+
export declare const useInfiniteScroll: <TScrollElement extends Element, TItemElement extends Element>({ pagination, scrollElementRef, count, estimateSize, overscan, onChange, skip, }: InfiniteScrollProps<TScrollElement, TItemElement>) => Virtualizer<TScrollElement, TItemElement>;
|
|
36
38
|
export {};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { Ref } from "react";
|
|
2
|
+
type UseIsTextTruncatedOptions = {
|
|
3
|
+
skip?: boolean;
|
|
4
|
+
};
|
|
2
5
|
/**
|
|
3
6
|
* A custom hook that determines if text within an element is truncated
|
|
4
7
|
* (i.e., the text overflows the container).
|
|
@@ -6,6 +9,8 @@ import { Ref } from "react";
|
|
|
6
9
|
* @template TElement - The type of the HTML element being observed (e.g., HTMLDivElement).
|
|
7
10
|
* @param {string} [text] - (Optional) Text used to trigger a re-check of truncation,
|
|
8
11
|
* especially if the text is dynamic (such as an input's value).
|
|
12
|
+
* @param {object} [options] - Configuration options
|
|
13
|
+
* @param {boolean} [options.skip] - Whether to skip observing for truncation (default: false)
|
|
9
14
|
* @returns {{
|
|
10
15
|
* ref: Ref<TElement | null>;
|
|
11
16
|
* isTooltipVisible: boolean;
|
|
@@ -13,7 +18,8 @@ import { Ref } from "react";
|
|
|
13
18
|
* - `ref`: a ref to attach to the element you want to observe for truncation.
|
|
14
19
|
* - `isTextTruncated`: a boolean indicating if the text is truncated.
|
|
15
20
|
*/
|
|
16
|
-
export declare const useIsTextTruncated: <TElement extends HTMLElement>(text?: string) => {
|
|
21
|
+
export declare const useIsTextTruncated: <TElement extends HTMLElement>(text?: string, { skip }?: UseIsTextTruncatedOptions) => {
|
|
17
22
|
ref: Ref<TElement>;
|
|
18
23
|
isTextTruncated: boolean;
|
|
19
24
|
};
|
|
25
|
+
export {};
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { RefObject } from "react";
|
|
2
|
+
type UseIsTextWrappingOptions = {
|
|
3
|
+
skip?: boolean;
|
|
4
|
+
};
|
|
2
5
|
/**
|
|
3
6
|
* Hook to detect if text content is wrapping to multiple lines
|
|
4
7
|
*
|
|
5
8
|
* @template TElement - The type of the HTML element being observed (e.g., HTMLDivElement).
|
|
9
|
+
* @param {object} [options] - Configuration options
|
|
10
|
+
* @param {boolean} [options.skip] - Whether to skip observing for wrapping (default: false)
|
|
6
11
|
* @returns {{
|
|
7
12
|
* ref: RefObject<TElement | null>;
|
|
8
13
|
* isTooltipVisible: boolean;
|
|
@@ -10,7 +15,8 @@ import { RefObject } from "react";
|
|
|
10
15
|
* - `ref`: a ref to attach to the element you want to observe for truncation.
|
|
11
16
|
* - `isTextWrapping`: a boolean indicating if the text is wrapping.
|
|
12
17
|
*/
|
|
13
|
-
export declare const useIsTextWrapping: <TElement extends HTMLElement>() => {
|
|
18
|
+
export declare const useIsTextWrapping: <TElement extends HTMLElement>(options?: UseIsTextWrappingOptions) => {
|
|
14
19
|
ref: RefObject<TElement | null>;
|
|
15
20
|
isTextWrapping: boolean;
|
|
16
21
|
};
|
|
22
|
+
export {};
|
|
@@ -12,12 +12,13 @@ type ScrollState = {
|
|
|
12
12
|
type UseScrollDetectionOptions = {
|
|
13
13
|
direction?: ScrollDirection;
|
|
14
14
|
onScrollStateChange?: (state: ScrollState) => void;
|
|
15
|
+
skip?: boolean;
|
|
15
16
|
};
|
|
16
17
|
/**
|
|
17
18
|
* Hook for detecting scroll values in horizontal or vertical direction.
|
|
18
19
|
*
|
|
19
20
|
* @param {useRef} elementRef - Ref hook holding the element that needs to be observed during scrolling
|
|
20
|
-
* @param {object} options - Options object containing direction
|
|
21
|
+
* @param {object} options - Options object containing direction, onScrollStateChange callback, and skip
|
|
21
22
|
* @returns {object} An object containing if the element is scrollable, is at the beginning, is at the end, and its current scroll position.
|
|
22
23
|
*/
|
|
23
24
|
export declare const useScrollDetection: (elementRef?: RefObject<HTMLElement | null>, options?: UseScrollDetectionOptions) => ScrollState;
|
|
@@ -10,7 +10,7 @@ export interface UseTimeoutProps {
|
|
|
10
10
|
* @param {number} options.duration - Duration of the timeout in milliseconds.
|
|
11
11
|
* @returns {object} An object containing functions to start and stop the timeout.
|
|
12
12
|
*/
|
|
13
|
-
export declare const useTimeout: ({ onTimeout, duration }: UseTimeoutProps) => {
|
|
13
|
+
export declare const useTimeout: ({ onTimeout, duration, }: UseTimeoutProps) => {
|
|
14
14
|
startTimeout: () => void;
|
|
15
15
|
stopTimeout: () => void;
|
|
16
16
|
};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { type BreakpointState } from "./breakpoint-utils";
|
|
2
|
+
type UseViewportBreakpointsOptions = {
|
|
3
|
+
skip?: boolean;
|
|
4
|
+
};
|
|
2
5
|
/**
|
|
3
6
|
* A custom React hook that provides real-time information about the current viewport size.
|
|
4
7
|
* ! Consider using `useContainerBreakpoints` instead, and only use this when you need to actually react to the viewport size, not the container size.
|
|
@@ -6,6 +9,8 @@ import { type BreakpointState } from "./breakpoint-utils";
|
|
|
6
9
|
* This hook listens to changes in the viewport size and returns an object with boolean values
|
|
7
10
|
* indicating which breakpoints are currently active.
|
|
8
11
|
*
|
|
12
|
+
* @param {object} [options] - Configuration options
|
|
13
|
+
* @param {boolean} [options.skip] - Whether to skip observing for viewport changes (default: false)
|
|
9
14
|
* @returns {BreakpointState} An object containing boolean values for each viewport size breakpoint.
|
|
10
15
|
* @example
|
|
11
16
|
* const MyComponent = () => {
|
|
@@ -18,4 +23,5 @@ import { type BreakpointState } from "./breakpoint-utils";
|
|
|
18
23
|
* return viewportSize.isMd ? <MediumScreenLayout /> : <SmallLayout />;
|
|
19
24
|
* }
|
|
20
25
|
*/
|
|
21
|
-
export declare const useViewportBreakpoints: () => BreakpointState;
|
|
26
|
+
export declare const useViewportBreakpoints: (options?: UseViewportBreakpointsOptions) => BreakpointState;
|
|
27
|
+
export {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
type UseWindowActivityProps = {
|
|
2
2
|
onFocus?: () => void;
|
|
3
3
|
onBlur?: () => void;
|
|
4
|
+
skip?: boolean;
|
|
4
5
|
};
|
|
5
6
|
/**
|
|
6
7
|
* Use this hook to disable functionality while the tab is hidden within the browser or to react to focus or blur events
|
|
7
8
|
*/
|
|
8
|
-
export declare const useWindowActivity: ({ onFocus, onBlur }?: UseWindowActivityProps) => {
|
|
9
|
+
export declare const useWindowActivity: ({ onFocus, onBlur, skip }?: UseWindowActivityProps) => {
|
|
9
10
|
focused: boolean;
|
|
10
11
|
};
|
|
11
12
|
export {};
|