@12-apps/ui 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/package.json +16 -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 -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,92 +0,0 @@
1
- import { render, screen } from "@testing-library/react";
2
- import { describe, expect, it } from "vitest";
3
-
4
- import { CardGrid } from "../CardGrid";
5
-
6
- /** The rendered grid container's inline `grid-auto-columns` track sizing. */
7
- function trackOf(children: number): string {
8
- const { unmount } = render(
9
- <CardGrid variant="scroll" cardWidth={165} maxCardWidth={190} gridTestId="rail">
10
- {Array.from({ length: children }, (_, i) => (
11
- <div key={i}>card {i}</div>
12
- ))}
13
- </CardGrid>,
14
- );
15
- const track = screen.getByTestId("rail").style.gridAutoColumns;
16
- unmount();
17
- return track;
18
- }
19
-
20
- describe("CardGrid scroll variant", () => {
21
- it("sizes tracks so two cards plus a peek of the third always fit", () => {
22
- // 2 cards + the 2 gaps that follow them + the 28px peek = the container.
23
- expect(trackOf(3)).toBe("min(190px, calc((100% - 60px) / 2))");
24
- });
25
-
26
- it("keeps the peek at every rail length past the fold", () => {
27
- expect(trackOf(7)).toBe(trackOf(3));
28
- });
29
-
30
- it("reserves no peek when there is nothing to scroll to", () => {
31
- // Two cards: no overflow, so no "there's more" hint to make room for —
32
- // they divide the row across the single gap between them.
33
- expect(trackOf(2)).toBe("min(190px, calc((100% - 16px) / 2))");
34
- expect(trackOf(1)).toBe("min(190px, calc((100% - 0px) / 1))");
35
- });
36
-
37
- it("never floors the track at cardWidth — a floor would swallow the peek", () => {
38
- // The narrow-phone guarantee only holds if the track can shrink below the
39
- // nominal card width; a `min-width` is exactly what broke it before.
40
- expect(trackOf(5)).not.toContain("165px");
41
- });
42
-
43
- it("defaults maxCardWidth to 1.6 × cardWidth", () => {
44
- render(
45
- <CardGrid variant="scroll" cardWidth={100} gridTestId="default-max">
46
- <div>a</div>
47
- <div>b</div>
48
- <div>c</div>
49
- </CardGrid>,
50
- );
51
- expect(screen.getByTestId("default-max").style.gridAutoColumns).toContain("160px");
52
- });
53
-
54
- it("scrolls horizontally and snaps each card to the rail start", () => {
55
- render(
56
- <CardGrid variant="scroll" cardWidth={165} gridTestId="snap">
57
- <div>a</div>
58
- <div>b</div>
59
- <div>c</div>
60
- </CardGrid>,
61
- );
62
- const rail = screen.getByTestId("snap");
63
- expect(rail.style.overflowX).toBe("auto");
64
- expect(rail.style.scrollSnapType).toBe("x mandatory");
65
- expect(rail.children).toHaveLength(3);
66
- for (const child of rail.children) {
67
- expect((child as HTMLElement).style.scrollSnapAlign).toBe("start");
68
- }
69
- });
70
- });
71
-
72
- describe("CardGrid wrapping variants", () => {
73
- it("leaves the fluid and fixed track math untouched", () => {
74
- render(
75
- <CardGrid variant="fluid" cardWidth={165} gridTestId="fluid">
76
- <div>a</div>
77
- </CardGrid>,
78
- );
79
- render(
80
- <CardGrid variant="fixed" cardWidth={230} gridTestId="fixed">
81
- <div>a</div>
82
- </CardGrid>,
83
- );
84
- expect(screen.getByTestId("fluid").style.gridTemplateColumns).toBe(
85
- "repeat(auto-fill, minmax(165px, 1fr))",
86
- );
87
- expect(screen.getByTestId("fixed").style.gridTemplateColumns).toBe(
88
- "repeat(auto-fill, 230px)",
89
- );
90
- expect(screen.getByTestId("fixed").style.justifyContent).toBe("space-around");
91
- });
92
- });
@@ -1,180 +0,0 @@
1
- import { Box,Card, Typography } from '@mui/material';
2
- import type { Meta, StoryObj } from '@storybook/react-vite';
3
- import { fn } from 'storybook/test';
4
-
5
- import { Collapsible, CollapsibleContent,CollapsibleTrigger } from './Collapsible';
6
-
7
- const meta: Meta<typeof Collapsible> = {
8
- title: 'Layout/Collapsible',
9
- component: Collapsible,
10
- parameters: {
11
- layout: 'padded',
12
- },
13
- tags: ['autodocs', 'component:Collapsible'],
14
- argTypes: {
15
- variant: {
16
- control: { type: 'select' },
17
- options: ['default', 'smooth', 'spring'],
18
- },
19
- duration: {
20
- control: { type: 'number' },
21
- min: 100,
22
- max: 1000,
23
- step: 50,
24
- },
25
- keepMounted: {
26
- control: { type: 'boolean' },
27
- },
28
- },
29
- };
30
-
31
- export default meta;
32
- type Story = StoryObj<typeof meta>;
33
-
34
- export const Default: Story = {
35
- args: {
36
- open: true,
37
- variant: 'default',
38
- duration: 300,
39
- keepMounted: false,
40
- onToggle: fn(),
41
- },
42
- render: (args) => (
43
- <Collapsible {...args}>
44
- <CollapsibleContent>
45
- <Typography variant="body1">
46
- This is the default collapsible content. It uses MUI's built-in Collapse component for
47
- smooth animations.
48
- </Typography>
49
- </CollapsibleContent>
50
- </Collapsible>
51
- ),
52
- };
53
-
54
- export const AllVariants: Story = {
55
- render: () => (
56
- <Box>
57
- <Typography variant="h6" sx={{ mb: 2 }}>
58
- Default Variant
59
- </Typography>
60
- <Collapsible open={true} variant="default" duration={300}>
61
- <CollapsibleContent>
62
- <Typography variant="body2">Default variant content</Typography>
63
- </CollapsibleContent>
64
- </Collapsible>
65
-
66
- <Typography variant="h6" sx={{ mt: 3, mb: 2 }}>
67
- Smooth Variant
68
- </Typography>
69
- <Collapsible open={true} variant="smooth" duration={300}>
70
- <CollapsibleContent>
71
- <Typography variant="body2">Smooth variant content</Typography>
72
- </CollapsibleContent>
73
- </Collapsible>
74
-
75
- <Typography variant="h6" sx={{ mt: 3, mb: 2 }}>
76
- Spring Variant
77
- </Typography>
78
- <Collapsible open={true} variant="spring" duration={300}>
79
- <CollapsibleContent>
80
- <Typography variant="body2">Spring variant content</Typography>
81
- </CollapsibleContent>
82
- </Collapsible>
83
- </Box>
84
- ),
85
- };
86
-
87
- export const AllSizes: Story = {
88
- render: () => (
89
- <Box>
90
- <Typography variant="h6" sx={{ mb: 2 }}>
91
- Small Content
92
- </Typography>
93
- <Collapsible open={true} variant="smooth" duration={250}>
94
- <CollapsibleContent>
95
- <Typography variant="body2">Short content example.</Typography>
96
- </CollapsibleContent>
97
- </Collapsible>
98
-
99
- <Typography variant="h6" sx={{ mt: 3, mb: 2 }}>
100
- Medium Content
101
- </Typography>
102
- <Collapsible open={true} variant="smooth" duration={350}>
103
- <CollapsibleContent>
104
- <Typography variant="body2" sx={{ mb: 2 }}>
105
- This is a medium-sized content area with multiple paragraphs.
106
- </Typography>
107
- <Typography variant="body2">
108
- The animation duration can be adjusted based on content size.
109
- </Typography>
110
- </CollapsibleContent>
111
- </Collapsible>
112
- </Box>
113
- ),
114
- };
115
-
116
- export const AllStates: Story = {
117
- render: () => (
118
- <Box>
119
- <Typography variant="h6" sx={{ mb: 2 }}>
120
- Open State
121
- </Typography>
122
- <Collapsible open={true} variant="default">
123
- <CollapsibleContent>
124
- <Typography variant="body2">This is an open collapsible.</Typography>
125
- </CollapsibleContent>
126
- </Collapsible>
127
-
128
- <Typography variant="h6" sx={{ mt: 3, mb: 2 }}>
129
- Closed State
130
- </Typography>
131
- <Collapsible open={false} variant="default">
132
- <CollapsibleContent>
133
- <Typography variant="body2">This content should not be visible.</Typography>
134
- </CollapsibleContent>
135
- </Collapsible>
136
-
137
- <Typography variant="h6" sx={{ mt: 3, mb: 2 }}>
138
- Disabled State
139
- </Typography>
140
- <Collapsible open={false} variant="default" disabled>
141
- <CollapsibleContent>
142
- <Typography variant="body2">This content is disabled.</Typography>
143
- </CollapsibleContent>
144
- </Collapsible>
145
- </Box>
146
- ),
147
- };
148
-
149
- export const InteractiveStates: Story = {
150
- render: () => (
151
- <Card>
152
- <CollapsibleTrigger>
153
- <Typography variant="subtitle1">Static Trigger</Typography>
154
- </CollapsibleTrigger>
155
- <Collapsible open={true} variant="smooth" duration={300}>
156
- <CollapsibleContent>
157
- <Typography variant="body2">Interactive content (static for story purposes).</Typography>
158
- </CollapsibleContent>
159
- </Collapsible>
160
- </Card>
161
- ),
162
- };
163
-
164
- export const Responsive: Story = {
165
- render: () => (
166
- <Box sx={{ width: '100%', maxWidth: { xs: '100%', sm: '600px', md: '800px' } }}>
167
- <Collapsible open={true} variant="smooth" duration={400}>
168
- <CollapsibleContent>
169
- <Typography variant="body1" gutterBottom>
170
- Responsive Content Layout
171
- </Typography>
172
- <Typography variant="body2">
173
- The collapsible component adapts to different screen sizes while maintaining smooth
174
- animations.
175
- </Typography>
176
- </CollapsibleContent>
177
- </Collapsible>
178
- </Box>
179
- ),
180
- };
@@ -1,308 +0,0 @@
1
- import ExpandLess from '@mui/icons-material/ExpandLess';
2
- import ExpandMore from '@mui/icons-material/ExpandMore';
3
- import { Box,Button, Card, Stack, Typography } from '@mui/material';
4
- import type { Meta, StoryObj } from '@storybook/react-vite';
5
- import { useState } from 'react';
6
- import { expect, userEvent, waitFor,within } from 'storybook/test';
7
-
8
- import { Collapsible, CollapsibleContent,CollapsibleTrigger } from './Collapsible';
9
-
10
- const meta: Meta<typeof Collapsible> = {
11
- title: 'Layout/Collapsible/Tests',
12
- component: Collapsible,
13
- parameters: {
14
- layout: 'centered',
15
- chromatic: { disableSnapshot: false },
16
- },
17
- tags: ['autodocs', 'test', 'component:Collapsible'],
18
- };
19
-
20
- export default meta;
21
- type Story = StoryObj<typeof meta>;
22
-
23
- // Basic Interaction Tests
24
- export const BasicInteraction: Story = {
25
- name: '🧪 Basic Interaction Test',
26
- render: () => {
27
- const InteractiveExample = () => {
28
- const [isOpen, setIsOpen] = useState(false);
29
-
30
- return (
31
- <div data-testid="collapsible-container">
32
- <Card>
33
- <CollapsibleTrigger
34
- onClick={() => setIsOpen(!isOpen)}
35
- expanded={isOpen}
36
- data-testid="collapsible-trigger"
37
- >
38
- <Typography variant="h6">Toggle Content</Typography>
39
- {isOpen ? <ExpandLess /> : <ExpandMore />}
40
- </CollapsibleTrigger>
41
- <Collapsible open={isOpen} data-testid="collapsible-content">
42
- <CollapsibleContent>
43
- <Typography variant="body1" data-testid="content-text">
44
- This is the collapsible content that can be toggled.
45
- </Typography>
46
- </CollapsibleContent>
47
- </Collapsible>
48
- </Card>
49
- </div>
50
- );
51
- };
52
-
53
- return <InteractiveExample />;
54
- },
55
- play: async ({ canvasElement, step }) => {
56
- const canvas = within(canvasElement);
57
-
58
- await step('Initial render verification', async () => {
59
- const container = canvas.getByTestId('collapsible-container');
60
- await expect(container).toBeInTheDocument();
61
-
62
- const trigger = canvas.getByTestId('collapsible-trigger');
63
- await expect(trigger).toBeInTheDocument();
64
- await expect(trigger).toHaveAttribute('aria-expanded', 'false');
65
- });
66
-
67
- await step('Click to expand', async () => {
68
- const trigger = canvas.getByTestId('collapsible-trigger');
69
- await userEvent.click(trigger);
70
-
71
- await waitFor(() => {
72
- expect(trigger).toHaveAttribute('aria-expanded', 'true');
73
- });
74
- });
75
-
76
- await step('Click to collapse', async () => {
77
- const trigger = canvas.getByTestId('collapsible-trigger');
78
- await userEvent.click(trigger);
79
-
80
- await waitFor(() => {
81
- expect(trigger).toHaveAttribute('aria-expanded', 'false');
82
- });
83
- });
84
- },
85
- };
86
-
87
- // Keyboard Navigation Tests
88
- export const KeyboardNavigation: Story = {
89
- name: '⌨️ Keyboard Navigation Test',
90
- render: () => (
91
- <div data-testid="keyboard-container">
92
- <Card>
93
- <CollapsibleTrigger onClick={() => {}} expanded={false} data-testid="keyboard-trigger">
94
- <Typography variant="h6">Keyboard Accessible Trigger</Typography>
95
- </CollapsibleTrigger>
96
- <Collapsible open={false} data-testid="keyboard-collapsible">
97
- <CollapsibleContent>
98
- <Typography variant="body1">Content for keyboard navigation</Typography>
99
- </CollapsibleContent>
100
- </Collapsible>
101
- </Card>
102
- </div>
103
- ),
104
- play: async ({ canvasElement, step }) => {
105
- const canvas = within(canvasElement);
106
-
107
- await step('Focus trigger with Tab', async () => {
108
- const trigger = canvas.getByTestId('keyboard-trigger');
109
- // Tab rather than .focus(): the trigger is the only focusable node in this
110
- // story, so this proves it is reachable by keyboard — which is what the
111
- // step claims to check. Asserting that .focus() focused only tests the DOM.
112
- await userEvent.tab();
113
- await waitFor(() => expect(trigger).toHaveFocus());
114
- });
115
-
116
- await step('Verify keyboard accessibility', async () => {
117
- const trigger = canvas.getByTestId('keyboard-trigger');
118
- await expect(trigger).toHaveAttribute('role', 'button');
119
- await expect(trigger).toHaveAttribute('tabIndex', '0');
120
- });
121
- },
122
- };
123
-
124
- // Focus Management Tests
125
- export const FocusManagement: Story = {
126
- name: '🎯 Focus Management Test',
127
- render: () => (
128
- <div data-testid="focus-container">
129
- <Card>
130
- <CollapsibleTrigger onClick={() => {}} expanded={false} data-testid="focus-trigger">
131
- <Typography variant="h6">Focus Test</Typography>
132
- </CollapsibleTrigger>
133
- <Collapsible open={true} data-testid="focus-collapsible">
134
- <CollapsibleContent>
135
- <Button data-testid="focus-button">Focusable Element</Button>
136
- </CollapsibleContent>
137
- </Collapsible>
138
- </Card>
139
- </div>
140
- ),
141
- play: async ({ canvasElement, step }) => {
142
- const canvas = within(canvasElement);
143
-
144
- await step('Verify focus management', async () => {
145
- const trigger = canvas.getByTestId('focus-trigger');
146
- const button = canvas.getByTestId('focus-button');
147
-
148
- await expect(trigger).toBeInTheDocument();
149
- await expect(button).toBeInTheDocument();
150
- });
151
- },
152
- };
153
-
154
- // Responsive Design Tests
155
- export const ResponsiveDesign: Story = {
156
- name: '📱 Responsive Design Test',
157
- render: () => (
158
- <Box
159
- sx={{ width: '100%', maxWidth: { xs: '100%', sm: '600px', md: '800px' } }}
160
- data-testid="responsive-container"
161
- >
162
- <Card>
163
- <CollapsibleTrigger onClick={() => {}} expanded={false} data-testid="responsive-trigger">
164
- <Typography variant="h6">Responsive Collapsible</Typography>
165
- </CollapsibleTrigger>
166
- <Collapsible open={true} data-testid="responsive-collapsible">
167
- <CollapsibleContent>
168
- <Typography variant="body1">
169
- This content adapts to different screen sizes while maintaining functionality.
170
- </Typography>
171
- </CollapsibleContent>
172
- </Collapsible>
173
- </Card>
174
- </Box>
175
- ),
176
- play: async ({ canvasElement, step }) => {
177
- const canvas = within(canvasElement);
178
-
179
- await step('Verify responsive container', async () => {
180
- const container = canvas.getByTestId('responsive-container');
181
- await expect(container).toBeInTheDocument();
182
- });
183
-
184
- await step('Verify responsive elements', async () => {
185
- const trigger = canvas.getByTestId('responsive-trigger');
186
- const collapsible = canvas.getByTestId('responsive-collapsible');
187
-
188
- await expect(trigger).toBeInTheDocument();
189
- await expect(collapsible).toBeInTheDocument();
190
- });
191
- },
192
- };
193
-
194
- // Theme Variations Tests
195
- export const ThemeVariations: Story = {
196
- name: '🎨 Theme Variations Test',
197
- render: () => (
198
- <Stack spacing={2} data-testid="theme-container">
199
- <Card>
200
- <CollapsibleTrigger onClick={() => {}} expanded={false} data-testid="theme-trigger">
201
- <Typography variant="h6">Theme Test</Typography>
202
- </CollapsibleTrigger>
203
- <Collapsible open={true} data-testid="theme-collapsible">
204
- <CollapsibleContent>
205
- <Typography variant="body1">Content with theme integration</Typography>
206
- </CollapsibleContent>
207
- </Collapsible>
208
- </Card>
209
- </Stack>
210
- ),
211
- play: async ({ canvasElement, step }) => {
212
- const canvas = within(canvasElement);
213
-
214
- await step('Verify theme integration', async () => {
215
- const container = canvas.getByTestId('theme-container');
216
- await expect(container).toBeInTheDocument();
217
- });
218
- },
219
- };
220
-
221
- // Visual States Tests
222
- export const VisualStates: Story = {
223
- name: '👁️ Visual States Test',
224
- render: () => (
225
- <Stack spacing={2} data-testid="visual-container">
226
- <Card>
227
- <CollapsibleTrigger onClick={() => {}} expanded={true} data-testid="expanded-trigger">
228
- <Typography variant="h6">Expanded State</Typography>
229
- </CollapsibleTrigger>
230
- <Collapsible open={true} data-testid="expanded-collapsible">
231
- <CollapsibleContent>
232
- <Typography variant="body1">Visible content</Typography>
233
- </CollapsibleContent>
234
- </Collapsible>
235
- </Card>
236
-
237
- <Card>
238
- <CollapsibleTrigger onClick={() => {}} expanded={false} data-testid="collapsed-trigger">
239
- <Typography variant="h6">Collapsed State</Typography>
240
- </CollapsibleTrigger>
241
- <Collapsible open={false} data-testid="collapsed-collapsible">
242
- <CollapsibleContent>
243
- <Typography variant="body1">Hidden content</Typography>
244
- </CollapsibleContent>
245
- </Collapsible>
246
- </Card>
247
- </Stack>
248
- ),
249
- play: async ({ canvasElement, step }) => {
250
- const canvas = within(canvasElement);
251
-
252
- await step('Verify expanded state', async () => {
253
- const expandedTrigger = canvas.getByTestId('expanded-trigger');
254
- await expect(expandedTrigger).toHaveAttribute('aria-expanded', 'true');
255
- });
256
-
257
- await step('Verify collapsed state', async () => {
258
- const collapsedTrigger = canvas.getByTestId('collapsed-trigger');
259
- await expect(collapsedTrigger).toHaveAttribute('aria-expanded', 'false');
260
- });
261
- },
262
- };
263
-
264
- // Edge Cases Tests
265
- export const EdgeCases: Story = {
266
- name: '🔍 Edge Cases Test',
267
- render: () => (
268
- <Stack spacing={2} data-testid="edge-cases-container">
269
- <Card>
270
- <CollapsibleTrigger
271
- onClick={() => {}}
272
- expanded={false}
273
- disabled
274
- data-testid="disabled-trigger"
275
- >
276
- <Typography variant="h6">Disabled Trigger</Typography>
277
- </CollapsibleTrigger>
278
- <Collapsible open={false} disabled data-testid="disabled-collapsible">
279
- <CollapsibleContent>
280
- <Typography variant="body1">Disabled content</Typography>
281
- </CollapsibleContent>
282
- </Collapsible>
283
- </Card>
284
-
285
- <Card>
286
- <CollapsibleTrigger onClick={() => {}} expanded={true} data-testid="empty-trigger">
287
- <Typography variant="h6">Empty Content</Typography>
288
- </CollapsibleTrigger>
289
- <Collapsible open={true} data-testid="empty-collapsible">
290
- <CollapsibleContent></CollapsibleContent>
291
- </Collapsible>
292
- </Card>
293
- </Stack>
294
- ),
295
- play: async ({ canvasElement, step }) => {
296
- const canvas = within(canvasElement);
297
-
298
- await step('Verify disabled state', async () => {
299
- const disabledTrigger = canvas.getByTestId('disabled-trigger');
300
- await expect(disabledTrigger).toHaveAttribute('disabled');
301
- });
302
-
303
- await step('Verify empty content handling', async () => {
304
- const emptyCollapsible = canvas.getByTestId('empty-collapsible');
305
- await expect(emptyCollapsible).toBeInTheDocument();
306
- });
307
- },
308
- };