@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,609 @@
|
|
|
1
|
+
# SelectListItem
|
|
2
|
+
|
|
3
|
+
A specialized list item component designed specifically for use within select dropdowns and option lists. It provides a consistent interface for selectable options with support for icons, disabled states, and click interactions. This component is optimized for use within select components and dropdown menus.
|
|
4
|
+
|
|
5
|
+
## Aliases
|
|
6
|
+
|
|
7
|
+
- SelectListItem
|
|
8
|
+
- SelectOption
|
|
9
|
+
- DropdownItem
|
|
10
|
+
|
|
11
|
+
## Props Breakdown
|
|
12
|
+
|
|
13
|
+
**Extends:** `HTMLAttributes<HTMLDivElement>` (excluding `style`)
|
|
14
|
+
|
|
15
|
+
| Prop | Type | Default | Required | Description |
|
|
16
|
+
|------|------|---------|----------|-------------|
|
|
17
|
+
| `leadingIcon` | `ReactNode` | `undefined` | No | Icon to be displayed before the content |
|
|
18
|
+
| `trailingIcon` | `ReactNode` | `undefined` | No | Icon to be displayed after the content |
|
|
19
|
+
| `disabled` | `boolean` | `false` | No | Whether the list item is disabled |
|
|
20
|
+
| `onClick` | `(event?: MouseEvent<HTMLElement>) => void` | `undefined` | No | Click event handler for the list item |
|
|
21
|
+
| `children` | `ReactNode` | `undefined` | No | The content of the list item |
|
|
22
|
+
| `className` | `string` | `undefined` | No | Additional class for styling |
|
|
23
|
+
|
|
24
|
+
Plus all standard HTML div attributes (id, title, aria-*, data-*, etc.).
|
|
25
|
+
|
|
26
|
+
## Examples
|
|
27
|
+
|
|
28
|
+
### Basic Select List Items
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { SelectListItem } from '@delightui/components';
|
|
32
|
+
|
|
33
|
+
function BasicSelectListExample() {
|
|
34
|
+
const [selectedOption, setSelectedOption] = useState('');
|
|
35
|
+
|
|
36
|
+
const options = ['Option 1', 'Option 2', 'Option 3'];
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div style={{
|
|
40
|
+
border: '1px solid #ccc',
|
|
41
|
+
borderRadius: '4px',
|
|
42
|
+
maxWidth: '200px'
|
|
43
|
+
}}>
|
|
44
|
+
{options.map((option, index) => (
|
|
45
|
+
<SelectListItem
|
|
46
|
+
key={index}
|
|
47
|
+
onClick={() => setSelectedOption(option)}
|
|
48
|
+
className={selectedOption === option ? 'selected' : ''}
|
|
49
|
+
>
|
|
50
|
+
{option}
|
|
51
|
+
</SelectListItem>
|
|
52
|
+
))}
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Select List with Icons
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
import { SelectListItem, Icon } from '@delightui/components';
|
|
62
|
+
|
|
63
|
+
function IconSelectListExample() {
|
|
64
|
+
const [selectedOption, setSelectedOption] = useState('');
|
|
65
|
+
|
|
66
|
+
const options = [
|
|
67
|
+
{ value: 'home', label: 'Home', icon: 'AddFilled' },
|
|
68
|
+
{ value: 'profile', label: 'Profile', icon: 'SearchFilled' },
|
|
69
|
+
{ value: 'settings', label: 'Settings', icon: 'InfoFilled' },
|
|
70
|
+
{ value: 'help', label: 'Help', icon: 'ErrorOutlined' }
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<div style={{
|
|
75
|
+
border: '1px solid #ccc',
|
|
76
|
+
borderRadius: '4px',
|
|
77
|
+
maxWidth: '250px'
|
|
78
|
+
}}>
|
|
79
|
+
{options.map((option) => (
|
|
80
|
+
<SelectListItem
|
|
81
|
+
key={option.value}
|
|
82
|
+
leadingIcon={<Icon name={option.icon} />}
|
|
83
|
+
trailingIcon={selectedOption === option.value ? <Icon name="CheckFilled" /> : undefined}
|
|
84
|
+
onClick={() => setSelectedOption(option.value)}
|
|
85
|
+
className={selectedOption === option.value ? 'selected' : ''}
|
|
86
|
+
>
|
|
87
|
+
{option.label}
|
|
88
|
+
</SelectListItem>
|
|
89
|
+
))}
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Country Selector
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
import { SelectListItem, Text } from '@delightui/components';
|
|
99
|
+
|
|
100
|
+
function CountrySelectorExample() {
|
|
101
|
+
const [selectedCountry, setSelectedCountry] = useState('');
|
|
102
|
+
|
|
103
|
+
const countries = [
|
|
104
|
+
{ code: 'US', name: 'United States', flag: '🇺🇸' },
|
|
105
|
+
{ code: 'CA', name: 'Canada', flag: '🇨🇦' },
|
|
106
|
+
{ code: 'UK', name: 'United Kingdom', flag: '🇬🇧' },
|
|
107
|
+
{ code: 'DE', name: 'Germany', flag: '🇩🇪' },
|
|
108
|
+
{ code: 'FR', name: 'France', flag: '🇫🇷' },
|
|
109
|
+
{ code: 'JP', name: 'Japan', flag: '🇯🇵' }
|
|
110
|
+
];
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<div style={{
|
|
114
|
+
border: '1px solid #ccc',
|
|
115
|
+
borderRadius: '4px',
|
|
116
|
+
maxWidth: '300px',
|
|
117
|
+
maxHeight: '200px',
|
|
118
|
+
overflowY: 'auto'
|
|
119
|
+
}}>
|
|
120
|
+
{countries.map((country) => (
|
|
121
|
+
<SelectListItem
|
|
122
|
+
key={country.code}
|
|
123
|
+
leadingIcon={<span style={{ fontSize: '18px' }}>{country.flag}</span>}
|
|
124
|
+
onClick={() => setSelectedCountry(country.code)}
|
|
125
|
+
className={selectedCountry === country.code ? 'selected' : ''}
|
|
126
|
+
>
|
|
127
|
+
<div>
|
|
128
|
+
<Text weight="medium">{country.name}</Text>
|
|
129
|
+
<Text size="small" color="secondary" style={{ display: 'block' }}>
|
|
130
|
+
{country.code}
|
|
131
|
+
</Text>
|
|
132
|
+
</div>
|
|
133
|
+
</SelectListItem>
|
|
134
|
+
))}
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### User Selection List
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
import { SelectListItem, Text } from '@delightui/components';
|
|
144
|
+
|
|
145
|
+
function UserSelectionExample() {
|
|
146
|
+
const [selectedUser, setSelectedUser] = useState('');
|
|
147
|
+
|
|
148
|
+
const users = [
|
|
149
|
+
{ id: '1', name: 'John Doe', email: 'john@example.com', role: 'Admin' },
|
|
150
|
+
{ id: '2', name: 'Jane Smith', email: 'jane@example.com', role: 'Editor' },
|
|
151
|
+
{ id: '3', name: 'Bob Johnson', email: 'bob@example.com', role: 'Viewer' },
|
|
152
|
+
{ id: '4', name: 'Alice Brown', email: 'alice@example.com', role: 'Editor' }
|
|
153
|
+
];
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<div style={{
|
|
157
|
+
border: '1px solid #ccc',
|
|
158
|
+
borderRadius: '4px',
|
|
159
|
+
maxWidth: '350px'
|
|
160
|
+
}}>
|
|
161
|
+
{users.map((user) => (
|
|
162
|
+
<SelectListItem
|
|
163
|
+
key={user.id}
|
|
164
|
+
leadingIcon={
|
|
165
|
+
<div style={{
|
|
166
|
+
width: '32px',
|
|
167
|
+
height: '32px',
|
|
168
|
+
borderRadius: '50%',
|
|
169
|
+
backgroundColor: '#007bff',
|
|
170
|
+
display: 'flex',
|
|
171
|
+
alignItems: 'center',
|
|
172
|
+
justifyContent: 'center',
|
|
173
|
+
color: 'white',
|
|
174
|
+
fontSize: '12px',
|
|
175
|
+
fontWeight: 'bold'
|
|
176
|
+
}}>
|
|
177
|
+
{user.name.split(' ').map(n => n[0]).join('')}
|
|
178
|
+
</div>
|
|
179
|
+
}
|
|
180
|
+
onClick={() => setSelectedUser(user.id)}
|
|
181
|
+
className={selectedUser === user.id ? 'selected' : ''}
|
|
182
|
+
>
|
|
183
|
+
<div>
|
|
184
|
+
<Text weight="medium">{user.name}</Text>
|
|
185
|
+
<Text size="small" color="secondary" style={{ display: 'block' }}>
|
|
186
|
+
{user.email}
|
|
187
|
+
</Text>
|
|
188
|
+
<Text size="small" color="primary" style={{ display: 'block' }}>
|
|
189
|
+
{user.role}
|
|
190
|
+
</Text>
|
|
191
|
+
</div>
|
|
192
|
+
</SelectListItem>
|
|
193
|
+
))}
|
|
194
|
+
</div>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Priority Selection
|
|
200
|
+
|
|
201
|
+
```tsx
|
|
202
|
+
import { SelectListItem, Icon, Text } from '@delightui/components';
|
|
203
|
+
|
|
204
|
+
function PrioritySelectionExample() {
|
|
205
|
+
const [selectedPriority, setSelectedPriority] = useState('');
|
|
206
|
+
|
|
207
|
+
const priorities = [
|
|
208
|
+
{
|
|
209
|
+
value: 'low',
|
|
210
|
+
label: 'Low Priority',
|
|
211
|
+
color: '#28a745',
|
|
212
|
+
icon: 'InfoFilled',
|
|
213
|
+
description: 'Not urgent, can be done later'
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
value: 'medium',
|
|
217
|
+
label: 'Medium Priority',
|
|
218
|
+
color: '#ffc107',
|
|
219
|
+
icon: 'InfoFilled',
|
|
220
|
+
description: 'Should be completed soon'
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
value: 'high',
|
|
224
|
+
label: 'High Priority',
|
|
225
|
+
color: '#fd7e14',
|
|
226
|
+
icon: 'ErrorOutlined',
|
|
227
|
+
description: 'Important, needs attention'
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
value: 'urgent',
|
|
231
|
+
label: 'Urgent',
|
|
232
|
+
color: '#dc3545',
|
|
233
|
+
icon: 'ErrorOutlined',
|
|
234
|
+
description: 'Critical, immediate action required'
|
|
235
|
+
}
|
|
236
|
+
];
|
|
237
|
+
|
|
238
|
+
return (
|
|
239
|
+
<div style={{
|
|
240
|
+
border: '1px solid #ccc',
|
|
241
|
+
borderRadius: '4px',
|
|
242
|
+
maxWidth: '300px'
|
|
243
|
+
}}>
|
|
244
|
+
{priorities.map((priority) => (
|
|
245
|
+
<SelectListItem
|
|
246
|
+
key={priority.value}
|
|
247
|
+
leadingIcon={
|
|
248
|
+
<Icon
|
|
249
|
+
name={priority.icon}
|
|
250
|
+
style={{ color: priority.color }}
|
|
251
|
+
/>
|
|
252
|
+
}
|
|
253
|
+
trailingIcon={
|
|
254
|
+
selectedPriority === priority.value ?
|
|
255
|
+
<Icon name="CheckFilled" style={{ color: '#28a745' }} /> :
|
|
256
|
+
undefined
|
|
257
|
+
}
|
|
258
|
+
onClick={() => setSelectedPriority(priority.value)}
|
|
259
|
+
className={selectedPriority === priority.value ? 'selected' : ''}
|
|
260
|
+
>
|
|
261
|
+
<div>
|
|
262
|
+
<Text weight="medium" style={{ color: priority.color }}>
|
|
263
|
+
{priority.label}
|
|
264
|
+
</Text>
|
|
265
|
+
<Text size="small" color="secondary" style={{ display: 'block' }}>
|
|
266
|
+
{priority.description}
|
|
267
|
+
</Text>
|
|
268
|
+
</div>
|
|
269
|
+
</SelectListItem>
|
|
270
|
+
))}
|
|
271
|
+
</div>
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### File Type Selection
|
|
277
|
+
|
|
278
|
+
```tsx
|
|
279
|
+
import { SelectListItem, Icon, Text } from '@delightui/components';
|
|
280
|
+
|
|
281
|
+
function FileTypeSelectionExample() {
|
|
282
|
+
const [selectedFileType, setSelectedFileType] = useState('');
|
|
283
|
+
|
|
284
|
+
const fileTypes = [
|
|
285
|
+
{
|
|
286
|
+
type: 'pdf',
|
|
287
|
+
label: 'PDF Document',
|
|
288
|
+
extension: '.pdf',
|
|
289
|
+
icon: 'AddFilled',
|
|
290
|
+
description: 'Portable Document Format'
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
type: 'doc',
|
|
294
|
+
label: 'Word Document',
|
|
295
|
+
extension: '.docx',
|
|
296
|
+
icon: 'AddFilled',
|
|
297
|
+
description: 'Microsoft Word Document'
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
type: 'excel',
|
|
301
|
+
label: 'Excel Spreadsheet',
|
|
302
|
+
extension: '.xlsx',
|
|
303
|
+
icon: 'AddFilled',
|
|
304
|
+
description: 'Microsoft Excel Spreadsheet'
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
type: 'image',
|
|
308
|
+
label: 'Image File',
|
|
309
|
+
extension: '.jpg, .png',
|
|
310
|
+
icon: 'SearchFilled',
|
|
311
|
+
description: 'JPEG or PNG Image'
|
|
312
|
+
}
|
|
313
|
+
];
|
|
314
|
+
|
|
315
|
+
return (
|
|
316
|
+
<div style={{
|
|
317
|
+
border: '1px solid #ccc',
|
|
318
|
+
borderRadius: '4px',
|
|
319
|
+
maxWidth: '350px'
|
|
320
|
+
}}>
|
|
321
|
+
{fileTypes.map((fileType) => (
|
|
322
|
+
<SelectListItem
|
|
323
|
+
key={fileType.type}
|
|
324
|
+
leadingIcon={<Icon name={fileType.icon} />}
|
|
325
|
+
onClick={() => setSelectedFileType(fileType.type)}
|
|
326
|
+
className={selectedFileType === fileType.type ? 'selected' : ''}
|
|
327
|
+
>
|
|
328
|
+
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', width: '100%' }}>
|
|
329
|
+
<div>
|
|
330
|
+
<Text weight="medium">{fileType.label}</Text>
|
|
331
|
+
<Text size="small" color="secondary" style={{ display: 'block' }}>
|
|
332
|
+
{fileType.description}
|
|
333
|
+
</Text>
|
|
334
|
+
</div>
|
|
335
|
+
<Text size="small" color="primary" weight="medium">
|
|
336
|
+
{fileType.extension}
|
|
337
|
+
</Text>
|
|
338
|
+
</div>
|
|
339
|
+
</SelectListItem>
|
|
340
|
+
))}
|
|
341
|
+
</div>
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Disabled Options
|
|
347
|
+
|
|
348
|
+
```tsx
|
|
349
|
+
import { SelectListItem, Icon, Text } from '@delightui/components';
|
|
350
|
+
|
|
351
|
+
function DisabledOptionsExample() {
|
|
352
|
+
const [selectedOption, setSelectedOption] = useState('');
|
|
353
|
+
|
|
354
|
+
const options = [
|
|
355
|
+
{ value: 'option1', label: 'Available Option 1', disabled: false },
|
|
356
|
+
{ value: 'option2', label: 'Available Option 2', disabled: false },
|
|
357
|
+
{ value: 'option3', label: 'Disabled Option 3', disabled: true },
|
|
358
|
+
{ value: 'option4', label: 'Available Option 4', disabled: false },
|
|
359
|
+
{ value: 'option5', label: 'Disabled Option 5', disabled: true }
|
|
360
|
+
];
|
|
361
|
+
|
|
362
|
+
return (
|
|
363
|
+
<div style={{
|
|
364
|
+
border: '1px solid #ccc',
|
|
365
|
+
borderRadius: '4px',
|
|
366
|
+
maxWidth: '250px'
|
|
367
|
+
}}>
|
|
368
|
+
{options.map((option) => (
|
|
369
|
+
<SelectListItem
|
|
370
|
+
key={option.value}
|
|
371
|
+
disabled={option.disabled}
|
|
372
|
+
onClick={option.disabled ? undefined : () => setSelectedOption(option.value)}
|
|
373
|
+
className={selectedOption === option.value ? 'selected' : ''}
|
|
374
|
+
trailingIcon={
|
|
375
|
+
option.disabled ?
|
|
376
|
+
<Icon name="ErrorOutlined" style={{ color: '#6c757d' }} /> :
|
|
377
|
+
(selectedOption === option.value ? <Icon name="CheckFilled" /> : undefined)
|
|
378
|
+
}
|
|
379
|
+
>
|
|
380
|
+
<Text color={option.disabled ? 'secondary' : 'default'}>
|
|
381
|
+
{option.label}
|
|
382
|
+
</Text>
|
|
383
|
+
</SelectListItem>
|
|
384
|
+
))}
|
|
385
|
+
</div>
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### Theme Selection
|
|
391
|
+
|
|
392
|
+
```tsx
|
|
393
|
+
import { SelectListItem, Text } from '@delightui/components';
|
|
394
|
+
|
|
395
|
+
function ThemeSelectionExample() {
|
|
396
|
+
const [selectedTheme, setSelectedTheme] = useState('light');
|
|
397
|
+
|
|
398
|
+
const themes = [
|
|
399
|
+
{
|
|
400
|
+
value: 'light',
|
|
401
|
+
name: 'Light Theme',
|
|
402
|
+
description: 'Clean and bright interface',
|
|
403
|
+
preview: '#ffffff'
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
value: 'dark',
|
|
407
|
+
name: 'Dark Theme',
|
|
408
|
+
description: 'Easy on the eyes for low light',
|
|
409
|
+
preview: '#1a1a1a'
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
value: 'blue',
|
|
413
|
+
name: 'Blue Theme',
|
|
414
|
+
description: 'Professional blue color scheme',
|
|
415
|
+
preview: '#007bff'
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
value: 'green',
|
|
419
|
+
name: 'Green Theme',
|
|
420
|
+
description: 'Nature-inspired green palette',
|
|
421
|
+
preview: '#28a745'
|
|
422
|
+
}
|
|
423
|
+
];
|
|
424
|
+
|
|
425
|
+
return (
|
|
426
|
+
<div style={{
|
|
427
|
+
border: '1px solid #ccc',
|
|
428
|
+
borderRadius: '4px',
|
|
429
|
+
maxWidth: '300px'
|
|
430
|
+
}}>
|
|
431
|
+
{themes.map((theme) => (
|
|
432
|
+
<SelectListItem
|
|
433
|
+
key={theme.value}
|
|
434
|
+
leadingIcon={
|
|
435
|
+
<div style={{
|
|
436
|
+
width: '24px',
|
|
437
|
+
height: '24px',
|
|
438
|
+
borderRadius: '4px',
|
|
439
|
+
backgroundColor: theme.preview,
|
|
440
|
+
border: '1px solid #ddd'
|
|
441
|
+
}} />
|
|
442
|
+
}
|
|
443
|
+
trailingIcon={
|
|
444
|
+
selectedTheme === theme.value ?
|
|
445
|
+
<Icon name="CheckFilled" style={{ color: '#28a745' }} /> :
|
|
446
|
+
undefined
|
|
447
|
+
}
|
|
448
|
+
onClick={() => setSelectedTheme(theme.value)}
|
|
449
|
+
className={selectedTheme === theme.value ? 'selected' : ''}
|
|
450
|
+
>
|
|
451
|
+
<div>
|
|
452
|
+
<Text weight="medium">{theme.name}</Text>
|
|
453
|
+
<Text size="small" color="secondary" style={{ display: 'block' }}>
|
|
454
|
+
{theme.description}
|
|
455
|
+
</Text>
|
|
456
|
+
</div>
|
|
457
|
+
</SelectListItem>
|
|
458
|
+
))}
|
|
459
|
+
</div>
|
|
460
|
+
);
|
|
461
|
+
}
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
### Searchable Select List
|
|
465
|
+
|
|
466
|
+
```tsx
|
|
467
|
+
import { SelectListItem, Input, Text, Icon } from '@delightui/components';
|
|
468
|
+
|
|
469
|
+
function SearchableSelectListExample() {
|
|
470
|
+
const [searchTerm, setSearchTerm] = useState('');
|
|
471
|
+
const [selectedItem, setSelectedItem] = useState('');
|
|
472
|
+
|
|
473
|
+
const allItems = [
|
|
474
|
+
'Apple', 'Banana', 'Cherry', 'Date', 'Elderberry',
|
|
475
|
+
'Fig', 'Grape', 'Honeydew', 'Kiwi', 'Lemon',
|
|
476
|
+
'Mango', 'Orange', 'Papaya', 'Quince', 'Raspberry'
|
|
477
|
+
];
|
|
478
|
+
|
|
479
|
+
const filteredItems = allItems.filter(item =>
|
|
480
|
+
item.toLowerCase().includes(searchTerm.toLowerCase())
|
|
481
|
+
);
|
|
482
|
+
|
|
483
|
+
return (
|
|
484
|
+
<div style={{
|
|
485
|
+
border: '1px solid #ccc',
|
|
486
|
+
borderRadius: '4px',
|
|
487
|
+
maxWidth: '250px'
|
|
488
|
+
}}>
|
|
489
|
+
<div style={{ padding: '8px', borderBottom: '1px solid #eee' }}>
|
|
490
|
+
<Input
|
|
491
|
+
value={searchTerm}
|
|
492
|
+
onValueChange={setSearchTerm}
|
|
493
|
+
placeholder="Search fruits..."
|
|
494
|
+
leadingIcon={<Icon name="SearchFilled" />}
|
|
495
|
+
/>
|
|
496
|
+
</div>
|
|
497
|
+
|
|
498
|
+
<div style={{ maxHeight: '200px', overflowY: 'auto' }}>
|
|
499
|
+
{filteredItems.length > 0 ? (
|
|
500
|
+
filteredItems.map((item) => (
|
|
501
|
+
<SelectListItem
|
|
502
|
+
key={item}
|
|
503
|
+
onClick={() => setSelectedItem(item)}
|
|
504
|
+
className={selectedItem === item ? 'selected' : ''}
|
|
505
|
+
trailingIcon={
|
|
506
|
+
selectedItem === item ?
|
|
507
|
+
<Icon name="CheckFilled" style={{ color: '#28a745' }} /> :
|
|
508
|
+
undefined
|
|
509
|
+
}
|
|
510
|
+
>
|
|
511
|
+
{item}
|
|
512
|
+
</SelectListItem>
|
|
513
|
+
))
|
|
514
|
+
) : (
|
|
515
|
+
<div style={{ padding: '16px', textAlign: 'center' }}>
|
|
516
|
+
<Text color="secondary" size="small">
|
|
517
|
+
No items found
|
|
518
|
+
</Text>
|
|
519
|
+
</div>
|
|
520
|
+
)}
|
|
521
|
+
</div>
|
|
522
|
+
</div>
|
|
523
|
+
);
|
|
524
|
+
}
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
### Multi-level Selection
|
|
528
|
+
|
|
529
|
+
```tsx
|
|
530
|
+
import { SelectListItem, Icon, Text } from '@delightui/components';
|
|
531
|
+
|
|
532
|
+
function MultiLevelSelectionExample() {
|
|
533
|
+
const [selectedCategory, setSelectedCategory] = useState('');
|
|
534
|
+
const [selectedSubcategory, setSelectedSubcategory] = useState('');
|
|
535
|
+
|
|
536
|
+
const categories = [
|
|
537
|
+
{
|
|
538
|
+
id: 'electronics',
|
|
539
|
+
name: 'Electronics',
|
|
540
|
+
subcategories: ['Computers', 'Phones', 'Tablets']
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
id: 'clothing',
|
|
544
|
+
name: 'Clothing',
|
|
545
|
+
subcategories: ['Shirts', 'Pants', 'Shoes']
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
id: 'books',
|
|
549
|
+
name: 'Books',
|
|
550
|
+
subcategories: ['Fiction', 'Non-Fiction', 'Technical']
|
|
551
|
+
}
|
|
552
|
+
];
|
|
553
|
+
|
|
554
|
+
const selectedCategoryData = categories.find(cat => cat.id === selectedCategory);
|
|
555
|
+
|
|
556
|
+
return (
|
|
557
|
+
<div style={{ display: 'flex', gap: '16px' }}>
|
|
558
|
+
<div style={{
|
|
559
|
+
border: '1px solid #ccc',
|
|
560
|
+
borderRadius: '4px',
|
|
561
|
+
minWidth: '200px'
|
|
562
|
+
}}>
|
|
563
|
+
<div style={{ padding: '8px', borderBottom: '1px solid #eee', backgroundColor: '#f8f9fa' }}>
|
|
564
|
+
<Text weight="bold" size="small">Categories</Text>
|
|
565
|
+
</div>
|
|
566
|
+
{categories.map((category) => (
|
|
567
|
+
<SelectListItem
|
|
568
|
+
key={category.id}
|
|
569
|
+
onClick={() => {
|
|
570
|
+
setSelectedCategory(category.id);
|
|
571
|
+
setSelectedSubcategory('');
|
|
572
|
+
}}
|
|
573
|
+
className={selectedCategory === category.id ? 'selected' : ''}
|
|
574
|
+
trailingIcon={<Icon name="ChevronRightOutlined" />}
|
|
575
|
+
>
|
|
576
|
+
{category.name}
|
|
577
|
+
</SelectListItem>
|
|
578
|
+
))}
|
|
579
|
+
</div>
|
|
580
|
+
|
|
581
|
+
{selectedCategoryData && (
|
|
582
|
+
<div style={{
|
|
583
|
+
border: '1px solid #ccc',
|
|
584
|
+
borderRadius: '4px',
|
|
585
|
+
minWidth: '200px'
|
|
586
|
+
}}>
|
|
587
|
+
<div style={{ padding: '8px', borderBottom: '1px solid #eee', backgroundColor: '#f8f9fa' }}>
|
|
588
|
+
<Text weight="bold" size="small">Subcategories</Text>
|
|
589
|
+
</div>
|
|
590
|
+
{selectedCategoryData.subcategories.map((subcategory) => (
|
|
591
|
+
<SelectListItem
|
|
592
|
+
key={subcategory}
|
|
593
|
+
onClick={() => setSelectedSubcategory(subcategory)}
|
|
594
|
+
className={selectedSubcategory === subcategory ? 'selected' : ''}
|
|
595
|
+
trailingIcon={
|
|
596
|
+
selectedSubcategory === subcategory ?
|
|
597
|
+
<Icon name="CheckFilled" style={{ color: '#28a745' }} /> :
|
|
598
|
+
undefined
|
|
599
|
+
}
|
|
600
|
+
>
|
|
601
|
+
{subcategory}
|
|
602
|
+
</SelectListItem>
|
|
603
|
+
))}
|
|
604
|
+
</div>
|
|
605
|
+
)}
|
|
606
|
+
</div>
|
|
607
|
+
);
|
|
608
|
+
}
|
|
609
|
+
```
|