@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,7 @@
|
|
|
1
|
+
import type { LabelProps, LabelTextProps } from "./types";
|
|
2
|
+
declare const Label: {
|
|
3
|
+
({ className, ...props }: LabelProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
displayName: string | undefined;
|
|
5
|
+
Text: ({ className, ...props }: LabelTextProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
};
|
|
7
|
+
export { Label };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getLabelClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Label } from "./Label";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
3
|
+
import { type VariantProps } from "../../../../libs";
|
|
4
|
+
import { getLabelClasses } from "./constants";
|
|
5
|
+
export type LabelProps = React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof getLabelClasses>;
|
|
6
|
+
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,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
3
|
+
import { PopoverProps } from "./types";
|
|
4
|
+
declare const Popover: {
|
|
5
|
+
(props: PopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
Content: React.ForwardRefExoticComponent<Omit<PopoverPrimitive.PopoverContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & import("class-variance-authority").VariantProps<(props?: import("class-variance-authority/types").ClassProp | undefined) => string> & React.RefAttributes<HTMLDivElement>>;
|
|
7
|
+
Trigger: React.ForwardRefExoticComponent<PopoverPrimitive.PopoverTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
8
|
+
};
|
|
9
|
+
export { Popover };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getPopoverContentClasses: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Popover } from "./Popover";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
3
|
+
import { type VariantProps } from "../../libs";
|
|
4
|
+
import { getPopoverContentClasses } from "./constants";
|
|
5
|
+
export type PopoverProps = React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Root>;
|
|
6
|
+
export type PopoverContentProps = React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content> & VariantProps<typeof getPopoverContentClasses>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as ProgressPrimitive from "@radix-ui/react-progress";
|
|
3
|
+
export declare const Progress: React.ForwardRefExoticComponent<Omit<Omit<ProgressPrimitive.ProgressProps & React.RefAttributes<HTMLDivElement>, "ref">, "asChild"> & import("class-variance-authority").VariantProps<(props?: ({
|
|
4
|
+
variant?: "accent" | "error" | "ghost" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | "base" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const getProgressClasses: (props?: ({
|
|
2
|
+
variant?: "accent" | "error" | "ghost" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | "base" | null | undefined;
|
|
3
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
4
|
+
export declare const getProgressIndicatorClasses: (props?: ({
|
|
5
|
+
variant?: "accent" | "error" | "ghost" | "info" | "link" | "neutral" | "primary" | "secondary" | "success" | "warning" | "base" | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Progress } from "./Progress";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import * as ProgressPrimitive from "@radix-ui/react-progress";
|
|
3
|
+
import { type VariantProps } from "../../libs";
|
|
4
|
+
import { getProgressClasses } from "./constants";
|
|
5
|
+
export type ProgressProps = Omit<React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>, "asChild"> & VariantProps<typeof getProgressClasses>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Separator } from "./Separator";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const getSkeletonClasses: (props?: ({
|
|
2
2
|
variant?: "pulse" | null | undefined;
|
|
3
|
-
width?:
|
|
4
|
-
height?:
|
|
3
|
+
width?: 4 | 8 | 12 | 16 | 24 | 32 | 48 | 64 | 2 | "full" | null | undefined;
|
|
4
|
+
height?: 4 | 8 | 12 | 16 | 24 | 32 | 48 | 64 | 2 | "full" | null | undefined;
|
|
5
5
|
round?: boolean | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const Text: ({ as, size, variant, children, className, ...props }: TextProps) => import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
import type { As, TextProps } from "./types";
|
|
2
|
+
export declare const Text: <T extends As>({ as, size, variant, children, className, ...props }: TextProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { type VariantProps } from "../../libs";
|
|
2
3
|
import { getTextClasses } from "./constants";
|
|
3
|
-
export type
|
|
4
|
-
|
|
4
|
+
export type As = "h1" | "h2" | "h3" | "h4" | "h5" | "p" | "span";
|
|
5
|
+
type AllowedElements = Pick<JSX.IntrinsicElements, As>;
|
|
6
|
+
export type TextProps<T extends As> = React.HTMLAttributes<HTMLElement & AllowedElements[T]> & VariantProps<typeof getTextClasses> & {
|
|
7
|
+
as?: As;
|
|
5
8
|
};
|
|
9
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,12 +2,21 @@
|
|
|
2
2
|
export * from "./components/Button";
|
|
3
3
|
export * from "./components/Breadcrumbs";
|
|
4
4
|
/** data display */
|
|
5
|
+
export * from "./components/Avatar";
|
|
5
6
|
export * from "./components/Badge";
|
|
6
7
|
export * from "./components/Card";
|
|
7
8
|
export * from "./components/Description";
|
|
9
|
+
export * from "./components/Progress";
|
|
10
|
+
export * from "./components/Separator";
|
|
8
11
|
export * from "./components/Text";
|
|
9
12
|
/** data input */
|
|
13
|
+
export * from "./components/Form";
|
|
14
|
+
export * from "./components/Combobox";
|
|
10
15
|
/** feedback */
|
|
11
16
|
export * from "./components/Loading";
|
|
12
17
|
export * from "./components/Skeleton";
|
|
13
18
|
export * from "./components/Tooltip";
|
|
19
|
+
/** composable */
|
|
20
|
+
export * from "./components/Dialog";
|
|
21
|
+
export * from "./components/Command";
|
|
22
|
+
export * from "./components/Popover";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mbao01/common",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.8",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Ayomide Bakare",
|
|
7
7
|
"license": "MIT",
|
|
@@ -60,25 +60,36 @@
|
|
|
60
60
|
"test:coverage": "vitest run --coverage"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
+
"@radix-ui/react-avatar": "^1.0.4",
|
|
64
|
+
"@radix-ui/react-checkbox": "^1.0.4",
|
|
65
|
+
"@radix-ui/react-dialog": "^1.0.5",
|
|
63
66
|
"@radix-ui/react-icons": "^1.3.0",
|
|
67
|
+
"@radix-ui/react-label": "^2.0.2",
|
|
68
|
+
"@radix-ui/react-popover": "^1.0.7",
|
|
69
|
+
"@radix-ui/react-progress": "^1.0.3",
|
|
70
|
+
"@radix-ui/react-select": "^2.0.0",
|
|
71
|
+
"@radix-ui/react-separator": "^1.0.3",
|
|
72
|
+
"@radix-ui/react-slider": "^1.1.2",
|
|
64
73
|
"@radix-ui/react-slot": "^1.0.2",
|
|
65
74
|
"@radix-ui/react-tooltip": "^1.0.7",
|
|
66
75
|
"class-variance-authority": "^0.7.0",
|
|
67
76
|
"clsx": "^2.1.0",
|
|
77
|
+
"cmdk": "^1.0.0",
|
|
68
78
|
"daisyui": "^4.6.2",
|
|
79
|
+
"react-international-phone": "^4.2.6",
|
|
69
80
|
"tailwind-merge": "^2.2.1",
|
|
70
81
|
"tailwindcss-animate": "^1.0.7"
|
|
71
82
|
},
|
|
72
83
|
"devDependencies": {
|
|
73
|
-
"@storybook/addon-essentials": "^
|
|
74
|
-
"@storybook/addon-interactions": "^
|
|
75
|
-
"@storybook/addon-links": "^
|
|
76
|
-
"@storybook/addon-onboarding": "^
|
|
77
|
-
"@storybook/addon-themes": "^
|
|
78
|
-
"@storybook/blocks": "^
|
|
79
|
-
"@storybook/react": "^
|
|
80
|
-
"@storybook/react-vite": "^
|
|
81
|
-
"@storybook/test": "^
|
|
84
|
+
"@storybook/addon-essentials": "^8.0.6",
|
|
85
|
+
"@storybook/addon-interactions": "^8.0.6",
|
|
86
|
+
"@storybook/addon-links": "^8.0.6",
|
|
87
|
+
"@storybook/addon-onboarding": "^8.0.6",
|
|
88
|
+
"@storybook/addon-themes": "^8.0.6",
|
|
89
|
+
"@storybook/blocks": "^8.0.6",
|
|
90
|
+
"@storybook/react": "^8.0.6",
|
|
91
|
+
"@storybook/react-vite": "^8.0.6",
|
|
92
|
+
"@storybook/test": "^8.0.6",
|
|
82
93
|
"@testing-library/jest-dom": "^6.4.2",
|
|
83
94
|
"@testing-library/react": "^14.2.1",
|
|
84
95
|
"@testing-library/user-event": "^14.5.2",
|
|
@@ -95,14 +106,14 @@
|
|
|
95
106
|
"eslint-plugin-react": "^7.33.2",
|
|
96
107
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
97
108
|
"eslint-plugin-react-refresh": "^0.4.5",
|
|
98
|
-
"eslint-plugin-storybook": "^0.
|
|
109
|
+
"eslint-plugin-storybook": "^0.8.0",
|
|
99
110
|
"jsdom": "^23.2.0",
|
|
100
111
|
"path": "^0.12.7",
|
|
101
112
|
"postcss": "^8.4.35",
|
|
102
113
|
"react": "^18.2.0",
|
|
103
114
|
"react-dom": "^18.2.0",
|
|
104
115
|
"react-router-dom": "^6.22.0",
|
|
105
|
-
"storybook": "^
|
|
116
|
+
"storybook": "^8.0.6",
|
|
106
117
|
"tailwindcss": "^3.4.1",
|
|
107
118
|
"typescript": "^5.3.3",
|
|
108
119
|
"vite": "^5.1.1",
|
|
@@ -114,5 +125,5 @@
|
|
|
114
125
|
"react-dom": "^18.2.0",
|
|
115
126
|
"typescript": "^5.2.2"
|
|
116
127
|
},
|
|
117
|
-
"gitHead": "
|
|
128
|
+
"gitHead": "b7bb9c19b245e54a221c02998dc7ec6815cead56"
|
|
118
129
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
|
4
|
+
import type {
|
|
5
|
+
AvatarProps,
|
|
6
|
+
AvatarImageProps,
|
|
7
|
+
AvatarFallbackProps,
|
|
8
|
+
} from "./types";
|
|
9
|
+
import { cn } from "../../utilities";
|
|
10
|
+
import {
|
|
11
|
+
getAvatarClasses,
|
|
12
|
+
getAvatarImageClasses,
|
|
13
|
+
getAvatarFallbackClasses,
|
|
14
|
+
} from "./constants";
|
|
15
|
+
|
|
16
|
+
const Avatar = ({ className, size, status, ...props }: AvatarProps) => (
|
|
17
|
+
<AvatarPrimitive.Root
|
|
18
|
+
className={cn(getAvatarClasses({ size, status }), className)}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
);
|
|
22
|
+
Avatar.displayName = AvatarPrimitive.Root.displayName;
|
|
23
|
+
|
|
24
|
+
const AvatarImage = ({
|
|
25
|
+
className,
|
|
26
|
+
ring,
|
|
27
|
+
shape,
|
|
28
|
+
variant,
|
|
29
|
+
...props
|
|
30
|
+
}: AvatarImageProps) => (
|
|
31
|
+
<AvatarPrimitive.Image
|
|
32
|
+
className={cn(getAvatarImageClasses({ ring, shape, variant }), className)}
|
|
33
|
+
{...props}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
AvatarImage.displayName = AvatarPrimitive.Image.displayName;
|
|
37
|
+
|
|
38
|
+
const AvatarFallback = ({
|
|
39
|
+
className,
|
|
40
|
+
size,
|
|
41
|
+
ring,
|
|
42
|
+
shape,
|
|
43
|
+
variant,
|
|
44
|
+
...props
|
|
45
|
+
}: AvatarFallbackProps) => (
|
|
46
|
+
<AvatarPrimitive.Fallback
|
|
47
|
+
className={cn(
|
|
48
|
+
getAvatarFallbackClasses({ ring, size, shape, variant }),
|
|
49
|
+
className
|
|
50
|
+
)}
|
|
51
|
+
{...props}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
|
|
55
|
+
|
|
56
|
+
Avatar.Image = AvatarImage;
|
|
57
|
+
Avatar.Fallback = AvatarFallback;
|
|
58
|
+
|
|
59
|
+
export { Avatar };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
|
|
3
|
+
export const getAvatarClasses = cva("avatar", {
|
|
4
|
+
variants: {
|
|
5
|
+
size: {
|
|
6
|
+
4: "w-4 h-4",
|
|
7
|
+
8: "w-8 h-8",
|
|
8
|
+
12: "w-12 h-12",
|
|
9
|
+
16: "w-16 h-16",
|
|
10
|
+
24: "w-24 h-24",
|
|
11
|
+
32: "w-32 h-32",
|
|
12
|
+
48: "w-48 h-48",
|
|
13
|
+
64: "w-64 h-64",
|
|
14
|
+
},
|
|
15
|
+
status: {
|
|
16
|
+
online: "online",
|
|
17
|
+
offline: "offline",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const classesConfig = {
|
|
23
|
+
variants: {
|
|
24
|
+
variant: {
|
|
25
|
+
accent: "bg-accent text-accent-content ring-accent",
|
|
26
|
+
default: "bg-default text-default-content ring-default",
|
|
27
|
+
error: "bg-error text-error-content ring-error",
|
|
28
|
+
ghost: "bg-ghost text-ghost-content ring-ghost",
|
|
29
|
+
info: "bg-info text-info-content ring-info",
|
|
30
|
+
neutral: "bg-neutral text-neutral-content ring-neutral",
|
|
31
|
+
primary: "bg-primary text-primary-content ring-primary",
|
|
32
|
+
secondary: "bg-secondary text-secondary-content ring-secondary",
|
|
33
|
+
success: "bg-success text-success-content ring-success",
|
|
34
|
+
warning: "bg-warning text-warning-content ring-warning",
|
|
35
|
+
},
|
|
36
|
+
shape: {
|
|
37
|
+
round: "rounded",
|
|
38
|
+
circle: "rounded-full",
|
|
39
|
+
hexagon: "mask mask-hexagon",
|
|
40
|
+
triangle: "mask mask-triangle",
|
|
41
|
+
television: "mask mask-squircle",
|
|
42
|
+
},
|
|
43
|
+
ring: {
|
|
44
|
+
true: "ring ring-offset-base-100 ring-offset-2",
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const getAvatarImageClasses = cva("", classesConfig);
|
|
50
|
+
|
|
51
|
+
export const getAvatarFallbackClasses = cva(
|
|
52
|
+
"flex items-center justify-center w-full",
|
|
53
|
+
{
|
|
54
|
+
...classesConfig,
|
|
55
|
+
variants: {
|
|
56
|
+
...classesConfig.variants,
|
|
57
|
+
size: {
|
|
58
|
+
4: "text-[4px]",
|
|
59
|
+
8: "text-base",
|
|
60
|
+
12: "text-lg",
|
|
61
|
+
16: "text-xl",
|
|
62
|
+
24: "text-2xl",
|
|
63
|
+
32: "text-3xl",
|
|
64
|
+
48: "text-4xl",
|
|
65
|
+
64: "text-5xl",
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
}
|
|
69
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Avatar } from "./Avatar";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
|
2
|
+
import { type VariantProps } from "../../libs";
|
|
3
|
+
import {
|
|
4
|
+
getAvatarClasses,
|
|
5
|
+
getAvatarFallbackClasses,
|
|
6
|
+
getAvatarImageClasses,
|
|
7
|
+
} from "./constants";
|
|
8
|
+
|
|
9
|
+
export type AvatarProps = Omit<
|
|
10
|
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>,
|
|
11
|
+
"asChild" | "size"
|
|
12
|
+
> &
|
|
13
|
+
VariantProps<typeof getAvatarClasses>;
|
|
14
|
+
|
|
15
|
+
export type AvatarImageProps = Omit<
|
|
16
|
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>,
|
|
17
|
+
"asChild"
|
|
18
|
+
> &
|
|
19
|
+
VariantProps<typeof getAvatarImageClasses>;
|
|
20
|
+
|
|
21
|
+
export type AvatarFallbackProps = Omit<
|
|
22
|
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>,
|
|
23
|
+
"asChild"
|
|
24
|
+
> &
|
|
25
|
+
VariantProps<typeof getAvatarFallbackClasses>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { CaretSortIcon, CheckIcon } from "@radix-ui/react-icons";
|
|
5
|
+
import type { ComboboxProps, Item } from "./types";
|
|
6
|
+
import { cn } from "../../utilities";
|
|
7
|
+
import { Command } from "../Command";
|
|
8
|
+
import { Popover } from "../Popover";
|
|
9
|
+
import { Button } from "../Button";
|
|
10
|
+
|
|
11
|
+
export const Combobox = <T extends Item>({
|
|
12
|
+
label,
|
|
13
|
+
items,
|
|
14
|
+
classes,
|
|
15
|
+
emptyText,
|
|
16
|
+
placeholder,
|
|
17
|
+
getItemValue = (item: T) => item.value as string,
|
|
18
|
+
getItemLabel = (item: T) => item.label as string,
|
|
19
|
+
}: ComboboxProps<T>) => {
|
|
20
|
+
const [open, setOpen] = React.useState(false);
|
|
21
|
+
const [value, setValue] = React.useState<string | number | null>(null);
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
23
|
+
const [_, setItem] = React.useState<T | null>(null);
|
|
24
|
+
|
|
25
|
+
const currentItem = items?.find((item) => getItemValue(item) === value);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<Popover open={open} onOpenChange={setOpen}>
|
|
29
|
+
<Popover.Trigger asChild>
|
|
30
|
+
<Button
|
|
31
|
+
outline
|
|
32
|
+
role="combobox"
|
|
33
|
+
aria-expanded={open}
|
|
34
|
+
className={cn("justify-between", classes?.trigger)}
|
|
35
|
+
>
|
|
36
|
+
{value && currentItem ? getItemLabel(currentItem) : label}
|
|
37
|
+
<CaretSortIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
|
38
|
+
</Button>
|
|
39
|
+
</Popover.Trigger>
|
|
40
|
+
<Popover.Content className={cn("w-[200px] p-0", classes?.popoverContent)}>
|
|
41
|
+
<Command className={cn(classes?.content)}>
|
|
42
|
+
<Command.Input
|
|
43
|
+
placeholder={placeholder}
|
|
44
|
+
className={cn(classes?.input)}
|
|
45
|
+
/>
|
|
46
|
+
<Command.Empty className={cn(classes?.empty)}>
|
|
47
|
+
{emptyText}
|
|
48
|
+
</Command.Empty>
|
|
49
|
+
<Command.List>
|
|
50
|
+
<Command.Group className={cn(classes?.group)}>
|
|
51
|
+
{items?.map((item) => (
|
|
52
|
+
<Command.Item
|
|
53
|
+
key={getItemValue(item)}
|
|
54
|
+
value={getItemValue(item)}
|
|
55
|
+
onSelect={(currentValue) => {
|
|
56
|
+
setValue(currentValue === value ? null : currentValue);
|
|
57
|
+
setItem(item);
|
|
58
|
+
setOpen(false);
|
|
59
|
+
}}
|
|
60
|
+
className={cn(
|
|
61
|
+
{
|
|
62
|
+
"bg-base-300": value === getItemValue(item),
|
|
63
|
+
},
|
|
64
|
+
classes?.item
|
|
65
|
+
)}
|
|
66
|
+
>
|
|
67
|
+
<CheckIcon
|
|
68
|
+
className={cn(
|
|
69
|
+
"mr-2 h-4 w-4",
|
|
70
|
+
value === getItemValue(item) ? "opacity-100" : "opacity-0"
|
|
71
|
+
)}
|
|
72
|
+
/>
|
|
73
|
+
{getItemLabel(item)}
|
|
74
|
+
</Command.Item>
|
|
75
|
+
))}
|
|
76
|
+
</Command.Group>
|
|
77
|
+
</Command.List>
|
|
78
|
+
</Command>
|
|
79
|
+
</Popover.Content>
|
|
80
|
+
</Popover>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Combobox } from "./Combobox";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2
|
+
export type Item = Record<string, any>;
|
|
3
|
+
|
|
4
|
+
export type ComboboxProps<T extends Item> = {
|
|
5
|
+
label: string;
|
|
6
|
+
items: T[];
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
emptyText?: string;
|
|
9
|
+
getItemValue?: (item: T) => string;
|
|
10
|
+
getItemLabel?: (item: T) => string;
|
|
11
|
+
classes?: Partial<{
|
|
12
|
+
root: string;
|
|
13
|
+
trigger: string;
|
|
14
|
+
content: string;
|
|
15
|
+
input: string;
|
|
16
|
+
empty: string;
|
|
17
|
+
group: string;
|
|
18
|
+
item: string;
|
|
19
|
+
popoverContent: string;
|
|
20
|
+
}>;
|
|
21
|
+
};
|