@ohif/ui-next 3.14.0-beta.98 → 3.14.0-beta.99
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.umd.js +4 -1925
- package/package.json +18 -7
- 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,124 @@
|
|
|
1
|
+
import { createElement } from 'react';
|
|
2
|
+
import { fireEvent, render } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
import Numeric from './Numeric';
|
|
5
|
+
|
|
6
|
+
beforeAll(() => {
|
|
7
|
+
global.ResizeObserver = class ResizeObserver {
|
|
8
|
+
observe() {}
|
|
9
|
+
unobserve() {}
|
|
10
|
+
disconnect() {}
|
|
11
|
+
} as typeof global.ResizeObserver;
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const numericInputs = [
|
|
15
|
+
{
|
|
16
|
+
name: 'NumberInput',
|
|
17
|
+
mode: 'number',
|
|
18
|
+
child: () => createElement(Numeric.NumberInput),
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'SingleRange',
|
|
22
|
+
mode: 'singleRange',
|
|
23
|
+
child: () => createElement(Numeric.SingleRange, { showNumberInput: true }),
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'NumberStepper',
|
|
27
|
+
mode: 'stepper',
|
|
28
|
+
child: () => createElement(Numeric.NumberStepper),
|
|
29
|
+
},
|
|
30
|
+
] as const;
|
|
31
|
+
|
|
32
|
+
const renderNumericInput = ({ mode, child }) => {
|
|
33
|
+
const onChange = jest.fn();
|
|
34
|
+
const result = render(
|
|
35
|
+
createElement(
|
|
36
|
+
Numeric.Container,
|
|
37
|
+
{
|
|
38
|
+
mode,
|
|
39
|
+
min: 0,
|
|
40
|
+
max: 100,
|
|
41
|
+
defaultValue: 50,
|
|
42
|
+
onChange,
|
|
43
|
+
},
|
|
44
|
+
child()
|
|
45
|
+
)
|
|
46
|
+
);
|
|
47
|
+
const input = result.container.querySelector('input') as HTMLInputElement;
|
|
48
|
+
|
|
49
|
+
return { ...result, input, onChange };
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
describe.each(numericInputs)('Numeric.$name', numericInput => {
|
|
53
|
+
it('keeps draft text and commits only on Enter', () => {
|
|
54
|
+
const { input, onChange } = renderNumericInput(numericInput);
|
|
55
|
+
|
|
56
|
+
for (const value of ['', '-', '.', '1', '15', '150']) {
|
|
57
|
+
fireEvent.change(input, { target: { value } });
|
|
58
|
+
expect(input.value).toBe(value);
|
|
59
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
fireEvent.keyDown(input, { key: 'Enter' });
|
|
63
|
+
|
|
64
|
+
expect(input.value).toBe('100');
|
|
65
|
+
expect(onChange).toHaveBeenLastCalledWith(100);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('restores the last valid value when an invalid draft loses focus', () => {
|
|
69
|
+
const { input, onChange } = renderNumericInput(numericInput);
|
|
70
|
+
|
|
71
|
+
fireEvent.change(input, { target: { value: '-' } });
|
|
72
|
+
fireEvent.blur(input);
|
|
73
|
+
|
|
74
|
+
expect(input.value).toBe('50');
|
|
75
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('does not commit Enter while an IME composition is active', () => {
|
|
79
|
+
const { input, onChange } = renderNumericInput(numericInput);
|
|
80
|
+
|
|
81
|
+
fireEvent.change(input, { target: { value: '30' } });
|
|
82
|
+
fireEvent.keyDown(input, { key: 'Enter', isComposing: true });
|
|
83
|
+
|
|
84
|
+
expect(input.value).toBe('30');
|
|
85
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
86
|
+
|
|
87
|
+
fireEvent.keyDown(input, { key: 'Enter' });
|
|
88
|
+
|
|
89
|
+
expect(onChange).toHaveBeenLastCalledWith(30);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('updates the displayed input when the controlled value changes', () => {
|
|
93
|
+
const onChange = jest.fn();
|
|
94
|
+
const renderControlledInput = value =>
|
|
95
|
+
createElement(
|
|
96
|
+
Numeric.Container,
|
|
97
|
+
{
|
|
98
|
+
mode: numericInput.mode,
|
|
99
|
+
min: 0,
|
|
100
|
+
max: 100,
|
|
101
|
+
value,
|
|
102
|
+
onChange,
|
|
103
|
+
},
|
|
104
|
+
numericInput.child()
|
|
105
|
+
);
|
|
106
|
+
const result = render(renderControlledInput(50));
|
|
107
|
+
const input = result.container.querySelector('input') as HTMLInputElement;
|
|
108
|
+
|
|
109
|
+
fireEvent.change(input, { target: { value: 'draft' } });
|
|
110
|
+
result.rerender(renderControlledInput(75));
|
|
111
|
+
|
|
112
|
+
expect(input.value).toBe('75');
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('commits a valid Numeric.NumberInput draft on blur', () => {
|
|
117
|
+
const { input, onChange } = renderNumericInput(numericInputs[0]);
|
|
118
|
+
|
|
119
|
+
fireEvent.change(input, { target: { value: '30' } });
|
|
120
|
+
fireEvent.blur(input);
|
|
121
|
+
|
|
122
|
+
expect(input.value).toBe('30');
|
|
123
|
+
expect(onChange).toHaveBeenLastCalledWith(30);
|
|
124
|
+
});
|
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
// Numeric.tsx
|
|
2
|
+
import React, { createContext, useContext, useCallback, useState, PropsWithChildren } from 'react';
|
|
3
|
+
import { useControllableState } from '@radix-ui/react-use-controllable-state';
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
import { Input } from '../Input/Input';
|
|
6
|
+
import { Slider } from '../Slider/Slider';
|
|
7
|
+
import { DoubleSlider } from '../DoubleSlider/DoubleSlider';
|
|
8
|
+
import { Button } from '../Button/Button';
|
|
9
|
+
import { ChevronUp, ChevronDown, ChevronLeft, ChevronRight } from 'lucide-react';
|
|
10
|
+
|
|
11
|
+
// Calculate decimal places based on step
|
|
12
|
+
const getDecimalPlaces = (step: number): number => {
|
|
13
|
+
if (Number.isInteger(step)) {
|
|
14
|
+
return 0;
|
|
15
|
+
}
|
|
16
|
+
const stepStr = step.toString();
|
|
17
|
+
if (stepStr.includes('.')) {
|
|
18
|
+
return stepStr.split('.')[1].length;
|
|
19
|
+
}
|
|
20
|
+
return 0;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
interface NumericMetaContextValue {
|
|
24
|
+
mode: 'number' | 'singleRange' | 'doubleRange' | 'stepper';
|
|
25
|
+
singleValue: number;
|
|
26
|
+
doubleValue: [number, number];
|
|
27
|
+
setSingleValue: (val: number) => void;
|
|
28
|
+
setDoubleValue: (vals: [number, number]) => void;
|
|
29
|
+
min: number;
|
|
30
|
+
max: number;
|
|
31
|
+
allowTypedExpansion?: boolean | [number, number];
|
|
32
|
+
step: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const NumericMetaContext = createContext<NumericMetaContextValue | null>(null);
|
|
36
|
+
|
|
37
|
+
/* -------------------------------------------------------------------------
|
|
38
|
+
1) Container
|
|
39
|
+
---------------------------------------------------------------------------*/
|
|
40
|
+
interface NumericMetaContainerProps {
|
|
41
|
+
mode: 'number' | 'singleRange' | 'doubleRange' | 'stepper';
|
|
42
|
+
value?: number; // for controlled single-value usage from parent
|
|
43
|
+
defaultValue?: number; // for uncontrolled single-value usage
|
|
44
|
+
values?: [number, number]; // for controlled double-range usage from parent
|
|
45
|
+
defaultValues?: [number, number]; // for uncontrolled double-range usage
|
|
46
|
+
onChange?: (val: number | [number, number]) => void;
|
|
47
|
+
min?: number;
|
|
48
|
+
max?: number;
|
|
49
|
+
allowTypedExpansion?: boolean | [number, number];
|
|
50
|
+
step?: number;
|
|
51
|
+
className?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function NumericMetaContainer({
|
|
55
|
+
mode,
|
|
56
|
+
value,
|
|
57
|
+
defaultValue,
|
|
58
|
+
values,
|
|
59
|
+
defaultValues,
|
|
60
|
+
onChange,
|
|
61
|
+
min = 0,
|
|
62
|
+
max = 100,
|
|
63
|
+
allowTypedExpansion,
|
|
64
|
+
step = 1,
|
|
65
|
+
className,
|
|
66
|
+
children,
|
|
67
|
+
}: PropsWithChildren<NumericMetaContainerProps>) {
|
|
68
|
+
// Calculate default values based on min and max
|
|
69
|
+
const calculatedDefaultValue = defaultValue ?? min + (max - min) / 2;
|
|
70
|
+
const calculatedDefaultValues = defaultValues ?? [
|
|
71
|
+
min + (max - min) * 0.3,
|
|
72
|
+
min + (max - min) * 0.7,
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
// Use useControllableState for both single and double values
|
|
76
|
+
const [internalSingleValue, setInternalSingleValue] = useControllableState({
|
|
77
|
+
prop: mode === 'number' || mode === 'singleRange' || mode === 'stepper' ? value : undefined,
|
|
78
|
+
defaultProp: calculatedDefaultValue,
|
|
79
|
+
onChange: newVal => {
|
|
80
|
+
if (mode === 'number' || mode === 'singleRange' || mode === 'stepper') {
|
|
81
|
+
onChange?.(newVal);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const [internalDoubleValue, setInternalDoubleValue] = useControllableState({
|
|
87
|
+
prop: mode === 'doubleRange' ? values : undefined,
|
|
88
|
+
defaultProp: calculatedDefaultValues,
|
|
89
|
+
onChange: newVals => {
|
|
90
|
+
if (mode === 'doubleRange') {
|
|
91
|
+
onChange?.(newVals);
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const handleSingleChange = useCallback(
|
|
97
|
+
(newVal: number) => {
|
|
98
|
+
setInternalSingleValue(newVal);
|
|
99
|
+
},
|
|
100
|
+
[setInternalSingleValue]
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const handleDoubleChange = useCallback(
|
|
104
|
+
(newVals: [number, number]) => {
|
|
105
|
+
setInternalDoubleValue(newVals);
|
|
106
|
+
},
|
|
107
|
+
[setInternalDoubleValue]
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<NumericMetaContext.Provider
|
|
112
|
+
value={{
|
|
113
|
+
mode,
|
|
114
|
+
singleValue: internalSingleValue,
|
|
115
|
+
doubleValue: internalDoubleValue,
|
|
116
|
+
setSingleValue: handleSingleChange,
|
|
117
|
+
setDoubleValue: handleDoubleChange,
|
|
118
|
+
min,
|
|
119
|
+
max,
|
|
120
|
+
allowTypedExpansion,
|
|
121
|
+
step,
|
|
122
|
+
}}
|
|
123
|
+
>
|
|
124
|
+
<div className={cn('flex flex-col', className)}>{children}</div>
|
|
125
|
+
</NumericMetaContext.Provider>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* -------------------------------------------------------------------------
|
|
130
|
+
2) Label sub-component
|
|
131
|
+
---------------------------------------------------------------------------*/
|
|
132
|
+
interface NumericMetaLabelProps {
|
|
133
|
+
showValue?: boolean; // optionally show the current numeric value(s)
|
|
134
|
+
className?: string;
|
|
135
|
+
children: React.ReactNode;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function NumericMetaLabel({ children, showValue, className }: NumericMetaLabelProps) {
|
|
139
|
+
const ctx = useContext(NumericMetaContext);
|
|
140
|
+
if (!ctx) {
|
|
141
|
+
throw new Error('NumericMetaLabel must be used inside <Numeric.Container>.');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const { mode, singleValue, doubleValue } = ctx;
|
|
145
|
+
|
|
146
|
+
let displayedValue = '';
|
|
147
|
+
let valueClasses = '';
|
|
148
|
+
if (mode === 'number' || mode === 'singleRange' || mode === 'stepper') {
|
|
149
|
+
displayedValue = singleValue.toString();
|
|
150
|
+
valueClasses = 'w-10';
|
|
151
|
+
} else if (mode === 'doubleRange') {
|
|
152
|
+
displayedValue = `[${doubleValue[0]} - ${doubleValue[1]}]`;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<div className={cn('text-foreground flex text-base', className)}>
|
|
157
|
+
{children}
|
|
158
|
+
{showValue && (
|
|
159
|
+
<span className={cn('inline-block', valueClasses)}>{`: ${displayedValue}`}</span>
|
|
160
|
+
)}
|
|
161
|
+
</div>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* -------------------------------------------------------------------------
|
|
166
|
+
3) SingleRange sub-component
|
|
167
|
+
---------------------------------------------------------------------------*/
|
|
168
|
+
|
|
169
|
+
interface SingleRangeProps {
|
|
170
|
+
showNumberInput?: boolean;
|
|
171
|
+
sliderClassName?: string;
|
|
172
|
+
numberInputClassName?: string;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function SingleRange({ showNumberInput, sliderClassName, numberInputClassName }: SingleRangeProps) {
|
|
176
|
+
const ctx = useContext(NumericMetaContext);
|
|
177
|
+
if (!ctx) {
|
|
178
|
+
throw new Error('SingleRange must be used inside <Numeric.Container>.');
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const { mode, singleValue, setSingleValue, min, max, step } = ctx;
|
|
182
|
+
const [inputValue, setInputValue] = useState(singleValue.toString());
|
|
183
|
+
// Adjust prop-derived state before React commits a render with a stale displayed value.
|
|
184
|
+
// See https://react.dev/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes
|
|
185
|
+
const [prevValue, setPrevValue] = useState(singleValue);
|
|
186
|
+
if (prevValue !== singleValue) {
|
|
187
|
+
setPrevValue(singleValue);
|
|
188
|
+
setInputValue(singleValue.toString());
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const handleSliderChange = useCallback(
|
|
192
|
+
(val: number[]) => {
|
|
193
|
+
setSingleValue(val[0]);
|
|
194
|
+
},
|
|
195
|
+
[setSingleValue]
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
const commitInputValue = useCallback(() => {
|
|
199
|
+
const parsedValue = Number(inputValue);
|
|
200
|
+
if (inputValue.trim() === '' || !Number.isFinite(parsedValue)) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const boundedValue = Math.max(min, Math.min(parsedValue, max));
|
|
205
|
+
setSingleValue(boundedValue);
|
|
206
|
+
setInputValue(boundedValue.toString());
|
|
207
|
+
return true;
|
|
208
|
+
}, [inputValue, max, min, setSingleValue]);
|
|
209
|
+
|
|
210
|
+
const restorePreviousInputValue = useCallback(() => {
|
|
211
|
+
setInputValue(singleValue.toString());
|
|
212
|
+
}, [singleValue]);
|
|
213
|
+
|
|
214
|
+
const handleBlur = useCallback(() => {
|
|
215
|
+
if (!commitInputValue()) {
|
|
216
|
+
restorePreviousInputValue();
|
|
217
|
+
}
|
|
218
|
+
}, [commitInputValue, restorePreviousInputValue]);
|
|
219
|
+
|
|
220
|
+
const handleKeyDown = useCallback(
|
|
221
|
+
(event: React.KeyboardEvent<HTMLInputElement>) => {
|
|
222
|
+
if (event.nativeEvent.isComposing) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (event.key === 'Enter') {
|
|
227
|
+
event.preventDefault();
|
|
228
|
+
if (!commitInputValue()) {
|
|
229
|
+
restorePreviousInputValue();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
[commitInputValue, restorePreviousInputValue]
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
if (mode !== 'singleRange') {
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return (
|
|
241
|
+
<div className="flex flex-1 items-center space-x-2">
|
|
242
|
+
<Slider
|
|
243
|
+
className={cn('flex-1', sliderClassName)}
|
|
244
|
+
value={[singleValue]}
|
|
245
|
+
min={min}
|
|
246
|
+
max={max}
|
|
247
|
+
step={step}
|
|
248
|
+
onValueChange={handleSliderChange}
|
|
249
|
+
/>
|
|
250
|
+
{showNumberInput && (
|
|
251
|
+
<Input
|
|
252
|
+
type="text"
|
|
253
|
+
inputMode="decimal"
|
|
254
|
+
className={cn('w-[50px] shrink-0', numberInputClassName)}
|
|
255
|
+
value={inputValue}
|
|
256
|
+
onChange={event => setInputValue(event.target.value)}
|
|
257
|
+
onKeyDown={handleKeyDown}
|
|
258
|
+
onBlur={handleBlur}
|
|
259
|
+
/>
|
|
260
|
+
)}
|
|
261
|
+
</div>
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/* -------------------------------------------------------------------------
|
|
266
|
+
4) DoubleRange sub-component
|
|
267
|
+
---------------------------------------------------------------------------*/
|
|
268
|
+
interface DoubleRangeProps {
|
|
269
|
+
showNumberInputs?: boolean;
|
|
270
|
+
className?: string;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function DoubleRange({ showNumberInputs, className }: DoubleRangeProps) {
|
|
274
|
+
const ctx = useContext(NumericMetaContext);
|
|
275
|
+
if (!ctx) {
|
|
276
|
+
throw new Error('DoubleRange must be used inside <Numeric.Container>.');
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const { mode, doubleValue, setDoubleValue, min, max, allowTypedExpansion, step } = ctx;
|
|
280
|
+
|
|
281
|
+
const handleSliderChange = useCallback(
|
|
282
|
+
(values: [number, number]) => {
|
|
283
|
+
setDoubleValue(values);
|
|
284
|
+
},
|
|
285
|
+
[setDoubleValue]
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
if (mode !== 'doubleRange') {
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return (
|
|
293
|
+
<div className={cn('min-w-0 flex-1', className)}>
|
|
294
|
+
<DoubleSlider
|
|
295
|
+
min={min}
|
|
296
|
+
max={max}
|
|
297
|
+
allowTypedExpansion={allowTypedExpansion}
|
|
298
|
+
step={step}
|
|
299
|
+
defaultValue={doubleValue}
|
|
300
|
+
onValueChange={handleSliderChange}
|
|
301
|
+
showNumberInputs={showNumberInputs}
|
|
302
|
+
/>
|
|
303
|
+
</div>
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/* -------------------------------------------------------------------------
|
|
308
|
+
5) Basic NumberInput sub-component
|
|
309
|
+
---------------------------------------------------------------------------*/
|
|
310
|
+
interface NumberInputProps {
|
|
311
|
+
className?: string;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function NumberInput({ className }: NumberInputProps) {
|
|
315
|
+
const ctx = useContext(NumericMetaContext);
|
|
316
|
+
if (!ctx) {
|
|
317
|
+
throw new Error('NumberInput must be used inside <Numeric.Container>.');
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const { mode, singleValue, setSingleValue, min, max } = ctx;
|
|
321
|
+
const [inputValue, setInputValue] = useState(singleValue.toString());
|
|
322
|
+
// Adjust prop-derived state before React commits a render with a stale displayed value.
|
|
323
|
+
// See https://react.dev/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes
|
|
324
|
+
const [prevValue, setPrevValue] = useState(singleValue);
|
|
325
|
+
if (prevValue !== singleValue) {
|
|
326
|
+
setPrevValue(singleValue);
|
|
327
|
+
setInputValue(singleValue.toString());
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (mode !== 'number') {
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const commitInputValue = () => {
|
|
335
|
+
const parsedValue = Number(inputValue);
|
|
336
|
+
if (inputValue.trim() === '' || !Number.isFinite(parsedValue)) {
|
|
337
|
+
return false;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const boundedValue = Math.max(min, Math.min(parsedValue, max));
|
|
341
|
+
setSingleValue(boundedValue);
|
|
342
|
+
setInputValue(boundedValue.toString());
|
|
343
|
+
return true;
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
// Calculate width based on max value's length, with a minimum of 3 characters
|
|
347
|
+
const maxLength = Math.max(3, max?.toString().length ?? 3);
|
|
348
|
+
const calculatedWidth = `${maxLength + 1.5}ch`;
|
|
349
|
+
|
|
350
|
+
return (
|
|
351
|
+
<Input
|
|
352
|
+
type="text"
|
|
353
|
+
inputMode="decimal"
|
|
354
|
+
value={inputValue}
|
|
355
|
+
onChange={event => setInputValue(event.target.value)}
|
|
356
|
+
onKeyDown={event => {
|
|
357
|
+
if (event.nativeEvent.isComposing) {
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
if (event.key === 'Enter') {
|
|
362
|
+
event.preventDefault();
|
|
363
|
+
if (!commitInputValue()) {
|
|
364
|
+
setInputValue(singleValue.toString());
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}}
|
|
368
|
+
onBlur={() => {
|
|
369
|
+
if (!commitInputValue()) {
|
|
370
|
+
setInputValue(singleValue.toString());
|
|
371
|
+
}
|
|
372
|
+
}}
|
|
373
|
+
className={cn('min-w-[60px]', `w-[${calculatedWidth}]`, className)}
|
|
374
|
+
/>
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/* -------------------------------------------------------------------------
|
|
379
|
+
6) NumberStepper sub-component
|
|
380
|
+
---------------------------------------------------------------------------*/
|
|
381
|
+
interface NumberStepperProps {
|
|
382
|
+
className?: string;
|
|
383
|
+
children?: React.ReactNode;
|
|
384
|
+
direction?: 'horizontal' | 'vertical';
|
|
385
|
+
inputWidth?: string;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// Modified NumberStepper component to properly position left/right controls
|
|
389
|
+
function NumberStepper({ className, children, direction, inputWidth }: NumberStepperProps) {
|
|
390
|
+
const ctx = useContext(NumericMetaContext);
|
|
391
|
+
if (!ctx) {
|
|
392
|
+
throw new Error('NumberStepper must be used inside <Numeric.Container>.');
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const { mode, singleValue, setSingleValue, min, max, step } = ctx;
|
|
396
|
+
const decimalPlaces = getDecimalPlaces(step);
|
|
397
|
+
const formatDisplayValue = useCallback(
|
|
398
|
+
(value: number) => (decimalPlaces > 0 ? value.toFixed(decimalPlaces) : value.toString()),
|
|
399
|
+
[decimalPlaces]
|
|
400
|
+
);
|
|
401
|
+
const formattedSingleValue = formatDisplayValue(singleValue);
|
|
402
|
+
const [inputValue, setInputValue] = useState(formattedSingleValue);
|
|
403
|
+
// Adjust prop-derived state before React commits a render with a stale displayed value.
|
|
404
|
+
// See https://react.dev/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes
|
|
405
|
+
const [prevFormattedValue, setPrevFormattedValue] = useState(formattedSingleValue);
|
|
406
|
+
if (prevFormattedValue !== formattedSingleValue) {
|
|
407
|
+
setPrevFormattedValue(formattedSingleValue);
|
|
408
|
+
setInputValue(formattedSingleValue);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
if (mode !== 'stepper') {
|
|
412
|
+
return null;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
const commitInputValue = () => {
|
|
416
|
+
const parsedValue = Number(inputValue);
|
|
417
|
+
if (inputValue.trim() === '' || !Number.isFinite(parsedValue)) {
|
|
418
|
+
return false;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
const boundedValue = Math.max(min, Math.min(parsedValue, max));
|
|
422
|
+
setSingleValue(boundedValue);
|
|
423
|
+
setInputValue(formatDisplayValue(boundedValue));
|
|
424
|
+
return true;
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
const handleBlur = () => {
|
|
428
|
+
if (!commitInputValue()) {
|
|
429
|
+
setInputValue(formatDisplayValue(singleValue));
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
|
|
434
|
+
if (event.nativeEvent.isComposing) {
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
if (event.key === 'Enter') {
|
|
439
|
+
event.preventDefault();
|
|
440
|
+
if (!commitInputValue()) {
|
|
441
|
+
setInputValue(formatDisplayValue(singleValue));
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
// Check if children is HorizontalControls component
|
|
447
|
+
const hasHorizontalControls = direction === 'horizontal';
|
|
448
|
+
|
|
449
|
+
if (hasHorizontalControls) {
|
|
450
|
+
// We'll handle the control positioning ourselves
|
|
451
|
+
return (
|
|
452
|
+
<div
|
|
453
|
+
className={cn(
|
|
454
|
+
'bg-background border-input flex h-[28px] items-center overflow-hidden rounded-md border',
|
|
455
|
+
className
|
|
456
|
+
)}
|
|
457
|
+
>
|
|
458
|
+
<LeftControl
|
|
459
|
+
min={min}
|
|
460
|
+
step={step}
|
|
461
|
+
value={singleValue}
|
|
462
|
+
setValue={setSingleValue}
|
|
463
|
+
/>
|
|
464
|
+
<Input
|
|
465
|
+
type="text"
|
|
466
|
+
inputMode="decimal"
|
|
467
|
+
value={inputValue}
|
|
468
|
+
onChange={event => setInputValue(event.target.value)}
|
|
469
|
+
onKeyDown={handleKeyDown}
|
|
470
|
+
onBlur={handleBlur}
|
|
471
|
+
className={cn(
|
|
472
|
+
'h-6 appearance-none border-none p-0 text-center shadow-none focus:border-none focus:outline-none',
|
|
473
|
+
inputWidth
|
|
474
|
+
)}
|
|
475
|
+
/>
|
|
476
|
+
{children}
|
|
477
|
+
<RightControl
|
|
478
|
+
max={max}
|
|
479
|
+
step={step}
|
|
480
|
+
value={singleValue}
|
|
481
|
+
setValue={setSingleValue}
|
|
482
|
+
/>
|
|
483
|
+
</div>
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
return (
|
|
488
|
+
<div
|
|
489
|
+
className={cn(
|
|
490
|
+
'bg-background border-input flex items-center overflow-hidden rounded-md border',
|
|
491
|
+
className
|
|
492
|
+
)}
|
|
493
|
+
>
|
|
494
|
+
<Input
|
|
495
|
+
type="text"
|
|
496
|
+
inputMode="decimal"
|
|
497
|
+
value={inputValue}
|
|
498
|
+
onChange={event => setInputValue(event.target.value)}
|
|
499
|
+
onKeyDown={handleKeyDown}
|
|
500
|
+
onBlur={handleBlur}
|
|
501
|
+
className={cn(
|
|
502
|
+
'h-6 appearance-none border-none p-0 text-center shadow-none focus:border-none focus:outline-none',
|
|
503
|
+
inputWidth ? inputWidth : 'max-w-12 min-w-0'
|
|
504
|
+
)}
|
|
505
|
+
/>
|
|
506
|
+
<div className="ml-1 flex flex-shrink-0 flex-col">
|
|
507
|
+
<Button
|
|
508
|
+
variant="ghost"
|
|
509
|
+
size="icon"
|
|
510
|
+
onClick={() => setSingleValue(singleValue + step)}
|
|
511
|
+
disabled={singleValue >= max}
|
|
512
|
+
className="text-primary h-3 w-5"
|
|
513
|
+
>
|
|
514
|
+
<ChevronUp className="h-3 w-3" />
|
|
515
|
+
</Button>
|
|
516
|
+
<Button
|
|
517
|
+
variant="ghost"
|
|
518
|
+
size="icon"
|
|
519
|
+
onClick={() => setSingleValue(singleValue - step)}
|
|
520
|
+
disabled={singleValue <= min}
|
|
521
|
+
className="text-primary h-3 w-5"
|
|
522
|
+
>
|
|
523
|
+
<ChevronDown className="h-3 w-3" />
|
|
524
|
+
</Button>
|
|
525
|
+
</div>
|
|
526
|
+
</div>
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// New components for left and right controls
|
|
531
|
+
function LeftControl({ min, step, value, setValue }) {
|
|
532
|
+
const decrement = useCallback(() => {
|
|
533
|
+
const newValue = Math.max(value - step, min);
|
|
534
|
+
setValue(newValue);
|
|
535
|
+
}, [value, min, step, setValue]);
|
|
536
|
+
|
|
537
|
+
return (
|
|
538
|
+
<Button
|
|
539
|
+
variant="ghost"
|
|
540
|
+
size="icon"
|
|
541
|
+
onClick={decrement}
|
|
542
|
+
className="text-primary h-full w-4 cursor-pointer p-0"
|
|
543
|
+
>
|
|
544
|
+
<ChevronLeft className="h-4 w-4" />
|
|
545
|
+
</Button>
|
|
546
|
+
);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
function RightControl({ max, step, value, setValue }) {
|
|
550
|
+
const increment = useCallback(() => {
|
|
551
|
+
const newValue = Math.min(value + step, max);
|
|
552
|
+
setValue(newValue);
|
|
553
|
+
}, [value, max, step, setValue]);
|
|
554
|
+
|
|
555
|
+
return (
|
|
556
|
+
<Button
|
|
557
|
+
variant="ghost"
|
|
558
|
+
size="icon"
|
|
559
|
+
onClick={increment}
|
|
560
|
+
className="text-primary h-full w-4 cursor-pointer p-0"
|
|
561
|
+
>
|
|
562
|
+
<ChevronRight className="h-4 w-4" />
|
|
563
|
+
</Button>
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
export const Numeric = {
|
|
568
|
+
Container: NumericMetaContainer,
|
|
569
|
+
Label: NumericMetaLabel,
|
|
570
|
+
SingleRange,
|
|
571
|
+
DoubleRange,
|
|
572
|
+
NumberInput,
|
|
573
|
+
NumberStepper,
|
|
574
|
+
};
|
|
575
|
+
|
|
576
|
+
export default Numeric;
|