laif-ds 0.2.43 → 0.2.45
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/_virtual/index6.js +2 -2
- package/dist/_virtual/index7.js +2 -2
- package/dist/agent-docs/components/Accordion.md +157 -0
- package/dist/agent-docs/components/Alert.md +95 -0
- package/dist/agent-docs/components/AlertDialog.md +126 -0
- package/dist/agent-docs/components/AppEditor.md +90 -0
- package/dist/agent-docs/components/AppForm.md +242 -0
- package/dist/agent-docs/components/AppMultipleSelectDropdown.md +38 -0
- package/dist/agent-docs/components/AppRadioGroup.md +223 -0
- package/dist/agent-docs/components/AppSelect.md +427 -0
- package/dist/agent-docs/components/AppSidebar.md +122 -0
- package/dist/agent-docs/components/AppStepper.md +77 -0
- package/dist/agent-docs/components/AspectRatio.md +87 -0
- package/dist/agent-docs/components/AsyncSelect.md +127 -0
- package/dist/agent-docs/components/AudioVisualizer.md +41 -0
- package/dist/agent-docs/components/Avatar.md +113 -0
- package/dist/agent-docs/components/Badge.md +118 -0
- package/dist/agent-docs/components/Breadcrumb.md +78 -0
- package/dist/agent-docs/components/Button.md +129 -0
- package/dist/agent-docs/components/Calendar.md +222 -0
- package/dist/agent-docs/components/Card.md +147 -0
- package/dist/agent-docs/components/Carousel.md +129 -0
- package/dist/agent-docs/components/Chart.md +75 -0
- package/dist/agent-docs/components/Chat.md +109 -0
- package/dist/agent-docs/components/ChatMessage.md +61 -0
- package/dist/agent-docs/components/Checkbox.md +135 -0
- package/dist/agent-docs/components/CircularProgress.md +49 -0
- package/dist/agent-docs/components/CodeHighlighter.md +31 -0
- package/dist/agent-docs/components/Collapsible.md +95 -0
- package/dist/agent-docs/components/Command.md +142 -0
- package/dist/agent-docs/components/Confirmer.md +175 -0
- package/dist/agent-docs/components/ContextMenu.md +191 -0
- package/dist/agent-docs/components/CopyButton.md +26 -0
- package/dist/agent-docs/components/DataCrossTable.md +94 -0
- package/dist/agent-docs/components/DataTable.md +254 -0
- package/dist/agent-docs/components/DatePicker.md +109 -0
- package/dist/agent-docs/components/Dialog.md +125 -0
- package/dist/agent-docs/components/Drawer.md +127 -0
- package/dist/agent-docs/components/DropdownMenu.md +57 -0
- package/dist/agent-docs/components/FilePreview.md +99 -0
- package/dist/agent-docs/components/FilePreviewer.md +139 -0
- package/dist/agent-docs/components/FileUploader.md +129 -0
- package/dist/agent-docs/components/Form.md +62 -0
- package/dist/agent-docs/components/FormComposer.md +137 -0
- package/dist/agent-docs/components/GanttChart.md +122 -0
- package/dist/agent-docs/components/HoverCard.md +37 -0
- package/dist/agent-docs/components/Icon.md +99 -0
- package/dist/agent-docs/components/Input.md +138 -0
- package/dist/agent-docs/components/InputOtp.md +40 -0
- package/dist/agent-docs/components/InputSelector.md +97 -0
- package/dist/agent-docs/components/InterruptPrompt.md +32 -0
- package/dist/agent-docs/components/Label.md +28 -0
- package/dist/agent-docs/components/MarkdownRenderer.md +36 -0
- package/dist/agent-docs/components/Menubar.md +164 -0
- package/dist/agent-docs/components/MessageInput.md +131 -0
- package/dist/agent-docs/components/MessageList.md +96 -0
- package/dist/agent-docs/components/MultipleSelector.md +146 -0
- package/dist/agent-docs/components/NavigationMenu.md +51 -0
- package/dist/agent-docs/components/Pagination.md +55 -0
- package/dist/agent-docs/components/Popover.md +103 -0
- package/dist/agent-docs/components/Progress.md +30 -0
- package/dist/agent-docs/components/PromptSuggestions.md +33 -0
- package/dist/agent-docs/components/RadioGroup.md +90 -0
- package/dist/agent-docs/components/Resizable.md +35 -0
- package/dist/agent-docs/components/ResizePrompt.md +13 -0
- package/dist/agent-docs/components/ScrollArea.md +49 -0
- package/dist/agent-docs/components/SecurePdfViewer.md +38 -0
- package/dist/agent-docs/components/Select.md +132 -0
- package/dist/agent-docs/components/Separator.md +32 -0
- package/dist/agent-docs/components/Sheet.md +40 -0
- package/dist/agent-docs/components/ShikiHighlighter.md +31 -0
- package/dist/agent-docs/components/Sidebar.md +85 -0
- package/dist/agent-docs/components/Skeleton.md +29 -0
- package/dist/agent-docs/components/Slider.md +58 -0
- package/dist/agent-docs/components/Sonner.md +21 -0
- package/dist/agent-docs/components/Spinner.md +139 -0
- package/dist/agent-docs/components/Stepper.md +67 -0
- package/dist/agent-docs/components/Switch.md +42 -0
- package/dist/agent-docs/components/Table.md +63 -0
- package/dist/agent-docs/components/TableSkeleton.md +46 -0
- package/dist/agent-docs/components/Tabs.md +86 -0
- package/dist/agent-docs/components/TextArea.md +52 -0
- package/dist/agent-docs/components/ThemeSwitcher.md +69 -0
- package/dist/agent-docs/components/Toaster.md +23 -0
- package/dist/agent-docs/components/Toggle.md +31 -0
- package/dist/agent-docs/components/ToggleGroup.md +30 -0
- package/dist/agent-docs/components/Tooltip.md +91 -0
- package/dist/agent-docs/components/TypingIndicator.md +21 -0
- package/dist/agent-docs/components/Typo.md +65 -0
- package/dist/agent-docs/components/WeeklyCalendar.md +64 -0
- package/dist/agent-docs/components-list.md +144 -0
- package/dist/components/ui/spinner.js +67 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +363 -361
- package/dist/node_modules/eventemitter3/index2.js +1 -1
- package/dist/node_modules/style-to-object/cjs/index.js +1 -1
- package/dist/styles.v3.css +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
# AppForm
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Dynamic form component that integrates with React Hook Form to provide a configurable form with multiple field types including input, textarea, select, multiselect, datepicker, radio, checkbox, switch, and slider. Automatically handles validation errors and form state.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Types
|
|
10
|
+
|
|
11
|
+
### AppFormItem
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
interface AppFormItem {
|
|
15
|
+
label: string; // Field label
|
|
16
|
+
component:
|
|
17
|
+
| "input"
|
|
18
|
+
| "select"
|
|
19
|
+
| "textarea"
|
|
20
|
+
| "checkbox"
|
|
21
|
+
| "multiselect"
|
|
22
|
+
| "datepicker"
|
|
23
|
+
| "radio"
|
|
24
|
+
| "switch"
|
|
25
|
+
| "slider"; // Field type
|
|
26
|
+
name: string; // Field name (used for form state and validation)
|
|
27
|
+
defaultValue?: string | boolean | number | string[] | Date | number[]; // Initial value
|
|
28
|
+
options?: AppSelectOption[]; // Options for select/multiselect/radio
|
|
29
|
+
disabled?: boolean; // Disables the field
|
|
30
|
+
placeholder?: string; // Placeholder text
|
|
31
|
+
caption?: string; // Helper text below the field
|
|
32
|
+
calendarRange?: [Date, Date]; // Date range for datepicker
|
|
33
|
+
min?: number; // Minimum value for slider
|
|
34
|
+
max?: number; // Maximum value for slider
|
|
35
|
+
step?: number; // Step value for slider
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Props
|
|
42
|
+
|
|
43
|
+
| Prop | Type | Default | Description |
|
|
44
|
+
| --------------- | -------------------------- | --------- | ---------------------------------------- |
|
|
45
|
+
| `items` | `AppFormItem[]` | **required** | Array of form field configurations |
|
|
46
|
+
| `form` | `UseFormReturn<any>` | **required** | React Hook Form instance |
|
|
47
|
+
| `cols` | `"1" \| "2" \| "3"` | `"2"` | Number of grid columns |
|
|
48
|
+
| `submitText` | `string` | `"Invia"` | Text for submit button |
|
|
49
|
+
| `onSubmit` | `(data: any) => void` | `undefined` | Form submission callback |
|
|
50
|
+
| `isSubmitting` | `boolean` | `false` | Shows loading state on submit button |
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Behavior
|
|
55
|
+
|
|
56
|
+
- **React Hook Form Integration**: Uses `Controller` from React Hook Form for each field
|
|
57
|
+
- **Validation Display**: Shows validation errors inline with each field
|
|
58
|
+
- **Grid Layout**: Automatically arranges fields in a responsive grid based on `cols` prop
|
|
59
|
+
- **Submit Button**: Automatically disabled when form is invalid or pristine
|
|
60
|
+
- **Last Field Spanning**: The last field automatically spans full width
|
|
61
|
+
- **Error Highlighting**: Fields with errors get red border styling
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Field Types
|
|
66
|
+
|
|
67
|
+
### input
|
|
68
|
+
Standard text input field
|
|
69
|
+
|
|
70
|
+
### textarea
|
|
71
|
+
Multi-line text area
|
|
72
|
+
|
|
73
|
+
### select
|
|
74
|
+
Single selection dropdown using AppSelect
|
|
75
|
+
|
|
76
|
+
### multiselect
|
|
77
|
+
Multiple selection dropdown using AppSelect with `multiple` prop
|
|
78
|
+
|
|
79
|
+
### datepicker
|
|
80
|
+
Date picker component with optional range selection via `calendarRange`
|
|
81
|
+
|
|
82
|
+
### radio
|
|
83
|
+
Radio button group with options
|
|
84
|
+
|
|
85
|
+
### checkbox
|
|
86
|
+
Single checkbox with label
|
|
87
|
+
|
|
88
|
+
### switch
|
|
89
|
+
Toggle switch with label and optional caption
|
|
90
|
+
|
|
91
|
+
### slider
|
|
92
|
+
Range slider with min/max/step configuration
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Examples
|
|
97
|
+
|
|
98
|
+
### Basic Form
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
import { AppForm } from "laif-ds";
|
|
102
|
+
import { useForm } from "react-hook-form";
|
|
103
|
+
|
|
104
|
+
export function BasicForm() {
|
|
105
|
+
const form = useForm();
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<AppForm
|
|
109
|
+
form={form}
|
|
110
|
+
items={[
|
|
111
|
+
{
|
|
112
|
+
label: "Name",
|
|
113
|
+
component: "input",
|
|
114
|
+
name: "name",
|
|
115
|
+
placeholder: "Enter your name",
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
label: "Email",
|
|
119
|
+
component: "input",
|
|
120
|
+
name: "email",
|
|
121
|
+
placeholder: "Enter your email",
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
label: "Message",
|
|
125
|
+
component: "textarea",
|
|
126
|
+
name: "message",
|
|
127
|
+
placeholder: "Enter your message",
|
|
128
|
+
},
|
|
129
|
+
]}
|
|
130
|
+
onSubmit={(data) => console.log(data)}
|
|
131
|
+
/>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Full Feature Form
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
import { AppForm } from "laif-ds";
|
|
140
|
+
import { useForm } from "react-hook-form";
|
|
141
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
142
|
+
import { z } from "zod";
|
|
143
|
+
|
|
144
|
+
const schema = z.object({
|
|
145
|
+
name: z.string().min(1, "Name is required"),
|
|
146
|
+
category: z.string(),
|
|
147
|
+
isActive: z.boolean(),
|
|
148
|
+
priority: z.number(),
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
export function FullFeatureForm() {
|
|
152
|
+
const form = useForm({
|
|
153
|
+
resolver: zodResolver(schema),
|
|
154
|
+
defaultValues: {
|
|
155
|
+
name: "",
|
|
156
|
+
category: "",
|
|
157
|
+
isActive: false,
|
|
158
|
+
priority: 5,
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<AppForm
|
|
164
|
+
form={form}
|
|
165
|
+
cols="2"
|
|
166
|
+
items={[
|
|
167
|
+
{
|
|
168
|
+
label: "Name",
|
|
169
|
+
component: "input",
|
|
170
|
+
name: "name",
|
|
171
|
+
placeholder: "Enter name",
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
label: "Category",
|
|
175
|
+
component: "select",
|
|
176
|
+
name: "category",
|
|
177
|
+
options: [
|
|
178
|
+
{ value: "tech", label: "Technology" },
|
|
179
|
+
{ value: "design", label: "Design" },
|
|
180
|
+
{ value: "marketing", label: "Marketing" },
|
|
181
|
+
],
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
label: "Active",
|
|
185
|
+
component: "switch",
|
|
186
|
+
name: "isActive",
|
|
187
|
+
caption: "Enable this option",
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
label: "Priority",
|
|
191
|
+
component: "slider",
|
|
192
|
+
name: "priority",
|
|
193
|
+
min: 1,
|
|
194
|
+
max: 10,
|
|
195
|
+
step: 1,
|
|
196
|
+
},
|
|
197
|
+
]}
|
|
198
|
+
submitText="Save"
|
|
199
|
+
onSubmit={(data) => console.log(data)}
|
|
200
|
+
/>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### With Date Range
|
|
206
|
+
|
|
207
|
+
```tsx
|
|
208
|
+
import { AppForm } from "laif-ds";
|
|
209
|
+
import { useForm } from "react-hook-form";
|
|
210
|
+
|
|
211
|
+
export function DateRangeForm() {
|
|
212
|
+
const form = useForm();
|
|
213
|
+
const startDate = new Date();
|
|
214
|
+
const endDate = new Date();
|
|
215
|
+
endDate.setMonth(endDate.getMonth() + 1);
|
|
216
|
+
|
|
217
|
+
return (
|
|
218
|
+
<AppForm
|
|
219
|
+
form={form}
|
|
220
|
+
items={[
|
|
221
|
+
{
|
|
222
|
+
label: "Date Range",
|
|
223
|
+
component: "datepicker",
|
|
224
|
+
name: "dateRange",
|
|
225
|
+
calendarRange: [startDate, endDate],
|
|
226
|
+
},
|
|
227
|
+
]}
|
|
228
|
+
onSubmit={(data) => console.log(data)}
|
|
229
|
+
/>
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Notes
|
|
237
|
+
|
|
238
|
+
- **React Hook Form Required**: This component requires React Hook Form to be installed and configured
|
|
239
|
+
- **Validation**: Use React Hook Form's resolver (e.g., Zod, Yup) for validation
|
|
240
|
+
- **Grid Layout**: The grid uses Tailwind's grid system with `grid-cols-{n}` classes
|
|
241
|
+
- **Submit Button**: Always appears at the end of the form on the right
|
|
242
|
+
- **Error Display**: Errors appear inline above each field and as border highlighting
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# AppMultipleSelectDropdown
|
|
2
|
+
|
|
3
|
+
> Deprecated: Use AppSelect instead.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Legacy multi-select dropdown component. This component is deprecated in favor of `AppSelect` which provides better accessibility, features, and API consistency.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Replacement
|
|
12
|
+
|
|
13
|
+
Use `AppSelect` with `multiple` and an array of values.
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { AppSelect } from "laif-ds";
|
|
17
|
+
|
|
18
|
+
export function Replacement() {
|
|
19
|
+
return (
|
|
20
|
+
<AppSelect
|
|
21
|
+
multiple
|
|
22
|
+
options={[
|
|
23
|
+
{ value: "a", label: "Option A" },
|
|
24
|
+
{ value: "b", label: "Option B" },
|
|
25
|
+
]}
|
|
26
|
+
value={["a"]}
|
|
27
|
+
onValueChange={(v) => console.log(v)}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Notes
|
|
36
|
+
|
|
37
|
+
- The old component supported search and maxSelectedItems, but `AppSelect` now provides these features with a more robust API and better UX.
|
|
38
|
+
- Plan migration to `AppSelect` and remove this component from new code.
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# AppRadioGroup
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Enhanced radio group component with support for icons, descriptions, card layout, horizontal/vertical orientation, and comprehensive error handling. Built on top of the base RadioGroup component with additional styling and features.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Types
|
|
10
|
+
|
|
11
|
+
### AppRadioGroupOption
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
export interface AppRadioGroupOption {
|
|
15
|
+
value: string; // Unique value for the option
|
|
16
|
+
label: string | React.ReactNode; // Display label (can be JSX)
|
|
17
|
+
description?: string | React.ReactNode; // Optional description text
|
|
18
|
+
disabled?: boolean; // Disables this specific option
|
|
19
|
+
icon?: IconName; // Optional icon name
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Props
|
|
26
|
+
|
|
27
|
+
| Prop | Type | Default | Description |
|
|
28
|
+
| ----------------- | -------------------------------- | ------------ | ---------------------------------------------- |
|
|
29
|
+
| `options` | `AppRadioGroupOption[]` | **required** | Array of radio options |
|
|
30
|
+
| `value` | `string` | `undefined` | Controlled value |
|
|
31
|
+
| `defaultValue` | `string` | `undefined` | Uncontrolled default value |
|
|
32
|
+
| `onValueChange` | `(value: string) => void` | `undefined` | Callback when value changes |
|
|
33
|
+
| `label` | `string \| React.ReactNode` | `undefined` | Label for the radio group |
|
|
34
|
+
| `description` | `string \| React.ReactNode` | `undefined` | Description text below label |
|
|
35
|
+
| `disabled` | `boolean` | `false` | Disables all options |
|
|
36
|
+
| `required` | `boolean` | `false` | Shows required asterisk |
|
|
37
|
+
| `name` | `string` | `undefined` | Form name attribute |
|
|
38
|
+
| `orientation` | `"horizontal" \| "vertical"` | `"vertical"` | Layout orientation |
|
|
39
|
+
| `loop` | `boolean` | `true` | Enable keyboard navigation looping |
|
|
40
|
+
| `className` | `string` | `""` | Additional classes for radio group container |
|
|
41
|
+
| `wrpClassName` | `string` | `""` | Additional classes for outer wrapper |
|
|
42
|
+
| `optionClassName` | `string` | `""` | Additional classes for each option |
|
|
43
|
+
| `layout` | `"default" \| "card"` | `"default"` | Visual layout style |
|
|
44
|
+
| `error` | `string` | `undefined` | Error message to display |
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Behavior
|
|
49
|
+
|
|
50
|
+
- **Controlled/Uncontrolled**: Supports both controlled (`value` + `onValueChange`) and uncontrolled (`defaultValue`) modes
|
|
51
|
+
- **Keyboard Navigation**: Full keyboard support with arrow keys and looping
|
|
52
|
+
- **Icons**: Automatically renders icons when provided in options
|
|
53
|
+
- **Card Layout**: In card mode, options have border, shadow, and background styling
|
|
54
|
+
- **Error State**: Red text for label and error message display when `error` prop is provided
|
|
55
|
+
- **Disabled State**: Applies opacity and cursor changes to disabled options
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Examples
|
|
60
|
+
|
|
61
|
+
### Basic Usage
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import { AppRadioGroup } from "laif-ds";
|
|
65
|
+
import { useState } from "react";
|
|
66
|
+
|
|
67
|
+
export function BasicRadioGroup() {
|
|
68
|
+
const [value, setValue] = useState("option1");
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<AppRadioGroup
|
|
72
|
+
label="Choose an option"
|
|
73
|
+
options={[
|
|
74
|
+
{ value: "option1", label: "Option 1" },
|
|
75
|
+
{ value: "option2", label: "Option 2" },
|
|
76
|
+
{ value: "option3", label: "Option 3" },
|
|
77
|
+
]}
|
|
78
|
+
value={value}
|
|
79
|
+
onValueChange={setValue}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### With Icons and Descriptions
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import { AppRadioGroup } from "laif-ds";
|
|
89
|
+
import { useState } from "react";
|
|
90
|
+
|
|
91
|
+
export function RadioWithIcons() {
|
|
92
|
+
const [value, setValue] = useState("email");
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<AppRadioGroup
|
|
96
|
+
label="Notification Method"
|
|
97
|
+
description="Choose how you want to receive notifications"
|
|
98
|
+
options={[
|
|
99
|
+
{
|
|
100
|
+
value: "email",
|
|
101
|
+
label: "Email",
|
|
102
|
+
description: "Receive notifications via email",
|
|
103
|
+
icon: "Mail",
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
value: "sms",
|
|
107
|
+
label: "SMS",
|
|
108
|
+
description: "Receive notifications via text message",
|
|
109
|
+
icon: "MessageSquare",
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
value: "push",
|
|
113
|
+
label: "Push",
|
|
114
|
+
description: "Receive push notifications",
|
|
115
|
+
icon: "Bell",
|
|
116
|
+
},
|
|
117
|
+
]}
|
|
118
|
+
value={value}
|
|
119
|
+
onValueChange={setValue}
|
|
120
|
+
/>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Card Layout
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
import { AppRadioGroup } from "laif-ds";
|
|
129
|
+
import { useState } from "react";
|
|
130
|
+
|
|
131
|
+
export function CardRadioGroup() {
|
|
132
|
+
const [value, setValue] = useState("basic");
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<AppRadioGroup
|
|
136
|
+
label="Choose a plan"
|
|
137
|
+
layout="card"
|
|
138
|
+
options={[
|
|
139
|
+
{
|
|
140
|
+
value: "basic",
|
|
141
|
+
label: "Basic",
|
|
142
|
+
description: "$9/month - Essential features",
|
|
143
|
+
icon: "Package",
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
value: "pro",
|
|
147
|
+
label: "Pro",
|
|
148
|
+
description: "$29/month - Advanced features",
|
|
149
|
+
icon: "Zap",
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
value: "enterprise",
|
|
153
|
+
label: "Enterprise",
|
|
154
|
+
description: "Custom pricing - All features",
|
|
155
|
+
icon: "Building",
|
|
156
|
+
},
|
|
157
|
+
]}
|
|
158
|
+
value={value}
|
|
159
|
+
onValueChange={setValue}
|
|
160
|
+
/>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Horizontal Orientation
|
|
166
|
+
|
|
167
|
+
```tsx
|
|
168
|
+
import { AppRadioGroup } from "laif-ds";
|
|
169
|
+
import { useState } from "react";
|
|
170
|
+
|
|
171
|
+
export function HorizontalRadioGroup() {
|
|
172
|
+
const [value, setValue] = useState("small");
|
|
173
|
+
|
|
174
|
+
return (
|
|
175
|
+
<AppRadioGroup
|
|
176
|
+
label="Size"
|
|
177
|
+
orientation="horizontal"
|
|
178
|
+
options={[
|
|
179
|
+
{ value: "small", label: "Small" },
|
|
180
|
+
{ value: "medium", label: "Medium" },
|
|
181
|
+
{ value: "large", label: "Large" },
|
|
182
|
+
]}
|
|
183
|
+
value={value}
|
|
184
|
+
onValueChange={setValue}
|
|
185
|
+
/>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### With Error State
|
|
191
|
+
|
|
192
|
+
```tsx
|
|
193
|
+
import { AppRadioGroup } from "laif-ds";
|
|
194
|
+
import { useState } from "react";
|
|
195
|
+
|
|
196
|
+
export function RadioWithError() {
|
|
197
|
+
const [value, setValue] = useState("");
|
|
198
|
+
|
|
199
|
+
return (
|
|
200
|
+
<AppRadioGroup
|
|
201
|
+
label="Choose an option"
|
|
202
|
+
required
|
|
203
|
+
options={[
|
|
204
|
+
{ value: "option1", label: "Option 1" },
|
|
205
|
+
{ value: "option2", label: "Option 2" },
|
|
206
|
+
]}
|
|
207
|
+
value={value}
|
|
208
|
+
onValueChange={setValue}
|
|
209
|
+
error={!value ? "Please select an option" : undefined}
|
|
210
|
+
/>
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## Notes
|
|
218
|
+
|
|
219
|
+
- **JSX Labels**: Both `label` and option labels support JSX for custom rendering
|
|
220
|
+
- **Icon Support**: Uses the Icon component from laif-ds (Feather Icons)
|
|
221
|
+
- **Accessibility**: Includes proper ARIA attributes and keyboard navigation
|
|
222
|
+
- **Card Styling**: Card layout includes hover effects and focus states
|
|
223
|
+
- **Disabled Options**: Individual options can be disabled while keeping others enabled
|