@12-apps/ui 1.5.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -9
- 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,114 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Range filters as pills in the INLINE filter bar (FUT-668).
|
|
3
|
-
*
|
|
4
|
-
* The bar used to render pills only, so `rangeFields` had a surface on the
|
|
5
|
-
* slide-in panel alone — the very panel `inlineFilters` replaces on a wide
|
|
6
|
-
* screen. A range filter was therefore invisible on exactly the screens that
|
|
7
|
-
* use it, which is what pushed Pedidos to hang its own inputs outside the grid.
|
|
8
|
-
*/
|
|
9
|
-
import { fireEvent, render, screen } from "@testing-library/react";
|
|
10
|
-
import { describe, expect, it, vi } from "vitest";
|
|
11
|
-
|
|
12
|
-
import { InlineFilterBar } from "../data-views-inline-bar";
|
|
13
|
-
import { rangeChipLabel } from "../data-views-range-pill";
|
|
14
|
-
import type { RangeFieldConfig } from "../data-views-types";
|
|
15
|
-
|
|
16
|
-
interface Row extends Record<string, unknown> {
|
|
17
|
-
day: string;
|
|
18
|
-
amount: number;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const PERIOD: RangeFieldConfig<Row> = {
|
|
22
|
-
id: "period",
|
|
23
|
-
label: "Data",
|
|
24
|
-
kind: "day",
|
|
25
|
-
accessor: (row) => row.day,
|
|
26
|
-
};
|
|
27
|
-
const TOTAL: RangeFieldConfig<Row> = {
|
|
28
|
-
id: "total",
|
|
29
|
-
label: "Valor",
|
|
30
|
-
unit: "R$",
|
|
31
|
-
step: 0.01,
|
|
32
|
-
accessor: (row) => row.amount,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
function renderBar(overrides: Partial<Parameters<typeof InlineFilterBar<Row>>[0]> = {}) {
|
|
36
|
-
const onChangeRange = vi.fn();
|
|
37
|
-
render(
|
|
38
|
-
<InlineFilterBar<Row>
|
|
39
|
-
testIdPrefix="grid"
|
|
40
|
-
search=""
|
|
41
|
-
fields={[]}
|
|
42
|
-
rangeFields={[PERIOD, TOTAL]}
|
|
43
|
-
pills={{}}
|
|
44
|
-
ranges={{}}
|
|
45
|
-
onSearchChange={vi.fn()}
|
|
46
|
-
onTogglePill={vi.fn()}
|
|
47
|
-
onChangeRange={onChangeRange}
|
|
48
|
-
onClearField={vi.fn()}
|
|
49
|
-
onClearAll={vi.fn()}
|
|
50
|
-
{...overrides}
|
|
51
|
-
/>,
|
|
52
|
-
);
|
|
53
|
-
return { onChangeRange };
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
describe("InlineFilterBar — range pills", () => {
|
|
57
|
-
it("renders one pill per range field, in the filter row", () => {
|
|
58
|
-
renderBar();
|
|
59
|
-
expect(screen.getByTestId("grid-range-period")).toHaveTextContent("Data");
|
|
60
|
-
expect(screen.getByTestId("grid-range-total")).toHaveTextContent("Valor");
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("opens a popover with both bounds and reports each edit", () => {
|
|
64
|
-
const { onChangeRange } = renderBar();
|
|
65
|
-
fireEvent.click(screen.getByTestId("grid-range-period"));
|
|
66
|
-
fireEvent.change(screen.getByTestId("grid-range-period-min"), {
|
|
67
|
-
target: { value: "2026-07-01" },
|
|
68
|
-
});
|
|
69
|
-
expect(onChangeRange).toHaveBeenCalledWith("period", { min: "2026-07-01" });
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("keeps the OTHER bound when one end changes", () => {
|
|
73
|
-
const { onChangeRange } = renderBar({ ranges: { period: { min: "2026-07-01" } } });
|
|
74
|
-
fireEvent.click(screen.getByTestId("grid-range-period"));
|
|
75
|
-
fireEvent.change(screen.getByTestId("grid-range-period-max"), {
|
|
76
|
-
target: { value: "2026-07-31" },
|
|
77
|
-
});
|
|
78
|
-
expect(onChangeRange).toHaveBeenCalledWith("period", {
|
|
79
|
-
min: "2026-07-01",
|
|
80
|
-
max: "2026-07-31",
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("clears a bound rather than writing NaN when a number is emptied", () => {
|
|
85
|
-
const { onChangeRange } = renderBar({ ranges: { total: { min: 20 } } });
|
|
86
|
-
fireEvent.click(screen.getByTestId("grid-range-total"));
|
|
87
|
-
fireEvent.change(screen.getByTestId("grid-range-total-min"), { target: { value: "" } });
|
|
88
|
-
expect(onChangeRange).toHaveBeenCalledWith("total", { min: undefined });
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("shows an applied window as ONE removable chip that drops both ends", () => {
|
|
92
|
-
const { onChangeRange } = renderBar({
|
|
93
|
-
ranges: { period: { min: "2026-07-01", max: "2026-07-31" } },
|
|
94
|
-
});
|
|
95
|
-
const chip = screen.getByText("Data: 01/07–31/07");
|
|
96
|
-
expect(chip).toBeInTheDocument();
|
|
97
|
-
// The chip's delete is its sibling ✕ — clearing the window, not one end.
|
|
98
|
-
fireEvent.click(chip.parentElement?.querySelector("svg") as Element);
|
|
99
|
-
expect(onChangeRange).toHaveBeenCalledWith("period", {});
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
describe("rangeChipLabel", () => {
|
|
104
|
-
it("reads a two-sided window as a range", () => {
|
|
105
|
-
expect(rangeChipLabel(PERIOD, { min: "2026-07-01", max: "2026-07-31" })).toBe(
|
|
106
|
-
"Data: 01/07–31/07",
|
|
107
|
-
);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it("reads a one-sided window as the inequality it is, not a blank end", () => {
|
|
111
|
-
expect(rangeChipLabel(TOTAL, { min: 20 })).toBe("Valor: ≥ R$ 20");
|
|
112
|
-
expect(rangeChipLabel(TOTAL, { max: 50 })).toBe("Valor: ≤ R$ 50");
|
|
113
|
-
});
|
|
114
|
-
});
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import TableRestaurantOutlinedIcon from "@mui/icons-material/TableRestaurantOutlined";
|
|
2
|
-
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
3
|
-
|
|
4
|
-
import { Chip } from "../Chip";
|
|
5
|
-
import { Button } from "../../form/Button";
|
|
6
|
-
import { DropdownMenu } from "../../navigation/DropdownMenu";
|
|
7
|
-
import { Box } from "../../../mui/Box";
|
|
8
|
-
|
|
9
|
-
import { BaseCard } from "./base-card";
|
|
10
|
-
import { CARD_ASPECT_RATIOS, type CardAspectRatio } from "./data-views-types";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* BaseCard is the only card in `@12-apps/ui`: a fixed-ratio, selectable tile with an
|
|
14
|
-
* image (or fallback), a title/subtitle caption, a top-right menu slot, and a
|
|
15
|
-
* top-left select checkbox. Domain "kind cards" live in the app and compose it.
|
|
16
|
-
*/
|
|
17
|
-
const meta: Meta<typeof BaseCard> = {
|
|
18
|
-
title: "DataDisplay/DataViews/BaseCard",
|
|
19
|
-
component: BaseCard,
|
|
20
|
-
parameters: { layout: "centered" },
|
|
21
|
-
tags: ["autodocs"],
|
|
22
|
-
argTypes: {
|
|
23
|
-
aspectRatio: {
|
|
24
|
-
control: "select",
|
|
25
|
-
options: Object.keys(CARD_ASPECT_RATIOS) as CardAspectRatio[],
|
|
26
|
-
},
|
|
27
|
-
scale: { control: { type: "range", min: 0.9, max: 1.6, step: 0.05 } },
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
export default meta;
|
|
31
|
-
|
|
32
|
-
type Story = StoryObj<typeof BaseCard>;
|
|
33
|
-
|
|
34
|
-
const kebab = (
|
|
35
|
-
<DropdownMenu
|
|
36
|
-
size="sm"
|
|
37
|
-
items={[
|
|
38
|
-
{ id: "edit", label: "Editar", onClick: () => {} },
|
|
39
|
-
{ id: "delete", label: "Excluir", color: "error", onClick: () => {} },
|
|
40
|
-
]}
|
|
41
|
-
trigger={
|
|
42
|
-
<Button variant="text" size="sm" aria-label="Ações">
|
|
43
|
-
⋮
|
|
44
|
-
</Button>
|
|
45
|
-
}
|
|
46
|
-
/>
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
/** Title-first card (no image): the fallback icon fills the media region. */
|
|
50
|
-
export const TitleWithFallback: Story = {
|
|
51
|
-
args: {
|
|
52
|
-
aspectRatio: "4:3",
|
|
53
|
-
scale: 1,
|
|
54
|
-
title: "Mesa 12",
|
|
55
|
-
subtitle: "4 lugares",
|
|
56
|
-
imageFallback: <TableRestaurantOutlinedIcon sx={{ fontSize: 48, opacity: 0.4 }} />,
|
|
57
|
-
menu: kebab,
|
|
58
|
-
onToggleSelect: () => {},
|
|
59
|
-
},
|
|
60
|
-
render: (args) => (
|
|
61
|
-
<Box sx={{ width: 220 }}>
|
|
62
|
-
<BaseCard {...args} />
|
|
63
|
-
</Box>
|
|
64
|
-
),
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
/** With a display image. */
|
|
68
|
-
export const WithImage: Story = {
|
|
69
|
-
args: {
|
|
70
|
-
aspectRatio: "1:1",
|
|
71
|
-
scale: 1,
|
|
72
|
-
title: "Espresso Duplo",
|
|
73
|
-
subtitle: "R$ 12,00",
|
|
74
|
-
image: <img src="https://placehold.co/300x300?text=☕" alt="" />,
|
|
75
|
-
menu: kebab,
|
|
76
|
-
onToggleSelect: () => {},
|
|
77
|
-
},
|
|
78
|
-
render: (args) => (
|
|
79
|
-
<Box sx={{ width: 220 }}>
|
|
80
|
-
<BaseCard {...args} />
|
|
81
|
-
</Box>
|
|
82
|
-
),
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
/** mesa-style centered body content via `children` (no image, no caption). */
|
|
86
|
-
export const CenteredBody: Story = {
|
|
87
|
-
args: {
|
|
88
|
-
aspectRatio: "4:3",
|
|
89
|
-
scale: 1,
|
|
90
|
-
menu: kebab,
|
|
91
|
-
onToggleSelect: () => {},
|
|
92
|
-
children: (
|
|
93
|
-
<>
|
|
94
|
-
<strong>Mesa 12</strong>
|
|
95
|
-
<Chip label="Livre" size="small" color="success" variant="outlined" />
|
|
96
|
-
</>
|
|
97
|
-
),
|
|
98
|
-
},
|
|
99
|
-
render: (args) => (
|
|
100
|
-
<Box sx={{ width: 220 }}>
|
|
101
|
-
<BaseCard {...args} />
|
|
102
|
-
</Box>
|
|
103
|
-
),
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
/** Every aspect ratio at a glance. */
|
|
107
|
-
export const AllRatios: Story = {
|
|
108
|
-
render: () => (
|
|
109
|
-
<Box sx={{ display: "flex", gap: 2, flexWrap: "wrap", maxWidth: 720 }}>
|
|
110
|
-
{(Object.keys(CARD_ASPECT_RATIOS) as CardAspectRatio[]).map((ratio) => (
|
|
111
|
-
<Box key={ratio} sx={{ width: 160 }}>
|
|
112
|
-
<BaseCard
|
|
113
|
-
aspectRatio={ratio}
|
|
114
|
-
title={ratio}
|
|
115
|
-
imageFallback={<Box sx={{ fontSize: 24 }}>{ratio}</Box>}
|
|
116
|
-
onToggleSelect={() => {}}
|
|
117
|
-
/>
|
|
118
|
-
</Box>
|
|
119
|
-
))}
|
|
120
|
-
</Box>
|
|
121
|
-
),
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
/** Selected + dimmed states. */
|
|
125
|
-
export const States: Story = {
|
|
126
|
-
render: () => (
|
|
127
|
-
<Box sx={{ display: "flex", gap: 2 }}>
|
|
128
|
-
<Box sx={{ width: 180 }}>
|
|
129
|
-
<BaseCard aspectRatio="4:3" title="Selecionada" selected onToggleSelect={() => {}} />
|
|
130
|
-
</Box>
|
|
131
|
-
<Box sx={{ width: 180 }}>
|
|
132
|
-
<BaseCard aspectRatio="4:3" title="Desativada" dimmed onToggleSelect={() => {}} />
|
|
133
|
-
</Box>
|
|
134
|
-
</Box>
|
|
135
|
-
),
|
|
136
|
-
};
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
|
|
2
|
-
import { Box, Stack } from '@mui/material';
|
|
3
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
4
|
-
|
|
5
|
-
import { Button } from '../../form/Button/Button';
|
|
6
|
-
import { Chip } from '../Chip/Chip';
|
|
7
|
-
import { DescriptionItem } from './DescriptionItem';
|
|
8
|
-
|
|
9
|
-
const meta: Meta<typeof DescriptionItem> = {
|
|
10
|
-
title: 'DataDisplay/DescriptionItem',
|
|
11
|
-
component: DescriptionItem,
|
|
12
|
-
parameters: {
|
|
13
|
-
layout: 'centered',
|
|
14
|
-
},
|
|
15
|
-
tags: ['autodocs', 'component:DescriptionItem'],
|
|
16
|
-
argTypes: {
|
|
17
|
-
label: {
|
|
18
|
-
control: 'text',
|
|
19
|
-
description: 'The label text to display',
|
|
20
|
-
},
|
|
21
|
-
value: {
|
|
22
|
-
control: 'text',
|
|
23
|
-
description: 'The value to display - can be text, number, or any React node',
|
|
24
|
-
},
|
|
25
|
-
orientation: {
|
|
26
|
-
control: 'radio',
|
|
27
|
-
options: ['vertical', 'horizontal'],
|
|
28
|
-
description: 'Layout orientation',
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export default meta;
|
|
34
|
-
type Story = StoryObj<typeof meta>;
|
|
35
|
-
|
|
36
|
-
export const Default: Story = {
|
|
37
|
-
args: {
|
|
38
|
-
label: 'Incident ID',
|
|
39
|
-
value: 'INC-12345',
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const WithNumber: Story = {
|
|
44
|
-
args: {
|
|
45
|
-
label: 'Services Affected',
|
|
46
|
-
value: 42,
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export const WithLongText: Story = {
|
|
51
|
-
args: {
|
|
52
|
-
label: 'Description',
|
|
53
|
-
value: 'This is a longer description that demonstrates how the component handles multiple lines of text content.',
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export const WithCustomContent: Story = {
|
|
58
|
-
render: () => (
|
|
59
|
-
<DescriptionItem
|
|
60
|
-
label="Status"
|
|
61
|
-
value={<Chip label="Active" color="success" size="small" />}
|
|
62
|
-
/>
|
|
63
|
-
),
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export const HorizontalOrientation: Story = {
|
|
67
|
-
render: () => (
|
|
68
|
-
<Stack spacing={2} sx={{ width: 400 }}>
|
|
69
|
-
<DescriptionItem label="Name" value="John Doe" orientation="horizontal" />
|
|
70
|
-
<DescriptionItem label="Email" value="john.doe@example.com" orientation="horizontal" />
|
|
71
|
-
<DescriptionItem label="Status" value={<Chip label="Active" color="success" size="small" />} orientation="horizontal" />
|
|
72
|
-
<DescriptionItem label="Role" value="Administrator" orientation="horizontal" />
|
|
73
|
-
</Stack>
|
|
74
|
-
),
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export const VerticalOrientation: Story = {
|
|
78
|
-
render: () => (
|
|
79
|
-
<Stack spacing={3} sx={{ width: 300 }}>
|
|
80
|
-
<DescriptionItem label="Name" value="John Doe" orientation="vertical" />
|
|
81
|
-
<DescriptionItem label="Email" value="john.doe@example.com" orientation="vertical" />
|
|
82
|
-
<DescriptionItem label="Status" value={<Chip label="Active" color="success" size="small" />} orientation="vertical" />
|
|
83
|
-
<DescriptionItem label="Role" value="Administrator" orientation="vertical" />
|
|
84
|
-
</Stack>
|
|
85
|
-
),
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export const WithCopyableValue: Story = {
|
|
89
|
-
render: () => (
|
|
90
|
-
<DescriptionItem
|
|
91
|
-
label="Incident ID"
|
|
92
|
-
value={
|
|
93
|
-
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
|
|
94
|
-
<span style={{ fontWeight: 600, fontSize: '0.875rem' }}>INC-12345</span>
|
|
95
|
-
<Button
|
|
96
|
-
variant="ghost"
|
|
97
|
-
size="sm"
|
|
98
|
-
onClick={() => navigator.clipboard.writeText('INC-12345')}
|
|
99
|
-
sx={{ minWidth: 'auto', padding: 0.25 }}
|
|
100
|
-
aria-label="Copy incident ID"
|
|
101
|
-
>
|
|
102
|
-
<ContentCopyIcon sx={{ fontSize: 16 }} />
|
|
103
|
-
</Button>
|
|
104
|
-
</Box>
|
|
105
|
-
}
|
|
106
|
-
/>
|
|
107
|
-
),
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
export const GridLayout: Story = {
|
|
111
|
-
render: () => (
|
|
112
|
-
<Box
|
|
113
|
-
sx={{
|
|
114
|
-
display: 'grid',
|
|
115
|
-
gridTemplateColumns: 'repeat(4, 1fr)',
|
|
116
|
-
gap: 3,
|
|
117
|
-
width: 800,
|
|
118
|
-
}}
|
|
119
|
-
>
|
|
120
|
-
<DescriptionItem label="Incident ID" value="INC-12345" />
|
|
121
|
-
<DescriptionItem label="Started" value="2 hours ago" />
|
|
122
|
-
<DescriptionItem label="Duration" value="Ongoing" />
|
|
123
|
-
<DescriptionItem label="Services Affected" value={5} />
|
|
124
|
-
</Box>
|
|
125
|
-
),
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
export const VerticalStack: Story = {
|
|
129
|
-
render: () => (
|
|
130
|
-
<Stack spacing={3} sx={{ width: 300 }}>
|
|
131
|
-
<DescriptionItem label="Name" value="John Doe" />
|
|
132
|
-
<DescriptionItem label="Email" value="john.doe@example.com" />
|
|
133
|
-
<DescriptionItem label="Department" value="Engineering" />
|
|
134
|
-
<DescriptionItem
|
|
135
|
-
label="Role"
|
|
136
|
-
value={<Chip label="Admin" color="primary" size="small" />}
|
|
137
|
-
/>
|
|
138
|
-
</Stack>
|
|
139
|
-
),
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
export const ResponsiveGrid: Story = {
|
|
143
|
-
render: () => (
|
|
144
|
-
<Box
|
|
145
|
-
sx={{
|
|
146
|
-
display: 'grid',
|
|
147
|
-
gridTemplateColumns: { xs: '1fr', sm: 'repeat(2, 1fr)', md: 'repeat(4, 1fr)' },
|
|
148
|
-
gap: 3,
|
|
149
|
-
maxWidth: 900,
|
|
150
|
-
}}
|
|
151
|
-
>
|
|
152
|
-
<DescriptionItem label="Order ID" value="ORD-2024-001" />
|
|
153
|
-
<DescriptionItem label="Customer" value="Acme Corp" />
|
|
154
|
-
<DescriptionItem label="Total Amount" value="$1,234.56" />
|
|
155
|
-
<DescriptionItem label="Status" value={<Chip label="Completed" color="success" size="small" />} />
|
|
156
|
-
<DescriptionItem label="Order Date" value="Jan 15, 2024" />
|
|
157
|
-
<DescriptionItem label="Shipping Method" value="Express" />
|
|
158
|
-
<DescriptionItem label="Items" value={3} />
|
|
159
|
-
<DescriptionItem label="Payment Method" value="Credit Card" />
|
|
160
|
-
</Box>
|
|
161
|
-
),
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
export const WithEmptyValue: Story = {
|
|
165
|
-
render: () => (
|
|
166
|
-
<Stack spacing={3} sx={{ width: 300 }}>
|
|
167
|
-
<DescriptionItem label="Optional Field" value="N/A" />
|
|
168
|
-
<DescriptionItem label="No Value" value="-" />
|
|
169
|
-
<DescriptionItem label="Empty" value="" />
|
|
170
|
-
</Stack>
|
|
171
|
-
),
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
export const MixedOrientations: Story = {
|
|
175
|
-
render: () => (
|
|
176
|
-
<Box sx={{ width: 600 }}>
|
|
177
|
-
<Stack spacing={3}>
|
|
178
|
-
<Box>
|
|
179
|
-
<h3>Vertical Layout (Default)</h3>
|
|
180
|
-
<Box sx={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 3, mt: 2 }}>
|
|
181
|
-
<DescriptionItem label="Name" value="John Doe" />
|
|
182
|
-
<DescriptionItem label="Age" value={32} />
|
|
183
|
-
<DescriptionItem label="City" value="San Francisco" />
|
|
184
|
-
</Box>
|
|
185
|
-
</Box>
|
|
186
|
-
|
|
187
|
-
<Box>
|
|
188
|
-
<h3>Horizontal Layout</h3>
|
|
189
|
-
<Stack spacing={2} sx={{ mt: 2 }}>
|
|
190
|
-
<DescriptionItem label="Name" value="John Doe" orientation="horizontal" />
|
|
191
|
-
<DescriptionItem label="Age" value={32} orientation="horizontal" />
|
|
192
|
-
<DescriptionItem label="City" value="San Francisco" orientation="horizontal" />
|
|
193
|
-
</Stack>
|
|
194
|
-
</Box>
|
|
195
|
-
</Stack>
|
|
196
|
-
</Box>
|
|
197
|
-
),
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
export const AllVariations: Story = {
|
|
201
|
-
render: () => (
|
|
202
|
-
<Stack spacing={4} sx={{ width: 800 }}>
|
|
203
|
-
<Box>
|
|
204
|
-
<h3>Text Values (Vertical)</h3>
|
|
205
|
-
<Box sx={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 3, mt: 2 }}>
|
|
206
|
-
<DescriptionItem label="Short Text" value="Value" />
|
|
207
|
-
<DescriptionItem label="Medium Text" value="This is a medium length value" />
|
|
208
|
-
<DescriptionItem label="Long Text" value="This is a much longer text value that will wrap to multiple lines" />
|
|
209
|
-
</Box>
|
|
210
|
-
</Box>
|
|
211
|
-
|
|
212
|
-
<Box>
|
|
213
|
-
<h3>Text Values (Horizontal)</h3>
|
|
214
|
-
<Stack spacing={2} sx={{ mt: 2 }}>
|
|
215
|
-
<DescriptionItem label="Short Text" value="Value" orientation="horizontal" />
|
|
216
|
-
<DescriptionItem label="Medium Text" value="This is a medium length value" orientation="horizontal" />
|
|
217
|
-
<DescriptionItem label="Long Text" value="This is a much longer text value that will wrap to multiple lines" orientation="horizontal" />
|
|
218
|
-
</Stack>
|
|
219
|
-
</Box>
|
|
220
|
-
|
|
221
|
-
<Box>
|
|
222
|
-
<h3>Number Values</h3>
|
|
223
|
-
<Box sx={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 3, mt: 2 }}>
|
|
224
|
-
<DescriptionItem label="Integer" value={42} />
|
|
225
|
-
<DescriptionItem label="Decimal" value={3.14159} />
|
|
226
|
-
<DescriptionItem label="Large Number" value={1234567890} />
|
|
227
|
-
</Box>
|
|
228
|
-
</Box>
|
|
229
|
-
|
|
230
|
-
<Box>
|
|
231
|
-
<h3>Custom Components</h3>
|
|
232
|
-
<Box sx={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 3, mt: 2 }}>
|
|
233
|
-
<DescriptionItem
|
|
234
|
-
label="With Chip"
|
|
235
|
-
value={<Chip label="Active" color="success" size="small" />}
|
|
236
|
-
/>
|
|
237
|
-
<DescriptionItem
|
|
238
|
-
label="With Button"
|
|
239
|
-
value={<Button size="xs" variant="outline">Action</Button>}
|
|
240
|
-
/>
|
|
241
|
-
<DescriptionItem
|
|
242
|
-
label="Multiple Elements"
|
|
243
|
-
value={
|
|
244
|
-
<Box sx={{ display: 'flex', gap: 0.5 }}>
|
|
245
|
-
<Chip label="Tag 1" size="small" />
|
|
246
|
-
<Chip label="Tag 2" size="small" />
|
|
247
|
-
</Box>
|
|
248
|
-
}
|
|
249
|
-
/>
|
|
250
|
-
</Box>
|
|
251
|
-
</Box>
|
|
252
|
-
</Stack>
|
|
253
|
-
),
|
|
254
|
-
};
|