@delightui/components 0.1.104 → 0.1.106
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/Popover/Popover.presenter.d.ts +26 -0
- package/dist/cjs/components/molecules/Select/Option/Option.types.d.ts +6 -0
- package/dist/cjs/components/molecules/Select/Select.Context.d.ts +1 -1
- package/dist/cjs/components/molecules/Select/Select.d.ts +5 -5
- package/dist/cjs/components/molecules/Select/Select.presenter.d.ts +1 -0
- package/dist/cjs/components/molecules/Select/Select.types.d.ts +5 -0
- package/dist/cjs/components/molecules/Select/index.d.ts +2 -9
- package/dist/cjs/components/molecules/index.d.ts +2 -0
- package/dist/cjs/components/utils/accessibilityUtils.d.ts +41 -0
- package/dist/cjs/components/utils/index.d.ts +2 -0
- package/dist/cjs/library.css +13 -0
- package/dist/cjs/library.js +2 -2
- 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/Popover/Popover.presenter.d.ts +26 -0
- package/dist/esm/components/molecules/Select/Option/Option.types.d.ts +6 -0
- package/dist/esm/components/molecules/Select/Select.Context.d.ts +1 -1
- package/dist/esm/components/molecules/Select/Select.d.ts +5 -5
- package/dist/esm/components/molecules/Select/Select.presenter.d.ts +1 -0
- package/dist/esm/components/molecules/Select/Select.types.d.ts +5 -0
- package/dist/esm/components/molecules/Select/index.d.ts +2 -9
- package/dist/esm/components/molecules/index.d.ts +2 -0
- package/dist/esm/components/utils/accessibilityUtils.d.ts +41 -0
- package/dist/esm/components/utils/index.d.ts +2 -0
- package/dist/esm/library.css +13 -0
- package/dist/esm/library.js +3 -3
- package/dist/esm/library.js.map +1 -1
- package/dist/index.d.ts +156 -12
- 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,502 @@
|
|
|
1
|
+
# ListItem
|
|
2
|
+
|
|
3
|
+
A versatile list item component that provides a standardized way to display individual items within lists. It supports leading and trailing icons, click interactions, and disabled states, making it ideal for navigation menus, option lists, and interactive collections.
|
|
4
|
+
|
|
5
|
+
## Aliases
|
|
6
|
+
|
|
7
|
+
- ListItem
|
|
8
|
+
- ListElement
|
|
9
|
+
- Item
|
|
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
|
+
*Note: In addition to the props listed above, this component inherits all HTML div attributes (except 'style') such as `id`, `data-*`, `aria-*`, `onMouseEnter`, `onMouseLeave`, etc., providing full accessibility and interaction support.*
|
|
25
|
+
|
|
26
|
+
## Examples
|
|
27
|
+
|
|
28
|
+
### Basic List Item
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { ListItem } from '@delightui/components';
|
|
32
|
+
|
|
33
|
+
function BasicListItemExample() {
|
|
34
|
+
return (
|
|
35
|
+
<div>
|
|
36
|
+
<ListItem>
|
|
37
|
+
Basic List Item
|
|
38
|
+
</ListItem>
|
|
39
|
+
<ListItem>
|
|
40
|
+
Another List Item
|
|
41
|
+
</ListItem>
|
|
42
|
+
<ListItem>
|
|
43
|
+
Third List Item
|
|
44
|
+
</ListItem>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Clickable List Items
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
import { ListItem } from '@delightui/components';
|
|
54
|
+
|
|
55
|
+
function ClickableListItemExample() {
|
|
56
|
+
const handleItemClick = (item: string) => {
|
|
57
|
+
console.log(`Clicked: ${item}`);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<div>
|
|
62
|
+
<ListItem onClick={() => handleItemClick('Home')}>
|
|
63
|
+
Home
|
|
64
|
+
</ListItem>
|
|
65
|
+
<ListItem onClick={() => handleItemClick('About')}>
|
|
66
|
+
About
|
|
67
|
+
</ListItem>
|
|
68
|
+
<ListItem onClick={() => handleItemClick('Services')}>
|
|
69
|
+
Services
|
|
70
|
+
</ListItem>
|
|
71
|
+
<ListItem onClick={() => handleItemClick('Contact')}>
|
|
72
|
+
Contact
|
|
73
|
+
</ListItem>
|
|
74
|
+
</div>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### List Items with Icons
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
import { ListItem, Icon } from '@delightui/components';
|
|
83
|
+
|
|
84
|
+
function IconListItemExample() {
|
|
85
|
+
return (
|
|
86
|
+
<div>
|
|
87
|
+
<ListItem
|
|
88
|
+
leadingIcon={<Icon name="AddFilled" />}
|
|
89
|
+
onClick={() => console.log('Add clicked')}
|
|
90
|
+
>
|
|
91
|
+
Add New Item
|
|
92
|
+
</ListItem>
|
|
93
|
+
|
|
94
|
+
<ListItem
|
|
95
|
+
leadingIcon={<Icon name="SearchFilled" />}
|
|
96
|
+
onClick={() => console.log('Search clicked')}
|
|
97
|
+
>
|
|
98
|
+
Search
|
|
99
|
+
</ListItem>
|
|
100
|
+
|
|
101
|
+
<ListItem
|
|
102
|
+
leadingIcon={<Icon name="InfoFilled" />}
|
|
103
|
+
trailingIcon={<Icon name="ChevronRightOutlined" />}
|
|
104
|
+
onClick={() => console.log('Info clicked')}
|
|
105
|
+
>
|
|
106
|
+
Information
|
|
107
|
+
</ListItem>
|
|
108
|
+
</div>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Navigation Menu Example
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
import { ListItem, Icon } from '@delightui/components';
|
|
117
|
+
|
|
118
|
+
function NavigationMenuExample() {
|
|
119
|
+
const [activeItem, setActiveItem] = useState('dashboard');
|
|
120
|
+
|
|
121
|
+
const menuItems = [
|
|
122
|
+
{ id: 'dashboard', label: 'Dashboard', icon: 'AddFilled' },
|
|
123
|
+
{ id: 'users', label: 'Users', icon: 'SearchFilled' },
|
|
124
|
+
{ id: 'settings', label: 'Settings', icon: 'InfoFilled' },
|
|
125
|
+
{ id: 'help', label: 'Help', icon: 'ErrorOutlined' }
|
|
126
|
+
];
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<nav style={{ width: '250px', border: '1px solid #ccc', borderRadius: '8px' }}>
|
|
130
|
+
{menuItems.map((item) => (
|
|
131
|
+
<ListItem
|
|
132
|
+
key={item.id}
|
|
133
|
+
leadingIcon={<Icon name={item.icon} />}
|
|
134
|
+
trailingIcon={activeItem === item.id ? <Icon name="CheckFilled" /> : undefined}
|
|
135
|
+
onClick={() => setActiveItem(item.id)}
|
|
136
|
+
className={activeItem === item.id ? 'active' : ''}
|
|
137
|
+
>
|
|
138
|
+
{item.label}
|
|
139
|
+
</ListItem>
|
|
140
|
+
))}
|
|
141
|
+
</nav>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Settings List Example
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
import { ListItem, Icon, Toggle } from '@delightui/components';
|
|
150
|
+
|
|
151
|
+
function SettingsListExample() {
|
|
152
|
+
const [settings, setSettings] = useState({
|
|
153
|
+
notifications: true,
|
|
154
|
+
darkMode: false,
|
|
155
|
+
autoSync: true
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const toggleSetting = (key: keyof typeof settings) => {
|
|
159
|
+
setSettings(prev => ({ ...prev, [key]: !prev[key] }));
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<div style={{ width: '300px' }}>
|
|
164
|
+
<ListItem
|
|
165
|
+
leadingIcon={<Icon name="InfoFilled" />}
|
|
166
|
+
trailingIcon={
|
|
167
|
+
<Toggle
|
|
168
|
+
value={settings.notifications}
|
|
169
|
+
onValueChange={() => toggleSetting('notifications')}
|
|
170
|
+
/>
|
|
171
|
+
}
|
|
172
|
+
>
|
|
173
|
+
Notifications
|
|
174
|
+
</ListItem>
|
|
175
|
+
|
|
176
|
+
<ListItem
|
|
177
|
+
leadingIcon={<Icon name="InfoFilled" />}
|
|
178
|
+
trailingIcon={
|
|
179
|
+
<Toggle
|
|
180
|
+
value={settings.darkMode}
|
|
181
|
+
onValueChange={() => toggleSetting('darkMode')}
|
|
182
|
+
/>
|
|
183
|
+
}
|
|
184
|
+
>
|
|
185
|
+
Dark Mode
|
|
186
|
+
</ListItem>
|
|
187
|
+
|
|
188
|
+
<ListItem
|
|
189
|
+
leadingIcon={<Icon name="InfoFilled" />}
|
|
190
|
+
trailingIcon={
|
|
191
|
+
<Toggle
|
|
192
|
+
value={settings.autoSync}
|
|
193
|
+
onValueChange={() => toggleSetting('autoSync')}
|
|
194
|
+
/>
|
|
195
|
+
}
|
|
196
|
+
>
|
|
197
|
+
Auto Sync
|
|
198
|
+
</ListItem>
|
|
199
|
+
</div>
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Disabled List Items
|
|
205
|
+
|
|
206
|
+
```tsx
|
|
207
|
+
import { ListItem, Icon } from '@delightui/components';
|
|
208
|
+
|
|
209
|
+
function DisabledListItemExample() {
|
|
210
|
+
return (
|
|
211
|
+
<div>
|
|
212
|
+
<ListItem
|
|
213
|
+
leadingIcon={<Icon name="AddFilled" />}
|
|
214
|
+
onClick={() => console.log('Available action')}
|
|
215
|
+
>
|
|
216
|
+
Available Action
|
|
217
|
+
</ListItem>
|
|
218
|
+
|
|
219
|
+
<ListItem
|
|
220
|
+
leadingIcon={<Icon name="SearchFilled" />}
|
|
221
|
+
disabled
|
|
222
|
+
onClick={() => console.log('This will not be called')}
|
|
223
|
+
>
|
|
224
|
+
Disabled Action
|
|
225
|
+
</ListItem>
|
|
226
|
+
|
|
227
|
+
<ListItem
|
|
228
|
+
leadingIcon={<Icon name="InfoFilled" />}
|
|
229
|
+
onClick={() => console.log('Another available action')}
|
|
230
|
+
>
|
|
231
|
+
Another Available Action
|
|
232
|
+
</ListItem>
|
|
233
|
+
</div>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### List with Different Content Types
|
|
239
|
+
|
|
240
|
+
```tsx
|
|
241
|
+
import { ListItem, Icon, Text, Button } from '@delightui/components';
|
|
242
|
+
|
|
243
|
+
function ContentTypesListExample() {
|
|
244
|
+
return (
|
|
245
|
+
<div>
|
|
246
|
+
<ListItem leadingIcon={<Icon name="AddFilled" />}>
|
|
247
|
+
<div>
|
|
248
|
+
<Text weight="bold">John Doe</Text>
|
|
249
|
+
<Text size="small" color="secondary">
|
|
250
|
+
john.doe@example.com
|
|
251
|
+
</Text>
|
|
252
|
+
</div>
|
|
253
|
+
</ListItem>
|
|
254
|
+
|
|
255
|
+
<ListItem leadingIcon={<Icon name="SearchFilled" />}>
|
|
256
|
+
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', width: '100%' }}>
|
|
257
|
+
<div>
|
|
258
|
+
<Text weight="bold">Project Alpha</Text>
|
|
259
|
+
<Text size="small" color="secondary">
|
|
260
|
+
Due: Tomorrow
|
|
261
|
+
</Text>
|
|
262
|
+
</div>
|
|
263
|
+
<Button size="Small" type="Outlined">
|
|
264
|
+
View
|
|
265
|
+
</Button>
|
|
266
|
+
</div>
|
|
267
|
+
</ListItem>
|
|
268
|
+
|
|
269
|
+
<ListItem>
|
|
270
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: '12px' }}>
|
|
271
|
+
<div style={{
|
|
272
|
+
width: '40px',
|
|
273
|
+
height: '40px',
|
|
274
|
+
borderRadius: '50%',
|
|
275
|
+
backgroundColor: '#007bff',
|
|
276
|
+
display: 'flex',
|
|
277
|
+
alignItems: 'center',
|
|
278
|
+
justifyContent: 'center',
|
|
279
|
+
color: 'white',
|
|
280
|
+
fontSize: '14px',
|
|
281
|
+
fontWeight: 'bold'
|
|
282
|
+
}}>
|
|
283
|
+
AB
|
|
284
|
+
</div>
|
|
285
|
+
<div>
|
|
286
|
+
<Text weight="bold">Alice Brown</Text>
|
|
287
|
+
<Text size="small" color="secondary">
|
|
288
|
+
Online
|
|
289
|
+
</Text>
|
|
290
|
+
</div>
|
|
291
|
+
</div>
|
|
292
|
+
</ListItem>
|
|
293
|
+
</div>
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Grouped List Items
|
|
299
|
+
|
|
300
|
+
```tsx
|
|
301
|
+
import { ListItem, Icon, Text } from '@delightui/components';
|
|
302
|
+
|
|
303
|
+
function GroupedListItemExample() {
|
|
304
|
+
const groups = [
|
|
305
|
+
{
|
|
306
|
+
title: 'Recent',
|
|
307
|
+
items: [
|
|
308
|
+
{ id: 1, name: 'Document 1', icon: 'AddFilled' },
|
|
309
|
+
{ id: 2, name: 'Document 2', icon: 'SearchFilled' }
|
|
310
|
+
]
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
title: 'Favorites',
|
|
314
|
+
items: [
|
|
315
|
+
{ id: 3, name: 'Important File', icon: 'InfoFilled' },
|
|
316
|
+
{ id: 4, name: 'Starred Item', icon: 'CheckFilled' }
|
|
317
|
+
]
|
|
318
|
+
}
|
|
319
|
+
];
|
|
320
|
+
|
|
321
|
+
return (
|
|
322
|
+
<div>
|
|
323
|
+
{groups.map((group) => (
|
|
324
|
+
<div key={group.title}>
|
|
325
|
+
<Text
|
|
326
|
+
weight="bold"
|
|
327
|
+
size="small"
|
|
328
|
+
color="secondary"
|
|
329
|
+
style={{ padding: '8px 16px', textTransform: 'uppercase' }}
|
|
330
|
+
>
|
|
331
|
+
{group.title}
|
|
332
|
+
</Text>
|
|
333
|
+
|
|
334
|
+
{group.items.map((item) => (
|
|
335
|
+
<ListItem
|
|
336
|
+
key={item.id}
|
|
337
|
+
leadingIcon={<Icon name={item.icon} />}
|
|
338
|
+
trailingIcon={<Icon name="ChevronRightOutlined" />}
|
|
339
|
+
onClick={() => console.log(`Clicked ${item.name}`)}
|
|
340
|
+
>
|
|
341
|
+
{item.name}
|
|
342
|
+
</ListItem>
|
|
343
|
+
))}
|
|
344
|
+
</div>
|
|
345
|
+
))}
|
|
346
|
+
</div>
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
### Interactive List with Selection
|
|
352
|
+
|
|
353
|
+
```tsx
|
|
354
|
+
import { ListItem, Icon, Checkbox } from '@delightui/components';
|
|
355
|
+
|
|
356
|
+
function SelectableListExample() {
|
|
357
|
+
const [selectedItems, setSelectedItems] = useState<number[]>([]);
|
|
358
|
+
|
|
359
|
+
const items = [
|
|
360
|
+
{ id: 1, name: 'Item 1' },
|
|
361
|
+
{ id: 2, name: 'Item 2' },
|
|
362
|
+
{ id: 3, name: 'Item 3' },
|
|
363
|
+
{ id: 4, name: 'Item 4' }
|
|
364
|
+
];
|
|
365
|
+
|
|
366
|
+
const toggleSelection = (itemId: number) => {
|
|
367
|
+
setSelectedItems(prev =>
|
|
368
|
+
prev.includes(itemId)
|
|
369
|
+
? prev.filter(id => id !== itemId)
|
|
370
|
+
: [...prev, itemId]
|
|
371
|
+
);
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
const isSelected = (itemId: number) => selectedItems.includes(itemId);
|
|
375
|
+
|
|
376
|
+
return (
|
|
377
|
+
<div>
|
|
378
|
+
<Text weight="bold" style={{ marginBottom: '8px' }}>
|
|
379
|
+
Selected: {selectedItems.length} items
|
|
380
|
+
</Text>
|
|
381
|
+
|
|
382
|
+
{items.map((item) => (
|
|
383
|
+
<ListItem
|
|
384
|
+
key={item.id}
|
|
385
|
+
leadingIcon={
|
|
386
|
+
<Checkbox
|
|
387
|
+
value={isSelected(item.id)}
|
|
388
|
+
onValueChange={() => toggleSelection(item.id)}
|
|
389
|
+
/>
|
|
390
|
+
}
|
|
391
|
+
onClick={() => toggleSelection(item.id)}
|
|
392
|
+
className={isSelected(item.id) ? 'selected' : ''}
|
|
393
|
+
>
|
|
394
|
+
{item.name}
|
|
395
|
+
</ListItem>
|
|
396
|
+
))}
|
|
397
|
+
</div>
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### Action List with Confirmation
|
|
403
|
+
|
|
404
|
+
```tsx
|
|
405
|
+
import { ListItem, Icon, Button } from '@delightui/components';
|
|
406
|
+
|
|
407
|
+
function ActionListExample() {
|
|
408
|
+
const [showConfirm, setShowConfirm] = useState<number | null>(null);
|
|
409
|
+
|
|
410
|
+
const handleDelete = (id: number) => {
|
|
411
|
+
setShowConfirm(id);
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
const confirmDelete = (id: number) => {
|
|
415
|
+
console.log(`Deleting item ${id}`);
|
|
416
|
+
setShowConfirm(null);
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
const items = [
|
|
420
|
+
{ id: 1, name: 'Item to Delete 1' },
|
|
421
|
+
{ id: 2, name: 'Item to Delete 2' },
|
|
422
|
+
{ id: 3, name: 'Item to Delete 3' }
|
|
423
|
+
];
|
|
424
|
+
|
|
425
|
+
return (
|
|
426
|
+
<div>
|
|
427
|
+
{items.map((item) => (
|
|
428
|
+
<ListItem
|
|
429
|
+
key={item.id}
|
|
430
|
+
leadingIcon={<Icon name="InfoFilled" />}
|
|
431
|
+
trailingIcon={
|
|
432
|
+
showConfirm === item.id ? (
|
|
433
|
+
<div style={{ display: 'flex', gap: '8px' }}>
|
|
434
|
+
<Button
|
|
435
|
+
size="Small"
|
|
436
|
+
type="Outlined"
|
|
437
|
+
onClick={() => setShowConfirm(null)}
|
|
438
|
+
>
|
|
439
|
+
Cancel
|
|
440
|
+
</Button>
|
|
441
|
+
<Button
|
|
442
|
+
size="Small"
|
|
443
|
+
style="Destructive"
|
|
444
|
+
onClick={() => confirmDelete(item.id)}
|
|
445
|
+
>
|
|
446
|
+
Delete
|
|
447
|
+
</Button>
|
|
448
|
+
</div>
|
|
449
|
+
) : (
|
|
450
|
+
<Button
|
|
451
|
+
size="Small"
|
|
452
|
+
type="Ghost"
|
|
453
|
+
onClick={() => handleDelete(item.id)}
|
|
454
|
+
>
|
|
455
|
+
<Icon name="CloseDeleteOutlined" />
|
|
456
|
+
</Button>
|
|
457
|
+
)
|
|
458
|
+
}
|
|
459
|
+
>
|
|
460
|
+
{item.name}
|
|
461
|
+
</ListItem>
|
|
462
|
+
))}
|
|
463
|
+
</div>
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
### Custom Styled List Items
|
|
469
|
+
|
|
470
|
+
```tsx
|
|
471
|
+
import { ListItem, Icon } from '@delightui/components';
|
|
472
|
+
|
|
473
|
+
function CustomStyledListExample() {
|
|
474
|
+
return (
|
|
475
|
+
<div>
|
|
476
|
+
<ListItem
|
|
477
|
+
leadingIcon={<Icon name="CheckFilled" />}
|
|
478
|
+
className="success-item"
|
|
479
|
+
style={{ backgroundColor: '#d4edda', borderLeft: '4px solid #28a745' }}
|
|
480
|
+
>
|
|
481
|
+
Success Item
|
|
482
|
+
</ListItem>
|
|
483
|
+
|
|
484
|
+
<ListItem
|
|
485
|
+
leadingIcon={<Icon name="ErrorOutlined" />}
|
|
486
|
+
className="warning-item"
|
|
487
|
+
style={{ backgroundColor: '#fff3cd', borderLeft: '4px solid #ffc107' }}
|
|
488
|
+
>
|
|
489
|
+
Warning Item
|
|
490
|
+
</ListItem>
|
|
491
|
+
|
|
492
|
+
<ListItem
|
|
493
|
+
leadingIcon={<Icon name="InfoFilled" />}
|
|
494
|
+
className="info-item"
|
|
495
|
+
style={{ backgroundColor: '#d1ecf1', borderLeft: '4px solid #17a2b8' }}
|
|
496
|
+
>
|
|
497
|
+
Info Item
|
|
498
|
+
</ListItem>
|
|
499
|
+
</div>
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
```
|