@12-apps/ui 1.4.1 → 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.
Files changed (229) hide show
  1. package/package.json +17 -8
  2. package/src/button/index.ts +1 -0
  3. package/src/social-login-button/index.ts +1 -0
  4. package/src/{social-login-button.tsx → social-login-button/social-login-button.tsx} +5 -5
  5. package/src/user-avatar/index.ts +1 -0
  6. package/src/{user-avatar.tsx → user-avatar/user-avatar.tsx} +4 -4
  7. package/eslint.config.js +0 -77
  8. package/src/__tests__/data-grid.test.tsx +0 -125
  9. package/src/__tests__/package-wiring.test.ts +0 -41
  10. package/src/__tests__/setup.ts +0 -1
  11. package/src/__tests__/social-login-button.test.tsx +0 -186
  12. package/src/__tests__/user-avatar.test.tsx +0 -195
  13. package/src/__tests__/viewport.test.ts +0 -50
  14. package/src/components/command/__tests__/command.test.tsx +0 -112
  15. package/src/components/data-display/Alert/Alert.stories.tsx +0 -559
  16. package/src/components/data-display/Alert/Alert.test.stories.tsx +0 -707
  17. package/src/components/data-display/AlertDialog/AlertDialog.stories.tsx +0 -362
  18. package/src/components/data-display/AlertDialog/AlertDialog.test.stories.tsx +0 -753
  19. package/src/components/data-display/AsyncStateContainer/AsyncStateContainer.stories.tsx +0 -230
  20. package/src/components/data-display/AsyncStateContainer/AsyncStateContainer.test.stories.tsx +0 -270
  21. package/src/components/data-display/Avatar/Avatar.stories.tsx +0 -721
  22. package/src/components/data-display/Avatar/Avatar.test.stories.tsx +0 -822
  23. package/src/components/data-display/Badge/Badge.stories.tsx +0 -1134
  24. package/src/components/data-display/Badge/Badge.test.stories.tsx +0 -1194
  25. package/src/components/data-display/Banner/Banner.stories.tsx +0 -528
  26. package/src/components/data-display/Banner/Banner.test.stories.tsx +0 -503
  27. package/src/components/data-display/Carousel/Carousel.stories.tsx +0 -607
  28. package/src/components/data-display/Carousel/Carousel.test.stories.tsx +0 -691
  29. package/src/components/data-display/Chart/Chart.stories.tsx +0 -568
  30. package/src/components/data-display/Chart/Chart.test.stories.tsx +0 -174
  31. package/src/components/data-display/Chart/SpecChart.stories.tsx +0 -150
  32. package/src/components/data-display/Chart/SpecChart.test.stories.tsx +0 -56
  33. package/src/components/data-display/Chart/__tests__/SpecChart.test.tsx +0 -60
  34. package/src/components/data-display/Chart/__tests__/chart-format.test.ts +0 -43
  35. package/src/components/data-display/Chart/__tests__/chart-spec.test.ts +0 -119
  36. package/src/components/data-display/Chip/Chip.stories.tsx +0 -252
  37. package/src/components/data-display/Chip/Chip.test.stories.tsx +0 -266
  38. package/src/components/data-display/DataGrid/DataGrid.stories.tsx +0 -515
  39. package/src/components/data-display/DataGrid/DataGrid.test.stories.tsx +0 -653
  40. package/src/components/data-display/DataViews/__tests__/DataViewsGrid.test.tsx +0 -271
  41. package/src/components/data-display/DataViews/__tests__/DataViewsTableBase.test.tsx +0 -134
  42. package/src/components/data-display/DataViews/__tests__/SaveViewModal.test.tsx +0 -83
  43. package/src/components/data-display/DataViews/__tests__/data-views-filter.test.ts +0 -115
  44. package/src/components/data-display/DataViews/__tests__/data-views-preview.test.ts +0 -53
  45. package/src/components/data-display/DataViews/__tests__/range-pill.test.tsx +0 -114
  46. package/src/components/data-display/DataViews/base-card.stories.tsx +0 -136
  47. package/src/components/data-display/DescriptionItem/DescriptionItem.stories.tsx +0 -254
  48. package/src/components/data-display/EmptyState/EmptyState.stories.tsx +0 -282
  49. package/src/components/data-display/EmptyState/EmptyState.test.stories.tsx +0 -441
  50. package/src/components/data-display/ErrorState/ErrorState.stories.tsx +0 -110
  51. package/src/components/data-display/ErrorState/ErrorState.test.stories.tsx +0 -133
  52. package/src/components/data-display/HoverCard/HoverCard.stories.tsx +0 -650
  53. package/src/components/data-display/HoverCard/HoverCard.test.stories.tsx +0 -929
  54. package/src/components/data-display/InteractiveTooltip/InteractiveTooltip.stories.tsx +0 -411
  55. package/src/components/data-display/LazyImage/LazyImage.stories.tsx +0 -387
  56. package/src/components/data-display/Lightbox/Lightbox.stories.tsx +0 -315
  57. package/src/components/data-display/Lightbox/Lightbox.test.stories.tsx +0 -598
  58. package/src/components/data-display/LoadingState/LoadingState.stories.tsx +0 -124
  59. package/src/components/data-display/LoadingState/LoadingState.test.stories.tsx +0 -99
  60. package/src/components/data-display/MapPreview/MapPreview.stories.tsx +0 -458
  61. package/src/components/data-display/MapPreview/MapPreview.test.stories.tsx +0 -394
  62. package/src/components/data-display/Popover/Popover.stories.tsx +0 -295
  63. package/src/components/data-display/Popover/Popover.test.stories.tsx +0 -1162
  64. package/src/components/data-display/Progress/Progress.stories.tsx +0 -481
  65. package/src/components/data-display/Progress/Progress.test.stories.tsx +0 -2070
  66. package/src/components/data-display/SectionOnboarding/SectionOnboarding.stories.tsx +0 -160
  67. package/src/components/data-display/SectionOnboarding/SectionOnboarding.test.stories.tsx +0 -190
  68. package/src/components/data-display/Sheet/Sheet.stories.tsx +0 -883
  69. package/src/components/data-display/Sheet/Sheet.test.stories.tsx +0 -1101
  70. package/src/components/data-display/StatCard/StatCard.stories.tsx +0 -167
  71. package/src/components/data-display/StatCard/StatCard.test.stories.tsx +0 -240
  72. package/src/components/data-display/Stepper/Stepper.stories.tsx +0 -540
  73. package/src/components/data-display/Stepper/Stepper.test.stories.tsx +0 -600
  74. package/src/components/data-display/Table/Table.stories.tsx +0 -803
  75. package/src/components/data-display/Table/Table.test.stories.tsx +0 -369
  76. package/src/components/data-display/Timeline/Timeline.stories.tsx +0 -442
  77. package/src/components/data-display/Timeline/Timeline.test.stories.tsx +0 -930
  78. package/src/components/data-display/TimingDiagram/TimingDiagram.stories.tsx +0 -475
  79. package/src/components/data-display/TimingDiagram/TimingDiagram.test.stories.tsx +0 -734
  80. package/src/components/data-display/Tooltip/Tooltip.stories.tsx +0 -468
  81. package/src/components/data-display/Tooltip/Tooltip.test.stories.tsx +0 -1154
  82. package/src/components/feedback/ConfirmAction/ConfirmAction.stories.tsx +0 -146
  83. package/src/components/feedback/ConfirmAction/ConfirmAction.test.stories.tsx +0 -114
  84. package/src/components/feedback/ConfirmAction/__tests__/confirm-action.test.tsx +0 -288
  85. package/src/components/feedback/Dialog/Dialog.stories.tsx +0 -833
  86. package/src/components/feedback/Dialog/Dialog.test.stories.tsx +0 -955
  87. package/src/components/feedback/Dialog/__tests__/dialog-content-spacing.test.tsx +0 -66
  88. package/src/components/feedback/Modal/Modal.stories.tsx +0 -765
  89. package/src/components/feedback/Modal/Modal.test.stories.tsx +0 -251
  90. package/src/components/feedback/Sonner/Sonner.stories.tsx +0 -698
  91. package/src/components/feedback/Sonner/Sonner.test.stories.tsx +0 -896
  92. package/src/components/feedback/StackedModal/StackedModal.stories.tsx +0 -1783
  93. package/src/components/feedback/StackedModal/StackedModal.test.stories.tsx +0 -975
  94. package/src/components/feedback/StackedModal/__tests__/stacked-modal-viewport.test.tsx +0 -104
  95. package/src/components/feedback/Toast/Toast.stories.tsx +0 -548
  96. package/src/components/feedback/Toast/Toast.test.stories.tsx +0 -834
  97. package/src/components/feedback/TutorialOverlay/TutorialOverlay.stories.tsx +0 -691
  98. package/src/components/feedback/TutorialOverlay/TutorialOverlay.test.stories.tsx +0 -634
  99. package/src/components/form/AddressAutocomplete/AddressAutocomplete.stories.tsx +0 -665
  100. package/src/components/form/AddressAutocomplete/AddressAutocomplete.test.stories.tsx +0 -727
  101. package/src/components/form/Autocomplete/Autocomplete.stories.tsx +0 -715
  102. package/src/components/form/Autocomplete/Autocomplete.test.stories.tsx +0 -825
  103. package/src/components/form/Button/Button.stories.tsx +0 -365
  104. package/src/components/form/Button/Button.test.stories.tsx +0 -607
  105. package/src/components/form/Calendar/Calendar.stories.tsx +0 -349
  106. package/src/components/form/Calendar/Calendar.test.stories.tsx +0 -464
  107. package/src/components/form/CepField/CepField.stories.tsx +0 -138
  108. package/src/components/form/CepField/CepField.test.stories.tsx +0 -281
  109. package/src/components/form/Checkbox/Checkbox.stories.tsx +0 -265
  110. package/src/components/form/Checkbox/Checkbox.test.stories.tsx +0 -181
  111. package/src/components/form/CodeEditor/CodeEditor.stories.tsx +0 -871
  112. package/src/components/form/CodeEditor/CodeEditor.test.stories.tsx +0 -574
  113. package/src/components/form/Command/Command.stories.tsx +0 -580
  114. package/src/components/form/Command/Command.test.stories.tsx +0 -215
  115. package/src/components/form/CreatableSelect/CreatableSelect.stories.tsx +0 -112
  116. package/src/components/form/CreatableSelect/CreatableSelect.test.stories.tsx +0 -134
  117. package/src/components/form/Form/Form.stories.tsx +0 -687
  118. package/src/components/form/Form/Form.test.stories.tsx +0 -601
  119. package/src/components/form/Input/Input.stories.tsx +0 -260
  120. package/src/components/form/Input/Input.test.stories.tsx +0 -1191
  121. package/src/components/form/InputOTP/InputOTP.stories.tsx +0 -774
  122. package/src/components/form/InputOTP/InputOTP.test.stories.tsx +0 -588
  123. package/src/components/form/Label/Label.stories.tsx +0 -473
  124. package/src/components/form/Label/Label.test.stories.tsx +0 -909
  125. package/src/components/form/Menubar/Menubar.stories.tsx +0 -472
  126. package/src/components/form/Menubar/Menubar.test.stories.tsx +0 -584
  127. package/src/components/form/PasswordStrength/PasswordStrength.stories.tsx +0 -562
  128. package/src/components/form/PasswordStrength/PasswordStrength.test.stories.tsx +0 -327
  129. package/src/components/form/PhoneInput/PhoneInput.stories.tsx +0 -495
  130. package/src/components/form/PhoneInput/PhoneInput.test.stories.tsx +0 -666
  131. package/src/components/form/RadioGroup/RadioGroup.stories.tsx +0 -518
  132. package/src/components/form/RadioGroup/RadioGroup.test.stories.tsx +0 -685
  133. package/src/components/form/RichTextEditor/RichTextEditor.stories.tsx +0 -261
  134. package/src/components/form/RichTextEditor/RichTextEditor.test.stories.tsx +0 -491
  135. package/src/components/form/SearchPalette/SearchPalette.stories.tsx +0 -135
  136. package/src/components/form/Select/Select.stories.tsx +0 -364
  137. package/src/components/form/Select/Select.test.stories.tsx +0 -985
  138. package/src/components/form/Slider/Slider.stories.tsx +0 -418
  139. package/src/components/form/Slider/Slider.test.stories.tsx +0 -1042
  140. package/src/components/form/Switch/Switch.stories.tsx +0 -697
  141. package/src/components/form/Switch/Switch.test.stories.tsx +0 -597
  142. package/src/components/form/Textarea/Textarea.stories.tsx +0 -473
  143. package/src/components/form/Textarea/Textarea.test.stories.tsx +0 -702
  144. package/src/components/form/Toggle/Toggle.stories.tsx +0 -638
  145. package/src/components/form/Toggle/Toggle.test.stories.tsx +0 -1159
  146. package/src/components/form/ToggleGroup/ToggleGroup.stories.tsx +0 -617
  147. package/src/components/form/ToggleGroup/ToggleGroup.test.stories.tsx +0 -918
  148. package/src/components/form/UploadButton/UploadButton.stories.tsx +0 -367
  149. package/src/components/form/UploadButton/UploadButton.test.stories.tsx +0 -573
  150. package/src/components/form/total-form/total-form.test.tsx +0 -214
  151. package/src/components/layout/Accordion/Accordion.stories.tsx +0 -694
  152. package/src/components/layout/Accordion/Accordion.test.stories.tsx +0 -1344
  153. package/src/components/layout/Card/Card.stories.tsx +0 -591
  154. package/src/components/layout/Card/Card.test.stories.tsx +0 -1134
  155. package/src/components/layout/CardGrid/__tests__/CardGrid.test.tsx +0 -92
  156. package/src/components/layout/Collapsible/Collapsible.stories.tsx +0 -180
  157. package/src/components/layout/Collapsible/Collapsible.test.stories.tsx +0 -308
  158. package/src/components/layout/Container/Container.stories.tsx +0 -557
  159. package/src/components/layout/Container/Container.test.stories.tsx +0 -745
  160. package/src/components/layout/ContentToolbar/ContentToolbar.stories.tsx +0 -129
  161. package/src/components/layout/ContentToolbar/ContentToolbar.test.stories.tsx +0 -251
  162. package/src/components/layout/ContentToolbar/__tests__/ColumnsMenu.test.tsx +0 -39
  163. package/src/components/layout/ContentToolbar/__tests__/MultiSelectDropdown.test.tsx +0 -131
  164. package/src/components/layout/ContentToolbar/__tests__/SavedViewsMenu.test.tsx +0 -99
  165. package/src/components/layout/Dashboard/Dashboard.stories.tsx +0 -104
  166. package/src/components/layout/Dashboard/Dashboard.test.stories.tsx +0 -190
  167. package/src/components/layout/Drawer/Drawer.stories.tsx +0 -658
  168. package/src/components/layout/Drawer/Drawer.test.stories.tsx +0 -1343
  169. package/src/components/layout/Resizable/Resizable.stories.tsx +0 -1039
  170. package/src/components/layout/Resizable/Resizable.test.stories.tsx +0 -750
  171. package/src/components/layout/ScrollArea/ScrollArea.stories.tsx +0 -651
  172. package/src/components/layout/ScrollArea/ScrollArea.test.stories.tsx +0 -619
  173. package/src/components/layout/Separator/Separator.stories.tsx +0 -563
  174. package/src/components/layout/Separator/Separator.test.stories.tsx +0 -518
  175. package/src/components/layout/SettingsLayout/SettingsLayout.stories.tsx +0 -192
  176. package/src/components/layout/SettingsLayout/SettingsLayout.test.stories.tsx +0 -175
  177. package/src/components/layout/Sidebar/Sidebar.stories.tsx +0 -609
  178. package/src/components/layout/Sidebar/Sidebar.test.stories.tsx +0 -1324
  179. package/src/components/layout/Skeleton/Skeleton.stories.tsx +0 -689
  180. package/src/components/layout/Skeleton/Skeleton.test.stories.tsx +0 -521
  181. package/src/components/layout/Spacer/Spacer.stories.tsx +0 -502
  182. package/src/components/layout/Spacer/Spacer.test.stories.tsx +0 -472
  183. package/src/components/layout/TableFilter/TableFilter.stories.tsx +0 -82
  184. package/src/components/layout/TableFilter/TableFilter.test.stories.tsx +0 -87
  185. package/src/components/navigation/Breadcrumbs/Breadcrumbs.stories.tsx +0 -638
  186. package/src/components/navigation/Breadcrumbs/Breadcrumbs.test.stories.tsx +0 -1008
  187. package/src/components/navigation/CommandPalette/CommandPalette.stories.tsx +0 -386
  188. package/src/components/navigation/CommandPalette/CommandPalette.test.stories.tsx +0 -435
  189. package/src/components/navigation/ContextMenu/ContextMenu.stories.tsx +0 -614
  190. package/src/components/navigation/ContextMenu/ContextMenu.test.stories.tsx +0 -845
  191. package/src/components/navigation/DropdownMenu/DropdownMenu.stories.tsx +0 -578
  192. package/src/components/navigation/DropdownMenu/DropdownMenu.test.stories.tsx +0 -660
  193. package/src/components/navigation/NavigationMenu/stories/NavigationMenu.stories.tsx +0 -516
  194. package/src/components/navigation/NavigationMenu/stories/NavigationMenu.test.stories.tsx +0 -935
  195. package/src/components/navigation/NavigationMenu/stories/NavigationMenuHorizontal.stories.tsx +0 -501
  196. package/src/components/navigation/NavigationMenu/stories/NavigationMenuVertical.stories.tsx +0 -453
  197. package/src/components/navigation/Pagination/Pagination.stories.tsx +0 -602
  198. package/src/components/navigation/Pagination/Pagination.test.stories.tsx +0 -520
  199. package/src/components/navigation/Tabs/Tabs.stories.tsx +0 -1004
  200. package/src/components/navigation/Tabs/Tabs.test.stories.tsx +0 -1225
  201. package/src/components/typography/Blockquote/Blockquote.stories.tsx +0 -359
  202. package/src/components/typography/Blockquote/Blockquote.test.stories.tsx +0 -432
  203. package/src/components/typography/Code/Code.stories.tsx +0 -686
  204. package/src/components/typography/Code/Code.test.stories.tsx +0 -703
  205. package/src/components/typography/Heading/Heading.stories.tsx +0 -451
  206. package/src/components/typography/Heading/Heading.test.stories.tsx +0 -830
  207. package/src/components/typography/Paragraph/Paragraph.stories.tsx +0 -280
  208. package/src/components/typography/Paragraph/Paragraph.test.stories.tsx +0 -231
  209. package/src/components/typography/Text/Text.stories.tsx +0 -359
  210. package/src/components/typography/Text/Text.test.stories.tsx +0 -762
  211. package/src/components/utility/AnimatedIcon/AnimatedIcon.stories.tsx +0 -945
  212. package/src/components/utility/AnimatedIcon/AnimatedIcon.test.stories.tsx +0 -603
  213. package/src/components/utility/AspectRatio/AspectRatio.stories.tsx +0 -414
  214. package/src/components/utility/AspectRatio/AspectRatio.test.stories.tsx +0 -859
  215. package/src/components/utility/InfiniteScroll/InfiniteScroll.stories.tsx +0 -620
  216. package/src/components/utility/InfiniteScroll/InfiniteScroll.test.stories.tsx +0 -361
  217. package/src/components/utility/InstallPrompt/InstallPrompt.stories.tsx +0 -118
  218. package/src/components/utility/InstallPrompt/InstallPrompt.test.stories.tsx +0 -83
  219. package/src/components/utility/InstallPrompt/__tests__/InstallPrompt.ios.test.tsx +0 -65
  220. package/src/components/utility/InstallPrompt/__tests__/usePwaInstall.test.tsx +0 -271
  221. package/src/components/utility/Portal/Portal.stories.tsx +0 -340
  222. package/src/components/utility/Portal/Portal.test.stories.tsx +0 -2086
  223. package/src/components/utility/Transition/Transition.stories.tsx +0 -493
  224. package/src/components/utility/Transition/Transition.test.stories.tsx +0 -854
  225. package/src/components/utility/VirtualList/VirtualList.stories.tsx +0 -1073
  226. package/src/components/utility/VirtualList/VirtualList.test.stories.tsx +0 -1085
  227. package/src/components/utility/WorkflowStep/WorkflowStep.stories.tsx +0 -431
  228. package/src/components/utility/WorkflowStep/WorkflowStep.test.stories.tsx +0 -364
  229. /package/src/{button.tsx → button/button.tsx} +0 -0
