@delightui/components 0.1.105 → 0.1.107
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 +104 -1
- package/dist/cjs/components/molecules/Modal/DemoModal.d.ts +8 -0
- package/dist/cjs/components/molecules/Modal/ModalContext/ModalContext.d.ts +41 -0
- package/dist/cjs/components/molecules/Modal/ModalContext/ModalContext.types.d.ts +87 -0
- package/dist/cjs/components/molecules/Modal/ModalContext/index.d.ts +3 -0
- package/dist/cjs/components/molecules/Modal/ModalContext/useModal.d.ts +34 -0
- package/dist/cjs/components/molecules/Modal/index.d.ts +2 -0
- package/dist/cjs/components/molecules/index.d.ts +2 -0
- package/dist/cjs/library.css +19 -6
- package/dist/cjs/library.js +3 -3
- package/dist/cjs/library.js.map +1 -1
- package/dist/esm/components/molecules/Modal/DemoModal.d.ts +8 -0
- package/dist/esm/components/molecules/Modal/ModalContext/ModalContext.d.ts +41 -0
- package/dist/esm/components/molecules/Modal/ModalContext/ModalContext.types.d.ts +87 -0
- package/dist/esm/components/molecules/Modal/ModalContext/index.d.ts +3 -0
- package/dist/esm/components/molecules/Modal/ModalContext/useModal.d.ts +34 -0
- package/dist/esm/components/molecules/Modal/index.d.ts +2 -0
- package/dist/esm/components/molecules/index.d.ts +2 -0
- package/dist/esm/library.css +19 -6
- package/dist/esm/library.js +3 -3
- package/dist/esm/library.js.map +1 -1
- package/dist/index.d.ts +108 -2
- package/docs/README.md +264 -0
- package/docs/components/atoms/ActionImage.md +119 -0
- package/docs/components/atoms/Button.md +197 -0
- package/docs/components/atoms/Checkbox.md +299 -0
- package/docs/components/atoms/CheckboxItem.md +314 -0
- package/docs/components/atoms/Chip.md +380 -0
- package/docs/components/atoms/CustomToggle.md +270 -0
- package/docs/components/atoms/Icon.md +365 -0
- package/docs/components/atoms/IconButton.md +407 -0
- package/docs/components/atoms/Image.md +448 -0
- package/docs/components/atoms/Input.md +430 -0
- package/docs/components/atoms/ListItem.md +502 -0
- package/docs/components/atoms/Password.md +472 -0
- package/docs/components/atoms/RadioButton.md +614 -0
- package/docs/components/atoms/RadioButtonItem.md +588 -0
- package/docs/components/atoms/ResponsiveComponent.md +612 -0
- package/docs/components/atoms/SelectListItem.md +609 -0
- package/docs/components/atoms/Slider.md +605 -0
- package/docs/components/atoms/Spinner.md +605 -0
- package/docs/components/atoms/Text.md +463 -0
- package/docs/components/atoms/TextArea.md +670 -0
- package/docs/components/atoms/ToastNotification.md +668 -0
- package/docs/components/atoms/Toggle.md +737 -0
- package/docs/components/atoms/ToggleButton.md +751 -0
- package/docs/components/atoms/Tooltip.md +391 -0
- package/docs/components/molecules/Accordion.md +440 -0
- package/docs/components/molecules/AccordionGroup.md +547 -0
- package/docs/components/molecules/ActionCard.md +546 -0
- package/docs/components/molecules/Breadcrumb.md +403 -0
- package/docs/components/molecules/Breadcrumbs.md +485 -0
- package/docs/components/molecules/ButtonGroup.md +383 -0
- package/docs/components/molecules/Card.md +298 -0
- package/docs/components/molecules/ChipInput.md +646 -0
- package/docs/components/molecules/ContextMenu.md +768 -0
- package/docs/components/molecules/CustomTimeSelector.md +116 -0
- package/docs/components/molecules/DatePicker.md +516 -0
- package/docs/components/molecules/DateTimeSelector.md +166 -0
- package/docs/components/molecules/FormField.md +312 -0
- package/docs/components/molecules/Grid.md +577 -0
- package/docs/components/molecules/GridItem.md +834 -0
- package/docs/components/molecules/GridList.md +244 -0
- package/docs/components/molecules/List.md +485 -0
- package/docs/components/molecules/Modal.md +470 -0
- package/docs/components/molecules/ModalFooter.md +702 -0
- package/docs/components/molecules/ModalHeader.md +756 -0
- package/docs/components/molecules/ModalProvider.md +205 -0
- package/docs/components/molecules/Nav.md +530 -0
- package/docs/components/molecules/NavItem.md +572 -0
- package/docs/components/molecules/NavLink.md +499 -0
- package/docs/components/molecules/Option.md +521 -0
- package/docs/components/molecules/Pagination.md +592 -0
- package/docs/components/molecules/PaginationNumberField.md +722 -0
- package/docs/components/molecules/Popover.md +516 -0
- package/docs/components/molecules/ProgressBar.md +624 -0
- package/docs/components/molecules/RadioGroup.md +831 -0
- package/docs/components/molecules/RepeaterList.md +185 -0
- package/docs/components/molecules/Select.md +402 -0
- package/docs/components/molecules/SortableTrigger.md +82 -0
- package/docs/components/molecules/useModal.md +379 -0
- package/docs/components/organisms/Dropzone.md +346 -0
- package/docs/components/organisms/DropzoneClear.md +135 -0
- package/docs/components/organisms/DropzoneContent.md +216 -0
- package/docs/components/organisms/DropzoneFilename.md +191 -0
- package/docs/components/organisms/DropzoneSupportedFormats.md +184 -0
- package/docs/components/organisms/DropzoneTrigger.md +209 -0
- package/docs/components/organisms/Form.md +533 -0
- package/docs/components/organisms/SlideOutPanel.md +662 -0
- package/docs/components/organisms/TabContent.md +902 -0
- package/docs/components/organisms/TabItem.md +1091 -0
- package/docs/components/organisms/Table.md +611 -0
- package/docs/components/organisms/TableBody.md +679 -0
- package/docs/components/organisms/TableCell.md +482 -0
- package/docs/components/organisms/TableHeader.md +513 -0
- package/docs/components/organisms/TableHeaderCell.md +661 -0
- package/docs/components/organisms/TableRow.md +715 -0
- package/docs/components/organisms/Tabs.md +1330 -0
- package/docs/components/utils/ConditionalView.md +568 -0
- package/docs/components/utils/RenderStateView.md +726 -0
- package/docs/components/utils/WrapTextNodes.md +614 -0
- package/package.json +3 -2
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
# RadioButtonItem
|
|
2
|
+
|
|
3
|
+
An enhanced radio button component that extends the basic RadioButton with additional action button functionality. It provides all the standard radio button features plus an optional right-side action button, making it perfect for scenarios where you need both selection and additional actions on radio options.
|
|
4
|
+
|
|
5
|
+
## Aliases
|
|
6
|
+
|
|
7
|
+
- RadioButtonItem
|
|
8
|
+
- RadioItem
|
|
9
|
+
- ActionRadioButton
|
|
10
|
+
|
|
11
|
+
## Props Breakdown
|
|
12
|
+
|
|
13
|
+
**Extends:** `RadioButtonProps` (which extends `InputHTMLAttributes<HTMLInputElement>` (excluding `type`, `size`, `value`) and `ControlledFormComponentProps<string | number>`)
|
|
14
|
+
|
|
15
|
+
| Prop | Type | Default | Required | Description |
|
|
16
|
+
|------|------|---------|----------|-------------|
|
|
17
|
+
| `showRightButton` | `boolean` | `false` | No | Flag to show right button |
|
|
18
|
+
| `onRightButtonClick` | `() => void` | `undefined` | No | Callback function when the right button is clicked |
|
|
19
|
+
| `rightButtonIcon` | `ReactNode` | `undefined` | No | Custom icon for the right button |
|
|
20
|
+
| `children` | `ReactNode` | `undefined` | No | The label content of the radio button |
|
|
21
|
+
| `size` | `'Small' \| 'Medium' \| 'Large'` | `'Medium'` | No | The size of the radio button |
|
|
22
|
+
| `labelAlignment` | `'Left' \| 'Right'` | `'Right'` | No | Position of the label relative to the radio button |
|
|
23
|
+
| `initialValue` | `string \| number` | `undefined` | No | The initial value for the field |
|
|
24
|
+
| `checked` | `boolean` | `undefined` | No | Whether the radio button is checked |
|
|
25
|
+
| `value` | `string \| number` | `undefined` | No | The current value of the form field |
|
|
26
|
+
| `onValueChange` | `(value: string \| number) => void` | `undefined` | No | Callback function that is called when the field value changes |
|
|
27
|
+
| `disabled` | `boolean` | `false` | No | Whether the form field is disabled and cannot be interacted with |
|
|
28
|
+
| `required` | `boolean` | `false` | No | Whether the form field must have a value |
|
|
29
|
+
| `invalid` | `boolean` | `false` | No | Whether the form field's current value is invalid |
|
|
30
|
+
| `id` | `string` | `undefined` | No | Id for the form field |
|
|
31
|
+
| `name` | `string` | `undefined` | No | Name attribute for the radio button |
|
|
32
|
+
|
|
33
|
+
Plus all standard HTML input attributes (id, title, aria-*, data-*, etc.).
|
|
34
|
+
|
|
35
|
+
## Examples
|
|
36
|
+
|
|
37
|
+
### Basic RadioButtonItem with Action
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { RadioButtonItem, Icon } from '@delightui/components';
|
|
41
|
+
|
|
42
|
+
function BasicRadioButtonItemExample() {
|
|
43
|
+
const [selectedOption, setSelectedOption] = useState('');
|
|
44
|
+
|
|
45
|
+
const handleEdit = (option: string) => {
|
|
46
|
+
console.log(`Edit clicked for: ${option}`);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
|
|
51
|
+
<RadioButtonItem
|
|
52
|
+
name="basicExample"
|
|
53
|
+
value="option1"
|
|
54
|
+
checked={selectedOption === 'option1'}
|
|
55
|
+
onValueChange={setSelectedOption}
|
|
56
|
+
showRightButton
|
|
57
|
+
rightButtonIcon={<Icon name="InfoFilled" />}
|
|
58
|
+
onRightButtonClick={() => handleEdit('option1')}
|
|
59
|
+
>
|
|
60
|
+
Option 1 with Edit
|
|
61
|
+
</RadioButtonItem>
|
|
62
|
+
|
|
63
|
+
<RadioButtonItem
|
|
64
|
+
name="basicExample"
|
|
65
|
+
value="option2"
|
|
66
|
+
checked={selectedOption === 'option2'}
|
|
67
|
+
onValueChange={setSelectedOption}
|
|
68
|
+
showRightButton
|
|
69
|
+
rightButtonIcon={<Icon name="InfoFilled" />}
|
|
70
|
+
onRightButtonClick={() => handleEdit('option2')}
|
|
71
|
+
>
|
|
72
|
+
Option 2 with Edit
|
|
73
|
+
</RadioButtonItem>
|
|
74
|
+
|
|
75
|
+
<RadioButtonItem
|
|
76
|
+
name="basicExample"
|
|
77
|
+
value="option3"
|
|
78
|
+
checked={selectedOption === 'option3'}
|
|
79
|
+
onValueChange={setSelectedOption}
|
|
80
|
+
>
|
|
81
|
+
Option 3 without Action
|
|
82
|
+
</RadioButtonItem>
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Payment Methods with Management
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
import { RadioButtonItem, Icon, Text } from '@delightui/components';
|
|
92
|
+
|
|
93
|
+
function PaymentMethodsExample() {
|
|
94
|
+
const [selectedPayment, setSelectedPayment] = useState('');
|
|
95
|
+
const [paymentMethods] = useState([
|
|
96
|
+
{ id: 'card1', name: 'Visa ending in 4532', details: 'Expires 12/25' },
|
|
97
|
+
{ id: 'card2', name: 'Mastercard ending in 9876', details: 'Expires 08/26' },
|
|
98
|
+
{ id: 'paypal', name: 'PayPal', details: 'user@example.com' }
|
|
99
|
+
]);
|
|
100
|
+
|
|
101
|
+
const handleEditPayment = (id: string) => {
|
|
102
|
+
console.log(`Edit payment method: ${id}`);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const handleDeletePayment = (id: string) => {
|
|
106
|
+
console.log(`Delete payment method: ${id}`);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<div>
|
|
111
|
+
<Text weight="bold" style={{ marginBottom: '16px' }}>
|
|
112
|
+
Select Payment Method
|
|
113
|
+
</Text>
|
|
114
|
+
|
|
115
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
|
|
116
|
+
{paymentMethods.map((method) => (
|
|
117
|
+
<RadioButtonItem
|
|
118
|
+
key={method.id}
|
|
119
|
+
name="paymentMethod"
|
|
120
|
+
value={method.id}
|
|
121
|
+
checked={selectedPayment === method.id}
|
|
122
|
+
onValueChange={setSelectedPayment}
|
|
123
|
+
showRightButton
|
|
124
|
+
rightButtonIcon={<Icon name="InfoFilled" />}
|
|
125
|
+
onRightButtonClick={() => handleEditPayment(method.id)}
|
|
126
|
+
>
|
|
127
|
+
<div>
|
|
128
|
+
<div>{method.name}</div>
|
|
129
|
+
<Text size="small" color="secondary">
|
|
130
|
+
{method.details}
|
|
131
|
+
</Text>
|
|
132
|
+
</div>
|
|
133
|
+
</RadioButtonItem>
|
|
134
|
+
))}
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Address Selection with Edit Options
|
|
142
|
+
|
|
143
|
+
```tsx
|
|
144
|
+
import { RadioButtonItem, Icon, Text } from '@delightui/components';
|
|
145
|
+
|
|
146
|
+
function AddressSelectionExample() {
|
|
147
|
+
const [selectedAddress, setSelectedAddress] = useState('');
|
|
148
|
+
const [addresses] = useState([
|
|
149
|
+
{
|
|
150
|
+
id: 'home',
|
|
151
|
+
label: 'Home',
|
|
152
|
+
address: '123 Main St, Anytown, ST 12345',
|
|
153
|
+
type: 'Residential'
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
id: 'work',
|
|
157
|
+
label: 'Work',
|
|
158
|
+
address: '456 Business Ave, Corporate City, ST 67890',
|
|
159
|
+
type: 'Business'
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
id: 'other',
|
|
163
|
+
label: 'Other',
|
|
164
|
+
address: '789 Alternative Rd, Different Town, ST 54321',
|
|
165
|
+
type: 'Residential'
|
|
166
|
+
}
|
|
167
|
+
]);
|
|
168
|
+
|
|
169
|
+
const handleEditAddress = (id: string) => {
|
|
170
|
+
console.log(`Edit address: ${id}`);
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
return (
|
|
174
|
+
<div>
|
|
175
|
+
<Text weight="bold" style={{ marginBottom: '16px' }}>
|
|
176
|
+
Delivery Address
|
|
177
|
+
</Text>
|
|
178
|
+
|
|
179
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
|
|
180
|
+
{addresses.map((addr) => (
|
|
181
|
+
<RadioButtonItem
|
|
182
|
+
key={addr.id}
|
|
183
|
+
name="deliveryAddress"
|
|
184
|
+
value={addr.id}
|
|
185
|
+
checked={selectedAddress === addr.id}
|
|
186
|
+
onValueChange={setSelectedAddress}
|
|
187
|
+
showRightButton
|
|
188
|
+
rightButtonIcon={<Icon name="InfoFilled" />}
|
|
189
|
+
onRightButtonClick={() => handleEditAddress(addr.id)}
|
|
190
|
+
size="Large"
|
|
191
|
+
>
|
|
192
|
+
<div>
|
|
193
|
+
<Text weight="bold">{addr.label}</Text>
|
|
194
|
+
<Text size="small" color="secondary" style={{ display: 'block', marginTop: '4px' }}>
|
|
195
|
+
{addr.address}
|
|
196
|
+
</Text>
|
|
197
|
+
<Text size="small" color="primary" style={{ display: 'block', marginTop: '2px' }}>
|
|
198
|
+
{addr.type}
|
|
199
|
+
</Text>
|
|
200
|
+
</div>
|
|
201
|
+
</RadioButtonItem>
|
|
202
|
+
))}
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Product Variants with Details
|
|
210
|
+
|
|
211
|
+
```tsx
|
|
212
|
+
import { RadioButtonItem, Icon, Text } from '@delightui/components';
|
|
213
|
+
|
|
214
|
+
function ProductVariantsExample() {
|
|
215
|
+
const [selectedVariant, setSelectedVariant] = useState('');
|
|
216
|
+
const [variants] = useState([
|
|
217
|
+
{
|
|
218
|
+
id: 'small',
|
|
219
|
+
name: 'Small',
|
|
220
|
+
price: '$19.99',
|
|
221
|
+
stock: 15,
|
|
222
|
+
description: 'Perfect for personal use'
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
id: 'medium',
|
|
226
|
+
name: 'Medium',
|
|
227
|
+
price: '$29.99',
|
|
228
|
+
stock: 8,
|
|
229
|
+
description: 'Great for small teams'
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
id: 'large',
|
|
233
|
+
name: 'Large',
|
|
234
|
+
price: '$39.99',
|
|
235
|
+
stock: 3,
|
|
236
|
+
description: 'Ideal for larger groups'
|
|
237
|
+
}
|
|
238
|
+
]);
|
|
239
|
+
|
|
240
|
+
const handleViewDetails = (id: string) => {
|
|
241
|
+
console.log(`View details for variant: ${id}`);
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
return (
|
|
245
|
+
<div>
|
|
246
|
+
<Text weight="bold" style={{ marginBottom: '16px' }}>
|
|
247
|
+
Choose Your Size
|
|
248
|
+
</Text>
|
|
249
|
+
|
|
250
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
|
|
251
|
+
{variants.map((variant) => (
|
|
252
|
+
<RadioButtonItem
|
|
253
|
+
key={variant.id}
|
|
254
|
+
name="productVariant"
|
|
255
|
+
value={variant.id}
|
|
256
|
+
checked={selectedVariant === variant.id}
|
|
257
|
+
onValueChange={setSelectedVariant}
|
|
258
|
+
showRightButton
|
|
259
|
+
rightButtonIcon={<Icon name="InfoFilled" />}
|
|
260
|
+
onRightButtonClick={() => handleViewDetails(variant.id)}
|
|
261
|
+
disabled={variant.stock === 0}
|
|
262
|
+
>
|
|
263
|
+
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', width: '100%' }}>
|
|
264
|
+
<div>
|
|
265
|
+
<Text weight="bold">{variant.name}</Text>
|
|
266
|
+
<Text size="small" color="secondary" style={{ display: 'block' }}>
|
|
267
|
+
{variant.description}
|
|
268
|
+
</Text>
|
|
269
|
+
<Text size="small" color={variant.stock > 0 ? 'success' : 'error'}>
|
|
270
|
+
{variant.stock > 0 ? `${variant.stock} in stock` : 'Out of stock'}
|
|
271
|
+
</Text>
|
|
272
|
+
</div>
|
|
273
|
+
<Text weight="bold" color="primary">
|
|
274
|
+
{variant.price}
|
|
275
|
+
</Text>
|
|
276
|
+
</div>
|
|
277
|
+
</RadioButtonItem>
|
|
278
|
+
))}
|
|
279
|
+
</div>
|
|
280
|
+
</div>
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Settings with Configuration
|
|
286
|
+
|
|
287
|
+
```tsx
|
|
288
|
+
import { RadioButtonItem, Icon, Text } from '@delightui/components';
|
|
289
|
+
|
|
290
|
+
function SettingsConfigurationExample() {
|
|
291
|
+
const [selectedTheme, setSelectedTheme] = useState('light');
|
|
292
|
+
const [themes] = useState([
|
|
293
|
+
{
|
|
294
|
+
id: 'light',
|
|
295
|
+
name: 'Light Theme',
|
|
296
|
+
description: 'Clean and bright interface',
|
|
297
|
+
customizable: true
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
id: 'dark',
|
|
301
|
+
name: 'Dark Theme',
|
|
302
|
+
description: 'Easy on the eyes for low light',
|
|
303
|
+
customizable: true
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
id: 'auto',
|
|
307
|
+
name: 'Auto Theme',
|
|
308
|
+
description: 'Follows system preference',
|
|
309
|
+
customizable: false
|
|
310
|
+
}
|
|
311
|
+
]);
|
|
312
|
+
|
|
313
|
+
const handleCustomizeTheme = (id: string) => {
|
|
314
|
+
console.log(`Customize theme: ${id}`);
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
return (
|
|
318
|
+
<div>
|
|
319
|
+
<Text weight="bold" style={{ marginBottom: '16px' }}>
|
|
320
|
+
Theme Settings
|
|
321
|
+
</Text>
|
|
322
|
+
|
|
323
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
|
|
324
|
+
{themes.map((theme) => (
|
|
325
|
+
<RadioButtonItem
|
|
326
|
+
key={theme.id}
|
|
327
|
+
name="theme"
|
|
328
|
+
value={theme.id}
|
|
329
|
+
checked={selectedTheme === theme.id}
|
|
330
|
+
onValueChange={setSelectedTheme}
|
|
331
|
+
showRightButton={theme.customizable}
|
|
332
|
+
rightButtonIcon={<Icon name="InfoFilled" />}
|
|
333
|
+
onRightButtonClick={theme.customizable ? () => handleCustomizeTheme(theme.id) : undefined}
|
|
334
|
+
>
|
|
335
|
+
<div>
|
|
336
|
+
<Text weight="bold">{theme.name}</Text>
|
|
337
|
+
<Text size="small" color="secondary" style={{ display: 'block', marginTop: '4px' }}>
|
|
338
|
+
{theme.description}
|
|
339
|
+
</Text>
|
|
340
|
+
{theme.customizable && (
|
|
341
|
+
<Text size="small" color="primary" style={{ display: 'block', marginTop: '2px' }}>
|
|
342
|
+
Customizable
|
|
343
|
+
</Text>
|
|
344
|
+
)}
|
|
345
|
+
</div>
|
|
346
|
+
</RadioButtonItem>
|
|
347
|
+
))}
|
|
348
|
+
</div>
|
|
349
|
+
</div>
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### Subscription Plans with Details
|
|
355
|
+
|
|
356
|
+
```tsx
|
|
357
|
+
import { RadioButtonItem, Icon, Text, Button } from '@delightui/components';
|
|
358
|
+
|
|
359
|
+
function SubscriptionPlansExample() {
|
|
360
|
+
const [selectedPlan, setSelectedPlan] = useState('');
|
|
361
|
+
const [plans] = useState([
|
|
362
|
+
{
|
|
363
|
+
id: 'basic',
|
|
364
|
+
name: 'Basic Plan',
|
|
365
|
+
price: '$9.99/month',
|
|
366
|
+
features: ['5 GB Storage', '10 Projects', 'Email Support'],
|
|
367
|
+
popular: false
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
id: 'pro',
|
|
371
|
+
name: 'Pro Plan',
|
|
372
|
+
price: '$19.99/month',
|
|
373
|
+
features: ['50 GB Storage', 'Unlimited Projects', 'Priority Support', 'Advanced Analytics'],
|
|
374
|
+
popular: true
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
id: 'enterprise',
|
|
378
|
+
name: 'Enterprise Plan',
|
|
379
|
+
price: '$49.99/month',
|
|
380
|
+
features: ['500 GB Storage', 'Unlimited Everything', '24/7 Phone Support', 'Custom Integrations'],
|
|
381
|
+
popular: false
|
|
382
|
+
}
|
|
383
|
+
]);
|
|
384
|
+
|
|
385
|
+
const handleViewPlanDetails = (id: string) => {
|
|
386
|
+
console.log(`View details for plan: ${id}`);
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
return (
|
|
390
|
+
<div>
|
|
391
|
+
<Text weight="bold" style={{ marginBottom: '16px' }}>
|
|
392
|
+
Choose Your Plan
|
|
393
|
+
</Text>
|
|
394
|
+
|
|
395
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
|
|
396
|
+
{plans.map((plan) => (
|
|
397
|
+
<div
|
|
398
|
+
key={plan.id}
|
|
399
|
+
style={{
|
|
400
|
+
border: selectedPlan === plan.id ? '2px solid #007bff' : '1px solid #ccc',
|
|
401
|
+
borderRadius: '8px',
|
|
402
|
+
padding: '16px',
|
|
403
|
+
position: 'relative'
|
|
404
|
+
}}
|
|
405
|
+
>
|
|
406
|
+
{plan.popular && (
|
|
407
|
+
<div style={{
|
|
408
|
+
position: 'absolute',
|
|
409
|
+
top: '-8px',
|
|
410
|
+
right: '16px',
|
|
411
|
+
backgroundColor: '#007bff',
|
|
412
|
+
color: 'white',
|
|
413
|
+
padding: '4px 8px',
|
|
414
|
+
borderRadius: '4px',
|
|
415
|
+
fontSize: '12px',
|
|
416
|
+
fontWeight: 'bold'
|
|
417
|
+
}}>
|
|
418
|
+
POPULAR
|
|
419
|
+
</div>
|
|
420
|
+
)}
|
|
421
|
+
|
|
422
|
+
<RadioButtonItem
|
|
423
|
+
name="subscriptionPlan"
|
|
424
|
+
value={plan.id}
|
|
425
|
+
checked={selectedPlan === plan.id}
|
|
426
|
+
onValueChange={setSelectedPlan}
|
|
427
|
+
showRightButton
|
|
428
|
+
rightButtonIcon={<Icon name="InfoFilled" />}
|
|
429
|
+
onRightButtonClick={() => handleViewPlanDetails(plan.id)}
|
|
430
|
+
size="Large"
|
|
431
|
+
>
|
|
432
|
+
<div style={{ width: '100%' }}>
|
|
433
|
+
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '8px' }}>
|
|
434
|
+
<Text weight="bold" size="large">{plan.name}</Text>
|
|
435
|
+
<Text weight="bold" color="primary" size="large">{plan.price}</Text>
|
|
436
|
+
</div>
|
|
437
|
+
|
|
438
|
+
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '8px' }}>
|
|
439
|
+
{plan.features.map((feature, index) => (
|
|
440
|
+
<Text key={index} size="small" color="secondary">
|
|
441
|
+
• {feature}
|
|
442
|
+
</Text>
|
|
443
|
+
))}
|
|
444
|
+
</div>
|
|
445
|
+
</div>
|
|
446
|
+
</RadioButtonItem>
|
|
447
|
+
</div>
|
|
448
|
+
))}
|
|
449
|
+
</div>
|
|
450
|
+
|
|
451
|
+
{selectedPlan && (
|
|
452
|
+
<Button style={{ width: '100%', marginTop: '20px' }}>
|
|
453
|
+
Continue with {plans.find(p => p.id === selectedPlan)?.name}
|
|
454
|
+
</Button>
|
|
455
|
+
)}
|
|
456
|
+
</div>
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
### File Selection with Actions
|
|
462
|
+
|
|
463
|
+
```tsx
|
|
464
|
+
import { RadioButtonItem, Icon, Text } from '@delightui/components';
|
|
465
|
+
|
|
466
|
+
function FileSelectionExample() {
|
|
467
|
+
const [selectedFile, setSelectedFile] = useState('');
|
|
468
|
+
const [files] = useState([
|
|
469
|
+
{
|
|
470
|
+
id: 'doc1',
|
|
471
|
+
name: 'Project Proposal.docx',
|
|
472
|
+
size: '2.4 MB',
|
|
473
|
+
modified: '2 hours ago',
|
|
474
|
+
type: 'document'
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
id: 'img1',
|
|
478
|
+
name: 'Design Mockup.png',
|
|
479
|
+
size: '1.8 MB',
|
|
480
|
+
modified: '1 day ago',
|
|
481
|
+
type: 'image'
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
id: 'pdf1',
|
|
485
|
+
name: 'Final Report.pdf',
|
|
486
|
+
size: '5.2 MB',
|
|
487
|
+
modified: '3 days ago',
|
|
488
|
+
type: 'pdf'
|
|
489
|
+
}
|
|
490
|
+
]);
|
|
491
|
+
|
|
492
|
+
const handleDownloadFile = (id: string) => {
|
|
493
|
+
console.log(`Download file: ${id}`);
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
const getFileIcon = (type: string) => {
|
|
497
|
+
switch (type) {
|
|
498
|
+
case 'document': return 'AddFilled';
|
|
499
|
+
case 'image': return 'SearchFilled';
|
|
500
|
+
case 'pdf': return 'InfoFilled';
|
|
501
|
+
default: return 'AddFilled';
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
return (
|
|
506
|
+
<div>
|
|
507
|
+
<Text weight="bold" style={{ marginBottom: '16px' }}>
|
|
508
|
+
Select File to Process
|
|
509
|
+
</Text>
|
|
510
|
+
|
|
511
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
|
|
512
|
+
{files.map((file) => (
|
|
513
|
+
<RadioButtonItem
|
|
514
|
+
key={file.id}
|
|
515
|
+
name="selectedFile"
|
|
516
|
+
value={file.id}
|
|
517
|
+
checked={selectedFile === file.id}
|
|
518
|
+
onValueChange={setSelectedFile}
|
|
519
|
+
showRightButton
|
|
520
|
+
rightButtonIcon={<Icon name="AddFilled" />}
|
|
521
|
+
onRightButtonClick={() => handleDownloadFile(file.id)}
|
|
522
|
+
>
|
|
523
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: '12px' }}>
|
|
524
|
+
<Icon name={getFileIcon(file.type)} />
|
|
525
|
+
<div>
|
|
526
|
+
<Text weight="bold">{file.name}</Text>
|
|
527
|
+
<Text size="small" color="secondary" style={{ display: 'block' }}>
|
|
528
|
+
{file.size} • Modified {file.modified}
|
|
529
|
+
</Text>
|
|
530
|
+
</div>
|
|
531
|
+
</div>
|
|
532
|
+
</RadioButtonItem>
|
|
533
|
+
))}
|
|
534
|
+
</div>
|
|
535
|
+
</div>
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
### Different Action Icons
|
|
541
|
+
|
|
542
|
+
```tsx
|
|
543
|
+
import { RadioButtonItem, Icon } from '@delightui/components';
|
|
544
|
+
|
|
545
|
+
function DifferentActionIconsExample() {
|
|
546
|
+
const [selectedOption, setSelectedOption] = useState('');
|
|
547
|
+
|
|
548
|
+
return (
|
|
549
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
|
|
550
|
+
<RadioButtonItem
|
|
551
|
+
name="actionIcons"
|
|
552
|
+
value="edit"
|
|
553
|
+
checked={selectedOption === 'edit'}
|
|
554
|
+
onValueChange={setSelectedOption}
|
|
555
|
+
showRightButton
|
|
556
|
+
rightButtonIcon={<Icon name="InfoFilled" />}
|
|
557
|
+
onRightButtonClick={() => console.log('Edit action')}
|
|
558
|
+
>
|
|
559
|
+
Option with Edit Action
|
|
560
|
+
</RadioButtonItem>
|
|
561
|
+
|
|
562
|
+
<RadioButtonItem
|
|
563
|
+
name="actionIcons"
|
|
564
|
+
value="info"
|
|
565
|
+
checked={selectedOption === 'info'}
|
|
566
|
+
onValueChange={setSelectedOption}
|
|
567
|
+
showRightButton
|
|
568
|
+
rightButtonIcon={<Icon name="InfoFilled" />}
|
|
569
|
+
onRightButtonClick={() => console.log('Info action')}
|
|
570
|
+
>
|
|
571
|
+
Option with Info Action
|
|
572
|
+
</RadioButtonItem>
|
|
573
|
+
|
|
574
|
+
<RadioButtonItem
|
|
575
|
+
name="actionIcons"
|
|
576
|
+
value="delete"
|
|
577
|
+
checked={selectedOption === 'delete'}
|
|
578
|
+
onValueChange={setSelectedOption}
|
|
579
|
+
showRightButton
|
|
580
|
+
rightButtonIcon={<Icon name="CloseDeleteOutlined" />}
|
|
581
|
+
onRightButtonClick={() => console.log('Delete action')}
|
|
582
|
+
>
|
|
583
|
+
Option with Delete Action
|
|
584
|
+
</RadioButtonItem>
|
|
585
|
+
</div>
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
```
|