@ohif/ui-next 3.14.0-beta.12 → 3.14.0-beta.120
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/dist/ohif-ui-next.css +6 -6
- package/dist/ohif-ui-next.umd.js +4 -1838
- package/package.json +31 -14
- package/src/__mocks__/fileMock.js +7 -0
- package/src/assets/fonts.css +50 -0
- package/src/assets/styles.css +55 -0
- package/src/assets/woff2/latin.woff2 +0 -0
- package/src/components/Accordion/Accordion.tsx +70 -0
- package/src/components/Accordion/index.ts +3 -0
- package/src/components/AllInOneMenu/BackItem.tsx +32 -0
- package/src/components/AllInOneMenu/DividerItem.tsx +11 -0
- package/src/components/AllInOneMenu/HeaderItem.tsx +15 -0
- package/src/components/AllInOneMenu/IconMenu.tsx +83 -0
- package/src/components/AllInOneMenu/Item.tsx +51 -0
- package/src/components/AllInOneMenu/ItemPanel.tsx +38 -0
- package/src/components/AllInOneMenu/Menu.tsx +231 -0
- package/src/components/AllInOneMenu/PanelSelector.tsx +32 -0
- package/src/components/AllInOneMenu/SubMenu.tsx +36 -0
- package/src/components/AllInOneMenu/index.ts +42 -0
- package/src/components/BackgroundColorSelect/BackgroundColorSelect.tsx +38 -0
- package/src/components/BackgroundColorSelect/index.tsx +1 -0
- package/src/components/Badge/Badge.tsx +38 -0
- package/src/components/Badge/index.ts +1 -0
- package/src/components/Button/Button.tsx +65 -0
- package/src/components/Button/index.ts +1 -0
- package/src/components/Calendar/Calendar.tsx +258 -0
- package/src/components/Calendar/index.tsx +3 -0
- package/src/components/Card/Card.tsx +83 -0
- package/src/components/Card/index.ts +2 -0
- package/src/components/Checkbox/Checkbox.tsx +27 -0
- package/src/components/Checkbox/index.tsx +3 -0
- package/src/components/CinePlayer/CinePlayer.tsx +187 -0
- package/src/components/CinePlayer/index.ts +5 -0
- package/src/components/Clipboard/Clipboard.tsx +58 -0
- package/src/components/Clipboard/index.tsx +3 -0
- package/src/components/ColorCircle.tsx +12 -0
- package/src/components/Combobox/Combobox.tsx +66 -0
- package/src/components/Combobox/index.ts +3 -0
- package/src/components/Command/Command.tsx +149 -0
- package/src/components/Command/index.ts +23 -0
- package/src/components/ContextMenu/ContextMenu.tsx +202 -0
- package/src/components/ContextMenu/index.ts +35 -0
- package/src/components/ContextMenuViewport/ContextMenuViewport.tsx +47 -0
- package/src/components/ContextMenuViewport/index.ts +1 -0
- package/src/components/DataRow/DataRow.tsx +532 -0
- package/src/components/DataRow/index.ts +1 -0
- package/src/components/DataRow/types.ts +31 -0
- package/src/components/DataTable/ActionOverlayCell.tsx +153 -0
- package/src/components/DataTable/ColumnHeader.tsx +70 -0
- package/src/components/DataTable/DataTable.tsx +532 -0
- package/src/components/DataTable/FilterRow.tsx +52 -0
- package/src/components/DataTable/Pagination.tsx +78 -0
- package/src/components/DataTable/Title.tsx +5 -0
- package/src/components/DataTable/Toolbar.tsx +5 -0
- package/src/components/DataTable/ViewOptions.tsx +86 -0
- package/src/components/DataTable/context.tsx +21 -0
- package/src/components/DataTable/index.ts +5 -0
- package/src/components/DataTable/types.ts +27 -0
- package/src/components/DataTable/useResponsiveColumns.tsx +346 -0
- package/src/components/DateRange/DateRange.tsx +163 -0
- package/src/components/DateRange/index.ts +3 -0
- package/src/components/Dialog/Dialog.tsx +201 -0
- package/src/components/Dialog/index.ts +25 -0
- package/src/components/Dialog/useDraggable.ts +108 -0
- package/src/components/DisplaySetMessageListTooltip/DisplaySetMessageListTooltip.tsx +64 -0
- package/src/components/DisplaySetMessageListTooltip/index.ts +3 -0
- package/src/components/DoubleSlider/DoubleSlider.test.ts +232 -0
- package/src/components/DoubleSlider/DoubleSlider.tsx +211 -0
- package/src/components/DoubleSlider/index.tsx +3 -0
- package/src/components/DropdownMenu/DropdownMenu.tsx +213 -0
- package/src/components/DropdownMenu/index.ts +35 -0
- package/src/components/Errorboundary/ErrorBoundary.tsx +345 -0
- package/src/components/Errorboundary/index.tsx +3 -0
- package/src/components/FooterAction/FooterAction.tsx +115 -0
- package/src/components/FooterAction/index.tsx +3 -0
- package/src/components/Header/Header.tsx +140 -0
- package/src/components/Header/index.js +2 -0
- package/src/components/HoverCard/HoverCard.tsx +30 -0
- package/src/components/HoverCard/index.ts +1 -0
- package/src/components/Icons/Icons.tsx +852 -0
- package/src/components/Icons/Sources/ActionNewDialog.tsx +64 -0
- package/src/components/Icons/Sources/Actions.tsx +47 -0
- package/src/components/Icons/Sources/Add.tsx +51 -0
- package/src/components/Icons/Sources/Alert.tsx +32 -0
- package/src/components/Icons/Sources/AlertOutline.tsx +30 -0
- package/src/components/Icons/Sources/ArrowLeftBold.tsx +49 -0
- package/src/components/Icons/Sources/ArrowRight.tsx +25 -0
- package/src/components/Icons/Sources/Cancel.tsx +37 -0
- package/src/components/Icons/Sources/CheckBoxChecked.tsx +39 -0
- package/src/components/Icons/Sources/CheckBoxUnChecked.tsx +25 -0
- package/src/components/Icons/Sources/Checked.tsx +23 -0
- package/src/components/Icons/Sources/ChevronClosed.tsx +40 -0
- package/src/components/Icons/Sources/ChevronLeft.tsx +28 -0
- package/src/components/Icons/Sources/ChevronOpen.tsx +38 -0
- package/src/components/Icons/Sources/Clear.tsx +34 -0
- package/src/components/Icons/Sources/Clipboard.tsx +15 -0
- package/src/components/Icons/Sources/Close.tsx +28 -0
- package/src/components/Icons/Sources/CloudSettings.tsx +34 -0
- package/src/components/Icons/Sources/Code.tsx +7 -0
- package/src/components/Icons/Sources/ColorChange.tsx +100 -0
- package/src/components/Icons/Sources/ContentNext.tsx +35 -0
- package/src/components/Icons/Sources/ContentPrev.tsx +35 -0
- package/src/components/Icons/Sources/Controls.tsx +99 -0
- package/src/components/Icons/Sources/Copy.tsx +44 -0
- package/src/components/Icons/Sources/Database.tsx +33 -0
- package/src/components/Icons/Sources/Delete.tsx +58 -0
- package/src/components/Icons/Sources/DicomTagBrowser.tsx +79 -0
- package/src/components/Icons/Sources/DisplayFillAndOutline.tsx +49 -0
- package/src/components/Icons/Sources/DisplayFillOnly.tsx +40 -0
- package/src/components/Icons/Sources/DisplayOutlineOnly.tsx +40 -0
- package/src/components/Icons/Sources/Download.tsx +75 -0
- package/src/components/Icons/Sources/Export.tsx +53 -0
- package/src/components/Icons/Sources/ExternalLink.tsx +26 -0
- package/src/components/Icons/Sources/EyeHidden.tsx +32 -0
- package/src/components/Icons/Sources/EyeVisible.tsx +28 -0
- package/src/components/Icons/Sources/FeedbackComplete.tsx +35 -0
- package/src/components/Icons/Sources/GearSettings.tsx +59 -0
- package/src/components/Icons/Sources/GroupLayers.tsx +33 -0
- package/src/components/Icons/Sources/Helpers.tsx +398 -0
- package/src/components/Icons/Sources/Hide.tsx +45 -0
- package/src/components/Icons/Sources/IconColorLUT.tsx +103 -0
- package/src/components/Icons/Sources/IconMPR.tsx +55 -0
- package/src/components/Icons/Sources/IconTransferring.tsx +25 -0
- package/src/components/Icons/Sources/IllustrationNotFound.tsx +102 -0
- package/src/components/Icons/Sources/Info.tsx +55 -0
- package/src/components/Icons/Sources/InfoLink.tsx +23 -0
- package/src/components/Icons/Sources/InfoSeries.tsx +52 -0
- package/src/components/Icons/Sources/InvestigationalUse.tsx +82 -0
- package/src/components/Icons/Sources/JumpToSlice.tsx +69 -0
- package/src/components/Icons/Sources/LaunchArrow.tsx +34 -0
- package/src/components/Icons/Sources/LaunchInfo.tsx +38 -0
- package/src/components/Icons/Sources/LayerBackground.tsx +28 -0
- package/src/components/Icons/Sources/LayerForeground.tsx +34 -0
- package/src/components/Icons/Sources/LayerSegmentation.tsx +20 -0
- package/src/components/Icons/Sources/Layout.tsx +433 -0
- package/src/components/Icons/Sources/Link.tsx +58 -0
- package/src/components/Icons/Sources/ListView.tsx +79 -0
- package/src/components/Icons/Sources/LoadingOHIFMark.tsx +21 -0
- package/src/components/Icons/Sources/LoadingSpinner.tsx +49 -0
- package/src/components/Icons/Sources/Lock.tsx +35 -0
- package/src/components/Icons/Sources/Magnifier.tsx +37 -0
- package/src/components/Icons/Sources/Minus.tsx +40 -0
- package/src/components/Icons/Sources/MissingIcon.tsx +6 -0
- package/src/components/Icons/Sources/More.tsx +53 -0
- package/src/components/Icons/Sources/MultiplePatients.tsx +76 -0
- package/src/components/Icons/Sources/NavigationPanelReveal.tsx +25 -0
- package/src/components/Icons/Sources/NotificationInfo.tsx +33 -0
- package/src/components/Icons/Sources/NotificationWarning.tsx +44 -0
- package/src/components/Icons/Sources/OHIFLogo.tsx +72 -0
- package/src/components/Icons/Sources/OHIFLogoColorDarkBackground.tsx +78 -0
- package/src/components/Icons/Sources/OHIFLogoHorizontal.tsx +139 -0
- package/src/components/Icons/Sources/Opacity.tsx +106 -0
- package/src/components/Icons/Sources/OrientationSwitch.tsx +41 -0
- package/src/components/Icons/Sources/OrientationSwitchA.tsx +41 -0
- package/src/components/Icons/Sources/OrientationSwitchC.tsx +41 -0
- package/src/components/Icons/Sources/OrientationSwitchR.tsx +41 -0
- package/src/components/Icons/Sources/OrientationSwitchS.tsx +41 -0
- package/src/components/Icons/Sources/PanelRight.tsx +29 -0
- package/src/components/Icons/Sources/Patient.tsx +58 -0
- package/src/components/Icons/Sources/PatientStudyList.tsx +62 -0
- package/src/components/Icons/Sources/Pause.tsx +26 -0
- package/src/components/Icons/Sources/Pencil.tsx +16 -0
- package/src/components/Icons/Sources/Pin.tsx +50 -0
- package/src/components/Icons/Sources/PinFill.tsx +51 -0
- package/src/components/Icons/Sources/Play.tsx +25 -0
- package/src/components/Icons/Sources/Plus.tsx +29 -0
- package/src/components/Icons/Sources/PowerOff.tsx +19 -0
- package/src/components/Icons/Sources/Redo.tsx +51 -0
- package/src/components/Icons/Sources/Refresh.tsx +42 -0
- package/src/components/Icons/Sources/Rename.tsx +50 -0
- package/src/components/Icons/Sources/Search.tsx +35 -0
- package/src/components/Icons/Sources/SegActions.tsx +594 -0
- package/src/components/Icons/Sources/Series.tsx +47 -0
- package/src/components/Icons/Sources/SeriesPlaceholder.tsx +40 -0
- package/src/components/Icons/Sources/Settings.tsx +105 -0
- package/src/components/Icons/Sources/SettingsStudyList.tsx +28 -0
- package/src/components/Icons/Sources/Show.tsx +67 -0
- package/src/components/Icons/Sources/SidePanelCloseLeft.tsx +75 -0
- package/src/components/Icons/Sources/SidePanelCloseRight.tsx +74 -0
- package/src/components/Icons/Sources/SocialGithub.tsx +39 -0
- package/src/components/Icons/Sources/Sorting.tsx +39 -0
- package/src/components/Icons/Sources/SortingAscending.tsx +28 -0
- package/src/components/Icons/Sources/SortingDescending.tsx +26 -0
- package/src/components/Icons/Sources/SortingNew.tsx +20 -0
- package/src/components/Icons/Sources/SortingNewAscending.tsx +35 -0
- package/src/components/Icons/Sources/SortingNewDescending.tsx +35 -0
- package/src/components/Icons/Sources/StatusAlert.tsx +36 -0
- package/src/components/Icons/Sources/StatusError.tsx +57 -0
- package/src/components/Icons/Sources/StatusLocked.tsx +35 -0
- package/src/components/Icons/Sources/StatusSuccess.tsx +45 -0
- package/src/components/Icons/Sources/StatusTracking.tsx +37 -0
- package/src/components/Icons/Sources/StatusUntracked.tsx +30 -0
- package/src/components/Icons/Sources/StatusWarning.tsx +58 -0
- package/src/components/Icons/Sources/Tab4D.tsx +54 -0
- package/src/components/Icons/Sources/TabContours.tsx +63 -0
- package/src/components/Icons/Sources/TabLinear.tsx +47 -0
- package/src/components/Icons/Sources/TabPatientInfo.tsx +33 -0
- package/src/components/Icons/Sources/TabRoiThreshold.tsx +38 -0
- package/src/components/Icons/Sources/TabSegmentation.tsx +38 -0
- package/src/components/Icons/Sources/TabStudies.tsx +62 -0
- package/src/components/Icons/Sources/Threshold.tsx +38 -0
- package/src/components/Icons/Sources/ThumbnailView.tsx +67 -0
- package/src/components/Icons/Sources/Tools.tsx +3659 -0
- package/src/components/Icons/Sources/Trash.tsx +17 -0
- package/src/components/Icons/Sources/Undo.tsx +51 -0
- package/src/components/Icons/Sources/Upload.tsx +29 -0
- package/src/components/Icons/Sources/ViewportViews.tsx +45 -0
- package/src/components/Icons/Sources/ViewportWindowLevel.tsx +58 -0
- package/src/components/Icons/Sources/WindowLevelAdvanced.tsx +30 -0
- package/src/components/Icons/index.ts +4 -0
- package/src/components/Icons/types.ts +3 -0
- package/src/components/Input/Input.tsx +25 -0
- package/src/components/Input/index.tsx +3 -0
- package/src/components/InputFilter/InputFilter.tsx +200 -0
- package/src/components/InputFilter/index.ts +2 -0
- package/src/components/InputMultiSelect/InputMultiSelect.tsx +370 -0
- package/src/components/InputMultiSelect/index.ts +1 -0
- package/src/components/InputNumber/InputNumber.tsx +439 -0
- package/src/components/InputNumber/index.ts +3 -0
- package/src/components/InvestigationalUseDialog/InvestigationalUseDialog.tsx +98 -0
- package/src/components/InvestigationalUseDialog/index.ts +3 -0
- package/src/components/Label/Label.tsx +24 -0
- package/src/components/Label/index.tsx +3 -0
- package/src/components/Labelling/LabellingFlow.tsx +92 -0
- package/src/components/Labelling/index.ts +2 -0
- package/src/components/LayoutSelector/LayoutSelector.tsx +345 -0
- package/src/components/LayoutSelector/index.ts +4 -0
- package/src/components/LineChart/LineChart.css +40 -0
- package/src/components/LineChart/LineChart.tsx +101 -0
- package/src/components/LineChart/d3LineChart/chart.ts +365 -0
- package/src/components/LineChart/d3LineChart/events.ts +149 -0
- package/src/components/LineChart/d3LineChart/index.ts +3 -0
- package/src/components/LineChart/d3LineChart/lineChart.ts +272 -0
- package/src/components/LineChart/index.ts +1 -0
- package/src/components/LoadingIndicatorProgress/LoadingIndicatorProgress.tsx +29 -0
- package/src/components/LoadingIndicatorProgress/index.ts +2 -0
- package/src/components/LoadingIndicatorTotalPercent/LoadingIndicatorTotalPercent.tsx +49 -0
- package/src/components/LoadingIndicatorTotalPercent/index.ts +2 -0
- package/src/components/MeasurementTable/MeasurementTable.tsx +144 -0
- package/src/components/MeasurementTable/index.js +3 -0
- package/src/components/Modal/Modal.tsx +44 -0
- package/src/components/NavBar/NavBar.tsx +32 -0
- package/src/components/NavBar/index.js +2 -0
- package/src/components/Numeric/Numeric.test.ts +124 -0
- package/src/components/Numeric/Numeric.tsx +576 -0
- package/src/components/Numeric/index.ts +3 -0
- package/src/components/OHIFDialogs/InputDialog.tsx +287 -0
- package/src/components/OHIFDialogs/PresetDialog.tsx +106 -0
- package/src/components/OHIFDialogs/index.ts +2 -0
- package/src/components/OHIFModals/AboutModal.tsx +114 -0
- package/src/components/OHIFModals/AppearanceModal.tsx +38 -0
- package/src/components/OHIFModals/ImageModal.tsx +251 -0
- package/src/components/OHIFModals/UserPreferencesModal.tsx +229 -0
- package/src/components/OHIFModals/index.ts +4 -0
- package/src/components/OHIFPanels/WindowLevel.tsx +162 -0
- package/src/components/OHIFPanels/WindowLevelHistogram.tsx +237 -0
- package/src/components/OHIFPanels/index.ts +3 -0
- package/src/components/OHIFPanels/types.ts +41 -0
- package/src/components/OHIFToolSettings/RowDoubleRange.tsx +67 -0
- package/src/components/OHIFToolSettings/RowInputRange.tsx +65 -0
- package/src/components/OHIFToolSettings/RowSegmentedControl.tsx +77 -0
- package/src/components/OHIFToolSettings/ToolSettings.tsx +253 -0
- package/src/components/OHIFToolSettings/index.ts +1 -0
- package/src/components/OHIFToolbox/ToolboxUI.tsx +104 -0
- package/src/components/OHIFToolbox/index.ts +1 -0
- package/src/components/Onboarding/Onboarding.css +48 -0
- package/src/components/Onboarding/Onboarding.tsx +58 -0
- package/src/components/Onboarding/index.ts +3 -0
- package/src/components/Onboarding/utilities.ts +91 -0
- package/src/components/PanelSection/PanelSection.tsx +70 -0
- package/src/components/PanelSection/index.ts +2 -0
- package/src/components/Popover/Popover.tsx +35 -0
- package/src/components/Popover/index.ts +3 -0
- package/src/components/ProgressDropdown/ProgressDiscreteBar.tsx +24 -0
- package/src/components/ProgressDropdown/ProgressDropdown.tsx +158 -0
- package/src/components/ProgressDropdown/ProgressItem.tsx +27 -0
- package/src/components/ProgressDropdown/ProgressItemDetail.tsx +89 -0
- package/src/components/ProgressDropdown/index.ts +1 -0
- package/src/components/ProgressDropdown/types.ts +9 -0
- package/src/components/ProgressLoadingBar/ProgressLoadingBar.css +26 -0
- package/src/components/ProgressLoadingBar/ProgressLoadingBar.tsx +32 -0
- package/src/components/ProgressLoadingBar/index.ts +2 -0
- package/src/components/Resizable/Resizable.tsx +43 -0
- package/src/components/Resizable/index.ts +3 -0
- package/src/components/ScrollArea/ScrollArea.tsx +127 -0
- package/src/components/ScrollArea/index.tsx +3 -0
- package/src/components/SegmentationTable/AddSegmentRow.tsx +78 -0
- package/src/components/SegmentationTable/AddSegmentationRow.tsx +56 -0
- package/src/components/SegmentationTable/SegmentStatistics.tsx +104 -0
- package/src/components/SegmentationTable/SegmentationCollapsed.tsx +211 -0
- package/src/components/SegmentationTable/SegmentationExpanded.tsx +173 -0
- package/src/components/SegmentationTable/SegmentationHeader.tsx +58 -0
- package/src/components/SegmentationTable/SegmentationLabel.tsx +27 -0
- package/src/components/SegmentationTable/SegmentationSegments.tsx +206 -0
- package/src/components/SegmentationTable/SegmentationTable.tsx +169 -0
- package/src/components/SegmentationTable/SegmentationTableConfig.tsx +194 -0
- package/src/components/SegmentationTable/contexts/SegmentStatisticsContext.tsx +45 -0
- package/src/components/SegmentationTable/contexts/SegmentationExpandedContext.tsx +45 -0
- package/src/components/SegmentationTable/contexts/SegmentationTableContext.tsx +148 -0
- package/src/components/SegmentationTable/contexts/index.ts +16 -0
- package/src/components/SegmentationTable/index.ts +27 -0
- package/src/components/Select/Select.tsx +167 -0
- package/src/components/Select/index.tsx +40 -0
- package/src/components/Separator/Separator.tsx +32 -0
- package/src/components/Separator/index.ts +3 -0
- package/src/components/Separator/index.tsx +3 -0
- package/src/components/SidePanel/SidePanel.tsx +479 -0
- package/src/components/SidePanel/index.ts +2 -0
- package/src/components/Slider/Slider.tsx +24 -0
- package/src/components/Slider/index.tsx +3 -0
- package/src/components/SmartScrollbar/SmartScrollbar.tsx +349 -0
- package/src/components/SmartScrollbar/SmartScrollbarEndpoints.tsx +82 -0
- package/src/components/SmartScrollbar/SmartScrollbarFill.tsx +54 -0
- package/src/components/SmartScrollbar/SmartScrollbarIndicator.tsx +59 -0
- package/src/components/SmartScrollbar/SmartScrollbarTrack.tsx +104 -0
- package/src/components/SmartScrollbar/defaultSmartScrollbarIndicatorConfig.tsx +48 -0
- package/src/components/SmartScrollbar/index.ts +11 -0
- package/src/components/SmartScrollbar/useByteArray.ts +146 -0
- package/src/components/SmartScrollbar/utils.test.ts +124 -0
- package/src/components/SmartScrollbar/utils.ts +168 -0
- package/src/components/Sonner/Sonner.tsx +31 -0
- package/src/components/Sonner/index.ts +4 -0
- package/src/components/StudyBrowser/StudyBrowser.tsx +89 -0
- package/src/components/StudyBrowser/index.ts +2 -0
- package/src/components/StudyBrowserSort/StudyBrowserSort.tsx +87 -0
- package/src/components/StudyBrowserSort/index.ts +3 -0
- package/src/components/StudyBrowserViewOptions/StudyBrowserViewOptions.tsx +50 -0
- package/src/components/StudyBrowserViewOptions/index.ts +3 -0
- package/src/components/StudyItem/StudyItem.tsx +100 -0
- package/src/components/StudyItem/index.ts +2 -0
- package/src/components/StudyList/columns/defaultColumns.tsx +258 -0
- package/src/components/StudyList/components/ActionCell.tsx +19 -0
- package/src/components/StudyList/components/Layout.tsx +206 -0
- package/src/components/StudyList/components/PreviewContainer.tsx +45 -0
- package/src/components/StudyList/components/PreviewContent.tsx +186 -0
- package/src/components/StudyList/components/PreviewHeader.tsx +5 -0
- package/src/components/StudyList/components/PreviewPatientSummary.tsx +224 -0
- package/src/components/StudyList/components/PreviewSeriesList.tsx +64 -0
- package/src/components/StudyList/components/PreviewToggleButton.tsx +69 -0
- package/src/components/StudyList/components/SettingsPopover.tsx +214 -0
- package/src/components/StudyList/components/Table.tsx +247 -0
- package/src/components/StudyList/components/WorkflowMenu.tsx +72 -0
- package/src/components/StudyList/components/WorkflowsProvider.tsx +169 -0
- package/src/components/StudyList/hooks/useDefaultWorkflow.ts +60 -0
- package/src/components/StudyList/index.ts +52 -0
- package/src/components/StudyList/types/types.ts +42 -0
- package/src/components/StudyList/utils/tokenizeModalities.ts +6 -0
- package/src/components/StudySummary/StudySummary.tsx +27 -0
- package/src/components/StudySummary/index.tsx +3 -0
- package/src/components/Switch/Switch.tsx +28 -0
- package/src/components/Switch/index.tsx +3 -0
- package/src/components/Table/Table.tsx +134 -0
- package/src/components/Table/index.ts +11 -0
- package/src/components/Tabs/Tabs.tsx +56 -0
- package/src/components/Tabs/index.ts +3 -0
- package/src/components/Tabs/index.tsx +3 -0
- package/src/components/ThemeWrapper/ThemeWrapper.tsx +5 -0
- package/src/components/ThemeWrapper/index.ts +1 -0
- package/src/components/Thumbnail/Thumbnail.test.ts +71 -0
- package/src/components/Thumbnail/Thumbnail.tsx +351 -0
- package/src/components/Thumbnail/index.ts +2 -0
- package/src/components/ThumbnailList/ThumbnailList.tsx +94 -0
- package/src/components/ThumbnailList/index.ts +2 -0
- package/src/components/Toggle/Toggle.tsx +45 -0
- package/src/components/Toggle/index.ts +3 -0
- package/src/components/Toggle/index.tsx +3 -0
- package/src/components/ToggleGroup/ToggleGroup.tsx +63 -0
- package/src/components/ToggleGroup/index.ts +3 -0
- package/src/components/ToolButton/ToolButton.tsx +134 -0
- package/src/components/ToolButton/ToolButtonList.tsx +243 -0
- package/src/components/ToolButton/index.ts +8 -0
- package/src/components/Tooltip/Tooltip.tsx +34 -0
- package/src/components/Tooltip/index.ts +3 -0
- package/src/components/Viewport/ImageScrollbar.module.css +89 -0
- package/src/components/Viewport/ImageScrollbar.tsx +71 -0
- package/src/components/Viewport/PatientInfo.tsx +126 -0
- package/src/components/Viewport/ViewportActionArrows.tsx +36 -0
- package/src/components/Viewport/ViewportActionBar.tsx +107 -0
- package/src/components/Viewport/ViewportActionButton.tsx +25 -0
- package/src/components/Viewport/ViewportActionCorners.tsx +171 -0
- package/src/components/Viewport/ViewportGrid.tsx +24 -0
- package/src/components/Viewport/ViewportOverlay.css +32 -0
- package/src/components/Viewport/ViewportOverlay.tsx +54 -0
- package/src/components/Viewport/ViewportPane.tsx +82 -0
- package/src/components/Viewport/index.ts +9 -0
- package/src/components/ViewportDialog/ViewportDialog.tsx +128 -0
- package/src/components/ViewportDialog/index.ts +2 -0
- package/src/components/index.ts +330 -0
- package/src/contextProviders/ActiveThemeProvider.tsx +204 -0
- package/src/contextProviders/CineProvider.tsx +98 -0
- package/src/contextProviders/DialogProvider.tsx +103 -0
- package/src/contextProviders/DragAndDropProvider.tsx +37 -0
- package/src/contextProviders/IconPresentationProvider.tsx +88 -0
- package/src/contextProviders/ImageViewerProvider.tsx +15 -0
- package/src/contextProviders/ManagedDialog.tsx +176 -0
- package/src/contextProviders/ModalProvider.tsx +102 -0
- package/src/contextProviders/NotificationProvider.tsx +246 -0
- package/src/contextProviders/UserAuthenticationProvider.tsx +118 -0
- package/src/contextProviders/ViewportDialogProvider.tsx +42 -0
- package/src/contextProviders/ViewportGridProvider.tsx +556 -0
- package/src/contextProviders/index.ts +26 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useDynamicMaxHeight.ts +105 -0
- package/src/hooks/useSessionStorage.test.js +103 -0
- package/src/hooks/useSessionStorage.tsx +71 -0
- package/src/index.ts +7 -0
- package/src/lib/utils.ts +6 -0
- package/src/tailwind.css +266 -0
- package/src/themes/arctic.json +31 -0
- package/src/themes/deep.json +31 -0
- package/src/themes/index.ts +16 -0
- package/src/themes/midnight.json +31 -0
- package/src/themes/orchid.json +31 -0
- package/src/themes/slate.json +31 -0
- package/src/themes/themes.css +206 -0
- package/src/themes/verdant.json +31 -0
- package/src/types/ActionCorners.ts +18 -0
- package/src/types/AppTypes.ts +24 -0
- package/src/types/ContextMenuItem.ts +9 -0
- package/src/types/Predicate.ts +1 -0
- package/src/types/ThumbnailType.ts +3 -0
- package/src/types/ViewportActionCornersTypes.ts +13 -0
- package/src/types/global.d.ts +4 -0
- package/src/types/index.ts +21 -0
- package/src/utils/formatDICOMDate.test.ts +61 -0
- package/src/utils/formatDICOMDate.ts +65 -0
- package/src/utils/formatDICOMTime.test.ts +62 -0
- package/src/utils/formatDICOMTime.ts +49 -0
- package/src/utils/getToggledClassName.tsx +5 -0
- package/src/utils/index.ts +15 -0
- package/src/utils/parseStudyDateTimestamp.test.ts +47 -0
- package/src/utils/parseStudyDateTimestamp.ts +27 -0
- package/src/utils/roundNumber.ts +43 -0
- package/tailwind.config.js +120 -0
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
// This file is compiled by the React Compiler — there is no opt-out here.
|
|
2
|
+
//
|
|
3
|
+
// The contract that keeps it correct: TanStack state must never be read
|
|
4
|
+
// through an identity-stable object (a row, cell, column, or header) in
|
|
5
|
+
// render. The compiler caches such reads keyed on the object, which never
|
|
6
|
+
// changes, so the value freezes at mount. Read the replaced-on-change state
|
|
7
|
+
// object instead — table.state.<slice> — and derive from it, or hand the
|
|
8
|
+
// value in through a Subscribe boundary (see ColumnHeader). Method reads
|
|
9
|
+
// keyed on the `table` wrapper itself are safe: useTable returns a fresh
|
|
10
|
+
// wrapper whenever options or subscribed state change. Reads of static
|
|
11
|
+
// column config (columnDef, meta) are safe frozen. Event handlers may call
|
|
12
|
+
// anything — they execute fresh at event time.
|
|
13
|
+
|
|
14
|
+
import React, {
|
|
15
|
+
type ReactNode,
|
|
16
|
+
type ReactElement,
|
|
17
|
+
useState,
|
|
18
|
+
useCallback,
|
|
19
|
+
useEffect,
|
|
20
|
+
useRef,
|
|
21
|
+
Children,
|
|
22
|
+
isValidElement,
|
|
23
|
+
} from 'react';
|
|
24
|
+
import { useTranslation } from 'react-i18next';
|
|
25
|
+
import type {
|
|
26
|
+
ColumnDef,
|
|
27
|
+
ColumnFiltersState,
|
|
28
|
+
RowSelectionState,
|
|
29
|
+
ReactTable,
|
|
30
|
+
SortingState,
|
|
31
|
+
ColumnVisibilityState,
|
|
32
|
+
PaginationState,
|
|
33
|
+
Row,
|
|
34
|
+
} from '@tanstack/react-table';
|
|
35
|
+
import {
|
|
36
|
+
columnFilteringFeature,
|
|
37
|
+
columnVisibilityFeature,
|
|
38
|
+
createFilteredRowModel,
|
|
39
|
+
createPaginatedRowModel,
|
|
40
|
+
createSortedRowModel,
|
|
41
|
+
rowPaginationFeature,
|
|
42
|
+
rowSelectionFeature,
|
|
43
|
+
rowSortingFeature,
|
|
44
|
+
tableFeatures,
|
|
45
|
+
useTable,
|
|
46
|
+
flexRender,
|
|
47
|
+
} from '@tanstack/react-table';
|
|
48
|
+
import { DataTableContext, DataTableContextValue, useDataTable } from './context';
|
|
49
|
+
import { Toolbar } from './Toolbar';
|
|
50
|
+
import { Title } from './Title';
|
|
51
|
+
import { Pagination } from './Pagination';
|
|
52
|
+
import { ViewOptions } from './ViewOptions';
|
|
53
|
+
import { ActionOverlayCell } from './ActionOverlayCell';
|
|
54
|
+
import { FilterRow } from './FilterRow';
|
|
55
|
+
import { ColumnHeader } from './ColumnHeader';
|
|
56
|
+
import { ResponsiveColumnsProvider, useResponsiveColumns } from './useResponsiveColumns';
|
|
57
|
+
import type { ColumnMeta } from './types';
|
|
58
|
+
import {
|
|
59
|
+
Table as BasicTable,
|
|
60
|
+
TableHeader as BasicTableHeader,
|
|
61
|
+
TableBody as BasicTableBody,
|
|
62
|
+
TableHead as BasicTableHead,
|
|
63
|
+
TableRow as BasicTableRow,
|
|
64
|
+
TableCell as BasicTableCell,
|
|
65
|
+
} from '../Table';
|
|
66
|
+
import { ScrollArea } from '../ScrollArea';
|
|
67
|
+
import { cn } from '../../lib/utils';
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The feature set for every OHIF DataTable.
|
|
71
|
+
*
|
|
72
|
+
* Defined at module scope deliberately: v9 requires `features` to be stable, and
|
|
73
|
+
* a fresh object each render would invalidate every data-dependent model. The
|
|
74
|
+
* core row model is automatic in v9 and must not be registered here.
|
|
75
|
+
*
|
|
76
|
+
* Client-side filtering is always registered; the `manualFiltering` prop
|
|
77
|
+
* disables the filtering step at runtime, which is the supported way to support
|
|
78
|
+
* both client- and server-side filtering from one static feature set.
|
|
79
|
+
*/
|
|
80
|
+
export const dataTableFeatures = tableFeatures({
|
|
81
|
+
columnFilteringFeature,
|
|
82
|
+
columnVisibilityFeature,
|
|
83
|
+
rowPaginationFeature,
|
|
84
|
+
rowSelectionFeature,
|
|
85
|
+
rowSortingFeature,
|
|
86
|
+
filteredRowModel: createFilteredRowModel(),
|
|
87
|
+
paginatedRowModel: createPaginatedRowModel(),
|
|
88
|
+
sortedRowModel: createSortedRowModel(),
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export type DataTableFeatures = typeof dataTableFeatures;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Drops selected row ids that are absent from the table’s currently visible row
|
|
95
|
+
* model. Returns the given selection unchanged when every selected row is
|
|
96
|
+
* visible, so callers can use reference identity to detect “nothing to do”.
|
|
97
|
+
*/
|
|
98
|
+
function pruneToVisibleRows<TData>(
|
|
99
|
+
selection: RowSelectionState,
|
|
100
|
+
table: ReactTable<DataTableFeatures, TData>
|
|
101
|
+
): RowSelectionState {
|
|
102
|
+
const selectedIds = Object.keys(selection);
|
|
103
|
+
if (selectedIds.length === 0) {
|
|
104
|
+
return selection;
|
|
105
|
+
}
|
|
106
|
+
const rows = table.getPaginatedRowModel().rows;
|
|
107
|
+
const visibleIds = new Set(rows.map(r => r.id));
|
|
108
|
+
if (selectedIds.every(id => visibleIds.has(id))) {
|
|
109
|
+
return selection;
|
|
110
|
+
}
|
|
111
|
+
const next: RowSelectionState = {};
|
|
112
|
+
for (const id of selectedIds) {
|
|
113
|
+
if (visibleIds.has(id)) {
|
|
114
|
+
next[id] = selection[id];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return next;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Type for state update functions that accept either a value or an updater function
|
|
121
|
+
type Updater<T> = T | ((prev: T) => T);
|
|
122
|
+
type OnChangeFn<T> = (updater: Updater<T>) => void;
|
|
123
|
+
|
|
124
|
+
export type DataTableProps<TData> = {
|
|
125
|
+
data: TData[];
|
|
126
|
+
columns: ColumnDef<DataTableFeatures, TData, unknown>[];
|
|
127
|
+
getRowId?: (row: TData, index: number) => string;
|
|
128
|
+
initialVisibility?: ColumnVisibilityState;
|
|
129
|
+
sorting?: SortingState;
|
|
130
|
+
pagination?: PaginationState;
|
|
131
|
+
filters?: ColumnFiltersState;
|
|
132
|
+
onSortingChange?: OnChangeFn<SortingState>;
|
|
133
|
+
onPaginationChange?: OnChangeFn<PaginationState>;
|
|
134
|
+
onFiltersChange?: OnChangeFn<ColumnFiltersState>;
|
|
135
|
+
manualFiltering?: boolean;
|
|
136
|
+
enforceSingleSelection?: boolean;
|
|
137
|
+
onSelectionChange?: (rows: TData[]) => void;
|
|
138
|
+
children: ReactNode;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Root DataTable provider component.
|
|
143
|
+
* Creates the TanStack table instance, manages state, and exposes it via context.
|
|
144
|
+
*/
|
|
145
|
+
function DataTableRoot<TData>({
|
|
146
|
+
data,
|
|
147
|
+
columns,
|
|
148
|
+
getRowId,
|
|
149
|
+
initialVisibility = {},
|
|
150
|
+
sorting = [],
|
|
151
|
+
pagination = { pageIndex: 0, pageSize: 50 },
|
|
152
|
+
filters = [],
|
|
153
|
+
onSortingChange,
|
|
154
|
+
onPaginationChange,
|
|
155
|
+
onFiltersChange,
|
|
156
|
+
manualFiltering = false,
|
|
157
|
+
enforceSingleSelection = true,
|
|
158
|
+
onSelectionChange,
|
|
159
|
+
children,
|
|
160
|
+
}: DataTableProps<TData>) {
|
|
161
|
+
const [columnVisibility, setColumnVisibility] =
|
|
162
|
+
useState<ColumnVisibilityState>(initialVisibility);
|
|
163
|
+
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
|
164
|
+
|
|
165
|
+
const table = useTable<DataTableFeatures, TData>({
|
|
166
|
+
features: dataTableFeatures,
|
|
167
|
+
data,
|
|
168
|
+
columns,
|
|
169
|
+
state: { sorting, columnVisibility, rowSelection, columnFilters: filters, pagination },
|
|
170
|
+
onSortingChange: onSortingChange,
|
|
171
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
172
|
+
onRowSelectionChange: setRowSelection,
|
|
173
|
+
onColumnFiltersChange: onFiltersChange,
|
|
174
|
+
onPaginationChange: onPaginationChange,
|
|
175
|
+
manualFiltering,
|
|
176
|
+
enableRowSelection: true,
|
|
177
|
+
enableMultiRowSelection: !enforceSingleSelection,
|
|
178
|
+
getRowId,
|
|
179
|
+
autoResetPageIndex: false,
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// Invariant: if a row id is in rowSelection, that row is on screen. Enforced
|
|
183
|
+
// in this one place so every reader — this component, its subcomponents, and
|
|
184
|
+
// onSelectionChange — gets the same answer with nothing to remember. Keeping
|
|
185
|
+
// off-screen rows selected and filtering at each point of use instead would
|
|
186
|
+
// leave two competing notions of what is selected, with the stored one as the
|
|
187
|
+
// wrong default.
|
|
188
|
+
//
|
|
189
|
+
// Adjusted during render rather than from an effect: React discards this
|
|
190
|
+
// render and re-runs it immediately with the corrected state, so there is no
|
|
191
|
+
// second commit and the stale selection is never painted.
|
|
192
|
+
//
|
|
193
|
+
// Convergence is on us. react-hooks/set-state-in-render permits any guarded
|
|
194
|
+
// set-state during render without checking that the guard settles, so what
|
|
195
|
+
// stops the re-render here is pruneToVisibleRows being idempotent and
|
|
196
|
+
// returning its argument unchanged when every selected row is already visible.
|
|
197
|
+
const prunedSelection = pruneToVisibleRows(rowSelection, table);
|
|
198
|
+
if (prunedSelection !== rowSelection) {
|
|
199
|
+
setRowSelection(prunedSelection);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Reset pagination to page 0 when filters or sorting change, but only when
|
|
203
|
+
// pagination itself did not change in the same render. A simultaneous
|
|
204
|
+
// pagination change means the caller set the page intentionally (e.g. a
|
|
205
|
+
// coordinated state restore), so we leave it alone.
|
|
206
|
+
// The refs are initialized to the mount-time values so the first effect run
|
|
207
|
+
// always sees all three as unchanged — ensuring that
|
|
208
|
+
// any pagination applied with filtering or sorting during the initial render
|
|
209
|
+
// is not overridden.
|
|
210
|
+
const prevFiltersRef = useRef(filters);
|
|
211
|
+
const prevSortingRef = useRef(sorting);
|
|
212
|
+
const prevPaginationRef = useRef(pagination);
|
|
213
|
+
|
|
214
|
+
useEffect(() => {
|
|
215
|
+
const filtersChanged = filters !== prevFiltersRef.current;
|
|
216
|
+
const sortingChanged = sorting !== prevSortingRef.current;
|
|
217
|
+
const paginationChanged = pagination !== prevPaginationRef.current;
|
|
218
|
+
prevFiltersRef.current = filters;
|
|
219
|
+
prevSortingRef.current = sorting;
|
|
220
|
+
prevPaginationRef.current = pagination;
|
|
221
|
+
|
|
222
|
+
if ((filtersChanged || sortingChanged) && !paginationChanged && onPaginationChange) {
|
|
223
|
+
onPaginationChange(p => ({ ...p, pageIndex: 0 }));
|
|
224
|
+
}
|
|
225
|
+
}, [filters, sorting, pagination, onPaginationChange]);
|
|
226
|
+
|
|
227
|
+
// Surface selection changes to consumers. Safe to read the selection whole:
|
|
228
|
+
// it is pruned to the visible rows above, so it can never contain a row the
|
|
229
|
+
// user cannot see.
|
|
230
|
+
useEffect(() => {
|
|
231
|
+
if (!onSelectionChange) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
onSelectionChange(table.getSelectedRowModel().rows.map(r => r.original as TData));
|
|
235
|
+
}, [rowSelection, onSelectionChange, table]);
|
|
236
|
+
|
|
237
|
+
return (
|
|
238
|
+
<DataTableContext.Provider value={{ table } as DataTableContextValue<unknown>}>
|
|
239
|
+
<ResponsiveColumnsProvider>{children}</ResponsiveColumnsProvider>
|
|
240
|
+
</DataTableContext.Provider>
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
type TableProps = {
|
|
245
|
+
children?: ReactNode;
|
|
246
|
+
/**
|
|
247
|
+
* Optional className applied to the outer bordered container.
|
|
248
|
+
*/
|
|
249
|
+
className?: string;
|
|
250
|
+
/**
|
|
251
|
+
* Optional className applied to the underlying <table> in both header and body tables.
|
|
252
|
+
*/
|
|
253
|
+
tableClassName?: string;
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Layout shell that renders:
|
|
258
|
+
* - A header table (column headers + optional filter row).
|
|
259
|
+
* - A scrollable body table.
|
|
260
|
+
*
|
|
261
|
+
* Consumers pass <DataTable.Header />, <DataTable.FilterRow />, and <DataTable.Body />
|
|
262
|
+
* as children; this component wires them into the correct structure.
|
|
263
|
+
*/
|
|
264
|
+
function Table<TData>({ children, className, tableClassName }: TableProps) {
|
|
265
|
+
const { table } = useDataTable<TData>();
|
|
266
|
+
const wrapperRef = useRef<HTMLDivElement>(null);
|
|
267
|
+
// Drive responsive column visibility from the wrapper's width. The hook
|
|
268
|
+
// is a no-op for tables whose columns don't declare meta.priority, and
|
|
269
|
+
// publishes the "unfit" set through ResponsiveColumnsProvider (rendered
|
|
270
|
+
// by DataTableRoot above us in the tree).
|
|
271
|
+
useResponsiveColumns(table, wrapperRef);
|
|
272
|
+
|
|
273
|
+
const rows = table.getPaginatedRowModel().rows;
|
|
274
|
+
const isEmpty = rows.length === 0;
|
|
275
|
+
|
|
276
|
+
const renderColGroup = useCallback(
|
|
277
|
+
() => (
|
|
278
|
+
<colgroup>
|
|
279
|
+
{table.getVisibleLeafColumns().map(col => {
|
|
280
|
+
const meta = (col.columnDef.meta as ColumnMeta | undefined) ?? undefined;
|
|
281
|
+
const minWidth = meta?.minWidth;
|
|
282
|
+
return minWidth ? (
|
|
283
|
+
<col
|
|
284
|
+
key={col.id}
|
|
285
|
+
style={{
|
|
286
|
+
width: typeof minWidth === 'number' ? `${minWidth}px` : minWidth,
|
|
287
|
+
}}
|
|
288
|
+
/>
|
|
289
|
+
) : (
|
|
290
|
+
<col key={col.id} />
|
|
291
|
+
);
|
|
292
|
+
})}
|
|
293
|
+
</colgroup>
|
|
294
|
+
),
|
|
295
|
+
[table]
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
let headerChild: ReactElement<any> | null = null;
|
|
299
|
+
let filterRowChild: ReactElement<any> | null = null;
|
|
300
|
+
let bodyChild: ReactElement<any> | null = null;
|
|
301
|
+
|
|
302
|
+
Children.forEach(children, child => {
|
|
303
|
+
if (!isValidElement(child)) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
if (child.type === Header) {
|
|
307
|
+
headerChild = child;
|
|
308
|
+
}
|
|
309
|
+
if (child.type === FilterRow) {
|
|
310
|
+
filterRowChild = child;
|
|
311
|
+
}
|
|
312
|
+
if (child.type === Body) {
|
|
313
|
+
bodyChild = child;
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
return (
|
|
318
|
+
<div
|
|
319
|
+
ref={wrapperRef}
|
|
320
|
+
className={cn('border-input/50 min-h-0 flex-1 rounded-md border', className)}
|
|
321
|
+
>
|
|
322
|
+
<div className="flex h-full flex-col">
|
|
323
|
+
{/* Header + filter row */}
|
|
324
|
+
<div className="border-input/50 shrink-0 border-b">
|
|
325
|
+
<BasicTable
|
|
326
|
+
className={cn('table-fixed', tableClassName)}
|
|
327
|
+
containerClassName="overflow-x-hidden"
|
|
328
|
+
noScroll
|
|
329
|
+
>
|
|
330
|
+
{renderColGroup()}
|
|
331
|
+
{headerChild}
|
|
332
|
+
<BasicTableBody>{filterRowChild}</BasicTableBody>
|
|
333
|
+
</BasicTable>
|
|
334
|
+
</div>
|
|
335
|
+
|
|
336
|
+
{/* Scrollable body */}
|
|
337
|
+
<div className="min-h-0 flex-1">
|
|
338
|
+
<ScrollArea className={cn('h-full', isEmpty && '[&>div>div]:!h-full')}>
|
|
339
|
+
<BasicTable
|
|
340
|
+
className={cn('h-full table-fixed', tableClassName)}
|
|
341
|
+
containerClassName="h-full"
|
|
342
|
+
noScroll
|
|
343
|
+
>
|
|
344
|
+
{renderColGroup()}
|
|
345
|
+
<BasicTableBody>{bodyChild}</BasicTableBody>
|
|
346
|
+
</BasicTable>
|
|
347
|
+
</ScrollArea>
|
|
348
|
+
</div>
|
|
349
|
+
</div>
|
|
350
|
+
</div>
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Renders the table header row(s) based on the current table instance.
|
|
356
|
+
* Applies meta.headerClassName and a muted background for visual separation from the body.
|
|
357
|
+
*/
|
|
358
|
+
function Header<TData>() {
|
|
359
|
+
const { table } = useDataTable<TData>();
|
|
360
|
+
// getHeaderGroups() is identity-stable across a sort change (header groups
|
|
361
|
+
// do not derive from sorting), so the loop below would not re-run for one.
|
|
362
|
+
// Reading the sorting state here — an object replaced on every change —
|
|
363
|
+
// and deriving each column's direction from it makes sorting a dependency
|
|
364
|
+
// of the loop.
|
|
365
|
+
const sorting = table.state.sorting;
|
|
366
|
+
|
|
367
|
+
return (
|
|
368
|
+
<BasicTableHeader>
|
|
369
|
+
{table.getHeaderGroups().map(headerGroup => (
|
|
370
|
+
<BasicTableRow key={headerGroup.id}>
|
|
371
|
+
{headerGroup.headers.map(header => {
|
|
372
|
+
const meta = (header.column.columnDef.meta as ColumnMeta | undefined) ?? undefined;
|
|
373
|
+
const headerClassName = meta?.headerClassName ?? '';
|
|
374
|
+
const sortEntry = sorting.find(s => s.id === header.column.id);
|
|
375
|
+
const sortState = sortEntry ? (sortEntry.desc ? 'desc' : 'asc') : false;
|
|
376
|
+
|
|
377
|
+
return (
|
|
378
|
+
<BasicTableHead
|
|
379
|
+
key={header.id}
|
|
380
|
+
className={cn('bg-muted', headerClassName)}
|
|
381
|
+
aria-sort={
|
|
382
|
+
sortState === 'asc' ? 'ascending' : sortState === 'desc' ? 'descending' : 'none'
|
|
383
|
+
}
|
|
384
|
+
>
|
|
385
|
+
{header.isPlaceholder
|
|
386
|
+
? null
|
|
387
|
+
: flexRender(header.column.columnDef.header, header.getContext())}
|
|
388
|
+
</BasicTableHead>
|
|
389
|
+
);
|
|
390
|
+
})}
|
|
391
|
+
</BasicTableRow>
|
|
392
|
+
))}
|
|
393
|
+
</BasicTableHeader>
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
type RowProps<TData> = {
|
|
398
|
+
render?: (row: Row<DataTableFeatures, TData>) => ReactNode;
|
|
399
|
+
onClick?: (row: Row<DataTableFeatures, TData>) => void;
|
|
400
|
+
onDoubleClick?: (row: Row<DataTableFeatures, TData>) => void;
|
|
401
|
+
className?: string | ((row: Row<DataTableFeatures, TData>) => string);
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
type BodyProps<TData> = {
|
|
405
|
+
rowProps?: RowProps<TData>;
|
|
406
|
+
/**
|
|
407
|
+
* Message shown when there are no rows to render.
|
|
408
|
+
*/
|
|
409
|
+
emptyMessage?: string;
|
|
410
|
+
/**
|
|
411
|
+
* When true and there are no rows, show loadingComponent centered instead of emptyMessage.
|
|
412
|
+
*/
|
|
413
|
+
isLoading?: boolean;
|
|
414
|
+
/**
|
|
415
|
+
* Rendered in the empty body when isLoading is true (e.g. customization loading indicator).
|
|
416
|
+
*/
|
|
417
|
+
loadingComponent?: ReactNode;
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Core body renderer. Keeps awareness of selection state via data-state="selected".
|
|
422
|
+
* Every DataTable is paginated: the paginated row model is registered statically
|
|
423
|
+
* in dataTableFeatures and pagination state always has a default.
|
|
424
|
+
* Consumers can either rely on the default row renderer or provide a custom one.
|
|
425
|
+
*/
|
|
426
|
+
function Body<TData>({ rowProps, emptyMessage, isLoading, loadingComponent }: BodyProps<TData>) {
|
|
427
|
+
const { t } = useTranslation('DataTable');
|
|
428
|
+
const resolvedEmptyMessage = emptyMessage ?? t('No results.');
|
|
429
|
+
const { table } = useDataTable<TData>();
|
|
430
|
+
|
|
431
|
+
// The row-model array is identity-stable across selection and visibility
|
|
432
|
+
// changes (row models derive from data/filters/sorting/pagination only), so
|
|
433
|
+
// the row loop below would not re-run for either. Reading both state
|
|
434
|
+
// objects here — each replaced on every change — and deriving per-row
|
|
435
|
+
// selection and per-row cells from them makes both dependencies of the loop.
|
|
436
|
+
const rowSelection = table.state.rowSelection;
|
|
437
|
+
const columnVisibility = table.state.columnVisibility;
|
|
438
|
+
|
|
439
|
+
// Automatically determine if pagination should be used
|
|
440
|
+
// Use pagination if getPaginatedRowModel is defined (pagination is configured)
|
|
441
|
+
const rows = table.getPaginatedRowModel().rows;
|
|
442
|
+
|
|
443
|
+
if (!rows.length) {
|
|
444
|
+
if (isLoading && loadingComponent) {
|
|
445
|
+
return (
|
|
446
|
+
<BasicTableRow className="hover:bg-transparent hover:text-inherit hover:[&>td]:text-inherit hover:[&>th]:text-inherit">
|
|
447
|
+
<BasicTableCell colSpan={table.getAllLeafColumns().length}>
|
|
448
|
+
<div className="flex h-full w-full items-center justify-center">{loadingComponent}</div>
|
|
449
|
+
</BasicTableCell>
|
|
450
|
+
</BasicTableRow>
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
return (
|
|
454
|
+
<BasicTableRow className="hover:bg-transparent hover:text-inherit hover:[&>td]:text-inherit hover:[&>th]:text-inherit">
|
|
455
|
+
<BasicTableCell
|
|
456
|
+
colSpan={table.getAllLeafColumns().length}
|
|
457
|
+
className="!pt-10 text-center align-text-top"
|
|
458
|
+
>
|
|
459
|
+
{resolvedEmptyMessage}
|
|
460
|
+
</BasicTableCell>
|
|
461
|
+
</BasicTableRow>
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
return (
|
|
466
|
+
<>
|
|
467
|
+
{rows.map(row => {
|
|
468
|
+
const customRender = rowProps?.render?.(row);
|
|
469
|
+
|
|
470
|
+
if (customRender) {
|
|
471
|
+
return customRender;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
const isSelected = rowSelection[row.id] === true;
|
|
475
|
+
// Default row rendering
|
|
476
|
+
return (
|
|
477
|
+
<BasicTableRow
|
|
478
|
+
key={row.id}
|
|
479
|
+
data-state={isSelected ? 'selected' : undefined}
|
|
480
|
+
className={
|
|
481
|
+
rowProps?.className
|
|
482
|
+
? typeof rowProps.className === 'function'
|
|
483
|
+
? rowProps.className(row)
|
|
484
|
+
: rowProps.className
|
|
485
|
+
: ''
|
|
486
|
+
}
|
|
487
|
+
{...(rowProps?.onClick && { onClick: () => rowProps.onClick(row) })}
|
|
488
|
+
{...(rowProps?.onDoubleClick && {
|
|
489
|
+
onDoubleClick: () => rowProps.onDoubleClick(row),
|
|
490
|
+
})}
|
|
491
|
+
aria-selected={isSelected}
|
|
492
|
+
>
|
|
493
|
+
{/* Cells are derived through the visibility map read above rather
|
|
494
|
+
than row.getVisibleCells(), whose result is reachable only via
|
|
495
|
+
the identity-stable row. Equivalent while this table has no
|
|
496
|
+
column ordering/pinning/grouping features. */}
|
|
497
|
+
{row
|
|
498
|
+
.getAllCells()
|
|
499
|
+
.filter(cell => columnVisibility[cell.column.id] !== false)
|
|
500
|
+
.map(cell => {
|
|
501
|
+
const metaClass =
|
|
502
|
+
(cell.column.columnDef.meta as ColumnMeta | undefined)?.cellClassName ?? '';
|
|
503
|
+
return (
|
|
504
|
+
<BasicTableCell
|
|
505
|
+
key={cell.id}
|
|
506
|
+
className={metaClass}
|
|
507
|
+
>
|
|
508
|
+
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
|
509
|
+
</BasicTableCell>
|
|
510
|
+
);
|
|
511
|
+
})}
|
|
512
|
+
</BasicTableRow>
|
|
513
|
+
);
|
|
514
|
+
})}
|
|
515
|
+
</>
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
const DataTable = Object.assign(DataTableRoot, {
|
|
520
|
+
Toolbar,
|
|
521
|
+
Title,
|
|
522
|
+
Pagination,
|
|
523
|
+
ViewOptions,
|
|
524
|
+
Table,
|
|
525
|
+
Header,
|
|
526
|
+
FilterRow,
|
|
527
|
+
Body,
|
|
528
|
+
ColumnHeader,
|
|
529
|
+
ActionOverlayCell,
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
export { DataTable };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TableRow, TableCell } from '../Table';
|
|
3
|
+
import { Input } from '../Input';
|
|
4
|
+
|
|
5
|
+
import { useDataTable } from './context';
|
|
6
|
+
|
|
7
|
+
export type FilterRowProps = {
|
|
8
|
+
excludeColumnIds?: string[];
|
|
9
|
+
renderFilterCell?: (opts: {
|
|
10
|
+
columnId: string;
|
|
11
|
+
value: unknown;
|
|
12
|
+
setValue: (v: unknown) => void;
|
|
13
|
+
}) => React.ReactNode;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export function FilterRow<TData>({ excludeColumnIds = [], renderFilterCell }: FilterRowProps) {
|
|
17
|
+
const { table } = useDataTable<TData>();
|
|
18
|
+
const cols = table.getVisibleLeafColumns();
|
|
19
|
+
return (
|
|
20
|
+
<TableRow
|
|
21
|
+
data-filter-row
|
|
22
|
+
className="hover:bg-transparent"
|
|
23
|
+
>
|
|
24
|
+
{cols.map(col => {
|
|
25
|
+
const id = col.id;
|
|
26
|
+
const value = table.getColumn(id)?.getFilterValue();
|
|
27
|
+
const setValue = (v: unknown) => table.getColumn(id)?.setFilterValue(v);
|
|
28
|
+
|
|
29
|
+
if (excludeColumnIds?.includes(id)) {
|
|
30
|
+
return <TableCell key={id} />;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const customRender = renderFilterCell?.({ columnId: id, value, setValue });
|
|
34
|
+
|
|
35
|
+
if (customRender) {
|
|
36
|
+
return <TableCell key={id}>{customRender}</TableCell>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Default cell rendering
|
|
40
|
+
return (
|
|
41
|
+
<TableCell key={id}>
|
|
42
|
+
<Input
|
|
43
|
+
value={(value as string) ?? ''}
|
|
44
|
+
onChange={e => setValue(e.target.value)}
|
|
45
|
+
className="h-7 w-full"
|
|
46
|
+
/>
|
|
47
|
+
</TableCell>
|
|
48
|
+
);
|
|
49
|
+
})}
|
|
50
|
+
</TableRow>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Button } from '../Button';
|
|
3
|
+
import {
|
|
4
|
+
DropdownMenu,
|
|
5
|
+
DropdownMenuTrigger,
|
|
6
|
+
DropdownMenuContent,
|
|
7
|
+
DropdownMenuItem,
|
|
8
|
+
} from '../DropdownMenu';
|
|
9
|
+
import { Icons } from '../Icons';
|
|
10
|
+
import { useDataTable } from './context';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Pagination
|
|
14
|
+
* Renders "start-end of total" and ghost chevron buttons for prev/next.
|
|
15
|
+
* Uses the TanStack table instance from DataTable context.
|
|
16
|
+
*/
|
|
17
|
+
export function Pagination<TData>() {
|
|
18
|
+
const { table } = useDataTable<TData>();
|
|
19
|
+
const { pageIndex, pageSize } = table.state.pagination ?? { pageIndex: 0, pageSize: 50 };
|
|
20
|
+
|
|
21
|
+
const total = table.getFilteredRowModel().rows.length;
|
|
22
|
+
const start = total === 0 ? 0 : pageIndex * pageSize + 1;
|
|
23
|
+
const end = Math.min(total, (pageIndex + 1) * pageSize);
|
|
24
|
+
|
|
25
|
+
const canPrev = table.getCanPreviousPage();
|
|
26
|
+
const canNext = table.getCanNextPage();
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div className="mr-2 flex items-center gap-0.5">
|
|
30
|
+
<DropdownMenu>
|
|
31
|
+
<DropdownMenuTrigger asChild>
|
|
32
|
+
<Button
|
|
33
|
+
variant="ghost"
|
|
34
|
+
size="sm"
|
|
35
|
+
className="text-primary/80 px-2 text-sm leading-tight"
|
|
36
|
+
aria-label="Rows per page"
|
|
37
|
+
>
|
|
38
|
+
{`${start}-${end} of ${total}`}
|
|
39
|
+
</Button>
|
|
40
|
+
</DropdownMenuTrigger>
|
|
41
|
+
<DropdownMenuContent align="start">
|
|
42
|
+
{[25, 50, 100].map(size => (
|
|
43
|
+
<DropdownMenuItem
|
|
44
|
+
key={size}
|
|
45
|
+
onSelect={e => {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
table.setPageSize(size);
|
|
48
|
+
}}
|
|
49
|
+
className="flex items-center gap-[2px]"
|
|
50
|
+
>
|
|
51
|
+
<Icons.Checked className={`h-6 w-6 ${pageSize === size ? '' : 'invisible'}`} />
|
|
52
|
+
{size} per page
|
|
53
|
+
</DropdownMenuItem>
|
|
54
|
+
))}
|
|
55
|
+
</DropdownMenuContent>
|
|
56
|
+
</DropdownMenu>
|
|
57
|
+
<Button
|
|
58
|
+
variant="ghost"
|
|
59
|
+
size="icon"
|
|
60
|
+
aria-label="Previous page"
|
|
61
|
+
onClick={() => table.previousPage()}
|
|
62
|
+
disabled={!canPrev}
|
|
63
|
+
className="ml-1"
|
|
64
|
+
>
|
|
65
|
+
<Icons.ChevronLeft className="h-3 w-3" />
|
|
66
|
+
</Button>
|
|
67
|
+
<Button
|
|
68
|
+
variant="ghost"
|
|
69
|
+
size="icon"
|
|
70
|
+
aria-label="Next page"
|
|
71
|
+
onClick={() => table.nextPage()}
|
|
72
|
+
disabled={!canNext}
|
|
73
|
+
>
|
|
74
|
+
<Icons.ChevronRight className="h-3 w-3" />
|
|
75
|
+
</Button>
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
}
|