@12-apps/ui 1.5.0 → 1.5.1
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/package.json +16 -8
- package/src/button/index.ts +1 -0
- package/src/social-login-button/index.ts +1 -0
- package/src/{social-login-button.tsx → social-login-button/social-login-button.tsx} +5 -5
- package/src/user-avatar/index.ts +1 -0
- package/src/{user-avatar.tsx → user-avatar/user-avatar.tsx} +4 -4
- package/eslint.config.js +0 -89
- package/src/__tests__/data-grid.test.tsx +0 -125
- package/src/__tests__/package-wiring.test.ts +0 -41
- package/src/__tests__/setup.ts +0 -1
- package/src/__tests__/social-login-button.test.tsx +0 -186
- package/src/__tests__/user-avatar.test.tsx +0 -195
- package/src/__tests__/viewport.test.ts +0 -50
- package/src/components/command/__tests__/command.test.tsx +0 -112
- package/src/components/data-display/Alert/Alert.stories.tsx +0 -559
- package/src/components/data-display/Alert/Alert.test.stories.tsx +0 -707
- package/src/components/data-display/AlertDialog/AlertDialog.stories.tsx +0 -362
- package/src/components/data-display/AlertDialog/AlertDialog.test.stories.tsx +0 -763
- package/src/components/data-display/AsyncStateContainer/AsyncStateContainer.stories.tsx +0 -230
- package/src/components/data-display/AsyncStateContainer/AsyncStateContainer.test.stories.tsx +0 -270
- package/src/components/data-display/Avatar/Avatar.stories.tsx +0 -721
- package/src/components/data-display/Avatar/Avatar.test.stories.tsx +0 -822
- package/src/components/data-display/Badge/Badge.stories.tsx +0 -1134
- package/src/components/data-display/Badge/Badge.test.stories.tsx +0 -1194
- package/src/components/data-display/Banner/Banner.stories.tsx +0 -528
- package/src/components/data-display/Banner/Banner.test.stories.tsx +0 -511
- package/src/components/data-display/Carousel/Carousel.stories.tsx +0 -607
- package/src/components/data-display/Carousel/Carousel.test.stories.tsx +0 -701
- package/src/components/data-display/Chart/Chart.stories.tsx +0 -568
- package/src/components/data-display/Chart/Chart.test.stories.tsx +0 -174
- package/src/components/data-display/Chart/SpecChart.stories.tsx +0 -150
- package/src/components/data-display/Chart/SpecChart.test.stories.tsx +0 -56
- package/src/components/data-display/Chart/__tests__/SpecChart.test.tsx +0 -60
- package/src/components/data-display/Chart/__tests__/chart-format.test.ts +0 -43
- package/src/components/data-display/Chart/__tests__/chart-spec.test.ts +0 -119
- package/src/components/data-display/Chip/Chip.stories.tsx +0 -252
- package/src/components/data-display/Chip/Chip.test.stories.tsx +0 -266
- package/src/components/data-display/DataGrid/DataGrid.stories.tsx +0 -515
- package/src/components/data-display/DataGrid/DataGrid.test.stories.tsx +0 -653
- package/src/components/data-display/DataViews/__tests__/DataViewsGrid.test.tsx +0 -271
- package/src/components/data-display/DataViews/__tests__/DataViewsTableBase.test.tsx +0 -134
- package/src/components/data-display/DataViews/__tests__/SaveViewModal.test.tsx +0 -83
- package/src/components/data-display/DataViews/__tests__/data-views-filter.test.ts +0 -115
- package/src/components/data-display/DataViews/__tests__/data-views-preview.test.ts +0 -53
- package/src/components/data-display/DataViews/__tests__/range-pill.test.tsx +0 -114
- package/src/components/data-display/DataViews/base-card.stories.tsx +0 -136
- package/src/components/data-display/DescriptionItem/DescriptionItem.stories.tsx +0 -254
- package/src/components/data-display/EmptyState/EmptyState.stories.tsx +0 -282
- package/src/components/data-display/EmptyState/EmptyState.test.stories.tsx +0 -441
- package/src/components/data-display/ErrorState/ErrorState.stories.tsx +0 -110
- package/src/components/data-display/ErrorState/ErrorState.test.stories.tsx +0 -133
- package/src/components/data-display/HoverCard/HoverCard.stories.tsx +0 -650
- package/src/components/data-display/HoverCard/HoverCard.test.stories.tsx +0 -929
- package/src/components/data-display/InteractiveTooltip/InteractiveTooltip.stories.tsx +0 -411
- package/src/components/data-display/LazyImage/LazyImage.stories.tsx +0 -387
- package/src/components/data-display/Lightbox/Lightbox.stories.tsx +0 -315
- package/src/components/data-display/Lightbox/Lightbox.test.stories.tsx +0 -598
- package/src/components/data-display/LoadingState/LoadingState.stories.tsx +0 -124
- package/src/components/data-display/LoadingState/LoadingState.test.stories.tsx +0 -99
- package/src/components/data-display/MapPreview/MapPreview.stories.tsx +0 -458
- package/src/components/data-display/MapPreview/MapPreview.test.stories.tsx +0 -394
- package/src/components/data-display/Popover/Popover.stories.tsx +0 -295
- package/src/components/data-display/Popover/Popover.test.stories.tsx +0 -1162
- package/src/components/data-display/Progress/Progress.stories.tsx +0 -481
- package/src/components/data-display/Progress/Progress.test.stories.tsx +0 -2070
- package/src/components/data-display/SectionOnboarding/SectionOnboarding.stories.tsx +0 -160
- package/src/components/data-display/SectionOnboarding/SectionOnboarding.test.stories.tsx +0 -190
- package/src/components/data-display/Sheet/Sheet.stories.tsx +0 -883
- package/src/components/data-display/Sheet/Sheet.test.stories.tsx +0 -1105
- package/src/components/data-display/StatCard/StatCard.stories.tsx +0 -167
- package/src/components/data-display/StatCard/StatCard.test.stories.tsx +0 -240
- package/src/components/data-display/Stepper/Stepper.stories.tsx +0 -540
- package/src/components/data-display/Stepper/Stepper.test.stories.tsx +0 -600
- package/src/components/data-display/Table/Table.stories.tsx +0 -803
- package/src/components/data-display/Table/Table.test.stories.tsx +0 -369
- package/src/components/data-display/Timeline/Timeline.stories.tsx +0 -442
- package/src/components/data-display/Timeline/Timeline.test.stories.tsx +0 -930
- package/src/components/data-display/TimingDiagram/TimingDiagram.stories.tsx +0 -475
- package/src/components/data-display/TimingDiagram/TimingDiagram.test.stories.tsx +0 -734
- package/src/components/data-display/Tooltip/Tooltip.stories.tsx +0 -468
- package/src/components/data-display/Tooltip/Tooltip.test.stories.tsx +0 -1154
- package/src/components/feedback/ConfirmAction/ConfirmAction.stories.tsx +0 -146
- package/src/components/feedback/ConfirmAction/ConfirmAction.test.stories.tsx +0 -114
- package/src/components/feedback/ConfirmAction/__tests__/confirm-action.test.tsx +0 -288
- package/src/components/feedback/Dialog/Dialog.stories.tsx +0 -833
- package/src/components/feedback/Dialog/Dialog.test.stories.tsx +0 -964
- package/src/components/feedback/Dialog/__tests__/dialog-content-spacing.test.tsx +0 -66
- package/src/components/feedback/Modal/Modal.stories.tsx +0 -765
- package/src/components/feedback/Modal/Modal.test.stories.tsx +0 -251
- package/src/components/feedback/Sonner/Sonner.stories.tsx +0 -698
- package/src/components/feedback/Sonner/Sonner.test.stories.tsx +0 -896
- package/src/components/feedback/StackedModal/StackedModal.stories.tsx +0 -1783
- package/src/components/feedback/StackedModal/StackedModal.test.stories.tsx +0 -973
- package/src/components/feedback/StackedModal/__tests__/stacked-modal-viewport.test.tsx +0 -104
- package/src/components/feedback/Toast/Toast.stories.tsx +0 -548
- package/src/components/feedback/Toast/Toast.test.stories.tsx +0 -834
- package/src/components/feedback/TutorialOverlay/TutorialOverlay.stories.tsx +0 -691
- package/src/components/feedback/TutorialOverlay/TutorialOverlay.test.stories.tsx +0 -634
- package/src/components/form/AddressAutocomplete/AddressAutocomplete.stories.tsx +0 -665
- package/src/components/form/AddressAutocomplete/AddressAutocomplete.test.stories.tsx +0 -727
- package/src/components/form/Autocomplete/Autocomplete.stories.tsx +0 -715
- package/src/components/form/Autocomplete/Autocomplete.test.stories.tsx +0 -825
- package/src/components/form/Button/Button.stories.tsx +0 -365
- package/src/components/form/Button/Button.test.stories.tsx +0 -607
- package/src/components/form/Calendar/Calendar.stories.tsx +0 -349
- package/src/components/form/Calendar/Calendar.test.stories.tsx +0 -464
- package/src/components/form/CepField/CepField.stories.tsx +0 -138
- package/src/components/form/CepField/CepField.test.stories.tsx +0 -281
- package/src/components/form/Checkbox/Checkbox.stories.tsx +0 -265
- package/src/components/form/Checkbox/Checkbox.test.stories.tsx +0 -181
- package/src/components/form/CodeEditor/CodeEditor.stories.tsx +0 -871
- package/src/components/form/CodeEditor/CodeEditor.test.stories.tsx +0 -574
- package/src/components/form/Command/Command.stories.tsx +0 -580
- package/src/components/form/Command/Command.test.stories.tsx +0 -215
- package/src/components/form/CreatableSelect/CreatableSelect.stories.tsx +0 -112
- package/src/components/form/CreatableSelect/CreatableSelect.test.stories.tsx +0 -134
- package/src/components/form/Form/Form.stories.tsx +0 -687
- package/src/components/form/Form/Form.test.stories.tsx +0 -601
- package/src/components/form/Input/Input.stories.tsx +0 -260
- package/src/components/form/Input/Input.test.stories.tsx +0 -1191
- package/src/components/form/InputOTP/InputOTP.stories.tsx +0 -774
- package/src/components/form/InputOTP/InputOTP.test.stories.tsx +0 -588
- package/src/components/form/Label/Label.stories.tsx +0 -473
- package/src/components/form/Label/Label.test.stories.tsx +0 -915
- package/src/components/form/Menubar/Menubar.stories.tsx +0 -472
- package/src/components/form/Menubar/Menubar.test.stories.tsx +0 -584
- package/src/components/form/PasswordStrength/PasswordStrength.stories.tsx +0 -562
- package/src/components/form/PasswordStrength/PasswordStrength.test.stories.tsx +0 -327
- package/src/components/form/PhoneInput/PhoneInput.stories.tsx +0 -495
- package/src/components/form/PhoneInput/PhoneInput.test.stories.tsx +0 -666
- package/src/components/form/RadioGroup/RadioGroup.stories.tsx +0 -518
- package/src/components/form/RadioGroup/RadioGroup.test.stories.tsx +0 -685
- package/src/components/form/RichTextEditor/RichTextEditor.stories.tsx +0 -261
- package/src/components/form/RichTextEditor/RichTextEditor.test.stories.tsx +0 -491
- package/src/components/form/SearchPalette/SearchPalette.stories.tsx +0 -135
- package/src/components/form/Select/Select.stories.tsx +0 -364
- package/src/components/form/Select/Select.test.stories.tsx +0 -985
- package/src/components/form/Slider/Slider.stories.tsx +0 -418
- package/src/components/form/Slider/Slider.test.stories.tsx +0 -1042
- package/src/components/form/Switch/Switch.stories.tsx +0 -697
- package/src/components/form/Switch/Switch.test.stories.tsx +0 -597
- package/src/components/form/Textarea/Textarea.stories.tsx +0 -473
- package/src/components/form/Textarea/Textarea.test.stories.tsx +0 -702
- package/src/components/form/Toggle/Toggle.stories.tsx +0 -638
- package/src/components/form/Toggle/Toggle.test.stories.tsx +0 -1159
- package/src/components/form/ToggleGroup/ToggleGroup.stories.tsx +0 -617
- package/src/components/form/ToggleGroup/ToggleGroup.test.stories.tsx +0 -915
- package/src/components/form/UploadButton/UploadButton.stories.tsx +0 -367
- package/src/components/form/UploadButton/UploadButton.test.stories.tsx +0 -573
- package/src/components/form/total-form/total-form.test.tsx +0 -214
- package/src/components/layout/Accordion/Accordion.stories.tsx +0 -694
- package/src/components/layout/Accordion/Accordion.test.stories.tsx +0 -1344
- package/src/components/layout/Card/Card.stories.tsx +0 -591
- package/src/components/layout/Card/Card.test.stories.tsx +0 -1134
- package/src/components/layout/CardGrid/__tests__/CardGrid.test.tsx +0 -92
- package/src/components/layout/Collapsible/Collapsible.stories.tsx +0 -180
- package/src/components/layout/Collapsible/Collapsible.test.stories.tsx +0 -308
- package/src/components/layout/Container/Container.stories.tsx +0 -557
- package/src/components/layout/Container/Container.test.stories.tsx +0 -745
- package/src/components/layout/ContentToolbar/ContentToolbar.stories.tsx +0 -129
- package/src/components/layout/ContentToolbar/ContentToolbar.test.stories.tsx +0 -251
- package/src/components/layout/ContentToolbar/__tests__/ColumnsMenu.test.tsx +0 -39
- package/src/components/layout/ContentToolbar/__tests__/MultiSelectDropdown.test.tsx +0 -131
- package/src/components/layout/ContentToolbar/__tests__/SavedViewsMenu.test.tsx +0 -99
- package/src/components/layout/Dashboard/Dashboard.stories.tsx +0 -104
- package/src/components/layout/Dashboard/Dashboard.test.stories.tsx +0 -190
- package/src/components/layout/Drawer/Drawer.stories.tsx +0 -658
- package/src/components/layout/Drawer/Drawer.test.stories.tsx +0 -1343
- package/src/components/layout/Resizable/Resizable.stories.tsx +0 -1039
- package/src/components/layout/Resizable/Resizable.test.stories.tsx +0 -754
- package/src/components/layout/ScrollArea/ScrollArea.stories.tsx +0 -651
- package/src/components/layout/ScrollArea/ScrollArea.test.stories.tsx +0 -619
- package/src/components/layout/Separator/Separator.stories.tsx +0 -563
- package/src/components/layout/Separator/Separator.test.stories.tsx +0 -518
- package/src/components/layout/SettingsLayout/SettingsLayout.stories.tsx +0 -192
- package/src/components/layout/SettingsLayout/SettingsLayout.test.stories.tsx +0 -175
- package/src/components/layout/Sidebar/Sidebar.stories.tsx +0 -609
- package/src/components/layout/Sidebar/Sidebar.test.stories.tsx +0 -1324
- package/src/components/layout/Skeleton/Skeleton.stories.tsx +0 -689
- package/src/components/layout/Skeleton/Skeleton.test.stories.tsx +0 -521
- package/src/components/layout/Spacer/Spacer.stories.tsx +0 -502
- package/src/components/layout/Spacer/Spacer.test.stories.tsx +0 -474
- package/src/components/layout/TableFilter/TableFilter.stories.tsx +0 -82
- package/src/components/layout/TableFilter/TableFilter.test.stories.tsx +0 -87
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.stories.tsx +0 -638
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.test.stories.tsx +0 -1008
- package/src/components/navigation/CommandPalette/CommandPalette.stories.tsx +0 -386
- package/src/components/navigation/CommandPalette/CommandPalette.test.stories.tsx +0 -435
- package/src/components/navigation/ContextMenu/ContextMenu.stories.tsx +0 -614
- package/src/components/navigation/ContextMenu/ContextMenu.test.stories.tsx +0 -845
- package/src/components/navigation/DropdownMenu/DropdownMenu.stories.tsx +0 -578
- package/src/components/navigation/DropdownMenu/DropdownMenu.test.stories.tsx +0 -660
- package/src/components/navigation/NavigationMenu/stories/NavigationMenu.stories.tsx +0 -516
- package/src/components/navigation/NavigationMenu/stories/NavigationMenu.test.stories.tsx +0 -935
- package/src/components/navigation/NavigationMenu/stories/NavigationMenuHorizontal.stories.tsx +0 -501
- package/src/components/navigation/NavigationMenu/stories/NavigationMenuVertical.stories.tsx +0 -453
- package/src/components/navigation/Pagination/Pagination.stories.tsx +0 -602
- package/src/components/navigation/Pagination/Pagination.test.stories.tsx +0 -520
- package/src/components/navigation/Tabs/Tabs.stories.tsx +0 -1004
- package/src/components/navigation/Tabs/Tabs.test.stories.tsx +0 -1225
- package/src/components/typography/Blockquote/Blockquote.stories.tsx +0 -359
- package/src/components/typography/Blockquote/Blockquote.test.stories.tsx +0 -432
- package/src/components/typography/Code/Code.stories.tsx +0 -686
- package/src/components/typography/Code/Code.test.stories.tsx +0 -703
- package/src/components/typography/Heading/Heading.stories.tsx +0 -451
- package/src/components/typography/Heading/Heading.test.stories.tsx +0 -830
- package/src/components/typography/Paragraph/Paragraph.stories.tsx +0 -280
- package/src/components/typography/Paragraph/Paragraph.test.stories.tsx +0 -231
- package/src/components/typography/Text/Text.stories.tsx +0 -359
- package/src/components/typography/Text/Text.test.stories.tsx +0 -759
- package/src/components/utility/AnimatedIcon/AnimatedIcon.stories.tsx +0 -945
- package/src/components/utility/AnimatedIcon/AnimatedIcon.test.stories.tsx +0 -603
- package/src/components/utility/AspectRatio/AspectRatio.stories.tsx +0 -414
- package/src/components/utility/AspectRatio/AspectRatio.test.stories.tsx +0 -859
- package/src/components/utility/InfiniteScroll/InfiniteScroll.stories.tsx +0 -620
- package/src/components/utility/InfiniteScroll/InfiniteScroll.test.stories.tsx +0 -361
- package/src/components/utility/InstallPrompt/InstallPrompt.stories.tsx +0 -118
- package/src/components/utility/InstallPrompt/InstallPrompt.test.stories.tsx +0 -83
- package/src/components/utility/InstallPrompt/__tests__/InstallPrompt.ios.test.tsx +0 -65
- package/src/components/utility/InstallPrompt/__tests__/usePwaInstall.test.tsx +0 -271
- package/src/components/utility/Portal/Portal.stories.tsx +0 -340
- package/src/components/utility/Portal/Portal.test.stories.tsx +0 -2086
- package/src/components/utility/Transition/Transition.stories.tsx +0 -493
- package/src/components/utility/Transition/Transition.test.stories.tsx +0 -854
- package/src/components/utility/VirtualList/VirtualList.stories.tsx +0 -1073
- package/src/components/utility/VirtualList/VirtualList.test.stories.tsx +0 -1085
- package/src/components/utility/WorkflowStep/WorkflowStep.stories.tsx +0 -431
- package/src/components/utility/WorkflowStep/WorkflowStep.test.stories.tsx +0 -364
- /package/src/{button.tsx → button/button.tsx} +0 -0
|
@@ -1,1073 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Avatar,
|
|
3
|
-
Box,
|
|
4
|
-
ListItem,
|
|
5
|
-
ListItemAvatar,
|
|
6
|
-
ListItemText,
|
|
7
|
-
Paper,
|
|
8
|
-
Typography,
|
|
9
|
-
} from '@mui/material';
|
|
10
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
11
|
-
|
|
12
|
-
import { VirtualGrid,VirtualList } from './VirtualList';
|
|
13
|
-
import type { VirtualListItem } from './VirtualList.types';
|
|
14
|
-
|
|
15
|
-
const meta: Meta<typeof VirtualList> = {
|
|
16
|
-
title: 'Utility/VirtualList',
|
|
17
|
-
component: VirtualList,
|
|
18
|
-
tags: ['autodocs', 'component:VirtualList'],
|
|
19
|
-
parameters: {
|
|
20
|
-
layout: 'centered',
|
|
21
|
-
docs: {
|
|
22
|
-
description: {
|
|
23
|
-
component:
|
|
24
|
-
'High-performance virtual scrolling components for large datasets with fixed and variable height support.',
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export default meta;
|
|
31
|
-
type Story = StoryObj<typeof VirtualList>;
|
|
32
|
-
|
|
33
|
-
// Generate sample data
|
|
34
|
-
const generateItems = (count: number): VirtualListItem[] => Array.from({ length: count }, (_, i) => ({
|
|
35
|
-
id: i,
|
|
36
|
-
data: {
|
|
37
|
-
name: `Item ${i + 1}`,
|
|
38
|
-
description: `This is the description for item ${i + 1}`,
|
|
39
|
-
avatar: `https://i.pravatar.cc/40?img=${(i % 70) + 1}`,
|
|
40
|
-
},
|
|
41
|
-
}));
|
|
42
|
-
|
|
43
|
-
const generateVariableItems = (count: number): VirtualListItem[] => Array.from({ length: count }, (_, i) => ({
|
|
44
|
-
id: i,
|
|
45
|
-
height: 60 + Math.floor(Math.random() * 100), // Random heights between 60-160px
|
|
46
|
-
data: {
|
|
47
|
-
name: `Variable Item ${i + 1}`,
|
|
48
|
-
description: `This item has a variable height. ${
|
|
49
|
-
Math.random() > 0.5
|
|
50
|
-
? 'It contains additional content that makes it taller than other items in the list.'
|
|
51
|
-
: 'Short description.'
|
|
52
|
-
}`,
|
|
53
|
-
avatar: `https://i.pravatar.cc/40?img=${(i % 70) + 1}`,
|
|
54
|
-
},
|
|
55
|
-
}));
|
|
56
|
-
|
|
57
|
-
// Required story exports for validation
|
|
58
|
-
export const Default: Story = {
|
|
59
|
-
render: () => {
|
|
60
|
-
const items = generateItems(1000);
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
<Paper sx={{ width: 400, height: 400 }}>
|
|
64
|
-
<VirtualList
|
|
65
|
-
items={items}
|
|
66
|
-
variant="fixed"
|
|
67
|
-
height={400}
|
|
68
|
-
itemHeight={80}
|
|
69
|
-
renderItem={({ item, style }) => (
|
|
70
|
-
<Box key={item.id} style={style}>
|
|
71
|
-
<ListItem>
|
|
72
|
-
<ListItemAvatar>
|
|
73
|
-
<Avatar src={item.data.avatar} />
|
|
74
|
-
</ListItemAvatar>
|
|
75
|
-
<ListItemText primary={item.data.name} secondary={item.data.description} />
|
|
76
|
-
</ListItem>
|
|
77
|
-
</Box>
|
|
78
|
-
)}
|
|
79
|
-
/>
|
|
80
|
-
</Paper>
|
|
81
|
-
);
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export const AllVariants: Story = {
|
|
86
|
-
render: () => {
|
|
87
|
-
const fixedItems = generateItems(1000);
|
|
88
|
-
const variableItems = generateVariableItems(500);
|
|
89
|
-
|
|
90
|
-
return (
|
|
91
|
-
<Box sx={{ display: 'flex', gap: 3, flexWrap: 'wrap' }}>
|
|
92
|
-
<Paper sx={{ width: 350, height: 400 }}>
|
|
93
|
-
<Box sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}>
|
|
94
|
-
<Typography variant="h6">Fixed Height</Typography>
|
|
95
|
-
</Box>
|
|
96
|
-
<VirtualList
|
|
97
|
-
items={fixedItems}
|
|
98
|
-
variant="fixed"
|
|
99
|
-
height={350}
|
|
100
|
-
itemHeight={60}
|
|
101
|
-
renderItem={({ item, style }) => (
|
|
102
|
-
<Box key={item.id} style={style}>
|
|
103
|
-
<ListItem>
|
|
104
|
-
<ListItemAvatar>
|
|
105
|
-
<Avatar>{item.id + 1}</Avatar>
|
|
106
|
-
</ListItemAvatar>
|
|
107
|
-
<ListItemText primary={item.data.name} secondary="Fixed height item" />
|
|
108
|
-
</ListItem>
|
|
109
|
-
</Box>
|
|
110
|
-
)}
|
|
111
|
-
/>
|
|
112
|
-
</Paper>
|
|
113
|
-
|
|
114
|
-
<Paper sx={{ width: 350, height: 400 }}>
|
|
115
|
-
<Box sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}>
|
|
116
|
-
<Typography variant="h6">Variable Height</Typography>
|
|
117
|
-
</Box>
|
|
118
|
-
<VirtualList
|
|
119
|
-
items={variableItems}
|
|
120
|
-
variant="variable"
|
|
121
|
-
height={350}
|
|
122
|
-
estimatedItemHeight={80}
|
|
123
|
-
renderItem={({ item, style }) => (
|
|
124
|
-
<Box key={item.id} style={style}>
|
|
125
|
-
<ListItem sx={{ alignItems: 'flex-start' }}>
|
|
126
|
-
<ListItemAvatar>
|
|
127
|
-
<Avatar>{item.id + 1}</Avatar>
|
|
128
|
-
</ListItemAvatar>
|
|
129
|
-
<ListItemText
|
|
130
|
-
primary={item.data.name}
|
|
131
|
-
secondary={
|
|
132
|
-
<Typography variant="body2" color="text.secondary">
|
|
133
|
-
{item.data.description}
|
|
134
|
-
</Typography>
|
|
135
|
-
}
|
|
136
|
-
/>
|
|
137
|
-
</ListItem>
|
|
138
|
-
</Box>
|
|
139
|
-
)}
|
|
140
|
-
/>
|
|
141
|
-
</Paper>
|
|
142
|
-
|
|
143
|
-
<Paper sx={{ width: 400, height: 400 }}>
|
|
144
|
-
<Box sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}>
|
|
145
|
-
<Typography variant="h6">Grid Layout</Typography>
|
|
146
|
-
</Box>
|
|
147
|
-
<VirtualGrid
|
|
148
|
-
items={fixedItems.slice(0, 1000)}
|
|
149
|
-
height={350}
|
|
150
|
-
width={400}
|
|
151
|
-
columnCount={3}
|
|
152
|
-
rowHeight={120}
|
|
153
|
-
gap={4}
|
|
154
|
-
renderItem={({ item, style }) => (
|
|
155
|
-
<Box
|
|
156
|
-
key={item.id}
|
|
157
|
-
style={style}
|
|
158
|
-
sx={{
|
|
159
|
-
p: 2,
|
|
160
|
-
bgcolor: 'background.paper',
|
|
161
|
-
border: '1px solid',
|
|
162
|
-
borderColor: 'divider',
|
|
163
|
-
borderRadius: 2,
|
|
164
|
-
display: 'flex',
|
|
165
|
-
flexDirection: 'column',
|
|
166
|
-
alignItems: 'center',
|
|
167
|
-
textAlign: 'center',
|
|
168
|
-
}}
|
|
169
|
-
>
|
|
170
|
-
<Avatar src={item.data.avatar} sx={{ mb: 1 }} />
|
|
171
|
-
<Typography variant="body2">{item.data.name}</Typography>
|
|
172
|
-
</Box>
|
|
173
|
-
)}
|
|
174
|
-
/>
|
|
175
|
-
</Paper>
|
|
176
|
-
</Box>
|
|
177
|
-
);
|
|
178
|
-
},
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
export const AllSizes: Story = {
|
|
182
|
-
render: () => {
|
|
183
|
-
const items = generateItems(500);
|
|
184
|
-
|
|
185
|
-
return (
|
|
186
|
-
<Box sx={{ display: 'flex', gap: 2 }}>
|
|
187
|
-
<Paper sx={{ width: 250, height: 300 }}>
|
|
188
|
-
<Box sx={{ p: 1, borderBottom: '1px solid', borderColor: 'divider' }}>
|
|
189
|
-
<Typography variant="subtitle2">Small (250x300)</Typography>
|
|
190
|
-
</Box>
|
|
191
|
-
<VirtualList
|
|
192
|
-
items={items}
|
|
193
|
-
variant="fixed"
|
|
194
|
-
height={270}
|
|
195
|
-
itemHeight={50}
|
|
196
|
-
renderItem={({ item, style }) => (
|
|
197
|
-
<Box key={item.id} style={style}>
|
|
198
|
-
<ListItem dense>
|
|
199
|
-
<ListItemAvatar>
|
|
200
|
-
<Avatar size="small">{item.id + 1}</Avatar>
|
|
201
|
-
</ListItemAvatar>
|
|
202
|
-
<ListItemText primary={`Item ${item.id + 1}`} />
|
|
203
|
-
</ListItem>
|
|
204
|
-
</Box>
|
|
205
|
-
)}
|
|
206
|
-
/>
|
|
207
|
-
</Paper>
|
|
208
|
-
|
|
209
|
-
<Paper sx={{ width: 400, height: 400 }}>
|
|
210
|
-
<Box sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}>
|
|
211
|
-
<Typography variant="subtitle1">Medium (400x400)</Typography>
|
|
212
|
-
</Box>
|
|
213
|
-
<VirtualList
|
|
214
|
-
items={items}
|
|
215
|
-
variant="fixed"
|
|
216
|
-
height={360}
|
|
217
|
-
itemHeight={70}
|
|
218
|
-
renderItem={({ item, style }) => (
|
|
219
|
-
<Box key={item.id} style={style}>
|
|
220
|
-
<ListItem>
|
|
221
|
-
<ListItemAvatar>
|
|
222
|
-
<Avatar>{item.id + 1}</Avatar>
|
|
223
|
-
</ListItemAvatar>
|
|
224
|
-
<ListItemText primary={item.data.name} secondary="Medium size" />
|
|
225
|
-
</ListItem>
|
|
226
|
-
</Box>
|
|
227
|
-
)}
|
|
228
|
-
/>
|
|
229
|
-
</Paper>
|
|
230
|
-
|
|
231
|
-
<Paper sx={{ width: 600, height: 500 }}>
|
|
232
|
-
<Box sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}>
|
|
233
|
-
<Typography variant="h6">Large (600x500)</Typography>
|
|
234
|
-
</Box>
|
|
235
|
-
<VirtualList
|
|
236
|
-
items={items}
|
|
237
|
-
variant="fixed"
|
|
238
|
-
height={450}
|
|
239
|
-
itemHeight={90}
|
|
240
|
-
renderItem={({ item, style }) => (
|
|
241
|
-
<Box key={item.id} style={style}>
|
|
242
|
-
<ListItem>
|
|
243
|
-
<ListItemAvatar>
|
|
244
|
-
<Avatar src={item.data.avatar} sx={{ width: 56, height: 56 }} />
|
|
245
|
-
</ListItemAvatar>
|
|
246
|
-
<ListItemText
|
|
247
|
-
primary={<Typography variant="h6">{item.data.name}</Typography>}
|
|
248
|
-
secondary={<Typography variant="body2">{item.data.description}</Typography>}
|
|
249
|
-
/>
|
|
250
|
-
</ListItem>
|
|
251
|
-
</Box>
|
|
252
|
-
)}
|
|
253
|
-
/>
|
|
254
|
-
</Paper>
|
|
255
|
-
</Box>
|
|
256
|
-
);
|
|
257
|
-
},
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
export const AllStates: Story = {
|
|
261
|
-
render: () => {
|
|
262
|
-
const items = generateItems(50);
|
|
263
|
-
const emptyItems: VirtualListItem[] = [];
|
|
264
|
-
const loadingItems = Array.from({ length: 5 }, (_, i) => ({ id: i }));
|
|
265
|
-
|
|
266
|
-
return (
|
|
267
|
-
<Box sx={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: 3 }}>
|
|
268
|
-
<Paper sx={{ width: 300, height: 250 }}>
|
|
269
|
-
<Box sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}>
|
|
270
|
-
<Typography variant="subtitle1">Normal State</Typography>
|
|
271
|
-
</Box>
|
|
272
|
-
<VirtualList
|
|
273
|
-
items={items}
|
|
274
|
-
variant="fixed"
|
|
275
|
-
height={200}
|
|
276
|
-
itemHeight={60}
|
|
277
|
-
renderItem={({ item, style }) => (
|
|
278
|
-
<Box key={item.id} style={style}>
|
|
279
|
-
<ListItem>
|
|
280
|
-
<ListItemAvatar>
|
|
281
|
-
<Avatar>{item.id + 1}</Avatar>
|
|
282
|
-
</ListItemAvatar>
|
|
283
|
-
<ListItemText primary={item.data.name} />
|
|
284
|
-
</ListItem>
|
|
285
|
-
</Box>
|
|
286
|
-
)}
|
|
287
|
-
/>
|
|
288
|
-
</Paper>
|
|
289
|
-
|
|
290
|
-
<Paper sx={{ width: 300, height: 250, position: 'relative' }}>
|
|
291
|
-
<Box sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}>
|
|
292
|
-
<Typography variant="subtitle1">Empty State</Typography>
|
|
293
|
-
</Box>
|
|
294
|
-
<VirtualList
|
|
295
|
-
items={emptyItems}
|
|
296
|
-
variant="fixed"
|
|
297
|
-
height={200}
|
|
298
|
-
itemHeight={60}
|
|
299
|
-
renderItem={({ item, style }) => (
|
|
300
|
-
<Box key={item.id} style={style}>
|
|
301
|
-
<ListItem>
|
|
302
|
-
<ListItemText primary="Should not render" />
|
|
303
|
-
</ListItem>
|
|
304
|
-
</Box>
|
|
305
|
-
)}
|
|
306
|
-
/>
|
|
307
|
-
{emptyItems.length === 0 && (
|
|
308
|
-
<Box
|
|
309
|
-
sx={{
|
|
310
|
-
position: 'absolute',
|
|
311
|
-
top: '60%',
|
|
312
|
-
left: '50%',
|
|
313
|
-
transform: 'translate(-50%, -50%)',
|
|
314
|
-
textAlign: 'center',
|
|
315
|
-
color: 'text.secondary',
|
|
316
|
-
}}
|
|
317
|
-
>
|
|
318
|
-
<Typography variant="body2">No items to display</Typography>
|
|
319
|
-
</Box>
|
|
320
|
-
)}
|
|
321
|
-
</Paper>
|
|
322
|
-
|
|
323
|
-
<Paper sx={{ width: 300, height: 250 }}>
|
|
324
|
-
<Box sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}>
|
|
325
|
-
<Typography variant="subtitle1">Loading State</Typography>
|
|
326
|
-
</Box>
|
|
327
|
-
<VirtualList
|
|
328
|
-
items={loadingItems}
|
|
329
|
-
variant="fixed"
|
|
330
|
-
height={200}
|
|
331
|
-
itemHeight={50}
|
|
332
|
-
renderItem={({ style }) => (
|
|
333
|
-
<Box style={style} sx={{ p: 1 }}>
|
|
334
|
-
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
|
335
|
-
<Box
|
|
336
|
-
sx={{
|
|
337
|
-
width: 32,
|
|
338
|
-
height: 32,
|
|
339
|
-
borderRadius: '50%',
|
|
340
|
-
bgcolor: 'grey.200',
|
|
341
|
-
animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
|
342
|
-
'@keyframes pulse': {
|
|
343
|
-
'0%, 100%': { opacity: 1 },
|
|
344
|
-
'50%': { opacity: 0.5 },
|
|
345
|
-
},
|
|
346
|
-
}}
|
|
347
|
-
/>
|
|
348
|
-
<Box
|
|
349
|
-
sx={{
|
|
350
|
-
height: 12,
|
|
351
|
-
bgcolor: 'grey.200',
|
|
352
|
-
borderRadius: 1,
|
|
353
|
-
width: '60%',
|
|
354
|
-
animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
|
355
|
-
}}
|
|
356
|
-
/>
|
|
357
|
-
</Box>
|
|
358
|
-
</Box>
|
|
359
|
-
)}
|
|
360
|
-
/>
|
|
361
|
-
</Paper>
|
|
362
|
-
|
|
363
|
-
<Paper sx={{ width: 300, height: 250 }}>
|
|
364
|
-
<Box sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}>
|
|
365
|
-
<Typography variant="subtitle1">Error State</Typography>
|
|
366
|
-
</Box>
|
|
367
|
-
<Box
|
|
368
|
-
sx={{
|
|
369
|
-
p: 2,
|
|
370
|
-
textAlign: 'center',
|
|
371
|
-
height: 200,
|
|
372
|
-
display: 'flex',
|
|
373
|
-
flexDirection: 'column',
|
|
374
|
-
alignItems: 'center',
|
|
375
|
-
justifyContent: 'center',
|
|
376
|
-
}}
|
|
377
|
-
>
|
|
378
|
-
<Typography variant="h6" color="error.main" gutterBottom>
|
|
379
|
-
⚠ Error
|
|
380
|
-
</Typography>
|
|
381
|
-
<Typography variant="body2" color="text.secondary">
|
|
382
|
-
Failed to load data
|
|
383
|
-
</Typography>
|
|
384
|
-
</Box>
|
|
385
|
-
</Paper>
|
|
386
|
-
</Box>
|
|
387
|
-
);
|
|
388
|
-
},
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
export const InteractiveStates: Story = {
|
|
392
|
-
render: () => {
|
|
393
|
-
const items = generateItems(100);
|
|
394
|
-
|
|
395
|
-
return (
|
|
396
|
-
<Box sx={{ display: 'flex', gap: 3 }}>
|
|
397
|
-
<Paper sx={{ width: 350, height: 400 }}>
|
|
398
|
-
<Box sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}>
|
|
399
|
-
<Typography variant="subtitle1">Hover Effects</Typography>
|
|
400
|
-
</Box>
|
|
401
|
-
<VirtualList
|
|
402
|
-
items={items}
|
|
403
|
-
variant="fixed"
|
|
404
|
-
height={350}
|
|
405
|
-
itemHeight={70}
|
|
406
|
-
renderItem={({ item, style }) => (
|
|
407
|
-
<Box key={item.id} style={style}>
|
|
408
|
-
<ListItem
|
|
409
|
-
sx={{
|
|
410
|
-
cursor: 'pointer',
|
|
411
|
-
transition: 'all 0.2s ease-in-out',
|
|
412
|
-
'&:hover': {
|
|
413
|
-
bgcolor: 'primary.light',
|
|
414
|
-
transform: 'translateX(4px)',
|
|
415
|
-
boxShadow: '0 2px 4px rgba(0,0,0,0.1)',
|
|
416
|
-
},
|
|
417
|
-
}}
|
|
418
|
-
>
|
|
419
|
-
<ListItemAvatar>
|
|
420
|
-
<Avatar>{item.id + 1}</Avatar>
|
|
421
|
-
</ListItemAvatar>
|
|
422
|
-
<ListItemText primary={item.data.name} secondary="Hover to see effect" />
|
|
423
|
-
</ListItem>
|
|
424
|
-
</Box>
|
|
425
|
-
)}
|
|
426
|
-
/>
|
|
427
|
-
</Paper>
|
|
428
|
-
|
|
429
|
-
<Paper sx={{ width: 350, height: 400, position: 'relative' }}>
|
|
430
|
-
<Box sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}>
|
|
431
|
-
<Typography variant="subtitle1">Disabled State</Typography>
|
|
432
|
-
</Box>
|
|
433
|
-
<VirtualList
|
|
434
|
-
items={items.slice(0, 20)}
|
|
435
|
-
variant="fixed"
|
|
436
|
-
height={350}
|
|
437
|
-
itemHeight={60}
|
|
438
|
-
renderItem={({ item, style }) => (
|
|
439
|
-
<Box key={item.id} style={style}>
|
|
440
|
-
<ListItem
|
|
441
|
-
disabled
|
|
442
|
-
sx={{
|
|
443
|
-
opacity: 0.6,
|
|
444
|
-
cursor: 'not-allowed',
|
|
445
|
-
}}
|
|
446
|
-
>
|
|
447
|
-
<ListItemAvatar>
|
|
448
|
-
<Avatar sx={{ filter: 'grayscale(100%)', opacity: 0.7 }}>{item.id + 1}</Avatar>
|
|
449
|
-
</ListItemAvatar>
|
|
450
|
-
<ListItemText
|
|
451
|
-
primary={
|
|
452
|
-
<Typography sx={{ color: 'text.disabled' }}>{item.data.name}</Typography>
|
|
453
|
-
}
|
|
454
|
-
secondary="Disabled item"
|
|
455
|
-
/>
|
|
456
|
-
</ListItem>
|
|
457
|
-
</Box>
|
|
458
|
-
)}
|
|
459
|
-
/>
|
|
460
|
-
<Box
|
|
461
|
-
sx={{
|
|
462
|
-
position: 'absolute',
|
|
463
|
-
top: 50,
|
|
464
|
-
left: 0,
|
|
465
|
-
right: 0,
|
|
466
|
-
bottom: 0,
|
|
467
|
-
bgcolor: 'rgba(255,255,255,0.7)',
|
|
468
|
-
display: 'flex',
|
|
469
|
-
alignItems: 'center',
|
|
470
|
-
justifyContent: 'center',
|
|
471
|
-
backdropFilter: 'blur(1px)',
|
|
472
|
-
}}
|
|
473
|
-
>
|
|
474
|
-
<Typography variant="h6" color="text.disabled">
|
|
475
|
-
List Disabled
|
|
476
|
-
</Typography>
|
|
477
|
-
</Box>
|
|
478
|
-
</Paper>
|
|
479
|
-
</Box>
|
|
480
|
-
);
|
|
481
|
-
},
|
|
482
|
-
};
|
|
483
|
-
|
|
484
|
-
export const Responsive: Story = {
|
|
485
|
-
render: () => {
|
|
486
|
-
const items = generateItems(500);
|
|
487
|
-
|
|
488
|
-
return (
|
|
489
|
-
<Box
|
|
490
|
-
sx={{
|
|
491
|
-
width: '100%',
|
|
492
|
-
maxWidth: '100vw',
|
|
493
|
-
display: 'flex',
|
|
494
|
-
flexDirection: 'column',
|
|
495
|
-
gap: 2,
|
|
496
|
-
}}
|
|
497
|
-
>
|
|
498
|
-
<Paper sx={{ width: '100%', height: 300 }}>
|
|
499
|
-
<Box sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}>
|
|
500
|
-
<Typography variant="h6">Responsive Width</Typography>
|
|
501
|
-
<Typography variant="body2" color="text.secondary">
|
|
502
|
-
Adapts to container width
|
|
503
|
-
</Typography>
|
|
504
|
-
</Box>
|
|
505
|
-
<VirtualList
|
|
506
|
-
items={items}
|
|
507
|
-
variant="fixed"
|
|
508
|
-
height={250}
|
|
509
|
-
itemHeight={60}
|
|
510
|
-
renderItem={({ item, style }) => (
|
|
511
|
-
<Box key={item.id} style={style}>
|
|
512
|
-
<ListItem>
|
|
513
|
-
<ListItemAvatar>
|
|
514
|
-
<Avatar src={item.data.avatar} />
|
|
515
|
-
</ListItemAvatar>
|
|
516
|
-
<ListItemText primary={item.data.name} secondary="Responsive list item" />
|
|
517
|
-
</ListItem>
|
|
518
|
-
</Box>
|
|
519
|
-
)}
|
|
520
|
-
/>
|
|
521
|
-
</Paper>
|
|
522
|
-
|
|
523
|
-
<Box sx={{ display: 'flex', gap: 2, flexWrap: 'wrap' }}>
|
|
524
|
-
<Paper sx={{ flex: '1 1 300px', minWidth: 250, height: 250 }}>
|
|
525
|
-
<Box sx={{ p: 1, borderBottom: '1px solid', borderColor: 'divider' }}>
|
|
526
|
-
<Typography variant="subtitle2">Mobile Size</Typography>
|
|
527
|
-
</Box>
|
|
528
|
-
<VirtualList
|
|
529
|
-
items={items}
|
|
530
|
-
variant="fixed"
|
|
531
|
-
height={220}
|
|
532
|
-
itemHeight={50}
|
|
533
|
-
renderItem={({ item, style }) => (
|
|
534
|
-
<Box key={item.id} style={style}>
|
|
535
|
-
<ListItem dense>
|
|
536
|
-
<ListItemAvatar>
|
|
537
|
-
<Avatar size="small">{item.id + 1}</Avatar>
|
|
538
|
-
</ListItemAvatar>
|
|
539
|
-
<ListItemText primary={`Item ${item.id + 1}`} />
|
|
540
|
-
</ListItem>
|
|
541
|
-
</Box>
|
|
542
|
-
)}
|
|
543
|
-
/>
|
|
544
|
-
</Paper>
|
|
545
|
-
|
|
546
|
-
<Paper sx={{ flex: '2 1 400px', minWidth: 350, height: 250 }}>
|
|
547
|
-
<Box sx={{ p: 1, borderBottom: '1px solid', borderColor: 'divider' }}>
|
|
548
|
-
<Typography variant="subtitle2">Desktop Size</Typography>
|
|
549
|
-
</Box>
|
|
550
|
-
<VirtualList
|
|
551
|
-
items={items}
|
|
552
|
-
variant="fixed"
|
|
553
|
-
height={220}
|
|
554
|
-
itemHeight={60}
|
|
555
|
-
renderItem={({ item, style }) => (
|
|
556
|
-
<Box key={item.id} style={style}>
|
|
557
|
-
<ListItem>
|
|
558
|
-
<ListItemAvatar>
|
|
559
|
-
<Avatar>{item.id + 1}</Avatar>
|
|
560
|
-
</ListItemAvatar>
|
|
561
|
-
<ListItemText primary={item.data.name} secondary={item.data.description} />
|
|
562
|
-
</ListItem>
|
|
563
|
-
</Box>
|
|
564
|
-
)}
|
|
565
|
-
/>
|
|
566
|
-
</Paper>
|
|
567
|
-
</Box>
|
|
568
|
-
</Box>
|
|
569
|
-
);
|
|
570
|
-
},
|
|
571
|
-
};
|
|
572
|
-
|
|
573
|
-
export const FixedHeightList: Story = {
|
|
574
|
-
render: () => {
|
|
575
|
-
const items = generateItems(10000);
|
|
576
|
-
|
|
577
|
-
return (
|
|
578
|
-
<Paper sx={{ width: 400, height: 400 }}>
|
|
579
|
-
<VirtualList
|
|
580
|
-
items={items}
|
|
581
|
-
variant="fixed"
|
|
582
|
-
height={400}
|
|
583
|
-
itemHeight={80}
|
|
584
|
-
renderItem={({ item, style }) => (
|
|
585
|
-
<Box key={item.id} style={style}>
|
|
586
|
-
<ListItem>
|
|
587
|
-
<ListItemAvatar>
|
|
588
|
-
<Avatar src={item.data.avatar} />
|
|
589
|
-
</ListItemAvatar>
|
|
590
|
-
<ListItemText primary={item.data.name} secondary={item.data.description} />
|
|
591
|
-
</ListItem>
|
|
592
|
-
</Box>
|
|
593
|
-
)}
|
|
594
|
-
/>
|
|
595
|
-
</Paper>
|
|
596
|
-
);
|
|
597
|
-
},
|
|
598
|
-
};
|
|
599
|
-
|
|
600
|
-
export const VariableHeightList: Story = {
|
|
601
|
-
render: () => {
|
|
602
|
-
const items = generateVariableItems(5000);
|
|
603
|
-
|
|
604
|
-
return (
|
|
605
|
-
<Paper sx={{ width: 400, height: 400 }}>
|
|
606
|
-
<VirtualList
|
|
607
|
-
items={items}
|
|
608
|
-
variant="variable"
|
|
609
|
-
height={400}
|
|
610
|
-
estimatedItemHeight={100}
|
|
611
|
-
renderItem={({ item, style }) => (
|
|
612
|
-
<Box key={item.id} style={style}>
|
|
613
|
-
<ListItem sx={{ alignItems: 'flex-start' }}>
|
|
614
|
-
<ListItemAvatar>
|
|
615
|
-
<Avatar src={item.data.avatar} />
|
|
616
|
-
</ListItemAvatar>
|
|
617
|
-
<ListItemText
|
|
618
|
-
primary={item.data.name}
|
|
619
|
-
secondary={
|
|
620
|
-
<Typography variant="body2" color="text.secondary">
|
|
621
|
-
{item.data.description}
|
|
622
|
-
</Typography>
|
|
623
|
-
}
|
|
624
|
-
/>
|
|
625
|
-
</ListItem>
|
|
626
|
-
</Box>
|
|
627
|
-
)}
|
|
628
|
-
/>
|
|
629
|
-
</Paper>
|
|
630
|
-
);
|
|
631
|
-
},
|
|
632
|
-
};
|
|
633
|
-
|
|
634
|
-
export const GridLayout: Story = {
|
|
635
|
-
render: () => {
|
|
636
|
-
const items = generateItems(10000);
|
|
637
|
-
|
|
638
|
-
return (
|
|
639
|
-
<Paper sx={{ width: 600, height: 400 }}>
|
|
640
|
-
<VirtualGrid
|
|
641
|
-
items={items}
|
|
642
|
-
height={400}
|
|
643
|
-
width={600}
|
|
644
|
-
columnCount={4}
|
|
645
|
-
rowHeight={150}
|
|
646
|
-
gap={8}
|
|
647
|
-
renderItem={({ item, style }) => (
|
|
648
|
-
<Box
|
|
649
|
-
key={item.id}
|
|
650
|
-
style={style}
|
|
651
|
-
sx={{
|
|
652
|
-
p: 2,
|
|
653
|
-
bgcolor: 'background.paper',
|
|
654
|
-
border: '1px solid',
|
|
655
|
-
borderColor: 'divider',
|
|
656
|
-
borderRadius: 2,
|
|
657
|
-
display: 'flex',
|
|
658
|
-
flexDirection: 'column',
|
|
659
|
-
alignItems: 'center',
|
|
660
|
-
textAlign: 'center',
|
|
661
|
-
}}
|
|
662
|
-
>
|
|
663
|
-
<Avatar src={item.data.avatar} sx={{ width: 56, height: 56, mb: 1 }} />
|
|
664
|
-
<Typography variant="body2" fontWeight="bold">
|
|
665
|
-
{item.data.name}
|
|
666
|
-
</Typography>
|
|
667
|
-
<Typography variant="caption" color="text.secondary">
|
|
668
|
-
Grid Item #{item.id + 1}
|
|
669
|
-
</Typography>
|
|
670
|
-
</Box>
|
|
671
|
-
)}
|
|
672
|
-
/>
|
|
673
|
-
</Paper>
|
|
674
|
-
);
|
|
675
|
-
},
|
|
676
|
-
};
|
|
677
|
-
|
|
678
|
-
export const LargeDataset: Story = {
|
|
679
|
-
render: () => {
|
|
680
|
-
const items = generateItems(100000); // 100k items
|
|
681
|
-
|
|
682
|
-
return (
|
|
683
|
-
<Box sx={{ display: 'flex', gap: 3 }}>
|
|
684
|
-
<Paper sx={{ width: 350, height: 500 }}>
|
|
685
|
-
<Box sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}>
|
|
686
|
-
<Typography variant="h6">100,000 Items</Typography>
|
|
687
|
-
<Typography variant="body2" color="text.secondary">
|
|
688
|
-
Fixed height virtual list
|
|
689
|
-
</Typography>
|
|
690
|
-
</Box>
|
|
691
|
-
<VirtualList
|
|
692
|
-
items={items}
|
|
693
|
-
variant="fixed"
|
|
694
|
-
height={450}
|
|
695
|
-
itemHeight={60}
|
|
696
|
-
renderItem={({ item, style }) => (
|
|
697
|
-
<Box key={item.id} style={style}>
|
|
698
|
-
<ListItem>
|
|
699
|
-
<ListItemAvatar>
|
|
700
|
-
<Avatar>{item.id + 1}</Avatar>
|
|
701
|
-
</ListItemAvatar>
|
|
702
|
-
<ListItemText
|
|
703
|
-
primary={`Item ${item.id + 1}`}
|
|
704
|
-
secondary={`Performance test item #${item.id + 1}`}
|
|
705
|
-
/>
|
|
706
|
-
</ListItem>
|
|
707
|
-
</Box>
|
|
708
|
-
)}
|
|
709
|
-
/>
|
|
710
|
-
</Paper>
|
|
711
|
-
|
|
712
|
-
<Paper sx={{ width: 400, height: 500 }}>
|
|
713
|
-
<Box sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}>
|
|
714
|
-
<Typography variant="h6">Grid View</Typography>
|
|
715
|
-
<Typography variant="body2" color="text.secondary">
|
|
716
|
-
25,000 items in grid layout
|
|
717
|
-
</Typography>
|
|
718
|
-
</Box>
|
|
719
|
-
<VirtualGrid
|
|
720
|
-
items={items.slice(0, 25000)}
|
|
721
|
-
height={450}
|
|
722
|
-
width={400}
|
|
723
|
-
columnCount={3}
|
|
724
|
-
rowHeight={120}
|
|
725
|
-
gap={4}
|
|
726
|
-
renderItem={({ item, style }) => (
|
|
727
|
-
<Box
|
|
728
|
-
key={item.id}
|
|
729
|
-
style={style}
|
|
730
|
-
sx={{
|
|
731
|
-
bgcolor: 'primary.light',
|
|
732
|
-
borderRadius: 1,
|
|
733
|
-
display: 'flex',
|
|
734
|
-
alignItems: 'center',
|
|
735
|
-
justifyContent: 'center',
|
|
736
|
-
color: 'primary.contrastText',
|
|
737
|
-
fontWeight: 'bold',
|
|
738
|
-
}}
|
|
739
|
-
>
|
|
740
|
-
#{item.id + 1}
|
|
741
|
-
</Box>
|
|
742
|
-
)}
|
|
743
|
-
/>
|
|
744
|
-
</Paper>
|
|
745
|
-
</Box>
|
|
746
|
-
);
|
|
747
|
-
},
|
|
748
|
-
};
|
|
749
|
-
|
|
750
|
-
export const CustomStyles: Story = {
|
|
751
|
-
render: () => {
|
|
752
|
-
const items = generateItems(1000);
|
|
753
|
-
|
|
754
|
-
return (
|
|
755
|
-
<Paper
|
|
756
|
-
sx={{
|
|
757
|
-
width: 500,
|
|
758
|
-
height: 400,
|
|
759
|
-
background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
|
|
760
|
-
}}
|
|
761
|
-
>
|
|
762
|
-
<VirtualList
|
|
763
|
-
items={items}
|
|
764
|
-
variant="fixed"
|
|
765
|
-
height={400}
|
|
766
|
-
itemHeight={100}
|
|
767
|
-
renderItem={({ item, index, style }) => (
|
|
768
|
-
<Box
|
|
769
|
-
key={item.id}
|
|
770
|
-
style={style}
|
|
771
|
-
sx={{
|
|
772
|
-
px: 2,
|
|
773
|
-
display: 'flex',
|
|
774
|
-
alignItems: 'center',
|
|
775
|
-
}}
|
|
776
|
-
>
|
|
777
|
-
<Box
|
|
778
|
-
sx={{
|
|
779
|
-
width: '100%',
|
|
780
|
-
p: 2,
|
|
781
|
-
bgcolor: 'rgba(255,255,255,0.1)',
|
|
782
|
-
backdropFilter: 'blur(10px)',
|
|
783
|
-
borderRadius: 2,
|
|
784
|
-
border: '1px solid rgba(255,255,255,0.2)',
|
|
785
|
-
display: 'flex',
|
|
786
|
-
alignItems: 'center',
|
|
787
|
-
gap: 2,
|
|
788
|
-
}}
|
|
789
|
-
>
|
|
790
|
-
<Avatar
|
|
791
|
-
src={item.data.avatar}
|
|
792
|
-
sx={{
|
|
793
|
-
border: '2px solid rgba(255,255,255,0.3)',
|
|
794
|
-
}}
|
|
795
|
-
/>
|
|
796
|
-
<Box sx={{ flex: 1 }}>
|
|
797
|
-
<Typography variant="subtitle1" sx={{ color: 'white', fontWeight: 'bold' }}>
|
|
798
|
-
{item.data.name}
|
|
799
|
-
</Typography>
|
|
800
|
-
<Typography variant="body2" sx={{ color: 'rgba(255,255,255,0.8)' }}>
|
|
801
|
-
Glass morphism style • Item {index + 1}
|
|
802
|
-
</Typography>
|
|
803
|
-
</Box>
|
|
804
|
-
</Box>
|
|
805
|
-
</Box>
|
|
806
|
-
)}
|
|
807
|
-
/>
|
|
808
|
-
</Paper>
|
|
809
|
-
);
|
|
810
|
-
},
|
|
811
|
-
};
|
|
812
|
-
|
|
813
|
-
export const EmptyState: Story = {
|
|
814
|
-
render: () => {
|
|
815
|
-
const emptyItems: VirtualListItem[] = [];
|
|
816
|
-
|
|
817
|
-
return (
|
|
818
|
-
<Paper sx={{ width: 400, height: 300, position: 'relative' }}>
|
|
819
|
-
<VirtualList
|
|
820
|
-
items={emptyItems}
|
|
821
|
-
variant="fixed"
|
|
822
|
-
height={300}
|
|
823
|
-
itemHeight={60}
|
|
824
|
-
renderItem={({ item, style }) => (
|
|
825
|
-
<Box key={item.id} style={style}>
|
|
826
|
-
<ListItem>
|
|
827
|
-
<ListItemText primary="This should not render" />
|
|
828
|
-
</ListItem>
|
|
829
|
-
</Box>
|
|
830
|
-
)}
|
|
831
|
-
/>
|
|
832
|
-
{emptyItems.length === 0 && (
|
|
833
|
-
<Box
|
|
834
|
-
sx={{
|
|
835
|
-
position: 'absolute',
|
|
836
|
-
top: '50%',
|
|
837
|
-
left: '50%',
|
|
838
|
-
transform: 'translate(-50%, -50%)',
|
|
839
|
-
textAlign: 'center',
|
|
840
|
-
color: 'text.secondary',
|
|
841
|
-
}}
|
|
842
|
-
>
|
|
843
|
-
<Typography variant="h6" gutterBottom>
|
|
844
|
-
No items to display
|
|
845
|
-
</Typography>
|
|
846
|
-
<Typography variant="body2">The virtual list is empty</Typography>
|
|
847
|
-
</Box>
|
|
848
|
-
)}
|
|
849
|
-
</Paper>
|
|
850
|
-
);
|
|
851
|
-
},
|
|
852
|
-
};
|
|
853
|
-
|
|
854
|
-
export const LoadingState: Story = {
|
|
855
|
-
render: () => {
|
|
856
|
-
const loadingItems = Array.from({ length: 8 }, (_, i) => ({ id: i }));
|
|
857
|
-
|
|
858
|
-
return (
|
|
859
|
-
<Paper sx={{ width: 400, height: 300 }}>
|
|
860
|
-
<VirtualList
|
|
861
|
-
items={loadingItems}
|
|
862
|
-
variant="fixed"
|
|
863
|
-
height={300}
|
|
864
|
-
itemHeight={60}
|
|
865
|
-
renderItem={({ style }) => (
|
|
866
|
-
<Box style={style} sx={{ p: 2 }}>
|
|
867
|
-
<Box sx={{ display: 'flex', alignItems: 'center', gap: 2 }}>
|
|
868
|
-
<Box
|
|
869
|
-
sx={{
|
|
870
|
-
width: 40,
|
|
871
|
-
height: 40,
|
|
872
|
-
borderRadius: '50%',
|
|
873
|
-
bgcolor: 'grey.200',
|
|
874
|
-
animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
|
875
|
-
'@keyframes pulse': {
|
|
876
|
-
'0%, 100%': {
|
|
877
|
-
opacity: 1,
|
|
878
|
-
},
|
|
879
|
-
'50%': {
|
|
880
|
-
opacity: 0.5,
|
|
881
|
-
},
|
|
882
|
-
},
|
|
883
|
-
}}
|
|
884
|
-
/>
|
|
885
|
-
<Box sx={{ flex: 1 }}>
|
|
886
|
-
<Box
|
|
887
|
-
sx={{
|
|
888
|
-
height: 16,
|
|
889
|
-
bgcolor: 'grey.200',
|
|
890
|
-
borderRadius: 1,
|
|
891
|
-
mb: 1,
|
|
892
|
-
width: '70%',
|
|
893
|
-
animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
|
894
|
-
}}
|
|
895
|
-
/>
|
|
896
|
-
<Box
|
|
897
|
-
sx={{
|
|
898
|
-
height: 12,
|
|
899
|
-
bgcolor: 'grey.200',
|
|
900
|
-
borderRadius: 1,
|
|
901
|
-
width: '50%',
|
|
902
|
-
animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
|
903
|
-
}}
|
|
904
|
-
/>
|
|
905
|
-
</Box>
|
|
906
|
-
</Box>
|
|
907
|
-
</Box>
|
|
908
|
-
)}
|
|
909
|
-
/>
|
|
910
|
-
</Paper>
|
|
911
|
-
);
|
|
912
|
-
},
|
|
913
|
-
};
|
|
914
|
-
|
|
915
|
-
export const HoverState: Story = {
|
|
916
|
-
render: () => {
|
|
917
|
-
const items = generateItems(100);
|
|
918
|
-
|
|
919
|
-
return (
|
|
920
|
-
<Paper sx={{ width: 400, height: 300 }}>
|
|
921
|
-
<VirtualList
|
|
922
|
-
items={items}
|
|
923
|
-
variant="fixed"
|
|
924
|
-
height={300}
|
|
925
|
-
itemHeight={70}
|
|
926
|
-
renderItem={({ item, style }) => (
|
|
927
|
-
<Box key={item.id} style={style}>
|
|
928
|
-
<ListItem
|
|
929
|
-
sx={{
|
|
930
|
-
cursor: 'pointer',
|
|
931
|
-
transition: 'all 0.2s ease-in-out',
|
|
932
|
-
'&:hover': {
|
|
933
|
-
bgcolor: 'primary.light',
|
|
934
|
-
transform: 'translateX(8px)',
|
|
935
|
-
boxShadow: '0 4px 8px rgba(0,0,0,0.12)',
|
|
936
|
-
},
|
|
937
|
-
}}
|
|
938
|
-
>
|
|
939
|
-
<ListItemAvatar>
|
|
940
|
-
<Avatar src={item.data.avatar} />
|
|
941
|
-
</ListItemAvatar>
|
|
942
|
-
<ListItemText primary={item.data.name} secondary="Hover to see effect" />
|
|
943
|
-
</ListItem>
|
|
944
|
-
</Box>
|
|
945
|
-
)}
|
|
946
|
-
/>
|
|
947
|
-
</Paper>
|
|
948
|
-
);
|
|
949
|
-
},
|
|
950
|
-
};
|
|
951
|
-
|
|
952
|
-
export const DisabledState: Story = {
|
|
953
|
-
render: () => {
|
|
954
|
-
const items = generateItems(50);
|
|
955
|
-
|
|
956
|
-
return (
|
|
957
|
-
<Paper sx={{ width: 400, height: 300, position: 'relative' }}>
|
|
958
|
-
<VirtualList
|
|
959
|
-
items={items}
|
|
960
|
-
variant="fixed"
|
|
961
|
-
height={300}
|
|
962
|
-
itemHeight={60}
|
|
963
|
-
renderItem={({ item, style }) => (
|
|
964
|
-
<Box key={item.id} style={style}>
|
|
965
|
-
<ListItem
|
|
966
|
-
disabled
|
|
967
|
-
sx={{
|
|
968
|
-
opacity: 0.6,
|
|
969
|
-
cursor: 'not-allowed',
|
|
970
|
-
'&:hover': {
|
|
971
|
-
bgcolor: 'transparent',
|
|
972
|
-
},
|
|
973
|
-
}}
|
|
974
|
-
>
|
|
975
|
-
<ListItemAvatar>
|
|
976
|
-
<Avatar
|
|
977
|
-
src={item.data.avatar}
|
|
978
|
-
sx={{
|
|
979
|
-
filter: 'grayscale(100%)',
|
|
980
|
-
opacity: 0.7,
|
|
981
|
-
}}
|
|
982
|
-
/>
|
|
983
|
-
</ListItemAvatar>
|
|
984
|
-
<ListItemText
|
|
985
|
-
primary={
|
|
986
|
-
<Typography sx={{ color: 'text.disabled' }}>{item.data.name}</Typography>
|
|
987
|
-
}
|
|
988
|
-
secondary={<Typography sx={{ color: 'text.disabled' }}>Disabled item</Typography>}
|
|
989
|
-
/>
|
|
990
|
-
</ListItem>
|
|
991
|
-
</Box>
|
|
992
|
-
)}
|
|
993
|
-
/>
|
|
994
|
-
<Box
|
|
995
|
-
sx={{
|
|
996
|
-
position: 'absolute',
|
|
997
|
-
top: 0,
|
|
998
|
-
left: 0,
|
|
999
|
-
right: 0,
|
|
1000
|
-
bottom: 0,
|
|
1001
|
-
bgcolor: 'rgba(255,255,255,0.7)',
|
|
1002
|
-
display: 'flex',
|
|
1003
|
-
alignItems: 'center',
|
|
1004
|
-
justifyContent: 'center',
|
|
1005
|
-
backdropFilter: 'blur(1px)',
|
|
1006
|
-
}}
|
|
1007
|
-
>
|
|
1008
|
-
<Typography variant="h6" color="text.disabled">
|
|
1009
|
-
List Disabled
|
|
1010
|
-
</Typography>
|
|
1011
|
-
</Box>
|
|
1012
|
-
</Paper>
|
|
1013
|
-
);
|
|
1014
|
-
},
|
|
1015
|
-
};
|
|
1016
|
-
|
|
1017
|
-
export const ErrorState: Story = {
|
|
1018
|
-
render: () => (
|
|
1019
|
-
<Paper sx={{ width: 400, height: 300 }}>
|
|
1020
|
-
<Box sx={{ p: 3, textAlign: 'center' }}>
|
|
1021
|
-
<Box
|
|
1022
|
-
sx={{
|
|
1023
|
-
width: 80,
|
|
1024
|
-
height: 80,
|
|
1025
|
-
mx: 'auto',
|
|
1026
|
-
mb: 2,
|
|
1027
|
-
borderRadius: '50%',
|
|
1028
|
-
bgcolor: 'error.light',
|
|
1029
|
-
display: 'flex',
|
|
1030
|
-
alignItems: 'center',
|
|
1031
|
-
justifyContent: 'center',
|
|
1032
|
-
}}
|
|
1033
|
-
>
|
|
1034
|
-
<Typography variant="h4" color="error.main">
|
|
1035
|
-
⚠
|
|
1036
|
-
</Typography>
|
|
1037
|
-
</Box>
|
|
1038
|
-
<Typography variant="h6" color="error.main" gutterBottom>
|
|
1039
|
-
Failed to Load Data
|
|
1040
|
-
</Typography>
|
|
1041
|
-
<Typography variant="body2" color="text.secondary" sx={{ mb: 3 }}>
|
|
1042
|
-
Unable to fetch virtual list items. Please try again.
|
|
1043
|
-
</Typography>
|
|
1044
|
-
<Box sx={{ display: 'flex', gap: 1, justifyContent: 'center' }}>
|
|
1045
|
-
<button
|
|
1046
|
-
style={{
|
|
1047
|
-
padding: '8px 16px',
|
|
1048
|
-
backgroundColor: '#1976d2',
|
|
1049
|
-
color: 'white',
|
|
1050
|
-
border: 'none',
|
|
1051
|
-
borderRadius: '4px',
|
|
1052
|
-
cursor: 'pointer',
|
|
1053
|
-
}}
|
|
1054
|
-
>
|
|
1055
|
-
Retry
|
|
1056
|
-
</button>
|
|
1057
|
-
<button
|
|
1058
|
-
style={{
|
|
1059
|
-
padding: '8px 16px',
|
|
1060
|
-
backgroundColor: 'transparent',
|
|
1061
|
-
color: '#1976d2',
|
|
1062
|
-
border: '1px solid #1976d2',
|
|
1063
|
-
borderRadius: '4px',
|
|
1064
|
-
cursor: 'pointer',
|
|
1065
|
-
}}
|
|
1066
|
-
>
|
|
1067
|
-
Cancel
|
|
1068
|
-
</button>
|
|
1069
|
-
</Box>
|
|
1070
|
-
</Box>
|
|
1071
|
-
</Paper>
|
|
1072
|
-
),
|
|
1073
|
-
};
|