@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,598 +0,0 @@
1
- import { Box,Button } from '@mui/material';
2
- import type { Meta, StoryObj } from '@storybook/react-vite';
3
- import React, { useRef,useState } from 'react';
4
- import { expect, fn,userEvent, waitFor, within } from 'storybook/test';
5
-
6
- import { Lightbox } from './Lightbox';
7
- import type { LightboxItem, LightboxRef } from './Lightbox.types';
8
-
9
- const meta: Meta<typeof Lightbox> = {
10
- title: 'DataDisplay/Lightbox/Tests',
11
- component: Lightbox,
12
- parameters: {
13
- layout: 'centered',
14
- chromatic: { disableSnapshot: false },
15
- },
16
- tags: ['autodocs', 'test', 'component:Lightbox'],
17
- };
18
-
19
- export default meta;
20
- export type Story = StoryObj<typeof meta>;
21
-
22
- // Test data
23
- const testImages: LightboxItem[] = [
24
- {
25
- src: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iODAwIiBoZWlnaHQ9IjYwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjNzc3Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtc2l6ZT0iMThweCIgZmlsbD0iI2ZmZiIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9IjAuM2VtIj5UZXN0IEltYWdlIDE8L3RleHQ+PC9zdmc+',
26
- alt: 'Test Image 1',
27
- caption: 'This is the first test image',
28
- type: 'image',
29
- },
30
- {
31
- src: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAwIiBoZWlnaHQ9IjgwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjNDQ0Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtc2l6ZT0iMThweCIgZmlsbD0iI2ZmZiIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9IjAuM2VtIj5UZXN0IEltYWdlIDI8L3RleHQ+PC9zdmc+',
32
- alt: 'Test Image 2',
33
- caption: 'This is the second test image',
34
- type: 'image',
35
- },
36
- {
37
- src: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iOTAwIiBoZWlnaHQ9IjYwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjOTk5Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtc2l6ZT0iMThweCIgZmlsbD0iIzAwMCIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9IjAuM2VtIj5UZXN0IEltYWdlIDM8L3RleHQ+PC9zdmc+',
38
- alt: 'Test Image 3',
39
- caption: 'This is the third test image',
40
- type: 'image',
41
- },
42
- ];
43
-
44
- // Helper component for testing
45
- interface LightboxTestWrapperProps {
46
- onClose?: () => void;
47
- onOpen?: () => void;
48
- children?: React.ReactNode;
49
- items?: LightboxItem[];
50
- showControls?: boolean;
51
- thumbnails?: boolean;
52
- autoplay?: boolean | { interval?: number };
53
- loop?: boolean;
54
- zoomable?: boolean;
55
- }
56
-
57
- const LightboxTestWrapper = ({
58
- onClose = fn(),
59
- onOpen = fn(),
60
- children,
61
- items = testImages,
62
- ...props
63
- }: LightboxTestWrapperProps) => {
64
- const [isOpen, setIsOpen] = useState(false);
65
- const lightboxRef = useRef<LightboxRef>(null);
66
-
67
- const handleOpen = () => {
68
- setIsOpen(true);
69
- onOpen();
70
- };
71
-
72
- const handleClose = () => {
73
- setIsOpen(false);
74
- onClose();
75
- };
76
-
77
- return (
78
- <Box sx={{ padding: 2 }}>
79
- <Button data-testid="open-lightbox" onClick={handleOpen} variant="contained">
80
- Open Lightbox
81
- </Button>
82
- {children}
83
- <Lightbox
84
- ref={lightboxRef}
85
- isOpen={isOpen}
86
- onClose={handleClose}
87
- items={items}
88
- data-testid="lightbox"
89
- {...props}
90
- />
91
- </Box>
92
- );
93
- };
94
-
95
- // 1. Basic Interaction Tests
96
- export const BasicInteraction: Story = {
97
- render: () => <LightboxTestWrapper />,
98
- play: async ({ canvasElement, step }) => {
99
- const canvas = within(canvasElement);
100
-
101
- await step('Should open lightbox when trigger clicked', async () => {
102
- const openButton = canvas.getByTestId('open-lightbox');
103
- expect(openButton).toBeInTheDocument();
104
-
105
- await userEvent.click(openButton);
106
-
107
- // Wait for lightbox to open
108
- await waitFor(() => {
109
- const lightbox = document.querySelector('[role="dialog"]');
110
- expect(lightbox).toBeInTheDocument();
111
- });
112
- });
113
-
114
- await step('Should show first image by default', async () => {
115
- const image = document.querySelector('img[alt="Test Image 1"]');
116
- expect(image).toBeInTheDocument();
117
- });
118
-
119
- await step('Should close lightbox with close button', async () => {
120
- const closeButton = document.querySelector('[aria-label="Close lightbox"]');
121
- expect(closeButton).toBeInTheDocument();
122
-
123
- await userEvent.click(closeButton!);
124
-
125
- await waitFor(() => {
126
- const lightbox = document.querySelector('[role="dialog"]');
127
- expect(lightbox).not.toBeInTheDocument();
128
- });
129
- });
130
- },
131
- };
132
-
133
- // 2. Navigation Tests
134
- export const Navigation: Story = {
135
- render: () => <LightboxTestWrapper showControls={true} />,
136
- play: async ({ canvasElement, step }) => {
137
- const canvas = within(canvasElement);
138
-
139
- await step('Should open lightbox', async () => {
140
- const openButton = canvas.getByTestId('open-lightbox');
141
- await userEvent.click(openButton);
142
-
143
- await waitFor(() => {
144
- const lightbox = document.querySelector('[role="dialog"]');
145
- expect(lightbox).toBeInTheDocument();
146
- });
147
- });
148
-
149
- await step('Should navigate to next image', async () => {
150
- const nextButton = document.querySelector('[aria-label="Next item"]');
151
- expect(nextButton).toBeInTheDocument();
152
-
153
- await userEvent.click(nextButton!);
154
-
155
- await waitFor(() => {
156
- const image = document.querySelector('img[alt="Test Image 2"]');
157
- expect(image).toBeInTheDocument();
158
- });
159
- });
160
-
161
- await step('Should navigate to previous image', async () => {
162
- const prevButton = document.querySelector('[aria-label="Previous item"]');
163
- expect(prevButton).toBeInTheDocument();
164
-
165
- await userEvent.click(prevButton!);
166
-
167
- await waitFor(() => {
168
- const image = document.querySelector('img[alt="Test Image 1"]');
169
- expect(image).toBeInTheDocument();
170
- });
171
- });
172
- },
173
- };
174
-
175
- // 3. Keyboard Navigation Tests
176
- export const KeyboardNavigation: Story = {
177
- render: () => <LightboxTestWrapper showControls={true} />,
178
- play: async ({ canvasElement, step }) => {
179
- const canvas = within(canvasElement);
180
-
181
- await step('Should open lightbox', async () => {
182
- const openButton = canvas.getByTestId('open-lightbox');
183
- await userEvent.click(openButton);
184
-
185
- await waitFor(() => {
186
- const lightbox = document.querySelector('[role="dialog"]');
187
- expect(lightbox).toBeInTheDocument();
188
- });
189
- });
190
-
191
- await step('Should navigate with arrow keys', async () => {
192
- // Navigate right
193
- await userEvent.keyboard('{ArrowRight}');
194
-
195
- await waitFor(() => {
196
- const image = document.querySelector('img[alt="Test Image 2"]');
197
- expect(image).toBeInTheDocument();
198
- });
199
-
200
- // Navigate left
201
- await userEvent.keyboard('{ArrowLeft}');
202
-
203
- await waitFor(() => {
204
- const image = document.querySelector('img[alt="Test Image 1"]');
205
- expect(image).toBeInTheDocument();
206
- });
207
- });
208
-
209
- await step('Should close with Escape key', async () => {
210
- await userEvent.keyboard('{Escape}');
211
-
212
- await waitFor(() => {
213
- const lightbox = document.querySelector('[role="dialog"]');
214
- expect(lightbox).not.toBeInTheDocument();
215
- });
216
- });
217
- },
218
- };
219
-
220
- // 4. Accessibility Tests
221
- export const AccessibilityCompliance: Story = {
222
- render: () => <LightboxTestWrapper />,
223
- play: async ({ canvasElement, step }) => {
224
- const canvas = within(canvasElement);
225
-
226
- await step('Should open lightbox', async () => {
227
- const openButton = canvas.getByTestId('open-lightbox');
228
- await userEvent.click(openButton);
229
-
230
- await waitFor(() => {
231
- const lightbox = document.querySelector('[role="dialog"]');
232
- expect(lightbox).toBeInTheDocument();
233
- });
234
- });
235
-
236
- await step('Should have proper ARIA attributes', async () => {
237
- // MUI Dialog might render aria-modal on the root div or the inner dialog element
238
- const dialogWithModal = document.querySelector('[aria-modal="true"]');
239
- expect(dialogWithModal).toBeInTheDocument();
240
-
241
- // Check if the title element exists (MUI Dialog might handle aria-labelledby differently)
242
- const title = document.getElementById('lightbox-title');
243
- expect(title).toBeInTheDocument();
244
-
245
- // Verify there's a dialog with proper labeling
246
- const dialog = document.querySelector('[role="dialog"]');
247
- expect(dialog).toBeInTheDocument();
248
- const hasAriaLabel =
249
- dialog?.hasAttribute('aria-label') || dialog?.hasAttribute('aria-labelledby');
250
- expect(hasAriaLabel).toBe(true);
251
- });
252
-
253
- await step('Should have accessible controls', async () => {
254
- const closeButton = document.querySelector('[aria-label="Close lightbox"]');
255
- expect(closeButton).toBeInTheDocument();
256
-
257
- const nextButton = document.querySelector('[aria-label="Next item"]');
258
- const prevButton = document.querySelector('[aria-label="Previous item"]');
259
-
260
- if (nextButton) expect(nextButton).toBeInTheDocument();
261
- if (prevButton) expect(prevButton).toBeInTheDocument();
262
- });
263
-
264
- await step('Should have item counter', async () => {
265
- const counter = document.querySelector('[aria-live="polite"]');
266
- expect(counter).toBeInTheDocument();
267
- expect(counter).toHaveTextContent('1 / 3');
268
- });
269
- },
270
- };
271
-
272
- // 5. Zoom and Pan Tests
273
- export const ZoomAndPan: Story = {
274
- render: () => <LightboxTestWrapper zoomable={true} />,
275
- play: async ({ canvasElement, step }) => {
276
- const canvas = within(canvasElement);
277
-
278
- await step('Should open lightbox', async () => {
279
- const openButton = canvas.getByTestId('open-lightbox');
280
- await userEvent.click(openButton);
281
-
282
- await waitFor(() => {
283
- const lightbox = document.querySelector('[role="dialog"]');
284
- expect(lightbox).toBeInTheDocument();
285
- });
286
- });
287
-
288
- await step('Should show zoom controls', async () => {
289
- const zoomIn = document.querySelector('[aria-label="Zoom in"]');
290
- const zoomOut = document.querySelector('[aria-label="Zoom out"]');
291
- const resetZoom = document.querySelector('[aria-label="Reset zoom"]');
292
-
293
- expect(zoomIn).toBeInTheDocument();
294
- expect(zoomOut).toBeInTheDocument();
295
- expect(resetZoom).toBeInTheDocument();
296
- });
297
-
298
- await step('Should zoom in when zoom in button clicked', async () => {
299
- const zoomInButton = document.querySelector('[aria-label="Zoom in"]');
300
- const image = document.querySelector('img[alt="Test Image 1"]');
301
-
302
- await userEvent.click(zoomInButton!);
303
-
304
- // Check if transform style indicates zoom
305
- await waitFor(() => {
306
- const style = window.getComputedStyle(image!);
307
- // Transform is computed as matrix, check if it's scaled (not identity matrix)
308
- expect(style.transform).not.toBe('none');
309
- expect(style.transform).toMatch(/matrix/);
310
- // Matrix with scale > 1 will have values > 1 in first and fourth positions
311
- const matrixMatch = style.transform.match(/matrix\(([^,]+),/);
312
- if (matrixMatch) {
313
- const scaleValue = parseFloat(matrixMatch[1]);
314
- expect(scaleValue).toBeGreaterThan(1);
315
- }
316
- });
317
- });
318
-
319
- await step('Should reset zoom when reset button clicked', async () => {
320
- const resetButton = document.querySelector('[aria-label="Reset zoom"]');
321
- const image = document.querySelector('img[alt="Test Image 1"]');
322
-
323
- await userEvent.click(resetButton!);
324
-
325
- await waitFor(() => {
326
- const style = window.getComputedStyle(image!);
327
- // Reset should set transform back to scale(1) which shows as matrix(1, 0, 0, 1, 0, 0) or none
328
- const isIdentityMatrix =
329
- style.transform === 'matrix(1, 0, 0, 1, 0, 0)' || style.transform === 'none';
330
- expect(isIdentityMatrix).toBe(true);
331
- });
332
- });
333
- },
334
- };
335
-
336
- // 6. Thumbnails/Filmstrip Tests
337
- export const ThumbnailsFilmstrip: Story = {
338
- render: () => <LightboxTestWrapper thumbnails={true} />,
339
- play: async ({ canvasElement, step }) => {
340
- const canvas = within(canvasElement);
341
-
342
- await step('Should open lightbox', async () => {
343
- const openButton = canvas.getByTestId('open-lightbox');
344
- await userEvent.click(openButton);
345
-
346
- await waitFor(() => {
347
- const lightbox = document.querySelector('[role="dialog"]');
348
- expect(lightbox).toBeInTheDocument();
349
- });
350
- });
351
-
352
- await step('Should show thumbnail filmstrip', async () => {
353
- // Look for thumbnail images with the test image alt text
354
- const thumbnails = document.querySelectorAll('img[alt^="Test Image"]');
355
- // Filter to only get the thumbnails (smaller images in the filmstrip)
356
- const thumbnailImages = Array.from(thumbnails).filter((img) => {
357
- const width = img.clientWidth;
358
- return width <= 60; // Thumbnails are 60px wide
359
- });
360
- expect(thumbnailImages).toHaveLength(3);
361
- });
362
-
363
- await step('Should navigate when thumbnail clicked', async () => {
364
- // Find the second thumbnail (Test Image 2)
365
- const thumbnails = document.querySelectorAll('img[alt^="Test Image"]');
366
- const thumbnailImages = Array.from(thumbnails).filter((img) => {
367
- const width = img.clientWidth;
368
- return width <= 60; // Thumbnails are 60px wide
369
- });
370
-
371
- const secondThumbnail = thumbnailImages.find((img) => (img as HTMLImageElement).alt === 'Test Image 2');
372
- expect(secondThumbnail).toBeInTheDocument();
373
-
374
- await userEvent.click(secondThumbnail!.parentElement!);
375
-
376
- await waitFor(() => {
377
- const mainImage = document.querySelector('img[alt="Test Image 2"]');
378
- expect(mainImage).toBeInTheDocument();
379
- });
380
- });
381
- },
382
- };
383
-
384
- // 7. Autoplay Tests
385
- export const AutoplayFunctionality: Story = {
386
- render: () => <LightboxTestWrapper autoplay={{ interval: 1000 }} />,
387
- play: async ({ canvasElement, step }) => {
388
- const canvas = within(canvasElement);
389
-
390
- await step('Should open lightbox', async () => {
391
- const openButton = canvas.getByTestId('open-lightbox');
392
- await userEvent.click(openButton);
393
-
394
- await waitFor(() => {
395
- const lightbox = document.querySelector('[role="dialog"]');
396
- expect(lightbox).toBeInTheDocument();
397
- });
398
- });
399
-
400
- await step('Should show autoplay controls', async () => {
401
- const playPauseButton = document.querySelector('[aria-label*="slideshow"]');
402
- expect(playPauseButton).toBeInTheDocument();
403
- });
404
-
405
- await step('Should auto-advance to next image', async () => {
406
- // Wait for auto-advance (interval is 1000ms)
407
- await waitFor(
408
- () => {
409
- const image = document.querySelector('img[alt="Test Image 2"]');
410
- expect(image).toBeInTheDocument();
411
- },
412
- { timeout: 2000 },
413
- );
414
- });
415
-
416
- await step('Should pause autoplay when button clicked', async () => {
417
- const pauseButton = document.querySelector('[aria-label="Pause slideshow"]');
418
- if (pauseButton) {
419
- await userEvent.click(pauseButton);
420
-
421
- // Verify it changes to play button
422
- await waitFor(() => {
423
- const playButton = document.querySelector('[aria-label="Start slideshow"]');
424
- expect(playButton).toBeInTheDocument();
425
- });
426
- }
427
- });
428
- },
429
- };
430
-
431
- // 8. Loop Navigation Tests
432
- export const LoopNavigation: Story = {
433
- render: () => <LightboxTestWrapper loop={true} showControls={true} />,
434
- play: async ({ canvasElement, step }) => {
435
- const canvas = within(canvasElement);
436
-
437
- await step('Should open lightbox', async () => {
438
- const openButton = canvas.getByTestId('open-lightbox');
439
- await userEvent.click(openButton);
440
-
441
- await waitFor(() => {
442
- const lightbox = document.querySelector('[role="dialog"]');
443
- expect(lightbox).toBeInTheDocument();
444
- });
445
- });
446
-
447
- await step('Should wrap to last image when going previous from first', async () => {
448
- const prevButton = document.querySelector('[aria-label="Previous item"]');
449
- expect(prevButton).toBeInTheDocument();
450
- expect(prevButton).not.toBeDisabled();
451
-
452
- await userEvent.click(prevButton!);
453
-
454
- await waitFor(() => {
455
- const image = document.querySelector('img[alt="Test Image 3"]');
456
- expect(image).toBeInTheDocument();
457
- });
458
- });
459
-
460
- await step('Should wrap to first image when going next from last', async () => {
461
- const nextButton = document.querySelector('[aria-label="Next item"]');
462
- expect(nextButton).toBeInTheDocument();
463
- expect(nextButton).not.toBeDisabled();
464
-
465
- await userEvent.click(nextButton!);
466
-
467
- await waitFor(() => {
468
- const image = document.querySelector('img[alt="Test Image 1"]');
469
- expect(image).toBeInTheDocument();
470
- });
471
- });
472
- },
473
- };
474
-
475
- // 9. Edge Cases Tests
476
- export const EdgeCases: Story = {
477
- render: () => <LightboxTestWrapper items={[]} />,
478
- play: async ({ canvasElement, step }) => {
479
- const canvas = within(canvasElement);
480
-
481
- await step('Should handle empty items array', async () => {
482
- const openButton = canvas.getByTestId('open-lightbox');
483
- await userEvent.click(openButton);
484
-
485
- // Lightbox should still open but show no content
486
- await waitFor(() => {
487
- const lightbox = document.querySelector('[role="dialog"]');
488
- expect(lightbox).toBeInTheDocument();
489
- });
490
-
491
- // The close button always renders, so waiting for it first means the
492
- // absence checks below describe what an empty gallery omits, rather than
493
- // passing because nothing had rendered yet.
494
- await waitFor(() => {
495
- expect(document.querySelector('[aria-label="Close lightbox"]')).toBeInTheDocument();
496
- expect(document.querySelector('[aria-label="Next item"]')).not.toBeInTheDocument();
497
- expect(document.querySelector('[aria-label="Previous item"]')).not.toBeInTheDocument();
498
- });
499
- });
500
- },
501
- };
502
-
503
- // 10. Single Image Tests
504
- export const SingleImageGallery: Story = {
505
- render: () => <LightboxTestWrapper items={[testImages[0]]} showControls={true} />,
506
- play: async ({ canvasElement, step }) => {
507
- const canvas = within(canvasElement);
508
-
509
- await step('Should open lightbox with single image', async () => {
510
- const openButton = canvas.getByTestId('open-lightbox');
511
- await userEvent.click(openButton);
512
-
513
- await waitFor(() => {
514
- const lightbox = document.querySelector('[role="dialog"]');
515
- expect(lightbox).toBeInTheDocument();
516
- });
517
- });
518
-
519
- await step('Should not show navigation controls for single image', async () => {
520
- // The close button proves the overlay rendered, so the absences here are
521
- // about what a one-item gallery omits rather than about timing.
522
- await waitFor(() => {
523
- expect(document.querySelector('[aria-label="Close lightbox"]')).toBeInTheDocument();
524
- expect(document.querySelector('[aria-label="Next item"]')).not.toBeInTheDocument();
525
- expect(document.querySelector('[aria-label="Previous item"]')).not.toBeInTheDocument();
526
- });
527
- });
528
-
529
- await step('Should show correct counter for single image', async () => {
530
- await waitFor(() => {
531
- // No counter for single image
532
- expect(document.querySelector('[aria-live="polite"]')).not.toBeInTheDocument();
533
- });
534
- });
535
- },
536
- };
537
-
538
- // 11. Open and navigate.
539
- // The two steps below used to bracket their waitFor calls with Date.now() and
540
- // assert 2s/500ms budgets. Those measured the machine rather than the component,
541
- // and could not fail independently of the waitFor timeout that already bounds
542
- // each wait.
543
- export const Performance: Story = {
544
- render: () => <LightboxTestWrapper />,
545
- play: async ({ canvasElement, step }) => {
546
- const canvas = within(canvasElement);
547
-
548
- await step('Should open lightbox', async () => {
549
- const openButton = canvas.getByTestId('open-lightbox');
550
- await userEvent.click(openButton);
551
-
552
- await waitFor(() => {
553
- expect(document.querySelector('[role="dialog"]')).toBeInTheDocument();
554
- });
555
- });
556
-
557
- await step('Should navigate between images', async () => {
558
- const nextButton = document.querySelector('[aria-label="Next item"]');
559
- await userEvent.click(nextButton!);
560
-
561
- await waitFor(() => {
562
- expect(document.querySelector('img[alt="Test Image 2"]')).toBeInTheDocument();
563
- });
564
- });
565
- },
566
- };
567
-
568
- // 12. Focus Management Tests
569
- export const FocusManagement: Story = {
570
- render: () => <LightboxTestWrapper />,
571
- play: async ({ canvasElement, step }) => {
572
- const canvas = within(canvasElement);
573
-
574
- await step('Should focus close button when lightbox opens', async () => {
575
- const openButton = canvas.getByTestId('open-lightbox');
576
- await userEvent.click(openButton);
577
-
578
- await waitFor(() => {
579
- const closeButton = document.querySelector('[aria-label="Close lightbox"]');
580
- expect(closeButton).toBeInTheDocument();
581
- // Focus management is handled by MUI Dialog
582
- expect(document.activeElement).toBeDefined();
583
- });
584
- });
585
-
586
- await step('Should trap focus within lightbox', async () => {
587
- // Tab through elements - focus should stay within dialog
588
- await userEvent.tab();
589
- await userEvent.tab();
590
- await userEvent.tab();
591
-
592
- // Focus should still be within the dialog
593
- const dialog = document.querySelector('[role="dialog"]');
594
- const activeElement = document.activeElement;
595
- expect(dialog!.contains(activeElement)).toBe(true);
596
- });
597
- },
598
- };