@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,281 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import React, { useState } from 'react';
|
|
3
|
-
import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
|
|
4
|
-
|
|
5
|
-
import { CepField } from './CepField';
|
|
6
|
-
import type { CepAddress } from './CepField.types';
|
|
7
|
-
|
|
8
|
-
const ADDRESS: CepAddress = {
|
|
9
|
-
cep: '01310100',
|
|
10
|
-
street: 'Avenida Paulista',
|
|
11
|
-
neighborhood: 'Bela Vista',
|
|
12
|
-
city: 'São Paulo',
|
|
13
|
-
state: 'SP',
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const meta: Meta<typeof CepField> = {
|
|
17
|
-
title: 'Form/CepField/Tests',
|
|
18
|
-
component: CepField,
|
|
19
|
-
parameters: {
|
|
20
|
-
layout: 'centered',
|
|
21
|
-
chromatic: { disableSnapshot: false },
|
|
22
|
-
docs: {
|
|
23
|
-
description: { component: 'Test stories for CepField masking, lookup and race-safety' },
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
tags: ['autodocs', 'test'],
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default meta;
|
|
30
|
-
export type Story = StoryObj<typeof meta>;
|
|
31
|
-
|
|
32
|
-
/** Controlled harness — the field is controlled, so tests need real state. */
|
|
33
|
-
function Harness({
|
|
34
|
-
onLookup,
|
|
35
|
-
onResolved,
|
|
36
|
-
onNotFound,
|
|
37
|
-
debounceMs = 0,
|
|
38
|
-
initial = '',
|
|
39
|
-
disabled = false,
|
|
40
|
-
}: {
|
|
41
|
-
onLookup?: (cep: string) => Promise<CepAddress | null>;
|
|
42
|
-
onResolved?: (address: CepAddress) => void;
|
|
43
|
-
onNotFound?: () => void;
|
|
44
|
-
debounceMs?: number;
|
|
45
|
-
initial?: string;
|
|
46
|
-
disabled?: boolean;
|
|
47
|
-
}): React.ReactElement {
|
|
48
|
-
const [value, setValue] = useState(initial);
|
|
49
|
-
return (
|
|
50
|
-
<CepField
|
|
51
|
-
value={value}
|
|
52
|
-
onChange={setValue}
|
|
53
|
-
onLookup={onLookup}
|
|
54
|
-
onResolved={onResolved}
|
|
55
|
-
onNotFound={onNotFound}
|
|
56
|
-
debounceMs={debounceMs}
|
|
57
|
-
disabled={disabled}
|
|
58
|
-
/>
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// 1. Masking
|
|
63
|
-
|
|
64
|
-
export const MasksWhileTyping: Story = {
|
|
65
|
-
render: () => <Harness />,
|
|
66
|
-
play: async ({ canvasElement }) => {
|
|
67
|
-
const canvas = within(canvasElement);
|
|
68
|
-
const input = canvas.getByTestId('cep-field-postalCode');
|
|
69
|
-
|
|
70
|
-
await userEvent.type(input, '01310100');
|
|
71
|
-
await expect(input).toHaveValue('01310-100');
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export const StripsNonDigitsAndCaps: Story = {
|
|
76
|
-
render: () => <Harness />,
|
|
77
|
-
play: async ({ canvasElement }) => {
|
|
78
|
-
const canvas = within(canvasElement);
|
|
79
|
-
const input = canvas.getByTestId('cep-field-postalCode');
|
|
80
|
-
|
|
81
|
-
await userEvent.type(input, 'ab01310100999');
|
|
82
|
-
await expect(input).toHaveValue('01310-100');
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
// 2. Lookup
|
|
87
|
-
|
|
88
|
-
export const ResolvesACompleteCep: Story = {
|
|
89
|
-
render: function ResolvesStory() {
|
|
90
|
-
const onResolved = fn();
|
|
91
|
-
return (
|
|
92
|
-
<Harness onLookup={async () => ADDRESS} onResolved={onResolved} />
|
|
93
|
-
);
|
|
94
|
-
},
|
|
95
|
-
play: async ({ canvasElement }) => {
|
|
96
|
-
const canvas = within(canvasElement);
|
|
97
|
-
const input = canvas.getByTestId('cep-field-postalCode');
|
|
98
|
-
|
|
99
|
-
await userEvent.type(input, '01310100');
|
|
100
|
-
await waitFor(() => expect(canvas.getByTestId('cep-field-postalCode-found')).toBeInTheDocument());
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export const DoesNotLookUpAnIncompleteCep: Story = {
|
|
105
|
-
render: function IncompleteStory() {
|
|
106
|
-
const lookup = fn(async () => ADDRESS);
|
|
107
|
-
return <Harness onLookup={lookup} />;
|
|
108
|
-
},
|
|
109
|
-
play: async ({ canvasElement }) => {
|
|
110
|
-
const canvas = within(canvasElement);
|
|
111
|
-
const input = canvas.getByTestId('cep-field-postalCode');
|
|
112
|
-
|
|
113
|
-
await userEvent.type(input, '0131');
|
|
114
|
-
// Presence evidence first: the field really did take the partial value…
|
|
115
|
-
await expect(input).toHaveValue('0131');
|
|
116
|
-
// …and no status line ever appears, because an incomplete CEP is never
|
|
117
|
-
// queried. waitFor gives the (absent) debounce a chance to fire first.
|
|
118
|
-
await waitFor(() => {
|
|
119
|
-
expect(canvas.queryByTestId('cep-field-postalCode-loading')).toBeNull();
|
|
120
|
-
expect(canvas.queryByTestId('cep-field-postalCode-found')).toBeNull();
|
|
121
|
-
});
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
export const ReportsAnUnknownCep: Story = {
|
|
126
|
-
render: () => <Harness onLookup={async () => null} />,
|
|
127
|
-
play: async ({ canvasElement }) => {
|
|
128
|
-
const canvas = within(canvasElement);
|
|
129
|
-
const input = canvas.getByTestId('cep-field-postalCode');
|
|
130
|
-
|
|
131
|
-
await userEvent.type(input, '00000000');
|
|
132
|
-
await waitFor(() =>
|
|
133
|
-
expect(canvas.getByTestId('cep-field-postalCode-notfound')).toBeInTheDocument(),
|
|
134
|
-
);
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* A miss must be REPORTED, not just displayed: callers that auto-filled from a
|
|
140
|
-
* previous CEP rely on `onNotFound` to undo it, so the form never shows one
|
|
141
|
-
* CEP's street under another's.
|
|
142
|
-
*/
|
|
143
|
-
export const ReportsAMissToTheCaller: Story = {
|
|
144
|
-
render: function ReportsMissStory() {
|
|
145
|
-
const [missed, setMissed] = useState(false);
|
|
146
|
-
return (
|
|
147
|
-
<div>
|
|
148
|
-
<Harness onLookup={async () => null} onNotFound={() => setMissed(true)} />
|
|
149
|
-
<span data-testid="miss-flag">{missed ? 'missed' : 'clean'}</span>
|
|
150
|
-
</div>
|
|
151
|
-
);
|
|
152
|
-
},
|
|
153
|
-
play: async ({ canvasElement }) => {
|
|
154
|
-
const canvas = within(canvasElement);
|
|
155
|
-
const input = canvas.getByTestId('cep-field-postalCode');
|
|
156
|
-
|
|
157
|
-
await userEvent.type(input, '00000000');
|
|
158
|
-
await waitFor(() => expect(canvas.getByTestId('miss-flag')).toHaveTextContent('missed'));
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
/** …and a resolved CEP must NOT report a miss. */
|
|
163
|
-
export const DoesNotReportAMissOnSuccess: Story = {
|
|
164
|
-
render: function NoMissStory() {
|
|
165
|
-
const [missed, setMissed] = useState(false);
|
|
166
|
-
return (
|
|
167
|
-
<div>
|
|
168
|
-
<Harness onLookup={async () => ADDRESS} onNotFound={() => setMissed(true)} />
|
|
169
|
-
<span data-testid="miss-flag">{missed ? 'missed' : 'clean'}</span>
|
|
170
|
-
</div>
|
|
171
|
-
);
|
|
172
|
-
},
|
|
173
|
-
play: async ({ canvasElement }) => {
|
|
174
|
-
const canvas = within(canvasElement);
|
|
175
|
-
const input = canvas.getByTestId('cep-field-postalCode');
|
|
176
|
-
|
|
177
|
-
await userEvent.type(input, '01310100');
|
|
178
|
-
await waitFor(() => expect(canvas.getByTestId('cep-field-postalCode-found')).toBeInTheDocument());
|
|
179
|
-
await expect(canvas.getByTestId('miss-flag')).toHaveTextContent('clean');
|
|
180
|
-
},
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
/** A lookup that throws is indistinguishable from "not found" — never a crash. */
|
|
184
|
-
export const SurvivesAThrowingLookup: Story = {
|
|
185
|
-
render: () => (
|
|
186
|
-
<Harness
|
|
187
|
-
onLookup={async () => {
|
|
188
|
-
throw new Error('provider down');
|
|
189
|
-
}}
|
|
190
|
-
/>
|
|
191
|
-
),
|
|
192
|
-
play: async ({ canvasElement }) => {
|
|
193
|
-
const canvas = within(canvasElement);
|
|
194
|
-
const input = canvas.getByTestId('cep-field-postalCode');
|
|
195
|
-
|
|
196
|
-
await userEvent.type(input, '01310100');
|
|
197
|
-
await waitFor(() =>
|
|
198
|
-
expect(canvas.getByTestId('cep-field-postalCode-notfound')).toBeInTheDocument(),
|
|
199
|
-
);
|
|
200
|
-
},
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* …including a lookup that throws BEFORE returning a promise, which is what a
|
|
205
|
-
* misconfigured adapter does. Awaiting the call and catching on its result
|
|
206
|
-
* would miss this one entirely and surface it as an unhandled rejection.
|
|
207
|
-
*/
|
|
208
|
-
export const SurvivesASynchronousThrow: Story = {
|
|
209
|
-
render: () => (
|
|
210
|
-
<Harness
|
|
211
|
-
onLookup={() => {
|
|
212
|
-
throw new Error('adapter misconfigured');
|
|
213
|
-
}}
|
|
214
|
-
/>
|
|
215
|
-
),
|
|
216
|
-
play: async ({ canvasElement }) => {
|
|
217
|
-
const canvas = within(canvasElement);
|
|
218
|
-
const input = canvas.getByTestId('cep-field-postalCode');
|
|
219
|
-
|
|
220
|
-
await userEvent.type(input, '01310100');
|
|
221
|
-
await waitFor(() =>
|
|
222
|
-
expect(canvas.getByTestId('cep-field-postalCode-notfound')).toBeInTheDocument(),
|
|
223
|
-
);
|
|
224
|
-
},
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
// 3. State
|
|
228
|
-
|
|
229
|
-
export const DisabledSuppressesLookup: Story = {
|
|
230
|
-
render: () => <Harness initial="01310-100" disabled onLookup={async () => ADDRESS} />,
|
|
231
|
-
play: async ({ canvasElement }) => {
|
|
232
|
-
const canvas = within(canvasElement);
|
|
233
|
-
const input = canvas.getByTestId('cep-field-postalCode');
|
|
234
|
-
|
|
235
|
-
await expect(input).toBeDisabled();
|
|
236
|
-
await expect(input).toHaveValue('01310-100');
|
|
237
|
-
// A complete CEP, but disabled suppresses the lookup entirely.
|
|
238
|
-
await waitFor(() => expect(canvas.queryByTestId('cep-field-postalCode-found')).toBeNull());
|
|
239
|
-
},
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
export const ClearsStatusWhenEditedBackToIncomplete: Story = {
|
|
243
|
-
render: () => <Harness onLookup={async () => ADDRESS} />,
|
|
244
|
-
play: async ({ canvasElement }) => {
|
|
245
|
-
const canvas = within(canvasElement);
|
|
246
|
-
const input = canvas.getByTestId('cep-field-postalCode');
|
|
247
|
-
|
|
248
|
-
await userEvent.type(input, '01310100');
|
|
249
|
-
await waitFor(() => expect(canvas.getByTestId('cep-field-postalCode-found')).toBeInTheDocument());
|
|
250
|
-
|
|
251
|
-
await userEvent.type(input, '{backspace}');
|
|
252
|
-
await waitFor(() => expect(canvas.queryByTestId('cep-field-postalCode-found')).toBeNull());
|
|
253
|
-
},
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
// 4. Accessibility
|
|
257
|
-
|
|
258
|
-
export const ExposesAccessibleStatus: Story = {
|
|
259
|
-
render: () => <Harness onLookup={async () => ADDRESS} />,
|
|
260
|
-
play: async ({ canvasElement }) => {
|
|
261
|
-
const canvas = within(canvasElement);
|
|
262
|
-
const input = canvas.getByTestId('cep-field-postalCode');
|
|
263
|
-
|
|
264
|
-
await expect(input).toHaveAttribute('aria-describedby', 'cep-field-postalCode-status');
|
|
265
|
-
await userEvent.type(input, '01310100');
|
|
266
|
-
await waitFor(() => expect(canvas.getByRole('status')).toBeInTheDocument());
|
|
267
|
-
},
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
export const RendersACallerError: Story = {
|
|
271
|
-
render: function ErrorStory() {
|
|
272
|
-
const [value, setValue] = useState('123');
|
|
273
|
-
return <CepField value={value} onChange={setValue} error="CEP inválido." />;
|
|
274
|
-
},
|
|
275
|
-
play: async ({ canvasElement }) => {
|
|
276
|
-
const canvas = within(canvasElement);
|
|
277
|
-
await expect(canvas.getByTestId('cep-field-postalCode-message')).toHaveTextContent(
|
|
278
|
-
'CEP inválido.',
|
|
279
|
-
);
|
|
280
|
-
},
|
|
281
|
-
};
|
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
import { FormGroup,Stack } from '@mui/material';
|
|
2
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
-
|
|
4
|
-
import { Checkbox } from './Checkbox';
|
|
5
|
-
|
|
6
|
-
const meta: Meta<typeof Checkbox> = {
|
|
7
|
-
title: 'Form/Checkbox',
|
|
8
|
-
component: Checkbox,
|
|
9
|
-
parameters: {
|
|
10
|
-
layout: 'centered',
|
|
11
|
-
},
|
|
12
|
-
tags: ['autodocs', 'component:Checkbox'],
|
|
13
|
-
argTypes: {
|
|
14
|
-
variant: {
|
|
15
|
-
control: { type: 'select' },
|
|
16
|
-
options: ['default', 'rounded', 'toggle'],
|
|
17
|
-
},
|
|
18
|
-
color: {
|
|
19
|
-
control: { type: 'select' },
|
|
20
|
-
options: ['primary', 'secondary', 'success', 'warning', 'error'],
|
|
21
|
-
},
|
|
22
|
-
size: {
|
|
23
|
-
control: { type: 'select' },
|
|
24
|
-
options: ['small', 'medium', 'large'],
|
|
25
|
-
},
|
|
26
|
-
loading: {
|
|
27
|
-
control: { type: 'boolean' },
|
|
28
|
-
},
|
|
29
|
-
ripple: {
|
|
30
|
-
control: { type: 'boolean' },
|
|
31
|
-
},
|
|
32
|
-
glow: {
|
|
33
|
-
control: { type: 'boolean' },
|
|
34
|
-
},
|
|
35
|
-
pulse: {
|
|
36
|
-
control: { type: 'boolean' },
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export default meta;
|
|
42
|
-
type Story = StoryObj<typeof meta>;
|
|
43
|
-
|
|
44
|
-
export const Default: Story = {
|
|
45
|
-
args: {
|
|
46
|
-
label: 'Default checkbox',
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export const Variants: Story = {
|
|
51
|
-
render: () => (
|
|
52
|
-
<Stack spacing={2}>
|
|
53
|
-
<Checkbox variant="default" label="Default checkbox" defaultChecked />
|
|
54
|
-
<Checkbox variant="rounded" label="Rounded checkbox" defaultChecked />
|
|
55
|
-
<Checkbox variant="toggle" label="Toggle-style checkbox" defaultChecked />
|
|
56
|
-
</Stack>
|
|
57
|
-
),
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export const States: Story = {
|
|
61
|
-
render: () => (
|
|
62
|
-
<Stack spacing={2}>
|
|
63
|
-
<Checkbox label="Unchecked" />
|
|
64
|
-
<Checkbox label="Checked" defaultChecked />
|
|
65
|
-
<Checkbox label="Indeterminate" indeterminate />
|
|
66
|
-
<Checkbox label="Disabled" disabled />
|
|
67
|
-
<Checkbox label="Disabled & Checked" disabled checked />
|
|
68
|
-
</Stack>
|
|
69
|
-
),
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export const Colors: Story = {
|
|
73
|
-
render: () => (
|
|
74
|
-
<Stack spacing={2}>
|
|
75
|
-
<Checkbox label="Primary" color="primary" defaultChecked />
|
|
76
|
-
<Checkbox label="Secondary" color="secondary" defaultChecked />
|
|
77
|
-
<Checkbox label="Success" color="success" defaultChecked />
|
|
78
|
-
<Checkbox label="Warning" color="warning" defaultChecked />
|
|
79
|
-
<Checkbox label="Error" color="error" defaultChecked />
|
|
80
|
-
</Stack>
|
|
81
|
-
),
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export const Sizes: Story = {
|
|
85
|
-
render: () => (
|
|
86
|
-
<Stack spacing={2}>
|
|
87
|
-
<Checkbox label="Small" size="small" defaultChecked />
|
|
88
|
-
<Checkbox label="Medium" size="medium" defaultChecked />
|
|
89
|
-
<Checkbox label="Large" size="large" defaultChecked />
|
|
90
|
-
</Stack>
|
|
91
|
-
),
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export const WithHelperText: Story = {
|
|
95
|
-
render: () => (
|
|
96
|
-
<Stack spacing={2}>
|
|
97
|
-
<Checkbox
|
|
98
|
-
label="Terms and Conditions"
|
|
99
|
-
helperText="Please read and accept our terms and conditions"
|
|
100
|
-
/>
|
|
101
|
-
<Checkbox label="Newsletter" helperText="Subscribe to our weekly newsletter" defaultChecked />
|
|
102
|
-
<Checkbox label="Required Field" helperText="This field is required" error />
|
|
103
|
-
</Stack>
|
|
104
|
-
),
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
export const CheckboxGroup: Story = {
|
|
108
|
-
render: () => (
|
|
109
|
-
<FormGroup>
|
|
110
|
-
<Checkbox label="Option 1" defaultChecked />
|
|
111
|
-
<Checkbox label="Option 2" />
|
|
112
|
-
<Checkbox label="Option 3" defaultChecked />
|
|
113
|
-
<Checkbox label="Option 4 (Disabled)" disabled />
|
|
114
|
-
</FormGroup>
|
|
115
|
-
),
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
export const ErrorState: Story = {
|
|
119
|
-
args: {
|
|
120
|
-
label: 'I accept the terms',
|
|
121
|
-
error: true,
|
|
122
|
-
helperText: 'You must accept the terms to continue',
|
|
123
|
-
},
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
export const LoadingState: Story = {
|
|
127
|
-
render: () => (
|
|
128
|
-
<Stack spacing={2}>
|
|
129
|
-
<Checkbox label="Loading checkbox" loading />
|
|
130
|
-
<Checkbox label="Loading with text" loading defaultChecked />
|
|
131
|
-
<Checkbox loading /> {/* Without label */}
|
|
132
|
-
</Stack>
|
|
133
|
-
),
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
export const AnimationEffects: Story = {
|
|
137
|
-
render: () => (
|
|
138
|
-
<Stack spacing={2}>
|
|
139
|
-
<Checkbox label="Glow effect" glow defaultChecked />
|
|
140
|
-
<Checkbox label="Pulse effect" pulse defaultChecked />
|
|
141
|
-
<Checkbox label="No ripple effect" ripple={false} />
|
|
142
|
-
<Checkbox label="All effects" glow pulse defaultChecked />
|
|
143
|
-
</Stack>
|
|
144
|
-
),
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
export const Accessibility: Story = {
|
|
148
|
-
render: () => (
|
|
149
|
-
<Stack spacing={2}>
|
|
150
|
-
<Checkbox
|
|
151
|
-
label="Accessible checkbox"
|
|
152
|
-
data-testid="accessible-checkbox"
|
|
153
|
-
aria-describedby="checkbox-description"
|
|
154
|
-
/>
|
|
155
|
-
<div id="checkbox-description">This checkbox has proper accessibility attributes</div>
|
|
156
|
-
<Checkbox
|
|
157
|
-
label="Required field"
|
|
158
|
-
required
|
|
159
|
-
error
|
|
160
|
-
helperText="This field is required"
|
|
161
|
-
data-testid="required-checkbox"
|
|
162
|
-
/>
|
|
163
|
-
</Stack>
|
|
164
|
-
),
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
export const Playground: Story = {
|
|
168
|
-
args: {
|
|
169
|
-
variant: 'default',
|
|
170
|
-
label: 'Playground Checkbox',
|
|
171
|
-
color: 'primary',
|
|
172
|
-
size: 'medium',
|
|
173
|
-
checked: false,
|
|
174
|
-
disabled: false,
|
|
175
|
-
indeterminate: false,
|
|
176
|
-
error: false,
|
|
177
|
-
helperText: '',
|
|
178
|
-
loading: false,
|
|
179
|
-
ripple: true,
|
|
180
|
-
glow: false,
|
|
181
|
-
pulse: false,
|
|
182
|
-
},
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
// Required story exports for validation
|
|
186
|
-
export const AllVariants: Story = {
|
|
187
|
-
render: () => (
|
|
188
|
-
<Stack spacing={3}>
|
|
189
|
-
<Stack direction="row" spacing={2} alignItems="center">
|
|
190
|
-
<Checkbox variant="default" label="Default variant" defaultChecked />
|
|
191
|
-
<Checkbox variant="rounded" label="Rounded variant" defaultChecked />
|
|
192
|
-
<Checkbox variant="toggle" label="Toggle variant" defaultChecked />
|
|
193
|
-
</Stack>
|
|
194
|
-
</Stack>
|
|
195
|
-
),
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
export const AllSizes: Story = {
|
|
199
|
-
render: () => (
|
|
200
|
-
<Stack direction="row" spacing={2} alignItems="center">
|
|
201
|
-
<Checkbox size="small" label="Small" defaultChecked />
|
|
202
|
-
<Checkbox size="medium" label="Medium" defaultChecked />
|
|
203
|
-
<Checkbox size="large" label="Large" defaultChecked />
|
|
204
|
-
</Stack>
|
|
205
|
-
),
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
export const AllStates: Story = {
|
|
209
|
-
render: () => (
|
|
210
|
-
<Stack spacing={2}>
|
|
211
|
-
<Stack direction="row" spacing={2}>
|
|
212
|
-
<Checkbox label="Default" />
|
|
213
|
-
<Checkbox label="Checked" defaultChecked />
|
|
214
|
-
<Checkbox label="Indeterminate" indeterminate />
|
|
215
|
-
</Stack>
|
|
216
|
-
<Stack direction="row" spacing={2}>
|
|
217
|
-
<Checkbox label="Disabled" disabled />
|
|
218
|
-
<Checkbox label="Disabled Checked" disabled defaultChecked />
|
|
219
|
-
<Checkbox label="Loading" loading />
|
|
220
|
-
</Stack>
|
|
221
|
-
<Stack direction="row" spacing={2}>
|
|
222
|
-
<Checkbox label="Error" error helperText="Error message" />
|
|
223
|
-
<Checkbox label="With Helper" helperText="Helper text" />
|
|
224
|
-
</Stack>
|
|
225
|
-
</Stack>
|
|
226
|
-
),
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
export const InteractiveStates: Story = {
|
|
230
|
-
render: () => (
|
|
231
|
-
<Stack spacing={3}>
|
|
232
|
-
<Stack direction="row" spacing={2}>
|
|
233
|
-
<Checkbox label="Hover me" glow />
|
|
234
|
-
<Checkbox label="Focus me" pulse />
|
|
235
|
-
<Checkbox label="Click me" defaultChecked />
|
|
236
|
-
</Stack>
|
|
237
|
-
<Stack direction="row" spacing={2}>
|
|
238
|
-
<Checkbox label="With ripple" ripple defaultChecked />
|
|
239
|
-
<Checkbox label="No ripple" ripple={false} defaultChecked />
|
|
240
|
-
</Stack>
|
|
241
|
-
</Stack>
|
|
242
|
-
),
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
export const Responsive: Story = {
|
|
246
|
-
parameters: {
|
|
247
|
-
viewport: {
|
|
248
|
-
viewports: {
|
|
249
|
-
mobile: { name: 'Mobile', styles: { width: '360px', height: '640px' } },
|
|
250
|
-
tablet: { name: 'Tablet', styles: { width: '768px', height: '1024px' } },
|
|
251
|
-
desktop: { name: 'Desktop', styles: { width: '1440px', height: '900px' } },
|
|
252
|
-
},
|
|
253
|
-
},
|
|
254
|
-
},
|
|
255
|
-
render: () => (
|
|
256
|
-
<Stack spacing={2} sx={{ width: '100%', p: 2 }}>
|
|
257
|
-
<FormGroup>
|
|
258
|
-
<Checkbox label="Responsive checkbox 1" defaultChecked />
|
|
259
|
-
<Checkbox label="Responsive checkbox 2" />
|
|
260
|
-
<Checkbox label="Responsive checkbox 3" defaultChecked />
|
|
261
|
-
<Checkbox label="Responsive checkbox 4" disabled />
|
|
262
|
-
</FormGroup>
|
|
263
|
-
</Stack>
|
|
264
|
-
),
|
|
265
|
-
};
|