@12-apps/ui 1.0.0 → 1.3.0
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,159 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { alpha, Badge as MuiBadge, IconButton, keyframes, Zoom } from '@mui/material';
|
|
3
|
-
import type { Theme } from '@mui/material/styles';
|
|
1
|
+
import { Badge as MuiBadge, Zoom } from '@mui/material';
|
|
4
2
|
import { styled } from '@mui/material/styles';
|
|
5
3
|
import React, { useEffect,useState } from 'react';
|
|
6
4
|
|
|
5
|
+
import {
|
|
6
|
+
badgeStyles,
|
|
7
|
+
getAnchorOrigin } from './Badge.styles';
|
|
8
|
+
import {
|
|
9
|
+
badgeContentOf,
|
|
10
|
+
definedAria,
|
|
11
|
+
formatCount,
|
|
12
|
+
resolveBadgeProps } from './Badge.helpers';
|
|
13
|
+
import type { ResolvedBadgeProps } from './Badge.helpers';
|
|
14
|
+
import { buildBadgeContent } from './BadgeContent';
|
|
7
15
|
import type { BadgeProps, BadgeSize, BadgeVariant } from './Badge.types';
|
|
8
16
|
export type { BadgeProps } from './Badge.types';
|
|
9
17
|
|
|
10
18
|
// Define pulse animation
|
|
11
|
-
const pulseAnimation = keyframes`
|
|
12
|
-
0% {
|
|
13
|
-
transform: scale(1);
|
|
14
|
-
opacity: 1;
|
|
15
|
-
}
|
|
16
|
-
70% {
|
|
17
|
-
transform: scale(1.2);
|
|
18
|
-
opacity: 0.7;
|
|
19
|
-
}
|
|
20
|
-
100% {
|
|
21
|
-
transform: scale(1);
|
|
22
|
-
opacity: 1;
|
|
23
|
-
}
|
|
24
|
-
`;
|
|
25
|
-
|
|
26
|
-
// Define bounce animation
|
|
27
|
-
const bounceAnimation = keyframes`
|
|
28
|
-
0%, 20%, 50%, 80%, 100% {
|
|
29
|
-
transform: translateY(0) scale(1);
|
|
30
|
-
}
|
|
31
|
-
40% {
|
|
32
|
-
transform: translateY(-8px) scale(1.05);
|
|
33
|
-
}
|
|
34
|
-
60% {
|
|
35
|
-
transform: translateY(-4px) scale(1.02);
|
|
36
|
-
}
|
|
37
|
-
`;
|
|
38
|
-
|
|
39
|
-
// Define shimmer animation
|
|
40
|
-
const shimmerAnimation = keyframes`
|
|
41
|
-
0% {
|
|
42
|
-
background-position: -1000px 0;
|
|
43
|
-
}
|
|
44
|
-
100% {
|
|
45
|
-
background-position: 1000px 0;
|
|
46
|
-
}
|
|
47
|
-
`;
|
|
48
|
-
|
|
49
|
-
// Define fade in animation with scale
|
|
50
|
-
const fadeInScaleAnimation = keyframes`
|
|
51
|
-
0% {
|
|
52
|
-
opacity: 0;
|
|
53
|
-
transform: scale(0.5);
|
|
54
|
-
}
|
|
55
|
-
50% {
|
|
56
|
-
transform: scale(1.1);
|
|
57
|
-
}
|
|
58
|
-
100% {
|
|
59
|
-
opacity: 1;
|
|
60
|
-
transform: scale(1);
|
|
61
|
-
}
|
|
62
|
-
`;
|
|
63
|
-
|
|
64
|
-
// Define glow pulse animation
|
|
65
|
-
const glowPulseAnimation = keyframes`
|
|
66
|
-
0% {
|
|
67
|
-
box-shadow: 0 0 5px 2px rgba(var(--glow-color), 0.4);
|
|
68
|
-
}
|
|
69
|
-
50% {
|
|
70
|
-
box-shadow: 0 0 20px 4px rgba(var(--glow-color), 0.8);
|
|
71
|
-
}
|
|
72
|
-
100% {
|
|
73
|
-
box-shadow: 0 0 5px 2px rgba(var(--glow-color), 0.4);
|
|
74
|
-
}
|
|
75
|
-
`;
|
|
76
|
-
|
|
77
|
-
const getColorFromTheme = (theme: Theme, color: string) => {
|
|
78
|
-
const colorMap: Record<string, ReturnType<typeof theme.palette.augmentColor>> = {
|
|
79
|
-
primary: theme.palette.primary,
|
|
80
|
-
secondary: theme.palette.secondary,
|
|
81
|
-
success: theme.palette.success,
|
|
82
|
-
warning: theme.palette.warning,
|
|
83
|
-
error: theme.palette.error,
|
|
84
|
-
info: theme.palette.info,
|
|
85
|
-
neutral: {
|
|
86
|
-
main: theme.palette.grey[600],
|
|
87
|
-
light: theme.palette.grey[400],
|
|
88
|
-
dark: theme.palette.grey[800],
|
|
89
|
-
contrastText: theme.palette.getContrastText(theme.palette.grey[600]),
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
return colorMap[color] || theme.palette.primary;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const getSizeStyles = (size: BadgeSize) => {
|
|
97
|
-
const sizeMap: Record<
|
|
98
|
-
BadgeSize,
|
|
99
|
-
{
|
|
100
|
-
minWidth: number;
|
|
101
|
-
height: number;
|
|
102
|
-
fontSize: string;
|
|
103
|
-
padding: string;
|
|
104
|
-
dotSize: number;
|
|
105
|
-
iconSize: string;
|
|
106
|
-
}
|
|
107
|
-
> = {
|
|
108
|
-
xs: {
|
|
109
|
-
minWidth: 14,
|
|
110
|
-
height: 14,
|
|
111
|
-
fontSize: '0.5rem',
|
|
112
|
-
padding: '0 3px',
|
|
113
|
-
dotSize: 6,
|
|
114
|
-
iconSize: '0.625rem',
|
|
115
|
-
},
|
|
116
|
-
sm: {
|
|
117
|
-
minWidth: 16,
|
|
118
|
-
height: 16,
|
|
119
|
-
fontSize: '0.625rem',
|
|
120
|
-
padding: '0 4px',
|
|
121
|
-
dotSize: 8,
|
|
122
|
-
iconSize: '0.75rem',
|
|
123
|
-
},
|
|
124
|
-
md: {
|
|
125
|
-
minWidth: 20,
|
|
126
|
-
height: 20,
|
|
127
|
-
fontSize: '0.75rem',
|
|
128
|
-
padding: '0 6px',
|
|
129
|
-
dotSize: 10,
|
|
130
|
-
iconSize: '0.875rem',
|
|
131
|
-
},
|
|
132
|
-
lg: {
|
|
133
|
-
minWidth: 24,
|
|
134
|
-
height: 24,
|
|
135
|
-
fontSize: '0.875rem',
|
|
136
|
-
padding: '0 8px',
|
|
137
|
-
dotSize: 12,
|
|
138
|
-
iconSize: '1rem',
|
|
139
|
-
},
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
return sizeMap[size] || sizeMap.md;
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
const getAnchorOrigin = (position: string) => {
|
|
146
|
-
const positionMap: Record<string, { vertical: 'top' | 'bottom'; horizontal: 'left' | 'right' }> =
|
|
147
|
-
{
|
|
148
|
-
'top-right': { vertical: 'top', horizontal: 'right' },
|
|
149
|
-
'top-left': { vertical: 'top', horizontal: 'left' },
|
|
150
|
-
'bottom-right': { vertical: 'bottom', horizontal: 'right' },
|
|
151
|
-
'bottom-left': { vertical: 'bottom', horizontal: 'left' },
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
return positionMap[position] || positionMap['top-right'];
|
|
155
|
-
};
|
|
156
|
-
|
|
157
19
|
const StyledBadge = styled(MuiBadge, {
|
|
158
20
|
shouldForwardProp: (prop) =>
|
|
159
21
|
![
|
|
@@ -166,8 +28,7 @@ const StyledBadge = styled(MuiBadge, {
|
|
|
166
28
|
'shimmer',
|
|
167
29
|
'bounce',
|
|
168
30
|
'hasIcon',
|
|
169
|
-
].includes(prop as string)
|
|
170
|
-
})<{
|
|
31
|
+
].includes(prop as string) })<{
|
|
171
32
|
customVariant?: BadgeVariant;
|
|
172
33
|
customSize?: BadgeSize;
|
|
173
34
|
customColor?: string;
|
|
@@ -187,420 +48,153 @@ const StyledBadge = styled(MuiBadge, {
|
|
|
187
48
|
animate,
|
|
188
49
|
shimmer,
|
|
189
50
|
bounce,
|
|
190
|
-
hasIcon
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
const b = parseInt(hex.slice(4, 6), 16);
|
|
203
|
-
return `${r}, ${g}, ${b}`;
|
|
204
|
-
}
|
|
205
|
-
// For rgb/rgba colors, extract values
|
|
206
|
-
const match = color.match(/\d+/g);
|
|
207
|
-
if (match) {
|
|
208
|
-
return `${match[0]}, ${match[1]}, ${match[2]}`;
|
|
209
|
-
}
|
|
210
|
-
return '255, 255, 255';
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
return {
|
|
214
|
-
'--glow-color': getRgbValues(colorPalette.main),
|
|
215
|
-
'& .MuiBadge-badge': {
|
|
216
|
-
transition: 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)',
|
|
217
|
-
fontWeight: 600,
|
|
218
|
-
border: `2px solid ${theme.palette.background.paper}`,
|
|
219
|
-
letterSpacing: '0.025em',
|
|
220
|
-
textTransform:
|
|
221
|
-
customVariant === 'gradient' || customVariant === 'glass' ? 'uppercase' : 'none',
|
|
222
|
-
willChange: 'transform, opacity',
|
|
223
|
-
backfaceVisibility: 'hidden',
|
|
224
|
-
|
|
225
|
-
// Base styles based on variant
|
|
226
|
-
...(customVariant === 'default' && {
|
|
227
|
-
backgroundColor: colorPalette.main,
|
|
228
|
-
color:
|
|
229
|
-
colorPalette.contrastText || theme.palette.getContrastText?.(colorPalette.main) || '#fff',
|
|
230
|
-
minWidth: sizeStyles.minWidth,
|
|
231
|
-
height: sizeStyles.height,
|
|
232
|
-
fontSize: sizeStyles.fontSize,
|
|
233
|
-
padding: sizeStyles.padding,
|
|
234
|
-
borderRadius: sizeStyles.height / 2,
|
|
235
|
-
}),
|
|
236
|
-
|
|
237
|
-
...(customVariant === 'dot' && {
|
|
238
|
-
backgroundColor: colorPalette.main,
|
|
239
|
-
width: sizeStyles.dotSize,
|
|
240
|
-
height: sizeStyles.dotSize,
|
|
241
|
-
minWidth: sizeStyles.dotSize,
|
|
242
|
-
borderRadius: '50%',
|
|
243
|
-
padding: 0,
|
|
244
|
-
}),
|
|
245
|
-
|
|
246
|
-
...(customVariant === 'count' && {
|
|
247
|
-
backgroundColor: colorPalette.main,
|
|
248
|
-
color:
|
|
249
|
-
colorPalette.contrastText || theme.palette.getContrastText?.(colorPalette.main) || '#fff',
|
|
250
|
-
minWidth: sizeStyles.minWidth,
|
|
251
|
-
height: sizeStyles.height,
|
|
252
|
-
fontSize: sizeStyles.fontSize,
|
|
253
|
-
padding: sizeStyles.padding,
|
|
254
|
-
borderRadius: '50%',
|
|
255
|
-
}),
|
|
256
|
-
|
|
257
|
-
...(customVariant === 'gradient' && {
|
|
258
|
-
background: `linear-gradient(135deg, ${colorPalette.main} 0%, ${colorPalette.dark || colorPalette.main} 100%)`,
|
|
259
|
-
color: '#fff',
|
|
260
|
-
minWidth: sizeStyles.minWidth,
|
|
261
|
-
height: sizeStyles.height,
|
|
262
|
-
fontSize: sizeStyles.fontSize,
|
|
263
|
-
padding: sizeStyles.padding,
|
|
264
|
-
borderRadius: sizeStyles.height / 2,
|
|
265
|
-
}),
|
|
266
|
-
|
|
267
|
-
...(customVariant === 'glass' && {
|
|
268
|
-
backgroundColor: alpha(colorPalette.main, 0.1),
|
|
269
|
-
backdropFilter: 'blur(10px) saturate(200%)',
|
|
270
|
-
WebkitBackdropFilter: 'blur(10px) saturate(200%)',
|
|
271
|
-
border: `1px solid ${alpha(colorPalette.main, 0.2)}`,
|
|
272
|
-
color: colorPalette.main,
|
|
273
|
-
minWidth: sizeStyles.minWidth,
|
|
274
|
-
height: sizeStyles.height,
|
|
275
|
-
fontSize: sizeStyles.fontSize,
|
|
276
|
-
padding: sizeStyles.padding,
|
|
277
|
-
borderRadius: sizeStyles.height / 2,
|
|
278
|
-
boxShadow: `inset 0 1px 1px ${alpha(theme.palette.common.white, 0.1)}`,
|
|
279
|
-
}),
|
|
280
|
-
|
|
281
|
-
// Outline variant
|
|
282
|
-
...(customVariant === 'outline' && {
|
|
283
|
-
backgroundColor: 'transparent',
|
|
284
|
-
border: `2px solid ${colorPalette.main}`,
|
|
285
|
-
color: colorPalette.main,
|
|
286
|
-
minWidth: sizeStyles.minWidth,
|
|
287
|
-
height: sizeStyles.height,
|
|
288
|
-
fontSize: sizeStyles.fontSize,
|
|
289
|
-
padding: sizeStyles.padding,
|
|
290
|
-
borderRadius: sizeStyles.height / 2,
|
|
291
|
-
}),
|
|
292
|
-
|
|
293
|
-
// Secondary variant
|
|
294
|
-
...(customVariant === 'secondary' && {
|
|
295
|
-
backgroundColor: alpha(colorPalette.main, 0.15),
|
|
296
|
-
color: colorPalette.main,
|
|
297
|
-
border: `1px solid ${alpha(colorPalette.main, 0.3)}`,
|
|
298
|
-
minWidth: sizeStyles.minWidth,
|
|
299
|
-
height: sizeStyles.height,
|
|
300
|
-
fontSize: sizeStyles.fontSize,
|
|
301
|
-
padding: sizeStyles.padding,
|
|
302
|
-
borderRadius: sizeStyles.height / 2,
|
|
303
|
-
}),
|
|
304
|
-
|
|
305
|
-
// Destructive variant
|
|
306
|
-
...(customVariant === 'destructive' && {
|
|
307
|
-
backgroundColor: theme.palette.error.main,
|
|
308
|
-
color: theme.palette.error.contrastText,
|
|
309
|
-
minWidth: sizeStyles.minWidth,
|
|
310
|
-
height: sizeStyles.height,
|
|
311
|
-
fontSize: sizeStyles.fontSize,
|
|
312
|
-
padding: sizeStyles.padding,
|
|
313
|
-
borderRadius: sizeStyles.height / 2,
|
|
314
|
-
fontWeight: 700,
|
|
315
|
-
}),
|
|
316
|
-
|
|
317
|
-
// Success variant
|
|
318
|
-
...(customVariant === 'success' && {
|
|
319
|
-
backgroundColor: theme.palette.success.main,
|
|
320
|
-
color: theme.palette.success.contrastText,
|
|
321
|
-
minWidth: sizeStyles.minWidth,
|
|
322
|
-
height: sizeStyles.height,
|
|
323
|
-
fontSize: sizeStyles.fontSize,
|
|
324
|
-
padding: sizeStyles.padding,
|
|
325
|
-
borderRadius: sizeStyles.height / 2,
|
|
326
|
-
}),
|
|
327
|
-
|
|
328
|
-
// Warning variant
|
|
329
|
-
...(customVariant === 'warning' && {
|
|
330
|
-
backgroundColor: theme.palette.warning.main,
|
|
331
|
-
color: theme.palette.warning.contrastText,
|
|
332
|
-
minWidth: sizeStyles.minWidth,
|
|
333
|
-
height: sizeStyles.height,
|
|
334
|
-
fontSize: sizeStyles.fontSize,
|
|
335
|
-
padding: sizeStyles.padding,
|
|
336
|
-
borderRadius: sizeStyles.height / 2,
|
|
337
|
-
}),
|
|
338
|
-
|
|
339
|
-
// Adjust padding when icon is present
|
|
340
|
-
...(hasIcon && {
|
|
341
|
-
paddingLeft: sizeStyles.padding.split(' ')[1],
|
|
342
|
-
display: 'inline-flex',
|
|
343
|
-
alignItems: 'center',
|
|
344
|
-
gap: '2px',
|
|
345
|
-
}),
|
|
346
|
-
|
|
347
|
-
// Animation on mount
|
|
348
|
-
...(animate &&
|
|
349
|
-
!bounce && {
|
|
350
|
-
animation: `${fadeInScaleAnimation} 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55)`,
|
|
351
|
-
}),
|
|
352
|
-
|
|
353
|
-
// Bounce animation
|
|
354
|
-
...(bounce && {
|
|
355
|
-
animation: `${bounceAnimation} 1s ease-in-out`,
|
|
356
|
-
}),
|
|
357
|
-
|
|
358
|
-
// Shimmer effect
|
|
359
|
-
...(shimmer && {
|
|
360
|
-
background:
|
|
361
|
-
customVariant === 'gradient'
|
|
362
|
-
? `linear-gradient(135deg, ${colorPalette.main} 0%, ${colorPalette.dark || colorPalette.main} 100%)`
|
|
363
|
-
: colorPalette.main,
|
|
364
|
-
backgroundSize: shimmer ? '1000px 100%' : 'auto',
|
|
365
|
-
position: 'relative',
|
|
366
|
-
overflow: 'hidden',
|
|
367
|
-
'&::after': {
|
|
368
|
-
content: '""',
|
|
369
|
-
position: 'absolute',
|
|
370
|
-
top: 0,
|
|
371
|
-
left: 0,
|
|
372
|
-
width: '100%',
|
|
373
|
-
height: '100%',
|
|
374
|
-
background: `linear-gradient(
|
|
375
|
-
90deg,
|
|
376
|
-
transparent,
|
|
377
|
-
${alpha(theme.palette.common.white, 0.4)},
|
|
378
|
-
transparent
|
|
379
|
-
)`,
|
|
380
|
-
animation: `${shimmerAnimation} 3s infinite`,
|
|
381
|
-
},
|
|
382
|
-
}),
|
|
383
|
-
|
|
384
|
-
// Glow effect
|
|
385
|
-
...(glow &&
|
|
386
|
-
!pulse && {
|
|
387
|
-
boxShadow: `0 0 15px 3px ${alpha(colorPalette.main, 0.5)}`,
|
|
388
|
-
filter: 'brightness(1.1)',
|
|
389
|
-
'&:hover': {
|
|
390
|
-
boxShadow: `0 0 20px 4px ${alpha(colorPalette.main, 0.6)}`,
|
|
391
|
-
},
|
|
392
|
-
}),
|
|
393
|
-
|
|
394
|
-
// Pulse animation
|
|
395
|
-
...(pulse &&
|
|
396
|
-
!glow && {
|
|
397
|
-
animation: `${pulseAnimation} 2s ease-in-out infinite`,
|
|
398
|
-
}),
|
|
399
|
-
|
|
400
|
-
// Both glow and pulse
|
|
401
|
-
...(glow &&
|
|
402
|
-
pulse && {
|
|
403
|
-
animation: `${glowPulseAnimation} 2s ease-in-out infinite, ${pulseAnimation} 2s ease-in-out infinite`,
|
|
404
|
-
filter: 'brightness(1.1)',
|
|
405
|
-
}),
|
|
406
|
-
|
|
407
|
-
// Hover effects
|
|
408
|
-
'&:not(.MuiBadge-dot):hover': {
|
|
409
|
-
transform: 'scale(1.1)',
|
|
410
|
-
zIndex: 1,
|
|
411
|
-
},
|
|
412
|
-
},
|
|
413
|
-
};
|
|
51
|
+
hasIcon }) => {
|
|
52
|
+
return badgeStyles({
|
|
53
|
+
theme,
|
|
54
|
+
customVariant,
|
|
55
|
+
customSize,
|
|
56
|
+
customColor,
|
|
57
|
+
glow,
|
|
58
|
+
pulse,
|
|
59
|
+
animate,
|
|
60
|
+
shimmer,
|
|
61
|
+
bounce,
|
|
62
|
+
hasIcon });
|
|
414
63
|
});
|
|
415
64
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
{
|
|
419
|
-
variant = 'default',
|
|
420
|
-
size = 'md',
|
|
421
|
-
color = 'primary',
|
|
422
|
-
glow = false,
|
|
423
|
-
pulse = false,
|
|
424
|
-
animate = true,
|
|
425
|
-
shimmer = false,
|
|
426
|
-
bounce = false,
|
|
427
|
-
max = 99,
|
|
428
|
-
showZero = false,
|
|
429
|
-
content,
|
|
430
|
-
position = 'top-right',
|
|
431
|
-
badgeContent,
|
|
432
|
-
children,
|
|
433
|
-
invisible,
|
|
434
|
-
closable = false,
|
|
435
|
-
onClose,
|
|
436
|
-
icon,
|
|
437
|
-
'aria-label': ariaLabel,
|
|
438
|
-
'aria-live': ariaLive = 'polite',
|
|
439
|
-
'aria-atomic': ariaAtomic = true,
|
|
440
|
-
'data-testid': dataTestId,
|
|
441
|
-
className,
|
|
442
|
-
...props
|
|
443
|
-
},
|
|
444
|
-
ref,
|
|
445
|
-
) => {
|
|
446
|
-
const [isVisible, setIsVisible] = useState(true);
|
|
447
|
-
const [isAnimating, setIsAnimating] = useState(false);
|
|
448
|
-
|
|
449
|
-
useEffect(() => {
|
|
450
|
-
if (animate || bounce) {
|
|
451
|
-
setIsAnimating(true);
|
|
452
|
-
const timer = window.setTimeout(() => setIsAnimating(false), 1000);
|
|
453
|
-
return () => window.clearTimeout(timer);
|
|
454
|
-
}
|
|
455
|
-
}, [animate, bounce]);
|
|
456
|
-
|
|
457
|
-
// Determine the badge content
|
|
458
|
-
const getBadgeContent = () => {
|
|
459
|
-
if (content !== undefined) return content;
|
|
460
|
-
if (badgeContent !== undefined) return badgeContent;
|
|
461
|
-
return null;
|
|
462
|
-
};
|
|
463
|
-
|
|
464
|
-
// For count variant, format numbers
|
|
465
|
-
const formatCount = (count: React.ReactNode): React.ReactNode => {
|
|
466
|
-
if (typeof count === 'number') {
|
|
467
|
-
if (count === 0 && !showZero) return null;
|
|
468
|
-
if (count > max) return `${max}+`;
|
|
469
|
-
return count;
|
|
470
|
-
}
|
|
471
|
-
return count;
|
|
472
|
-
};
|
|
473
|
-
|
|
474
|
-
// Handle close action
|
|
475
|
-
const handleClose = (e: React.MouseEvent) => {
|
|
476
|
-
e.stopPropagation();
|
|
477
|
-
setIsVisible(false);
|
|
478
|
-
window.setTimeout(() => {
|
|
479
|
-
onClose?.();
|
|
480
|
-
}, 300);
|
|
481
|
-
};
|
|
482
|
-
|
|
483
|
-
// Prepare badge content with icon and close button
|
|
484
|
-
const prepareBadgeContent = () => {
|
|
485
|
-
const baseContent = variant === 'count' ? formatCount(getBadgeContent()) : getBadgeContent();
|
|
486
|
-
|
|
487
|
-
if (variant === 'dot') return '';
|
|
65
|
+
const CLOSE_DELAY_MS = 300;
|
|
66
|
+
const ANIMATION_MS = 1000;
|
|
488
67
|
|
|
489
|
-
|
|
68
|
+
// A one-shot flag so bounce/animate run on mount and then stop.
|
|
69
|
+
const useMountAnimation = (enabled: boolean) => {
|
|
70
|
+
const [isAnimating, setIsAnimating] = useState(false);
|
|
490
71
|
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
const sizeStyles = getSizeStyles(size);
|
|
494
|
-
contentElements.push(
|
|
495
|
-
<span
|
|
496
|
-
key="icon"
|
|
497
|
-
data-testid={dataTestId ? `${dataTestId}-icon` : 'badge-icon'}
|
|
498
|
-
style={{ fontSize: sizeStyles.iconSize, display: 'inline-flex', alignItems: 'center' }}
|
|
499
|
-
>
|
|
500
|
-
{icon}
|
|
501
|
-
</span>,
|
|
502
|
-
);
|
|
503
|
-
}
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (!enabled) return;
|
|
504
74
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
{baseContent}
|
|
510
|
-
</span>,
|
|
511
|
-
);
|
|
512
|
-
}
|
|
75
|
+
setIsAnimating(true);
|
|
76
|
+
const timer = window.setTimeout(() => setIsAnimating(false), ANIMATION_MS);
|
|
77
|
+
return () => window.clearTimeout(timer);
|
|
78
|
+
}, [enabled]);
|
|
513
79
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
const closeIconSize =
|
|
517
|
-
size === 'xs'
|
|
518
|
-
? '0.5rem'
|
|
519
|
-
: size === 'sm'
|
|
520
|
-
? '0.625rem'
|
|
521
|
-
: size === 'md'
|
|
522
|
-
? '0.75rem'
|
|
523
|
-
: '0.875rem';
|
|
524
|
-
contentElements.push(
|
|
525
|
-
<IconButton
|
|
526
|
-
key="close"
|
|
527
|
-
size="small"
|
|
528
|
-
onClick={handleClose}
|
|
529
|
-
data-testid={dataTestId ? `${dataTestId}-close` : 'badge-close'}
|
|
530
|
-
sx={{
|
|
531
|
-
p: 0,
|
|
532
|
-
ml: 0.5,
|
|
533
|
-
color: 'inherit',
|
|
534
|
-
'& svg': { fontSize: closeIconSize },
|
|
535
|
-
'&:hover': { opacity: 0.8 },
|
|
536
|
-
}}
|
|
537
|
-
>
|
|
538
|
-
<CloseIcon />
|
|
539
|
-
</IconButton>,
|
|
540
|
-
);
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
return contentElements.length > 0 ? (
|
|
544
|
-
<span style={{ display: 'inline-flex', alignItems: 'center', gap: '2px' }}>
|
|
545
|
-
{contentElements}
|
|
546
|
-
</span>
|
|
547
|
-
) : null;
|
|
548
|
-
};
|
|
549
|
-
|
|
550
|
-
const finalBadgeContent = prepareBadgeContent();
|
|
551
|
-
const anchorOrigin = getAnchorOrigin(position);
|
|
552
|
-
|
|
553
|
-
// Determine if badge should be invisible
|
|
554
|
-
const shouldBeInvisible =
|
|
555
|
-
invisible || (variant === 'count' && finalBadgeContent === null && !showZero) || !isVisible;
|
|
80
|
+
return isAnimating;
|
|
81
|
+
};
|
|
556
82
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
83
|
+
// The chip itself. Local because StyledBadge cannot cross a module boundary
|
|
84
|
+
// (TS2742).
|
|
85
|
+
const BadgeSurface: React.FC<
|
|
86
|
+
ResolvedBadgeProps & {
|
|
87
|
+
innerRef: React.Ref<HTMLSpanElement>;
|
|
88
|
+
isVisible: boolean;
|
|
89
|
+
isAnimating: boolean;
|
|
90
|
+
shouldBeInvisible: boolean;
|
|
91
|
+
finalBadgeContent: React.ReactNode;
|
|
92
|
+
aria: Record<string, string | boolean>;
|
|
93
|
+
rest: Record<string, unknown>;
|
|
94
|
+
}
|
|
95
|
+
> = ({ innerRef, isVisible, isAnimating, shouldBeInvisible, finalBadgeContent, aria, rest, ...p }) => {
|
|
96
|
+
const testId = p['data-testid'];
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<Zoom in={isVisible} timeout={CLOSE_DELAY_MS}>
|
|
100
|
+
<StyledBadge
|
|
101
|
+
ref={innerRef}
|
|
102
|
+
className={p.className}
|
|
103
|
+
customVariant={p.variant}
|
|
104
|
+
customSize={p.size}
|
|
105
|
+
customColor={p.color}
|
|
106
|
+
glow={p.glow}
|
|
107
|
+
pulse={p.pulse}
|
|
108
|
+
animate={p.animate}
|
|
109
|
+
shimmer={p.shimmer}
|
|
110
|
+
bounce={p.bounce && isAnimating}
|
|
111
|
+
hasIcon={Boolean(p.icon)}
|
|
112
|
+
badgeContent={finalBadgeContent}
|
|
113
|
+
variant={p.variant === 'dot' ? 'dot' : 'standard'}
|
|
114
|
+
anchorOrigin={getAnchorOrigin(p.position)}
|
|
115
|
+
invisible={shouldBeInvisible}
|
|
116
|
+
data-testid={testId || 'badge'}
|
|
117
|
+
slotProps={{
|
|
118
|
+
badge: {
|
|
119
|
+
...aria,
|
|
120
|
+
// @ts-expect-error - MUI Badge slotProps doesn't include data-testid in types, but it works at runtime
|
|
121
|
+
'data-testid': testId ? `${testId}-content-wrapper` : 'badge-content-wrapper' } }}
|
|
122
|
+
{...rest}
|
|
123
|
+
>
|
|
124
|
+
{p.children}
|
|
125
|
+
</StyledBadge>
|
|
126
|
+
</Zoom>
|
|
127
|
+
);
|
|
128
|
+
};
|
|
563
129
|
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
130
|
+
export const Badge = React.forwardRef<HTMLSpanElement, BadgeProps>((componentProps, ref) => {
|
|
131
|
+
const resolved = resolveBadgeProps(componentProps);
|
|
132
|
+
const {
|
|
133
|
+
variant,
|
|
134
|
+
size,
|
|
135
|
+
color: _color,
|
|
136
|
+
glow: _glow,
|
|
137
|
+
pulse: _pulse,
|
|
138
|
+
animate,
|
|
139
|
+
shimmer: _shimmer,
|
|
140
|
+
bounce,
|
|
141
|
+
max,
|
|
142
|
+
showZero,
|
|
143
|
+
position: _position,
|
|
144
|
+
children: _children,
|
|
145
|
+
invisible,
|
|
146
|
+
closable,
|
|
147
|
+
onClose,
|
|
148
|
+
icon,
|
|
149
|
+
'aria-label': ariaLabel,
|
|
150
|
+
'aria-live': ariaLive = 'polite',
|
|
151
|
+
'aria-atomic': ariaAtomic = true,
|
|
152
|
+
'data-testid': dataTestId,
|
|
153
|
+
className: _className,
|
|
154
|
+
content: _content,
|
|
155
|
+
badgeContent: _badgeContent,
|
|
156
|
+
...props
|
|
157
|
+
} = resolved;
|
|
158
|
+
|
|
159
|
+
const [isVisible, setIsVisible] = useState(true);
|
|
160
|
+
const isAnimating = useMountAnimation(animate || bounce);
|
|
161
|
+
|
|
162
|
+
const handleClose = (event: React.MouseEvent) => {
|
|
163
|
+
event.stopPropagation();
|
|
164
|
+
setIsVisible(false);
|
|
165
|
+
// Let the Zoom finish before telling the caller.
|
|
166
|
+
window.setTimeout(() => onClose?.(), CLOSE_DELAY_MS);
|
|
167
|
+
};
|
|
570
168
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
</Zoom>
|
|
602
|
-
);
|
|
603
|
-
},
|
|
604
|
-
);
|
|
169
|
+
const rawContent = badgeContentOf(resolved);
|
|
170
|
+
const finalBadgeContent = buildBadgeContent({
|
|
171
|
+
variant,
|
|
172
|
+
size,
|
|
173
|
+
icon,
|
|
174
|
+
closable,
|
|
175
|
+
dataTestId,
|
|
176
|
+
baseContent: variant === 'count' ? formatCount(rawContent, { max, showZero }) : rawContent,
|
|
177
|
+
onClose: handleClose });
|
|
178
|
+
|
|
179
|
+
// A count that formatted away leaves nothing worth showing.
|
|
180
|
+
const shouldBeInvisible =
|
|
181
|
+
invisible || (variant === 'count' && finalBadgeContent === null && !showZero) || !isVisible;
|
|
182
|
+
|
|
183
|
+
return (
|
|
184
|
+
<BadgeSurface
|
|
185
|
+
{...resolved}
|
|
186
|
+
innerRef={ref}
|
|
187
|
+
isVisible={isVisible}
|
|
188
|
+
isAnimating={isAnimating}
|
|
189
|
+
shouldBeInvisible={shouldBeInvisible}
|
|
190
|
+
finalBadgeContent={finalBadgeContent}
|
|
191
|
+
aria={definedAria({
|
|
192
|
+
'aria-label': ariaLabel,
|
|
193
|
+
'aria-live': ariaLive,
|
|
194
|
+
'aria-atomic': ariaAtomic })}
|
|
195
|
+
rest={props as unknown as Record<string, unknown>}
|
|
196
|
+
/>
|
|
197
|
+
);
|
|
198
|
+
});
|
|
605
199
|
|
|
606
200
|
Badge.displayName = 'Badge';
|