@rovula/ui 0.0.9 → 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 +443 -3
- package/dist/cjs/bundle.js +1 -1
- package/dist/cjs/bundle.js.map +1 -1
- package/dist/cjs/types/components/AlertDialog/Alert.stories.d.ts +20 -0
- package/dist/cjs/types/components/AlertDialog/AlertDialog.d.ts +20 -0
- package/dist/cjs/types/components/Button/Button.d.ts +14 -3
- package/dist/cjs/types/components/Button/Button.styles.d.ts +1 -1
- package/dist/cjs/types/components/Button/Buttons.stories.d.ts +8 -6
- package/dist/cjs/types/components/Checkbox/Checkbox.d.ts +4 -0
- package/dist/cjs/types/components/Checkbox/Checkbox.stories.d.ts +308 -0
- 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/Dialog/Dialog.d.ts +19 -0
- package/dist/cjs/types/components/Dialog/Dialog.stories.d.ts +25 -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/Input/Input.d.ts +5 -0
- package/dist/cjs/types/components/Input/Input.stories.d.ts +314 -0
- package/dist/cjs/types/components/Label/Label.d.ts +5 -0
- package/dist/cjs/types/components/Label/Label.stories.d.ts +286 -0
- package/dist/cjs/types/components/RadioGroup/RadioGroup.d.ts +5 -0
- package/dist/cjs/types/components/RadioGroup/RadioGroup.stories.d.ts +299 -0
- package/dist/cjs/types/components/Table/Datagrid.d.ts +11 -0
- package/dist/cjs/types/components/Table/Table.d.ts +10 -11
- package/dist/cjs/types/components/Table/Table.stories.d.ts +283 -0
- package/dist/cjs/types/components/Tabs/Tabs.d.ts +7 -5
- package/dist/cjs/types/components/Tabs/Tabs.stories.d.ts +49 -0
- 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 +10 -1
- package/dist/cjs/types/utils/cn.d.ts +2 -0
- package/dist/components/AlertDialog/Alert.stories.js +39 -0
- package/dist/components/AlertDialog/AlertDialog.js +73 -0
- package/dist/components/Button/Button.js +6 -5
- package/dist/components/Button/Button.styles.js +1 -1
- package/dist/components/Checkbox/Checkbox.js +37 -0
- package/dist/components/Checkbox/Checkbox.stories.js +49 -0
- package/dist/components/DataTable/DataTable.js +32 -0
- package/dist/components/DataTable/DataTable.stories.js +66 -0
- package/dist/components/Dialog/Dialog.js +63 -0
- package/dist/components/Dialog/Dialog.stories.js +52 -0
- package/dist/components/Dropdown/Dropdown.js +15 -5
- package/dist/components/Dropdown/Dropdown.stories.js +48 -0
- package/dist/components/Input/Input.js +31 -0
- package/dist/components/Input/Input.stories.js +37 -0
- package/dist/components/Label/Label.js +35 -0
- package/dist/components/Label/Label.stories.js +38 -0
- package/dist/components/RadioGroup/RadioGroup.js +41 -0
- package/dist/components/RadioGroup/RadioGroup.stories.js +44 -0
- package/dist/components/Table/Datagrid.js +6 -0
- package/dist/components/Table/Table.js +65 -5
- package/dist/components/Table/Table.stories.js +32 -0
- package/dist/components/Tabs/Tabs.js +10 -4
- package/dist/components/Tabs/Tabs.stories.js +60 -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 +443 -3
- package/dist/esm/bundle.js +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/types/components/AlertDialog/Alert.stories.d.ts +20 -0
- package/dist/esm/types/components/AlertDialog/AlertDialog.d.ts +20 -0
- package/dist/esm/types/components/Button/Button.d.ts +14 -3
- package/dist/esm/types/components/Button/Button.styles.d.ts +1 -1
- package/dist/esm/types/components/Button/Buttons.stories.d.ts +8 -6
- package/dist/esm/types/components/Checkbox/Checkbox.d.ts +4 -0
- package/dist/esm/types/components/Checkbox/Checkbox.stories.d.ts +308 -0
- 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/Dialog/Dialog.d.ts +19 -0
- package/dist/esm/types/components/Dialog/Dialog.stories.d.ts +25 -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/Input/Input.d.ts +5 -0
- package/dist/esm/types/components/Input/Input.stories.d.ts +314 -0
- package/dist/esm/types/components/Label/Label.d.ts +5 -0
- package/dist/esm/types/components/Label/Label.stories.d.ts +286 -0
- package/dist/esm/types/components/RadioGroup/RadioGroup.d.ts +5 -0
- package/dist/esm/types/components/RadioGroup/RadioGroup.stories.d.ts +299 -0
- package/dist/esm/types/components/Table/Datagrid.d.ts +11 -0
- package/dist/esm/types/components/Table/Table.d.ts +10 -11
- package/dist/esm/types/components/Table/Table.stories.d.ts +283 -0
- package/dist/esm/types/components/Tabs/Tabs.d.ts +7 -5
- package/dist/esm/types/components/Tabs/Tabs.stories.d.ts +49 -0
- 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 +10 -1
- package/dist/esm/types/utils/cn.d.ts +2 -0
- package/dist/index.d.ts +139 -31
- package/dist/index.js +7 -1
- package/dist/src/theme/global.css +529 -3
- package/dist/theme/global.css +57 -0
- package/dist/theme/main-preset.js +29 -1
- package/dist/theme/presets/colors.js +19 -0
- package/dist/utils/cn.js +9 -0
- package/package.json +10 -1
- package/src/components/AlertDialog/Alert.stories.tsx +67 -0
- package/src/components/AlertDialog/AlertDialog.tsx +142 -0
- package/src/components/Button/Button.styles.ts +1 -1
- package/src/components/Button/Button.tsx +49 -41
- package/src/components/Checkbox/Checkbox.stories.tsx +91 -0
- package/src/components/Checkbox/Checkbox.tsx +36 -0
- package/src/components/DataTable/DataTable.stories.tsx +76 -0
- package/src/components/DataTable/DataTable.tsx +105 -0
- package/src/components/Dialog/Dialog.stories.tsx +118 -0
- package/src/components/Dialog/Dialog.tsx +119 -0
- package/src/components/Dropdown/Dropdown.stories.tsx +87 -3
- package/src/components/Dropdown/Dropdown.tsx +147 -109
- package/src/components/Input/Input.stories.tsx +40 -0
- package/src/components/Input/Input.tsx +25 -0
- package/src/components/Label/Label.stories.tsx +45 -0
- package/src/components/Label/Label.tsx +26 -0
- package/src/components/RadioGroup/RadioGroup.stories.tsx +71 -0
- package/src/components/RadioGroup/RadioGroup.tsx +59 -0
- package/src/components/Table/Datagrid.tsx +36 -0
- package/src/components/Table/Table.stories.tsx +79 -0
- package/src/components/Table/Table.tsx +116 -35
- package/src/components/Tabs/Tabs.stories.tsx +75 -0
- package/src/components/Tabs/Tabs.tsx +39 -10
- 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 +13 -1
- package/src/theme/global.css +57 -0
- package/src/theme/main-preset.js +29 -1
- package/src/theme/presets/colors.js +19 -0
- package/src/utils/cn.ts +6 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
|
|
4
|
+
import Button from "../Button/Button";
|
|
5
|
+
import { Label } from "../Label/Label";
|
|
6
|
+
import { Input } from "../Input/Input";
|
|
7
|
+
import { DataTable } from "./DataTable";
|
|
8
|
+
import { ColumnDef } from "@tanstack/react-table";
|
|
9
|
+
|
|
10
|
+
const meta = {
|
|
11
|
+
title: "Components/DataTable",
|
|
12
|
+
component: DataTable,
|
|
13
|
+
tags: ["autodocs"],
|
|
14
|
+
parameters: {
|
|
15
|
+
layout: "fullscreen",
|
|
16
|
+
},
|
|
17
|
+
decorators: [
|
|
18
|
+
(Story) => (
|
|
19
|
+
<div className="p-5 flex w-full">
|
|
20
|
+
<Story />
|
|
21
|
+
</div>
|
|
22
|
+
),
|
|
23
|
+
],
|
|
24
|
+
} satisfies Meta<typeof DataTable>;
|
|
25
|
+
|
|
26
|
+
export default meta;
|
|
27
|
+
|
|
28
|
+
const columns: ColumnDef<any>[] = [
|
|
29
|
+
{
|
|
30
|
+
accessorKey: "amount",
|
|
31
|
+
header: () => <div className="text-right">Amount</div>,
|
|
32
|
+
cell: ({ row }: any) => {
|
|
33
|
+
const amount = parseFloat(row.getValue("amount"));
|
|
34
|
+
const formatted = new Intl.NumberFormat("en-US", {
|
|
35
|
+
style: "currency",
|
|
36
|
+
currency: "USD",
|
|
37
|
+
}).format(amount);
|
|
38
|
+
|
|
39
|
+
return <div className="text-right font-medium">{formatted}</div>;
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
accessorKey: "status",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
accessorKey: "email",
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
export const Default = {
|
|
51
|
+
args: {
|
|
52
|
+
// label: "Lorem Ipsum",
|
|
53
|
+
// value: "Lorem Ipsum",
|
|
54
|
+
// fullwidth: true,
|
|
55
|
+
},
|
|
56
|
+
render: (args) => {
|
|
57
|
+
console.log("args ", args);
|
|
58
|
+
const props: typeof args = {
|
|
59
|
+
...args,
|
|
60
|
+
};
|
|
61
|
+
const data = [
|
|
62
|
+
{
|
|
63
|
+
id: "728ed52f",
|
|
64
|
+
amount: 100,
|
|
65
|
+
status: "pending",
|
|
66
|
+
email: "m@example.com",
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<div className="flex flex-row gap-4 w-full">
|
|
72
|
+
<DataTable columns={columns} data={data} />
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
},
|
|
76
|
+
} satisfies StoryObj;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import {
|
|
5
|
+
ColumnDef,
|
|
6
|
+
flexRender,
|
|
7
|
+
getCoreRowModel,
|
|
8
|
+
useReactTable,
|
|
9
|
+
} from "@tanstack/react-table";
|
|
10
|
+
|
|
11
|
+
// This type is used to define the shape of our data.
|
|
12
|
+
// You can use a Zod schema here if you want.
|
|
13
|
+
export type Payment = {
|
|
14
|
+
id: string;
|
|
15
|
+
amount: number;
|
|
16
|
+
status: "pending" | "processing" | "success" | "failed";
|
|
17
|
+
email: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const columns: ColumnDef<Payment>[] = [
|
|
21
|
+
{
|
|
22
|
+
accessorKey: "status",
|
|
23
|
+
header: "Status",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
accessorKey: "email",
|
|
27
|
+
header: "Email",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
accessorKey: "amount",
|
|
31
|
+
header: "Amount",
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
import {
|
|
36
|
+
Table,
|
|
37
|
+
TableBody,
|
|
38
|
+
TableCell,
|
|
39
|
+
TableHead,
|
|
40
|
+
TableHeader,
|
|
41
|
+
TableRow,
|
|
42
|
+
} from "@/components/ui/table";
|
|
43
|
+
|
|
44
|
+
interface DataTableProps<TData, TValue> {
|
|
45
|
+
columns: ColumnDef<TData, TValue>[];
|
|
46
|
+
data: TData[];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function DataTable<TData, TValue>({
|
|
50
|
+
columns,
|
|
51
|
+
data,
|
|
52
|
+
}: DataTableProps<TData, TValue>) {
|
|
53
|
+
const table = useReactTable({
|
|
54
|
+
data,
|
|
55
|
+
columns,
|
|
56
|
+
getCoreRowModel: getCoreRowModel(),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div className="rounded-md border">
|
|
61
|
+
<Table>
|
|
62
|
+
<TableHeader>
|
|
63
|
+
{table.getHeaderGroups().map((headerGroup) => (
|
|
64
|
+
<TableRow key={headerGroup.id}>
|
|
65
|
+
{headerGroup.headers.map((header) => {
|
|
66
|
+
return (
|
|
67
|
+
<TableHead key={header.id}>
|
|
68
|
+
{header.isPlaceholder
|
|
69
|
+
? null
|
|
70
|
+
: flexRender(
|
|
71
|
+
header.column.columnDef.header,
|
|
72
|
+
header.getContext()
|
|
73
|
+
)}
|
|
74
|
+
</TableHead>
|
|
75
|
+
);
|
|
76
|
+
})}
|
|
77
|
+
</TableRow>
|
|
78
|
+
))}
|
|
79
|
+
</TableHeader>
|
|
80
|
+
<TableBody>
|
|
81
|
+
{table.getRowModel().rows?.length ? (
|
|
82
|
+
table.getRowModel().rows.map((row) => (
|
|
83
|
+
<TableRow
|
|
84
|
+
key={row.id}
|
|
85
|
+
data-state={row.getIsSelected() && "selected"}
|
|
86
|
+
>
|
|
87
|
+
{row.getVisibleCells().map((cell) => (
|
|
88
|
+
<TableCell key={cell.id}>
|
|
89
|
+
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
|
90
|
+
</TableCell>
|
|
91
|
+
))}
|
|
92
|
+
</TableRow>
|
|
93
|
+
))
|
|
94
|
+
) : (
|
|
95
|
+
<TableRow>
|
|
96
|
+
<TableCell colSpan={columns.length} className="h-24 text-center">
|
|
97
|
+
No results.
|
|
98
|
+
</TableCell>
|
|
99
|
+
</TableRow>
|
|
100
|
+
)}
|
|
101
|
+
</TableBody>
|
|
102
|
+
</Table>
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import {
|
|
4
|
+
Dialog,
|
|
5
|
+
DialogContent,
|
|
6
|
+
DialogDescription,
|
|
7
|
+
DialogFooter,
|
|
8
|
+
DialogHeader,
|
|
9
|
+
DialogTitle,
|
|
10
|
+
DialogTrigger,
|
|
11
|
+
} from "./Dialog";
|
|
12
|
+
import Button from "../Button/Button";
|
|
13
|
+
import { Label } from "../Label/Label";
|
|
14
|
+
import { Input } from "../Input/Input";
|
|
15
|
+
|
|
16
|
+
const meta = {
|
|
17
|
+
title: "Components/Dialog",
|
|
18
|
+
component: Dialog,
|
|
19
|
+
tags: ["autodocs"],
|
|
20
|
+
parameters: {
|
|
21
|
+
layout: "fullscreen",
|
|
22
|
+
},
|
|
23
|
+
decorators: [
|
|
24
|
+
(Story) => (
|
|
25
|
+
<div className="p-5 flex w-full">
|
|
26
|
+
<Story />
|
|
27
|
+
</div>
|
|
28
|
+
),
|
|
29
|
+
],
|
|
30
|
+
} satisfies Meta<typeof Dialog>;
|
|
31
|
+
|
|
32
|
+
export default meta;
|
|
33
|
+
|
|
34
|
+
export const Default = {
|
|
35
|
+
args: {
|
|
36
|
+
// label: "Lorem Ipsum",
|
|
37
|
+
// value: "Lorem Ipsum",
|
|
38
|
+
// fullwidth: true,
|
|
39
|
+
},
|
|
40
|
+
render: (args) => {
|
|
41
|
+
console.log("args ", args);
|
|
42
|
+
const props: typeof args = {
|
|
43
|
+
...args,
|
|
44
|
+
};
|
|
45
|
+
return (
|
|
46
|
+
<div className="flex flex-row gap-4 w-full">
|
|
47
|
+
<Dialog>
|
|
48
|
+
<DialogTrigger>Open</DialogTrigger>
|
|
49
|
+
<DialogContent>
|
|
50
|
+
<DialogHeader>
|
|
51
|
+
<DialogTitle>Are you absolutely sure?</DialogTitle>
|
|
52
|
+
<DialogDescription>
|
|
53
|
+
This action cannot be undone. This will permanently delete your
|
|
54
|
+
account and remove your data from our servers.
|
|
55
|
+
</DialogDescription>
|
|
56
|
+
</DialogHeader>
|
|
57
|
+
</DialogContent>
|
|
58
|
+
</Dialog>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
},
|
|
62
|
+
} satisfies StoryObj;
|
|
63
|
+
|
|
64
|
+
export const Demo = {
|
|
65
|
+
args: {
|
|
66
|
+
// label: "Lorem Ipsum",
|
|
67
|
+
// value: "Lorem Ipsum",
|
|
68
|
+
// fullwidth: true,
|
|
69
|
+
},
|
|
70
|
+
render: (args) => {
|
|
71
|
+
console.log("args ", args);
|
|
72
|
+
const props: typeof args = {
|
|
73
|
+
...args,
|
|
74
|
+
};
|
|
75
|
+
return (
|
|
76
|
+
<div className="flex flex-row gap-4 w-full">
|
|
77
|
+
<Dialog>
|
|
78
|
+
<DialogTrigger asChild>
|
|
79
|
+
<Button variant="outline">Edit Profile</Button>
|
|
80
|
+
</DialogTrigger>
|
|
81
|
+
<DialogContent className="sm:max-w-[425px]">
|
|
82
|
+
<DialogHeader>
|
|
83
|
+
<DialogTitle>Edit profile</DialogTitle>
|
|
84
|
+
<DialogDescription>
|
|
85
|
+
Make changes to your profile here. Click save when you're done.
|
|
86
|
+
</DialogDescription>
|
|
87
|
+
</DialogHeader>
|
|
88
|
+
<div className="grid gap-4 py-4">
|
|
89
|
+
<div className="grid grid-cols-4 items-center gap-4">
|
|
90
|
+
<Label htmlFor="name" className="text-right">
|
|
91
|
+
Name
|
|
92
|
+
</Label>
|
|
93
|
+
<Input
|
|
94
|
+
id="name"
|
|
95
|
+
defaultValue="Pedro Duarte"
|
|
96
|
+
className="col-span-3"
|
|
97
|
+
/>
|
|
98
|
+
</div>
|
|
99
|
+
<div className="grid grid-cols-4 items-center gap-4">
|
|
100
|
+
<Label htmlFor="username" className="text-right">
|
|
101
|
+
Username
|
|
102
|
+
</Label>
|
|
103
|
+
<Input
|
|
104
|
+
id="username"
|
|
105
|
+
defaultValue="@peduarte"
|
|
106
|
+
className="col-span-3"
|
|
107
|
+
/>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
<DialogFooter>
|
|
111
|
+
<Button type="submit">Save changes</Button>
|
|
112
|
+
</DialogFooter>
|
|
113
|
+
</DialogContent>
|
|
114
|
+
</Dialog>
|
|
115
|
+
</div>
|
|
116
|
+
);
|
|
117
|
+
},
|
|
118
|
+
} satisfies StoryObj;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
5
|
+
|
|
6
|
+
import { XMarkIcon } from "@heroicons/react/16/solid";
|
|
7
|
+
import { cn } from "@/utils/cn";
|
|
8
|
+
|
|
9
|
+
const Dialog = DialogPrimitive.Root;
|
|
10
|
+
|
|
11
|
+
const DialogTrigger = DialogPrimitive.Trigger;
|
|
12
|
+
|
|
13
|
+
const DialogPortal = DialogPrimitive.Portal;
|
|
14
|
+
|
|
15
|
+
const DialogClose = DialogPrimitive.Close;
|
|
16
|
+
|
|
17
|
+
const DialogOverlay = React.forwardRef<
|
|
18
|
+
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
|
19
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
|
20
|
+
>(({ className, ...props }, ref) => (
|
|
21
|
+
<DialogPrimitive.Overlay
|
|
22
|
+
ref={ref}
|
|
23
|
+
className={cn(
|
|
24
|
+
"fixed inset-0 z-50 bg-popup-overlay data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
25
|
+
className
|
|
26
|
+
)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
));
|
|
30
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
31
|
+
|
|
32
|
+
const DialogContent = React.forwardRef<
|
|
33
|
+
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
34
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
|
35
|
+
>(({ className, children, ...props }, ref) => (
|
|
36
|
+
<DialogPortal>
|
|
37
|
+
<DialogOverlay />
|
|
38
|
+
<DialogPrimitive.Content
|
|
39
|
+
ref={ref}
|
|
40
|
+
className={cn(
|
|
41
|
+
"fixed text-textcolor-grey-dark left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-[var(--popup-rounded)]",
|
|
42
|
+
className
|
|
43
|
+
)}
|
|
44
|
+
{...props}
|
|
45
|
+
>
|
|
46
|
+
{children}
|
|
47
|
+
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
|
48
|
+
<XMarkIcon className="h-4 w-4" />
|
|
49
|
+
<span className="sr-only">Close</span>
|
|
50
|
+
</DialogPrimitive.Close>
|
|
51
|
+
</DialogPrimitive.Content>
|
|
52
|
+
</DialogPortal>
|
|
53
|
+
));
|
|
54
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
55
|
+
|
|
56
|
+
const DialogHeader = ({
|
|
57
|
+
className,
|
|
58
|
+
...props
|
|
59
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
60
|
+
<div
|
|
61
|
+
className={cn(
|
|
62
|
+
"flex flex-col space-y-2 text-center sm:text-left",
|
|
63
|
+
className
|
|
64
|
+
)}
|
|
65
|
+
{...props}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
DialogHeader.displayName = "DialogHeader";
|
|
69
|
+
|
|
70
|
+
const DialogFooter = ({
|
|
71
|
+
className,
|
|
72
|
+
...props
|
|
73
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
74
|
+
<div
|
|
75
|
+
className={cn(
|
|
76
|
+
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
77
|
+
className
|
|
78
|
+
)}
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
DialogFooter.displayName = "DialogFooter";
|
|
83
|
+
|
|
84
|
+
const DialogTitle = React.forwardRef<
|
|
85
|
+
React.ElementRef<typeof DialogPrimitive.Title>,
|
|
86
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
|
87
|
+
>(({ className, ...props }, ref) => (
|
|
88
|
+
<DialogPrimitive.Title
|
|
89
|
+
ref={ref}
|
|
90
|
+
className={cn("typography-h5 tracking-tight", className)}
|
|
91
|
+
{...props}
|
|
92
|
+
/>
|
|
93
|
+
));
|
|
94
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
95
|
+
|
|
96
|
+
const DialogDescription = React.forwardRef<
|
|
97
|
+
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
98
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
|
99
|
+
>(({ className, ...props }, ref) => (
|
|
100
|
+
<DialogPrimitive.Description
|
|
101
|
+
ref={ref}
|
|
102
|
+
className={cn("text-sm", className)}
|
|
103
|
+
{...props}
|
|
104
|
+
/>
|
|
105
|
+
));
|
|
106
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
107
|
+
|
|
108
|
+
export {
|
|
109
|
+
Dialog,
|
|
110
|
+
DialogPortal,
|
|
111
|
+
DialogOverlay,
|
|
112
|
+
DialogClose,
|
|
113
|
+
DialogTrigger,
|
|
114
|
+
DialogContent,
|
|
115
|
+
DialogHeader,
|
|
116
|
+
DialogFooter,
|
|
117
|
+
DialogTitle,
|
|
118
|
+
DialogDescription,
|
|
119
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useRef } from "react";
|
|
2
2
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
-
import Dropdown from "./Dropdown";
|
|
3
|
+
import Dropdown, { Options } from "./Dropdown";
|
|
4
|
+
import Button from "../Button/Button";
|
|
5
|
+
import { cn } from "@/utils/cn";
|
|
4
6
|
|
|
5
7
|
// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction
|
|
6
8
|
const meta = {
|
|
@@ -22,7 +24,7 @@ const meta = {
|
|
|
22
24
|
|
|
23
25
|
export default meta;
|
|
24
26
|
|
|
25
|
-
const options = new Array(100).fill("").map((__, index) => ({
|
|
27
|
+
const options: Options[] = new Array(100).fill("").map((__, index) => ({
|
|
26
28
|
value: `option${index + 1}`,
|
|
27
29
|
label: `Option ${index + 1}`,
|
|
28
30
|
}));
|
|
@@ -47,3 +49,85 @@ export const Default = {
|
|
|
47
49
|
);
|
|
48
50
|
},
|
|
49
51
|
} satisfies StoryObj;
|
|
52
|
+
|
|
53
|
+
const DropdownWithRef = (props: any) => {
|
|
54
|
+
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<Dropdown
|
|
58
|
+
id="1"
|
|
59
|
+
size="lg"
|
|
60
|
+
{...props}
|
|
61
|
+
ref={inputRef}
|
|
62
|
+
labelClassName="peer-focus:bg-red-500"
|
|
63
|
+
onKeyDown={(e) => {
|
|
64
|
+
if (e.code === "Enter") {
|
|
65
|
+
inputRef.current?.blur?.();
|
|
66
|
+
}
|
|
67
|
+
}}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const WithRef = {
|
|
73
|
+
args: {
|
|
74
|
+
label: "Choose an option:",
|
|
75
|
+
fullwidth: true,
|
|
76
|
+
options,
|
|
77
|
+
filterMode: true,
|
|
78
|
+
},
|
|
79
|
+
render: (args) => {
|
|
80
|
+
console.log("args ", args);
|
|
81
|
+
const props: typeof args = {
|
|
82
|
+
...args,
|
|
83
|
+
};
|
|
84
|
+
return (
|
|
85
|
+
<div className="flex flex-row gap-4 w-full">
|
|
86
|
+
<DropdownWithRef id="1" size="lg" options={options} {...args} />\
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
},
|
|
90
|
+
} satisfies StoryObj;
|
|
91
|
+
|
|
92
|
+
const customOptions: Options[] = new Array(100).fill("").map((__, index) => ({
|
|
93
|
+
value: `option${index + 1}`,
|
|
94
|
+
label: `Option ${index + 1}`,
|
|
95
|
+
renderLabel(config) {
|
|
96
|
+
return (
|
|
97
|
+
<div
|
|
98
|
+
className={cn(config, "w-full flex justify-between")}
|
|
99
|
+
onMouseDown={config.handleOnClick}
|
|
100
|
+
>
|
|
101
|
+
<span>Test custom</span>
|
|
102
|
+
<Button
|
|
103
|
+
onMouseDown={(e) => {
|
|
104
|
+
// e.stopPropagation();
|
|
105
|
+
alert("SSS");
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
Add action
|
|
109
|
+
</Button>
|
|
110
|
+
</div>
|
|
111
|
+
);
|
|
112
|
+
},
|
|
113
|
+
}));
|
|
114
|
+
|
|
115
|
+
export const CustomOption = {
|
|
116
|
+
args: {
|
|
117
|
+
label: "Choose an option:",
|
|
118
|
+
fullwidth: true,
|
|
119
|
+
options: customOptions,
|
|
120
|
+
filterMode: true,
|
|
121
|
+
},
|
|
122
|
+
render: (args) => {
|
|
123
|
+
console.log("args ", args);
|
|
124
|
+
const props: typeof args = {
|
|
125
|
+
...args,
|
|
126
|
+
};
|
|
127
|
+
return (
|
|
128
|
+
<div className="flex flex-row gap-4 w-full">
|
|
129
|
+
<DropdownWithRef id="1" size="lg" options={options} {...args} />\
|
|
130
|
+
</div>
|
|
131
|
+
);
|
|
132
|
+
},
|
|
133
|
+
} satisfies StoryObj;
|