@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Box } from '@mui/material';
|
|
2
2
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
-
import { expect, fn,userEvent, waitFor, within } from 'storybook/test';
|
|
4
|
+
import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
|
|
5
5
|
|
|
6
6
|
import { Stepper } from './Stepper';
|
|
7
7
|
import type { Step } from './Stepper.types';
|
|
@@ -135,8 +135,8 @@ export const KeyboardNavigation: Story = {
|
|
|
135
135
|
const firstStepButton = canvas.getByLabelText(/Step 1.*Personal Info/);
|
|
136
136
|
|
|
137
137
|
// Focus the first step button
|
|
138
|
-
|
|
139
|
-
await expect(firstStepButton).toHaveFocus();
|
|
138
|
+
await userEvent.click(firstStepButton);
|
|
139
|
+
await waitFor(() => expect(firstStepButton).toHaveFocus());
|
|
140
140
|
|
|
141
141
|
// Press Enter to activate
|
|
142
142
|
await userEvent.keyboard('{Enter}');
|
|
@@ -146,17 +146,17 @@ export const KeyboardNavigation: Story = {
|
|
|
146
146
|
|
|
147
147
|
// Test Space key
|
|
148
148
|
const thirdStepButton = canvas.getByLabelText(/Step 3.*Payment/);
|
|
149
|
-
|
|
149
|
+
await userEvent.click(thirdStepButton);
|
|
150
150
|
await userEvent.keyboard(' ');
|
|
151
151
|
await waitFor(() => {
|
|
152
152
|
expect(args.onStepChange).toHaveBeenCalledWith('step3');
|
|
153
153
|
});
|
|
154
154
|
|
|
155
155
|
// Test Tab navigation
|
|
156
|
-
|
|
156
|
+
await userEvent.click(firstStepButton);
|
|
157
157
|
await userEvent.tab();
|
|
158
158
|
const nextButton = canvas.getByLabelText(/Step 2.*Address/);
|
|
159
|
-
await expect(nextButton).toHaveFocus();
|
|
159
|
+
await waitFor(() => expect(nextButton).toHaveFocus());
|
|
160
160
|
},
|
|
161
161
|
};
|
|
162
162
|
|
|
@@ -233,23 +233,23 @@ export const FocusManagement: Story = {
|
|
|
233
233
|
const firstStepButton = canvas.getByLabelText(/Step 1.*Personal Info/);
|
|
234
234
|
|
|
235
235
|
// Focus external element first
|
|
236
|
-
|
|
237
|
-
await expect(externalButton).toHaveFocus();
|
|
236
|
+
await userEvent.click(externalButton);
|
|
237
|
+
await waitFor(() => expect(externalButton).toHaveFocus());
|
|
238
238
|
|
|
239
239
|
// Tab to first step
|
|
240
240
|
await userEvent.tab();
|
|
241
|
-
await expect(firstStepButton).toHaveFocus();
|
|
241
|
+
await waitFor(() => expect(firstStepButton).toHaveFocus());
|
|
242
242
|
|
|
243
243
|
// Click step and verify focus remains
|
|
244
244
|
await userEvent.click(firstStepButton);
|
|
245
|
-
await expect(firstStepButton).toHaveFocus();
|
|
245
|
+
await waitFor(() => expect(firstStepButton).toHaveFocus());
|
|
246
246
|
|
|
247
247
|
// Test that disabled steps don't receive focus
|
|
248
248
|
const steps = canvas.getAllByRole('button');
|
|
249
249
|
for (const step of steps) {
|
|
250
250
|
if (!step.hasAttribute('disabled')) {
|
|
251
|
-
|
|
252
|
-
await expect(step).toHaveFocus();
|
|
251
|
+
await userEvent.click(step);
|
|
252
|
+
await waitFor(() => expect(step).toHaveFocus());
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
},
|
|
@@ -390,7 +390,6 @@ export const Performance: Story = {
|
|
|
390
390
|
},
|
|
391
391
|
play: async ({ args, canvasElement }) => {
|
|
392
392
|
const canvas = within(canvasElement);
|
|
393
|
-
const startTime = Date.now();
|
|
394
393
|
|
|
395
394
|
// Verify all 10 steps render
|
|
396
395
|
const stepButtons = canvas.getAllByRole('button');
|
|
@@ -405,12 +404,6 @@ export const Performance: Story = {
|
|
|
405
404
|
await userEvent.click(step3Button);
|
|
406
405
|
await userEvent.click(step7Button);
|
|
407
406
|
|
|
408
|
-
const endTime = Date.now();
|
|
409
|
-
const renderTime = endTime - startTime;
|
|
410
|
-
|
|
411
|
-
// Verify interactions completed quickly (less than 1000ms)
|
|
412
|
-
expect(renderTime).toBeLessThan(1000);
|
|
413
|
-
|
|
414
407
|
// Verify callback was called for all clicks
|
|
415
408
|
await waitFor(() => {
|
|
416
409
|
expect(args.onStepChange).toHaveBeenCalledTimes(3);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { TableProps } from './Table.types';
|
|
2
|
+
|
|
3
|
+
export const TABLE_DEFAULTS: Partial<TableProps> = {
|
|
4
|
+
variant: 'default',
|
|
5
|
+
stripeColor: 'neutral',
|
|
6
|
+
glow: false,
|
|
7
|
+
pulse: false,
|
|
8
|
+
hoverable: false,
|
|
9
|
+
loading: false,
|
|
10
|
+
density: 'normal',
|
|
11
|
+
stickyHeader: false,
|
|
12
|
+
selectable: false,
|
|
13
|
+
selectedRows: [],
|
|
14
|
+
sortable: false,
|
|
15
|
+
virtualScrolling: false,
|
|
16
|
+
rowHeight: 52,
|
|
17
|
+
overscan: 5,
|
|
18
|
+
responsive: false,
|
|
19
|
+
showColumnToggle: true,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// Strips explicitly-undefined props before the merge, so `prop={undefined}` still
|
|
23
|
+
// falls back to the default as a destructuring default would. Eighteen separate
|
|
24
|
+
// destructuring defaults were most of this component's branch count.
|
|
25
|
+
export const definedProps = (props: TableProps): Partial<TableProps> =>
|
|
26
|
+
Object.fromEntries(
|
|
27
|
+
Object.entries(props).filter(([, value]) => value !== undefined),
|
|
28
|
+
) as Partial<TableProps>;
|
|
29
|
+
|
|
30
|
+
// The container + styled table + optional header, shared by the loading, empty
|
|
31
|
+
// and populated renders.
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { useMediaQuery, useTheme } from '@mui/material';
|
|
2
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
3
|
+
|
|
4
|
+
import type { ColumnConfig, TableProps } from './Table.types';
|
|
5
|
+
|
|
6
|
+
export const useVirtualScrolling = (
|
|
7
|
+
data: Record<string, unknown>[],
|
|
8
|
+
rowHeight: number,
|
|
9
|
+
containerHeight: number,
|
|
10
|
+
overscan: number = 5
|
|
11
|
+
) => {
|
|
12
|
+
const [scrollTop, setScrollTop] = useState(0);
|
|
13
|
+
|
|
14
|
+
const visibleItems = useMemo(() => {
|
|
15
|
+
const visibleHeight = containerHeight;
|
|
16
|
+
const startIndex = Math.floor(scrollTop / rowHeight);
|
|
17
|
+
const endIndex = Math.min(
|
|
18
|
+
data.length,
|
|
19
|
+
Math.ceil((scrollTop + visibleHeight) / rowHeight)
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const start = Math.max(0, startIndex - overscan);
|
|
23
|
+
const end = Math.min(data.length, endIndex + overscan);
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
startIndex: start,
|
|
27
|
+
endIndex: end,
|
|
28
|
+
items: data.slice(start, end),
|
|
29
|
+
totalHeight: data.length * rowHeight,
|
|
30
|
+
offsetY: start * rowHeight,
|
|
31
|
+
};
|
|
32
|
+
}, [data, rowHeight, containerHeight, scrollTop, overscan]);
|
|
33
|
+
|
|
34
|
+
const handleScroll = useCallback((e: React.UIEvent<HTMLDivElement>) => {
|
|
35
|
+
setScrollTop(e.currentTarget.scrollTop);
|
|
36
|
+
}, []);
|
|
37
|
+
|
|
38
|
+
return { visibleItems, handleScroll };
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// Responsive Hook
|
|
42
|
+
|
|
43
|
+
const useResponsive = (
|
|
44
|
+
columns: ColumnConfig[],
|
|
45
|
+
columnPriorities?: number[]
|
|
46
|
+
) => {
|
|
47
|
+
const theme = useTheme();
|
|
48
|
+
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
49
|
+
const isTablet = useMediaQuery(theme.breakpoints.down('lg'));
|
|
50
|
+
|
|
51
|
+
const [hiddenColumns, setHiddenColumns] = useState<number[]>([]);
|
|
52
|
+
const [columnMenuAnchor, setColumnMenuAnchor] = useState<null | HTMLElement>(null);
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (!columnPriorities) return;
|
|
56
|
+
|
|
57
|
+
let columnsToHide: number[] = [];
|
|
58
|
+
|
|
59
|
+
if (isMobile) {
|
|
60
|
+
// Hide lowest priority columns on mobile
|
|
61
|
+
columnsToHide = columnPriorities
|
|
62
|
+
.map((priority, index) => ({ priority, index }))
|
|
63
|
+
.sort((a, b) => b.priority - a.priority)
|
|
64
|
+
.slice(0, Math.floor(columns.length / 2))
|
|
65
|
+
.map(item => item.index);
|
|
66
|
+
} else if (isTablet) {
|
|
67
|
+
// Hide some columns on tablet
|
|
68
|
+
columnsToHide = columnPriorities
|
|
69
|
+
.map((priority, index) => ({ priority, index }))
|
|
70
|
+
.sort((a, b) => b.priority - a.priority)
|
|
71
|
+
.slice(0, Math.floor(columns.length / 3))
|
|
72
|
+
.map(item => item.index);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
setHiddenColumns(columnsToHide);
|
|
76
|
+
}, [isMobile, isTablet, columnPriorities, columns.length]);
|
|
77
|
+
|
|
78
|
+
const visibleColumns = columns.filter((_, index) => !hiddenColumns.includes(index));
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
visibleColumns,
|
|
82
|
+
hiddenColumns,
|
|
83
|
+
isMobile,
|
|
84
|
+
columnMenuAnchor,
|
|
85
|
+
setColumnMenuAnchor,
|
|
86
|
+
setHiddenColumns,
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// Enhanced Table Header Component
|
|
91
|
+
// Visible/hidden column split for responsive mode, plus row selection.
|
|
92
|
+
export const useTableSelection = ({
|
|
93
|
+
columns,
|
|
94
|
+
data,
|
|
95
|
+
responsive,
|
|
96
|
+
columnPriorities,
|
|
97
|
+
selectedRows,
|
|
98
|
+
rowKeyExtractor,
|
|
99
|
+
onSelectionChange,
|
|
100
|
+
}: {
|
|
101
|
+
columns?: ColumnConfig[];
|
|
102
|
+
data: TableProps['data'];
|
|
103
|
+
responsive?: boolean;
|
|
104
|
+
columnPriorities?: number[];
|
|
105
|
+
selectedRows: (string | number)[];
|
|
106
|
+
rowKeyExtractor?: (row: Record<string, unknown>, index: number) => string | number;
|
|
107
|
+
onSelectionChange?: TableProps['onSelectionChange'];
|
|
108
|
+
}) => {
|
|
109
|
+
|
|
110
|
+
// Use responsive hook if responsive mode is enabled
|
|
111
|
+
const {
|
|
112
|
+
visibleColumns,
|
|
113
|
+
hiddenColumns,
|
|
114
|
+
isMobile,
|
|
115
|
+
columnMenuAnchor,
|
|
116
|
+
setColumnMenuAnchor,
|
|
117
|
+
setHiddenColumns,
|
|
118
|
+
} = useResponsive(
|
|
119
|
+
columns || [],
|
|
120
|
+
responsive ? columnPriorities : undefined
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
// Handle selection changes
|
|
124
|
+
const handleSelectionChange = useCallback((rowKey: string | number, selected: boolean) => {
|
|
125
|
+
if (!onSelectionChange) return;
|
|
126
|
+
|
|
127
|
+
let newSelection: (string | number)[];
|
|
128
|
+
if (selected) {
|
|
129
|
+
newSelection = [...selectedRows, rowKey];
|
|
130
|
+
} else {
|
|
131
|
+
newSelection = selectedRows.filter(key => key !== rowKey);
|
|
132
|
+
}
|
|
133
|
+
onSelectionChange(newSelection);
|
|
134
|
+
}, [selectedRows, onSelectionChange]);
|
|
135
|
+
|
|
136
|
+
const handleSelectAll = useCallback((selected: boolean) => {
|
|
137
|
+
if (!onSelectionChange || !data) return;
|
|
138
|
+
|
|
139
|
+
if (selected) {
|
|
140
|
+
const allKeys = data.map((rowData, index) =>
|
|
141
|
+
rowKeyExtractor ? rowKeyExtractor(rowData, index) : (rowData.id as string | number) || index
|
|
142
|
+
);
|
|
143
|
+
onSelectionChange(allKeys);
|
|
144
|
+
} else {
|
|
145
|
+
onSelectionChange([]);
|
|
146
|
+
}
|
|
147
|
+
}, [data, onSelectionChange, rowKeyExtractor]);
|
|
148
|
+
|
|
149
|
+
// Loading state
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
visibleColumns,
|
|
153
|
+
hiddenColumns,
|
|
154
|
+
isMobile,
|
|
155
|
+
columnMenuAnchor,
|
|
156
|
+
setColumnMenuAnchor,
|
|
157
|
+
setHiddenColumns,
|
|
158
|
+
handleSelectionChange,
|
|
159
|
+
handleSelectAll,
|
|
160
|
+
};
|
|
161
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DeleteIcon from '@mui/icons-material/Delete';
|
|
2
|
+
import EditIcon from '@mui/icons-material/Edit';
|
|
3
|
+
import StarIcon from '@mui/icons-material/Star';
|
|
2
4
|
import {
|
|
3
5
|
Avatar,
|
|
4
6
|
Box,
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { alpha, keyframes } from '@mui/material';
|
|
2
|
+
import type { CSSObject, Theme } from '@mui/material/styles';
|
|
3
|
+
|
|
4
|
+
import type { TableDensity, TableStripeColor } from './Table.types';
|
|
5
|
+
|
|
6
|
+
const pulseAnimation = keyframes`
|
|
7
|
+
0% {
|
|
8
|
+
box-shadow: 0 0 0 0 currentColor;
|
|
9
|
+
opacity: 1;
|
|
10
|
+
}
|
|
11
|
+
70% {
|
|
12
|
+
box-shadow: 0 0 0 10px currentColor;
|
|
13
|
+
opacity: 0;
|
|
14
|
+
}
|
|
15
|
+
100% {
|
|
16
|
+
box-shadow: 0 0 0 0 currentColor;
|
|
17
|
+
opacity: 0;
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
// Density configurations
|
|
22
|
+
const getDensityConfig = (density: TableDensity = 'normal') => {
|
|
23
|
+
const configs = {
|
|
24
|
+
compact: {
|
|
25
|
+
rowHeight: 36,
|
|
26
|
+
cellPadding: '6px 12px',
|
|
27
|
+
fontSize: '0.8125rem',
|
|
28
|
+
headerPadding: '8px 12px' },
|
|
29
|
+
normal: {
|
|
30
|
+
rowHeight: 52,
|
|
31
|
+
cellPadding: '12px 16px',
|
|
32
|
+
fontSize: '0.875rem',
|
|
33
|
+
headerPadding: '16px 16px' },
|
|
34
|
+
comfortable: {
|
|
35
|
+
rowHeight: 68,
|
|
36
|
+
cellPadding: '18px 24px',
|
|
37
|
+
fontSize: '0.875rem',
|
|
38
|
+
headerPadding: '20px 24px' } };
|
|
39
|
+
return configs[density];
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const getStripeColorFromTheme = (theme: { palette: { primary: { main: string }; secondary: { main: string }; info: { main: string }; success: { main: string }; warning: { main: string }; error: { main: string }; action: { hover: string } } }, stripeColor: TableStripeColor = 'neutral') => {
|
|
43
|
+
const colorMap: Record<TableStripeColor, string> = {
|
|
44
|
+
primary: theme.palette.primary.main,
|
|
45
|
+
secondary: theme.palette.secondary.main,
|
|
46
|
+
info: theme.palette.info.main,
|
|
47
|
+
success: theme.palette.success.main,
|
|
48
|
+
warning: theme.palette.warning.main,
|
|
49
|
+
error: theme.palette.error.main,
|
|
50
|
+
neutral: theme.palette.action.hover };
|
|
51
|
+
return colorMap[stripeColor];
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// One variant applies at a time, so a lookup replaces the mutually exclusive
|
|
55
|
+
// spreads.
|
|
56
|
+
const TABLE_VARIANTS: Record<string, (args: VariantArgs) => CSSObject> = {
|
|
57
|
+
default: ({ theme }) => ({
|
|
58
|
+
backgroundColor: theme.palette.background.paper,
|
|
59
|
+
'& .MuiTableHead-root': {
|
|
60
|
+
backgroundColor: alpha(theme.palette.primary.main, 0.1) } }),
|
|
61
|
+
striped: ({ theme, stripeColor }) => ({
|
|
62
|
+
backgroundColor: theme.palette.background.paper,
|
|
63
|
+
'& .MuiTableBody-root .MuiTableRow-root:nth-of-type(even)': {
|
|
64
|
+
backgroundColor: alpha(getStripeColorFromTheme(theme, stripeColor), stripeColor === 'neutral' ? 0.5 : 0.15) } }),
|
|
65
|
+
glass: ({ theme }) => ({
|
|
66
|
+
backgroundColor: alpha(theme.palette.background.paper, 0.1),
|
|
67
|
+
backdropFilter: 'blur(20px)',
|
|
68
|
+
border: `1px solid ${alpha(theme.palette.divider, 0.2)}` }),
|
|
69
|
+
minimal: ({ theme }) => ({
|
|
70
|
+
backgroundColor: 'transparent',
|
|
71
|
+
'& .MuiTableCell-root': {
|
|
72
|
+
borderBottom: `1px solid ${alpha(theme.palette.divider, 0.1)}` } }),
|
|
73
|
+
gradient: ({ theme }) => ({
|
|
74
|
+
background: `linear-gradient(135deg, ${alpha(theme.palette.primary.main, 0.05)}, ${alpha(theme.palette.secondary.main, 0.05)})`,
|
|
75
|
+
border: `1px solid ${alpha(theme.palette.divider, 0.2)}`,
|
|
76
|
+
'& .MuiTableHead-root': {
|
|
77
|
+
background: `linear-gradient(135deg, ${alpha(theme.palette.primary.main, 0.15)}, ${alpha(theme.palette.secondary.main, 0.15)})` },
|
|
78
|
+
'& .MuiTableCell-root': {
|
|
79
|
+
borderBottom: `1px solid ${alpha(theme.palette.divider, 0.15)}` } }) };
|
|
80
|
+
|
|
81
|
+
type VariantArgs = {
|
|
82
|
+
theme: Theme;
|
|
83
|
+
densityConfig: ReturnType<typeof getDensityConfig>;
|
|
84
|
+
stripeColor?: TableStripeColor;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const tableVariantStyles = (args: VariantArgs, customVariant?: string): CSSObject =>
|
|
88
|
+
customVariant ? (TABLE_VARIANTS[customVariant]?.(args) ?? {}) : {};
|
|
89
|
+
|
|
90
|
+
// Sticky headers and row hover are independent of the variant.
|
|
91
|
+
const stickyHeaderStyles = (
|
|
92
|
+
theme: Theme,
|
|
93
|
+
densityConfig: ReturnType<typeof getDensityConfig>,
|
|
94
|
+
): CSSObject => ({
|
|
95
|
+
'& .MuiTableHead-root': {
|
|
96
|
+
position: 'sticky',
|
|
97
|
+
top: 0,
|
|
98
|
+
zIndex: 100,
|
|
99
|
+
backgroundColor: theme.palette.background.paper,
|
|
100
|
+
'& .MuiTableCell-root': {
|
|
101
|
+
borderBottom: `2px solid ${theme.palette.divider}`,
|
|
102
|
+
fontWeight: 600,
|
|
103
|
+
padding: densityConfig.headerPadding } } });
|
|
104
|
+
|
|
105
|
+
const hoverableRowStyles = (theme: Theme): CSSObject => ({
|
|
106
|
+
'& .MuiTableBody-root .MuiTableRow-root:hover': {
|
|
107
|
+
backgroundColor: alpha(theme.palette.primary.main, 0.08),
|
|
108
|
+
cursor: 'pointer',
|
|
109
|
+
transition: 'background-color 0.15s ease-in-out' } });
|
|
110
|
+
|
|
111
|
+
// glow and pulse combine into three distinct looks, spelled out rather than
|
|
112
|
+
// layered — the glow-only shadow differs from the one used when both are on.
|
|
113
|
+
const emphasisStyles = (theme: Theme, glow?: boolean, pulse?: boolean): CSSObject => {
|
|
114
|
+
if (glow && pulse) return ({
|
|
115
|
+
position: 'relative',
|
|
116
|
+
boxShadow: `0 0 20px 5px ${alpha(theme.palette.primary.main, 0.3)} !important`,
|
|
117
|
+
filter: 'brightness(1.05)',
|
|
118
|
+
'&::after': {
|
|
119
|
+
content: '""',
|
|
120
|
+
position: 'absolute',
|
|
121
|
+
top: 0,
|
|
122
|
+
left: 0,
|
|
123
|
+
right: 0,
|
|
124
|
+
bottom: 0,
|
|
125
|
+
borderRadius: 'inherit',
|
|
126
|
+
backgroundColor: theme.palette.primary.main,
|
|
127
|
+
opacity: 0.1,
|
|
128
|
+
animation: `${pulseAnimation} 2s infinite`,
|
|
129
|
+
pointerEvents: 'none',
|
|
130
|
+
zIndex: -1 } });
|
|
131
|
+
if (glow) return ({
|
|
132
|
+
boxShadow: `0 0 20px 5px ${alpha(theme.palette.primary.main, 0.3)} !important`,
|
|
133
|
+
filter: 'brightness(1.05)' });
|
|
134
|
+
if (pulse) return ({
|
|
135
|
+
position: 'relative',
|
|
136
|
+
'&::after': {
|
|
137
|
+
content: '""',
|
|
138
|
+
position: 'absolute',
|
|
139
|
+
top: 0,
|
|
140
|
+
left: 0,
|
|
141
|
+
right: 0,
|
|
142
|
+
bottom: 0,
|
|
143
|
+
borderRadius: 'inherit',
|
|
144
|
+
backgroundColor: theme.palette.primary.main,
|
|
145
|
+
opacity: 0.1,
|
|
146
|
+
animation: `${pulseAnimation} 2s infinite`,
|
|
147
|
+
pointerEvents: 'none',
|
|
148
|
+
zIndex: -1 } });
|
|
149
|
+
|
|
150
|
+
return {};
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// The table's own styling, lifted out so the styled() callback just forwards
|
|
154
|
+
// its props.
|
|
155
|
+
export const tableStyles = ({
|
|
156
|
+
theme,
|
|
157
|
+
customVariant,
|
|
158
|
+
glow,
|
|
159
|
+
pulse,
|
|
160
|
+
hoverable,
|
|
161
|
+
density,
|
|
162
|
+
stickyHeader,
|
|
163
|
+
stripeColor = 'neutral' }: {
|
|
164
|
+
theme: Theme;
|
|
165
|
+
customVariant?: string;
|
|
166
|
+
glow?: boolean;
|
|
167
|
+
pulse?: boolean;
|
|
168
|
+
hoverable?: boolean;
|
|
169
|
+
density?: TableDensity;
|
|
170
|
+
stickyHeader?: boolean;
|
|
171
|
+
stripeColor?: TableStripeColor;
|
|
172
|
+
}): CSSObject => {
|
|
173
|
+
const densityConfig = getDensityConfig(density);
|
|
174
|
+
|
|
175
|
+
return {
|
|
176
|
+
borderRadius: theme.spacing(1),
|
|
177
|
+
overflow: 'hidden',
|
|
178
|
+
transition: 'all 0.3s ease',
|
|
179
|
+
position: 'relative',
|
|
180
|
+
|
|
181
|
+
// Density styles
|
|
182
|
+
'& .MuiTableCell-root': {
|
|
183
|
+
padding: densityConfig.cellPadding,
|
|
184
|
+
fontSize: densityConfig.fontSize,
|
|
185
|
+
height: densityConfig.rowHeight },
|
|
186
|
+
|
|
187
|
+
// Sticky header
|
|
188
|
+
...tableVariantStyles({ theme, densityConfig, stripeColor }, customVariant),
|
|
189
|
+
...(stickyHeader ? stickyHeaderStyles(theme, densityConfig) : {}),
|
|
190
|
+
...(hoverable ? hoverableRowStyles(theme) : {}),
|
|
191
|
+
...emphasisStyles(theme, glow, pulse),
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
// Variant styles
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
// Hoverable rows
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
// Selection styles
|
|
209
|
+
'& .MuiTableRow-root.selected': {
|
|
210
|
+
backgroundColor: alpha(theme.palette.primary.main, 0.12),
|
|
211
|
+
'&:hover': {
|
|
212
|
+
backgroundColor: alpha(theme.palette.primary.main, 0.16) } },
|
|
213
|
+
|
|
214
|
+
// Glow effect
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
// Pulse animation
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
// Both glow and pulse
|
|
221
|
+
|
|
222
|
+
};
|
|
223
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Box, Typography } from '@mui/material';
|
|
2
2
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
-
import { expect, userEvent, waitFor,within } from 'storybook/test';
|
|
4
|
+
import { expect, userEvent, waitFor, within } from 'storybook/test';
|
|
5
5
|
|
|
6
6
|
import { Table } from './Table';
|
|
7
7
|
import type { ColumnConfig } from './Table.types';
|
|
@@ -149,7 +149,7 @@ export const KeyboardNavigation: Story = {
|
|
|
149
149
|
// Test Tab navigation
|
|
150
150
|
await userEvent.tab();
|
|
151
151
|
const firstCheckbox = canvas.getAllByRole('checkbox')[0];
|
|
152
|
-
await expect(firstCheckbox).toHaveFocus();
|
|
152
|
+
await waitFor(() => expect(firstCheckbox).toHaveFocus());
|
|
153
153
|
},
|
|
154
154
|
};
|
|
155
155
|
|
|
@@ -201,11 +201,11 @@ export const FocusManagement: Story = {
|
|
|
201
201
|
const canvas = within(canvasElement);
|
|
202
202
|
|
|
203
203
|
const beforeButton = canvas.getByTestId('before');
|
|
204
|
-
|
|
204
|
+
await userEvent.click(beforeButton);
|
|
205
205
|
|
|
206
206
|
await userEvent.tab();
|
|
207
207
|
const firstCheckbox = canvas.getAllByRole('checkbox')[0];
|
|
208
|
-
await expect(firstCheckbox).toHaveFocus();
|
|
208
|
+
await waitFor(() => expect(firstCheckbox).toHaveFocus());
|
|
209
209
|
},
|
|
210
210
|
};
|
|
211
211
|
|