@ohif/ui-next 3.14.0-beta.1 → 3.14.0-beta.100
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 +7 -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 +15 -0
- package/src/components/SegmentationTable/index.ts +24 -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 +323 -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,98 @@
|
|
|
1
|
+
import React, { createContext, useContext, useEffect, useReducer } from 'react';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_STATE = {
|
|
4
|
+
isCineEnabled: false,
|
|
5
|
+
cines: {
|
|
6
|
+
/*
|
|
7
|
+
* viewportId: { isPlaying: false, frameRate: 24 };
|
|
8
|
+
*/
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const DEFAULT_CINE = { isPlaying: false, frameRate: 24 };
|
|
13
|
+
|
|
14
|
+
export const CineContext = createContext(null);
|
|
15
|
+
|
|
16
|
+
export default function CineProvider({ children, service }) {
|
|
17
|
+
const reducer = (state, action) => {
|
|
18
|
+
switch (action.type) {
|
|
19
|
+
case 'SET_CINE': {
|
|
20
|
+
const { id, frameRate, isPlaying = undefined } = action.payload;
|
|
21
|
+
const cines = state.cines;
|
|
22
|
+
|
|
23
|
+
const syncedCineIds = service.getSyncedViewports(id).map(({ viewportId }) => viewportId);
|
|
24
|
+
const cineIdsToUpdate = [id, ...syncedCineIds].filter(curId => {
|
|
25
|
+
const currentCine = cines[curId] ?? {};
|
|
26
|
+
const shouldUpdateFrameRate =
|
|
27
|
+
currentCine.frameRate !== (frameRate ?? currentCine.frameRate);
|
|
28
|
+
const shouldUpdateIsPlaying =
|
|
29
|
+
currentCine.isPlaying !== (isPlaying ?? currentCine.isPlaying);
|
|
30
|
+
|
|
31
|
+
return shouldUpdateFrameRate || shouldUpdateIsPlaying;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
cineIdsToUpdate.forEach(currId => {
|
|
35
|
+
let cine = cines[currId];
|
|
36
|
+
|
|
37
|
+
if (!cine) {
|
|
38
|
+
cine = { id, ...DEFAULT_CINE };
|
|
39
|
+
cines[currId] = cine;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
cine.frameRate = frameRate ?? cine.frameRate;
|
|
43
|
+
cine.isPlaying = isPlaying ?? cine.isPlaying;
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return { ...state, ...cines };
|
|
47
|
+
}
|
|
48
|
+
case 'SET_IS_CINE_ENABLED': {
|
|
49
|
+
return { ...state, ...{ isCineEnabled: action.payload } };
|
|
50
|
+
}
|
|
51
|
+
default:
|
|
52
|
+
return action.payload;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const [state, dispatch] = useReducer(reducer, DEFAULT_STATE);
|
|
57
|
+
|
|
58
|
+
const getState = () => state;
|
|
59
|
+
|
|
60
|
+
const setIsCineEnabled = isCineEnabled =>
|
|
61
|
+
dispatch({ type: 'SET_IS_CINE_ENABLED', payload: isCineEnabled });
|
|
62
|
+
|
|
63
|
+
const setCine = ({ id, frameRate, isPlaying }) =>
|
|
64
|
+
dispatch({
|
|
65
|
+
type: 'SET_CINE',
|
|
66
|
+
payload: {
|
|
67
|
+
id,
|
|
68
|
+
frameRate,
|
|
69
|
+
isPlaying,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Sets the implementation of a modal service that can be used by extensions.
|
|
75
|
+
*
|
|
76
|
+
* @returns void
|
|
77
|
+
*/
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (service) {
|
|
80
|
+
service.setServiceImplementation({ getState, setIsCineEnabled, setCine });
|
|
81
|
+
}
|
|
82
|
+
}, [getState, service, setCine, setIsCineEnabled]);
|
|
83
|
+
|
|
84
|
+
const api = {
|
|
85
|
+
getState,
|
|
86
|
+
setCine,
|
|
87
|
+
setIsCineEnabled: isCineEnabled => service.setIsCineEnabled(isCineEnabled),
|
|
88
|
+
playClip: (element, playClipOptions) => service.playClip(element, playClipOptions),
|
|
89
|
+
stopClip: (element, stopClipOptions) => service.stopClip(element, stopClipOptions),
|
|
90
|
+
setViewportCineClosed: viewportId => service.setViewportCineClosed(viewportId),
|
|
91
|
+
clearViewportCineClosed: viewportId => service.clearViewportCineClosed(viewportId),
|
|
92
|
+
isViewportCineClosed: viewportId => service.isViewportCineClosed(viewportId),
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
return <CineContext.Provider value={[state, api]}>{children}</CineContext.Provider>;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export const useCine = () => useContext(CineContext);
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import React, { useState, createContext, useContext, useEffect, useRef } from 'react';
|
|
2
|
+
import ManagedDialog, { ManagedDialogProps, ManagedDialogRef } from './ManagedDialog';
|
|
3
|
+
|
|
4
|
+
interface DialogContextType {
|
|
5
|
+
show: (options: ManagedDialogProps) => string;
|
|
6
|
+
hide: (id: string) => void;
|
|
7
|
+
hideAll: () => void;
|
|
8
|
+
isEmpty: () => boolean;
|
|
9
|
+
updatePosition: (id: string, position: { x: number; y: number }) => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface DialogService {
|
|
13
|
+
setServiceImplementation: (implementation: DialogContextType) => void;
|
|
14
|
+
getCustomComponent?: () => React.ComponentType<ManagedDialogProps> | null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface DialogProviderProps {
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
dialog?: React.ComponentType<ManagedDialogProps>;
|
|
20
|
+
service?: DialogService | null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const DialogContext = createContext<DialogContextType | null>(null);
|
|
24
|
+
|
|
25
|
+
export const useDialog = () => {
|
|
26
|
+
const context = useContext(DialogContext);
|
|
27
|
+
if (!context) {
|
|
28
|
+
throw new Error('useDialog must be used within a DialogProvider');
|
|
29
|
+
}
|
|
30
|
+
return context;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const DialogProvider: React.FC<DialogProviderProps> = ({
|
|
34
|
+
children,
|
|
35
|
+
dialog: DialogComponent = ManagedDialog,
|
|
36
|
+
service = null,
|
|
37
|
+
}) => {
|
|
38
|
+
const [dialogs, setDialogs] = useState<(ManagedDialogProps & { id: string })[]>([]);
|
|
39
|
+
const dialogRefs = useRef<Map<string, ManagedDialogRef>>(new Map());
|
|
40
|
+
|
|
41
|
+
const show = (options: ManagedDialogProps) => {
|
|
42
|
+
const id = options.id;
|
|
43
|
+
setDialogs(prev => [...prev, { ...options, id }]);
|
|
44
|
+
return id;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const hide = (id: string) => {
|
|
48
|
+
setDialogs(prev => prev.filter(dialog => dialog.id !== id));
|
|
49
|
+
dialogRefs.current.delete(id);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const hideAll = () => {
|
|
53
|
+
setDialogs([]);
|
|
54
|
+
dialogRefs.current.clear();
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const isEmpty = () => dialogs.length === 0;
|
|
58
|
+
|
|
59
|
+
const updatePosition = (id: string, position: { x: number; y: number }) => {
|
|
60
|
+
const dialogRef = dialogRefs.current.get(id);
|
|
61
|
+
if (dialogRef) {
|
|
62
|
+
dialogRef.updatePosition(position);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const contextValue = {
|
|
67
|
+
show,
|
|
68
|
+
hide,
|
|
69
|
+
hideAll,
|
|
70
|
+
isEmpty,
|
|
71
|
+
updatePosition,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (service) {
|
|
76
|
+
service.setServiceImplementation(contextValue);
|
|
77
|
+
}
|
|
78
|
+
}, [service, contextValue]);
|
|
79
|
+
|
|
80
|
+
const CustomDialog = service?.getCustomComponent?.();
|
|
81
|
+
const RenderedDialog = CustomDialog || DialogComponent;
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<DialogContext.Provider value={contextValue}>
|
|
85
|
+
{dialogs.map(dialog => (
|
|
86
|
+
<RenderedDialog
|
|
87
|
+
key={dialog.id}
|
|
88
|
+
ref={(ref: ManagedDialogRef) => {
|
|
89
|
+
if (ref) {
|
|
90
|
+
dialogRefs.current.set(dialog.id, ref);
|
|
91
|
+
}
|
|
92
|
+
}}
|
|
93
|
+
onClose={hide}
|
|
94
|
+
isOpen={true}
|
|
95
|
+
{...dialog}
|
|
96
|
+
/>
|
|
97
|
+
))}
|
|
98
|
+
{children}
|
|
99
|
+
</DialogContext.Provider>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export { DialogProvider };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DndProvider } from 'react-dnd';
|
|
3
|
+
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
4
|
+
|
|
5
|
+
// import TouchBackend from 'react-dnd-touch-backend';
|
|
6
|
+
|
|
7
|
+
// TODO: this is false when it should not be :thinking:
|
|
8
|
+
const isTouchDevice =
|
|
9
|
+
typeof window !== `undefined` && !!('ontouchstart' in window || navigator.maxTouchPoints);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Relevant:
|
|
13
|
+
* https://github.com/react-dnd/react-dnd/issues/186#issuecomment-335429067
|
|
14
|
+
* https://github.com/react-dnd/react-dnd/issues/186#issuecomment-282789420
|
|
15
|
+
*
|
|
16
|
+
* Docs:
|
|
17
|
+
* http://react-dnd.github.io/react-dnd/docs/api/drag-drop-context
|
|
18
|
+
*/
|
|
19
|
+
function DragAndDropProvider({ children }) {
|
|
20
|
+
const backend = HTML5Backend; // isTouchDevice ? TouchBackend : HTML5Backend;
|
|
21
|
+
const opts = {}; // isTouchDevice ? { enableMouseEvents: true } : {};
|
|
22
|
+
|
|
23
|
+
console.log('using... touch backend?', isTouchDevice);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<DndProvider
|
|
27
|
+
backend={backend}
|
|
28
|
+
opts={opts}
|
|
29
|
+
>
|
|
30
|
+
{children}
|
|
31
|
+
</DndProvider>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
export default DragAndDropProvider;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React, { createContext, useContext, ReactNode, ComponentType } from 'react';
|
|
2
|
+
import { cn } from '../utils';
|
|
3
|
+
import { Button } from '../components/Button';
|
|
4
|
+
|
|
5
|
+
export type IconSizeType = 'tiny' | 'small' | 'medium' | 'large' | number;
|
|
6
|
+
|
|
7
|
+
interface IconSizeContextType {
|
|
8
|
+
size: IconSizeType;
|
|
9
|
+
getSizeValue: (size?: IconSizeType) => number | string;
|
|
10
|
+
getSizeClassName: (size?: IconSizeType, additionalClasses?: string) => string;
|
|
11
|
+
IconContainer: ComponentType<any>;
|
|
12
|
+
containerProps: {
|
|
13
|
+
variant: string;
|
|
14
|
+
size: string;
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
};
|
|
17
|
+
className: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const sizeMap = {
|
|
21
|
+
tiny: 16,
|
|
22
|
+
small: 20,
|
|
23
|
+
medium: 24,
|
|
24
|
+
large: 28,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const getSizeValue = (size: IconSizeType = 'medium'): number | string => {
|
|
28
|
+
if (typeof size === 'number') {
|
|
29
|
+
return size;
|
|
30
|
+
}
|
|
31
|
+
return sizeMap[size] || sizeMap.medium;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const getSizeClassName = (size: IconSizeType = 'medium', additionalClasses = ''): string => {
|
|
35
|
+
const sizeValue = getSizeValue(size);
|
|
36
|
+
return cn(`h-[${sizeValue}px] w-[${sizeValue}px]`, additionalClasses);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const defaultContext: IconSizeContextType = {
|
|
40
|
+
size: 'medium',
|
|
41
|
+
getSizeValue,
|
|
42
|
+
getSizeClassName,
|
|
43
|
+
IconContainer: Button,
|
|
44
|
+
containerProps: {
|
|
45
|
+
variant: 'ghost',
|
|
46
|
+
size: 'icon',
|
|
47
|
+
},
|
|
48
|
+
className: '',
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const IconSizeContext = createContext<IconSizeContextType>(defaultContext);
|
|
52
|
+
|
|
53
|
+
interface IconPresentationProviderProps {
|
|
54
|
+
size: IconSizeType;
|
|
55
|
+
children: ReactNode;
|
|
56
|
+
IconContainer?: ComponentType<any>;
|
|
57
|
+
containerProps?: {
|
|
58
|
+
variant?: string;
|
|
59
|
+
size?: string;
|
|
60
|
+
[key: string]: any;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const IconPresentationProvider = ({
|
|
65
|
+
size,
|
|
66
|
+
children,
|
|
67
|
+
IconContainer = Button,
|
|
68
|
+
containerProps = {},
|
|
69
|
+
}: IconPresentationProviderProps) => {
|
|
70
|
+
const className = getSizeClassName(size);
|
|
71
|
+
const mergedProps = {
|
|
72
|
+
variant: 'ghost',
|
|
73
|
+
size: 'icon',
|
|
74
|
+
...containerProps,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const contextValue = {
|
|
78
|
+
size,
|
|
79
|
+
getSizeValue,
|
|
80
|
+
getSizeClassName,
|
|
81
|
+
IconContainer,
|
|
82
|
+
containerProps: mergedProps,
|
|
83
|
+
className,
|
|
84
|
+
};
|
|
85
|
+
return <IconSizeContext.Provider value={contextValue}>{children}</IconSizeContext.Provider>;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const useIconPresentation = () => useContext(IconSizeContext);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { ReactNode, createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
interface ImageViewerProviderProps {
|
|
4
|
+
StudyInstanceUIDs: string[];
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const ImageViewerContext = createContext(null);
|
|
9
|
+
export const useImageViewer = () => useContext(ImageViewerContext);
|
|
10
|
+
|
|
11
|
+
export function ImageViewerProvider({ StudyInstanceUIDs, children }: ImageViewerProviderProps) {
|
|
12
|
+
const value = { StudyInstanceUIDs };
|
|
13
|
+
|
|
14
|
+
return <ImageViewerContext.Provider value={value}>{children}</ImageViewerContext.Provider>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import React, { useState, useImperativeHandle, useCallback, useLayoutEffect, useRef } from 'react';
|
|
2
|
+
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '../components/Dialog/Dialog';
|
|
3
|
+
import { cn } from '../lib/utils';
|
|
4
|
+
|
|
5
|
+
type Position = {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export interface ManagedDialogProps {
|
|
11
|
+
id: string;
|
|
12
|
+
isOpen?: boolean;
|
|
13
|
+
title?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
content: React.ComponentType<{ hide?: () => void }>;
|
|
16
|
+
contentProps?: Record<string, unknown>;
|
|
17
|
+
isDraggable?: boolean;
|
|
18
|
+
shouldCloseOnEsc?: boolean;
|
|
19
|
+
shouldCloseOnOverlayClick?: boolean;
|
|
20
|
+
defaultPosition?: { x: number; y: number };
|
|
21
|
+
onClose?: (id: string) => void;
|
|
22
|
+
unstyled?: boolean;
|
|
23
|
+
showOverlay?: boolean;
|
|
24
|
+
containerClassName?: string;
|
|
25
|
+
ref?: React.Ref<ManagedDialogRef>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ManagedDialogRef {
|
|
29
|
+
updatePosition: (position: Position) => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const _updatePosition = (
|
|
33
|
+
contentNode: HTMLElement,
|
|
34
|
+
desiredPosition: { x: number; y: number },
|
|
35
|
+
setCurrentPosition: React.Dispatch<React.SetStateAction<Position>>
|
|
36
|
+
) => {
|
|
37
|
+
if (!contentNode || !desiredPosition) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Build a new position object: desiredPosition is often the defaultPosition
|
|
42
|
+
// prop or the current state value, and mutating it in place would leave the
|
|
43
|
+
// state reference unchanged, so React (and compiler-memoized JSX) would not
|
|
44
|
+
// re-render with the adjusted coordinates. The functional update bails out
|
|
45
|
+
// (returns the previous reference) when the coordinates are unchanged, so
|
|
46
|
+
// repeated calls - e.g. from a ref callback that is re-attached on every
|
|
47
|
+
// render - cannot start a setState loop.
|
|
48
|
+
const boundingClientRect = contentNode.getBoundingClientRect();
|
|
49
|
+
let { x, y } = desiredPosition;
|
|
50
|
+
if (boundingClientRect.bottom > window.innerHeight) {
|
|
51
|
+
y = y - boundingClientRect.height;
|
|
52
|
+
}
|
|
53
|
+
if (boundingClientRect.right > window.innerWidth) {
|
|
54
|
+
x = x - boundingClientRect.width;
|
|
55
|
+
}
|
|
56
|
+
setCurrentPosition(prev => (prev && prev.x === x && prev.y === y ? prev : { x, y }));
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const ManagedDialog = ({
|
|
60
|
+
id,
|
|
61
|
+
isOpen,
|
|
62
|
+
title,
|
|
63
|
+
content: DialogContentComponent,
|
|
64
|
+
contentProps,
|
|
65
|
+
isDraggable,
|
|
66
|
+
shouldCloseOnEsc = false,
|
|
67
|
+
shouldCloseOnOverlayClick = false,
|
|
68
|
+
showOverlay = true,
|
|
69
|
+
defaultPosition,
|
|
70
|
+
onClose,
|
|
71
|
+
unstyled,
|
|
72
|
+
containerClassName,
|
|
73
|
+
ref,
|
|
74
|
+
}: ManagedDialogProps) => {
|
|
75
|
+
const [currentPosition, setCurrentPosition] = useState(defaultPosition);
|
|
76
|
+
// The node is held in both state and a ref because the two consumers need
|
|
77
|
+
// different things: the layout effect below has to re-run when the node
|
|
78
|
+
// arrives (state), while the imperative handle needs to read the current node
|
|
79
|
+
// without being rebuilt (ref).
|
|
80
|
+
const [contentNode, setContentNode] = useState<HTMLElement | null>(null);
|
|
81
|
+
const contentNodeRef = useRef<HTMLElement | null>(null);
|
|
82
|
+
|
|
83
|
+
useImperativeHandle(
|
|
84
|
+
ref,
|
|
85
|
+
() => ({
|
|
86
|
+
updatePosition: (position: Position) => {
|
|
87
|
+
// Read through the ref, not the state captured when this handle was
|
|
88
|
+
// built: the handle is created once (empty deps) and at that point the
|
|
89
|
+
// node is always null, so closing over it made updatePosition a no-op
|
|
90
|
+
// for the lifetime of the dialog.
|
|
91
|
+
_updatePosition(contentNodeRef.current, position, setCurrentPosition);
|
|
92
|
+
},
|
|
93
|
+
}),
|
|
94
|
+
[]
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
// When a default position is provided, the assumption is that the position
|
|
99
|
+
// is respected unless the position chosen results in the dialog being
|
|
100
|
+
// clipped off-screen (i.e. part of the dialog is rendered outside the browser
|
|
101
|
+
// window). When the dialog is clipped it will be repositioned about
|
|
102
|
+
// the default position such that it is no longer clipped. To avoid a flash
|
|
103
|
+
// during the reposition, we initially hide the dialog.
|
|
104
|
+
const [contentVisibility, setContentVisibility] = useState(
|
|
105
|
+
defaultPosition ? 'invisible' : 'visible'
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
// Capture the dialog's DOM node. The ref chain below this component is
|
|
109
|
+
// re-created on renders (useDraggable composes an unmemoized ref), so this
|
|
110
|
+
// callback can fire repeatedly with the same node - the functional update
|
|
111
|
+
// bails to the previous reference in that case, so no render is scheduled.
|
|
112
|
+
const contentRef = useCallback(node => {
|
|
113
|
+
if (node) {
|
|
114
|
+
contentNodeRef.current = node;
|
|
115
|
+
setContentNode(prev => (prev === node ? prev : node));
|
|
116
|
+
}
|
|
117
|
+
}, []);
|
|
118
|
+
|
|
119
|
+
// Reposition an explicitly positioned dialog so it is not clipped by the
|
|
120
|
+
// window, then reveal it. A layout effect runs after the dialog content is
|
|
121
|
+
// laid out (so the measured size is real) but before paint (so there is no
|
|
122
|
+
// visible jump). Note that if the dialog is larger than the window (in
|
|
123
|
+
// either dimension), the dialog will still be clipped in some manner.
|
|
124
|
+
useLayoutEffect(() => {
|
|
125
|
+
if (!contentNode) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
_updatePosition(contentNode, defaultPosition, setCurrentPosition);
|
|
129
|
+
setContentVisibility('visible');
|
|
130
|
+
}, [contentNode, defaultPosition]);
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<Dialog
|
|
134
|
+
open={isOpen}
|
|
135
|
+
modal={false} // keep modal behavior off for independent windows
|
|
136
|
+
onOpenChange={open => {
|
|
137
|
+
if (!open) {
|
|
138
|
+
onClose(id);
|
|
139
|
+
}
|
|
140
|
+
}}
|
|
141
|
+
isDraggable={isDraggable}
|
|
142
|
+
shouldCloseOnEsc={shouldCloseOnEsc}
|
|
143
|
+
shouldCloseOnOverlayClick={shouldCloseOnOverlayClick}
|
|
144
|
+
showOverlay={showOverlay}
|
|
145
|
+
>
|
|
146
|
+
<DialogContent
|
|
147
|
+
ref={contentRef}
|
|
148
|
+
className={cn(unstyled ? 'p-0' : '', containerClassName, contentVisibility)}
|
|
149
|
+
unstyled={unstyled}
|
|
150
|
+
style={{
|
|
151
|
+
...(currentPosition
|
|
152
|
+
? {
|
|
153
|
+
position: 'fixed',
|
|
154
|
+
left: `${currentPosition.x}px`,
|
|
155
|
+
top: `${currentPosition.y}px`,
|
|
156
|
+
transform: 'translate(0, 0)',
|
|
157
|
+
margin: 0,
|
|
158
|
+
animation: 'none',
|
|
159
|
+
transition: 'none',
|
|
160
|
+
}
|
|
161
|
+
: {}),
|
|
162
|
+
}}
|
|
163
|
+
>
|
|
164
|
+
{!unstyled && <DialogHeader>{title && <DialogTitle>{title}</DialogTitle>}</DialogHeader>}
|
|
165
|
+
<DialogContentComponent
|
|
166
|
+
{...contentProps}
|
|
167
|
+
hide={() => onClose(id)}
|
|
168
|
+
/>
|
|
169
|
+
</DialogContent>
|
|
170
|
+
</Dialog>
|
|
171
|
+
);
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
ManagedDialog.displayName = 'ManagedDialog';
|
|
175
|
+
|
|
176
|
+
export default ManagedDialog;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import React, { useState, createContext, useContext, useCallback, useEffect } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
|
|
4
|
+
interface ModalOptions {
|
|
5
|
+
title?: string;
|
|
6
|
+
shouldCloseOnEsc?: boolean;
|
|
7
|
+
content?: React.ComponentType;
|
|
8
|
+
contentProps?: Record<string, unknown>;
|
|
9
|
+
containerClassName?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface ModalContextType {
|
|
13
|
+
show: (options: Partial<ModalOptions>) => void;
|
|
14
|
+
hide: () => void;
|
|
15
|
+
containerClassName?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface ModalComponentProps {
|
|
19
|
+
isOpen: boolean;
|
|
20
|
+
onClose: () => void;
|
|
21
|
+
title?: string;
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const ModalContext = createContext<ModalContextType | null>(null);
|
|
26
|
+
|
|
27
|
+
export const useModal = () => {
|
|
28
|
+
const ctx = useContext(ModalContext);
|
|
29
|
+
if (!ctx) {
|
|
30
|
+
throw new Error('useModal must be used within a ModalProvider');
|
|
31
|
+
}
|
|
32
|
+
return ctx;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const DEFAULT_OPTIONS: ModalOptions = {
|
|
36
|
+
title: '',
|
|
37
|
+
shouldCloseOnEsc: true,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
interface ModalService {
|
|
41
|
+
setServiceImplementation: (implementation: ModalContextType) => void;
|
|
42
|
+
getCustomComponent: () => React.ComponentType<ModalComponentProps> | null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface ModalProviderProps {
|
|
46
|
+
children: React.ReactNode;
|
|
47
|
+
modal: React.ComponentType<ModalComponentProps>;
|
|
48
|
+
service?: ModalService | null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const ModalProvider: React.FC<ModalProviderProps> = ({
|
|
52
|
+
children,
|
|
53
|
+
modal: ModalComponent,
|
|
54
|
+
service = null,
|
|
55
|
+
}) => {
|
|
56
|
+
const { t } = useTranslation('Modals');
|
|
57
|
+
const [options, setOptions] = useState<ModalOptions>(DEFAULT_OPTIONS);
|
|
58
|
+
|
|
59
|
+
const ModalContent = options.content;
|
|
60
|
+
|
|
61
|
+
const show = useCallback((props: Partial<ModalOptions>) => {
|
|
62
|
+
setOptions(prev => ({ ...prev, ...props }));
|
|
63
|
+
}, []);
|
|
64
|
+
|
|
65
|
+
const hide = useCallback(() => {
|
|
66
|
+
setOptions(DEFAULT_OPTIONS);
|
|
67
|
+
}, []);
|
|
68
|
+
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (service) {
|
|
71
|
+
service.setServiceImplementation({ show, hide });
|
|
72
|
+
}
|
|
73
|
+
}, [hide, service, show]);
|
|
74
|
+
|
|
75
|
+
const { title } = options;
|
|
76
|
+
|
|
77
|
+
const CustomModal = service?.getCustomComponent();
|
|
78
|
+
const RenderedModal = CustomModal || ModalComponent;
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<ModalContext.Provider value={{ show, hide }}>
|
|
82
|
+
{ModalContent && (
|
|
83
|
+
<RenderedModal
|
|
84
|
+
isOpen={true}
|
|
85
|
+
onClose={hide}
|
|
86
|
+
title={t(title)}
|
|
87
|
+
{...options}
|
|
88
|
+
>
|
|
89
|
+
<ModalContent
|
|
90
|
+
{...options.contentProps}
|
|
91
|
+
show={show}
|
|
92
|
+
hide={hide}
|
|
93
|
+
/>
|
|
94
|
+
</RenderedModal>
|
|
95
|
+
)}
|
|
96
|
+
{children}
|
|
97
|
+
</ModalContext.Provider>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export { ModalProvider };
|
|
102
|
+
export const ModalConsumer = ModalContext.Consumer;
|