@jackbernnie/hiyf 0.1.0
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/LICENSE +191 -0
- package/NOTICE +12 -0
- package/README.md +47 -0
- package/dist/components/Accordion.d.ts +38 -0
- package/dist/components/Accordion.js +38 -0
- package/dist/components/Alert.d.ts +29 -0
- package/dist/components/Alert.js +39 -0
- package/dist/components/AlertDialog.d.ts +37 -0
- package/dist/components/AlertDialog.js +38 -0
- package/dist/components/AspectRatio.d.ts +15 -0
- package/dist/components/AspectRatio.js +15 -0
- package/dist/components/Avatar.d.ts +26 -0
- package/dist/components/Avatar.js +13 -0
- package/dist/components/Badge.d.ts +18 -0
- package/dist/components/Badge.js +17 -0
- package/dist/components/Box.d.ts +13 -0
- package/dist/components/Box.js +52 -0
- package/dist/components/Breadcrumb.d.ts +33 -0
- package/dist/components/Breadcrumb.js +16 -0
- package/dist/components/Button.d.ts +40 -0
- package/dist/components/Button.js +33 -0
- package/dist/components/ButtonGroup.d.ts +18 -0
- package/dist/components/ButtonGroup.js +8 -0
- package/dist/components/Card.d.ts +46 -0
- package/dist/components/Card.js +24 -0
- package/dist/components/Carousel.d.ts +27 -0
- package/dist/components/Carousel.js +13 -0
- package/dist/components/Chart.d.ts +17 -0
- package/dist/components/Chart.js +94 -0
- package/dist/components/Checkbox.d.ts +26 -0
- package/dist/components/Checkbox.js +9 -0
- package/dist/components/Collapsible.d.ts +27 -0
- package/dist/components/Collapsible.js +26 -0
- package/dist/components/Combobox.d.ts +36 -0
- package/dist/components/Combobox.js +41 -0
- package/dist/components/Command.d.ts +37 -0
- package/dist/components/Command.js +32 -0
- package/dist/components/ContextMenu.d.ts +34 -0
- package/dist/components/ContextMenu.js +23 -0
- package/dist/components/Dialog.d.ts +20 -0
- package/dist/components/Dialog.js +34 -0
- package/dist/components/Drawer.d.ts +28 -0
- package/dist/components/Drawer.js +25 -0
- package/dist/components/DropdownMenu.d.ts +42 -0
- package/dist/components/DropdownMenu.js +32 -0
- package/dist/components/Empty.d.ts +28 -0
- package/dist/components/Empty.js +15 -0
- package/dist/components/Field.d.ts +30 -0
- package/dist/components/Field.js +13 -0
- package/dist/components/Grid.d.ts +32 -0
- package/dist/components/Grid.js +37 -0
- package/dist/components/GridItem.d.ts +30 -0
- package/dist/components/GridItem.js +40 -0
- package/dist/components/HoverCard.d.ts +22 -0
- package/dist/components/HoverCard.js +12 -0
- package/dist/components/Input.d.ts +34 -0
- package/dist/components/Input.js +8 -0
- package/dist/components/InputGroup.d.ts +28 -0
- package/dist/components/InputGroup.js +13 -0
- package/dist/components/InputOTP.d.ts +26 -0
- package/dist/components/InputOTP.js +25 -0
- package/dist/components/Kbd.d.ts +26 -0
- package/dist/components/Kbd.js +11 -0
- package/dist/components/Label.d.ts +20 -0
- package/dist/components/Label.js +17 -0
- package/dist/components/Menubar.d.ts +35 -0
- package/dist/components/Menubar.js +19 -0
- package/dist/components/NativeSelect.d.ts +33 -0
- package/dist/components/NativeSelect.js +37 -0
- package/dist/components/NavigationMenu.d.ts +32 -0
- package/dist/components/NavigationMenu.js +14 -0
- package/dist/components/Pagination.d.ts +28 -0
- package/dist/components/Pagination.js +62 -0
- package/dist/components/Popover.d.ts +28 -0
- package/dist/components/Popover.js +19 -0
- package/dist/components/Progress.d.ts +25 -0
- package/dist/components/Progress.js +37 -0
- package/dist/components/RadioGroup.d.ts +35 -0
- package/dist/components/RadioGroup.js +44 -0
- package/dist/components/Resizable.d.ts +31 -0
- package/dist/components/Resizable.js +17 -0
- package/dist/components/ScrollArea.d.ts +8 -0
- package/dist/components/ScrollArea.js +14 -0
- package/dist/components/Select.d.ts +35 -0
- package/dist/components/Select.js +33 -0
- package/dist/components/Separator.d.ts +10 -0
- package/dist/components/Separator.js +30 -0
- package/dist/components/Sheet.d.ts +31 -0
- package/dist/components/Sheet.js +26 -0
- package/dist/components/Sidebar.d.ts +52 -0
- package/dist/components/Sidebar.js +96 -0
- package/dist/components/Skeleton.d.ts +40 -0
- package/dist/components/Skeleton.js +42 -0
- package/dist/components/Slider.d.ts +26 -0
- package/dist/components/Slider.js +9 -0
- package/dist/components/Spinner.d.ts +7 -0
- package/dist/components/Spinner.js +13 -0
- package/dist/components/Status.d.ts +30 -0
- package/dist/components/Status.js +27 -0
- package/dist/components/Switch.d.ts +27 -0
- package/dist/components/Switch.js +9 -0
- package/dist/components/Table.d.ts +39 -0
- package/dist/components/Table.js +22 -0
- package/dist/components/Tabs.d.ts +32 -0
- package/dist/components/Tabs.js +21 -0
- package/dist/components/Text.d.ts +2 -0
- package/dist/components/Text.js +5 -0
- package/dist/components/Textarea.d.ts +32 -0
- package/dist/components/Textarea.js +15 -0
- package/dist/components/Toaster.d.ts +30 -0
- package/dist/components/Toaster.js +9 -0
- package/dist/components/Toggle.d.ts +34 -0
- package/dist/components/Toggle.js +31 -0
- package/dist/components/ToggleGroup.d.ts +46 -0
- package/dist/components/ToggleGroup.js +26 -0
- package/dist/components/Tooltip.d.ts +25 -0
- package/dist/components/Tooltip.js +12 -0
- package/dist/components/ui/accordion.d.ts +7 -0
- package/dist/components/ui/accordion.js +81 -0
- package/dist/components/ui/alert-dialog.d.ts +18 -0
- package/dist/components/ui/alert-dialog.js +154 -0
- package/dist/components/ui/alert.d.ts +10 -0
- package/dist/components/ui/alert.js +64 -0
- package/dist/components/ui/aspect-ratio.d.ts +3 -0
- package/dist/components/ui/aspect-ratio.js +11 -0
- package/dist/components/ui/avatar.d.ts +11 -0
- package/dist/components/ui/avatar.js +57 -0
- package/dist/components/ui/badge.d.ts +9 -0
- package/dist/components/ui/badge.js +42 -0
- package/dist/components/ui/breadcrumb.d.ts +11 -0
- package/dist/components/ui/breadcrumb.js +87 -0
- package/dist/components/ui/button-group.d.ts +11 -0
- package/dist/components/ui/button-group.js +37 -0
- package/dist/components/ui/button.d.ts +10 -0
- package/dist/components/ui/button.js +55 -0
- package/dist/components/ui/card.d.ts +11 -0
- package/dist/components/ui/card.js +82 -0
- package/dist/components/ui/carousel.d.ts +28 -0
- package/dist/components/ui/carousel.js +196 -0
- package/dist/components/ui/chart.d.ts +44 -0
- package/dist/components/ui/chart.js +198 -0
- package/dist/components/ui/checkbox.d.ts +4 -0
- package/dist/components/ui/checkbox.js +33 -0
- package/dist/components/ui/collapsible.d.ts +5 -0
- package/dist/components/ui/collapsible.js +33 -0
- package/dist/components/ui/combobox.d.ts +24 -0
- package/dist/components/ui/combobox.js +160 -0
- package/dist/components/ui/command.d.ts +18 -0
- package/dist/components/ui/command.js +142 -0
- package/dist/components/ui/context-menu.d.ts +31 -0
- package/dist/components/ui/context-menu.js +73 -0
- package/dist/components/ui/dialog.d.ts +17 -0
- package/dist/components/ui/dialog.js +138 -0
- package/dist/components/ui/direction.d.ts +7 -0
- package/dist/components/ui/direction.js +14 -0
- package/dist/components/ui/drawer.d.ts +13 -0
- package/dist/components/ui/drawer.js +101 -0
- package/dist/components/ui/dropdown-menu.d.ts +29 -0
- package/dist/components/ui/dropdown-menu.js +98 -0
- package/dist/components/ui/empty.d.ts +11 -0
- package/dist/components/ui/empty.js +97 -0
- package/dist/components/ui/field.d.ts +24 -0
- package/dist/components/ui/field.js +110 -0
- package/dist/components/ui/hover-card.d.ts +6 -0
- package/dist/components/ui/hover-card.js +37 -0
- package/dist/components/ui/input-group.d.ts +16 -0
- package/dist/components/ui/input-group.js +111 -0
- package/dist/components/ui/input-otp.d.ts +11 -0
- package/dist/components/ui/input-otp.js +66 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/input.js +19 -0
- package/dist/components/ui/item.d.ts +23 -0
- package/dist/components/ui/item.js +181 -0
- package/dist/components/ui/kbd.d.ts +3 -0
- package/dist/components/ui/kbd.js +28 -0
- package/dist/components/ui/label.d.ts +4 -0
- package/dist/components/ui/label.js +23 -0
- package/dist/components/ui/menubar.d.ts +30 -0
- package/dist/components/ui/menubar.js +119 -0
- package/dist/components/ui/native-select.d.ts +8 -0
- package/dist/components/ui/native-select.js +49 -0
- package/dist/components/ui/navigation-menu.d.ts +14 -0
- package/dist/components/ui/navigation-menu.js +139 -0
- package/dist/components/ui/pagination.d.ts +17 -0
- package/dist/components/ui/pagination.js +120 -0
- package/dist/components/ui/popover.d.ts +10 -0
- package/dist/components/ui/popover.js +37 -0
- package/dist/components/ui/progress.d.ts +4 -0
- package/dist/components/ui/radio-group.d.ts +5 -0
- package/dist/components/ui/radio-group.js +44 -0
- package/dist/components/ui/resizable.d.ts +7 -0
- package/dist/components/ui/resizable.js +44 -0
- package/dist/components/ui/scroll-area.d.ts +5 -0
- package/dist/components/ui/scroll-area.js +59 -0
- package/dist/components/ui/select.d.ts +15 -0
- package/dist/components/ui/select.js +131 -0
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/components/ui/separator.js +27 -0
- package/dist/components/ui/sheet.d.ts +14 -0
- package/dist/components/ui/sheet.js +113 -0
- package/dist/components/ui/sidebar.d.ts +69 -0
- package/dist/components/ui/sidebar.js +459 -0
- package/dist/components/ui/skeleton.d.ts +2 -0
- package/dist/components/ui/slider.d.ts +4 -0
- package/dist/components/ui/slider.js +60 -0
- package/dist/components/ui/sonner.d.ts +3 -0
- package/dist/components/ui/sonner.js +38 -0
- package/dist/components/ui/spinner.d.ts +2 -0
- package/dist/components/ui/spinner.js +13 -0
- package/dist/components/ui/switch.d.ts +6 -0
- package/dist/components/ui/switch.js +32 -0
- package/dist/components/ui/table.d.ts +10 -0
- package/dist/components/ui/table.js +95 -0
- package/dist/components/ui/tabs.d.ts +11 -0
- package/dist/components/ui/tabs.js +87 -0
- package/dist/components/ui/textarea.d.ts +3 -0
- package/dist/components/ui/textarea.js +18 -0
- package/dist/components/ui/toggle-group.d.ts +10 -0
- package/dist/components/ui/toggle-group.js +76 -0
- package/dist/components/ui/toggle.d.ts +9 -0
- package/dist/components/ui/toggle.js +43 -0
- package/dist/components/ui/tooltip.d.ts +7 -0
- package/dist/components/ui/tooltip.js +53 -0
- package/dist/hooks/use-mobile.d.ts +1 -0
- package/dist/hooks/use-mobile.js +18 -0
- package/dist/index.d.ts +122 -0
- package/dist/index.js +61 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +8 -0
- package/dist/primitives/createText.d.ts +103 -0
- package/dist/primitives/createText.js +183 -0
- package/dist/primitives/resolveProperties.d.ts +17 -0
- package/dist/stylex.css +1450 -0
- package/dist/tokens/animations.d.ts +126 -0
- package/dist/tokens/animations.js +61 -0
- package/dist/tokens/tokens.stylex.d.ts +85 -0
- package/dist/tokens/tokens.stylex.js +81 -0
- package/dist/utils/box-styles.d.ts +1117 -0
- package/dist/utils/box-styles.js +1455 -0
- package/dist/utils/grid.d.ts +4 -0
- package/dist/utils/resolvers.d.ts +10 -0
- package/dist/utils/resolvers.js +356 -0
- package/dist/utils/types.d.ts +133 -0
- package/package.json +80 -0
- package/src/theme.css +206 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import { type ComponentPropsWithoutRef, type JSX, type ReactNode } from 'react';
|
|
3
|
+
type TextTag = 'p' | 'span' | 'label' | 'strong' | 'em' | 'small' | 'code' | 'div' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
4
|
+
declare const textVariants: (props?: ({
|
|
5
|
+
variant?: "default" | "label" | "body" | "caption" | "heading-2xl" | "heading-xl" | "heading-l" | "heading-m" | "heading-s" | "heading-xs" | "heading-xxs" | null | undefined;
|
|
6
|
+
color?: "default" | "inherit" | "disabled" | "black" | "white" | "error" | "muted" | "accent" | "danger" | "warning" | "success" | "inverse" | null | undefined;
|
|
7
|
+
align?: "left" | "right" | "center" | "justify" | null | undefined;
|
|
8
|
+
wrap?: "balance" | "nowrap" | "wrap" | "pretty" | null | undefined;
|
|
9
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
10
|
+
export type TextVariant = NonNullable<VariantProps<typeof textVariants>['variant']>;
|
|
11
|
+
export type TextColor = NonNullable<VariantProps<typeof textVariants>['color']>;
|
|
12
|
+
export type TextStyleProps = VariantProps<typeof textVariants>;
|
|
13
|
+
/**
|
|
14
|
+
* How to render the value passed as children. A named preset keeps the common
|
|
15
|
+
* cases discoverable; the function form is the escape hatch for the long tail
|
|
16
|
+
* (currency, units, locale-specific rules). Either way the output is a string,
|
|
17
|
+
* so no visual decision leaks out of the component.
|
|
18
|
+
*/
|
|
19
|
+
export type TextFormatter = 'number' | 'compact' | ((value: string | number) => string);
|
|
20
|
+
type TextProps<E extends TextTag = 'p'> = TextStyleProps & {
|
|
21
|
+
/**
|
|
22
|
+
* The role this text plays, which decides its size, weight and font family.
|
|
23
|
+
* Headings use the display scale; `body`/`default`/`label`/`caption` cover
|
|
24
|
+
* supporting copy. Pick the role, never a raw size.
|
|
25
|
+
*/
|
|
26
|
+
variant?: TextStyleProps['variant'];
|
|
27
|
+
/**
|
|
28
|
+
* Semantic foreground color that resolves for light and dark automatically.
|
|
29
|
+
* Use `inherit` to adopt the color of a parent Box.
|
|
30
|
+
*/
|
|
31
|
+
color?: TextStyleProps['color'];
|
|
32
|
+
/**
|
|
33
|
+
* Underlying DOM element. Defaults to a sensible element per variant (heading
|
|
34
|
+
* variants render `h1`–`h6`, everything else `p`). Override to keep a correct
|
|
35
|
+
* document outline. DOM props for the element are typed and forwarded.
|
|
36
|
+
*/
|
|
37
|
+
as?: E;
|
|
38
|
+
/**
|
|
39
|
+
* Horizontal text alignment.
|
|
40
|
+
*/
|
|
41
|
+
align?: TextStyleProps['align'];
|
|
42
|
+
/**
|
|
43
|
+
* Line-wrapping behavior. Defaults are baked per role (headings `balance`,
|
|
44
|
+
* body `pretty`); set this to override. Ignored while truncating.
|
|
45
|
+
*/
|
|
46
|
+
wrap?: TextStyleProps['wrap'];
|
|
47
|
+
/**
|
|
48
|
+
* The text to render. Prefer plain strings and numbers; inline elements are
|
|
49
|
+
* allowed where you genuinely need them (a `<br>`, an inline link), but reach
|
|
50
|
+
* for Box to compose layout rather than nesting containers inside Text.
|
|
51
|
+
*/
|
|
52
|
+
children?: ReactNode;
|
|
53
|
+
/**
|
|
54
|
+
* Render a pulsing skeleton placeholder instead of children, for content that
|
|
55
|
+
* is still loading.
|
|
56
|
+
*/
|
|
57
|
+
loading?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Sizes the single-line loading skeleton. Falls back to children, then to
|
|
60
|
+
* "Loading...".
|
|
61
|
+
*/
|
|
62
|
+
placeholderText?: string;
|
|
63
|
+
/**
|
|
64
|
+
* When greater than 1, renders a multi-line loading skeleton with that many
|
|
65
|
+
* lines.
|
|
66
|
+
*/
|
|
67
|
+
placeholderNumberOfLines?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Apply a line-through decoration, e.g. for a struck-out previous price.
|
|
70
|
+
*/
|
|
71
|
+
lineThrough?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Render in the monospace font family while keeping the variant's size and
|
|
74
|
+
* weight. Orthogonal to `variant`, so any text can be monospaced.
|
|
75
|
+
*/
|
|
76
|
+
monospace?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Align figures for vertical scanning in tables and stat readouts. Pairs well
|
|
79
|
+
* with a numeric `formatter`.
|
|
80
|
+
*/
|
|
81
|
+
tabularNums?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Truncate overflow. `true` clamps to a single line with an ellipsis; a
|
|
84
|
+
* number clamps to that many lines. The component owns the CSS, so callers
|
|
85
|
+
* never hand-roll line-clamp utilities.
|
|
86
|
+
*/
|
|
87
|
+
truncate?: boolean | number;
|
|
88
|
+
/**
|
|
89
|
+
* Format the children value for display. 'number' adds grouping separators
|
|
90
|
+
* (3290033 → "3,290,033"), 'compact' shortens (3290033 → "3.3M"), or pass a
|
|
91
|
+
* function for full control. Pass the raw value as children, not a
|
|
92
|
+
* pre-formatted string.
|
|
93
|
+
*/
|
|
94
|
+
formatter?: TextFormatter;
|
|
95
|
+
} & Omit<ComponentPropsWithoutRef<E>, keyof TextStyleProps | 'className' | 'loading' | 'children'>;
|
|
96
|
+
declare function Text<E extends TextTag = 'p'>({ as, variant, color, align, wrap, children, style, loading, placeholderText, placeholderNumberOfLines, lineThrough, monospace, tabularNums, truncate, formatter, ...props }: TextProps<E> & {
|
|
97
|
+
style?: React.CSSProperties;
|
|
98
|
+
}): JSX.Element;
|
|
99
|
+
declare namespace Text {
|
|
100
|
+
var displayName: string;
|
|
101
|
+
}
|
|
102
|
+
export declare function createText(): typeof Text;
|
|
103
|
+
export { Text };
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { twMerge } from 'tailwind-merge';
|
|
4
|
+
|
|
5
|
+
const textVariants = cva("", {
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
default: "text-sm",
|
|
9
|
+
body: "text-base",
|
|
10
|
+
label: "text-xs font-medium",
|
|
11
|
+
caption: "text-xs leading-snug",
|
|
12
|
+
"heading-2xl": `font-display text-6xl md:text-8xl`,
|
|
13
|
+
"heading-xl": `font-display text-5xl md:text-7xl`,
|
|
14
|
+
"heading-l": `font-display text-4xl md:text-5xl`,
|
|
15
|
+
"heading-m": `text-3xl md:text-4xl`,
|
|
16
|
+
"heading-s": `text-2xl md:text-3xl`,
|
|
17
|
+
"heading-xs": `text-xl md:text-2xl`,
|
|
18
|
+
"heading-xxs": `text-lg md:text-xl`
|
|
19
|
+
},
|
|
20
|
+
color: {
|
|
21
|
+
default: "text-black dark:text-white",
|
|
22
|
+
muted: "text-gray-500 dark:text-polar-500",
|
|
23
|
+
disabled: "text-gray-400 dark:text-polar-600",
|
|
24
|
+
accent: "text-indigo-500 dark:text-indigo-500",
|
|
25
|
+
danger: "text-red-500 dark:text-red-500",
|
|
26
|
+
error: "text-red-500 dark:text-red-500",
|
|
27
|
+
warning: "text-amber-500 dark:text-amber-500",
|
|
28
|
+
success: "text-emerald-500 dark:text-emerald-500",
|
|
29
|
+
inverse: "text-white dark:text-black",
|
|
30
|
+
white: "text-white dark:text-white",
|
|
31
|
+
black: "text-black dark:text-black",
|
|
32
|
+
inherit: ""
|
|
33
|
+
},
|
|
34
|
+
align: {
|
|
35
|
+
left: "text-left",
|
|
36
|
+
center: "text-center",
|
|
37
|
+
right: "text-right",
|
|
38
|
+
justify: "text-justify"
|
|
39
|
+
},
|
|
40
|
+
wrap: {
|
|
41
|
+
wrap: "text-wrap",
|
|
42
|
+
nowrap: "text-nowrap",
|
|
43
|
+
balance: "text-balance",
|
|
44
|
+
pretty: "text-pretty"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
defaultVariants: {
|
|
48
|
+
variant: "default",
|
|
49
|
+
color: "default"
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const VARIANT_DEFAULT_TAG = {
|
|
53
|
+
default: "p",
|
|
54
|
+
body: "p",
|
|
55
|
+
label: "p",
|
|
56
|
+
caption: "p",
|
|
57
|
+
"heading-2xl": "h1",
|
|
58
|
+
"heading-xl": "h2",
|
|
59
|
+
"heading-l": "h3",
|
|
60
|
+
"heading-m": "h4",
|
|
61
|
+
"heading-s": "h5",
|
|
62
|
+
"heading-xs": "h6",
|
|
63
|
+
"heading-xxs": "h6"
|
|
64
|
+
};
|
|
65
|
+
const VARIANT_DEFAULT_WRAP = {
|
|
66
|
+
body: "pretty",
|
|
67
|
+
"heading-2xl": "balance",
|
|
68
|
+
"heading-xl": "balance",
|
|
69
|
+
"heading-l": "balance"
|
|
70
|
+
};
|
|
71
|
+
const numberFormatter = new Intl.NumberFormat("en-US");
|
|
72
|
+
const compactFormatter = new Intl.NumberFormat("en-US", { notation: "compact" });
|
|
73
|
+
function applyFormatter(formatter, value) {
|
|
74
|
+
if (typeof formatter === "function") return formatter(value);
|
|
75
|
+
const n = typeof value === "number" ? value : Number(value);
|
|
76
|
+
if (Number.isNaN(n)) return String(value);
|
|
77
|
+
return formatter === "compact" ? compactFormatter.format(n) : numberFormatter.format(n);
|
|
78
|
+
}
|
|
79
|
+
const HEADING_FONT_FEATURES = "'ss07' 1, 'ss08' 1, 'zero' 1, 'liga' 0";
|
|
80
|
+
const SKELETON_CLASSES = "dark:bg-polar-700 animate-pulse rounded-sm bg-gray-100";
|
|
81
|
+
const renderMultiLineSkeleton = (lines) => Array.from({ length: lines }, (_, i) => /* @__PURE__ */ jsx(
|
|
82
|
+
"span",
|
|
83
|
+
{
|
|
84
|
+
"aria-hidden": true,
|
|
85
|
+
style: {
|
|
86
|
+
display: "flex",
|
|
87
|
+
alignItems: "center",
|
|
88
|
+
height: "1lh"
|
|
89
|
+
},
|
|
90
|
+
children: /* @__PURE__ */ jsx(
|
|
91
|
+
"span",
|
|
92
|
+
{
|
|
93
|
+
className: SKELETON_CLASSES,
|
|
94
|
+
style: {
|
|
95
|
+
display: "block",
|
|
96
|
+
height: "1em",
|
|
97
|
+
width: i === lines - 1 ? "60%" : "100%"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
},
|
|
102
|
+
i
|
|
103
|
+
));
|
|
104
|
+
const renderSingleLineSkeleton = (placeholder) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
105
|
+
/* @__PURE__ */ jsx("span", { style: { visibility: "hidden" }, children: placeholder }),
|
|
106
|
+
/* @__PURE__ */ jsx(
|
|
107
|
+
"span",
|
|
108
|
+
{
|
|
109
|
+
"aria-hidden": true,
|
|
110
|
+
className: SKELETON_CLASSES,
|
|
111
|
+
style: { position: "absolute", inset: 0 }
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
] });
|
|
115
|
+
function Text({
|
|
116
|
+
as,
|
|
117
|
+
variant,
|
|
118
|
+
color,
|
|
119
|
+
align,
|
|
120
|
+
wrap,
|
|
121
|
+
children,
|
|
122
|
+
style,
|
|
123
|
+
loading,
|
|
124
|
+
placeholderText,
|
|
125
|
+
placeholderNumberOfLines,
|
|
126
|
+
lineThrough,
|
|
127
|
+
monospace,
|
|
128
|
+
tabularNums,
|
|
129
|
+
truncate,
|
|
130
|
+
formatter,
|
|
131
|
+
...props
|
|
132
|
+
}) {
|
|
133
|
+
const resolvedVariant = variant ?? "default";
|
|
134
|
+
const Tag = as ?? VARIANT_DEFAULT_TAG[resolvedVariant];
|
|
135
|
+
const isHeading = resolvedVariant.startsWith("heading-");
|
|
136
|
+
const resolvedWrap = wrap ?? (truncate ? void 0 : VARIANT_DEFAULT_WRAP[resolvedVariant]);
|
|
137
|
+
let content = formatter !== void 0 && (typeof children === "string" || typeof children === "number") ? applyFormatter(formatter, children) : children;
|
|
138
|
+
let loadingStyle;
|
|
139
|
+
if (loading) {
|
|
140
|
+
const lines = placeholderNumberOfLines ?? 1;
|
|
141
|
+
if (lines > 1) {
|
|
142
|
+
content = renderMultiLineSkeleton(lines);
|
|
143
|
+
loadingStyle = void 0;
|
|
144
|
+
} else {
|
|
145
|
+
content = renderSingleLineSkeleton(
|
|
146
|
+
placeholderText ?? children ?? "Loading..."
|
|
147
|
+
);
|
|
148
|
+
loadingStyle = { position: "relative", display: "inline-block" };
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const mergedStyle = {
|
|
152
|
+
...isHeading && { fontFeatureSettings: HEADING_FONT_FEATURES },
|
|
153
|
+
...lineThrough ? { textDecoration: "line-through" } : {},
|
|
154
|
+
...typeof truncate === "number" ? {
|
|
155
|
+
display: "-webkit-box",
|
|
156
|
+
WebkitLineClamp: truncate,
|
|
157
|
+
WebkitBoxOrient: "vertical",
|
|
158
|
+
overflow: "hidden"
|
|
159
|
+
} : {},
|
|
160
|
+
...style,
|
|
161
|
+
...loadingStyle
|
|
162
|
+
};
|
|
163
|
+
return /* @__PURE__ */ jsx(
|
|
164
|
+
Tag,
|
|
165
|
+
{
|
|
166
|
+
className: twMerge(
|
|
167
|
+
textVariants({ variant, color, align, wrap: resolvedWrap }),
|
|
168
|
+
monospace && "font-mono",
|
|
169
|
+
tabularNums && "tabular-nums",
|
|
170
|
+
truncate === true && "truncate"
|
|
171
|
+
),
|
|
172
|
+
style: mergedStyle,
|
|
173
|
+
...props,
|
|
174
|
+
children: content
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
Text.displayName = "Text";
|
|
179
|
+
function createText() {
|
|
180
|
+
return Text;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export { Text, createText };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type Breakpoint = 'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
2
|
+
export type Responsive<T> = T | Partial<Record<Breakpoint, T>>;
|
|
3
|
+
export type FlexContainerProps = {
|
|
4
|
+
display?: Responsive<'flex' | 'block' | 'inline-flex' | 'grid' | 'inline-grid' | 'hidden'>;
|
|
5
|
+
flexDirection?: Responsive<'row' | 'column' | 'row-reverse' | 'column-reverse'>;
|
|
6
|
+
alignItems?: Responsive<'start' | 'end' | 'center' | 'stretch' | 'baseline'>;
|
|
7
|
+
justifyContent?: Responsive<'start' | 'end' | 'center' | 'between' | 'around' | 'evenly'>;
|
|
8
|
+
flexWrap?: Responsive<'wrap' | 'nowrap' | 'wrap-reverse'>;
|
|
9
|
+
};
|
|
10
|
+
export type FlexChildProps = {
|
|
11
|
+
flex?: Responsive<'1' | 'auto' | 'none' | 'initial'>;
|
|
12
|
+
alignSelf?: Responsive<'auto' | 'start' | 'end' | 'center' | 'stretch' | 'baseline'>;
|
|
13
|
+
flexGrow?: '0' | '1';
|
|
14
|
+
flexShrink?: '0' | '1';
|
|
15
|
+
};
|
|
16
|
+
export declare function resolveContainerClasses(props: FlexContainerProps): string;
|
|
17
|
+
export declare function resolveFlexChildClasses(props: FlexChildProps): string;
|