@12-apps/ui 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +16 -8
- package/src/button/index.ts +1 -0
- package/src/social-login-button/index.ts +1 -0
- package/src/{social-login-button.tsx → social-login-button/social-login-button.tsx} +5 -5
- package/src/user-avatar/index.ts +1 -0
- package/src/{user-avatar.tsx → user-avatar/user-avatar.tsx} +4 -4
- package/eslint.config.js +0 -89
- package/src/__tests__/data-grid.test.tsx +0 -125
- package/src/__tests__/package-wiring.test.ts +0 -41
- package/src/__tests__/setup.ts +0 -1
- package/src/__tests__/social-login-button.test.tsx +0 -186
- package/src/__tests__/user-avatar.test.tsx +0 -195
- package/src/__tests__/viewport.test.ts +0 -50
- package/src/components/command/__tests__/command.test.tsx +0 -112
- package/src/components/data-display/Alert/Alert.stories.tsx +0 -559
- package/src/components/data-display/Alert/Alert.test.stories.tsx +0 -707
- package/src/components/data-display/AlertDialog/AlertDialog.stories.tsx +0 -362
- package/src/components/data-display/AlertDialog/AlertDialog.test.stories.tsx +0 -763
- package/src/components/data-display/AsyncStateContainer/AsyncStateContainer.stories.tsx +0 -230
- package/src/components/data-display/AsyncStateContainer/AsyncStateContainer.test.stories.tsx +0 -270
- package/src/components/data-display/Avatar/Avatar.stories.tsx +0 -721
- package/src/components/data-display/Avatar/Avatar.test.stories.tsx +0 -822
- package/src/components/data-display/Badge/Badge.stories.tsx +0 -1134
- package/src/components/data-display/Badge/Badge.test.stories.tsx +0 -1194
- package/src/components/data-display/Banner/Banner.stories.tsx +0 -528
- package/src/components/data-display/Banner/Banner.test.stories.tsx +0 -511
- package/src/components/data-display/Carousel/Carousel.stories.tsx +0 -607
- package/src/components/data-display/Carousel/Carousel.test.stories.tsx +0 -701
- package/src/components/data-display/Chart/Chart.stories.tsx +0 -568
- package/src/components/data-display/Chart/Chart.test.stories.tsx +0 -174
- package/src/components/data-display/Chart/SpecChart.stories.tsx +0 -150
- package/src/components/data-display/Chart/SpecChart.test.stories.tsx +0 -56
- package/src/components/data-display/Chart/__tests__/SpecChart.test.tsx +0 -60
- package/src/components/data-display/Chart/__tests__/chart-format.test.ts +0 -43
- package/src/components/data-display/Chart/__tests__/chart-spec.test.ts +0 -119
- package/src/components/data-display/Chip/Chip.stories.tsx +0 -252
- package/src/components/data-display/Chip/Chip.test.stories.tsx +0 -266
- package/src/components/data-display/DataGrid/DataGrid.stories.tsx +0 -515
- package/src/components/data-display/DataGrid/DataGrid.test.stories.tsx +0 -653
- package/src/components/data-display/DataViews/__tests__/DataViewsGrid.test.tsx +0 -271
- package/src/components/data-display/DataViews/__tests__/DataViewsTableBase.test.tsx +0 -134
- package/src/components/data-display/DataViews/__tests__/SaveViewModal.test.tsx +0 -83
- package/src/components/data-display/DataViews/__tests__/data-views-filter.test.ts +0 -115
- package/src/components/data-display/DataViews/__tests__/data-views-preview.test.ts +0 -53
- package/src/components/data-display/DataViews/__tests__/range-pill.test.tsx +0 -114
- package/src/components/data-display/DataViews/base-card.stories.tsx +0 -136
- package/src/components/data-display/DescriptionItem/DescriptionItem.stories.tsx +0 -254
- package/src/components/data-display/EmptyState/EmptyState.stories.tsx +0 -282
- package/src/components/data-display/EmptyState/EmptyState.test.stories.tsx +0 -441
- package/src/components/data-display/ErrorState/ErrorState.stories.tsx +0 -110
- package/src/components/data-display/ErrorState/ErrorState.test.stories.tsx +0 -133
- package/src/components/data-display/HoverCard/HoverCard.stories.tsx +0 -650
- package/src/components/data-display/HoverCard/HoverCard.test.stories.tsx +0 -929
- package/src/components/data-display/InteractiveTooltip/InteractiveTooltip.stories.tsx +0 -411
- package/src/components/data-display/LazyImage/LazyImage.stories.tsx +0 -387
- package/src/components/data-display/Lightbox/Lightbox.stories.tsx +0 -315
- package/src/components/data-display/Lightbox/Lightbox.test.stories.tsx +0 -598
- package/src/components/data-display/LoadingState/LoadingState.stories.tsx +0 -124
- package/src/components/data-display/LoadingState/LoadingState.test.stories.tsx +0 -99
- package/src/components/data-display/MapPreview/MapPreview.stories.tsx +0 -458
- package/src/components/data-display/MapPreview/MapPreview.test.stories.tsx +0 -394
- package/src/components/data-display/Popover/Popover.stories.tsx +0 -295
- package/src/components/data-display/Popover/Popover.test.stories.tsx +0 -1162
- package/src/components/data-display/Progress/Progress.stories.tsx +0 -481
- package/src/components/data-display/Progress/Progress.test.stories.tsx +0 -2070
- package/src/components/data-display/SectionOnboarding/SectionOnboarding.stories.tsx +0 -160
- package/src/components/data-display/SectionOnboarding/SectionOnboarding.test.stories.tsx +0 -190
- package/src/components/data-display/Sheet/Sheet.stories.tsx +0 -883
- package/src/components/data-display/Sheet/Sheet.test.stories.tsx +0 -1105
- package/src/components/data-display/StatCard/StatCard.stories.tsx +0 -167
- package/src/components/data-display/StatCard/StatCard.test.stories.tsx +0 -240
- package/src/components/data-display/Stepper/Stepper.stories.tsx +0 -540
- package/src/components/data-display/Stepper/Stepper.test.stories.tsx +0 -600
- package/src/components/data-display/Table/Table.stories.tsx +0 -803
- package/src/components/data-display/Table/Table.test.stories.tsx +0 -369
- package/src/components/data-display/Timeline/Timeline.stories.tsx +0 -442
- package/src/components/data-display/Timeline/Timeline.test.stories.tsx +0 -930
- package/src/components/data-display/TimingDiagram/TimingDiagram.stories.tsx +0 -475
- package/src/components/data-display/TimingDiagram/TimingDiagram.test.stories.tsx +0 -734
- package/src/components/data-display/Tooltip/Tooltip.stories.tsx +0 -468
- package/src/components/data-display/Tooltip/Tooltip.test.stories.tsx +0 -1154
- package/src/components/feedback/ConfirmAction/ConfirmAction.stories.tsx +0 -146
- package/src/components/feedback/ConfirmAction/ConfirmAction.test.stories.tsx +0 -114
- package/src/components/feedback/ConfirmAction/__tests__/confirm-action.test.tsx +0 -288
- package/src/components/feedback/Dialog/Dialog.stories.tsx +0 -833
- package/src/components/feedback/Dialog/Dialog.test.stories.tsx +0 -964
- package/src/components/feedback/Dialog/__tests__/dialog-content-spacing.test.tsx +0 -66
- package/src/components/feedback/Modal/Modal.stories.tsx +0 -765
- package/src/components/feedback/Modal/Modal.test.stories.tsx +0 -251
- package/src/components/feedback/Sonner/Sonner.stories.tsx +0 -698
- package/src/components/feedback/Sonner/Sonner.test.stories.tsx +0 -896
- package/src/components/feedback/StackedModal/StackedModal.stories.tsx +0 -1783
- package/src/components/feedback/StackedModal/StackedModal.test.stories.tsx +0 -973
- package/src/components/feedback/StackedModal/__tests__/stacked-modal-viewport.test.tsx +0 -104
- package/src/components/feedback/Toast/Toast.stories.tsx +0 -548
- package/src/components/feedback/Toast/Toast.test.stories.tsx +0 -834
- package/src/components/feedback/TutorialOverlay/TutorialOverlay.stories.tsx +0 -691
- package/src/components/feedback/TutorialOverlay/TutorialOverlay.test.stories.tsx +0 -634
- package/src/components/form/AddressAutocomplete/AddressAutocomplete.stories.tsx +0 -665
- package/src/components/form/AddressAutocomplete/AddressAutocomplete.test.stories.tsx +0 -727
- package/src/components/form/Autocomplete/Autocomplete.stories.tsx +0 -715
- package/src/components/form/Autocomplete/Autocomplete.test.stories.tsx +0 -825
- package/src/components/form/Button/Button.stories.tsx +0 -365
- package/src/components/form/Button/Button.test.stories.tsx +0 -607
- package/src/components/form/Calendar/Calendar.stories.tsx +0 -349
- package/src/components/form/Calendar/Calendar.test.stories.tsx +0 -464
- package/src/components/form/CepField/CepField.stories.tsx +0 -138
- package/src/components/form/CepField/CepField.test.stories.tsx +0 -281
- package/src/components/form/Checkbox/Checkbox.stories.tsx +0 -265
- package/src/components/form/Checkbox/Checkbox.test.stories.tsx +0 -181
- package/src/components/form/CodeEditor/CodeEditor.stories.tsx +0 -871
- package/src/components/form/CodeEditor/CodeEditor.test.stories.tsx +0 -574
- package/src/components/form/Command/Command.stories.tsx +0 -580
- package/src/components/form/Command/Command.test.stories.tsx +0 -215
- package/src/components/form/CreatableSelect/CreatableSelect.stories.tsx +0 -112
- package/src/components/form/CreatableSelect/CreatableSelect.test.stories.tsx +0 -134
- package/src/components/form/Form/Form.stories.tsx +0 -687
- package/src/components/form/Form/Form.test.stories.tsx +0 -601
- package/src/components/form/Input/Input.stories.tsx +0 -260
- package/src/components/form/Input/Input.test.stories.tsx +0 -1191
- package/src/components/form/InputOTP/InputOTP.stories.tsx +0 -774
- package/src/components/form/InputOTP/InputOTP.test.stories.tsx +0 -588
- package/src/components/form/Label/Label.stories.tsx +0 -473
- package/src/components/form/Label/Label.test.stories.tsx +0 -915
- package/src/components/form/Menubar/Menubar.stories.tsx +0 -472
- package/src/components/form/Menubar/Menubar.test.stories.tsx +0 -584
- package/src/components/form/PasswordStrength/PasswordStrength.stories.tsx +0 -562
- package/src/components/form/PasswordStrength/PasswordStrength.test.stories.tsx +0 -327
- package/src/components/form/PhoneInput/PhoneInput.stories.tsx +0 -495
- package/src/components/form/PhoneInput/PhoneInput.test.stories.tsx +0 -666
- package/src/components/form/RadioGroup/RadioGroup.stories.tsx +0 -518
- package/src/components/form/RadioGroup/RadioGroup.test.stories.tsx +0 -685
- package/src/components/form/RichTextEditor/RichTextEditor.stories.tsx +0 -261
- package/src/components/form/RichTextEditor/RichTextEditor.test.stories.tsx +0 -491
- package/src/components/form/SearchPalette/SearchPalette.stories.tsx +0 -135
- package/src/components/form/Select/Select.stories.tsx +0 -364
- package/src/components/form/Select/Select.test.stories.tsx +0 -985
- package/src/components/form/Slider/Slider.stories.tsx +0 -418
- package/src/components/form/Slider/Slider.test.stories.tsx +0 -1042
- package/src/components/form/Switch/Switch.stories.tsx +0 -697
- package/src/components/form/Switch/Switch.test.stories.tsx +0 -597
- package/src/components/form/Textarea/Textarea.stories.tsx +0 -473
- package/src/components/form/Textarea/Textarea.test.stories.tsx +0 -702
- package/src/components/form/Toggle/Toggle.stories.tsx +0 -638
- package/src/components/form/Toggle/Toggle.test.stories.tsx +0 -1159
- package/src/components/form/ToggleGroup/ToggleGroup.stories.tsx +0 -617
- package/src/components/form/ToggleGroup/ToggleGroup.test.stories.tsx +0 -915
- package/src/components/form/UploadButton/UploadButton.stories.tsx +0 -367
- package/src/components/form/UploadButton/UploadButton.test.stories.tsx +0 -573
- package/src/components/form/total-form/total-form.test.tsx +0 -214
- package/src/components/layout/Accordion/Accordion.stories.tsx +0 -694
- package/src/components/layout/Accordion/Accordion.test.stories.tsx +0 -1344
- package/src/components/layout/Card/Card.stories.tsx +0 -591
- package/src/components/layout/Card/Card.test.stories.tsx +0 -1134
- package/src/components/layout/CardGrid/__tests__/CardGrid.test.tsx +0 -92
- package/src/components/layout/Collapsible/Collapsible.stories.tsx +0 -180
- package/src/components/layout/Collapsible/Collapsible.test.stories.tsx +0 -308
- package/src/components/layout/Container/Container.stories.tsx +0 -557
- package/src/components/layout/Container/Container.test.stories.tsx +0 -745
- package/src/components/layout/ContentToolbar/ContentToolbar.stories.tsx +0 -129
- package/src/components/layout/ContentToolbar/ContentToolbar.test.stories.tsx +0 -251
- package/src/components/layout/ContentToolbar/__tests__/ColumnsMenu.test.tsx +0 -39
- package/src/components/layout/ContentToolbar/__tests__/MultiSelectDropdown.test.tsx +0 -131
- package/src/components/layout/ContentToolbar/__tests__/SavedViewsMenu.test.tsx +0 -99
- package/src/components/layout/Dashboard/Dashboard.stories.tsx +0 -104
- package/src/components/layout/Dashboard/Dashboard.test.stories.tsx +0 -190
- package/src/components/layout/Drawer/Drawer.stories.tsx +0 -658
- package/src/components/layout/Drawer/Drawer.test.stories.tsx +0 -1343
- package/src/components/layout/Resizable/Resizable.stories.tsx +0 -1039
- package/src/components/layout/Resizable/Resizable.test.stories.tsx +0 -754
- package/src/components/layout/ScrollArea/ScrollArea.stories.tsx +0 -651
- package/src/components/layout/ScrollArea/ScrollArea.test.stories.tsx +0 -619
- package/src/components/layout/Separator/Separator.stories.tsx +0 -563
- package/src/components/layout/Separator/Separator.test.stories.tsx +0 -518
- package/src/components/layout/SettingsLayout/SettingsLayout.stories.tsx +0 -192
- package/src/components/layout/SettingsLayout/SettingsLayout.test.stories.tsx +0 -175
- package/src/components/layout/Sidebar/Sidebar.stories.tsx +0 -609
- package/src/components/layout/Sidebar/Sidebar.test.stories.tsx +0 -1324
- package/src/components/layout/Skeleton/Skeleton.stories.tsx +0 -689
- package/src/components/layout/Skeleton/Skeleton.test.stories.tsx +0 -521
- package/src/components/layout/Spacer/Spacer.stories.tsx +0 -502
- package/src/components/layout/Spacer/Spacer.test.stories.tsx +0 -474
- package/src/components/layout/TableFilter/TableFilter.stories.tsx +0 -82
- package/src/components/layout/TableFilter/TableFilter.test.stories.tsx +0 -87
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.stories.tsx +0 -638
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.test.stories.tsx +0 -1008
- package/src/components/navigation/CommandPalette/CommandPalette.stories.tsx +0 -386
- package/src/components/navigation/CommandPalette/CommandPalette.test.stories.tsx +0 -435
- package/src/components/navigation/ContextMenu/ContextMenu.stories.tsx +0 -614
- package/src/components/navigation/ContextMenu/ContextMenu.test.stories.tsx +0 -845
- package/src/components/navigation/DropdownMenu/DropdownMenu.stories.tsx +0 -578
- package/src/components/navigation/DropdownMenu/DropdownMenu.test.stories.tsx +0 -660
- package/src/components/navigation/NavigationMenu/stories/NavigationMenu.stories.tsx +0 -516
- package/src/components/navigation/NavigationMenu/stories/NavigationMenu.test.stories.tsx +0 -935
- package/src/components/navigation/NavigationMenu/stories/NavigationMenuHorizontal.stories.tsx +0 -501
- package/src/components/navigation/NavigationMenu/stories/NavigationMenuVertical.stories.tsx +0 -453
- package/src/components/navigation/Pagination/Pagination.stories.tsx +0 -602
- package/src/components/navigation/Pagination/Pagination.test.stories.tsx +0 -520
- package/src/components/navigation/Tabs/Tabs.stories.tsx +0 -1004
- package/src/components/navigation/Tabs/Tabs.test.stories.tsx +0 -1225
- package/src/components/typography/Blockquote/Blockquote.stories.tsx +0 -359
- package/src/components/typography/Blockquote/Blockquote.test.stories.tsx +0 -432
- package/src/components/typography/Code/Code.stories.tsx +0 -686
- package/src/components/typography/Code/Code.test.stories.tsx +0 -703
- package/src/components/typography/Heading/Heading.stories.tsx +0 -451
- package/src/components/typography/Heading/Heading.test.stories.tsx +0 -830
- package/src/components/typography/Paragraph/Paragraph.stories.tsx +0 -280
- package/src/components/typography/Paragraph/Paragraph.test.stories.tsx +0 -231
- package/src/components/typography/Text/Text.stories.tsx +0 -359
- package/src/components/typography/Text/Text.test.stories.tsx +0 -759
- package/src/components/utility/AnimatedIcon/AnimatedIcon.stories.tsx +0 -945
- package/src/components/utility/AnimatedIcon/AnimatedIcon.test.stories.tsx +0 -603
- package/src/components/utility/AspectRatio/AspectRatio.stories.tsx +0 -414
- package/src/components/utility/AspectRatio/AspectRatio.test.stories.tsx +0 -859
- package/src/components/utility/InfiniteScroll/InfiniteScroll.stories.tsx +0 -620
- package/src/components/utility/InfiniteScroll/InfiniteScroll.test.stories.tsx +0 -361
- package/src/components/utility/InstallPrompt/InstallPrompt.stories.tsx +0 -118
- package/src/components/utility/InstallPrompt/InstallPrompt.test.stories.tsx +0 -83
- package/src/components/utility/InstallPrompt/__tests__/InstallPrompt.ios.test.tsx +0 -65
- package/src/components/utility/InstallPrompt/__tests__/usePwaInstall.test.tsx +0 -271
- package/src/components/utility/Portal/Portal.stories.tsx +0 -340
- package/src/components/utility/Portal/Portal.test.stories.tsx +0 -2086
- package/src/components/utility/Transition/Transition.stories.tsx +0 -493
- package/src/components/utility/Transition/Transition.test.stories.tsx +0 -854
- package/src/components/utility/VirtualList/VirtualList.stories.tsx +0 -1073
- package/src/components/utility/VirtualList/VirtualList.test.stories.tsx +0 -1085
- package/src/components/utility/WorkflowStep/WorkflowStep.stories.tsx +0 -431
- package/src/components/utility/WorkflowStep/WorkflowStep.test.stories.tsx +0 -364
- /package/src/{button.tsx → button/button.tsx} +0 -0
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import { Box, Typography } from '@mui/material';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
-
import { fn } from 'storybook/test';
|
|
4
|
-
|
|
5
|
-
import { EmptyState } from '../EmptyState/EmptyState';
|
|
6
|
-
|
|
7
|
-
import { AsyncStateContainer } from './AsyncStateContainer';
|
|
8
|
-
import { ErrorState } from '../ErrorState/ErrorState';
|
|
9
|
-
import { LoadingState } from '../LoadingState/LoadingState';
|
|
10
|
-
|
|
11
|
-
const meta: Meta<typeof AsyncStateContainer> = {
|
|
12
|
-
title: 'DataDisplay/AsyncStates/AsyncStateContainer',
|
|
13
|
-
component: AsyncStateContainer,
|
|
14
|
-
parameters: {
|
|
15
|
-
layout: 'padded',
|
|
16
|
-
docs: {
|
|
17
|
-
description: {
|
|
18
|
-
component: `
|
|
19
|
-
A composition-based wrapper component for handling async data states consistently.
|
|
20
|
-
|
|
21
|
-
## Features
|
|
22
|
-
- **Priority-based rendering**: loading > error > empty > children
|
|
23
|
-
- **Composition pattern**: Pass custom components for each state
|
|
24
|
-
- **Render props**: Alternatively use render functions for more control
|
|
25
|
-
- **Accessible**: Proper ARIA attributes and semantic markup
|
|
26
|
-
|
|
27
|
-
## Usage Patterns
|
|
28
|
-
|
|
29
|
-
### Component Props (Composition)
|
|
30
|
-
\`\`\`tsx
|
|
31
|
-
<AsyncStateContainer
|
|
32
|
-
isLoading={isLoading}
|
|
33
|
-
error={error}
|
|
34
|
-
isEmpty={data.length === 0}
|
|
35
|
-
loadingComponent={<LoadingState variant="skeleton" />}
|
|
36
|
-
errorComponent={<ErrorState message={error} onRetry={refetch} />}
|
|
37
|
-
emptyComponent={<EmptyState title="No items" onCreate={handleCreate} />}
|
|
38
|
-
>
|
|
39
|
-
<DataGrid data={data} />
|
|
40
|
-
</AsyncStateContainer>
|
|
41
|
-
\`\`\`
|
|
42
|
-
|
|
43
|
-
### Render Props
|
|
44
|
-
\`\`\`tsx
|
|
45
|
-
<AsyncStateContainer
|
|
46
|
-
isLoading={isLoading}
|
|
47
|
-
error={error}
|
|
48
|
-
isEmpty={data.length === 0}
|
|
49
|
-
renderLoading={() => <CustomLoader />}
|
|
50
|
-
renderError={(error) => <CustomError error={error} />}
|
|
51
|
-
renderEmpty={() => <CustomEmpty />}
|
|
52
|
-
>
|
|
53
|
-
<DataGrid data={data} />
|
|
54
|
-
</AsyncStateContainer>
|
|
55
|
-
\`\`\`
|
|
56
|
-
`,
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
tags: ['autodocs', 'component:AsyncStateContainer'],
|
|
61
|
-
argTypes: {
|
|
62
|
-
isLoading: {
|
|
63
|
-
control: 'boolean',
|
|
64
|
-
description: 'Whether the container is in a loading state',
|
|
65
|
-
},
|
|
66
|
-
error: {
|
|
67
|
-
control: 'text',
|
|
68
|
-
description: 'Error message or object',
|
|
69
|
-
},
|
|
70
|
-
isEmpty: {
|
|
71
|
-
control: 'boolean',
|
|
72
|
-
description: 'Whether the data is empty',
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export default meta;
|
|
78
|
-
type Story = StoryObj<typeof meta>;
|
|
79
|
-
|
|
80
|
-
const SampleContent = () => (
|
|
81
|
-
<Box
|
|
82
|
-
sx={{
|
|
83
|
-
p: 4,
|
|
84
|
-
bgcolor: 'background.paper',
|
|
85
|
-
border: '1px solid',
|
|
86
|
-
borderColor: 'divider',
|
|
87
|
-
borderRadius: 2,
|
|
88
|
-
}}
|
|
89
|
-
>
|
|
90
|
-
<Typography variant="h6" gutterBottom>
|
|
91
|
-
Data Loaded Successfully!
|
|
92
|
-
</Typography>
|
|
93
|
-
<Typography variant="body2" color="text.secondary">
|
|
94
|
-
This is the actual content that displays when data is available.
|
|
95
|
-
</Typography>
|
|
96
|
-
</Box>
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
export const SuccessState: Story = {
|
|
100
|
-
name: 'Success State (Children)',
|
|
101
|
-
args: {
|
|
102
|
-
isLoading: false,
|
|
103
|
-
error: null,
|
|
104
|
-
isEmpty: false,
|
|
105
|
-
children: <SampleContent />,
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export const LoadingStateDefault: Story = {
|
|
110
|
-
name: 'Loading State (Default)',
|
|
111
|
-
args: {
|
|
112
|
-
isLoading: true,
|
|
113
|
-
error: null,
|
|
114
|
-
isEmpty: false,
|
|
115
|
-
children: <SampleContent />,
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
export const LoadingStateCustom: Story = {
|
|
120
|
-
name: 'Loading State (Custom Component)',
|
|
121
|
-
args: {
|
|
122
|
-
isLoading: true,
|
|
123
|
-
error: null,
|
|
124
|
-
isEmpty: false,
|
|
125
|
-
loadingComponent: <LoadingState variant="skeleton" message="Fetching your data..." />,
|
|
126
|
-
children: <SampleContent />,
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
export const ErrorStateDefault: Story = {
|
|
131
|
-
name: 'Error State (Default)',
|
|
132
|
-
args: {
|
|
133
|
-
isLoading: false,
|
|
134
|
-
error: 'Failed to load data from the server',
|
|
135
|
-
isEmpty: false,
|
|
136
|
-
children: <SampleContent />,
|
|
137
|
-
},
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
export const ErrorStateCustom: Story = {
|
|
141
|
-
name: 'Error State (Custom Component)',
|
|
142
|
-
args: {
|
|
143
|
-
isLoading: false,
|
|
144
|
-
error: 'Network connection failed',
|
|
145
|
-
isEmpty: false,
|
|
146
|
-
errorComponent: (
|
|
147
|
-
<ErrorState
|
|
148
|
-
title="Connection Error"
|
|
149
|
-
message="Network connection failed"
|
|
150
|
-
onRetry={fn()}
|
|
151
|
-
retryLabel="Reconnect"
|
|
152
|
-
/>
|
|
153
|
-
),
|
|
154
|
-
children: <SampleContent />,
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
export const EmptyStateDefault: Story = {
|
|
159
|
-
name: 'Empty State (Default)',
|
|
160
|
-
args: {
|
|
161
|
-
isLoading: false,
|
|
162
|
-
error: null,
|
|
163
|
-
isEmpty: true,
|
|
164
|
-
children: <SampleContent />,
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
export const EmptyStateCustom: Story = {
|
|
169
|
-
name: 'Empty State (Custom Component)',
|
|
170
|
-
args: {
|
|
171
|
-
isLoading: false,
|
|
172
|
-
error: null,
|
|
173
|
-
isEmpty: true,
|
|
174
|
-
emptyComponent: (
|
|
175
|
-
<EmptyState
|
|
176
|
-
title="No projects found"
|
|
177
|
-
description="Get started by creating your first project"
|
|
178
|
-
onCreate={fn()}
|
|
179
|
-
createLabel="New Project"
|
|
180
|
-
onRefresh={fn()}
|
|
181
|
-
/>
|
|
182
|
-
),
|
|
183
|
-
children: <SampleContent />,
|
|
184
|
-
},
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
export const WithRenderProps: Story = {
|
|
188
|
-
name: 'Using Render Props',
|
|
189
|
-
args: {
|
|
190
|
-
isLoading: true,
|
|
191
|
-
error: null,
|
|
192
|
-
isEmpty: false,
|
|
193
|
-
renderLoading: () => (
|
|
194
|
-
<Box sx={{ textAlign: 'center', py: 4 }}>
|
|
195
|
-
<Typography variant="h6" color="primary">
|
|
196
|
-
🔄 Custom loading via render prop...
|
|
197
|
-
</Typography>
|
|
198
|
-
</Box>
|
|
199
|
-
),
|
|
200
|
-
children: <SampleContent />,
|
|
201
|
-
},
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
export const PriorityDemonstration: Story = {
|
|
205
|
-
name: 'Priority: Loading > Error > Empty',
|
|
206
|
-
args: {
|
|
207
|
-
isLoading: true,
|
|
208
|
-
error: 'This error should not show',
|
|
209
|
-
isEmpty: true,
|
|
210
|
-
children: <SampleContent />,
|
|
211
|
-
},
|
|
212
|
-
parameters: {
|
|
213
|
-
docs: {
|
|
214
|
-
description: {
|
|
215
|
-
story:
|
|
216
|
-
'Demonstrates priority order: when isLoading is true, loading state is shown even if error and isEmpty are also set.',
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
|
-
},
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
export const ErrorWithObject: Story = {
|
|
223
|
-
name: 'Error with Error Object',
|
|
224
|
-
args: {
|
|
225
|
-
isLoading: false,
|
|
226
|
-
error: new Error('TypeError: Cannot read property of undefined'),
|
|
227
|
-
isEmpty: false,
|
|
228
|
-
children: <SampleContent />,
|
|
229
|
-
},
|
|
230
|
-
};
|
package/src/components/data-display/AsyncStateContainer/AsyncStateContainer.test.stories.tsx
DELETED
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
import { Typography } from '@mui/material';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
-
import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
|
|
4
|
-
|
|
5
|
-
import { EmptyState } from '../EmptyState/EmptyState';
|
|
6
|
-
|
|
7
|
-
import { AsyncStateContainer } from './AsyncStateContainer';
|
|
8
|
-
import { ErrorState } from '../ErrorState/ErrorState';
|
|
9
|
-
import { LoadingState } from '../LoadingState/LoadingState';
|
|
10
|
-
|
|
11
|
-
const meta: Meta<typeof AsyncStateContainer> = {
|
|
12
|
-
title: 'DataDisplay/AsyncStates/AsyncStateContainer/Tests',
|
|
13
|
-
component: AsyncStateContainer,
|
|
14
|
-
parameters: {
|
|
15
|
-
layout: 'padded',
|
|
16
|
-
chromatic: { disableSnapshot: false },
|
|
17
|
-
},
|
|
18
|
-
tags: ['autodocs', 'test', 'component:AsyncStateContainer'],
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default meta;
|
|
22
|
-
type Story = StoryObj<typeof meta>;
|
|
23
|
-
|
|
24
|
-
const TestContent = () => (
|
|
25
|
-
<Typography data-testid="success-content">Content Loaded</Typography>
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
export const SuccessStateTest: Story = {
|
|
29
|
-
name: '🧪 Success State Rendering',
|
|
30
|
-
args: {
|
|
31
|
-
isLoading: false,
|
|
32
|
-
error: null,
|
|
33
|
-
isEmpty: false,
|
|
34
|
-
children: <TestContent />,
|
|
35
|
-
},
|
|
36
|
-
play: async ({ canvasElement, step }) => {
|
|
37
|
-
const canvas = within(canvasElement);
|
|
38
|
-
|
|
39
|
-
await step('Verify container has success state', async () => {
|
|
40
|
-
const container = canvas.getByTestId('async-state-container');
|
|
41
|
-
await expect(container).toHaveAttribute('data-state', 'success');
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
await step('Verify children content is rendered', async () => {
|
|
45
|
-
const content = canvas.getByTestId('success-content');
|
|
46
|
-
await expect(content).toHaveTextContent('Content Loaded');
|
|
47
|
-
});
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const LoadingStateTest: Story = {
|
|
52
|
-
name: '🧪 Loading State Rendering',
|
|
53
|
-
args: {
|
|
54
|
-
isLoading: true,
|
|
55
|
-
error: null,
|
|
56
|
-
isEmpty: false,
|
|
57
|
-
children: <TestContent />,
|
|
58
|
-
},
|
|
59
|
-
play: async ({ canvasElement, step }) => {
|
|
60
|
-
const canvas = within(canvasElement);
|
|
61
|
-
|
|
62
|
-
await step('Verify container has loading state', async () => {
|
|
63
|
-
const container = canvas.getByTestId('async-state-container');
|
|
64
|
-
await expect(container).toHaveAttribute('data-state', 'loading');
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
await step('Verify children content is NOT rendered', async () => {
|
|
68
|
-
const content = canvas.queryByTestId('success-content');
|
|
69
|
-
await waitFor(() => expect(content).not.toBeInTheDocument());
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
await step('Verify loading component is rendered', async () => {
|
|
73
|
-
const loading = canvas.getByTestId('loading-state');
|
|
74
|
-
await expect(loading).toBeInTheDocument();
|
|
75
|
-
});
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export const ErrorStateTest: Story = {
|
|
80
|
-
name: '🧪 Error State Rendering',
|
|
81
|
-
args: {
|
|
82
|
-
isLoading: false,
|
|
83
|
-
error: 'Something went wrong',
|
|
84
|
-
isEmpty: false,
|
|
85
|
-
children: <TestContent />,
|
|
86
|
-
},
|
|
87
|
-
play: async ({ canvasElement, step }) => {
|
|
88
|
-
const canvas = within(canvasElement);
|
|
89
|
-
|
|
90
|
-
await step('Verify container has error state', async () => {
|
|
91
|
-
const container = canvas.getByTestId('async-state-container');
|
|
92
|
-
await expect(container).toHaveAttribute('data-state', 'error');
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
await step('Verify children content is NOT rendered', async () => {
|
|
96
|
-
const content = canvas.queryByTestId('success-content');
|
|
97
|
-
await waitFor(() => expect(content).not.toBeInTheDocument());
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
await step('Verify error component is rendered', async () => {
|
|
101
|
-
const error = canvas.getByTestId('error-state');
|
|
102
|
-
await expect(error).toBeInTheDocument();
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
await step('Verify error message is displayed', async () => {
|
|
106
|
-
const message = canvas.getByTestId('error-state-message');
|
|
107
|
-
await expect(message).toHaveTextContent('Something went wrong');
|
|
108
|
-
});
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
export const EmptyStateTest: Story = {
|
|
113
|
-
name: '🧪 Empty State Rendering',
|
|
114
|
-
args: {
|
|
115
|
-
isLoading: false,
|
|
116
|
-
error: null,
|
|
117
|
-
isEmpty: true,
|
|
118
|
-
children: <TestContent />,
|
|
119
|
-
},
|
|
120
|
-
play: async ({ canvasElement, step }) => {
|
|
121
|
-
const canvas = within(canvasElement);
|
|
122
|
-
|
|
123
|
-
await step('Verify container has empty state', async () => {
|
|
124
|
-
const container = canvas.getByTestId('async-state-container');
|
|
125
|
-
await expect(container).toHaveAttribute('data-state', 'empty');
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
await step('Verify children content is NOT rendered', async () => {
|
|
129
|
-
const content = canvas.queryByTestId('success-content');
|
|
130
|
-
await waitFor(() => expect(content).not.toBeInTheDocument());
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
await step('Verify empty state component is rendered', async () => {
|
|
134
|
-
const empty = canvas.getByTestId('empty-state');
|
|
135
|
-
await expect(empty).toBeInTheDocument();
|
|
136
|
-
});
|
|
137
|
-
},
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
export const PriorityTest: Story = {
|
|
141
|
-
name: '🧪 Priority: Loading > Error > Empty',
|
|
142
|
-
args: {
|
|
143
|
-
isLoading: true,
|
|
144
|
-
error: 'This should not show',
|
|
145
|
-
isEmpty: true,
|
|
146
|
-
children: <TestContent />,
|
|
147
|
-
},
|
|
148
|
-
play: async ({ canvasElement, step }) => {
|
|
149
|
-
const canvas = within(canvasElement);
|
|
150
|
-
|
|
151
|
-
await step('Verify loading state takes priority', async () => {
|
|
152
|
-
const container = canvas.getByTestId('async-state-container');
|
|
153
|
-
await expect(container).toHaveAttribute('data-state', 'loading');
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
await step('Verify loading component is rendered, not error', async () => {
|
|
157
|
-
const loading = canvas.getByTestId('loading-state');
|
|
158
|
-
await expect(loading).toBeInTheDocument();
|
|
159
|
-
|
|
160
|
-
const error = canvas.queryByTestId('error-state');
|
|
161
|
-
await waitFor(() => expect(error).not.toBeInTheDocument());
|
|
162
|
-
});
|
|
163
|
-
},
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
export const CustomComponentsTest: Story = {
|
|
167
|
-
name: '🧪 Custom Components via Props',
|
|
168
|
-
args: {
|
|
169
|
-
isLoading: false,
|
|
170
|
-
error: null,
|
|
171
|
-
isEmpty: true,
|
|
172
|
-
emptyComponent: (
|
|
173
|
-
<EmptyState
|
|
174
|
-
title="No items found"
|
|
175
|
-
description="Create your first item"
|
|
176
|
-
onCreate={fn()}
|
|
177
|
-
dataTestId="custom-empty"
|
|
178
|
-
/>
|
|
179
|
-
),
|
|
180
|
-
children: <TestContent />,
|
|
181
|
-
},
|
|
182
|
-
play: async ({ canvasElement, step }) => {
|
|
183
|
-
const canvas = within(canvasElement);
|
|
184
|
-
|
|
185
|
-
await step('Verify custom empty component is used', async () => {
|
|
186
|
-
const customEmpty = canvas.getByTestId('custom-empty');
|
|
187
|
-
await expect(customEmpty).toBeInTheDocument();
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
await step('Verify custom empty title', async () => {
|
|
191
|
-
const title = canvas.getByTestId('custom-empty-title');
|
|
192
|
-
await expect(title).toHaveTextContent('No items found');
|
|
193
|
-
});
|
|
194
|
-
},
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
export const CustomLoadingWithRetry: Story = {
|
|
198
|
-
name: '🧪 Error State with Retry Interaction',
|
|
199
|
-
args: {
|
|
200
|
-
isLoading: false,
|
|
201
|
-
error: 'Network error',
|
|
202
|
-
isEmpty: false,
|
|
203
|
-
errorComponent: (
|
|
204
|
-
<ErrorState
|
|
205
|
-
title="Connection Failed"
|
|
206
|
-
message="Network error"
|
|
207
|
-
onRetry={fn()}
|
|
208
|
-
dataTestId="custom-error"
|
|
209
|
-
/>
|
|
210
|
-
),
|
|
211
|
-
children: <TestContent />,
|
|
212
|
-
},
|
|
213
|
-
play: async ({ canvasElement, _args, step }) => {
|
|
214
|
-
const canvas = within(canvasElement);
|
|
215
|
-
|
|
216
|
-
await step('Verify custom error component', async () => {
|
|
217
|
-
const customError = canvas.getByTestId('custom-error');
|
|
218
|
-
await expect(customError).toBeInTheDocument();
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
await step('Click retry button', async () => {
|
|
222
|
-
const retryButton = canvas.getByTestId('custom-error-retry-button');
|
|
223
|
-
await userEvent.click(retryButton);
|
|
224
|
-
});
|
|
225
|
-
},
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
export const RenderPropsTest: Story = {
|
|
229
|
-
name: '🧪 Render Props Pattern',
|
|
230
|
-
args: {
|
|
231
|
-
isLoading: true,
|
|
232
|
-
error: null,
|
|
233
|
-
isEmpty: false,
|
|
234
|
-
renderLoading: () => (
|
|
235
|
-
<LoadingState variant="skeleton" message="Custom render prop" dataTestId="render-prop-loading" />
|
|
236
|
-
),
|
|
237
|
-
children: <TestContent />,
|
|
238
|
-
},
|
|
239
|
-
play: async ({ canvasElement, step }) => {
|
|
240
|
-
const canvas = within(canvasElement);
|
|
241
|
-
|
|
242
|
-
await step('Verify render prop loading is used', async () => {
|
|
243
|
-
const loading = canvas.getByTestId('render-prop-loading');
|
|
244
|
-
await expect(loading).toBeInTheDocument();
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
await step('Verify custom message', async () => {
|
|
248
|
-
const message = canvas.getByTestId('render-prop-loading-message');
|
|
249
|
-
await expect(message).toHaveTextContent('Custom render prop');
|
|
250
|
-
});
|
|
251
|
-
},
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
export const ErrorObjectTest: Story = {
|
|
255
|
-
name: '🧪 Error Object Handling',
|
|
256
|
-
args: {
|
|
257
|
-
isLoading: false,
|
|
258
|
-
error: new Error('TypeError: Cannot read property'),
|
|
259
|
-
isEmpty: false,
|
|
260
|
-
children: <TestContent />,
|
|
261
|
-
},
|
|
262
|
-
play: async ({ canvasElement, step }) => {
|
|
263
|
-
const canvas = within(canvasElement);
|
|
264
|
-
|
|
265
|
-
await step('Verify error message from Error object', async () => {
|
|
266
|
-
const message = canvas.getByTestId('error-state-message');
|
|
267
|
-
await expect(message).toHaveTextContent('TypeError: Cannot read property');
|
|
268
|
-
});
|
|
269
|
-
},
|
|
270
|
-
};
|