shadcn-ui-react 0.2.7 → 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 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 'shadcn-ui-react/dist/style.css';
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 'shadcn-ui-react'
26
+ import { Button } from "shadcn-ui-react";
27
27
 
28
28
  export default function MyComponent() {
29
- return (<Button>Hello world</Button>)
29
+ return <Button>Hello world</Button>;
30
30
  }
31
31
  ```
32
32
 
33
33
  ```tsx
34
- import { Card } from 'shadcn-ui-react'
34
+ import { Card } from "shadcn-ui-react";
35
35
 
36
36
  export default function MyComponent() {
37
- return (<Card><h1>Hello World</h1></Card>)
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 'react';
43
- import { SearchInput } from './components/search-input';
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('Search term:', term);
54
+ console.log("Search term:", term);
51
55
  };
52
56
 
53
- return (<SearchInput placeholder="Search" value={searchTerm} onSearch={handleSearch} />);
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 '@hookform/resolvers/zod';
60
- import { useForm } from 'react-hook-form';
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 'shadcn-ui-react';
71
- import * as z from 'zod';
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: 'Enter a valid email address' }),
85
+ email: z.string().email({ message: "Enter a valid email address" }),
75
86
  password: z
76
87
  .string()
77
- .min(8, { message: 'Password must be at least 8 characters' })
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: 'demo@domain.com'
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
- <Form {...form}>
95
- <form
96
- onSubmit={form.handleSubmit(onSubmit)}
97
- className="w-full space-y-2"
98
- >
99
- <FormField
100
- control={form.control}
101
- name="email"
102
- render={({ field }) => (
103
- <FormItem>
104
- <FormLabel>Email</FormLabel>
105
- <FormControl>
106
- <Input
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 'react';
130
- import { DataTable } from 'shadcn-ui-react';
131
- import { ColumnDef } from '@tanstack/react-table';
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: 'id',
142
- header: 'ID',
137
+ accessorKey: "id",
138
+ header: "ID",
143
139
  },
144
140
  {
145
- accessorKey: 'name',
146
- header: 'Name',
141
+ accessorKey: "name",
142
+ header: "Name",
147
143
  },
148
144
  {
149
- accessorKey: 'age',
150
- header: 'Age',
145
+ accessorKey: "age",
146
+ header: "Age",
151
147
  },
152
148
  ];
153
149
 
154
150
  const data: Data[] = [
155
- { id: 1, name: 'John Doe', age: 28 },
156
- { id: 2, name: 'Jane Smith', age: 34 },
157
- { id: 3, name: 'Sam Johnson', age: 45 },
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('Row clicked:', row);
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
+ ```