@mbao01/common 0.0.6 → 0.0.8
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/dist/types/components/Avatar/Avatar.d.ts +14 -0
- package/dist/types/components/Avatar/constants.d.ts +15 -0
- package/dist/types/components/Avatar/index.d.ts +1 -0
- package/dist/types/components/Avatar/types.d.ts +7 -0
- package/dist/types/components/Badge/types.d.ts +1 -0
- package/dist/types/components/Breadcrumbs/types.d.ts +1 -0
- package/dist/types/components/Combobox/Combobox.d.ts +2 -0
- package/dist/types/components/Combobox/index.d.ts +1 -0
- package/dist/types/components/Combobox/types.d.ts +19 -0
- package/dist/types/components/Command/Command.d.ts +67 -0
- package/dist/types/components/Command/constants.d.ts +11 -0
- package/dist/types/components/Command/index.d.ts +1 -0
- package/dist/types/components/Command/types.d.ts +8 -0
- package/dist/types/components/Description/types.d.ts +1 -0
- package/dist/types/components/Dialog/Dialog.d.ts +22 -0
- package/dist/types/components/Dialog/constants.d.ts +7 -0
- package/dist/types/components/Dialog/index.d.ts +1 -0
- package/dist/types/components/Dialog/types.d.ts +11 -0
- package/dist/types/components/Form/Checkbox/Checkbox.d.ts +6 -0
- package/dist/types/components/Form/Checkbox/constants.d.ts +4 -0
- package/dist/types/components/Form/Checkbox/index.d.ts +1 -0
- package/dist/types/components/Form/Checkbox/types.d.ts +4 -0
- package/dist/types/components/Form/Input/Input.d.ts +7 -0
- package/dist/types/components/Form/Input/constants.d.ts +6 -0
- package/dist/types/components/Form/Input/index.d.ts +1 -0
- package/dist/types/components/Form/Input/types.d.ts +4 -0
- package/dist/types/components/Form/Phone/Phone.d.ts +17 -0
- package/dist/types/components/Form/Phone/constants.d.ts +2 -0
- package/dist/types/components/Form/Phone/index.d.ts +1 -0
- package/dist/types/components/Form/Phone/types.d.ts +8 -0
- package/dist/types/components/Form/Radio/Radio.d.ts +6 -0
- package/dist/types/components/Form/Radio/constants.d.ts +4 -0
- package/dist/types/components/Form/Radio/index.d.ts +1 -0
- package/dist/types/components/Form/Radio/types.d.ts +4 -0
- package/dist/types/components/Form/Range/Range.d.ts +8 -0
- package/dist/types/components/Form/Range/constants.d.ts +6 -0
- package/dist/types/components/Form/Range/index.d.ts +1 -0
- package/dist/types/components/Form/Range/types.d.ts +4 -0
- package/dist/types/components/Form/Select/Select.d.ts +27 -0
- package/dist/types/components/Form/Select/constants.d.ts +17 -0
- package/dist/types/components/Form/Select/index.d.ts +1 -0
- package/dist/types/components/Form/Select/types.d.ts +7 -0
- package/dist/types/components/Form/Slider/Slider.d.ts +15 -0
- package/dist/types/components/Form/Slider/constants.d.ts +15 -0
- package/dist/types/components/Form/Slider/index.d.ts +1 -0
- package/dist/types/components/Form/Slider/types.d.ts +5 -0
- package/dist/types/components/Form/Switch/Switch.d.ts +6 -0
- package/dist/types/components/Form/Switch/constants.d.ts +4 -0
- package/dist/types/components/Form/Switch/index.d.ts +1 -0
- package/dist/types/components/Form/Switch/types.d.ts +4 -0
- package/dist/types/components/Form/TextField/TextField.d.ts +10 -0
- package/dist/types/components/Form/TextField/constants.d.ts +1 -0
- package/dist/types/components/Form/TextField/index.d.ts +1 -0
- package/dist/types/components/Form/TextField/types.d.ts +6 -0
- package/dist/types/components/Form/Textarea/Textarea.d.ts +8 -0
- package/dist/types/components/Form/Textarea/constants.d.ts +6 -0
- package/dist/types/components/Form/Textarea/index.d.ts +1 -0
- package/dist/types/components/Form/Textarea/types.d.ts +4 -0
- package/dist/types/components/Form/components/FormControl/FormControl.d.ts +2 -0
- package/dist/types/components/Form/components/FormControl/constants.d.ts +1 -0
- package/dist/types/components/Form/components/FormControl/index.d.ts +1 -0
- package/dist/types/components/Form/components/FormControl/types.d.ts +9 -0
- package/dist/types/components/Form/components/Label/Label.d.ts +7 -0
- package/dist/types/components/Form/components/Label/constants.d.ts +1 -0
- package/dist/types/components/Form/components/Label/index.d.ts +1 -0
- package/dist/types/components/Form/components/Label/types.d.ts +6 -0
- package/dist/types/components/Form/index.d.ts +11 -0
- package/dist/types/components/Loading/types.d.ts +1 -0
- package/dist/types/components/Popover/Popover.d.ts +9 -0
- package/dist/types/components/Popover/constants.d.ts +1 -0
- package/dist/types/components/Popover/index.d.ts +1 -0
- package/dist/types/components/Popover/types.d.ts +6 -0
- package/dist/types/components/Progress/Progress.d.ts +5 -0
- package/dist/types/components/Progress/constants.d.ts +6 -0
- package/dist/types/components/Progress/index.d.ts +1 -0
- package/dist/types/components/Progress/types.d.ts +5 -0
- package/dist/types/components/Separator/Separator.d.ts +2 -0
- package/dist/types/components/Separator/constants.d.ts +3 -0
- package/dist/types/components/Separator/index.d.ts +1 -0
- package/dist/types/components/Separator/types.d.ts +3 -0
- package/dist/types/components/Skeleton/constants.d.ts +2 -2
- package/dist/types/components/Skeleton/types.d.ts +1 -0
- package/dist/types/components/Text/Text.d.ts +2 -2
- package/dist/types/components/Text/types.d.ts +6 -2
- package/dist/types/components/Tooltip/types.d.ts +1 -0
- package/dist/types/index.d.ts +9 -0
- package/package.json +24 -13
- package/src/components/Avatar/Avatar.tsx +59 -0
- package/src/components/Avatar/constants.ts +69 -0
- package/src/components/Avatar/index.ts +1 -0
- package/src/components/Avatar/types.ts +25 -0
- package/src/components/Combobox/Combobox.tsx +82 -0
- package/src/components/Combobox/index.ts +1 -0
- package/src/components/Combobox/types.ts +21 -0
- package/src/components/Command/Command.tsx +142 -0
- package/src/components/Command/constants.ts +39 -0
- package/src/components/Command/index.ts +1 -0
- package/src/components/Command/types.ts +16 -0
- package/src/components/Dialog/Dialog.tsx +105 -0
- package/src/components/Dialog/constants.ts +27 -0
- package/src/components/Dialog/index.ts +1 -0
- package/src/components/Dialog/types.ts +40 -0
- package/src/components/Form/Checkbox/Checkbox.tsx +18 -0
- package/src/components/Form/Checkbox/constants.ts +21 -0
- package/src/components/Form/Checkbox/index.ts +1 -0
- package/src/components/Form/Checkbox/types.ts +8 -0
- package/src/components/Form/Input/Input.tsx +18 -0
- package/src/components/Form/Input/constants.ts +37 -0
- package/src/components/Form/Input/index.ts +1 -0
- package/src/components/Form/Input/types.ts +8 -0
- package/src/components/Form/Phone/Phone.tsx +120 -0
- package/src/components/Form/Phone/constants.ts +7 -0
- package/src/components/Form/Phone/index.ts +1 -0
- package/src/components/Form/Phone/types.ts +12 -0
- package/src/components/Form/Radio/Radio.tsx +18 -0
- package/src/components/Form/Radio/constants.ts +21 -0
- package/src/components/Form/Radio/index.ts +1 -0
- package/src/components/Form/Radio/types.ts +8 -0
- package/src/components/Form/Range/Range.tsx +22 -0
- package/src/components/Form/Range/constants.ts +31 -0
- package/src/components/Form/Range/index.ts +1 -0
- package/src/components/Form/Range/types.ts +8 -0
- package/src/components/Form/Select/Select.tsx +151 -0
- package/src/components/Form/Select/constants.ts +80 -0
- package/src/components/Form/Select/index.ts +1 -0
- package/src/components/Form/Select/types.ts +18 -0
- package/src/components/Form/Slider/Slider.tsx +43 -0
- package/src/components/Form/Slider/constants.ts +87 -0
- package/src/components/Form/Slider/index.ts +1 -0
- package/src/components/Form/Slider/types.ts +16 -0
- package/src/components/Form/Switch/Switch.tsx +19 -0
- package/src/components/Form/Switch/constants.ts +21 -0
- package/src/components/Form/Switch/index.ts +1 -0
- package/src/components/Form/Switch/types.ts +8 -0
- package/src/components/Form/TextField/TextField.tsx +37 -0
- package/src/components/Form/TextField/constants.ts +5 -0
- package/src/components/Form/TextField/index.ts +1 -0
- package/src/components/Form/TextField/types.ts +7 -0
- package/src/components/Form/Textarea/Textarea.tsx +22 -0
- package/src/components/Form/Textarea/constants.ts +37 -0
- package/src/components/Form/Textarea/index.ts +1 -0
- package/src/components/Form/Textarea/types.ts +8 -0
- package/src/components/Form/components/FormControl/FormControl.tsx +21 -0
- package/src/components/Form/components/FormControl/constants.ts +3 -0
- package/src/components/Form/components/FormControl/index.ts +1 -0
- package/src/components/Form/components/FormControl/types.ts +13 -0
- package/src/components/Form/components/Label/Label.tsx +22 -0
- package/src/components/Form/components/Label/constants.ts +3 -0
- package/src/components/Form/components/Label/index.ts +1 -0
- package/src/components/Form/components/Label/types.ts +10 -0
- package/src/components/Form/index.ts +11 -0
- package/src/components/Popover/Popover.tsx +30 -0
- package/src/components/Popover/constants.ts +5 -0
- package/src/components/Popover/index.ts +1 -0
- package/src/components/Popover/types.ts +12 -0
- package/src/components/Progress/Progress.tsx +31 -0
- package/src/components/Progress/constants.ts +49 -0
- package/src/components/Progress/index.ts +1 -0
- package/src/components/Progress/types.ts +9 -0
- package/src/components/Separator/Separator.tsx +20 -0
- package/src/components/Separator/constants.ts +10 -0
- package/src/components/Separator/index.ts +1 -0
- package/src/components/Separator/types.ts +5 -0
- package/src/components/Text/Text.tsx +3 -3
- package/src/components/Text/types.ts +8 -5
- package/src/index.ts +10 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Textarea } from "./Textarea";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
2
|
+
import type { As, FormControlProps } from "./types";
|
|
3
|
+
import { getFormControlClasses } from "./constants";
|
|
4
|
+
import { cn } from "../../../../utilities";
|
|
5
|
+
import { Label } from "../Label";
|
|
6
|
+
|
|
7
|
+
export const FormControl = <T extends As>({
|
|
8
|
+
as,
|
|
9
|
+
children,
|
|
10
|
+
className,
|
|
11
|
+
...props
|
|
12
|
+
}: FormControlProps<T>) => {
|
|
13
|
+
const SlotChild = !as || as === "label" ? Label : as;
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Slot className={cn(getFormControlClasses(), className)} {...props}>
|
|
17
|
+
{/* slot merges it's prop into it's immediate child */}
|
|
18
|
+
<SlotChild>{children}</SlotChild>
|
|
19
|
+
</Slot>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FormControl } from "./FormControl";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type VariantProps } from "../../../../libs";
|
|
2
|
+
import { getFormControlClasses } from "./constants";
|
|
3
|
+
|
|
4
|
+
export type As = "div" | "span" | "label";
|
|
5
|
+
|
|
6
|
+
type AllowedElements = Pick<JSX.IntrinsicElements, As>;
|
|
7
|
+
|
|
8
|
+
export type FormControlProps<T extends As> = (T extends "label"
|
|
9
|
+
? React.LabelHTMLAttributes<HTMLLabelElement>
|
|
10
|
+
: React.HTMLAttributes<HTMLElement & AllowedElements[T]>) &
|
|
11
|
+
VariantProps<typeof getFormControlClasses> & {
|
|
12
|
+
as?: T;
|
|
13
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
2
|
+
import type { LabelProps, LabelTextProps } from "./types";
|
|
3
|
+
import { cn } from "../../../../utilities";
|
|
4
|
+
import { getLabelClasses } from "./constants";
|
|
5
|
+
|
|
6
|
+
const Label = ({ className, ...props }: LabelProps) => (
|
|
7
|
+
<LabelPrimitive.Root
|
|
8
|
+
className={cn(getLabelClasses(), className)}
|
|
9
|
+
{...props}
|
|
10
|
+
/>
|
|
11
|
+
);
|
|
12
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
13
|
+
|
|
14
|
+
const LabelText = ({ className, ...props }: LabelTextProps) => (
|
|
15
|
+
<span className={cn("label-text", className)} {...props}>
|
|
16
|
+
Pick the best fantasy franchise
|
|
17
|
+
</span>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
Label.Text = LabelText;
|
|
21
|
+
|
|
22
|
+
export { Label };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Label } from "./Label";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
2
|
+
import { type VariantProps } from "../../../../libs";
|
|
3
|
+
import { getLabelClasses } from "./constants";
|
|
4
|
+
|
|
5
|
+
export type LabelProps = React.ComponentPropsWithoutRef<
|
|
6
|
+
typeof LabelPrimitive.Root
|
|
7
|
+
> &
|
|
8
|
+
VariantProps<typeof getLabelClasses>;
|
|
9
|
+
|
|
10
|
+
export type LabelTextProps = React.HTMLAttributes<HTMLSpanElement>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { Input } from "./Input";
|
|
2
|
+
export { Phone } from "./Phone";
|
|
3
|
+
export { Radio } from "./Radio";
|
|
4
|
+
export { Range } from "./Range";
|
|
5
|
+
export { Select } from "./Select";
|
|
6
|
+
export { Slider } from "./Slider";
|
|
7
|
+
export { Checkbox } from "./Checkbox";
|
|
8
|
+
export { Textarea } from "./Textarea";
|
|
9
|
+
export { TextField } from "./TextField";
|
|
10
|
+
export { Label } from "./components/Label";
|
|
11
|
+
export { FormControl } from "./components/FormControl";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
5
|
+
import { getPopoverContentClasses } from "./constants";
|
|
6
|
+
import { cn } from "../../utilities";
|
|
7
|
+
import { PopoverContentProps, PopoverProps } from "./types";
|
|
8
|
+
|
|
9
|
+
const Popover = (props: PopoverProps) => <PopoverPrimitive.Root {...props} />;
|
|
10
|
+
|
|
11
|
+
const PopoverContent = React.forwardRef<
|
|
12
|
+
React.ElementRef<typeof PopoverPrimitive.Content>,
|
|
13
|
+
PopoverContentProps
|
|
14
|
+
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
|
|
15
|
+
<PopoverPrimitive.Portal>
|
|
16
|
+
<PopoverPrimitive.Content
|
|
17
|
+
ref={ref}
|
|
18
|
+
align={align}
|
|
19
|
+
sideOffset={sideOffset}
|
|
20
|
+
className={cn(getPopoverContentClasses(), className)}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
</PopoverPrimitive.Portal>
|
|
24
|
+
));
|
|
25
|
+
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
26
|
+
|
|
27
|
+
Popover.Content = PopoverContent;
|
|
28
|
+
Popover.Trigger = PopoverPrimitive.Trigger;
|
|
29
|
+
|
|
30
|
+
export { Popover };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
|
|
3
|
+
export const getPopoverContentClasses = cva(
|
|
4
|
+
"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
|
|
5
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Popover } from "./Popover";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
2
|
+
import { type VariantProps } from "../../libs";
|
|
3
|
+
import { getPopoverContentClasses } from "./constants";
|
|
4
|
+
|
|
5
|
+
export type PopoverProps = React.ComponentPropsWithoutRef<
|
|
6
|
+
typeof PopoverPrimitive.Root
|
|
7
|
+
>;
|
|
8
|
+
|
|
9
|
+
export type PopoverContentProps = React.ComponentPropsWithoutRef<
|
|
10
|
+
typeof PopoverPrimitive.Content
|
|
11
|
+
> &
|
|
12
|
+
VariantProps<typeof getPopoverContentClasses>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import * as ProgressPrimitive from "@radix-ui/react-progress";
|
|
5
|
+
import { type ProgressProps } from "./types";
|
|
6
|
+
import { cn } from "../../utilities";
|
|
7
|
+
import { getProgressClasses, getProgressIndicatorClasses } from "./constants";
|
|
8
|
+
|
|
9
|
+
export const Progress = React.forwardRef<
|
|
10
|
+
React.ElementRef<typeof ProgressPrimitive.Root>,
|
|
11
|
+
ProgressProps
|
|
12
|
+
>(({ className, value, max = 100, variant, ...props }, ref) => (
|
|
13
|
+
<ProgressPrimitive.Root
|
|
14
|
+
ref={ref}
|
|
15
|
+
max={max}
|
|
16
|
+
value={value}
|
|
17
|
+
className={cn(getProgressClasses({ variant }), className)}
|
|
18
|
+
{...props}
|
|
19
|
+
>
|
|
20
|
+
<ProgressPrimitive.Indicator
|
|
21
|
+
className={cn(getProgressIndicatorClasses({ variant }))}
|
|
22
|
+
style={{
|
|
23
|
+
transform: `translateX(-${
|
|
24
|
+
(100 * (max - Math.max(Math.min(value ?? 0, max), 0))) / max
|
|
25
|
+
}%)`,
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
28
|
+
</ProgressPrimitive.Root>
|
|
29
|
+
));
|
|
30
|
+
|
|
31
|
+
Progress.displayName = ProgressPrimitive.Root.displayName;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
|
|
3
|
+
export const getProgressClasses = cva(
|
|
4
|
+
"relative h-2 w-full overflow-hidden rounded-full",
|
|
5
|
+
{
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
accent: "bg-accent/20",
|
|
9
|
+
base: "bg-base-content/20",
|
|
10
|
+
error: "bg-error/20",
|
|
11
|
+
ghost: "bg-ghost/20",
|
|
12
|
+
info: "bg-info/20",
|
|
13
|
+
link: "bg-link/20",
|
|
14
|
+
neutral: "bg-neutral/20",
|
|
15
|
+
primary: "bg-primary/20",
|
|
16
|
+
secondary: "bg-secondary/20",
|
|
17
|
+
success: "bg-success/20",
|
|
18
|
+
warning: "bg-warning/20",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
defaultVariants: {
|
|
22
|
+
variant: "base",
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
export const getProgressIndicatorClasses = cva(
|
|
28
|
+
"h-full w-full flex-1 transition-all",
|
|
29
|
+
{
|
|
30
|
+
variants: {
|
|
31
|
+
variant: {
|
|
32
|
+
accent: "bg-accent",
|
|
33
|
+
base: "bg-base-content",
|
|
34
|
+
error: "bg-error",
|
|
35
|
+
ghost: "bg-ghost",
|
|
36
|
+
info: "bg-info",
|
|
37
|
+
link: "bg-link",
|
|
38
|
+
neutral: "bg-neutral",
|
|
39
|
+
primary: "bg-primary",
|
|
40
|
+
secondary: "bg-secondary",
|
|
41
|
+
success: "bg-success",
|
|
42
|
+
warning: "bg-warning",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
defaultVariants: {
|
|
46
|
+
variant: "base",
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Progress } from "./Progress";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as ProgressPrimitive from "@radix-ui/react-progress";
|
|
2
|
+
import { type VariantProps } from "../../libs";
|
|
3
|
+
import { getProgressClasses } from "./constants";
|
|
4
|
+
|
|
5
|
+
export type ProgressProps = Omit<
|
|
6
|
+
React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>,
|
|
7
|
+
"asChild"
|
|
8
|
+
> &
|
|
9
|
+
VariantProps<typeof getProgressClasses>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
|
4
|
+
import { type SeparatorProps } from "./types";
|
|
5
|
+
import { getSeparatorClasses } from "./constants";
|
|
6
|
+
import { cn } from "../../utilities";
|
|
7
|
+
|
|
8
|
+
export const Separator = ({
|
|
9
|
+
className,
|
|
10
|
+
orientation = "horizontal",
|
|
11
|
+
decorative = true,
|
|
12
|
+
...props
|
|
13
|
+
}: SeparatorProps) => (
|
|
14
|
+
<SeparatorPrimitive.Root
|
|
15
|
+
decorative={decorative}
|
|
16
|
+
orientation={orientation}
|
|
17
|
+
className={cn(getSeparatorClasses({ orientation }), className)}
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Separator } from "./Separator";
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import type { As, TextProps } from "./types";
|
|
3
3
|
import { getTextClasses } from "./constants";
|
|
4
4
|
import { cn } from "../../utilities";
|
|
5
5
|
import { Slot } from "@radix-ui/react-slot";
|
|
6
6
|
|
|
7
|
-
export const Text = ({
|
|
7
|
+
export const Text = <T extends As>({
|
|
8
8
|
as,
|
|
9
9
|
size,
|
|
10
10
|
variant,
|
|
11
11
|
children,
|
|
12
12
|
className,
|
|
13
13
|
...props
|
|
14
|
-
}: TextProps) => {
|
|
14
|
+
}: TextProps<T>) => {
|
|
15
15
|
const Comp = as ? Slot : "span";
|
|
16
16
|
const SlotChild = as ? as : React.Fragment;
|
|
17
17
|
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { type VariantProps } from "../../libs";
|
|
2
2
|
import { getTextClasses } from "./constants";
|
|
3
3
|
|
|
4
|
-
export type
|
|
4
|
+
export type As = "h1" | "h2" | "h3" | "h4" | "h5" | "p" | "span";
|
|
5
|
+
|
|
6
|
+
type AllowedElements = Pick<JSX.IntrinsicElements, As>;
|
|
7
|
+
|
|
8
|
+
export type TextProps<T extends As> = React.HTMLAttributes<
|
|
9
|
+
HTMLElement & AllowedElements[T]
|
|
10
|
+
> &
|
|
5
11
|
VariantProps<typeof getTextClasses> & {
|
|
6
|
-
as?:
|
|
7
|
-
JSX.IntrinsicElements,
|
|
8
|
-
"h1" | "h2" | "h3" | "h4" | "h5" | "p"
|
|
9
|
-
>;
|
|
12
|
+
as?: As;
|
|
10
13
|
};
|
package/src/index.ts
CHANGED
|
@@ -3,14 +3,24 @@ export * from "./components/Button";
|
|
|
3
3
|
export * from "./components/Breadcrumbs";
|
|
4
4
|
|
|
5
5
|
/** data display */
|
|
6
|
+
export * from "./components/Avatar";
|
|
6
7
|
export * from "./components/Badge";
|
|
7
8
|
export * from "./components/Card";
|
|
8
9
|
export * from "./components/Description";
|
|
10
|
+
export * from "./components/Progress";
|
|
11
|
+
export * from "./components/Separator";
|
|
9
12
|
export * from "./components/Text";
|
|
10
13
|
|
|
11
14
|
/** data input */
|
|
15
|
+
export * from "./components/Form";
|
|
16
|
+
export * from "./components/Combobox";
|
|
12
17
|
|
|
13
18
|
/** feedback */
|
|
14
19
|
export * from "./components/Loading";
|
|
15
20
|
export * from "./components/Skeleton";
|
|
16
21
|
export * from "./components/Tooltip";
|
|
22
|
+
|
|
23
|
+
/** composable */
|
|
24
|
+
export * from "./components/Dialog";
|
|
25
|
+
export * from "./components/Command";
|
|
26
|
+
export * from "./components/Popover";
|