@12-apps/ui 1.0.0 → 1.3.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/components-catalog.md +14 -0
- package/package.json +42 -27
- package/src/__tests__/data-grid.test.tsx +125 -0
- package/src/__tests__/package-wiring.test.ts +12 -8
- package/src/__tests__/social-login-button.test.tsx +5 -5
- package/src/__tests__/viewport.test.ts +50 -0
- package/src/charts/index.ts +8 -0
- package/src/components/data-display/Alert/Alert.md +1 -1
- package/src/components/data-display/Alert/Alert.stories.tsx +5 -7
- package/src/components/data-display/Alert/Alert.styles.tsx +255 -0
- package/src/components/data-display/Alert/Alert.test.stories.tsx +11 -13
- package/src/components/data-display/Alert/Alert.tsx +135 -328
- package/src/components/data-display/AlertDialog/AlertDialog.stories.tsx +3 -1
- package/src/components/data-display/AlertDialog/AlertDialog.tsx +191 -78
- package/src/components/data-display/AlertDialog/AlertDialog.types.ts +8 -1
- package/src/components/data-display/AsyncStateContainer/AsyncStateContainer.test.stories.tsx +5 -5
- package/src/components/data-display/AsyncStateContainer/AsyncStateContainer.tsx +44 -35
- package/src/components/data-display/Avatar/Avatar.stories.tsx +4 -1
- package/src/components/data-display/Avatar/Avatar.test.stories.tsx +5 -3
- package/src/components/data-display/Avatar/Avatar.tsx +154 -450
- package/src/components/data-display/Avatar/Avatar.view.tsx +396 -0
- package/src/components/data-display/Badge/Badge.animations.ts +67 -0
- package/src/components/data-display/Badge/Badge.helpers.ts +74 -0
- package/src/components/data-display/Badge/Badge.stories.tsx +14 -16
- package/src/components/data-display/Badge/Badge.styles.ts +261 -0
- package/src/components/data-display/Badge/Badge.test.stories.tsx +32 -31
- package/src/components/data-display/Badge/Badge.tsx +151 -557
- package/src/components/data-display/Badge/Badge.variants.ts +106 -0
- package/src/components/data-display/Badge/BadgeContent.tsx +107 -0
- package/src/components/data-display/Banner/Banner.stories.tsx +5 -1
- package/src/components/data-display/Banner/Banner.styles.ts +120 -0
- package/src/components/data-display/Banner/Banner.tsx +179 -224
- package/src/components/data-display/Chart/Chart.md +48 -1
- package/src/components/data-display/Chart/Chart.tsx +82 -500
- package/src/components/data-display/Chart/Chart.types.ts +2 -0
- package/src/components/data-display/Chart/ChartComposables.tsx +121 -0
- package/src/components/data-display/Chart/ChartSpec.types.ts +70 -0
- package/src/components/data-display/Chart/SpecChart.stories.tsx +150 -0
- package/src/components/data-display/Chart/SpecChart.test.stories.tsx +56 -0
- package/src/components/data-display/Chart/SpecChart.tsx +53 -0
- package/src/components/data-display/Chart/__tests__/SpecChart.test.tsx +60 -0
- package/src/components/data-display/Chart/__tests__/chart-format.test.ts +43 -0
- package/src/components/data-display/Chart/__tests__/chart-spec.test.ts +119 -0
- package/src/components/data-display/Chart/chart-format.ts +26 -0
- package/src/components/data-display/Chart/chart-internals.ts +148 -0
- package/src/components/data-display/Chart/chart-renderers.tsx +338 -0
- package/src/components/data-display/Chart/chart-spec-registry.ts +74 -0
- package/src/components/data-display/Chart/chart-spec.ts +171 -0
- package/src/components/data-display/Chart/index.ts +30 -0
- package/src/components/data-display/Chip/Chip.helpers.tsx +131 -0
- package/src/components/data-display/Chip/Chip.stories.tsx +2 -1
- package/src/components/data-display/Chip/Chip.test.stories.tsx +11 -8
- package/src/components/data-display/Chip/Chip.tsx +31 -94
- package/src/components/data-display/DataGrid/DataGrid.body.tsx +141 -0
- package/src/components/data-display/DataGrid/DataGrid.cells.tsx +238 -0
- package/src/components/data-display/DataGrid/DataGrid.model.ts +315 -0
- package/src/components/data-display/DataGrid/DataGrid.rows.ts +112 -0
- package/src/components/data-display/DataGrid/DataGrid.states.tsx +102 -0
- package/src/components/data-display/DataGrid/DataGrid.test.stories.tsx +6 -12
- package/src/components/data-display/DataGrid/DataGrid.tsx +129 -725
- package/src/components/data-display/DataViews/DataViewsGrid.tsx +187 -0
- package/src/components/data-display/DataViews/DataViewsTableBase.tsx +400 -0
- package/src/components/data-display/DataViews/ManageViewsDialog.tsx +140 -0
- package/src/components/data-display/DataViews/SaveViewModal.tsx +289 -0
- package/src/components/data-display/DataViews/__tests__/DataViewsGrid.test.tsx +271 -0
- package/src/components/data-display/DataViews/__tests__/DataViewsTableBase.test.tsx +134 -0
- package/src/components/data-display/DataViews/__tests__/SaveViewModal.test.tsx +83 -0
- package/src/components/data-display/DataViews/__tests__/data-views-filter.test.ts +115 -0
- package/src/components/data-display/DataViews/__tests__/data-views-preview.test.ts +53 -0
- package/src/components/data-display/DataViews/__tests__/range-pill.test.tsx +114 -0
- package/src/components/data-display/DataViews/base-card.stories.tsx +136 -0
- package/src/components/data-display/DataViews/base-card.tsx +278 -0
- package/src/components/data-display/DataViews/data-views-filter-panel.tsx +184 -0
- package/src/components/data-display/DataViews/data-views-filter.ts +138 -0
- package/src/components/data-display/DataViews/data-views-grid-helpers.tsx +248 -0
- package/src/components/data-display/DataViews/data-views-grid-parts.tsx +400 -0
- package/src/components/data-display/DataViews/data-views-inline-bar.tsx +257 -0
- package/src/components/data-display/DataViews/data-views-layout-context.tsx +176 -0
- package/src/components/data-display/DataViews/data-views-pagination.tsx +31 -0
- package/src/components/data-display/DataViews/data-views-preview.ts +53 -0
- package/src/components/data-display/DataViews/data-views-range-pill.tsx +277 -0
- package/src/components/data-display/DataViews/data-views-table-parts.tsx +150 -0
- package/src/components/data-display/DataViews/data-views-toolbar.tsx +149 -0
- package/src/components/data-display/DataViews/data-views-types.ts +312 -0
- package/src/components/data-display/DataViews/data-views-view-mutations.ts +68 -0
- package/src/components/data-display/DataViews/index.ts +33 -0
- package/src/components/data-display/DataViews/use-data-views-state.ts +349 -0
- package/src/components/data-display/DateTimeDisplay/DateTimeDisplay.hooks.ts +104 -0
- package/src/components/data-display/DateTimeDisplay/DateTimeDisplay.tsx +68 -118
- package/src/components/data-display/DescriptionItem/DescriptionItem.stories.tsx +1 -1
- package/src/components/data-display/DescriptionItem/DescriptionItem.tsx +52 -34
- package/src/components/data-display/EmptyState/EmptyState.test.stories.tsx +6 -6
- package/src/components/data-display/EmptyState/EmptyState.tsx +218 -135
- package/src/components/data-display/ErrorState/ErrorState.test.stories.tsx +2 -2
- package/src/components/data-display/ErrorState/ErrorState.tsx +83 -55
- package/src/components/data-display/HoverCard/HoverCard.stories.tsx +3 -1
- package/src/components/data-display/HoverCard/HoverCard.test.stories.tsx +5 -5
- package/src/components/data-display/InteractiveTooltip/InteractiveTooltip.hooks.ts +99 -0
- package/src/components/data-display/InteractiveTooltip/InteractiveTooltip.styles.ts +87 -0
- package/src/components/data-display/InteractiveTooltip/InteractiveTooltip.tsx +28 -155
- package/src/components/data-display/LazyImage/LazyImage.hooks.ts +203 -0
- package/src/components/data-display/LazyImage/LazyImage.md +1 -1
- package/src/components/data-display/LazyImage/LazyImage.stories.tsx +3 -3
- package/src/components/data-display/LazyImage/LazyImage.tsx +144 -243
- package/src/components/data-display/Lightbox/Lightbox.constants.ts +53 -0
- package/src/components/data-display/Lightbox/Lightbox.helpers.ts +39 -0
- package/src/components/data-display/Lightbox/Lightbox.hooks.ts +259 -0
- package/src/components/data-display/Lightbox/Lightbox.test.stories.tsx +28 -35
- package/src/components/data-display/Lightbox/Lightbox.tsx +98 -658
- package/src/components/data-display/Lightbox/LightboxControls.tsx +152 -0
- package/src/components/data-display/Lightbox/LightboxCurrentMedia.tsx +50 -0
- package/src/components/data-display/Lightbox/LightboxMedia.tsx +76 -0
- package/src/components/data-display/Lightbox/LightboxOverlay.tsx +83 -0
- package/src/components/data-display/Lightbox/LightboxStage.tsx +97 -0
- package/src/components/data-display/Lightbox/LightboxThumbnails.tsx +83 -0
- package/src/components/data-display/Lightbox/useLightbox.ts +80 -0
- package/src/components/data-display/LoadingState/LoadingState.helpers.ts +52 -0
- package/src/components/data-display/LoadingState/LoadingState.tsx +117 -87
- package/src/components/data-display/MapPreview/MapControlBar.tsx +116 -0
- package/src/components/data-display/MapPreview/MapDecorations.tsx +155 -0
- package/src/components/data-display/MapPreview/MapLayers.tsx +70 -0
- package/src/components/data-display/MapPreview/MapMarkers.tsx +84 -0
- package/src/components/data-display/MapPreview/MapOverlays.tsx +68 -0
- package/src/components/data-display/MapPreview/MapPreview.constants.ts +19 -0
- package/src/components/data-display/MapPreview/MapPreview.helpers.ts +63 -0
- package/src/components/data-display/MapPreview/MapPreview.hooks.ts +265 -0
- package/src/components/data-display/MapPreview/MapPreview.test.stories.tsx +14 -10
- package/src/components/data-display/MapPreview/MapPreview.tsx +52 -882
- package/src/components/data-display/MapPreview/MapPreview.types.ts +8 -1
- package/src/components/data-display/MapPreview/MapSearchBar.tsx +64 -0
- package/src/components/data-display/MapPreview/MapTiles.tsx +70 -0
- package/src/components/data-display/MapPreview/StaticMapView.tsx +63 -0
- package/src/components/data-display/MapPreview/mapProjection.ts +52 -0
- package/src/components/data-display/MapPreview/mapSurface.ts +37 -0
- package/src/components/data-display/MapPreview/useMapPreview.ts +62 -0
- package/src/components/data-display/Popover/Popover.test.stories.tsx +13 -19
- package/src/components/data-display/Progress/Progress.helpers.ts +37 -0
- package/src/components/data-display/Progress/Progress.styles.ts +101 -0
- package/src/components/data-display/Progress/Progress.tsx +185 -213
- package/src/components/data-display/SectionOnboarding/SectionOnboarding.stories.tsx +1 -1
- package/src/components/data-display/SectionOnboarding/SectionOnboarding.tsx +1 -1
- package/src/components/data-display/StatCard/StatCard.md +117 -0
- package/src/components/data-display/StatCard/StatCard.stories.tsx +167 -0
- package/src/components/data-display/StatCard/StatCard.test.stories.tsx +240 -0
- package/src/components/data-display/StatCard/StatCard.tsx +236 -0
- package/src/components/data-display/StatCard/StatCard.types.ts +62 -0
- package/src/components/data-display/StatCard/index.ts +7 -0
- package/src/components/data-display/Stepper/Stepper.test.stories.tsx +12 -19
- package/src/components/data-display/Stepper/Stepper.tsx +1 -1
- package/src/components/data-display/Table/Table.helpers.ts +31 -0
- package/src/components/data-display/Table/Table.hooks.ts +161 -0
- package/src/components/data-display/Table/Table.stories.tsx +3 -1
- package/src/components/data-display/Table/Table.styles.ts +223 -0
- package/src/components/data-display/Table/Table.test.stories.tsx +4 -4
- package/src/components/data-display/Table/Table.tsx +291 -748
- package/src/components/data-display/Table/TableParts.hooks.tsx +112 -0
- package/src/components/data-display/Table/TableParts.tsx +298 -0
- package/src/components/data-display/Table/TableStates.tsx +21 -0
- package/src/components/data-display/Timeline/Timeline.stories.tsx +10 -12
- package/src/components/data-display/Timeline/Timeline.test.stories.tsx +30 -44
- package/src/components/data-display/Timeline/Timeline.tsx +23 -284
- package/src/components/data-display/Timeline/TimelineRow.tsx +346 -0
- package/src/components/data-display/TimingDiagram/TimingDiagram.tsx +38 -311
- package/src/components/data-display/TimingDiagram/TimingDiagram.views.tsx +346 -0
- package/src/components/data-display/Tooltip/Tooltip.stories.tsx +4 -1
- package/src/components/data-display/Tooltip/Tooltip.test.stories.tsx +44 -58
- package/src/components/data-display/Tooltip/Tooltip.tsx +67 -62
- package/src/components/data-display/index.ts +1 -0
- package/src/components/feedback/ConfirmAction/ConfirmAction.hooks.ts +96 -0
- package/src/components/feedback/ConfirmAction/ConfirmAction.md +140 -0
- package/src/components/feedback/ConfirmAction/ConfirmAction.parts.tsx +154 -0
- package/src/components/feedback/ConfirmAction/ConfirmAction.stories.tsx +146 -0
- package/src/components/feedback/ConfirmAction/ConfirmAction.test.stories.tsx +114 -0
- package/src/components/feedback/ConfirmAction/ConfirmAction.tsx +46 -0
- package/src/components/feedback/ConfirmAction/ConfirmAction.types.ts +111 -0
- package/src/components/feedback/ConfirmAction/ConfirmButton.tsx +18 -0
- package/src/components/feedback/ConfirmAction/__tests__/confirm-action.test.tsx +288 -0
- package/src/components/feedback/ConfirmAction/index.ts +16 -0
- package/src/components/feedback/ConfirmAction/with-confirmation.tsx +112 -0
- package/src/components/feedback/Dialog/Dialog.styles.ts +4 -2
- package/src/components/feedback/Dialog/Dialog.tsx +26 -1
- package/src/components/feedback/Dialog/__tests__/dialog-content-spacing.test.tsx +66 -0
- package/src/components/feedback/Modal/Modal.md +1 -1
- package/src/components/feedback/Modal/Modal.stories.tsx +2 -2
- package/src/components/feedback/Sonner/Sonner.tsx +104 -288
- package/src/components/feedback/Sonner/Sonner.types.ts +7 -0
- package/src/components/feedback/Sonner/SonnerToast.tsx +216 -0
- package/src/components/feedback/StackedModal/StackedModal.hooks.ts +226 -0
- package/src/components/feedback/StackedModal/StackedModal.parts.tsx +311 -0
- package/src/components/feedback/StackedModal/StackedModal.stories.tsx +13 -15
- package/src/components/feedback/StackedModal/StackedModal.styles.ts +193 -0
- package/src/components/feedback/StackedModal/StackedModal.tsx +100 -619
- package/src/components/feedback/StackedModal/StackedModal.types.ts +17 -3
- package/src/components/feedback/StackedModal/__tests__/stacked-modal-viewport.test.tsx +104 -0
- package/src/components/feedback/StackedModal/modal-stack.tsx +119 -0
- package/src/components/feedback/Toast/Toast.tsx +92 -81
- package/src/components/feedback/TutorialOverlay/TutorialOverlay.geometry.ts +65 -0
- package/src/components/feedback/TutorialOverlay/TutorialOverlay.hooks.ts +185 -0
- package/src/components/feedback/TutorialOverlay/TutorialOverlay.test.stories.tsx +2 -2
- package/src/components/feedback/TutorialOverlay/TutorialOverlay.tsx +156 -414
- package/src/components/feedback/TutorialOverlay/TutorialStepBody.tsx +255 -0
- package/src/components/feedback/index.ts +1 -0
- package/src/components/form/AddressAutocomplete/AddressAutocomplete.helpers.ts +58 -0
- package/src/components/form/AddressAutocomplete/AddressAutocomplete.hooks.ts +93 -0
- package/src/components/form/AddressAutocomplete/AddressAutocomplete.mapper.ts +57 -0
- package/src/components/form/AddressAutocomplete/AddressAutocomplete.stories.tsx +4 -2
- package/src/components/form/AddressAutocomplete/AddressAutocomplete.test.stories.tsx +20 -16
- package/src/components/form/AddressAutocomplete/AddressAutocomplete.tsx +26 -829
- package/src/components/form/AddressAutocomplete/AddressAutocomplete.types.ts +11 -0
- package/src/components/form/AddressAutocomplete/AddressAutocompleteField.tsx +86 -0
- package/src/components/form/AddressAutocomplete/AddressFallbackField.tsx +64 -0
- package/src/components/form/AddressAutocomplete/AddressInputField.tsx +80 -0
- package/src/components/form/AddressAutocomplete/AddressOption.tsx +83 -0
- package/src/components/form/AddressAutocomplete/AddressSuggestionsPaper.tsx +24 -0
- package/src/components/form/AddressAutocomplete/AddressTextField.tsx +43 -0
- package/src/components/form/AddressAutocomplete/mockPlaces.ts +208 -0
- package/src/components/form/AddressAutocomplete/useAddressPredictions.ts +136 -0
- package/src/components/form/AddressAutocomplete/useAddressSelection.ts +113 -0
- package/src/components/form/AddressAutocomplete/useCurrentLocation.ts +116 -0
- package/src/components/form/AddressAutocomplete/useGoogleMapsAPI.ts +75 -0
- package/src/components/form/Button/Button.helpers.ts +36 -0
- package/src/components/form/Button/Button.stories.tsx +4 -1
- package/src/components/form/Button/Button.styles.ts +225 -0
- package/src/components/form/Button/Button.test.stories.tsx +25 -21
- package/src/components/form/Button/Button.tsx +45 -252
- package/src/components/form/Calendar/Calendar.dates.ts +100 -0
- package/src/components/form/Calendar/Calendar.helpers.ts +32 -0
- package/src/components/form/Calendar/Calendar.hooks.ts +278 -0
- package/src/components/form/Calendar/Calendar.keyboard.ts +32 -0
- package/src/components/form/Calendar/Calendar.selection.ts +156 -0
- package/src/components/form/Calendar/Calendar.test.stories.tsx +33 -34
- package/src/components/form/Calendar/Calendar.tsx +63 -551
- package/src/components/form/Calendar/Calendar.types.ts +16 -0
- package/src/components/form/Calendar/CalendarDay.tsx +127 -0
- package/src/components/form/Calendar/CalendarDayCell.tsx +52 -0
- package/src/components/form/Calendar/CalendarMonth.tsx +128 -0
- package/src/components/form/CepField/CepField.md +138 -0
- package/src/components/form/CepField/CepField.stories.tsx +138 -0
- package/src/components/form/CepField/CepField.test.stories.tsx +281 -0
- package/src/components/form/CepField/CepField.tsx +211 -0
- package/src/components/form/CepField/CepField.types.ts +73 -0
- package/src/components/form/CepField/index.ts +2 -0
- package/src/components/form/Checkbox/Checkbox.helpers.ts +28 -0
- package/src/components/form/Checkbox/Checkbox.tsx +19 -16
- package/src/components/form/CodeEditor/CodeEditor.helpers.ts +45 -0
- package/src/components/form/CodeEditor/CodeEditor.hooks.ts +104 -0
- package/src/components/form/CodeEditor/CodeEditor.monaco.ts +109 -0
- package/src/components/form/CodeEditor/CodeEditor.test.stories.tsx +17 -18
- package/src/components/form/CodeEditor/CodeEditor.tsx +81 -330
- package/src/components/form/CodeEditor/CodeEditorToolbar.tsx +168 -0
- package/src/components/form/Command/Command.hooks.ts +207 -0
- package/src/components/form/Command/Command.parts.tsx +58 -0
- package/src/components/form/Command/Command.styles.ts +83 -0
- package/src/components/form/Command/Command.tsx +61 -270
- package/src/components/form/CreatableSelect/CreatableSelect.md +1 -1
- package/src/components/form/CreatableSelect/CreatableSelect.test.stories.tsx +1 -1
- package/src/components/form/CreatableSelect/CreatableSelect.tsx +152 -71
- package/src/components/form/CreatableSelect/CreatableSelect.types.ts +13 -0
- package/src/components/form/HeaderButton/HeaderButton.tsx +80 -0
- package/src/components/form/HeaderButton/index.ts +2 -0
- package/src/components/form/Input/Input.stories.tsx +5 -1
- package/src/components/form/Input/Input.styles.ts +176 -0
- package/src/components/form/Input/Input.test.stories.tsx +30 -23
- package/src/components/form/Input/Input.tsx +71 -211
- package/src/components/form/Input/Input.types.ts +11 -0
- package/src/components/form/InputOTP/InputOTP.test.stories.tsx +9 -17
- package/src/components/form/Menubar/Menubar.test.stories.tsx +4 -8
- package/src/components/form/PasswordStrength/PasswordStrength.helpers.tsx +117 -0
- package/src/components/form/PasswordStrength/PasswordStrength.test.stories.tsx +3 -3
- package/src/components/form/PasswordStrength/PasswordStrength.tsx +202 -255
- package/src/components/form/PhoneInput/PhoneInput.hooks.ts +134 -0
- package/src/components/form/PhoneInput/PhoneInput.test.stories.tsx +4 -4
- package/src/components/form/PhoneInput/PhoneInput.tsx +279 -292
- package/src/components/form/PhoneInput/countries.ts +54 -0
- package/src/components/form/PhoneInput/phone.ts +47 -0
- package/src/components/form/RadioGroup/RadioGroup.test.stories.tsx +9 -9
- package/src/components/form/RichTextEditor/RichTextEditor.dom.ts +124 -0
- package/src/components/form/RichTextEditor/RichTextEditor.format.ts +61 -0
- package/src/components/form/RichTextEditor/RichTextEditor.hooks.ts +142 -0
- package/src/components/form/RichTextEditor/RichTextEditor.test.stories.tsx +5 -12
- package/src/components/form/RichTextEditor/RichTextEditor.tsx +98 -410
- package/src/components/form/RichTextEditor/RichTextEditorToolbar.tsx +187 -0
- package/src/components/form/SearchPalette/SearchPalette.parts.tsx +22 -0
- package/src/components/form/SearchPalette/SearchPalette.tsx +13 -9
- package/src/components/form/Select/Select.test.stories.tsx +35 -27
- package/src/components/form/Slider/Slider.test.stories.tsx +9 -11
- package/src/components/form/Switch/Switch.md +2 -1
- package/src/components/form/Switch/Switch.test.stories.tsx +6 -6
- package/src/components/form/Textarea/Textarea.styles.ts +143 -0
- package/src/components/form/Textarea/Textarea.test.stories.tsx +20 -26
- package/src/components/form/Textarea/Textarea.tsx +114 -535
- package/src/components/form/Textarea/TextareaRichEditor.tsx +377 -0
- package/src/components/form/Toggle/Toggle.styles.ts +211 -0
- package/src/components/form/Toggle/Toggle.test.stories.tsx +19 -27
- package/src/components/form/Toggle/Toggle.tsx +10 -185
- package/src/components/form/UploadButton/UploadButton.hooks.ts +323 -0
- package/src/components/form/UploadButton/UploadButton.parts.tsx +210 -0
- package/src/components/form/UploadButton/UploadButton.stories.tsx +2 -1
- package/src/components/form/UploadButton/UploadButton.test.stories.tsx +123 -4
- package/src/components/form/UploadButton/UploadButton.tsx +76 -305
- package/src/components/form/UploadButton/UploadButton.types.ts +16 -0
- package/src/components/form/index.ts +1 -0
- package/src/components/form/total-form/Fields/CepField.tsx +143 -0
- package/src/components/form/total-form/Fields/ToggleField.tsx +61 -0
- package/src/components/form/total-form/Fields/index.ts +4 -0
- package/src/components/form/total-form/FormContainer.tsx +3 -3
- package/src/components/form/total-form/SubmitButton.tsx +25 -2
- package/src/components/form/total-form/total-form.test.tsx +118 -1
- package/src/components/layout/Accordion/Accordion.md +1 -1
- package/src/components/layout/Accordion/Accordion.stories.tsx +5 -1
- package/src/components/layout/Accordion/Accordion.styles.ts +80 -0
- package/src/components/layout/Accordion/Accordion.test.stories.tsx +32 -50
- package/src/components/layout/Accordion/Accordion.tsx +2 -75
- package/src/components/layout/Card/Card.helpers.ts +30 -0
- package/src/components/layout/Card/Card.stories.tsx +9 -11
- package/src/components/layout/Card/Card.styles.ts +182 -0
- package/src/components/layout/Card/Card.test.stories.tsx +46 -46
- package/src/components/layout/Card/Card.tsx +24 -241
- package/src/components/layout/CardGrid/CardGrid.md +96 -0
- package/src/components/layout/CardGrid/CardGrid.tsx +140 -0
- package/src/components/layout/CardGrid/__tests__/CardGrid.test.tsx +92 -0
- package/src/components/layout/CardGrid/index.ts +2 -0
- package/src/components/layout/Collapsible/Collapsible.helpers.ts +83 -0
- package/src/components/layout/Collapsible/Collapsible.test.stories.tsx +7 -3
- package/src/components/layout/Collapsible/Collapsible.tsx +111 -107
- package/src/components/layout/Container/Container.test.stories.tsx +11 -16
- package/src/components/layout/ContentToolbar/ColumnsMenu.tsx +1 -1
- package/src/components/layout/ContentToolbar/ContentToolbar.tsx +120 -44
- package/src/components/layout/ContentToolbar/ContentToolbar.types.ts +9 -0
- package/src/components/layout/ContentToolbar/FilterTrigger.tsx +1 -1
- package/src/components/layout/ContentToolbar/MultiSelectDropdown.tsx +58 -43
- package/src/components/layout/ContentToolbar/MultiSelectTriggers.tsx +139 -0
- package/src/components/layout/ContentToolbar/SavedViewsMenu.tsx +10 -3
- package/src/components/layout/ContentToolbar/SortByDropdown.tsx +35 -11
- package/src/components/layout/ContentToolbar/ViewSelector.tsx +5 -6
- package/src/components/layout/ContentToolbar/__tests__/MultiSelectDropdown.test.tsx +21 -0
- package/src/components/layout/Dashboard/Dashboard.test.stories.tsx +27 -1
- package/src/components/layout/Dashboard/Dashboard.tsx +27 -8
- package/src/components/layout/Dashboard/DashboardParts.tsx +12 -19
- package/src/components/layout/Dashboard/index.ts +2 -1
- package/src/components/layout/Drawer/Drawer.stories.tsx +8 -10
- package/src/components/layout/Drawer/Drawer.test.stories.tsx +18 -14
- package/src/components/layout/Drawer/Drawer.tsx +67 -53
- package/src/components/layout/Resizable/Resizable.helpers.ts +133 -0
- package/src/components/layout/Resizable/Resizable.hooks.ts +68 -0
- package/src/components/layout/Resizable/Resizable.tsx +38 -153
- package/src/components/layout/ScrollArea/ScrollArea.helpers.ts +51 -0
- package/src/components/layout/ScrollArea/ScrollArea.styles.ts +248 -0
- package/src/components/layout/ScrollArea/ScrollArea.tsx +183 -374
- package/src/components/layout/ScrollArea/ScrollAreaContent.tsx +70 -0
- package/src/components/layout/ScrollArea/ScrollViewport.tsx +90 -0
- package/src/components/layout/Separator/Separator.styles.ts +128 -0
- package/src/components/layout/Separator/Separator.test.stories.tsx +3 -12
- package/src/components/layout/Separator/Separator.tsx +6 -132
- package/src/components/layout/SettingsLayout/SettingsLayout.parts.tsx +2 -1
- package/src/components/layout/SettingsLayout/SettingsLayout.stories.tsx +6 -8
- package/src/components/layout/Sidebar/Sidebar.stories.tsx +10 -12
- package/src/components/layout/Sidebar/Sidebar.test.stories.tsx +35 -37
- package/src/components/layout/Skeleton/Skeleton.helpers.ts +33 -0
- package/src/components/layout/Skeleton/Skeleton.styles.ts +114 -0
- package/src/components/layout/Skeleton/Skeleton.test.stories.tsx +3 -3
- package/src/components/layout/Skeleton/Skeleton.tsx +67 -155
- package/src/components/layout/TableFilter/TableFilter.tsx +2 -1
- package/src/components/navigation/Breadcrumbs/BreadcrumbEntry.tsx +305 -0
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.md +2 -1
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.stories.tsx +12 -14
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.styles.tsx +212 -0
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.test.stories.tsx +62 -61
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.tsx +116 -429
- package/src/components/navigation/CommandPalette/CommandPalette.helpers.ts +82 -0
- package/src/components/navigation/CommandPalette/CommandPalette.hooks.ts +202 -0
- package/src/components/navigation/CommandPalette/CommandPalette.stories.tsx +3 -1
- package/src/components/navigation/CommandPalette/CommandPalette.test.stories.tsx +3 -5
- package/src/components/navigation/CommandPalette/CommandPalette.tsx +108 -341
- package/src/components/navigation/CommandPalette/CommandPaletteResults.tsx +182 -0
- package/src/components/navigation/CommandPalette/ShortcutChip.tsx +18 -0
- package/src/components/navigation/ContextMenu/ContextMenu.md +3 -1
- package/src/components/navigation/ContextMenu/ContextMenu.stories.tsx +4 -1
- package/src/components/navigation/ContextMenu/ContextMenu.test.stories.tsx +19 -24
- package/src/components/navigation/ContextMenu/ContextMenu.tsx +70 -54
- package/src/components/navigation/DropdownMenu/DropdownMenu.md +3 -1
- package/src/components/navigation/DropdownMenu/DropdownMenu.stories.tsx +17 -19
- package/src/components/navigation/DropdownMenu/DropdownMenu.test.stories.tsx +26 -26
- package/src/components/navigation/DropdownMenu/DropdownMenu.tsx +189 -111
- package/src/components/navigation/NavigationMenu/NavigationMegaSection.tsx +66 -0
- package/src/components/navigation/NavigationMenu/NavigationMenu.md +7 -2
- package/src/components/navigation/NavigationMenu/NavigationMenu.shell.tsx +218 -0
- package/src/components/navigation/NavigationMenu/NavigationMenu.styles.ts +223 -0
- package/src/components/navigation/NavigationMenu/NavigationMenu.tsx +119 -808
- package/src/components/navigation/NavigationMenu/NavigationMenuItem.hooks.ts +126 -0
- package/src/components/navigation/NavigationMenu/NavigationMenuItem.tsx +352 -0
- package/src/components/navigation/NavigationMenu/NavigationStandardBody.tsx +148 -0
- package/src/components/navigation/NavigationMenu/stories/NavigationMenu.stories.tsx +15 -17
- package/src/components/navigation/NavigationMenu/stories/NavigationMenu.test.stories.tsx +27 -23
- package/src/components/navigation/NavigationMenu/stories/NavigationMenuHorizontal.stories.tsx +11 -13
- package/src/components/navigation/NavigationMenu/stories/NavigationMenuVertical.stories.tsx +9 -11
- package/src/components/navigation/Pagination/Pagination.helpers.tsx +85 -0
- package/src/components/navigation/Pagination/Pagination.md +2 -1
- package/src/components/navigation/Pagination/Pagination.stories.tsx +4 -6
- package/src/components/navigation/Pagination/Pagination.styles.ts +135 -0
- package/src/components/navigation/Pagination/Pagination.tsx +178 -313
- package/src/components/navigation/Pagination/PaginationParts.tsx +81 -0
- package/src/components/navigation/Tabs/Tabs.md +3 -1
- package/src/components/navigation/Tabs/Tabs.stories.tsx +21 -23
- package/src/components/navigation/Tabs/Tabs.styles.ts +163 -0
- package/src/components/navigation/Tabs/Tabs.test.stories.tsx +37 -37
- package/src/components/navigation/Tabs/Tabs.tsx +192 -361
- package/src/components/navigation/Tabs/TabsPanel.tsx +100 -0
- package/src/components/typography/Blockquote/Blockquote.tsx +1 -1
- package/src/components/typography/Code/Code.test.stories.tsx +5 -5
- package/src/components/typography/Code/Code.tsx +74 -49
- package/src/components/typography/Heading/Heading.test.stories.tsx +8 -8
- package/src/components/typography/Paragraph/Paragraph.test.stories.tsx +5 -12
- package/src/components/typography/Text/Text.tsx +84 -77
- package/src/components/utility/AnimatedIcon/AnimatedIcon.md +4 -4
- package/src/components/utility/AnimatedIcon/AnimatedIcon.stories.tsx +19 -21
- package/src/components/utility/AnimatedIcon/AnimatedIcon.test.stories.tsx +19 -12
- package/src/components/utility/AspectRatio/AspectRatio.test.stories.tsx +9 -9
- package/src/components/utility/InfiniteScroll/InfiniteScroll.hooks.ts +118 -0
- package/src/components/utility/InfiniteScroll/InfiniteScroll.parts.tsx +54 -0
- package/src/components/utility/InfiniteScroll/InfiniteScroll.test.stories.tsx +12 -9
- package/src/components/utility/InfiniteScroll/InfiniteScroll.tsx +29 -148
- package/src/components/utility/InstallPrompt/InstallPrompt.helpers.ts +124 -0
- package/src/components/utility/InstallPrompt/InstallPrompt.md +113 -0
- package/src/components/utility/InstallPrompt/InstallPrompt.stories.tsx +118 -0
- package/src/components/utility/InstallPrompt/InstallPrompt.styles.ts +50 -0
- package/src/components/utility/InstallPrompt/InstallPrompt.test.stories.tsx +83 -0
- package/src/components/utility/InstallPrompt/InstallPrompt.tsx +192 -0
- package/src/components/utility/InstallPrompt/InstallPrompt.types.ts +78 -0
- package/src/components/utility/InstallPrompt/__tests__/InstallPrompt.ios.test.tsx +65 -0
- package/src/components/utility/InstallPrompt/__tests__/usePwaInstall.test.tsx +271 -0
- package/src/components/utility/InstallPrompt/index.ts +10 -0
- package/src/components/utility/InstallPrompt/usePwaInstall.ts +171 -0
- package/src/components/utility/Transition/Transition.helpers.ts +40 -0
- package/src/components/utility/Transition/Transition.tsx +17 -68
- package/src/components/utility/VirtualList/VirtualList.hooks.ts +319 -0
- package/src/components/utility/VirtualList/VirtualList.test.stories.tsx +49 -38
- package/src/components/utility/VirtualList/VirtualList.tsx +110 -315
- package/src/components/utility/WorkflowStep/WorkflowStep.helpers.ts +151 -0
- package/src/components/utility/WorkflowStep/WorkflowStep.parts.tsx +371 -0
- package/src/components/utility/WorkflowStep/WorkflowStep.stories.tsx +9 -11
- package/src/components/utility/WorkflowStep/WorkflowStep.test.stories.tsx +7 -7
- package/src/components/utility/WorkflowStep/WorkflowStep.tsx +51 -449
- package/src/components/utility/WorkflowStep/WorkflowStepRow.tsx +96 -0
- package/src/components/utility/index.ts +1 -0
- package/src/mui/Link.ts +2 -0
- package/src/utils/index.ts +2 -1
- package/src/utils/viewport.ts +65 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { render, screen, waitFor } from "@testing-library/react";
|
|
3
|
+
import { ThemeProvider, createTheme } from "../../../../mui/styles";
|
|
4
|
+
|
|
5
|
+
import { DataViewsTableBase } from "../DataViewsTableBase";
|
|
6
|
+
import type {
|
|
7
|
+
DataViewColumn,
|
|
8
|
+
DataViewPersistence,
|
|
9
|
+
DataViewRouter,
|
|
10
|
+
DataViewServer,
|
|
11
|
+
DataViewState,
|
|
12
|
+
FilterFieldConfig,
|
|
13
|
+
} from "../data-views-types";
|
|
14
|
+
|
|
15
|
+
interface Row extends Record<string, unknown> {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
status: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const rows: Row[] = [
|
|
22
|
+
{ id: "1", name: "Ana", status: "ACTIVE" },
|
|
23
|
+
{ id: "2", name: "Bruno", status: "INACTIVE" },
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
const columns: DataViewColumn<Row>[] = [
|
|
27
|
+
{ id: "name", header: "Nome", accessor: "name", searchable: true },
|
|
28
|
+
{ id: "status", header: "Status", accessor: "status", searchable: true },
|
|
29
|
+
{ id: "actions", header: "", type: "actions", hideable: false, cell: () => null },
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
const fields: FilterFieldConfig<Row>[] = [];
|
|
33
|
+
|
|
34
|
+
const persistence: DataViewPersistence = {
|
|
35
|
+
create: vi.fn(async () => ({ ok: true as const })),
|
|
36
|
+
update: vi.fn(async () => ({ ok: true as const })),
|
|
37
|
+
remove: vi.fn(async () => ({ ok: true as const })),
|
|
38
|
+
};
|
|
39
|
+
const router: DataViewRouter = { syncViewParam: vi.fn(), refresh: vi.fn() };
|
|
40
|
+
|
|
41
|
+
/** A server-mode wiring; `onQueryChange` is a no-op — we only assert the controls. */
|
|
42
|
+
const server: DataViewServer = { totalCount: 2, page: 1, pageSize: 20, onQueryChange: vi.fn() };
|
|
43
|
+
|
|
44
|
+
/** The URL-seeded controls a server page would parse off the address bar. */
|
|
45
|
+
function urlState(search: string): DataViewState {
|
|
46
|
+
return { search, pills: {}, ranges: {}, sortBy: [], visibleColumns: [] };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function renderBase(props: Partial<React.ComponentProps<typeof DataViewsTableBase<Row>>> = {}) {
|
|
50
|
+
return render(
|
|
51
|
+
<ThemeProvider theme={createTheme()}>
|
|
52
|
+
<DataViewsTableBase<Row>
|
|
53
|
+
persistence={persistence}
|
|
54
|
+
router={router}
|
|
55
|
+
rows={rows}
|
|
56
|
+
columns={columns}
|
|
57
|
+
fields={fields}
|
|
58
|
+
getRowId={(row) => row.id}
|
|
59
|
+
views={[]}
|
|
60
|
+
dataTestId="people"
|
|
61
|
+
testIdPrefix="people"
|
|
62
|
+
{...props}
|
|
63
|
+
/>
|
|
64
|
+
</ThemeProvider>,
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const searchInput = (): HTMLInputElement =>
|
|
69
|
+
screen.getByTestId("people-search-all") as HTMLInputElement;
|
|
70
|
+
|
|
71
|
+
describe("DataViewsTableBase — URL sync (FUT-180)", () => {
|
|
72
|
+
it("seeds the search box from initialState", () => {
|
|
73
|
+
renderBase({ server, initialState: urlState("maria") });
|
|
74
|
+
expect(searchInput().value).toBe("maria");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("re-applies the URL controls on a later initialState change (server mode: back/forward)", async () => {
|
|
78
|
+
// A new initialState reference is exactly what a browser back/forward produces:
|
|
79
|
+
// the server component re-renders with the restored URL's controls. In server
|
|
80
|
+
// mode the base forwards them as the grid's reactive `syncState`, so the
|
|
81
|
+
// controls reconcile instead of staying stuck on the previous query.
|
|
82
|
+
const { rerender } = renderBase({ server, initialState: urlState("maria") });
|
|
83
|
+
expect(searchInput().value).toBe("maria");
|
|
84
|
+
|
|
85
|
+
rerender(
|
|
86
|
+
<ThemeProvider theme={createTheme()}>
|
|
87
|
+
<DataViewsTableBase<Row>
|
|
88
|
+
persistence={persistence}
|
|
89
|
+
router={router}
|
|
90
|
+
rows={rows}
|
|
91
|
+
columns={columns}
|
|
92
|
+
fields={fields}
|
|
93
|
+
getRowId={(row) => row.id}
|
|
94
|
+
views={[]}
|
|
95
|
+
dataTestId="people"
|
|
96
|
+
testIdPrefix="people"
|
|
97
|
+
server={server}
|
|
98
|
+
initialState={urlState("ana")}
|
|
99
|
+
/>
|
|
100
|
+
</ThemeProvider>,
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
await waitFor(() => expect(searchInput().value).toBe("ana"));
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("does NOT reactively re-apply in client mode (no server): initialState only seeds on mount", () => {
|
|
107
|
+
// Client-mode lists don't keep their filters in the URL, so a changing
|
|
108
|
+
// initialState must not force the controls — only the mount seed applies.
|
|
109
|
+
// Without a `server` wiring the base forwards no `syncState`, so re-rendering
|
|
110
|
+
// with a new initialState leaves the seeded search untouched (a synchronous
|
|
111
|
+
// fact: no reconciling effect exists to fire).
|
|
112
|
+
const { rerender } = renderBase({ initialState: urlState("maria") });
|
|
113
|
+
expect(searchInput().value).toBe("maria");
|
|
114
|
+
|
|
115
|
+
rerender(
|
|
116
|
+
<ThemeProvider theme={createTheme()}>
|
|
117
|
+
<DataViewsTableBase<Row>
|
|
118
|
+
persistence={persistence}
|
|
119
|
+
router={router}
|
|
120
|
+
rows={rows}
|
|
121
|
+
columns={columns}
|
|
122
|
+
fields={fields}
|
|
123
|
+
getRowId={(row) => row.id}
|
|
124
|
+
views={[]}
|
|
125
|
+
dataTestId="people"
|
|
126
|
+
testIdPrefix="people"
|
|
127
|
+
initialState={urlState("ana")}
|
|
128
|
+
/>
|
|
129
|
+
</ThemeProvider>,
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
expect(searchInput().value).toBe("maria");
|
|
133
|
+
});
|
|
134
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { fireEvent, render, screen, waitFor, within } from "@testing-library/react";
|
|
3
|
+
import { ThemeProvider, createTheme } from "../../../../mui/styles";
|
|
4
|
+
|
|
5
|
+
import { SaveViewModal } from "../SaveViewModal";
|
|
6
|
+
import type { DataViewColumn, DataViewState, FilterFieldConfig } from "../data-views-types";
|
|
7
|
+
|
|
8
|
+
interface Row extends Record<string, unknown> {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
status: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const columns: DataViewColumn<Row>[] = [
|
|
15
|
+
{ id: "name", header: "Nome" },
|
|
16
|
+
{ id: "status", header: "Status" },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const fields: FilterFieldConfig<Row>[] = [
|
|
20
|
+
{ id: "status", label: "Status", options: [{ value: "ACTIVE", label: "Ativo" }] },
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
const currentState: DataViewState = {
|
|
24
|
+
search: "",
|
|
25
|
+
pills: { status: ["ACTIVE"] },
|
|
26
|
+
sortBy: [],
|
|
27
|
+
visibleColumns: ["name", "status"],
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function renderModal(onSave = vi.fn()) {
|
|
31
|
+
render(
|
|
32
|
+
<ThemeProvider theme={createTheme()}>
|
|
33
|
+
<SaveViewModal<Row>
|
|
34
|
+
open
|
|
35
|
+
onClose={vi.fn()}
|
|
36
|
+
currentState={currentState}
|
|
37
|
+
fields={fields}
|
|
38
|
+
columns={columns}
|
|
39
|
+
onSave={onSave}
|
|
40
|
+
testIdPrefix="views"
|
|
41
|
+
/>
|
|
42
|
+
</ThemeProvider>,
|
|
43
|
+
);
|
|
44
|
+
return onSave;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
describe("SaveViewModal", () => {
|
|
48
|
+
it("previews the current filters and columns", () => {
|
|
49
|
+
renderModal();
|
|
50
|
+
const filters = screen.getByTestId("views-preview-filters");
|
|
51
|
+
expect(within(filters).getByText("Status: Ativo")).toBeInTheDocument();
|
|
52
|
+
const cols = screen.getByTestId("views-preview-columns");
|
|
53
|
+
expect(within(cols).getByText("Nome")).toBeInTheDocument();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("requires a name before saving", () => {
|
|
57
|
+
renderModal();
|
|
58
|
+
expect(screen.getByTestId("views-save-submit")).toBeDisabled();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("saves the entered name + share toggle", () => {
|
|
62
|
+
const onSave = renderModal();
|
|
63
|
+
fireEvent.change(screen.getByTestId("views-save-name"), { target: { value: "Baixo estoque" } });
|
|
64
|
+
fireEvent.click(screen.getByTestId("views-save-shared")); // the switch input carries the testid
|
|
65
|
+
fireEvent.click(screen.getByTestId("views-save-submit"));
|
|
66
|
+
expect(onSave).toHaveBeenCalledWith(
|
|
67
|
+
expect.objectContaining({ name: "Baixo estoque", shared: true, pinned: false, isDefault: false }),
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("surfaces the error and keeps the modal open when the save is rejected", async () => {
|
|
72
|
+
const onSave = vi.fn().mockRejectedValue(new Error("Já existe uma visão com esse nome."));
|
|
73
|
+
renderModal(onSave);
|
|
74
|
+
fireEvent.change(screen.getByTestId("views-save-name"), { target: { value: "Duplicada" } });
|
|
75
|
+
fireEvent.click(screen.getByTestId("views-save-submit"));
|
|
76
|
+
|
|
77
|
+
await waitFor(() =>
|
|
78
|
+
expect(screen.getByTestId("views-save-error")).toHaveTextContent(/já existe uma visão/i),
|
|
79
|
+
);
|
|
80
|
+
// Still open + the button re-enabled for a retry.
|
|
81
|
+
expect(screen.getByTestId("views-save-submit")).toBeEnabled();
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { filterRows } from "../data-views-filter";
|
|
4
|
+
import type {
|
|
5
|
+
DataViewColumn,
|
|
6
|
+
FilterFieldConfig,
|
|
7
|
+
RangeFieldConfig,
|
|
8
|
+
} from "../data-views-types";
|
|
9
|
+
|
|
10
|
+
interface Row extends Record<string, unknown> {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
status: string;
|
|
14
|
+
tags: string[];
|
|
15
|
+
price: number;
|
|
16
|
+
stock: number | null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const rows: Row[] = [
|
|
20
|
+
{ id: "1", name: "Ana", status: "ACTIVE", tags: ["vip"], price: 10, stock: 5 },
|
|
21
|
+
{ id: "2", name: "Bruno", status: "INACTIVE", tags: ["new"], price: 20, stock: 0 },
|
|
22
|
+
{ id: "3", name: "Carla", status: "ACTIVE", tags: ["vip", "new"], price: 30, stock: null },
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const rangeFields: RangeFieldConfig<Row>[] = [
|
|
26
|
+
{ id: "price", label: "Preço", accessor: (row) => row.price },
|
|
27
|
+
{ id: "stock", label: "Estoque", accessor: (row) => row.stock },
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
const columns: DataViewColumn<Row>[] = [
|
|
31
|
+
{ id: "name", header: "Nome", accessor: "name", searchable: true },
|
|
32
|
+
{ id: "status", header: "Status", accessor: "status" },
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
const fields: FilterFieldConfig<Row>[] = [
|
|
36
|
+
{ id: "status", label: "Status", options: [
|
|
37
|
+
{ value: "ACTIVE", label: "Ativo" },
|
|
38
|
+
{ value: "INACTIVE", label: "Inativo" },
|
|
39
|
+
] },
|
|
40
|
+
{ id: "tags", label: "Tags", accessor: (row) => row.tags, options: [
|
|
41
|
+
{ value: "vip", label: "VIP" },
|
|
42
|
+
{ value: "new", label: "Novo" },
|
|
43
|
+
] },
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
const ids = (result: Row[]): string[] => result.map((r) => r.id);
|
|
47
|
+
|
|
48
|
+
describe("filterRows", () => {
|
|
49
|
+
it("returns every row with no search or pills", () => {
|
|
50
|
+
expect(ids(filterRows(rows, columns, fields, { search: "", pills: {} }))).toEqual(["1", "2", "3"]);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("matches the search term across searchable columns only", () => {
|
|
54
|
+
expect(ids(filterRows(rows, columns, fields, { search: "car", pills: {} }))).toEqual(["3"]);
|
|
55
|
+
// status is not searchable, so a status term matches nothing by search.
|
|
56
|
+
expect(filterRows(rows, columns, fields, { search: "active", pills: {} })).toHaveLength(0);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("narrows by a single-value pill", () => {
|
|
60
|
+
expect(ids(filterRows(rows, columns, fields, { search: "", pills: { status: ["ACTIVE"] } }))).toEqual(["1", "3"]);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("treats a multi-value field via its accessor as OR membership", () => {
|
|
64
|
+
expect(ids(filterRows(rows, columns, fields, { search: "", pills: { tags: ["new"] } }))).toEqual(["2", "3"]);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("combines search AND pills", () => {
|
|
68
|
+
const result = filterRows(rows, columns, fields, { search: "a", pills: { status: ["ACTIVE"] } });
|
|
69
|
+
// "a" matches Ana + Carla; ACTIVE keeps both.
|
|
70
|
+
expect(ids(result)).toEqual(["1", "3"]);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("ignores a pill with an empty selection", () => {
|
|
74
|
+
expect(ids(filterRows(rows, columns, fields, { search: "", pills: { status: [] } }))).toEqual(["1", "2", "3"]);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe("numeric ranges", () => {
|
|
78
|
+
const crit = (ranges: Record<string, { min?: number; max?: number }>) => ({
|
|
79
|
+
search: "",
|
|
80
|
+
pills: {},
|
|
81
|
+
ranges,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("filters by a minimum bound", () => {
|
|
85
|
+
expect(ids(filterRows(rows, columns, fields, crit({ price: { min: 20 } }), rangeFields))).toEqual(["2", "3"]);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("filters by a maximum bound", () => {
|
|
89
|
+
expect(ids(filterRows(rows, columns, fields, crit({ price: { max: 20 } }), rangeFields))).toEqual(["1", "2"]);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("filters by an inclusive min+max window", () => {
|
|
93
|
+
expect(ids(filterRows(rows, columns, fields, crit({ price: { min: 10, max: 20 } }), rangeFields))).toEqual(["1", "2"]);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("excludes rows whose value is null when a bound is set", () => {
|
|
97
|
+
// Carla (id 3) has null stock, so any bounded stock range drops her.
|
|
98
|
+
expect(ids(filterRows(rows, columns, fields, crit({ stock: { min: 0 } }), rangeFields))).toEqual(["1", "2"]);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("ignores an empty range (no bounds)", () => {
|
|
102
|
+
expect(ids(filterRows(rows, columns, fields, crit({ price: {} }), rangeFields))).toEqual(["1", "2", "3"]);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("ignores an inverted range (max < min) instead of filtering everything out", () => {
|
|
106
|
+
expect(ids(filterRows(rows, columns, fields, crit({ price: { min: 30, max: 10 } }), rangeFields))).toEqual(["1", "2", "3"]);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("combines ranges with pills", () => {
|
|
110
|
+
const result = filterRows(rows, columns, fields, { search: "", pills: { status: ["ACTIVE"] }, ranges: { price: { min: 25 } } }, rangeFields);
|
|
111
|
+
// ACTIVE → Ana(10), Carla(30); price ≥ 25 → only Carla.
|
|
112
|
+
expect(ids(result)).toEqual(["3"]);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { describeViewState } from "../data-views-preview";
|
|
4
|
+
import type { DataViewColumn, DataViewState, FilterFieldConfig } from "../data-views-types";
|
|
5
|
+
|
|
6
|
+
interface Row extends Record<string, unknown> {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
status: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const columns: DataViewColumn<Row>[] = [
|
|
13
|
+
{ id: "name", header: "Nome" },
|
|
14
|
+
{ id: "status", header: "Status" },
|
|
15
|
+
{ id: "actions", header: "", hideable: false },
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
const fields: FilterFieldConfig<Row>[] = [
|
|
19
|
+
{ id: "status", label: "Status", options: [{ value: "ACTIVE", label: "Ativo" }] },
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
describe("describeViewState", () => {
|
|
23
|
+
it("summarizes search, pills, visible columns, and sort with labels", () => {
|
|
24
|
+
const state: DataViewState = {
|
|
25
|
+
search: "burg",
|
|
26
|
+
pills: { status: ["ACTIVE"] },
|
|
27
|
+
sortBy: [{ id: "name", dir: "asc" }],
|
|
28
|
+
visibleColumns: ["name", "status"],
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const result = describeViewState(state, fields, columns);
|
|
32
|
+
|
|
33
|
+
expect(result.filters).toEqual(['Busca: "burg"', "Status: Ativo"]);
|
|
34
|
+
expect(result.columns).toEqual(["Nome", "Status"]);
|
|
35
|
+
expect(result.sort).toEqual(["Nome (crescente)"]);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("returns empty sections for a pristine state", () => {
|
|
39
|
+
const state: DataViewState = { search: "", pills: {}, sortBy: [], visibleColumns: [] };
|
|
40
|
+
const result = describeViewState(state, fields, columns);
|
|
41
|
+
expect(result).toEqual({ filters: [], columns: [], sort: [] });
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("omits the actions column (non-hideable) from the columns summary", () => {
|
|
45
|
+
const state: DataViewState = {
|
|
46
|
+
search: "",
|
|
47
|
+
pills: {},
|
|
48
|
+
sortBy: [],
|
|
49
|
+
visibleColumns: ["name", "actions"],
|
|
50
|
+
};
|
|
51
|
+
expect(describeViewState(state, fields, columns).columns).toEqual(["Nome"]);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,136 @@
|
|
|
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
|
+
};
|