@12-apps/ui 1.5.0 → 1.5.2

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 -9
  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 -89
  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 -763
  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 -511
  27. package/src/components/data-display/Carousel/Carousel.stories.tsx +0 -607
  28. package/src/components/data-display/Carousel/Carousel.test.stories.tsx +0 -701
  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 -1105
  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 -964
  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 -973
  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 -915
  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 -915
  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 -754
  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 -474
  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 -759
  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,619 +0,0 @@
1
- import { Box, Button, List, ListItem,TextField, Typography } from '@mui/material';
2
- import type { Meta, StoryObj } from '@storybook/react-vite';
3
- import React from 'react';
4
- import { expect, fn,userEvent, waitFor, within } from 'storybook/test';
5
-
6
- import { ScrollArea } from './ScrollArea';
7
-
8
- const meta: Meta<typeof ScrollArea> = {
9
- title: 'Layout/ScrollArea/Tests',
10
- component: ScrollArea,
11
- parameters: {
12
- layout: 'centered',
13
- chromatic: { disableSnapshot: false },
14
- },
15
- tags: ['autodocs', 'test', 'component:ScrollArea'],
16
- };
17
-
18
- export default meta;
19
- type Story = StoryObj<typeof meta>;
20
-
21
- // Helper to generate content
22
- const generateContent = (lines: number) => (
23
- <Box sx={{ p: 2 }}>
24
- {Array.from({ length: lines }, (_, i) => (
25
- <Typography key={i} paragraph data-testid={`line-${i}`}>
26
- Line {i + 1}: This is scrollable content. Lorem ipsum dolor sit amet.
27
- </Typography>
28
- ))}
29
- </Box>
30
- );
31
-
32
- // Test 1: Basic Interaction Test
33
- export const BasicInteraction: Story = {
34
- args: {
35
- width: 400,
36
- height: 300,
37
- scrollToTopButton: true,
38
- scrollToTopThreshold: 50,
39
- onScroll: fn(),
40
- children: generateContent(50),
41
- },
42
- play: async ({ canvasElement, args }) => {
43
- const canvas = within(canvasElement);
44
-
45
- // Find scroll area
46
- const scrollArea = await canvas.findByTestId('scroll-area');
47
- expect(scrollArea).toBeInTheDocument();
48
-
49
- // Find the scrollable container
50
- const scrollContainer = scrollArea.querySelector('[role="region"]');
51
- expect(scrollContainer).toBeInTheDocument();
52
-
53
- // Verify initial state
54
- expect(scrollContainer).toHaveAttribute('aria-label', 'Scrollable content');
55
- expect(scrollContainer).toHaveAttribute('aria-busy', 'false');
56
-
57
- // Simulate scroll
58
- if (scrollContainer) {
59
- // Scroll down
60
- scrollContainer.scrollTop = 200;
61
- scrollContainer.dispatchEvent(new window.Event('scroll', { bubbles: true }));
62
-
63
- await waitFor(() => {
64
- expect(args.onScroll).toHaveBeenCalled();
65
- });
66
-
67
- // Check if scroll-to-top button appears
68
- await waitFor(() => {
69
- const scrollToTopBtn = canvas.queryByLabelText('Scroll to top');
70
- expect(scrollToTopBtn).toBeInTheDocument();
71
- });
72
-
73
- // Click scroll to top
74
- const scrollToTopBtn = await canvas.findByLabelText('Scroll to top');
75
- await userEvent.click(scrollToTopBtn);
76
-
77
- // Verify scrolled to top
78
- await waitFor(() => {
79
- expect(scrollContainer.scrollTop).toBeLessThan(50);
80
- });
81
- }
82
- },
83
- };
84
-
85
- // Test 2: Form Interaction Test
86
- export const FormInteraction: Story = {
87
- args: {
88
- width: 400,
89
- height: 300,
90
- onScroll: fn(),
91
- children: (
92
- <Box sx={{ p: 2 }}>
93
- <Typography variant="h6" gutterBottom>
94
- Form in Scroll Area
95
- </Typography>
96
- {Array.from({ length: 10 }, (_, i) => (
97
- <TextField
98
- key={i}
99
- fullWidth
100
- label={`Field ${i + 1}`}
101
- margin="normal"
102
- data-testid={`field-${i}`}
103
- />
104
- ))}
105
- <Button variant="contained" sx={{ mt: 2 }} data-testid="submit-btn">
106
- Submit
107
- </Button>
108
- </Box>
109
- ),
110
- },
111
- play: async ({ canvasElement }) => {
112
- const canvas = within(canvasElement);
113
-
114
- // Find form elements
115
- const firstField = await canvas.findByTestId('field-0');
116
- const lastField = await canvas.findByTestId('field-9');
117
- const submitBtn = await canvas.findByTestId('submit-btn');
118
-
119
- expect(firstField).toBeInTheDocument();
120
- expect(lastField).toBeInTheDocument();
121
- expect(submitBtn).toBeInTheDocument();
122
-
123
- // Type in first field
124
- await userEvent.type(firstField, 'Test input');
125
-
126
- // Scroll to last field
127
- lastField.scrollIntoView({ behavior: 'smooth' });
128
-
129
- await waitFor(() => {
130
- const rect = lastField.getBoundingClientRect();
131
- expect(rect.top).toBeGreaterThan(0);
132
- });
133
-
134
- // Type in last field (skip clear due to MUI TextField compatibility)
135
- await userEvent.type(lastField, 'Last field input');
136
-
137
- // Click submit
138
- await userEvent.click(submitBtn);
139
- },
140
- };
141
-
142
- // Test 3: Keyboard Navigation Test
143
- export const KeyboardNavigation: Story = {
144
- args: {
145
- width: 400,
146
- height: 300,
147
- scrollToTopButton: true,
148
- onScroll: fn(),
149
- children: (
150
- <List>
151
- {Array.from({ length: 30 }, (_, i) => (
152
- <ListItem key={i} button tabIndex={0} data-testid={`item-${i}`}>
153
- <Typography>Item {i + 1}</Typography>
154
- </ListItem>
155
- ))}
156
- </List>
157
- ),
158
- },
159
- play: async ({ canvasElement }) => {
160
- const canvas = within(canvasElement);
161
-
162
- // Find scroll area
163
- const scrollArea = await canvas.findByTestId('scroll-area');
164
- const scrollContainer = scrollArea.querySelector('[role="region"]') as HTMLDivElement;
165
-
166
- expect(scrollContainer).toBeInTheDocument();
167
- expect(scrollContainer).toHaveAttribute('tabIndex', '0');
168
-
169
- // Focus the scroll area
170
- if (scrollContainer) {
171
- scrollContainer.focus();
172
- expect(document.activeElement).toBe(scrollContainer);
173
-
174
- // Test that keyboard events are handled (simulate the effect manually since browsers don't scroll in test environment)
175
- await userEvent.keyboard('{ArrowDown}');
176
- await userEvent.keyboard('{ArrowDown}');
177
- await userEvent.keyboard('{PageDown}');
178
-
179
- // Manually simulate scrolling to test scroll behavior
180
- scrollContainer.scrollTop = 100;
181
- scrollContainer.dispatchEvent(new window.Event('scroll', { bubbles: true }));
182
-
183
- await waitFor(() => {
184
- expect(scrollContainer.scrollTop).toBeGreaterThan(0);
185
- });
186
-
187
- // Test scroll reset (simulate Home key effect)
188
- scrollContainer.scrollTop = 0;
189
- scrollContainer.dispatchEvent(new window.Event('scroll', { bubbles: true }));
190
-
191
- await waitFor(() => {
192
- expect(scrollContainer.scrollTop).toBe(0);
193
- });
194
-
195
- // Test scroll to end (simulate End key effect)
196
- scrollContainer.scrollTop = scrollContainer.scrollHeight;
197
- scrollContainer.dispatchEvent(new window.Event('scroll', { bubbles: true }));
198
-
199
- await waitFor(() => {
200
- expect(scrollContainer.scrollTop).toBeGreaterThan(100);
201
- });
202
- }
203
- },
204
- };
205
-
206
- // Test 4: Screen Reader Test
207
- export const ScreenReader: Story = {
208
- args: {
209
- width: 400,
210
- height: 300,
211
- loading: false,
212
- disabled: false,
213
- onScroll: fn(),
214
- children: generateContent(20),
215
- },
216
- play: async ({ canvasElement }) => {
217
- const canvas = within(canvasElement);
218
-
219
- // Check ARIA attributes
220
- const scrollArea = await canvas.findByTestId('scroll-area');
221
- const scrollContainer = scrollArea.querySelector('[role="region"]');
222
-
223
- expect(scrollContainer).toHaveAttribute('role', 'region');
224
- expect(scrollContainer).toHaveAttribute('aria-label', 'Scrollable content');
225
- expect(scrollContainer).toHaveAttribute('aria-busy', 'false');
226
- expect(scrollContainer).toHaveAttribute('tabIndex', '0');
227
-
228
- // Test with loading state
229
- const loadingDiv = document.createElement('div');
230
- loadingDiv.innerHTML = '<div role="region" aria-busy="true">Loading...</div>';
231
- const loadingRegion = loadingDiv.querySelector('[role="region"]');
232
- expect(loadingRegion).toHaveAttribute('aria-busy', 'true');
233
-
234
- // Test with disabled state
235
- const disabledDiv = document.createElement('div');
236
- disabledDiv.innerHTML = '<div role="region" tabindex="-1">Disabled</div>';
237
- const disabledRegion = disabledDiv.querySelector('[role="region"]');
238
- expect(disabledRegion).toHaveAttribute('tabIndex', '-1');
239
- },
240
- };
241
-
242
- // Test 5: Focus Management Test
243
- export const FocusManagement: Story = {
244
- args: {
245
- width: 400,
246
- height: 300,
247
- onScroll: fn(),
248
- children: (
249
- <Box sx={{ p: 2 }}>
250
- <Button data-testid="btn-1">Button 1</Button>
251
- {generateContent(20)}
252
- <Button data-testid="btn-2">Button 2</Button>
253
- </Box>
254
- ),
255
- },
256
- play: async ({ canvasElement }) => {
257
- const canvas = within(canvasElement);
258
-
259
- const scrollArea = await canvas.findByTestId('scroll-area');
260
- const scrollContainer = scrollArea.querySelector('[role="region"]') as HTMLDivElement;
261
- const btn1 = await canvas.findByTestId('btn-1');
262
- const btn2 = await canvas.findByTestId('btn-2');
263
-
264
- // Focus first button
265
- btn1.focus();
266
- expect(document.activeElement).toBe(btn1);
267
-
268
- // Tab to scroll container
269
- await userEvent.tab();
270
-
271
- // Verify focus management
272
- if (scrollContainer) {
273
- // The focus might go to scrollContainer or btn2 depending on implementation
274
- const activeEl = document.activeElement;
275
- expect(activeEl === scrollContainer || activeEl === btn2).toBe(true);
276
-
277
- // Focus scroll container directly
278
- scrollContainer.focus();
279
- expect(document.activeElement).toBe(scrollContainer);
280
-
281
- // Verify focus visible styles are applied
282
- // const computedStyle = window.getComputedStyle(scrollContainer);
283
- // Focus styles should be present when focused
284
- }
285
- },
286
- };
287
-
288
- // Test 6: Responsive Design Test
289
- export const ResponsiveDesign: Story = {
290
- args: {
291
- width: '100%',
292
- maxWidth: 600,
293
- height: '50vh',
294
- maxHeight: 400,
295
- onScroll: fn(),
296
- children: generateContent(30),
297
- },
298
- parameters: {
299
- viewport: {
300
- viewports: {
301
- mobile: { name: 'Mobile', styles: { width: '375px', height: '667px' } },
302
- tablet: { name: 'Tablet', styles: { width: '768px', height: '1024px' } },
303
- desktop: { name: 'Desktop', styles: { width: '1920px', height: '1080px' } },
304
- },
305
- },
306
- },
307
- play: async ({ canvasElement }) => {
308
- const canvas = within(canvasElement);
309
- const scrollArea = await canvas.findByTestId('scroll-area');
310
-
311
- // Check responsive width
312
- const styles = window.getComputedStyle(scrollArea);
313
- const width = parseInt(styles.width);
314
-
315
- // Should not exceed maxWidth
316
- expect(width).toBeLessThanOrEqual(600);
317
-
318
- // Check height constraints
319
- const height = parseInt(styles.height);
320
- expect(height).toBeLessThanOrEqual(400);
321
- },
322
- };
323
-
324
- // Test 7: Theme Variations Test
325
- export const ThemeVariations: Story = {
326
- args: {
327
- width: 400,
328
- height: 200,
329
- onScroll: fn(),
330
- children: generateContent(20),
331
- },
332
- render: (args) => (
333
- <Box sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
334
- <ScrollArea {...args} variant="default" data-testid="scroll-area" />
335
- <ScrollArea {...args} variant="overlay" data-testid="scroll-area-overlay" />
336
- <ScrollArea {...args} variant="glass" data-testid="scroll-area-glass" />
337
- </Box>
338
- ),
339
- play: async ({ canvasElement }) => {
340
- const canvas = within(canvasElement);
341
-
342
- // Test default variant
343
- const defaultArea = await canvas.findByTestId('scroll-area');
344
- expect(defaultArea).toBeInTheDocument();
345
-
346
- // Test overlay variant
347
- const overlayArea = await canvas.findByTestId('scroll-area-overlay');
348
- expect(overlayArea).toBeInTheDocument();
349
-
350
- // Test glass variant
351
- const glassArea = await canvas.findByTestId('scroll-area-glass');
352
- expect(glassArea).toBeInTheDocument();
353
-
354
- // Verify different styling is applied
355
- const defaultStyles = window.getComputedStyle(defaultArea.querySelector('[role="region"]')!);
356
- const overlayStyles = window.getComputedStyle(overlayArea.querySelector('[role="region"]')!);
357
- const glassStyles = window.getComputedStyle(glassArea.querySelector('[role="region"]')!);
358
-
359
- // Each variant should have unique styles
360
- expect(defaultStyles).toBeDefined();
361
- expect(overlayStyles).toBeDefined();
362
- expect(glassStyles).toBeDefined();
363
- },
364
- };
365
-
366
- // Test 8: Visual States Test
367
- export const VisualStates: Story = {
368
- args: {
369
- width: 400,
370
- height: 200,
371
- onScroll: fn(),
372
- },
373
- render: (args) => (
374
- <Box sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
375
- <ScrollArea {...args} data-testid="scroll-area-normal">
376
- {generateContent(10)}
377
- </ScrollArea>
378
- <ScrollArea {...args} disabled data-testid="scroll-area-disabled">
379
- {generateContent(10)}
380
- </ScrollArea>
381
- <ScrollArea {...args} loading data-testid="scroll-area-loading">
382
- {generateContent(10)}
383
- </ScrollArea>
384
- <ScrollArea {...args} emptyContent="No content" data-testid="scroll-area-empty" />
385
- </Box>
386
- ),
387
- play: async ({ canvasElement }) => {
388
- const canvas = within(canvasElement);
389
-
390
- // Test normal state
391
- const normalArea = await canvas.findByTestId('scroll-area-normal');
392
- const normalContainer = normalArea.querySelector('[role="region"]');
393
- expect(normalContainer).toHaveAttribute('aria-busy', 'false');
394
- expect(normalContainer).toHaveAttribute('tabIndex', '0');
395
-
396
- // Test disabled state
397
- const disabledArea = await canvas.findByTestId('scroll-area-disabled');
398
- const disabledContainer = disabledArea.querySelector('[role="region"]');
399
- expect(disabledContainer).toHaveAttribute('tabIndex', '-1');
400
-
401
- // Test loading state
402
- const loadingArea = await canvas.findByTestId('scroll-area-loading');
403
- const loadingContainer = loadingArea.querySelector('[role="region"]');
404
- expect(loadingContainer).toHaveAttribute('aria-busy', 'true');
405
-
406
- // Test empty state
407
- const emptyArea = await canvas.findByTestId('scroll-area-empty');
408
- expect(emptyArea).toHaveTextContent('No content');
409
- },
410
- };
411
-
412
- // Test 9: Performance Test
413
- export const Performance: Story = {
414
- args: {
415
- width: 400,
416
- height: 300,
417
- smoothScroll: true,
418
- onScroll: fn(),
419
- children: (
420
- <Box sx={{ p: 2 }}>
421
- {Array.from({ length: 1000 }, (_, i) => (
422
- <Typography key={i} paragraph data-testid={`perf-line-${i}`}>
423
- Performance test line {i + 1}: Lorem ipsum dolor sit amet, consectetur adipiscing elit.
424
- </Typography>
425
- ))}
426
- </Box>
427
- ),
428
- },
429
- play: async ({ canvasElement, args }) => {
430
- const canvas = within(canvasElement);
431
-
432
- // Find scroll area
433
- const scrollArea = await canvas.findByTestId('scroll-area');
434
- const scrollContainer = scrollArea.querySelector('[role="region"]') as HTMLDivElement;
435
-
436
- expect(scrollArea).toBeInTheDocument();
437
- expect(scrollContainer).toBeInTheDocument();
438
-
439
- // Wait for content to render and ensure it's scrollable
440
- await waitFor(() => {
441
- expect(scrollContainer.scrollHeight).toBeGreaterThan(scrollContainer.clientHeight);
442
- });
443
-
444
- // Verify container is scrollable
445
- const isScrollable = scrollContainer.scrollHeight > scrollContainer.clientHeight;
446
- expect(isScrollable).toBe(true);
447
-
448
- // Test scroll functionality
449
- scrollContainer.scrollTop = 500;
450
- scrollContainer.dispatchEvent(new window.Event('scroll', { bubbles: true }));
451
-
452
- await waitFor(() => {
453
- expect(args.onScroll).toHaveBeenCalled();
454
- });
455
-
456
- // Verify scroll position changed
457
- await waitFor(() => {
458
- expect(scrollContainer.scrollTop).toBeGreaterThan(0);
459
- });
460
-
461
- // Test smooth scroll to bottom
462
- const maxScroll = scrollContainer.scrollHeight - scrollContainer.clientHeight;
463
- scrollContainer.scrollTo({ top: maxScroll, behavior: 'smooth' });
464
-
465
- await waitFor(
466
- () => {
467
- expect(scrollContainer.scrollTop).toBeGreaterThan(100);
468
- },
469
- { timeout: 3000 },
470
- );
471
-
472
- // Test scroll to top
473
- scrollContainer.scrollTop = 0;
474
- scrollContainer.dispatchEvent(new window.Event('scroll', { bubbles: true }));
475
-
476
- await waitFor(() => {
477
- expect(scrollContainer.scrollTop).toBe(0);
478
- });
479
- },
480
- };
481
-
482
- // Test 10: Edge Cases Test
483
- export const EdgeCases: Story = {
484
- args: {
485
- width: 400,
486
- height: 300,
487
- onScroll: fn(),
488
- },
489
- render: (args) => (
490
- <Box sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
491
- {/* Empty content */}
492
- <ScrollArea {...args} data-testid="scroll-area-empty">
493
- {null}
494
- </ScrollArea>
495
-
496
- {/* Very long content */}
497
- <ScrollArea {...args} height={100} data-testid="scroll-area-long">
498
- {generateContent(100)}
499
- </ScrollArea>
500
-
501
- {/* Wide content */}
502
- <ScrollArea {...args} width={200} orientation="horizontal" data-testid="scroll-area-wide">
503
- <Box sx={{ width: 1000, p: 2 }}>
504
- <Typography>Very wide content that requires horizontal scrolling</Typography>
505
- </Box>
506
- </ScrollArea>
507
-
508
- {/* No scrollable content */}
509
- <ScrollArea {...args} height={300} data-testid="scroll-area-no-scroll">
510
- <Typography>Short content</Typography>
511
- </ScrollArea>
512
- </Box>
513
- ),
514
- play: async ({ canvasElement }) => {
515
- const canvas = within(canvasElement);
516
-
517
- // Test empty content
518
- const emptyArea = await canvas.findByTestId('scroll-area-empty');
519
- expect(emptyArea).toBeInTheDocument();
520
-
521
- // Test very long content
522
- const longArea = await canvas.findByTestId('scroll-area-long');
523
- const longContainer = longArea.querySelector('[role="region"]');
524
- expect(longContainer?.scrollHeight).toBeGreaterThan(100);
525
-
526
- // Test wide content
527
- const wideArea = await canvas.findByTestId('scroll-area-wide');
528
- const wideContainer = wideArea.querySelector('[role="region"]');
529
- expect(wideContainer?.scrollWidth).toBeGreaterThan(200);
530
-
531
- // Test no scroll needed
532
- const noScrollArea = await canvas.findByTestId('scroll-area-no-scroll');
533
- const noScrollContainer = noScrollArea.querySelector('[role="region"]');
534
- expect(noScrollContainer?.scrollHeight).toBeLessThanOrEqual(300);
535
- },
536
- };
537
-
538
- // Test 11: Integration Test
539
- export const Integration: Story = {
540
- args: {
541
- width: 600,
542
- height: 400,
543
- scrollToTopButton: true,
544
- variant: 'overlay',
545
- onScroll: fn(),
546
- },
547
- render: function IntegrationRender(args) {
548
- const [scrollPosition, setScrollPosition] = React.useState(0);
549
-
550
- return (
551
- <Box>
552
- <Typography variant="h6" gutterBottom>
553
- Scroll Position: {scrollPosition}px
554
- </Typography>
555
- <ScrollArea
556
- {...args}
557
- data-testid="scroll-area"
558
- onScroll={(e) => {
559
- const target = e.target as HTMLDivElement;
560
- setScrollPosition(Math.round(target.scrollTop));
561
- args.onScroll?.(e);
562
- }}
563
- >
564
- <Box sx={{ p: 2 }}>
565
- <Button
566
- variant="contained"
567
- data-testid="action-btn"
568
- onClick={() => window.alert('Button clicked!')}
569
- >
570
- Action Button
571
- </Button>
572
- {generateContent(50)}
573
- <TextField fullWidth label="Input Field" data-testid="input-field" sx={{ mt: 2 }} />
574
- </Box>
575
- </ScrollArea>
576
- </Box>
577
- );
578
- },
579
- play: async ({ canvasElement, args }) => {
580
- const canvas = within(canvasElement);
581
-
582
- // Find elements
583
- const scrollArea = await canvas.findByTestId('scroll-area');
584
- const actionBtn = await canvas.findByTestId('action-btn');
585
- const scrollContainer = scrollArea.querySelector('[role="region"]');
586
-
587
- // Test button interaction
588
- await userEvent.click(actionBtn);
589
-
590
- // Test scrolling
591
- if (scrollContainer) {
592
- scrollContainer.scrollTop = 200;
593
- scrollContainer.dispatchEvent(new window.Event('scroll', { bubbles: true }));
594
-
595
- await waitFor(() => {
596
- expect(args.onScroll).toHaveBeenCalled();
597
- const positionText = canvas.getByText(/Scroll Position: \d+px/);
598
- expect(positionText).toBeInTheDocument();
599
- });
600
-
601
- // Scroll to bottom to find input field
602
- scrollContainer.scrollTop = scrollContainer.scrollHeight;
603
- scrollContainer.dispatchEvent(new window.Event('scroll', { bubbles: true }));
604
-
605
- await waitFor(() => {
606
- const inputField = canvas.getByTestId('input-field');
607
- expect(inputField).toBeInTheDocument();
608
- });
609
-
610
- // Test scroll to top button
611
- const scrollToTopBtn = await canvas.findByLabelText('Scroll to top');
612
- await userEvent.click(scrollToTopBtn);
613
-
614
- await waitFor(() => {
615
- expect(scrollContainer.scrollTop).toBeLessThan(50);
616
- });
617
- }
618
- },
619
- };