@@ -1,620 +0,0 @@
1
- import {
2
- Avatar,
3
- Box,
4
- Card,
5
- CardContent,
6
- CircularProgress,
7
- ListItem,
8
- ListItemAvatar,
9
- ListItemText,
10
- Paper,
11
- Typography,
12
- } from '@mui/material';
13
- import type { Meta, StoryObj } from '@storybook/react-vite';
14
- import { useCallback,useState } from 'react';
15
-
16
- import { InfiniteScroll } from './InfiniteScroll';
17
-
18
- const meta: Meta<typeof InfiniteScroll> = {
19
- title: 'Utility/InfiniteScroll',
20
- component: InfiniteScroll,
21
- tags: ['autodocs', 'component:InfiniteScroll'],
22
- parameters: {
23
- layout: 'centered',
24
- docs: {
25
- description: {
26
- component:
27
- 'Infinite scroll component with support for vertical, reverse, and horizontal scrolling modes.',
28
- },
29
- },
30
- },
31
- };
32
-
33
- export default meta;
34
- type Story = StoryObj<typeof InfiniteScroll>;
35
-
36
- interface Item {
37
- id: number;
38
- name: string;
39
- description: string;
40
- avatar: string;
41
- }
42
-
43
- const generateItems = (startIndex: number, count: number): Item[] => Array.from({ length: count }, (_, i) => ({
44
- id: startIndex + i,
45
- name: `User ${startIndex + i + 1}`,
46
- description: `This is a description for user ${startIndex + i + 1}. They have been using our platform for a while.`,
47
- avatar: `https://i.pravatar.cc/40?img=${((startIndex + i) % 70) + 1}`,
48
- }));
49
-
50
- const VerticalScrollComponent = () => {
51
- const [items, setItems] = useState<Item[]>(generateItems(0, 20));
52
- const [loading, setLoading] = useState(false);
53
- const [hasMore, setHasMore] = useState(true);
54
-
55
- const loadMore = useCallback(async () => {
56
- setLoading(true);
57
-
58
- // Simulate API delay
59
- await new Promise((resolve) => window.setTimeout(resolve, 1000));
60
-
61
- const newItems = generateItems(items.length, 10);
62
- setItems((prev) => [...prev, ...newItems]);
63
- setLoading(false);
64
-
65
- // Stop loading after 100 items for demo
66
- if (items.length >= 90) {
67
- setHasMore(false);
68
- }
69
- }, [items.length]);
70
-
71
- return (
72
- <Paper sx={{ width: 400, height: 500, overflow: 'hidden' }}>
73
- <Box sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}>
74
- <Typography variant="h6">Infinite Scroll Demo</Typography>
75
- <Typography variant="body2" color="text.secondary">
76
- {items.length} items loaded
77
- </Typography>
78
- </Box>
79
-
80
- <Box sx={{ height: 'calc(100% - 80px)', overflow: 'auto' }}>
81
- <InfiniteScroll hasMore={hasMore} loading={loading} loadMore={loadMore} threshold={100}>
82
- {items.map((item) => (
83
- <ListItem key={item.id}>
84
- <ListItemAvatar>
85
- <Avatar src={item.avatar} />
86
- </ListItemAvatar>
87
- <ListItemText primary={item.name} secondary={item.description} />
88
- </ListItem>
89
- ))}
90
- </InfiniteScroll>
91
- </Box>
92
- </Paper>
93
- );
94
- };
95
-
96
- export const VerticalScroll: Story = {
97
- render: () => <VerticalScrollComponent />,
98
- };
99
-
100
- const CardGridComponent = () => {
101
- const [items, setItems] = useState<Item[]>(generateItems(0, 12));
102
- const [loading, setLoading] = useState(false);
103
- const [hasMore, setHasMore] = useState(true);
104
-
105
- const loadMore = useCallback(async () => {
106
- setLoading(true);
107
- await new Promise((resolve) => window.setTimeout(resolve, 1500));
108
-
109
- const newItems = generateItems(items.length, 8);
110
- setItems((prev) => [...prev, ...newItems]);
111
- setLoading(false);
112
-
113
- if (items.length >= 60) {
114
- setHasMore(false);
115
- }
116
- }, [items.length]);
117
-
118
- return (
119
- <Box sx={{ width: 800, height: 600, overflow: 'auto' }}>
120
- <Typography variant="h5" sx={{ p: 3, pb: 2 }}>
121
- Infinite Card Grid
122
- </Typography>
123
-
124
- <InfiniteScroll
125
- hasMore={hasMore}
126
- loading={loading}
127
- loadMore={loadMore}
128
- threshold={200}
129
- loader={
130
- <Box sx={{ display: 'flex', justifyContent: 'center', p: 4 }}>
131
- <CircularProgress />
132
- <Typography sx={{ ml: 2 }}>Loading more cards...</Typography>
133
- </Box>
134
- }
135
- >
136
- <Box
137
- sx={{
138
- display: 'grid',
139
- gridTemplateColumns: 'repeat(auto-fill, minmax(250px, 1fr))',
140
- gap: 3,
141
- p: 3,
142
- }}
143
- >
144
- {items.map((item) => (
145
- <Card
146
- key={item.id}
147
- sx={{
148
- transition: 'transform 0.2s, box-shadow 0.2s',
149
- '&:hover': {
150
- transform: 'translateY(-4px)',
151
- boxShadow: 4,
152
- },
153
- }}
154
- >
155
- <CardContent>
156
- <Box sx={{ display: 'flex', alignItems: 'center', mb: 2 }}>
157
- <Avatar src={item.avatar} sx={{ mr: 2 }} />
158
- <Typography variant="h6">{item.name}</Typography>
159
- </Box>
160
- <Typography variant="body2" color="text.secondary">
161
- {item.description}
162
- </Typography>
163
- <Typography variant="caption" color="primary" sx={{ mt: 1, display: 'block' }}>
164
- ID: {item.id}
165
- </Typography>
166
- </CardContent>
167
- </Card>
168
- ))}
169
- </Box>
170
- </InfiniteScroll>
171
- </Box>
172
- );
173
- };
174
-
175
- export const CardGrid: Story = {
176
- render: () => <CardGridComponent />,
177
- };
178
-
179
- const ReverseScrollComponent = () => {
180
- const [messages, setMessages] = useState<Item[]>(generateItems(0, 15));
181
- const [loading, setLoading] = useState(false);
182
- const [hasMore, setHasMore] = useState(true);
183
-
184
- const loadMore = useCallback(async () => {
185
- setLoading(true);
186
- await new Promise((resolve) => window.setTimeout(resolve, 800));
187
-
188
- // Add older messages at the beginning
189
- const olderMessages = generateItems(-messages.length - 10, 10).reverse();
190
- setMessages((prev) => [...olderMessages, ...prev]);
191
- setLoading(false);
192
-
193
- if (messages.length >= 50) {
194
- setHasMore(false);
195
- }
196
- }, [messages.length]);
197
-
198
- return (
199
- <Paper sx={{ width: 500, height: 600 }}>
200
- <Box sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}>
201
- <Typography variant="h6">Chat History</Typography>
202
- <Typography variant="body2" color="text.secondary">
203
- Reverse infinite scroll (loads older messages at top)
204
- </Typography>
205
- </Box>
206
-
207
- <Box sx={{ height: 'calc(100% - 80px)', overflow: 'auto' }}>
208
- <InfiniteScroll
209
- variant="reverse"
210
- hasMore={hasMore}
211
- loading={loading}
212
- loadMore={loadMore}
213
- threshold={50}
214
- loader={
215
- <Box sx={{ display: 'flex', justifyContent: 'center', p: 2 }}>
216
- <CircularProgress size={20} />
217
- <Typography variant="body2" sx={{ ml: 1 }}>
218
- Loading older messages...
219
- </Typography>
220
- </Box>
221
- }
222
- >
223
- {messages.map((message, index) => (
224
- <Box
225
- key={message.id}
226
- sx={{
227
- p: 2,
228
- borderBottom: index < messages.length - 1 ? '1px solid' : 'none',
229
- borderColor: 'divider',
230
- display: 'flex',
231
- alignItems: 'flex-start',
232
- gap: 2,
233
- }}
234
- >
235
- <Avatar src={message.avatar} sx={{ width: 32, height: 32 }} />
236
- <Box sx={{ flex: 1 }}>
237
- <Typography variant="subtitle2" sx={{ fontWeight: 600 }}>
238
- {message.name}
239
- </Typography>
240
- <Typography variant="body2" color="text.secondary">
241
- {message.description}
242
- </Typography>
243
- <Typography
244
- variant="caption"
245
- color="text.secondary"
246
- sx={{ mt: 1, display: 'block' }}
247
- >
248
- Message ID: {message.id}
249
- </Typography>
250
- </Box>
251
- </Box>
252
- ))}
253
- </InfiniteScroll>
254
- </Box>
255
- </Paper>
256
- );
257
- };
258
-
259
- export const ReverseScroll: Story = {
260
- render: () => <ReverseScrollComponent />,
261
- };
262
-
263
- const HorizontalScrollComponent = () => {
264
- const [items, setItems] = useState<Item[]>(generateItems(0, 10));
265
- const [loading, setLoading] = useState(false);
266
- const [hasMore, setHasMore] = useState(true);
267
-
268
- const loadMore = useCallback(async () => {
269
- setLoading(true);
270
- await new Promise((resolve) => window.setTimeout(resolve, 1000));
271
-
272
- const newItems = generateItems(items.length, 5);
273
- setItems((prev) => [...prev, ...newItems]);
274
- setLoading(false);
275
-
276
- if (items.length >= 40) {
277
- setHasMore(false);
278
- }
279
- }, [items.length]);
280
-
281
- return (
282
- <Paper sx={{ width: 600, height: 300 }}>
283
- <Box sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}>
284
- <Typography variant="h6">Horizontal Infinite Scroll</Typography>
285
- <Typography variant="body2" color="text.secondary">
286
- Scroll horizontally to load more items
287
- </Typography>
288
- </Box>
289
-
290
- <InfiniteScroll
291
- variant="horizontal"
292
- hasMore={hasMore}
293
- loading={loading}
294
- loadMore={loadMore}
295
- width="100%"
296
- threshold={100}
297
- loader={
298
- <Box
299
- sx={{
300
- display: 'flex',
301
- flexDirection: 'column',
302
- alignItems: 'center',
303
- justifyContent: 'center',
304
- p: 2,
305
- minWidth: 120,
306
- height: '100%',
307
- }}
308
- >
309
- <CircularProgress size={20} />
310
- <Typography variant="caption" sx={{ mt: 1 }}>
311
- Loading...
312
- </Typography>
313
- </Box>
314
- }
315
- >
316
- <Box
317
- sx={{
318
- display: 'flex',
319
- gap: 2,
320
- p: 2,
321
- height: '100%',
322
- }}
323
- >
324
- {items.map((item) => (
325
- <Card
326
- key={item.id}
327
- sx={{
328
- minWidth: 200,
329
- maxWidth: 200,
330
- height: 'fit-content',
331
- }}
332
- >
333
- <CardContent sx={{ textAlign: 'center' }}>
334
- <Avatar
335
- src={item.avatar}
336
- sx={{
337
- width: 60,
338
- height: 60,
339
- mx: 'auto',
340
- mb: 2,
341
- }}
342
- />
343
- <Typography variant="h6" gutterBottom>
344
- {item.name}
345
- </Typography>
346
- <Typography variant="body2" color="text.secondary">
347
- Item #{item.id + 1}
348
- </Typography>
349
- </CardContent>
350
- </Card>
351
- ))}
352
- </Box>
353
- </InfiniteScroll>
354
- </Paper>
355
- );
356
- };
357
-
358
- export const HorizontalScroll: Story = {
359
- render: () => <HorizontalScrollComponent />,
360
- };
361
- // Required standardized story exports for validation
362
- export const Default: Story = {
363
- render: () => <VerticalScrollComponent />,
364
- };
365
-
366
- export const AllVariants: Story = {
367
- render: () => (
368
- <Box sx={{ display: 'flex', gap: 3, flexWrap: 'wrap' }}>
369
- <Box sx={{ minWidth: 400 }}>
370
- <Typography variant="h6" sx={{ mb: 2 }}>
371
- Vertical (Default)
372
- </Typography>
373
- <VerticalScrollComponent />
374
- </Box>
375
- <Box sx={{ minWidth: 500 }}>
376
- <Typography variant="h6" sx={{ mb: 2 }}>
377
- Reverse Scroll
378
- </Typography>
379
- <ReverseScrollComponent />
380
- </Box>
381
- <Box sx={{ minWidth: 600 }}>
382
- <Typography variant="h6" sx={{ mb: 2 }}>
383
- Horizontal Scroll
384
- </Typography>
385
- <HorizontalScrollComponent />
386
- </Box>
387
- </Box>
388
- ),
389
- parameters: { layout: 'fullscreen' },
390
- };
391
-
392
- export const AllSizes: Story = {
393
- render: () => (
394
- <Box sx={{ display: 'flex', gap: 3, alignItems: 'flex-start' }}>
395
- <Paper sx={{ width: 300, height: 400, overflow: 'hidden' }}>
396
- <Typography
397
- variant="subtitle1"
398
- sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}
399
- >
400
- Small (300x400)
401
- </Typography>
402
- <Box sx={{ height: 'calc(100% - 60px)', overflow: 'auto' }}>
403
- <InfiniteScroll hasMore={true} loading={false} loadMore={() => {}} threshold={50}>
404
- {generateItems(0, 10).map((item) => (
405
- <ListItem key={item.id} dense>
406
- <ListItemAvatar>
407
- <Avatar src={item.avatar} sx={{ width: 30, height: 30 }} />
408
- </ListItemAvatar>
409
- <ListItemText primary={item.name} primaryTypographyProps={{ variant: 'body2' }} />
410
- </ListItem>
411
- ))}
412
- </InfiniteScroll>
413
- </Box>
414
- </Paper>
415
- <Paper sx={{ width: 500, height: 600, overflow: 'hidden' }}>
416
- <Typography
417
- variant="subtitle1"
418
- sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}
419
- >
420
- Medium (500x600)
421
- </Typography>
422
- <Box sx={{ height: 'calc(100% - 60px)', overflow: 'auto' }}>
423
- <InfiniteScroll hasMore={true} loading={false} loadMore={() => {}} threshold={100}>
424
- {generateItems(0, 15).map((item) => (
425
- <ListItem key={item.id}>
426
- <ListItemAvatar>
427
- <Avatar src={item.avatar} />
428
- </ListItemAvatar>
429
- <ListItemText primary={item.name} secondary={item.description} />
430
- </ListItem>
431
- ))}
432
- </InfiniteScroll>
433
- </Box>
434
- </Paper>
435
- </Box>
436
- ),
437
- parameters: { layout: 'fullscreen' },
438
- };
439
-
440
- export const AllStates: Story = {
441
- render: () => (
442
- <Box sx={{ display: 'flex', gap: 3, flexWrap: 'wrap' }}>
443
- <Paper sx={{ width: 350, height: 400 }}>
444
- <Typography variant="h6" sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}>
445
- Default State
446
- </Typography>
447
- <Box sx={{ height: 'calc(100% - 60px)', overflow: 'auto' }}>
448
- <InfiniteScroll hasMore={true} loading={false} loadMore={() => {}} threshold={100}>
449
- {generateItems(0, 5).map((item) => (
450
- <ListItem key={item.id}>
451
- <ListItemAvatar>
452
- <Avatar src={item.avatar} />
453
- </ListItemAvatar>
454
- <ListItemText primary={item.name} secondary="Ready to load more" />
455
- </ListItem>
456
- ))}
457
- </InfiniteScroll>
458
- </Box>
459
- </Paper>
460
- <Paper sx={{ width: 350, height: 400 }}>
461
- <Typography variant="h6" sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}>
462
- Loading State
463
- </Typography>
464
- <Box sx={{ height: 'calc(100% - 60px)', overflow: 'auto' }}>
465
- <InfiniteScroll hasMore={true} loading={true} loadMore={() => {}} threshold={100}>
466
- {generateItems(0, 5).map((item) => (
467
- <ListItem key={item.id}>
468
- <ListItemAvatar>
469
- <Avatar src={item.avatar} />
470
- </ListItemAvatar>
471
- <ListItemText primary={item.name} secondary="Loading more items..." />
472
- </ListItem>
473
- ))}
474
- </InfiniteScroll>
475
- </Box>
476
- </Paper>
477
- <Paper sx={{ width: 350, height: 400 }}>
478
- <Typography variant="h6" sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}>
479
- End State (No More Items)
480
- </Typography>
481
- <Box sx={{ height: 'calc(100% - 60px)', overflow: 'auto' }}>
482
- <InfiniteScroll
483
- hasMore={false}
484
- loading={false}
485
- loadMore={() => {}}
486
- threshold={100}
487
- endMessage={
488
- <Box sx={{ p: 3, textAlign: 'center' }}>
489
- <Typography variant="body2" color="text.secondary">
490
- 🎉 You have reached the end! No more items to load.
491
- </Typography>
492
- </Box>
493
- }
494
- >
495
- {generateItems(0, 8).map((item) => (
496
- <ListItem key={item.id}>
497
- <ListItemAvatar>
498
- <Avatar src={item.avatar} />
499
- </ListItemAvatar>
500
- <ListItemText primary={item.name} secondary="All items loaded" />
501
- </ListItem>
502
- ))}
503
- </InfiniteScroll>
504
- </Box>
505
- </Paper>
506
- <Paper sx={{ width: 350, height: 400 }}>
507
- <Typography variant="h6" sx={{ p: 2, borderBottom: '1px solid', borderColor: 'divider' }}>
508
- Error State
509
- </Typography>
510
- <Box sx={{ height: 'calc(100% - 60px)', overflow: 'auto' }}>
511
- <InfiniteScroll
512
- hasMore={true}
513
- loading={false}
514
- loadMore={() => {}}
515
- threshold={100}
516
- error={{ message: 'Failed to load more items' }}
517
- errorComponent={
518
- <Box sx={{ p: 3, textAlign: 'center' }}>
519
- <Typography variant="body2" color="error">
520
- ⚠️ Error loading more items. Please try again.
521
- </Typography>
522
- </Box>
523
- }
524
- >
525
- {generateItems(0, 3).map((item) => (
526
- <ListItem key={item.id}>
527
- <ListItemAvatar>
528
- <Avatar src={item.avatar} />
529
- </ListItemAvatar>
530
- <ListItemText primary={item.name} secondary="Error state example" />
531
- </ListItem>
532
- ))}
533
- </InfiniteScroll>
534
- </Box>
535
- </Paper>
536
- </Box>
537
- ),
538
- parameters: { layout: 'fullscreen' },
539
- };
540
-
541
- export const InteractiveStates: Story = {
542
- render: () => <VerticalScrollComponent />,
543
- parameters: { layout: 'fullscreen' },
544
- };
545
-
546
- export const Responsive: Story = {
547
- render: () => (
548
- <Box sx={{ width: '100%' }}>
549
- <Typography variant="h5" sx={{ mb: 3, textAlign: 'center' }}>
550
- Responsive Infinite Scroll
551
- </Typography>
552
- <Box
553
- sx={{
554
- width: '100%',
555
- maxWidth: '100vw',
556
- height: '70vh',
557
- overflow: 'auto',
558
- border: '1px solid',
559
- borderColor: 'divider',
560
- borderRadius: 2,
561
- }}
562
- >
563
- <InfiniteScroll hasMore={true} loading={false} loadMore={() => {}} threshold={100}>
564
- <Box
565
- sx={{
566
- display: 'grid',
567
- gridTemplateColumns: {
568
- xs: '1fr',
569
- sm: 'repeat(2, 1fr)',
570
- md: 'repeat(3, 1fr)',
571
- lg: 'repeat(4, 1fr)',
572
- xl: 'repeat(5, 1fr)',
573
- },
574
- gap: 2,
575
- p: 2,
576
- }}
577
- >
578
- {generateItems(0, 50).map((item) => (
579
- <Card key={item.id}>
580
- <CardContent>
581
- <Box sx={{ display: 'flex', alignItems: 'center', mb: 1 }}>
582
- <Avatar
583
- src={item.avatar}
584
- sx={{ mr: 2, width: { xs: 32, sm: 40 }, height: { xs: 32, sm: 40 } }}
585
- />
586
- <Typography
587
- variant="subtitle2"
588
- sx={{ fontSize: { xs: '0.875rem', sm: '1rem' } }}
589
- >
590
- {item.name}
591
- </Typography>
592
- </Box>
593
- <Typography
594
- variant="body2"
595
- color="text.secondary"
596
- sx={{
597
- fontSize: { xs: '0.75rem', sm: '0.875rem' },
598
- lineHeight: { xs: 1.3, sm: 1.4 },
599
- }}
600
- >
601
- {item.description.substring(0, 60)}...
602
- </Typography>
603
- <Typography variant="caption" color="primary" sx={{ mt: 1, display: 'block' }}>
604
- #{item.id + 1}
605
- </Typography>
606
- </CardContent>
607
- </Card>
608
- ))}
609
- </Box>
610
- </InfiniteScroll>
611
- </Box>
612
- <Box sx={{ mt: 3, textAlign: 'center' }}>
613
- <Typography variant="body2" color="text.secondary">
614
- Grid automatically adjusts: 1 column (mobile) → 2 columns (tablet) → 3+ columns (desktop)
615
- </Typography>
616
- </Box>
617
- </Box>
618
- ),
619
- parameters: { layout: 'fullscreen' },
620
- };