@juv/codego-react-ui 3.1.7 → 3.1.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 +34 -0
- package/dist/index.cjs +2710 -1937
- package/dist/index.d.cts +657 -505
- package/dist/index.d.ts +657 -505
- package/dist/index.global.js +2697 -1899
- package/dist/index.js +2660 -1890
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -424,6 +424,40 @@ import { Button, Card, Modal } from "@juv/codego-react-ui"
|
|
|
424
424
|
|
|
425
425
|
---
|
|
426
426
|
|
|
427
|
+
## Form Validation Props
|
|
428
|
+
|
|
429
|
+
All form input components support two shared validation props:
|
|
430
|
+
|
|
431
|
+
| Prop | Type | Description |
|
|
432
|
+
|---|---|---|
|
|
433
|
+
| `required` | `boolean` | Marks the field as required. Shows a `*` indicator next to the label. Also sets `aria-required` on the underlying input. |
|
|
434
|
+
| `error` | `string` | External error message rendered below the field in destructive color. Also sets `aria-invalid` on the underlying input. |
|
|
435
|
+
|
|
436
|
+
Applies to: `Input`, `Select`, `Textarea`, `Checkbox`, `ToggleSwitch`, `RadioGroup`, `Combobox`, `TagInput`, `OtpInput`, `ColorPicker`, `Slider`, `RangeSlider`, `FileUpload`.
|
|
437
|
+
|
|
438
|
+
```tsx
|
|
439
|
+
// Required field with * indicator
|
|
440
|
+
<Input label="Email" required placeholder="you@example.com" />
|
|
441
|
+
|
|
442
|
+
// External error message (e.g. from server validation)
|
|
443
|
+
<Input label="Email" required error="Email is already taken" />
|
|
444
|
+
|
|
445
|
+
// Works on all form components
|
|
446
|
+
<Select label="Role" required error="Please select a role" options={options} />
|
|
447
|
+
<Checkbox inline label="Accept terms" required error="You must accept the terms" />
|
|
448
|
+
<ToggleSwitch inline label="Enable 2FA" required />
|
|
449
|
+
<Textarea label="Bio" required error="Bio is required" />
|
|
450
|
+
<RadioGroup options={plans} required error="Please select a plan" />
|
|
451
|
+
<Combobox options={frameworks} required error="Please select a framework" />
|
|
452
|
+
<TagInput required error="At least one tag is required" />
|
|
453
|
+
<OtpInput length={6} required error="Please enter the code" />
|
|
454
|
+
<ColorPicker required error="Please select a color" />
|
|
455
|
+
<Slider label="Volume" required error="Please set a value" />
|
|
456
|
+
<FileUpload label="Avatar" required error="Please upload a file" />
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
---
|
|
460
|
+
|
|
427
461
|
## Components
|
|
428
462
|
|
|
429
463
|
| Component | Export(s) |
|