@trackunit/react-components 1.14.6 → 1.14.11
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 +293 -166
- package/index.esm.js +291 -167
- package/package.json +5 -5
- package/src/components/KPI/KPI.d.ts +1 -5
- package/src/components/KPI/KPISkeleton.d.ts +14 -0
- package/src/components/KPICard/KPICard.d.ts +1 -1
- package/src/components/KPICard/KPICard.variants.d.ts +2 -0
- package/src/components/KPICard/KPICardSkeleton.d.ts +30 -0
- package/src/components/PageHeader/components/PageHeaderKpiMetrics.d.ts +1 -1
- package/src/components/Skeleton/Skeleton.helpers.d.ts +28 -0
- package/src/components/Skeleton/SkeletonBlock/SkeletonBlock.d.ts +48 -0
- package/src/components/Skeleton/SkeletonBlock/index.d.ts +2 -0
- package/src/components/Skeleton/SkeletonLabel/SkeletonLabel.d.ts +51 -0
- package/src/components/Skeleton/SkeletonLabel/index.d.ts +2 -0
- package/src/components/Skeleton/index.d.ts +4 -2
- package/src/components/SkeletonLines/SkeletonLines.d.ts +138 -21
- package/src/components/SkeletonLines/SkeletonLines.presets.d.ts +5 -0
- package/src/index.d.ts +2 -0
- package/src/components/Skeleton/Skeleton.d.ts +0 -115
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
import { CommonProps } from "../../common/CommonProps";
|
|
3
|
+
import { Styleable } from "../../common/Styleable";
|
|
4
|
+
export interface KPISkeletonProps extends CommonProps, Styleable {
|
|
5
|
+
/**
|
|
6
|
+
* The size of the KPI skeleton
|
|
7
|
+
*/
|
|
8
|
+
variant?: "small" | "default" | "condensed";
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Skeleton loading indicator that mimics the KPI component structure.
|
|
12
|
+
* Uses the same layout, spacing, and visual hierarchy as KPI.
|
|
13
|
+
*/
|
|
14
|
+
export declare const KPISkeleton: ({ variant, className, "data-testid": dataTestId, style, ...rest }: KPISkeletonProps) => ReactElement;
|
|
@@ -46,4 +46,4 @@ export interface KPICardProps extends MappedOmit<KPIProps, "variant"> {
|
|
|
46
46
|
* @param {KPICardProps} props - The props for the KPICard component
|
|
47
47
|
* @returns {ReactElement} KPICard component
|
|
48
48
|
*/
|
|
49
|
-
export declare const KPICard: ({ isActive, onClick, className, "data-testid": dataTestId, children, iconName, iconColor,
|
|
49
|
+
export declare const KPICard: ({ isActive, onClick, className, "data-testid": dataTestId, children, iconName, iconColor, notice, valueBar, trends, unit, ...rest }: KPICardProps) => ReactElement;
|
|
@@ -2,6 +2,8 @@ export declare const cvaKPICard: (props?: ({
|
|
|
2
2
|
isClickable?: boolean | null | undefined;
|
|
3
3
|
isActive?: boolean | null | undefined;
|
|
4
4
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
5
|
+
export declare const cvaKPICardBody: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
6
|
+
export declare const cvaKPICardHeader: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
5
7
|
export declare const cvaKPIIconContainer: (props?: ({
|
|
6
8
|
iconColor?: "success" | "warning" | "danger" | "info" | "neutral" | null | undefined;
|
|
7
9
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from "react";
|
|
2
|
+
import { CommonProps } from "../../common/CommonProps";
|
|
3
|
+
import { Styleable } from "../../common/Styleable";
|
|
4
|
+
export interface KPICardSkeletonProps extends CommonProps, Styleable {
|
|
5
|
+
/**
|
|
6
|
+
* Whether to show an icon skeleton
|
|
7
|
+
*/
|
|
8
|
+
hasIcon?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Whether to show trends skeleton
|
|
11
|
+
*/
|
|
12
|
+
hasTrends?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Whether to show value bar skeleton
|
|
15
|
+
*/
|
|
16
|
+
hasValueBar?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Whether to show notice skeleton
|
|
19
|
+
*/
|
|
20
|
+
hasNotice?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Children to be rendered (e.g., custom skeleton content)
|
|
23
|
+
*/
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Skeleton loading indicator that mimics the KPICard component structure.
|
|
28
|
+
* Uses the same layout, spacing, and visual hierarchy as KPICard.
|
|
29
|
+
*/
|
|
30
|
+
export declare const KPICardSkeleton: ({ hasIcon, hasTrends, hasValueBar, hasNotice, children, className, "data-testid": dataTestId, style, ...rest }: KPICardSkeletonProps) => ReactElement;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactElement } from "react";
|
|
2
2
|
import { PageHeaderKpiMetricsType } from "../types";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Renders KPI metrics in the PageHeader component.
|
|
5
5
|
*
|
|
6
6
|
* @param {object} props - The props for the PageHeaderKpiMetrics component
|
|
7
7
|
* @param {Array<PageHeaderKpiMetricsType>} props.kpiMetrics - The KPI metrics to render
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { fontSizeKeys } from "@trackunit/ui-design-tokens";
|
|
2
|
+
export type CSSLength = `${number}px` | `${number}rem` | `${number}em` | `${number}ch` | `${number}ex` | `${number}%`;
|
|
3
|
+
export type TextSizeKey = `text-${fontSizeKeys}`;
|
|
4
|
+
export type SkeletonVariant = "text" | "block";
|
|
5
|
+
export declare const VALID_SIZE_KEYS: ReadonlyArray<fontSizeKeys>;
|
|
6
|
+
/**
|
|
7
|
+
* Extract the size key from a text size string (e.g., "text-base" → "base").
|
|
8
|
+
*
|
|
9
|
+
* @param value - The text size string to parse
|
|
10
|
+
* @returns {fontSizeKeys | null} The extracted size key or null if invalid
|
|
11
|
+
*/
|
|
12
|
+
export declare const extractSizeKey: (value: string) => fontSizeKeys | null;
|
|
13
|
+
/**
|
|
14
|
+
* Calculate the height value based on the height prop and variant.
|
|
15
|
+
*
|
|
16
|
+
* @param height - The height value (number, CSS length, or text size key)
|
|
17
|
+
* @param variant - The skeleton variant ("text" or "block")
|
|
18
|
+
* @returns {string} The calculated CSS height value
|
|
19
|
+
*/
|
|
20
|
+
export declare const getHeightValue: (height: TextSizeKey | number | string, variant: SkeletonVariant) => string;
|
|
21
|
+
/**
|
|
22
|
+
* Calculate the vertical margin value for text variant to align with text baseline.
|
|
23
|
+
* Formula: (line-height - cap-height) / 2, where cap-height = font-size × 0.7
|
|
24
|
+
*
|
|
25
|
+
* @param height - The height value (number, CSS length, or text size key)
|
|
26
|
+
* @returns {string} The calculated CSS margin value
|
|
27
|
+
*/
|
|
28
|
+
export declare const getMarginValue: (height: TextSizeKey | number | string) => string;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { StringWithAutocompleteOptions } from "@trackunit/shared-utils";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { CommonProps } from "../../../common/CommonProps";
|
|
4
|
+
import { CSSLength } from "../Skeleton.helpers";
|
|
5
|
+
export type SkeletonBlockProps = CommonProps & {
|
|
6
|
+
/**
|
|
7
|
+
* The height of the skeleton.
|
|
8
|
+
*
|
|
9
|
+
* - Number: treated as pixels (e.g., 24 → "24px")
|
|
10
|
+
* - CSS length: any CSS length value (e.g., "1.5rem", "2em")
|
|
11
|
+
*
|
|
12
|
+
* @default 16
|
|
13
|
+
*/
|
|
14
|
+
height?: number | StringWithAutocompleteOptions<CSSLength>;
|
|
15
|
+
/**
|
|
16
|
+
* The width of the skeleton.
|
|
17
|
+
*
|
|
18
|
+
* - Number: treated as pixels (e.g., 200 → "200px")
|
|
19
|
+
* - CSS length: any CSS length value or percentage (e.g., "50%", "20rem")
|
|
20
|
+
*
|
|
21
|
+
* @default "100%"
|
|
22
|
+
*/
|
|
23
|
+
width?: number | StringWithAutocompleteOptions<CSSLength>;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the width can shrink to fit within its container.
|
|
26
|
+
*
|
|
27
|
+
* - `true`: Uses max-width pattern - width can shrink if container is smaller
|
|
28
|
+
* - `false`: Uses exact width - width is fixed and won't shrink
|
|
29
|
+
*
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
flexibleWidth?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Optional children to render inside the skeleton.
|
|
35
|
+
* Useful for custom skeleton layouts with specific content.
|
|
36
|
+
*/
|
|
37
|
+
children?: ReactNode;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Display a single placeholder block for shape-based elements before data gets loaded to reduce load-time frustration.
|
|
41
|
+
*
|
|
42
|
+
* Fills the full height for images, badges, buttons, avatars, and other shape-based elements.
|
|
43
|
+
* Uses numbers or CSS length values for height.
|
|
44
|
+
*
|
|
45
|
+
* For text content, use SkeletonLabel component instead.
|
|
46
|
+
* For multiple text lines, use SkeletonLines component instead.
|
|
47
|
+
*/
|
|
48
|
+
export declare const SkeletonBlock: import("react").NamedExoticComponent<SkeletonBlockProps>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { StringWithAutocompleteOptions } from "@trackunit/shared-utils";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { CommonProps } from "../../../common/CommonProps";
|
|
4
|
+
import { CSSLength, TextSizeKey } from "../Skeleton.helpers";
|
|
5
|
+
export type SkeletonLabelProps = CommonProps & {
|
|
6
|
+
/**
|
|
7
|
+
* The text size to match, using text size keys.
|
|
8
|
+
*
|
|
9
|
+
* Text size keys: text-xs, text-sm, text-base, text-lg, text-xl, text-2xl, text-3xl, text-4xl, text-5xl, text-6xl, text-7xl, text-8xl, text-9xl
|
|
10
|
+
*
|
|
11
|
+
* Height uses font-size × 0.7 to approximate visual cap-height, while margins are calculated as (line-height - cap-height) / 2
|
|
12
|
+
* using CSS variables. For large text sizes (5xl+), margins may be negative, allowing the skeleton to extend beyond the
|
|
13
|
+
* line-height box just like actual text does.
|
|
14
|
+
*
|
|
15
|
+
* @default "text-base"
|
|
16
|
+
*/
|
|
17
|
+
textSize?: TextSizeKey;
|
|
18
|
+
/**
|
|
19
|
+
* The width of the skeleton.
|
|
20
|
+
*
|
|
21
|
+
* - Number: treated as pixels (e.g., 200 → "200px")
|
|
22
|
+
* - CSS length: any CSS length value or percentage (e.g., "50%", "20rem")
|
|
23
|
+
*
|
|
24
|
+
* @default "100%"
|
|
25
|
+
*/
|
|
26
|
+
width?: number | StringWithAutocompleteOptions<CSSLength>;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the width can shrink to fit within its container.
|
|
29
|
+
*
|
|
30
|
+
* - `true`: Uses max-width pattern - width can shrink if container is smaller
|
|
31
|
+
* - `false`: Uses exact width - width is fixed and won't shrink
|
|
32
|
+
*
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
flexibleWidth?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Optional children to render inside the skeleton.
|
|
38
|
+
* Useful for custom skeleton layouts with specific content.
|
|
39
|
+
*/
|
|
40
|
+
children?: ReactNode;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Display a single placeholder line for text content before data gets loaded to reduce load-time frustration.
|
|
44
|
+
*
|
|
45
|
+
* Reduces height and adds vertical margins to match the visual space text occupies within its line-height.
|
|
46
|
+
* Uses text-size keys (text-xs, text-sm, text-base, etc.) for height to match actual text elements.
|
|
47
|
+
*
|
|
48
|
+
* For multiple text lines, use SkeletonLines component instead.
|
|
49
|
+
* For shape-based elements (images, badges, buttons), use SkeletonBlock component instead.
|
|
50
|
+
*/
|
|
51
|
+
export declare const SkeletonLabel: import("react").NamedExoticComponent<SkeletonLabelProps>;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type {
|
|
1
|
+
export { SkeletonLabel } from "./SkeletonLabel";
|
|
2
|
+
export type { SkeletonLabelProps } from "./SkeletonLabel";
|
|
3
|
+
export { SkeletonBlock } from "./SkeletonBlock";
|
|
4
|
+
export type { SkeletonBlockProps } from "./SkeletonBlock";
|
|
@@ -1,36 +1,153 @@
|
|
|
1
|
+
import { StringWithAutocompleteOptions } from "@trackunit/shared-utils";
|
|
2
|
+
import { fontSizeKeys } from "@trackunit/ui-design-tokens";
|
|
1
3
|
import { CommonProps } from "../../common/CommonProps";
|
|
2
|
-
type
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
4
|
+
type CSSLength = `${number}px` | `${number}rem` | `${number}em` | `${number}ch` | `${number}ex` | `${number}%`;
|
|
5
|
+
type TextSizeKey = `text-${fontSizeKeys}`;
|
|
6
|
+
/**
|
|
7
|
+
* Preset configurations for common skeleton patterns.
|
|
8
|
+
*/
|
|
9
|
+
export type SkeletonLinesPreset = "short-paragraph" | "paragraph" | "long-paragraph" | "title-paragraph" | "heading-text" | "article";
|
|
10
|
+
/**
|
|
11
|
+
* Base configuration shared between single line config and uniform mode.
|
|
12
|
+
*/
|
|
13
|
+
type BaseSkeletonLineConfig = {
|
|
14
|
+
/**
|
|
15
|
+
* The text size to match, using text size keys.
|
|
16
|
+
*
|
|
17
|
+
* Text size keys: text-xs, text-sm, text-base, text-lg, text-xl, text-2xl, text-3xl, text-4xl, text-5xl, text-6xl, text-7xl, text-8xl, text-9xl
|
|
18
|
+
*
|
|
19
|
+
* @default "text-base"
|
|
20
|
+
*/
|
|
21
|
+
textSize?: TextSizeKey;
|
|
22
|
+
/**
|
|
23
|
+
* The width of the line.
|
|
24
|
+
*
|
|
25
|
+
* - Number: treated as pixels (e.g., 200 → "200px")
|
|
26
|
+
* - CSS length: any CSS length value or percentage (e.g., "50%", "20rem")
|
|
27
|
+
*
|
|
28
|
+
* @default "100%"
|
|
29
|
+
*/
|
|
30
|
+
width?: number | StringWithAutocompleteOptions<CSSLength>;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the width can shrink to fit within its container.
|
|
33
|
+
*
|
|
34
|
+
* - `true`: Uses max-width pattern - width can shrink if container is smaller
|
|
35
|
+
* - `false`: Uses exact width - width is fixed and won't shrink
|
|
36
|
+
*
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
39
|
+
flexibleWidth?: boolean;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Configuration for a single skeleton line.
|
|
43
|
+
*/
|
|
44
|
+
export type SkeletonLineConfig = BaseSkeletonLineConfig & {
|
|
45
|
+
/**
|
|
46
|
+
* Optional className to apply to this specific line.
|
|
47
|
+
*/
|
|
48
|
+
className?: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Props for SkeletonLines in uniform mode (default).
|
|
52
|
+
*
|
|
53
|
+
* Use this for displaying multiple identical skeleton lines.
|
|
54
|
+
*/
|
|
55
|
+
export type UniformSkeletonLinesProps = CommonProps & BaseSkeletonLineConfig & {
|
|
8
56
|
/**
|
|
9
|
-
*
|
|
57
|
+
* Visual variant: "uniform" (default)
|
|
58
|
+
*
|
|
59
|
+
* Displays uniform skeleton lines with identical configuration.
|
|
10
60
|
*/
|
|
11
|
-
|
|
61
|
+
variant: "uniform";
|
|
12
62
|
/**
|
|
13
|
-
*
|
|
63
|
+
* Number of skeleton lines to display.
|
|
14
64
|
*/
|
|
15
|
-
|
|
65
|
+
count: number;
|
|
16
66
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
67
|
+
* Optional className to apply to each individual line.
|
|
68
|
+
*
|
|
69
|
+
* Note: The container-level `className` prop (from CommonProps) applies to the wrapping container.
|
|
19
70
|
*/
|
|
20
|
-
|
|
71
|
+
lineClassName?: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Props for SkeletonLines in custom mode.
|
|
75
|
+
*
|
|
76
|
+
* Use this for displaying skeleton lines with per-line configuration (varying widths, textSize (height), etc.).
|
|
77
|
+
*/
|
|
78
|
+
type CustomSkeletonLinesProps = CommonProps & {
|
|
21
79
|
/**
|
|
22
|
-
*
|
|
80
|
+
* Visual variant: "custom"
|
|
81
|
+
*
|
|
82
|
+
* Displays custom skeleton lines with per-line configuration.
|
|
23
83
|
*/
|
|
24
|
-
|
|
84
|
+
variant: "custom";
|
|
25
85
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
86
|
+
* Array of line configurations, one for each skeleton line.
|
|
87
|
+
*
|
|
88
|
+
* Each line can have its own textSize (height), width, and flexibleWidth settings.
|
|
28
89
|
*/
|
|
29
|
-
|
|
30
|
-
}
|
|
90
|
+
lines: Array<SkeletonLineConfig>;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Props for SkeletonLines in preset mode.
|
|
94
|
+
*
|
|
95
|
+
* Use this for common skeleton patterns with predefined configurations.
|
|
96
|
+
*/
|
|
97
|
+
type PresetSkeletonLinesProps = CommonProps & {
|
|
98
|
+
/**
|
|
99
|
+
* Visual variant: "preset"
|
|
100
|
+
*
|
|
101
|
+
* Displays skeleton lines using a predefined preset configuration.
|
|
102
|
+
*/
|
|
103
|
+
variant: "preset";
|
|
104
|
+
/**
|
|
105
|
+
* The preset configuration to use.
|
|
106
|
+
*
|
|
107
|
+
* Available presets:
|
|
108
|
+
* - `"short-paragraph"`: 3 lines with last line at 60% width
|
|
109
|
+
* - `"paragraph"`: 5 lines with progressive width reduction
|
|
110
|
+
* - `"long-paragraph"`: 8 lines with varied widths
|
|
111
|
+
* - `"title-paragraph"`: Large heading + 3 body lines
|
|
112
|
+
* - `"heading-text"`: Heading + 4 body lines
|
|
113
|
+
* - `"article"`: Large title + meta info + 5 paragraph lines
|
|
114
|
+
*/
|
|
115
|
+
preset: SkeletonLinesPreset;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Props for SkeletonLines component using discriminated union for type safety.
|
|
119
|
+
*
|
|
120
|
+
* - Use default (or `variant="uniform"`) with `count` for identical lines
|
|
121
|
+
* - Use `variant="custom"` with `lines` array for per-line configuration
|
|
122
|
+
* - Use `variant="preset"` with `preset` name for common patterns
|
|
123
|
+
*/
|
|
124
|
+
export type SkeletonLinesProps = UniformSkeletonLinesProps | CustomSkeletonLinesProps | PresetSkeletonLinesProps;
|
|
31
125
|
/**
|
|
32
|
-
* Display placeholder lines before
|
|
33
|
-
*
|
|
126
|
+
* Display multiple placeholder lines before data gets loaded to reduce load-time frustration.
|
|
127
|
+
*
|
|
128
|
+
* Supports three modes:
|
|
129
|
+
* - **Uniform mode** (default): Display identical lines using `count` prop
|
|
130
|
+
* - **Custom mode**: Display customized lines with per-line configuration using `variant="custom"` and `lines` prop
|
|
131
|
+
* - **Preset mode**: Display common patterns using `variant="preset"` and `preset` name
|
|
132
|
+
*
|
|
133
|
+
* Built on top of the [SkeletonLabel](?path=/docs/components-loading-states-skeletonlabel--docs) component for text-specific margins and sizing.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* // Uniform lines (simple mode)
|
|
137
|
+
* <SkeletonLines count={3} textSize="text-base" variant="uniform" />
|
|
138
|
+
* @example
|
|
139
|
+
* // Custom lines (advanced mode)
|
|
140
|
+
* <SkeletonLines
|
|
141
|
+
* variant="custom"
|
|
142
|
+
* lines={[
|
|
143
|
+
* { textSize: "text-lg", width: "100%" },
|
|
144
|
+
* { textSize: "text-base", width: "95%" },
|
|
145
|
+
* { textSize: "text-base", width: "70%" }
|
|
146
|
+
* ]}
|
|
147
|
+
* />
|
|
148
|
+
* @example
|
|
149
|
+
* // Preset lines (quick patterns)
|
|
150
|
+
* <SkeletonLines variant="preset" preset="title-paragraph" />
|
|
34
151
|
*/
|
|
35
152
|
export declare const SkeletonLines: import("react").NamedExoticComponent<SkeletonLinesProps>;
|
|
36
153
|
export {};
|
package/src/index.d.ts
CHANGED
|
@@ -32,9 +32,11 @@ export * from "./components/Indicator";
|
|
|
32
32
|
export * from "./components/Indicator/Indicator.variants";
|
|
33
33
|
export * from "./components/InteractableItem/InteractableItem.variants";
|
|
34
34
|
export * from "./components/KPI/KPI";
|
|
35
|
+
export * from "./components/KPI/KPISkeleton";
|
|
35
36
|
export * from "./components/KPICard/components/TrendIndicator/TrendIndicator";
|
|
36
37
|
export * from "./components/KPICard/components/TrendIndicators";
|
|
37
38
|
export * from "./components/KPICard/KPICard";
|
|
39
|
+
export * from "./components/KPICard/KPICardSkeleton";
|
|
38
40
|
export * from "./components/List/List";
|
|
39
41
|
export * from "./components/List/List.variants";
|
|
40
42
|
export * from "./components/List/useList";
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { StringWithAutocompleteOptions } from "@trackunit/shared-utils";
|
|
2
|
-
import { fontSizeKeys } from "@trackunit/ui-design-tokens";
|
|
3
|
-
import { ReactNode } from "react";
|
|
4
|
-
import { CommonProps } from "../../common/CommonProps";
|
|
5
|
-
type CSSLength = `${number}px` | `${number}rem` | `${number}em` | `${number}ch` | `${number}ex` | `${number}%`;
|
|
6
|
-
type TextSizeKey = `text-${fontSizeKeys}`;
|
|
7
|
-
export type SkeletonVariant = "text" | "block";
|
|
8
|
-
/**
|
|
9
|
-
* Props for Skeleton when using text variant.
|
|
10
|
-
*
|
|
11
|
-
* Reduces height and adds vertical margins to match the visual space text occupies within its line-height.
|
|
12
|
-
* Must be used with text-size keys for height.
|
|
13
|
-
*/
|
|
14
|
-
type SkeletonTextProps = {
|
|
15
|
-
/**
|
|
16
|
-
* Visual variant: "text"
|
|
17
|
-
*
|
|
18
|
-
* @default "text"
|
|
19
|
-
*/
|
|
20
|
-
variant?: "text";
|
|
21
|
-
/**
|
|
22
|
-
* The height of the skeleton using text size keys.
|
|
23
|
-
*
|
|
24
|
-
* Text size keys: text-xs, text-sm, text-base, text-lg, text-xl, text-2xl, text-3xl, text-4xl, text-5xl, text-6xl, text-7xl, text-8xl, text-9xl
|
|
25
|
-
*
|
|
26
|
-
* Height uses font-size × 0.7 to approximate visual cap-height, while margins are calculated as (line-height - cap-height) / 2
|
|
27
|
-
* using CSS variables. For large text sizes (5xl+), margins may be negative, allowing the skeleton to extend beyond the
|
|
28
|
-
* line-height box just like actual text does.
|
|
29
|
-
*
|
|
30
|
-
* @default "text-base"
|
|
31
|
-
*/
|
|
32
|
-
height?: TextSizeKey;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Props for Skeleton when using block variant.
|
|
36
|
-
*
|
|
37
|
-
* Fills the full height (for images, badges, buttons, and other shape-based elements).
|
|
38
|
-
* Must be used with numbers or CSS length values for height.
|
|
39
|
-
*/
|
|
40
|
-
type SkeletonBlockProps = {
|
|
41
|
-
/**
|
|
42
|
-
* Visual variant: "block"
|
|
43
|
-
*/
|
|
44
|
-
variant: "block";
|
|
45
|
-
/**
|
|
46
|
-
* The height of the skeleton.
|
|
47
|
-
*
|
|
48
|
-
* - Number: treated as pixels (e.g., 24 → "24px")
|
|
49
|
-
* - CSS length: any CSS length value (e.g., "1.5rem", "2em")
|
|
50
|
-
*/
|
|
51
|
-
height?: number | StringWithAutocompleteOptions<CSSLength>;
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Props for Skeleton component using discriminated union for type safety.
|
|
55
|
-
*
|
|
56
|
-
* - Use `variant="text"` with text-size keys (text-xs, text-sm, etc.) for text placeholders
|
|
57
|
-
* - Use `variant="block"` with numbers or CSS lengths for shape-based elements (images, badges, buttons, etc.)
|
|
58
|
-
*/
|
|
59
|
-
export type SkeletonProps = CommonProps & (SkeletonTextProps | SkeletonBlockProps) & {
|
|
60
|
-
/**
|
|
61
|
-
* The width of the skeleton.
|
|
62
|
-
*
|
|
63
|
-
* - Number: treated as pixels (e.g., 200 → "200px")
|
|
64
|
-
* - CSS length: any CSS length value or percentage (e.g., "50%", "20rem")
|
|
65
|
-
*
|
|
66
|
-
* @default "100%"
|
|
67
|
-
*/
|
|
68
|
-
width?: number | StringWithAutocompleteOptions<CSSLength>;
|
|
69
|
-
/**
|
|
70
|
-
* Whether the width can shrink to fit within its container.
|
|
71
|
-
*
|
|
72
|
-
* - `true`: Uses max-width pattern - width can shrink if container is smaller
|
|
73
|
-
* - `false`: Uses exact width - width is fixed and won't shrink
|
|
74
|
-
*
|
|
75
|
-
* @default true for text variant, false for block variant
|
|
76
|
-
*/
|
|
77
|
-
flexibleWidth?: boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Optional children to render inside the skeleton.
|
|
80
|
-
* Useful for custom skeleton layouts with specific content.
|
|
81
|
-
*/
|
|
82
|
-
children?: ReactNode;
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* Extract the size key from a text size string (e.g., "text-base" → "base").
|
|
86
|
-
*
|
|
87
|
-
* @param value - The text size string to parse
|
|
88
|
-
* @returns {fontSizeKeys | null} The extracted size key or null if invalid
|
|
89
|
-
*/
|
|
90
|
-
export declare const extractSizeKey: (value: string) => fontSizeKeys | null;
|
|
91
|
-
/**
|
|
92
|
-
* Calculate the height value based on the height prop and variant.
|
|
93
|
-
*
|
|
94
|
-
* @param height - The height value (number, CSS length, or text size key)
|
|
95
|
-
* @param variant - The skeleton variant ("text" or "block")
|
|
96
|
-
* @returns {string} The calculated CSS height value
|
|
97
|
-
*/
|
|
98
|
-
export declare const getHeightValue: (height: TextSizeKey | number | string, variant: SkeletonVariant) => string;
|
|
99
|
-
/**
|
|
100
|
-
* Calculate the vertical margin value for text variant to align with text baseline.
|
|
101
|
-
* Formula: (line-height - cap-height) / 2, where cap-height = font-size × 0.7
|
|
102
|
-
*
|
|
103
|
-
* @param height - The height value (number, CSS length, or text size key)
|
|
104
|
-
* @returns {string} The calculated CSS margin value
|
|
105
|
-
*/
|
|
106
|
-
export declare const getMarginValue: (height: TextSizeKey | number | string) => string;
|
|
107
|
-
/**
|
|
108
|
-
* Display a single placeholder line before data gets loaded to reduce load-time frustration.
|
|
109
|
-
*
|
|
110
|
-
* Use `variant="text"` with text-size keys for text placeholders.
|
|
111
|
-
* Use `variant="block"` with numbers/CSS for images, badges, buttons, and other shape-based elements.
|
|
112
|
-
* Pass children to create custom skeleton layouts.
|
|
113
|
-
*/
|
|
114
|
-
export declare const Skeleton: import("react").NamedExoticComponent<SkeletonProps>;
|
|
115
|
-
export {};
|