@trackunit/react-components 1.13.10 → 1.13.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 +1103 -6
- package/index.esm.js +1091 -9
- package/package.json +5 -5
- package/src/components/GridAreas/GridAreas.d.ts +95 -0
- package/src/components/GridAreas/createGrid.d.ts +130 -0
- package/src/components/GridAreas/generateCss.d.ts +15 -0
- package/src/components/GridAreas/types.d.ts +104 -0
- package/src/components/GridAreas/useGridAreas.d.ts +62 -0
- package/src/components/GridAreas/validateGridConfig.d.ts +9 -0
- package/src/components/GridAreas/validateGridSlots.d.ts +9 -0
- package/src/components/ListItem/ListItem.variants.d.ts +5 -0
- package/src/components/PreferenceCard/PreferenceCard.d.ts +70 -0
- package/src/components/PreferenceCard/PreferenceCard.variants.d.ts +25 -0
- package/src/components/PreferenceCard/PreferenceCardSkeleton.d.ts +25 -0
- package/src/components/Skeleton/Skeleton.d.ts +115 -0
- package/src/components/Skeleton/Skeleton.variants.d.ts +1 -0
- package/src/components/Skeleton/index.d.ts +2 -0
- package/src/index.d.ts +8 -0
|
@@ -0,0 +1,115 @@
|
|
|
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 {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const cvaSkeleton: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
package/src/index.d.ts
CHANGED
|
@@ -20,6 +20,10 @@ export * from "./components/EmptyState/EmptyState";
|
|
|
20
20
|
export * from "./components/EmptyState/EmptyState.variants";
|
|
21
21
|
export * from "./components/EmptyValue/EmptyValue";
|
|
22
22
|
export * from "./components/ExternalLink/ExternalLink";
|
|
23
|
+
export { createGrid } from "./components/GridAreas/createGrid";
|
|
24
|
+
export { GridAreas, type GridAreasProps } from "./components/GridAreas/GridAreas";
|
|
25
|
+
export type { GridAreasResult, GridConfig, SlotProps } from "./components/GridAreas/types";
|
|
26
|
+
export { useGridAreas } from "./components/GridAreas/useGridAreas";
|
|
23
27
|
export * from "./components/Heading";
|
|
24
28
|
export * from "./components/Highlight/Highlight";
|
|
25
29
|
export * from "./components/HorizontalOverflowScroller/HorizontalOverflowScroller";
|
|
@@ -47,10 +51,14 @@ export * from "./components/Polygon/Polygon";
|
|
|
47
51
|
export * from "./components/Popover";
|
|
48
52
|
export * from "./components/Popover/Popover";
|
|
49
53
|
export * from "./components/Portal/Portal";
|
|
54
|
+
export * from "./components/PreferenceCard/PreferenceCard";
|
|
55
|
+
export * from "./components/PreferenceCard/PreferenceCard.variants";
|
|
56
|
+
export * from "./components/PreferenceCard/PreferenceCardSkeleton";
|
|
50
57
|
export * from "./components/Prompt";
|
|
51
58
|
export * from "./components/SectionHeader";
|
|
52
59
|
export * from "./components/Sidebar/Sidebar";
|
|
53
60
|
export * from "./components/Sidebar/useOverflowItems";
|
|
61
|
+
export * from "./components/Skeleton";
|
|
54
62
|
export * from "./components/SkeletonLines";
|
|
55
63
|
export * from "./components/Spacer";
|
|
56
64
|
export * from "./components/Spinner";
|