@rovula/ui 0.0.10 → 0.0.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/dist/cjs/bundle.css +14 -0
- package/dist/cjs/bundle.js +1 -1
- package/dist/cjs/bundle.js.map +1 -1
- package/dist/cjs/types/components/Button/Button.d.ts +14 -3
- package/dist/cjs/types/components/Button/Buttons.stories.d.ts +8 -6
- package/dist/cjs/types/components/DataTable/DataTable.d.ts +14 -0
- package/dist/cjs/types/components/DataTable/DataTable.stories.d.ts +19 -0
- package/dist/cjs/types/components/Dropdown/Dropdown.d.ts +29 -3
- package/dist/cjs/types/components/Dropdown/Dropdown.stories.d.ts +31 -30
- package/dist/cjs/types/components/Label/Label.stories.d.ts +1 -1
- package/dist/cjs/types/components/RadioGroup/RadioGroup.stories.d.ts +1 -1
- package/dist/cjs/types/components/Text/Text.d.ts +3 -3
- package/dist/cjs/types/components/Text/Text.stories.d.ts +3 -9
- package/dist/cjs/types/components/TextInput/TextInput.d.ts +20 -2
- package/dist/cjs/types/components/TextInput/TextInput.stories.d.ts +28 -1
- package/dist/cjs/types/components/ui/table.d.ts +10 -0
- package/dist/cjs/types/index.d.ts +3 -0
- package/dist/components/Button/Button.js +4 -3
- package/dist/components/DataTable/DataTable.js +32 -0
- package/dist/components/DataTable/DataTable.stories.js +66 -0
- package/dist/components/Dropdown/Dropdown.js +15 -5
- package/dist/components/Dropdown/Dropdown.stories.js +48 -0
- package/dist/components/Text/Text.js +3 -2
- package/dist/components/TextInput/TextInput.js +5 -7
- package/dist/components/TextInput/TextInput.stories.js +22 -0
- package/dist/components/ui/table.js +66 -0
- package/dist/esm/bundle.css +14 -0
- package/dist/esm/bundle.js +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/types/components/Button/Button.d.ts +14 -3
- package/dist/esm/types/components/Button/Buttons.stories.d.ts +8 -6
- package/dist/esm/types/components/DataTable/DataTable.d.ts +14 -0
- package/dist/esm/types/components/DataTable/DataTable.stories.d.ts +19 -0
- package/dist/esm/types/components/Dropdown/Dropdown.d.ts +29 -3
- package/dist/esm/types/components/Dropdown/Dropdown.stories.d.ts +31 -30
- package/dist/esm/types/components/Label/Label.stories.d.ts +1 -1
- package/dist/esm/types/components/RadioGroup/RadioGroup.stories.d.ts +1 -1
- package/dist/esm/types/components/Text/Text.d.ts +3 -3
- package/dist/esm/types/components/Text/Text.stories.d.ts +3 -9
- package/dist/esm/types/components/TextInput/TextInput.d.ts +20 -2
- package/dist/esm/types/components/TextInput/TextInput.stories.d.ts +28 -1
- package/dist/esm/types/components/ui/table.d.ts +10 -0
- package/dist/esm/types/index.d.ts +3 -0
- package/dist/index.d.ts +61 -7
- package/dist/src/theme/global.css +18 -0
- package/package.json +2 -1
- package/src/components/Button/Button.tsx +47 -39
- package/src/components/DataTable/DataTable.stories.tsx +76 -0
- package/src/components/DataTable/DataTable.tsx +105 -0
- package/src/components/Dropdown/Dropdown.stories.tsx +87 -3
- package/src/components/Dropdown/Dropdown.tsx +147 -109
- package/src/components/Text/Text.tsx +21 -19
- package/src/components/TextInput/TextInput.stories.tsx +46 -1
- package/src/components/TextInput/TextInput.tsx +7 -7
- package/src/components/ui/table.tsx +117 -0
- package/src/index.ts +5 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React, { FC } from "react";
|
|
1
|
+
import React, { FC, forwardRef } from "react";
|
|
2
2
|
|
|
3
|
-
type TextProps = {
|
|
3
|
+
export type TextProps = {
|
|
4
4
|
variant?:
|
|
5
5
|
| "h1"
|
|
6
6
|
| "h2"
|
|
@@ -38,22 +38,24 @@ type TextProps = {
|
|
|
38
38
|
id?: string;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
const Text
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
41
|
+
const Text = forwardRef<TextProps["tag"], TextProps>(
|
|
42
|
+
({
|
|
43
|
+
variant = "body1",
|
|
44
|
+
tag: Tag = "p",
|
|
45
|
+
children,
|
|
46
|
+
className,
|
|
47
|
+
color,
|
|
48
|
+
style,
|
|
49
|
+
}) => {
|
|
50
|
+
return (
|
|
51
|
+
<Tag
|
|
52
|
+
className={`typography-${variant} text-${color} ${className}`}
|
|
53
|
+
style={style}
|
|
54
|
+
>
|
|
55
|
+
{children}
|
|
56
|
+
</Tag>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
);
|
|
58
60
|
|
|
59
61
|
export default Text;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useRef } from "react";
|
|
2
2
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
3
|
import TextInput from "./TextInput";
|
|
4
4
|
|
|
@@ -42,3 +42,48 @@ export const Default = {
|
|
|
42
42
|
);
|
|
43
43
|
},
|
|
44
44
|
} satisfies StoryObj;
|
|
45
|
+
|
|
46
|
+
const InputWithRef = (props: any) => {
|
|
47
|
+
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<TextInput
|
|
51
|
+
id="1"
|
|
52
|
+
size="lg"
|
|
53
|
+
{...props}
|
|
54
|
+
ref={inputRef}
|
|
55
|
+
labelClassName="peer-focus:bg-red-500"
|
|
56
|
+
onKeyDown={(e) => {
|
|
57
|
+
if (e.code === "Enter") {
|
|
58
|
+
inputRef.current?.blur?.();
|
|
59
|
+
}
|
|
60
|
+
}}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const CustomLabel = {
|
|
66
|
+
args: {
|
|
67
|
+
label: "Lorem Ipsum",
|
|
68
|
+
// value: "Lorem Ipsum",
|
|
69
|
+
fullwidth: true,
|
|
70
|
+
},
|
|
71
|
+
render: (args) => {
|
|
72
|
+
console.log("args ", args);
|
|
73
|
+
const props: typeof args = {
|
|
74
|
+
...args,
|
|
75
|
+
};
|
|
76
|
+
return (
|
|
77
|
+
<div className="flex flex-row gap-4 w-full">
|
|
78
|
+
<TextInput
|
|
79
|
+
id="1"
|
|
80
|
+
size="lg"
|
|
81
|
+
{...args}
|
|
82
|
+
labelClassName="peer-focus:bg-red-500"
|
|
83
|
+
/>
|
|
84
|
+
<InputWithRef id="2" size="md" {...args} />
|
|
85
|
+
<TextInput id="3" size="sm" {...args} />
|
|
86
|
+
</div>
|
|
87
|
+
);
|
|
88
|
+
},
|
|
89
|
+
} satisfies StoryObj;
|
|
@@ -12,8 +12,8 @@ import {
|
|
|
12
12
|
inputVariant,
|
|
13
13
|
labelVariant,
|
|
14
14
|
} from "./TextInput.styles";
|
|
15
|
-
import { twMerge } from "tailwind-merge";
|
|
16
15
|
import { XCircleIcon, ExclamationCircleIcon } from "@heroicons/react/16/solid";
|
|
16
|
+
import { cn } from "@/utils/cn";
|
|
17
17
|
|
|
18
18
|
export type InputProps = {
|
|
19
19
|
id?: string;
|
|
@@ -31,9 +31,10 @@ export type InputProps = {
|
|
|
31
31
|
hasClearIcon?: boolean;
|
|
32
32
|
endIcon?: ReactNode;
|
|
33
33
|
className?: string;
|
|
34
|
+
labelClassName?: string;
|
|
34
35
|
} & Omit<React.InputHTMLAttributes<HTMLInputElement>, "size">;
|
|
35
36
|
|
|
36
|
-
const TextInput
|
|
37
|
+
export const TextInput = forwardRef<HTMLInputElement, InputProps>(
|
|
37
38
|
(
|
|
38
39
|
{
|
|
39
40
|
id,
|
|
@@ -50,6 +51,7 @@ const TextInput: FC<InputProps> = forwardRef(
|
|
|
50
51
|
required = true,
|
|
51
52
|
hasClearIcon = true,
|
|
52
53
|
endIcon,
|
|
54
|
+
labelClassName,
|
|
53
55
|
...props
|
|
54
56
|
},
|
|
55
57
|
ref
|
|
@@ -74,9 +76,7 @@ const TextInput: FC<InputProps> = forwardRef(
|
|
|
74
76
|
const iconWrapperClassname = iconWrapperVariant({ size });
|
|
75
77
|
const iconClassname = iconVariant({ size });
|
|
76
78
|
|
|
77
|
-
useImperativeHandle(ref, () =>
|
|
78
|
-
clearInput: handleClearInput,
|
|
79
|
-
}));
|
|
79
|
+
useImperativeHandle(ref, () => inputRef?.current as HTMLInputElement);
|
|
80
80
|
|
|
81
81
|
const handleClearInput = () => {
|
|
82
82
|
if (inputRef.current) {
|
|
@@ -94,7 +94,7 @@ const TextInput: FC<InputProps> = forwardRef(
|
|
|
94
94
|
type={type}
|
|
95
95
|
id={_id}
|
|
96
96
|
disabled={disabled}
|
|
97
|
-
className={
|
|
97
|
+
className={cn(inputClassname, props.className)}
|
|
98
98
|
/>
|
|
99
99
|
{hasClearIcon && (
|
|
100
100
|
<div className={iconWrapperClassname}>
|
|
@@ -106,7 +106,7 @@ const TextInput: FC<InputProps> = forwardRef(
|
|
|
106
106
|
</div>
|
|
107
107
|
)}
|
|
108
108
|
{endIcon}
|
|
109
|
-
<label htmlFor={_id} className={labelClassname}>
|
|
109
|
+
<label htmlFor={_id} className={cn(labelClassname, labelClassName)}>
|
|
110
110
|
{label} {required && <span className="text-error">*</span>}
|
|
111
111
|
</label>
|
|
112
112
|
</div>
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/utils/cn"
|
|
4
|
+
|
|
5
|
+
const Table = React.forwardRef<
|
|
6
|
+
HTMLTableElement,
|
|
7
|
+
React.HTMLAttributes<HTMLTableElement>
|
|
8
|
+
>(({ className, ...props }, ref) => (
|
|
9
|
+
<div className="relative w-full overflow-auto">
|
|
10
|
+
<table
|
|
11
|
+
ref={ref}
|
|
12
|
+
className={cn("w-full caption-bottom text-sm", className)}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
</div>
|
|
16
|
+
))
|
|
17
|
+
Table.displayName = "Table"
|
|
18
|
+
|
|
19
|
+
const TableHeader = React.forwardRef<
|
|
20
|
+
HTMLTableSectionElement,
|
|
21
|
+
React.HTMLAttributes<HTMLTableSectionElement>
|
|
22
|
+
>(({ className, ...props }, ref) => (
|
|
23
|
+
<thead ref={ref} className={cn("[&_tr]:border-b", className)} {...props} />
|
|
24
|
+
))
|
|
25
|
+
TableHeader.displayName = "TableHeader"
|
|
26
|
+
|
|
27
|
+
const TableBody = React.forwardRef<
|
|
28
|
+
HTMLTableSectionElement,
|
|
29
|
+
React.HTMLAttributes<HTMLTableSectionElement>
|
|
30
|
+
>(({ className, ...props }, ref) => (
|
|
31
|
+
<tbody
|
|
32
|
+
ref={ref}
|
|
33
|
+
className={cn("[&_tr:last-child]:border-0", className)}
|
|
34
|
+
{...props}
|
|
35
|
+
/>
|
|
36
|
+
))
|
|
37
|
+
TableBody.displayName = "TableBody"
|
|
38
|
+
|
|
39
|
+
const TableFooter = React.forwardRef<
|
|
40
|
+
HTMLTableSectionElement,
|
|
41
|
+
React.HTMLAttributes<HTMLTableSectionElement>
|
|
42
|
+
>(({ className, ...props }, ref) => (
|
|
43
|
+
<tfoot
|
|
44
|
+
ref={ref}
|
|
45
|
+
className={cn(
|
|
46
|
+
"border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",
|
|
47
|
+
className
|
|
48
|
+
)}
|
|
49
|
+
{...props}
|
|
50
|
+
/>
|
|
51
|
+
))
|
|
52
|
+
TableFooter.displayName = "TableFooter"
|
|
53
|
+
|
|
54
|
+
const TableRow = React.forwardRef<
|
|
55
|
+
HTMLTableRowElement,
|
|
56
|
+
React.HTMLAttributes<HTMLTableRowElement>
|
|
57
|
+
>(({ className, ...props }, ref) => (
|
|
58
|
+
<tr
|
|
59
|
+
ref={ref}
|
|
60
|
+
className={cn(
|
|
61
|
+
"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
|
|
62
|
+
className
|
|
63
|
+
)}
|
|
64
|
+
{...props}
|
|
65
|
+
/>
|
|
66
|
+
))
|
|
67
|
+
TableRow.displayName = "TableRow"
|
|
68
|
+
|
|
69
|
+
const TableHead = React.forwardRef<
|
|
70
|
+
HTMLTableCellElement,
|
|
71
|
+
React.ThHTMLAttributes<HTMLTableCellElement>
|
|
72
|
+
>(({ className, ...props }, ref) => (
|
|
73
|
+
<th
|
|
74
|
+
ref={ref}
|
|
75
|
+
className={cn(
|
|
76
|
+
"h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",
|
|
77
|
+
className
|
|
78
|
+
)}
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
))
|
|
82
|
+
TableHead.displayName = "TableHead"
|
|
83
|
+
|
|
84
|
+
const TableCell = React.forwardRef<
|
|
85
|
+
HTMLTableCellElement,
|
|
86
|
+
React.TdHTMLAttributes<HTMLTableCellElement>
|
|
87
|
+
>(({ className, ...props }, ref) => (
|
|
88
|
+
<td
|
|
89
|
+
ref={ref}
|
|
90
|
+
className={cn("p-4 align-middle [&:has([role=checkbox])]:pr-0", className)}
|
|
91
|
+
{...props}
|
|
92
|
+
/>
|
|
93
|
+
))
|
|
94
|
+
TableCell.displayName = "TableCell"
|
|
95
|
+
|
|
96
|
+
const TableCaption = React.forwardRef<
|
|
97
|
+
HTMLTableCaptionElement,
|
|
98
|
+
React.HTMLAttributes<HTMLTableCaptionElement>
|
|
99
|
+
>(({ className, ...props }, ref) => (
|
|
100
|
+
<caption
|
|
101
|
+
ref={ref}
|
|
102
|
+
className={cn("mt-4 text-sm text-muted-foreground", className)}
|
|
103
|
+
{...props}
|
|
104
|
+
/>
|
|
105
|
+
))
|
|
106
|
+
TableCaption.displayName = "TableCaption"
|
|
107
|
+
|
|
108
|
+
export {
|
|
109
|
+
Table,
|
|
110
|
+
TableHeader,
|
|
111
|
+
TableBody,
|
|
112
|
+
TableFooter,
|
|
113
|
+
TableHead,
|
|
114
|
+
TableRow,
|
|
115
|
+
TableCell,
|
|
116
|
+
TableCaption,
|
|
117
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -13,6 +13,11 @@ export * from "./components/Table/Table";
|
|
|
13
13
|
export * from "./components/Dialog/Dialog";
|
|
14
14
|
export * from "./components/AlertDialog/AlertDialog";
|
|
15
15
|
|
|
16
|
+
// Export component types
|
|
17
|
+
export type { ButtonProps } from "./components/Button/Button";
|
|
18
|
+
export type { InputProps } from "./components/TextInput/TextInput";
|
|
19
|
+
export type { DropdownProps } from "./components/Dropdown/Dropdown";
|
|
20
|
+
|
|
16
21
|
// UTILS
|
|
17
22
|
export {
|
|
18
23
|
resloveTimestamp,
|