shadcn-ui-react 0.5.0 → 0.5.1

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
@@ -141,6 +141,116 @@ export default function App() {
141
141
  <Button loading>Loading...</Button>
142
142
  ```
143
143
 
144
+ ---
145
+
146
+ ### ✍️ UiInput
147
+
148
+ ```tsx
149
+ import { UiInput } from "shadcn-ui-react";
150
+
151
+ export default function Example() {
152
+ const [name, setName] = React.useState("");
153
+
154
+ return (
155
+ <UiInput
156
+ htmlFormItemId="name"
157
+ variant="outline"
158
+ label="Name"
159
+ placeholder="Enter name"
160
+ value={name}
161
+ onChange={(e) => setName(e.target.value)}
162
+ errorMessage={
163
+ name.length > 0 && name.trim().length < 2
164
+ ? "Min 2 characters"
165
+ : undefined
166
+ }
167
+ />
168
+ );
169
+ }
170
+ ```
171
+
172
+ ---
173
+
174
+ ### 🧾 UiSelect
175
+
176
+ Using `items`:
177
+
178
+ ```tsx
179
+ import { UiSelect } from "shadcn-ui-react";
180
+
181
+ export default function LanguageSelectItemsDemo() {
182
+ const [lang, setLang] = React.useState("");
183
+
184
+ return (
185
+ <UiSelect
186
+ htmlFormItemId="language"
187
+ label="Language"
188
+ placeholder="Select a language"
189
+ value={lang}
190
+ onChange={setLang}
191
+ variant="outline"
192
+ size="md"
193
+ items={[
194
+ { label: "Spanish", value: "es" },
195
+ { label: "English", value: "en" },
196
+ { label: "Portuguese", value: "pt" },
197
+ { label: "Chinese", value: "zh" },
198
+ { label: "Japanese", value: "ja" },
199
+ { label: "Korean (disabled)", value: "ko", disabled: true },
200
+ ]}
201
+ errorMessage={!lang ? "Please select a language." : undefined}
202
+ />
203
+ );
204
+ }
205
+ ```
206
+
207
+ Using `children`:
208
+
209
+ ```tsx
210
+ import {
211
+ UiSelect,
212
+ SelectGroup,
213
+ SelectItem,
214
+ SelectLabel,
215
+ SelectSeparator,
216
+ } from "shadcn-ui-react";
217
+
218
+ export default function LanguageSelectChildrenDemo() {
219
+ const [lang, setLang] = React.useState("");
220
+
221
+ return (
222
+ <UiSelect
223
+ htmlFormItemId="language_children"
224
+ label="Language (grouped)"
225
+ placeholder="Select a language"
226
+ value={lang}
227
+ onChange={setLang}
228
+ variant="outline"
229
+ size="md"
230
+ errorMessage={!lang ? "Please select a language." : undefined}
231
+ >
232
+ <SelectGroup>
233
+ <SelectLabel>Common</SelectLabel>
234
+ <SelectItem value="es">Spanish</SelectItem>
235
+ <SelectItem value="en">English</SelectItem>
236
+ <SelectItem value="pt">Portuguese</SelectItem>
237
+
238
+ <SelectSeparator />
239
+
240
+ <SelectLabel>Asia</SelectLabel>
241
+ <SelectItem value="zh">Chinese</SelectItem>
242
+ <SelectItem value="ja">Japanese</SelectItem>
243
+ <SelectItem value="ko" disabled>
244
+ Korean (disabled)
245
+ </SelectItem>
246
+ </SelectGroup>
247
+ </UiSelect>
248
+ );
249
+ }
250
+ ```
251
+
252
+ ---
253
+
144
254
  ### 🪄 Accordion
145
255
 
146
256
  ```tsx
@@ -152,12 +262,16 @@ export default function App() {
152
262
  </Accordion>
153
263
  ```
154
264
 
265
+ ---
266
+
155
267
  ### ⚠️ Alert
156
268
 
157
269
  ```tsx
158
270
  <Alert>This is an alert message</Alert>
159
271
  ```
160
272
 
273
+ ---
274
+
161
275
  ### 🧾 Form
162
276
 
163
277
  ```tsx
@@ -177,13 +291,13 @@ import * as z from "zod";
177
291
 
178
292
  const formSchema = z.object({
179
293
  email: z.email({
180
- pattern: z.regexes.email,
181
- error: 'Email is required'
294
+ pattern: z.regexes.email,
295
+ error: "Email is required",
182
296
  }),
183
297
  password: z
184
298
  .string()
185
299
  .min(8, { message: "Password must be at least 8 characters" }),
186
- gender: z.enum(['male', 'female']).optional().nullable(),
300
+ gender: z.enum(["male", "female"]).optional().nullable(),
187
301
  });
188
302
 
189
303
  type UserFormValue = z.infer<typeof formSchema>;
@@ -192,6 +306,7 @@ export default function UserAuthForm() {
192
306
  const defaultValues = {
193
307
  email: "demo@domain.com",
194
308
  };
309
+
195
310
  const form = useForm<UserFormValue>({
196
311
  resolver: zodResolver(formSchema),
197
312
  defaultValues,
@@ -207,29 +322,32 @@ export default function UserAuthForm() {
207
322
  type="email"
208
323
  placeholder="Enter your email"
209
324
  label="Email"
210
- variant="outline" //outline | soft | ghost | filled | flushed | unstyled | link
211
- className="" //your style
325
+ variant="outline" // outline | soft | ghost | filled | flushed | unstyled | link
326
+ className="" // your style
212
327
  />
328
+
213
329
  <FormField
214
- control={form.control}
215
- name="password"
216
- type="password"
217
- placeholder="Enter password"
218
- label="Password"
219
- variant="outline" //outline | soft | ghost | filled | flushed | unstyled | link
220
- className="" //your style
221
- />
330
+ control={form.control}
331
+ name="password"
332
+ type="password"
333
+ placeholder="Enter password"
334
+ label="Password"
335
+ variant="outline" // outline | soft | ghost | filled | flushed | unstyled | link
336
+ className="" // your style
337
+ />
338
+
222
339
  <FormSelect
223
340
  control={form.control}
224
341
  name="gender"
225
342
  label="Gender"
226
- variant="outline" //outline | soft | ghost | filled | flushed | unstyled | link
227
- className="" //your style
343
+ variant="outline" // outline | soft | ghost | filled | flushed | unstyled | link
344
+ className="" // your style
228
345
  items={[
229
346
  { label: "Male", value: "male" },
230
347
  { label: "Female", value: "female" },
231
348
  ]}
232
349
  />
350
+
233
351
  <Button className="ml-auto w-full" type="submit">
234
352
  Log In
235
353
  </Button>
@@ -238,6 +356,8 @@ export default function UserAuthForm() {
238
356
  }
239
357
  ```
240
358
 
359
+ ---
360
+
241
361
  ### 📊 DataTable
242
362
 
243
363
  ```tsx
@@ -252,18 +372,9 @@ type User = {
252
372
  };
253
373
 
254
374
  const columns: ColumnDef<User, any>[] = [
255
- {
256
- accessorKey: "id",
257
- header: "ID",
258
- },
259
- {
260
- accessorKey: "name",
261
- header: "Name",
262
- },
263
- {
264
- accessorKey: "email",
265
- header: "Email",
266
- },
375
+ { accessorKey: "id", header: "ID" },
376
+ { accessorKey: "name", header: "Name" },
377
+ { accessorKey: "email", header: "Email" },
267
378
  ];
268
379
 
269
380
  const data: User[] = [
@@ -285,18 +396,17 @@ const Example = () => {
285
396
 
286
397
  const paginatedData = data.slice((page - 1) * perPage, page * perPage);
287
398
 
288
- const handlePageChange = (newPage: number) => {
289
- setPage(newPage);
290
- };
399
+ const handlePageChange = (newPage: number) => setPage(newPage);
291
400
 
292
401
  const handlePageSizeChange = (newPageSize: number) => {
293
402
  setPerPage(newPageSize);
294
- setPage(1); // Reset to the first page when page size changes
403
+ setPage(1);
295
404
  };
296
405
 
297
406
  return (
298
407
  <div>
299
408
  <h1 className="text-xl font-bold mb-4">Data Table with Pagination</h1>
409
+
300
410
  <DataTable
301
411
  columns={columns}
302
412
  data={paginatedData}