shadcn-ui-react 0.2.5 → 0.2.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/README.md +60 -64
- package/dist/index.cjs +800 -835
- package/dist/index.d.cts +95 -66
- package/dist/index.d.ts +95 -66
- package/dist/index.js +769 -800
- package/dist/style.css +198 -57
- package/package.json +76 -57
package/README.md
CHANGED
|
@@ -17,47 +17,58 @@ yarn add shadcn-ui-react
|
|
|
17
17
|
Import `style.css` in the App root:
|
|
18
18
|
|
|
19
19
|
```tsx
|
|
20
|
-
import
|
|
20
|
+
import "shadcn-ui-react/dist/style.css";
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
Then use the components:
|
|
24
24
|
|
|
25
25
|
```tsx
|
|
26
|
-
import { Button } from
|
|
26
|
+
import { Button } from "shadcn-ui-react";
|
|
27
27
|
|
|
28
28
|
export default function MyComponent() {
|
|
29
|
-
return
|
|
29
|
+
return <Button>Hello world</Button>;
|
|
30
30
|
}
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
```tsx
|
|
34
|
-
import { Card } from
|
|
34
|
+
import { Card } from "shadcn-ui-react";
|
|
35
35
|
|
|
36
36
|
export default function MyComponent() {
|
|
37
|
-
return (
|
|
37
|
+
return (
|
|
38
|
+
<Card>
|
|
39
|
+
<h1>Hello World</h1>
|
|
40
|
+
</Card>
|
|
41
|
+
);
|
|
38
42
|
}
|
|
39
43
|
```
|
|
40
44
|
|
|
41
45
|
```tsx
|
|
42
|
-
import React, { useState } from
|
|
43
|
-
import { SearchInput } from
|
|
46
|
+
import React, { useState } from "react";
|
|
47
|
+
import { SearchInput } from "./components/search-input";
|
|
44
48
|
|
|
45
|
-
export default function MyComponent()
|
|
46
|
-
const [searchTerm, setSearchTerm] = useState(
|
|
49
|
+
export default function MyComponent() {
|
|
50
|
+
const [searchTerm, setSearchTerm] = useState("");
|
|
47
51
|
|
|
48
|
-
const handleSearch = (term) => {
|
|
52
|
+
const handleSearch = (term?: string) => {
|
|
49
53
|
setSearchTerm(term);
|
|
50
|
-
console.log(
|
|
54
|
+
console.log("Search term:", term);
|
|
51
55
|
};
|
|
52
56
|
|
|
53
|
-
return (
|
|
54
|
-
|
|
57
|
+
return (
|
|
58
|
+
<SearchInput
|
|
59
|
+
placeholder="Search"
|
|
60
|
+
value={searchTerm}
|
|
61
|
+
onSearch={handleSearch}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
55
65
|
```
|
|
56
66
|
|
|
57
67
|
## Example of a login form
|
|
68
|
+
|
|
58
69
|
```tsx
|
|
59
|
-
import { zodResolver } from
|
|
60
|
-
import { useForm } from
|
|
70
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
71
|
+
import { useForm } from "react-hook-form";
|
|
61
72
|
import {
|
|
62
73
|
Button,
|
|
63
74
|
Form,
|
|
@@ -66,59 +77,44 @@ import {
|
|
|
66
77
|
FormItem,
|
|
67
78
|
FormLabel,
|
|
68
79
|
FormMessage,
|
|
69
|
-
Input
|
|
70
|
-
} from
|
|
71
|
-
import * as z from
|
|
80
|
+
Input,
|
|
81
|
+
} from "shadcn-ui-react";
|
|
82
|
+
import * as z from "zod";
|
|
72
83
|
|
|
73
84
|
const formSchema = z.object({
|
|
74
|
-
email: z.string().email({ message:
|
|
85
|
+
email: z.string().email({ message: "Enter a valid email address" }),
|
|
75
86
|
password: z
|
|
76
87
|
.string()
|
|
77
|
-
.min(8, { message:
|
|
88
|
+
.min(8, { message: "Password must be at least 8 characters" }),
|
|
78
89
|
});
|
|
79
90
|
|
|
80
91
|
type UserFormValue = z.infer<typeof formSchema>;
|
|
81
92
|
|
|
82
93
|
export default function UserAuthForm() {
|
|
83
94
|
const defaultValues = {
|
|
84
|
-
email:
|
|
95
|
+
email: "demo@domain.com",
|
|
85
96
|
};
|
|
86
97
|
const form = useForm<UserFormValue>({
|
|
87
98
|
resolver: zodResolver(formSchema),
|
|
88
|
-
defaultValues
|
|
99
|
+
defaultValues,
|
|
89
100
|
});
|
|
90
101
|
|
|
91
102
|
const onSubmit = async (data: UserFormValue) => {};
|
|
92
103
|
|
|
93
104
|
return (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
id="email"
|
|
108
|
-
type="email"
|
|
109
|
-
placeholder="demo@domain.com"
|
|
110
|
-
{...field}
|
|
111
|
-
/>
|
|
112
|
-
</FormControl>
|
|
113
|
-
<FormMessage />
|
|
114
|
-
</FormItem>
|
|
115
|
-
)}
|
|
116
|
-
/>
|
|
117
|
-
<Button className="ml-auto w-full" type="submit">
|
|
118
|
-
Log In
|
|
119
|
-
</Button>
|
|
120
|
-
</form>
|
|
121
|
-
</Form>
|
|
105
|
+
<Form methods={form} onSubmit={onSubmit}>
|
|
106
|
+
<FormField
|
|
107
|
+
control={form.control}
|
|
108
|
+
name="email"
|
|
109
|
+
placeholder="Enter your email"
|
|
110
|
+
onChange={(e) => {
|
|
111
|
+
form.setValue("firstname", e.target.value);
|
|
112
|
+
}}
|
|
113
|
+
/>
|
|
114
|
+
<Button className="ml-auto w-full" type="submit">
|
|
115
|
+
Log In
|
|
116
|
+
</Button>
|
|
117
|
+
</Form>
|
|
122
118
|
);
|
|
123
119
|
}
|
|
124
120
|
```
|
|
@@ -126,9 +122,9 @@ export default function UserAuthForm() {
|
|
|
126
122
|
## Example of a data table
|
|
127
123
|
|
|
128
124
|
```tsx
|
|
129
|
-
import React, { useState } from
|
|
130
|
-
import { DataTable } from
|
|
131
|
-
import { ColumnDef } from
|
|
125
|
+
import React, { useState } from "react";
|
|
126
|
+
import { DataTable } from "shadcn-ui-react";
|
|
127
|
+
import { ColumnDef } from "@tanstack/react-table";
|
|
132
128
|
|
|
133
129
|
type Data = {
|
|
134
130
|
id: number;
|
|
@@ -138,23 +134,23 @@ type Data = {
|
|
|
138
134
|
|
|
139
135
|
const columns: ColumnDef<Data, any>[] = [
|
|
140
136
|
{
|
|
141
|
-
accessorKey:
|
|
142
|
-
header:
|
|
137
|
+
accessorKey: "id",
|
|
138
|
+
header: "ID",
|
|
143
139
|
},
|
|
144
140
|
{
|
|
145
|
-
accessorKey:
|
|
146
|
-
header:
|
|
141
|
+
accessorKey: "name",
|
|
142
|
+
header: "Name",
|
|
147
143
|
},
|
|
148
144
|
{
|
|
149
|
-
accessorKey:
|
|
150
|
-
header:
|
|
145
|
+
accessorKey: "age",
|
|
146
|
+
header: "Age",
|
|
151
147
|
},
|
|
152
148
|
];
|
|
153
149
|
|
|
154
150
|
const data: Data[] = [
|
|
155
|
-
{ id: 1, name:
|
|
156
|
-
{ id: 2, name:
|
|
157
|
-
{ id: 3, name:
|
|
151
|
+
{ id: 1, name: "John Doe", age: 28 },
|
|
152
|
+
{ id: 2, name: "Jane Smith", age: 34 },
|
|
153
|
+
{ id: 3, name: "Sam Johnson", age: 45 },
|
|
158
154
|
];
|
|
159
155
|
|
|
160
156
|
const Example = () => {
|
|
@@ -165,7 +161,7 @@ const Example = () => {
|
|
|
165
161
|
};
|
|
166
162
|
|
|
167
163
|
const handleRowClick = (row: Data) => {
|
|
168
|
-
console.log(
|
|
164
|
+
console.log("Row clicked:", row);
|
|
169
165
|
};
|
|
170
166
|
|
|
171
167
|
return (
|
|
@@ -184,4 +180,4 @@ const Example = () => {
|
|
|
184
180
|
};
|
|
185
181
|
|
|
186
182
|
export default Example;
|
|
187
|
-
```
|
|
183
|
+
```
|